aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlok Chauhan <alokc@nvidia.com>2012-04-02 01:53:02 -0400
committerWolfram Sang <w.sang@pengutronix.de>2012-04-22 15:29:05 -0400
commitf70893d08338b9cab8008d2e30404ce58930a513 (patch)
tree69ae57606254ebe2598791895cea425143f25d41
parent6c557cfee08751d22aed34840f389b846f0f4508 (diff)
i2c: tegra: Add delay before resetting the controller after NACK
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>
-rw-r--r--drivers/i2c/busses/i2c-tegra.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c
index e978635e60f0..55e5ea62ccee 100644
--- a/drivers/i2c/busses/i2c-tegra.c
+++ b/drivers/i2c/busses/i2c-tegra.c
@@ -516,6 +516,14 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev,
516 if (likely(i2c_dev->msg_err == I2C_ERR_NONE)) 516 if (likely(i2c_dev->msg_err == I2C_ERR_NONE))
517 return 0; 517 return 0;
518 518
519 /*
520 * NACK interrupt is generated before the I2C controller generates the
521 * STOP condition on the bus. So wait for 2 clock periods before resetting
522 * the controller so that STOP condition has been delivered properly.
523 */
524 if (i2c_dev->msg_err == I2C_ERR_NO_ACK)
525 udelay(DIV_ROUND_UP(2 * 1000000, i2c_dev->bus_clk_rate));
526
519 tegra_i2c_init(i2c_dev); 527 tegra_i2c_init(i2c_dev);
520 if (i2c_dev->msg_err == I2C_ERR_NO_ACK) { 528 if (i2c_dev->msg_err == I2C_ERR_NO_ACK) {
521 if (msg->flags & I2C_M_IGNORE_NAK) 529 if (msg->flags & I2C_M_IGNORE_NAK)