summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorDinh Nguyen <r00091@freescale.com>2009-09-01 11:12:12 -0500
committerDinh Nguyen <r00091@freescale.com>2009-09-01 11:30:17 -0500
commit27f1b60875b736e73e6f7a8db305368995051de7 (patch)
treed2b63e4da50439ce56998b86466678bf3f8e3685 /drivers
parentc7c619b467c410721535d377fef02776031e5659 (diff)
ENGR00116103 Need to poll I2C Busy bit after a repeat-start signal
Errors on the I2C lines when the Busy bit was not being polled during a repeat-start transaction. Signed-off-by: Dinh Nguyen <Dinh.Nguyen@freescale.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/i2c/busses/mxc_i2c.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/drivers/i2c/busses/mxc_i2c.c b/drivers/i2c/busses/mxc_i2c.c
index 54dd0f1dec65..689ed1ec0c1d 100644
--- a/drivers/i2c/busses/mxc_i2c.c
+++ b/drivers/i2c/busses/mxc_i2c.c
@@ -235,10 +235,11 @@ static int mxc_i2c_start(mxc_i2c_device *dev, struct i2c_msg *msg)
* @param *msg pointer to a message structure that contains the slave
* address
*/
-static void mxc_i2c_repstart(mxc_i2c_device * dev, struct i2c_msg *msg)
+static void mxc_i2c_repstart(mxc_i2c_device *dev, struct i2c_msg *msg)
{
- volatile unsigned int cr;
+ volatile unsigned int cr, sr;
unsigned int addr_trans;
+ int retry = 16;
/*
* Set the slave address and the requested transfer mode
@@ -251,7 +252,16 @@ static void mxc_i2c_repstart(mxc_i2c_device * dev, struct i2c_msg *msg)
cr = readw(dev->membase + MXC_I2CR);
cr |= MXC_I2CR_RSTA;
writew(cr, dev->membase + MXC_I2CR);
- udelay(3);
+ /* Wait till the Bus Busy bit is set */
+ sr = readw(dev->membase + MXC_I2SR);
+ while (retry-- && (!(sr & MXC_I2SR_IBB))) {
+ udelay(3);
+ sr = readw(dev->membase + MXC_I2SR);
+ }
+ if (retry <= 0) {
+ dev_err(&dev->adap.dev, "Could not grab Bus ownership\n");
+ return -EBUSY;
+ }
writew(addr_trans, dev->membase + MXC_I2DR);
}