Commit 828e66c0 authored by Jan Luebbe's avatar Jan Luebbe Committed by Wolfram Sang

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: default avatarJan Luebbe <jlu@pengutronix.de>
Tested-by: default avatarAlexander Sverdlin <alexander.sverdlin@gmail.com>
Reviewed-by: default avatarGrygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: default avatarWolfram Sang <wsa@the-dreams.de>
parent 8b062608
...@@ -1247,7 +1247,14 @@ static void omap_i2c_prepare_recovery(struct i2c_adapter *adap) ...@@ -1247,7 +1247,14 @@ static void omap_i2c_prepare_recovery(struct i2c_adapter *adap)
u32 reg; u32 reg;
reg = omap_i2c_read_reg(dev, OMAP_I2C_SYSTEST_REG); reg = omap_i2c_read_reg(dev, OMAP_I2C_SYSTEST_REG);
/* enable test mode */
reg |= OMAP_I2C_SYSTEST_ST_EN; reg |= OMAP_I2C_SYSTEST_ST_EN;
/* select SDA/SCL IO mode */
reg |= 3 << OMAP_I2C_SYSTEST_TMODE_SHIFT;
/* set SCL to high-impedance state (reset value is 0) */
reg |= OMAP_I2C_SYSTEST_SCL_O;
/* set SDA to high-impedance state (reset value is 0) */
reg |= OMAP_I2C_SYSTEST_SDA_O;
omap_i2c_write_reg(dev, OMAP_I2C_SYSTEST_REG, reg); omap_i2c_write_reg(dev, OMAP_I2C_SYSTEST_REG, reg);
} }
...@@ -1257,7 +1264,11 @@ static void omap_i2c_unprepare_recovery(struct i2c_adapter *adap) ...@@ -1257,7 +1264,11 @@ static void omap_i2c_unprepare_recovery(struct i2c_adapter *adap)
u32 reg; u32 reg;
reg = omap_i2c_read_reg(dev, OMAP_I2C_SYSTEST_REG); reg = omap_i2c_read_reg(dev, OMAP_I2C_SYSTEST_REG);
/* restore reset values */
reg &= ~OMAP_I2C_SYSTEST_ST_EN; reg &= ~OMAP_I2C_SYSTEST_ST_EN;
reg &= ~OMAP_I2C_SYSTEST_TMODE_MASK;
reg &= ~OMAP_I2C_SYSTEST_SCL_O;
reg &= ~OMAP_I2C_SYSTEST_SDA_O;
omap_i2c_write_reg(dev, OMAP_I2C_SYSTEST_REG, reg); omap_i2c_write_reg(dev, OMAP_I2C_SYSTEST_REG, reg);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment