i2c-imx: fix clear IFF race condition
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@pengutronix.de>
This commit is contained in:
parent
ed85e6d361
commit
6d34576586
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue