i2c: tegra: Add delay before reset the controller
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
@@ -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
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.Signed-off-by Alok Chauhan <[email protected]>---
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@@ -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
-0return 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
-0if (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.
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.
Signed-off-by Alok Chauhan <[email protected]>---
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.cindex 6381604..62e197c 100644drivers/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
-1if (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.
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
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.Signed-off-by Alok Chauhan <[email protected]>---
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
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
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.
Signed-off-by Alok Chauhan <[email protected]>---
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.cindex 6381604..62e197c 100644drivers/i2c/busses/i2c-tegra.c +6
-0@@ -517,6 +517,14 @@ static int tegra_i2c_xfer_msg(structtegra_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
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.
Signed-off-by Alok Chauhan <[email protected]>---
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.cindex 6381604..62e197c 100644drivers/i2c/busses/i2c-tegra.c +6
-0@@ -517,6 +517,14 @@ static int tegra_i2c_xfer_msg(structtegra_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
A message that is not in the archive (sent off-list or not yet received): 7A0BFCFE3DA5CD47B0FB7984326F201A136B886672-kdsAE/[email protected]
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
Signed-off-by Alok Chauhan <[email protected]>---
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.cindex 6381604..62e197c 100644drivers/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
A message that is not in the archive (sent off-list or not yet received): [email protected]
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
Signed-off-by Alok Chauhan <[email protected]>---
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.cindex 6381604..62e197c 100644drivers/i2c/busses/i2c-tegra.c +6
-0@@ -517,6 +517,14 @@ static int tegra_i2c_xfer_msg(structtegra_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