Skip to content

Commit 828e66c

Browse files
jluebbeWolfram Sang
authored and
Wolfram Sang
committed
i2c: omap: fix bus recovery setup
At least on the AM335x, enabling OMAP_I2C_SYSTEST_ST_EN is not enough to allow direct access to the SCL and SDA pins. In addition to ST_EN, we need to set the TMODE to 0b11 (Loop back & SDA/SCL IO mode select). Also, as the reset values of SCL_O and SDA_O are 0 (which means "drive low level"), we need to set them to 1 (which means "high-impedance") to avoid unwanted changes on the pins. As a precaution, reset all these bits to their default values after recovery is complete. Signed-off-by: Jan Luebbe <[email protected]> Tested-by: Alexander Sverdlin <[email protected]> Reviewed-by: Grygorii Strashko <[email protected]> Signed-off-by: Wolfram Sang <[email protected]>
1 parent 8b06260 commit 828e66c

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

drivers/i2c/busses/i2c-omap.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,7 +1247,14 @@ static void omap_i2c_prepare_recovery(struct i2c_adapter *adap)
12471247
u32 reg;
12481248

12491249
reg = omap_i2c_read_reg(dev, OMAP_I2C_SYSTEST_REG);
1250+
/* enable test mode */
12501251
reg |= OMAP_I2C_SYSTEST_ST_EN;
1252+
/* select SDA/SCL IO mode */
1253+
reg |= 3 << OMAP_I2C_SYSTEST_TMODE_SHIFT;
1254+
/* set SCL to high-impedance state (reset value is 0) */
1255+
reg |= OMAP_I2C_SYSTEST_SCL_O;
1256+
/* set SDA to high-impedance state (reset value is 0) */
1257+
reg |= OMAP_I2C_SYSTEST_SDA_O;
12511258
omap_i2c_write_reg(dev, OMAP_I2C_SYSTEST_REG, reg);
12521259
}
12531260

@@ -1257,7 +1264,11 @@ static void omap_i2c_unprepare_recovery(struct i2c_adapter *adap)
12571264
u32 reg;
12581265

12591266
reg = omap_i2c_read_reg(dev, OMAP_I2C_SYSTEST_REG);
1267+
/* restore reset values */
12601268
reg &= ~OMAP_I2C_SYSTEST_ST_EN;
1269+
reg &= ~OMAP_I2C_SYSTEST_TMODE_MASK;
1270+
reg &= ~OMAP_I2C_SYSTEST_SCL_O;
1271+
reg &= ~OMAP_I2C_SYSTEST_SDA_O;
12611272
omap_i2c_write_reg(dev, OMAP_I2C_SYSTEST_REG, reg);
12621273
}
12631274

0 commit comments

Comments
 (0)