i2c: tegra: Add delay before reset the controller
PATCH 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 worst case delay of 1 ms (assuming lowest clock frequency will be 1 KHZ) before reset the controller in case of NACK error.
--- drivers/i2c/busses/i2c-tegra.c | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-)
drivers/i2c/busses/i2c-tegra.c +9 -0
@@ -517,6 +517,15 @@ 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 worst case delay of 1 ms (assuming lowest clock +* frequency will be 1 KHz) to complete STOP condition. +*/ +if (i2c_dev->msg_err ==I2C_ERR_NO_ACK ) +mdelay (1 ); +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
Hi,
(Adding linux-tegra and Dylan Reid who was debugging this before)
Quoted 10 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 worst case delay of 1 ms (assuming lowest clock frequency will be 1 KHZ) before reset the controller in case of NACK error.
This change causes problems systems with some models of i2c TPMs, since the first transaction to them will always time out (TPM quirk), and the delay means that the tpm will have time to go back to sleep and thus timeout even on the retry. So you'll never make progress.
In other words: this patch will break some systems and thus shouldn't be applied.
-Olof
Hi,
(Adding Laxman Dewangan)
Quoted 1 line
This change causes problems systems with some models of i2c TPMs, since the first transaction to them will always time out (TPM quirk), and the delay means that the tpm will have time to go back to sleep and thus timeout >even on the retry. So you'll never make progress.
Working on this.
-Alok
-----Original Message-----
From: Olof Johansson [mailto:[email protected]]
Sent: Friday, December 23, 2011 2:48 AM
To: Alok Chauhan
Cc: [email protected]; [email protected]; Stephen Warren; bones-s3s/[email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH] i2c: tegra: Add delay before reset the controller
Hi,
(Adding linux-tegra and Dylan Reid who was debugging this before)
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 worst case delay of 1 ms (assuming lowest clock frequency will be 1 KHZ) before reset the controller in case of NACK error.
This change causes problems systems with some models of i2c TPMs, since the first transaction to them will always time out (TPM quirk), and the delay means that the tpm will have time to go back to sleep and thus timeout even on the retry. So you'll never make progress.
In other words: this patch will break some systems and thus shouldn't be applied.
-Olof
Laxman Dewangan
maintainerQuoted 39 lines
-----Original Message-----
From: Alok ChauhanHi,
(Adding Laxman Dewangan)
Quoted 1 line
This change causes problems systems with some models of i2c TPMs, since the
first transaction to them will always time out (TPM quirk), and the delay means that the tpm will have time to go back to sleep and thus timeout >even on the retry. So you'll never make progress.
Working on this.-Alok
-----Original Message-----
From: Olof Johansson [mailto:[email protected]]
Sent: Friday, December 23, 2011 2:48 AM
To: Alok Chauhan
Cc: [email protected]; [email protected]; Stephen Warren; bones-s3s/[email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH] i2c: tegra: Add delay before reset the controllerHi,
(Adding linux-tegra and Dylan Reid who was debugging this before)
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 worst case delay of 1 ms (assuming lowest clock frequency will be 1 KHZ) before reset the controller in case of NACK error.
Quoted 8 lines
This change causes problems systems with some models of i2c TPMs, since the first transaction to them will always time out (TPM quirk), and the delay means that the tpm will have time to go back to sleep and thus timeout even on the retry. So you'll never make progress.
In other words: this patch will break some systems and thus shouldn't be applied.
I think the delay should be calculated based on speed. So if it is 100KHz, then
delay is 10mcro second for 1 bit. We should wait for 2 bit (ack clock to be complete and stop pulse to be transmitted).
This patch will make sure that i2c driver will not break the specs i.e. in case of NACK error, the stop signal should be completed by i2c controller before resetting controller.
I will prefer of having the udelay(2*1000000/speed).
Quoted 2 lines
-Olof