Skip to content

Commit 2db39a2

Browse files
committed
Merge branch 'i2c/for-current' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux
Pull i2c fixes from Wolfram Sang: - I2C core bugfix regarding bus recovery - driver bugfix for the tegra driver - typo correction * 'i2c/for-current' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux: i2c: recovery: if possible send STOP with recovery pulses i2c: tegra: Fix NACK error handling i2c: stu300: use non-archaic spelling of failes
2 parents 3951dbf + abe4118 commit 2db39a2

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed

drivers/i2c/busses/i2c-stu300.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ enum stu300_error {
127127

128128
/*
129129
* The number of address send athemps tried before giving up.
130-
* If the first one failes it seems like 5 to 8 attempts are required.
130+
* If the first one fails it seems like 5 to 8 attempts are required.
131131
*/
132132
#define NUM_ADDR_RESEND_ATTEMPTS 12
133133

drivers/i2c/busses/i2c-tegra.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,14 @@ static int tegra_i2c_disable_packet_mode(struct tegra_i2c_dev *i2c_dev)
545545
{
546546
u32 cnfg;
547547

548+
/*
549+
* NACK interrupt is generated before the I2C controller generates
550+
* the STOP condition on the bus. So wait for 2 clock periods
551+
* before disabling the controller so that the STOP condition has
552+
* been delivered properly.
553+
*/
554+
udelay(DIV_ROUND_UP(2 * 1000000, i2c_dev->bus_clk_rate));
555+
548556
cnfg = i2c_readl(i2c_dev, I2C_CNFG);
549557
if (cnfg & I2C_CNFG_PACKET_MODE_EN)
550558
i2c_writel(i2c_dev, cnfg & ~I2C_CNFG_PACKET_MODE_EN, I2C_CNFG);
@@ -706,15 +714,6 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev,
706714
if (likely(i2c_dev->msg_err == I2C_ERR_NONE))
707715
return 0;
708716

709-
/*
710-
* NACK interrupt is generated before the I2C controller generates
711-
* the STOP condition on the bus. So wait for 2 clock periods
712-
* before resetting the controller so that the STOP condition has
713-
* been delivered properly.
714-
*/
715-
if (i2c_dev->msg_err == I2C_ERR_NO_ACK)
716-
udelay(DIV_ROUND_UP(2 * 1000000, i2c_dev->bus_clk_rate));
717-
718717
tegra_i2c_init(i2c_dev);
719718
if (i2c_dev->msg_err == I2C_ERR_NO_ACK) {
720719
if (msg->flags & I2C_M_IGNORE_NAK)

drivers/i2c/i2c-core-base.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,16 @@ int i2c_generic_scl_recovery(struct i2c_adapter *adap)
198198

199199
val = !val;
200200
bri->set_scl(adap, val);
201-
ndelay(RECOVERY_NDELAY);
201+
202+
/*
203+
* If we can set SDA, we will always create STOP here to ensure
204+
* the additional pulses will do no harm. This is achieved by
205+
* letting SDA follow SCL half a cycle later.
206+
*/
207+
ndelay(RECOVERY_NDELAY / 2);
208+
if (bri->set_sda)
209+
bri->set_sda(adap, val);
210+
ndelay(RECOVERY_NDELAY / 2);
202211
}
203212

204213
/* check if recovery actually succeeded */

0 commit comments

Comments
 (0)