i2c-omap: OMAP3430 Silicon Errata 1.153
authorSonasath, Moiz <m-sonasath@ti.com>
Tue, 21 Jul 2009 15:15:12 +0000 (10:15 -0500)
committerBen Dooks <ben-linux@fluff.org>
Thu, 30 Jul 2009 00:03:24 +0000 (01:03 +0100)
When an XRDY/XDR is hit, wait for XUDF before writing data to DATA_REG.
Otherwise some data bytes can be lost while transferring them from the
memory to the I2C interface.

Do a Busy-wait for XUDF, before writing data to DATA_REG. While waiting
if there is NACK | AL, set the appropriate error flags, ack the pending
interrupts and return from the ISR.

Signed-off-by: Moiz Sonasath <m-sonasath@ti.com>
Signed-off-by: Vikram pandita <vikram.pandita@ti.com>
[ben-linux@fluff.org: fixed mail format and added i2c-omap to subject]
Signed-off-by: Ben Dooks <ben-linux@fluff.org>
drivers/i2c/busses/i2c-omap.c

index 5c508ccf4384fa1d0f496ee17a5dcaba45b3734f..d258b02aef44c4ef99c38d58b5da84a2d943b3c6 100644 (file)
@@ -672,9 +672,10 @@ omap_i2c_isr(int this_irq, void *dev_id)
                        break;
                }
 
+               err = 0;
+complete:
                omap_i2c_write_reg(dev, OMAP_I2C_STAT_REG, stat);
 
-               err = 0;
                if (stat & OMAP_I2C_STAT_NACK) {
                        err |= OMAP_I2C_STAT_NACK;
                        omap_i2c_write_reg(dev, OMAP_I2C_CON_REG,
@@ -764,6 +765,27 @@ omap_i2c_isr(int this_irq, void *dev_id)
                                                        "data to send\n");
                                        break;
                                }
+
+                               /*
+                                * OMAP3430 Errata 1.153: When an XRDY/XDR
+                                * is hit, wait for XUDF before writing data
+                                * to DATA_REG. Otherwise some data bytes can
+                                * be lost while transferring them from the
+                                * memory to the I2C interface.
+                                */
+
+                               if (cpu_is_omap34xx()) {
+                                               while (!(stat & OMAP_I2C_STAT_XUDF)) {
+                                                       if (stat & (OMAP_I2C_STAT_NACK | OMAP_I2C_STAT_AL)) {
+                                                               omap_i2c_ack_stat(dev, stat & (OMAP_I2C_STAT_XRDY | OMAP_I2C_STAT_XDR));
+                                                               err |= OMAP_I2C_STAT_XUDF;
+                                                               goto complete;
+                                                       }
+                                                       cpu_relax();
+                                                       stat = omap_i2c_read_reg(dev, OMAP_I2C_STAT_REG);
+                                               }
+                               }
+
                                omap_i2c_write_reg(dev, OMAP_I2C_DATA_REG, w);
                        }
                        omap_i2c_ack_stat(dev,