From 28dc207f5f877fcb2cff43367f7a84a45fdec630 Mon Sep 17 00:00:00 2001 From: Peter Maydell Date: Sat, 16 Sep 2017 17:46:17 +0100 Subject: hw/i2c/omap_i2c.c: Don't use old_mmio Don't use old_mmio in the memory region ops struct. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 1505580378-9044-6-git-send-email-peter.maydell@linaro.org --- hw/i2c/omap_i2c.c | 44 ++++++++++++++++++++++++++++++++------------ 1 file changed, 32 insertions(+), 12 deletions(-) (limited to 'hw') diff --git a/hw/i2c/omap_i2c.c b/hw/i2c/omap_i2c.c index f6e80bee25..12264ee0f5 100644 --- a/hw/i2c/omap_i2c.c +++ b/hw/i2c/omap_i2c.c @@ -430,19 +430,39 @@ static void omap_i2c_writeb(void *opaque, hwaddr addr, } } +static uint64_t omap_i2c_readfn(void *opaque, hwaddr addr, + unsigned size) +{ + switch (size) { + case 2: + return omap_i2c_read(opaque, addr); + default: + return omap_badwidth_read16(opaque, addr); + } +} + +static void omap_i2c_writefn(void *opaque, hwaddr addr, + uint64_t value, unsigned size) +{ + switch (size) { + case 1: + /* Only the last fifo write can be 8 bit. */ + omap_i2c_writeb(opaque, addr, value); + break; + case 2: + omap_i2c_write(opaque, addr, value); + break; + default: + omap_badwidth_write16(opaque, addr, value); + break; + } +} + static const MemoryRegionOps omap_i2c_ops = { - .old_mmio = { - .read = { - omap_badwidth_read16, - omap_i2c_read, - omap_badwidth_read16, - }, - .write = { - omap_i2c_writeb, /* Only the last fifo write can be 8 bit. */ - omap_i2c_write, - omap_badwidth_write16, - }, - }, + .read = omap_i2c_readfn, + .write = omap_i2c_writefn, + .valid.min_access_size = 1, + .valid.max_access_size = 4, .endianness = DEVICE_NATIVE_ENDIAN, }; -- cgit v1.2.3