1
From 093f316f0db143475efeec7ed06debb2c87495a9 Mon Sep 17 00:00:00 2001
2
From: Matt Waddel <matt.waddel@ubuntu.com>
3
Date: Mon, 18 Feb 2013 16:58:26 +0000
4
Subject: [PATCH 21/70] omap_i2c.c: Support byte reads to registers
6
Added support for the byte read of the omap i2c system.
7
Handling is similar to the way i2c_write and i2c_writeb work.
9
hw/i2c/omap_i2c.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
10
1 file changed, 56 insertions(+), 1 deletion(-)
12
diff --git a/hw/i2c/omap_i2c.c b/hw/i2c/omap_i2c.c
13
index 9a1b0d2..0278390 100644
14
--- a/hw/i2c/omap_i2c.c
15
+++ b/hw/i2c/omap_i2c.c
16
@@ -326,6 +326,61 @@ static uint32_t omap_i2c_read(void *opaque, hwaddr addr)
20
+static uint32_t omap_i2c_readb(void *opaque, hwaddr addr)
22
+ OMAPI2CState *s = opaque;
23
+ int offset = addr & OMAP_MPUI_REG_MASK;
27
+ case 0x1c: /* I2C_DATA */
30
+ if (s->revision < OMAP3_INTR_REV) {
31
+ if (s->control & (1 << 14)) /* BE */
32
+ ret = (((uint8_t)s->fifo[s->fifostart]) << 8)
33
+ | s->fifo[(s->fifostart + 1) & I2C_FIFO_SIZE_MASK];
35
+ ret = (((uint8_t)s->fifo[(s->fifostart + 1) & I2C_FIFO_SIZE_MASK]) << 8)
36
+ | s->fifo[s->fifostart];
37
+ s->fifostart = (s->fifostart + 2) & I2C_FIFO_SIZE_MASK;
38
+ if (s->fifolen == 1) {
39
+ s->stat |= 1 << 15; /* SBD */
44
+ s->stat &= ~(1 << 3); /* RRDY */
45
+ s->stat |= 1 << 2; /* ARDY */
48
+ s->stat &= ~(1 << 7); /* AERR */
49
+ ret = (uint8_t)s->fifo[s->fifostart++];
50
+ s->fifostart &= I2C_FIFO_SIZE_MASK;
52
+ if (s->fifolen <= ((s->dma >> 8) & 0x3f)) {
53
+ s->stat &= ~(1 << 3); /* RRDY */
54
+ s->stat |= 1 << 13; /* RDR */
57
+ s->stat &= ~((1 << 3) | (1 << 13)); /* RRDY | RDR */
58
+ s->stat |= 1 << 2; /* ARDY */
61
+ s->stat &= ~(1 << 11); /* ROVR */
62
+ } else if (s->revision >= OMAP3_INTR_REV)
63
+ s->stat |= (1 << 7); /* AERR */
64
+ omap_i2c_fifo_run(s);
65
+ omap_i2c_interrupts_update(s);
75
static void omap_i2c_write(void *opaque, hwaddr addr,
78
@@ -589,7 +644,7 @@ static void omap_i2c_writeb(void *opaque, hwaddr addr,
79
static const MemoryRegionOps omap_i2c_ops = {
82
- omap_badwidth_read16,