i2c: omap: fix bus recovery setup
Subsystems (4)
PATCH 1/1 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.
--- drivers/i2c/busses/i2c-omap.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/i2c/busses/i2c-omap.c +11 -0
@@ -1247,7 +1247,14 @@ static void omap_i2c_prepare_recovery(struct i2c_adapter *adap)u32 reg; reg =omap_i2c_read_reg (dev,OMAP_I2C_SYSTEST_REG ); +/* enable test mode */ 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); }
@@ -1257,7 +1264,11 @@ static void omap_i2c_unprepare_recovery(struct i2c_adapter *adap)u32 reg; reg =omap_i2c_read_reg (dev,OMAP_I2C_SYSTEST_REG ); +/* restore reset values */ 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); }
Signature · 1 line
2.1.4
PATCH 1/1 i2c: omap: fix bus recovery setup
Quoted 11 lines · Jan Luebbe
At least on the AM335x, enabling
OMAP_I2C_SYSTEST_ST_ENis not enough to allow direct access to the SCL and SDA pins. In addition toST_EN, we need to set the TMODE to 0b11 (Loop back & SDA/SCL IO mode select). Also, as the reset values ofSCL_OandSDA_Oare 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 with oscilloscope on Beagle Bone Black, without the patch nothing meningful appears on SCL during recovery, with the patch I'm able to see the recovery pulses.
Quoted 34 lines
--- drivers/i2c/busses/i2c-omap.c | 11 +++++++++++ 1 file changed, 11 insertions(+)drivers/i2c/busses/i2c-omap.c +11
-0@@ -1247,7 +1247,14 @@ static void omap_i2c_prepare_recovery(struct i2c_adapter *adap)u32 reg; reg =omap_i2c_read_reg (dev,OMAP_I2C_SYSTEST_REG ); +/* enable test mode */ 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); }@@ -1257,7 +1264,11 @@ static void omap_i2c_unprepare_recovery(struct i2c_adapter *adap)u32 reg; reg =omap_i2c_read_reg (dev,OMAP_I2C_SYSTEST_REG ); +/* restore reset values */ 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); }
PATCH 1/1 i2c: omap: fix bus recovery setup
In reply to Jan LuebbeQuoted 1 line · Jan Luebbe
At least on the AM335x, enabling
OMAP_I2C_SYSTEST_ST_ENis not enough to
Felipe: it seems you did not need this; is this AM335x specific?
Quoted 48 lines
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 ofSCL_OandSDA_Oare 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]>--- drivers/i2c/busses/i2c-omap.c | 11 +++++++++++ 1 file changed, 11 insertions(+)drivers/i2c/busses/i2c-omap.c +11
-0@@ -1247,7 +1247,14 @@ static void omap_i2c_prepare_recovery(struct i2c_adapter *adap)u32 reg; reg =omap_i2c_read_reg (dev,OMAP_I2C_SYSTEST_REG ); +/* enable test mode */ 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); }@@ -1257,7 +1264,11 @@ static void omap_i2c_unprepare_recovery(struct i2c_adapter *adap)u32 reg; reg =omap_i2c_read_reg (dev,OMAP_I2C_SYSTEST_REG ); +/* restore reset values */ 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); }Signature · 1 line
2.1.4
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150714/d6115559/attachment.sig>
PATCH 1/1 i2c: omap: fix bus recovery setup
Hi Wolfram,
Quoted 4 lines · Wolfram Sang
Quoted 1 line · Jan Luebbe
At least on the AM335x, enabling
OMAP_I2C_SYSTEST_ST_ENis not enough toFelipe: it seems you did not need this; is this AM335x specific?
We need it (Felipe's reply can be delayed).
It's not AM335x specific. TMODE has to be configured for all OMAP4+ SoCs too.
Quoted 9 lines
Quoted 9 lines
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 ofSCL_OandSDA_Oare 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.
Quoted 40 lines
Quoted 40 lines
Signed-off-by Jan Luebbe <[email protected]>--- drivers/i2c/busses/i2c-omap.c | 11 +++++++++++ 1 file changed, 11 insertions(+)drivers/i2c/busses/i2c-omap.c +11
-0@@ -1247,7 +1247,14 @@ static void omap_i2c_prepare_recovery(struct i2c_adapter *adap)u32 reg; reg =omap_i2c_read_reg (dev,OMAP_I2C_SYSTEST_REG ); +/* enable test mode */ 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); }@@ -1257,7 +1264,11 @@ static void omap_i2c_unprepare_recovery(struct i2c_adapter *adap)u32 reg; reg =omap_i2c_read_reg (dev,OMAP_I2C_SYSTEST_REG ); +/* restore reset values */ 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); }Signature · 1 line
2.1.4
Signature · 2 lines
regards, -grygorii
PATCH 1/1 i2c: omap: fix bus recovery setup
Quoted 9 lines · Grygorii Strashko
Hi Wolfram,
Quoted 4 lines · Wolfram Sang
Quoted 1 line · Jan Luebbe
At least on the AM335x, enabling
OMAP_I2C_SYSTEST_ST_ENis not enough toFelipe: it seems you did not need this; is this AM335x specific?
We need it (Felipe's reply can be delayed).
So, how did it work for him?
Quoted 1 line
It's not AM335x specific. TMODE has to be configured for all OMAP4+ SoCs too.
Okay, thanks for the stepping in!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150714/2dd52bbc/attachment.sig>
PATCH 1/1 i2c: omap: fix bus recovery setup
Quoted 9 lines · Wolfram Sang
Quoted 8 lines · Grygorii Strashko
Hi Wolfram,
Quoted 4 lines · Wolfram Sang
Quoted 1 line · Jan Luebbe
At least on the AM335x, enabling
OMAP_I2C_SYSTEST_ST_ENis not enough toFelipe: it seems you did not need this; is this AM335x specific?
Quoted 7 lines
Quoted 1 line
We need it (Felipe's reply can be delayed).
So, how did it work for him?
Quoted 1 line
It's not AM335x specific. TMODE has to be configured for all OMAP4+ SoCs too.
Okay, thanks for the stepping in!
Wolfram, will you pick this as-is?
Regards,
Jan
Signature · 4 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
PATCH 1/1 i2c: omap: fix bus recovery setup
Quoted 12 lines · Jan L?bbe
Quoted 11 lines · Wolfram Sang
Quoted 9 lines · Grygorii Strashko
Hi Wolfram,
Quoted 4 lines · Wolfram Sang
Quoted 1 line · Jan Luebbe
At least on the AM335x, enabling
OMAP_I2C_SYSTEST_ST_ENis not enough toFelipe: it seems you did not need this; is this AM335x specific?
We need it (Felipe's reply can be delayed).
Quoted 7 lines
Quoted 5 lines
So, how did it work for him?
Quoted 1 line
It's not AM335x specific. TMODE has to be configured for all OMAP4+ SoCs too.
Okay, thanks for the stepping in!
Wolfram, will you pick this as-is?
Yes, I was hoping for an answer to my above question to get a better understanding, but we can still apply the patches meanwhile.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150731/936f06db/attachment.sig>
Wolfram Sang
AppliedPATCH 1/1 i2c: omap: fix bus recovery setup
In reply to Jan LuebbeQuoted 11 lines · Jan Luebbe
At least on the AM335x, enabling
OMAP_I2C_SYSTEST_ST_ENis not enough to allow direct access to the SCL and SDA pins. In addition toST_EN, we need to set the TMODE to 0b11 (Loop back & SDA/SCL IO mode select). Also, as the reset values ofSCL_OandSDA_Oare 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]>
Applied to for-current, thanks!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20150731/5a1363c0/attachment.sig>