[PATCH 2/4] i2c-imx: fix clear IFF race condition
Marc Kleine-Budde
mkl at pengutronix.de
Wed Dec 9 09:42:32 EST 2009
During i2c read the original pattern was:
1. write i2c slave address
2. wait for transmit complete + clear IIF
3. wait for receive acknowledge
4. wait for IIF interrupt
Due to the clear of the I2SR register, the IIF flag was cleared, too. So
in step 4 the Interrupt wasn't detected. To fix this problem, we move
the clean of IIF before the writing of the slave address. So that it
looks this way:
0. clear IIF
1. write i2c slave address
2. wait for transmit complete
3. wait for receive acknowledge
4. wait for IIF interrupt
Signed-off-by: Marc Kleine-Budde <mkl at pengutronix.de>
---
drivers/i2c/i2c-imx.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/i2c/i2c-imx.c b/drivers/i2c/i2c-imx.c
index 387c598..14d5260 100644
--- a/drivers/i2c/i2c-imx.c
+++ b/drivers/i2c/i2c-imx.c
@@ -177,8 +177,6 @@ static int i2c_imx_trx_complete(struct i2c_adapter *adapter)
dev_err(adapter->dev, "<%s> TXR timeout\n", __func__);
return -EIO;
}
-
- writeb(0x0, base + IMX_I2C_I2SR);
}
return 0;
@@ -360,6 +358,9 @@ static int i2c_imx_read(struct i2c_adapter *adapter, struct i2c_msg *msgs)
"<%s> write slave address: addr=0x%02x\n",
__func__, (msgs->addr << 1) | 0x01);
+ /* clear IIF */
+ writeb(0x0, base + IMX_I2C_I2SR);
+
/* write slave address */
writeb((msgs->addr << 1) | 0x01, base + IMX_I2C_I2DR);
--
1.6.5.4
More information about the u-boot-v2
mailing list