aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c/busses/i2c-omap.c
diff options
context:
space:
mode:
authorAlexander Shishkin <virtuoso@slind.org>2010-05-11 14:35:14 -0400
committerBen Dooks <ben-linux@fluff.org>2010-05-19 19:18:59 -0400
commit2dd151ab2792cd27a2268a6e4f3248193beed504 (patch)
treee12ad3c787db9770db5850e163ef1875127bb1ce /drivers/i2c/busses/i2c-omap.c
parent20c9d2c4ab8243a1c311248232954b2c1da3ba75 (diff)
omap: i2c: make errata 1.153 workaround a separate function
This is to avoid insanely long lines and levels of indentation. Signed-off-by: Alexander Shishkin <virtuoso@slind.org> Cc: Nishant Menon <nm@ti.com> Signed-off-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Diffstat (limited to 'drivers/i2c/busses/i2c-omap.c')
-rw-r--r--drivers/i2c/busses/i2c-omap.c43
1 files changed, 24 insertions, 19 deletions
diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index 42c0b9108c7f..ef73483efb84 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -756,6 +756,27 @@ omap_i2c_rev1_isr(int this_irq, void *dev_id)
756#define omap_i2c_rev1_isr NULL 756#define omap_i2c_rev1_isr NULL
757#endif 757#endif
758 758
759/*
760 * OMAP3430 Errata 1.153: When an XRDY/XDR is hit, wait for XUDF before writing
761 * data to DATA_REG. Otherwise some data bytes can be lost while transferring
762 * them from the memory to the I2C interface.
763 */
764static int errata_omap3_1p153(struct omap_i2c_dev *dev, u16 *stat, int *err)
765{
766 while (!(*stat & OMAP_I2C_STAT_XUDF)) {
767 if (*stat & (OMAP_I2C_STAT_NACK | OMAP_I2C_STAT_AL)) {
768 omap_i2c_ack_stat(dev, *stat & (OMAP_I2C_STAT_XRDY |
769 OMAP_I2C_STAT_XDR));
770 *err |= OMAP_I2C_STAT_XUDF;
771 return -ETIMEDOUT;
772 }
773 cpu_relax();
774 *stat = omap_i2c_read_reg(dev, OMAP_I2C_STAT_REG);
775 }
776
777 return 0;
778}
779
759static irqreturn_t 780static irqreturn_t
760omap_i2c_isr(int this_irq, void *dev_id) 781omap_i2c_isr(int this_irq, void *dev_id)
761{ 782{
@@ -885,25 +906,9 @@ complete:
885 break; 906 break;
886 } 907 }
887 908
888 /* 909 if ((dev->rev <= OMAP_I2C_REV_ON_3430) &&
889 * OMAP3430 Errata 1.153: When an XRDY/XDR 910 errata_omap3_1p153(dev, &stat, &err))
890 * is hit, wait for XUDF before writing data 911 goto complete;
891 * to DATA_REG. Otherwise some data bytes can
892 * be lost while transferring them from the
893 * memory to the I2C interface.
894 */
895
896 if (dev->rev <= OMAP_I2C_REV_ON_3430) {
897 while (!(stat & OMAP_I2C_STAT_XUDF)) {
898 if (stat & (OMAP_I2C_STAT_NACK | OMAP_I2C_STAT_AL)) {
899 omap_i2c_ack_stat(dev, stat & (OMAP_I2C_STAT_XRDY | OMAP_I2C_STAT_XDR));
900 err |= OMAP_I2C_STAT_XUDF;
901 goto complete;
902 }
903 cpu_relax();
904 stat = omap_i2c_read_reg(dev, OMAP_I2C_STAT_REG);
905 }
906 }
907 912
908 omap_i2c_write_reg(dev, OMAP_I2C_DATA_REG, w); 913 omap_i2c_write_reg(dev, OMAP_I2C_DATA_REG, w);
909 } 914 }