Skip to contentSkip to conversation

i2c: tegra: Add delay before reset the controller

PATCH Superseded Alok Chauhan 5 participants 9 messages Dec 26, 2011 – Mar 26, 2012 2 messages not in the archive

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 i2c: tegra: Add delay before reset the controller

From: Alok Chauhan <[email protected]>

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.

---
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(-)
drivers/i2c/busses/i2c-tegra.c +8 -0
index 6381604..62e197c 100644
@@ -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)
Signature · 1 line
1.7.4.1
#1 lore raw
Quoted 23 lines · Alok Chauhan

From: Alok Chauhan <[email protected]>

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.

---
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(-)
drivers/i2c/busses/i2c-tegra.c +0 -0
index 6381604..62e197c 100644
@@ -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))

drivers/i2c/busses/i2c-tegra.c static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev, · line 527

Quoted 10 lines
drivers/i2c/busses/i2c-tegra.c +8 -0
 		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));
+

Is a delay here good, would it be better to sleep so that some other process can gain cpu time?

tegra_i2c_init(i2c_dev);

Quoted 9 lines
drivers/i2c/busses/i2c-tegra.c +0 -0
 	if (i2c_dev->msg_err == I2C_ERR_NO_ACK) {
 		if (msg->flags & I2C_M_IGNORE_NAK)
Signature · 6 lines
1.7.4.1

--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Signature · 3 lines
Ben Dooks, [email protected], http://www.fluff.org/ben/

Large Hadron Colada: A large Pina Colada that makes the universe disappear.
#2 lore raw
Quoted 33 lines · Alok Chauhan

From: Alok Chauhan <[email protected]>

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.

---
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(-)
(quoted diff) +0 -0

b/drivers/i2c/busses/i2c-tegra.c index 6381604..62e197c 100644

drivers/i2c/busses/i2c-tegra.c +8 -0
@@ -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));
+
 
Quoted 1 line

Is a delay here good, would it be better to sleep so that some other process can gain cpu time?

We mostly used 100 khz i2c clock frequency and delay in that case will be 20 usec. Would it be ok to sleep for such a smaller time? Won't it increase any other overhead?

tegra_i2c_init(i2c_dev);

Quoted 9 lines
drivers/i2c/busses/i2c-tegra.c +0 -1
 	if (i2c_dev->msg_err == I2C_ERR_NO_ACK) {
 		if (msg->flags & I2C_M_IGNORE_NAK)
--

1.7.4.1

--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

--
Ben Dooks, [email protected], http://www.fluff.org/ben/

Large Hadron Colada: A large Pina Colada that makes the universe disappear.

#3 lore raw
Quoted 11 lines · Alok Chauhan
Quoted 1 line
drivers/i2c/busses/i2c-tegra.c +8 -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));
+
Quoted 2 lines

Is a delay here good, would it be better to sleep so that some other process can gain cpu time?

Quoted 1 line

We mostly used 100 khz i2c clock frequency and delay in that case will be 20 usec. Would it be ok to sleep for such a smaller time? Won't it increase any other overhead?

Please let me know if sleep is better option here instead of waiting.

Thanks
Alok

--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#4 lore raw
In reply to Alok Chauhan

Hello Alok,

Quoted 22 lines · Alok Chauhan

From: Alok Chauhan <[email protected]>

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.

---
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(-)
drivers/i2c/busses/i2c-tegra.c +0 -0
index 6381604..62e197c 100644

drivers/i2c/busses/i2c-tegra.c static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev, · line 524

Quoted 8 lines
drivers/i2c/busses/i2c-tegra.c +5 -0
@@ -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.
+        */

Why do you need to reset the controller in case of a NACK.

Quoted 13 lines
drivers/i2c/busses/i2c-tegra.c +3 -1
+       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

--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

#5 lore raw

Hi Shubhrajyot,

Quoted 32 lines · Alok Chauhan

From: Alok Chauhan <[email protected]>

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.

---
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(-)
(quoted diff) +0 -0

b/drivers/i2c/busses/i2c-tegra.c index 6381604..62e197c 100644

drivers/i2c/busses/i2c-tegra.c +6 -0
@@ -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.
+        */
 
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Why do you need to reset the controller in case of a NACK.

This is required because of hardware limitations. Without reset we can't flus the internal hardware registers.

Quoted 14 lines

+       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

--
To unsubscribe from this list: send the line "unsubscribe linux-i2c"
in the body of a message to [email protected] More majordomo info at  http://vger.kernel.org/majordomo-info.html

