linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] i2c: tegra: Add delay before reset the controller
@ 2012-04-02  5:53 Alok Chauhan
  2012-04-02  5:59 ` Alok Chauhan
                   ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: Alok Chauhan @ 2012-04-02  5:53 UTC (permalink / raw)
  To: swarren, khali, ben-linux, w.sang, swarren, olof, bones,
	omaplinuxkernel, ccross, ldewangan, linux-tegra, linux-i2c,
	dgreid
  Cc: alokc, linux-kernel

NACK interrupt generated before I2C controller generates
the STOP condition on bus. In Software, 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 reset the
controller in case of NACK error.

Signed-off-by: Alok Chauhan <alokc@nvidia.com>
---
Added the more descriptive commit message about issue in case
of NACK error condition. Changed the comment in code also

 drivers/i2c/busses/i2c-tegra.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c
index e978635..dfb850a8 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,
 	if (likely(i2c_dev->msg_err == I2C_ERR_NONE))
 		return 0;
 
+	/*
+	 * NACK interrupt generated before I2C controller generates the STOP
+	 * condition on bus. So wait for some time before reset the controller
+	 * so that STOP condition has delivered properly on bus.
+	 */
+	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)
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread
* [PATCH v2] i2c: tegra: Add delay before reset the controller
@ 2011-12-26 11:14 Alok Chauhan
  2012-01-06 16:18 ` Ben Dooks
  2012-02-10  9:35 ` Shubhrajyoti Datta
  0 siblings, 2 replies; 16+ messages in thread
From: Alok Chauhan @ 2011-12-26 11:14 UTC (permalink / raw)
  To: khali, ben-linux, swarren, olof, bones, paul.gortmaker, dgreid,
	ldewangan
  Cc: linux-tegra, linux-i2c, linux-kernel, Alok Chauhan

From: Alok Chauhan <alokc@nvidia.com>

In NACK error condition, I2C controller violates
clock-to-data setup time before stop. In Software,
because of this reset of controller is happening
before I2C controller could complete STOP condition.

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

Signed-off-by: Alok Chauhan <alokc@nvidia.com>
---
Instead of setting constant value for delay as was in previous patch, now in
the current modification delay will be calculated based on clock frequency of the bus.
 drivers/i2c/busses/i2c-tegra.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c
index 6381604..62e197c 100644
--- a/drivers/i2c/busses/i2c-tegra.c
+++ b/drivers/i2c/busses/i2c-tegra.c
@@ -517,6 +517,14 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev,
 	if (likely(i2c_dev->msg_err == I2C_ERR_NONE))
 		return 0;
 
+	/*
+	 * In NACK error condition resetting of I2C controller happens
+	 * before STOP condition is properly completed by I2C controller,
+	 * so wait for 2 clock cycle to complete STOP condition.
+	 */
+	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)
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2012-04-18 20:21 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-02  5:53 [PATCH v2] i2c: tegra: Add delay before reset the controller Alok Chauhan
2012-04-02  5:59 ` Alok Chauhan
2012-04-02 10:19   ` Shubhrajyoti Datta
2012-04-02 12:06     ` Alok Chauhan
2012-04-02 19:58 ` Stephen Warren
2012-04-13 22:51   ` Stephen Warren
2012-04-18 14:27 ` Wolfram Sang
2012-04-18 20:02   ` Stephen Warren
2012-04-18 20:20     ` Wolfram Sang
  -- strict thread matches above, loose matches on Subject: below --
2011-12-26 11:14 Alok Chauhan
2012-01-06 16:18 ` Ben Dooks
2012-01-10  4:12   ` Alok Chauhan
2012-02-10  9:20     ` Alok Chauhan
2012-02-10  9:35 ` Shubhrajyoti Datta
2012-02-14  5:49   ` Alok Chauhan
2012-03-08  6:29     ` Alok Chauhan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).