Skip to content

Commit

Permalink
i2c: tegra: Add delay before resetting the controller after NACK
Browse files Browse the repository at this point in the history
NACK interrupt is generated before I2C controller generates the STOP
condition on bus. Because of this reset of controller is happening
before I2C controller could complete STOP condition. So wait for some
time before resetting the controller so that STOP condition has
delivered properly on bus.

Added delay of 2 clock period before resetting the controller in case of
NACK error.

Signed-off-by: Alok Chauhan <alokc@nvidia.com>
Acked-by: Stephen Warren <swarren@wwwdotorg.org>

[wsa: Reworded the commit msg and code comment a bit]

Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
  • Loading branch information
Alok Chauhan authored and Wolfram Sang committed Apr 22, 2012
1 parent 6c557cf commit f70893d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions drivers/i2c/busses/i2c-tegra.c
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,14 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev,
if (likely(i2c_dev->msg_err == I2C_ERR_NONE))
return 0;

/*
* NACK interrupt is generated before the I2C controller generates the
* STOP condition on the bus. So wait for 2 clock periods before resetting
* the controller so that STOP condition has been delivered properly.
*/
if (i2c_dev->msg_err == I2C_ERR_NO_ACK)
udelay(DIV_ROUND_UP(2 * 1000000, i2c_dev->bus_clk_rate));

tegra_i2c_init(i2c_dev);
if (i2c_dev->msg_err == I2C_ERR_NO_ACK) {
if (msg->flags & I2C_M_IGNORE_NAK)
Expand Down

0 comments on commit f70893d

Please sign in to comment.