diff options
author | Marc Reilly <marc@cpdesign.com.au> | 2010-10-01 14:30:59 +1000 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2010-10-01 10:01:14 +0200 |
commit | b82ee742d0e1190a3e61098b7f32b30938c3c0a8 (patch) | |
tree | 53a9f9c115ad03c15da2602a4a6bbd5bc1043592 | |
parent | 056dd7906fa19cd153c57fd36ae0b6a982e91199 (diff) | |
download | barebox-b82ee742d0e1190a3e61098b7f32b30938c3c0a8.tar.gz barebox-b82ee742d0e1190a3e61098b7f32b30938c3c0a8.tar.xz |
i2c-imx: wait for STOP before disabling controller
Makes sure that the STOP condition is transmitted before the I2C
controller is disabled.
This fixes a problem where writing to an external EEPROM was not working
because the EEPROM waits until the STOP before initiating the write
internally.
Signed-off-by: Marc Reilly <marc@cpdesign.com.au>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r-- | drivers/i2c/busses/i2c-imx.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c index cc64d943c1..266cb52c0c 100644 --- a/drivers/i2c/busses/i2c-imx.c +++ b/drivers/i2c/busses/i2c-imx.c @@ -265,7 +265,9 @@ static void i2c_imx_stop(struct i2c_adapter *adapter) temp = readb(base + IMX_I2C_I2CR); temp &= ~(I2CR_MSTA | I2CR_MTX); writeb(temp, base + IMX_I2C_I2CR); - i2c_imx->stopped = 1; + /* wait for the stop condition to be send, otherwise the i2c + * controller is disabled before the STOP is sent completely */ + i2c_imx->stopped = i2c_imx_bus_busy(adapter, 0) ? 0 : 1; } if (cpu_is_mx1()) { /* @@ -275,11 +277,9 @@ static void i2c_imx_stop(struct i2c_adapter *adapter) udelay(i2c_imx->disable_delay); } - if (!i2c_imx->stopped) - i2c_imx_bus_busy(adapter, 0); - - /* Disable I2C controller */ + /* Disable I2C controller, and force our state to stopped */ writeb(0, base + IMX_I2C_I2CR); + i2c_imx->stopped = 1; } static void i2c_imx_set_clk(struct imx_i2c_struct *i2c_imx, |