#6 lore raw

Hi all,

If there are no more concern then can we merge this patch to i2c tegra driver?

Thanks
Alok

Quoted 46 lines · Alok Chauhan

From: Alok Chauhan <[email protected]>

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.

---
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(-)
(quoted diff) +0 -0

b/drivers/i2c/busses/i2c-tegra.c index 6381604..62e197c 100644

drivers/i2c/busses/i2c-tegra.c +6 -0
@@ -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.
+        */
 
Quoted 2 lines
Quoted 2 lines
Quoted 1 line

Why do you need to reset the controller in case of a NACK.

This is required because of hardware limitations. Without reset we can't flus the internal hardware registers.

+       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

Quoted 4 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-i2c"
in the body of a message to [email protected] More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#8 lore raw
In reply to a message not in the archive
Quoted 8 lines · Alok Chauhan

From: Alok Chauhan <[email protected]>

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.

(CC list cut down to people who were active in the original patch posting thread)

Quoted 3 lines · Alok Chauhan

Hi all,

If there are no more concern then can we merge this patch to i2c tegra driver?

Alok, a couple comments:

1) The set of I2C maintainers has changed since you last posted this patch. You should resend the whole patch to make sure the new maintainers have a copy. I've CC'd Wolfram on this message, but you still need to repost since there's no way Wolfram can extract the patch from this email.

2) Wasn't there an outstanding question about the length of the delay here, and whether it negatively interfered with the TPM chips on some boards, since they always NACK the first transaction, which then needs to be retried quickly so the TPM doesn't go back to sleep? I don't recall you answering addressing that issue. There's no point reposting without addressing all the issues. Also, I'm not sure whether Shubhrajyot or Ben consider the answers you gave to their questions satisfactory or not.

P.S. Top-posting makes for confusing emails.

Thanks.

Quoted 37 lines
Quoted 37 lines

---
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(-)
(quoted diff) +0 -0

b/drivers/i2c/busses/i2c-tegra.c index 6381604..62e197c 100644

drivers/i2c/busses/i2c-tegra.c +6 -0
@@ -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.
+        */
 
Quoted 2 lines
Quoted 2 lines
Quoted 1 line

Why do you need to reset the controller in case of a NACK.

This is required because of hardware limitations. Without reset we can't flus the internal hardware registers.

drivers/i2c/busses/i2c-tegra.c +4 -1
+       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

#10 lore raw
In reply to a message not in the archive
Quoted 26 lines · Stephen Warren
Quoted 8 lines · Alok Chauhan

From: Alok Chauhan <[email protected]>

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.

(CC list cut down to people who were active in the original patch posting thread)

Quoted 3 lines · Alok Chauhan

Hi all,

If there are no more concern then can we merge this patch to i2c tegra driver?

Alok, a couple comments:

1) The set of I2C maintainers has changed since you last posted this patch. You should resend the whole patch to make sure the new maintainers have a copy. I've CC'd Wolfram on this message, but you still need to repost since there's no way Wolfram can extract the patch from this email.

Quoted 8 lines

2) Wasn't there an outstanding question about the length of the delay here, and whether it negatively interfered with the TPM chips on some boards, since they always NACK the first transaction, which then needs to be retried quickly so the TPM doesn't go back to sleep? I don't recall you answering addressing that issue. There's no point reposting without addressing all the issues. Also, I'm not sure whether Shubhrajyot or Ben consider the answers you gave to their questions satisfactory or not.

The TPM issue was from the inital patchset, this current patch works with those slow TPMs. The change to make the sleep duration dependent on the i2c clock rate fixed it. Sorry it took so long for me to test it.

Quoted 46 lines

P.S. Top-posting makes for confusing emails.

Thanks.

Quoted 28 lines
Quoted 26 lines

---
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(-)
(quoted diff) +0 -0

b/drivers/i2c/busses/i2c-tegra.c index 6381604..62e197c 100644

drivers/i2c/busses/i2c-tegra.c +6 -0
@@ -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.
+        */
 
Quoted 2 lines
Quoted 2 lines
Quoted 1 line

Why do you need to reset the controller in case of a NACK.

This is required because of hardware limitations. Without reset we can't flus the internal hardware registers.

Quoted 9 lines
Quoted 9 lines

+       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

--
To unsubscribe from this list: send the line "unsubscribe linux-tegra" in the body of a message to [email protected] More majordomo info at  http://vger.kernel.org/majordomo-info.html