i2c: tegra: Add delay before reset the controller
PATCH v2 1/1 i2c: tegra: Add delay before reset the controller
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.
---
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(-)
drivers/i2c/busses/i2c-tegra.c +8 -0
@@ -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 )
Signature · 1 line
1.7.4.1
Stephen,
I've updated the commit message and comment in the code as per your suggestion. Tegra I2C controller doesn't have idle bit so delay is required before reset the controller in case of NACK error. This delay is calculated purely based on clock period of that particular i2c bus and not passed as hardcoded value. I2C SCL clock-stretching won't affect this calculated delay.
Thanks
Alok
-----Original Message-----
From: Alok Chauhan [mailto:[email protected]]
Sent: Monday, April 02, 2012 11:23 AM
To: [email protected]; [email protected]; [email protected]; [email protected]; Stephen Warren; [email protected]; bones-s3s/[email protected]; [email protected]; [email protected]; Laxman Dewangan; [email protected]; [email protected]; [email protected]
Cc: Alok Chauhan; [email protected]
Subject: [PATCH v2] i2c: tegra: Add delay before reset the controller
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.
---
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(-)
drivers/i2c/busses/i2c-tegra.c +8 -0
@@ -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
Hi Alok,
Few / doubts /questions.
Quoted 3 lines · Alok Chauhan
Stephen,
I've updated the commit message and comment in the code as per your suggestion. Tegra I2C controller doesn't have idle bit so delay is required before reset the controller in case of NACK error. This delay is calculated purely based on clock period of that particular i2c bus and not passed as hardcoded value. I2C SCL clock-stretching won't affect this calculated delay.
Why is it clock cycle dependent?
Is it possible to poll if the stop is sent by controller ?
Quoted 12 lines
Thanks
Alok-----Original Message-----
From: Alok Chauhan [mailto:[email protected]]
Sent: Monday, April 02, 2012 11:23 AM
To: [email protected]; [email protected]; [email protected]; [email protected]; Stephen Warren; [email protected]; [email protected]; [email protected]; [email protected]; Laxman Dewangan; [email protected]; [email protected]; [email protected]
Cc: Alok Chauhan; [email protected]
Subject: [PATCH v2] i2c: tegra: Add delay before reset the controller
Quoted 3 lines
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
How did you calculate the 2 clock cycles?
before reset the controller in case of NACK error.
Quoted 8 lines
Signed-off-by Alok Chauhan <[email protected]>---
Added the more descriptive commit message about issue in case of NACK error condition. Changed the comment in code alsodrivers/i2c/busses/i2c-tegra.c | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
Hi Shubhrajyoti,
Quoted 1 line
Why is it clock cycle dependent?
I think you got me wrong. What I meant to say that delay is calculated based on clock period of that bus. So in this way I don't have to hardcode the delay value.
Quoted 1 line
Is it possible to poll if the stop is sent by controller ?
No, Tegra i2c controller doesn't have any register for STOP condition completion status bit. So delay is the only option here.
Thanks
Alok
-----Original Message-----
From: Shubhrajyoti Datta [mailto:[email protected]]
Sent: Monday, April 02, 2012 3:49 PM
To: Alok Chauhan
Cc: Stephen Warren; [email protected]; [email protected]; [email protected]; [email protected]; Stephen Warren; [email protected]; bones-s3s/[email protected]; [email protected]; Laxman Dewangan; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH v2] i2c: tegra: Add delay before reset the controller
Hi Alok,
Few / doubts /questions.
Quoted 3 lines · Alok Chauhan
Stephen,
I've updated the commit message and comment in the code as per your suggestion. Tegra I2C controller doesn't have idle bit so delay is required before reset the controller in case of NACK error. This delay is calculated purely based on clock period of that particular i2c bus and not passed as hardcoded value. I2C SCL clock-stretching won't affect this calculated delay.
Why is it clock cycle dependent?
Is it possible to poll if the stop is sent by controller ?
Quoted 12 lines
Thanks
Alok-----Original Message-----
From: Alok Chauhan [mailto:[email protected]]
Sent: Monday, April 02, 2012 11:23 AM
To: [email protected]; [email protected]; [email protected]; [email protected]; Stephen Warren; [email protected]; [email protected]; [email protected]; [email protected]; Laxman Dewangan; [email protected]; [email protected]; [email protected]
Cc: Alok Chauhan; [email protected]
Subject: [PATCH v2] i2c: tegra: Add delay before reset the controller
Quoted 3 lines
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
How did you calculate the 2 clock cycles?
before reset the controller in case of NACK error.
Quoted 8 lines
Signed-off-by Alok Chauhan <[email protected]>---
Added the more descriptive commit message about issue in case of NACK error condition. Changed the comment in code alsodrivers/i2c/busses/i2c-tegra.c | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
Quoted 10 lines · Alok Chauhan
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 <[email protected]>
Quoted 7 lines · Stephen Warren
Quoted 6 lines · Alok Chauhan
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.
Quoted 6 lines
Quoted 4 lines
Added delay of 2 clock period before reset the
controller in case of NACK error.Signed-off-by Alok Chauhan <[email protected]>Acked-by Stephen Warren <[email protected]>
Wolfram, Ben, can this be picked up for 3.5?
Quoted 10 lines · Alok Chauhan
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 <[email protected]>
Applied with Stephen's ACK and slightly reworded comment and commit msg.
Wondering a bit that you want it for 3.5, not for 3.4. Looks like a bugfix to me.
Signature · 2 lines
Pengutronix e.K. | Wolfram Sang | Industrial Linux Solutions | http://www.pengutronix.de/ |
Quoted 10 lines · Wolfram Sang
Quoted 9 lines · Alok Chauhan
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.
Quoted 6 lines
Quoted 1 line
Signed-off-by Alok Chauhan <[email protected]>Applied with Stephen's ACK and slightly reworded comment and commit msg.
Wondering a bit that you want it for 3.5, not for 3.4. Looks like a bugfix to me.
Yes, applying this to 3.4 would make sense. When I said "for 3.5" earlier, I meant I'd like it to at least get into 3.5 not later.
Thanks.
Quoted 8 lines
Quoted 5 lines
Applied with Stephen's ACK and slightly reworded comment and commit msg.
Wondering a bit that you want it for 3.5, not for 3.4. Looks like a bugfix to me.
Yes, applying this to 3.4 would make sense. When I said "for 3.5" earlier, I meant I'd like it to at least get into 3.5 not later.
Done, thanks for clarifying.
Signature · 2 lines
Pengutronix e.K. | Wolfram Sang | Industrial Linux Solutions | http://www.pengutronix.de/ |