All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] i2c: omap: fix bus recovery setup
@ 2015-07-08 14:35 ` Jan Luebbe
  0 siblings, 0 replies; 16+ messages in thread
From: Jan Luebbe @ 2015-07-08 14:35 UTC (permalink / raw)
  To: Wolfram Sang, Tony Lindgren, Felipe Balbi
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-omap-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	kernel-bIcnvbaLZ9MEGnE8C9+IrQ, Jan Luebbe

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 <jlu-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
---
 drivers/i2c/busses/i2c-omap.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index d1c22e3fdd14..fc9bf7f30e35 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -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);
 }
 
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH] i2c: omap: fix bus recovery setup
@ 2015-07-08 14:35 ` Jan Luebbe
  0 siblings, 0 replies; 16+ messages in thread
From: Jan Luebbe @ 2015-07-08 14:35 UTC (permalink / raw)
  To: linux-arm-kernel

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 <jlu@pengutronix.de>
---
 drivers/i2c/busses/i2c-omap.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index d1c22e3fdd14..fc9bf7f30e35 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -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);
 }
 
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH] i2c: omap: fix bus recovery setup
  2015-07-08 14:35 ` Jan Luebbe
@ 2015-07-12 15:32     ` Alexander Sverdlin
  -1 siblings, 0 replies; 16+ messages in thread
From: Alexander Sverdlin @ 2015-07-12 15:32 UTC (permalink / raw)
  To: Jan Luebbe, Wolfram Sang, Tony Lindgren, Felipe Balbi
  Cc: kernel-bIcnvbaLZ9MEGnE8C9+IrQ, linux-omap-u79uwXL29TY76Z2rM5mHXA,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r

On 08/07/15 16:35, Jan Luebbe wrote:
> 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 <jlu-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>

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.

Tested-by: Alexander Sverdlin <alexander.sverdlin-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

> ---
>  drivers/i2c/busses/i2c-omap.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
> index d1c22e3fdd14..fc9bf7f30e35 100644
> --- a/drivers/i2c/busses/i2c-omap.c
> +++ b/drivers/i2c/busses/i2c-omap.c
> @@ -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);
>  }

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH] i2c: omap: fix bus recovery setup
@ 2015-07-12 15:32     ` Alexander Sverdlin
  0 siblings, 0 replies; 16+ messages in thread
From: Alexander Sverdlin @ 2015-07-12 15:32 UTC (permalink / raw)
  To: linux-arm-kernel

On 08/07/15 16:35, Jan Luebbe wrote:
> 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 <jlu@pengutronix.de>

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.

Tested-by: Alexander Sverdlin <alexander.sverdlin@gmail.com>

> ---
>  drivers/i2c/busses/i2c-omap.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
> index d1c22e3fdd14..fc9bf7f30e35 100644
> --- a/drivers/i2c/busses/i2c-omap.c
> +++ b/drivers/i2c/busses/i2c-omap.c
> @@ -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);
>  }

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH] i2c: omap: fix bus recovery setup
  2015-07-08 14:35 ` Jan Luebbe
@ 2015-07-14 11:10     ` Wolfram Sang
  -1 siblings, 0 replies; 16+ messages in thread
From: Wolfram Sang @ 2015-07-14 11:10 UTC (permalink / raw)
  To: Jan Luebbe
  Cc: Tony Lindgren, Felipe Balbi, linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-omap-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	kernel-bIcnvbaLZ9MEGnE8C9+IrQ

[-- Attachment #1: Type: text/plain, Size: 2032 bytes --]

On Wed, Jul 08, 2015 at 04:35:27PM +0200, Jan Luebbe wrote:
> At least on the AM335x, enabling OMAP_I2C_SYSTEST_ST_EN is not enough to

Felipe: it seems you did not need this; is this AM335x specific?

> 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 <jlu-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
> ---
>  drivers/i2c/busses/i2c-omap.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
> index d1c22e3fdd14..fc9bf7f30e35 100644
> --- a/drivers/i2c/busses/i2c-omap.c
> +++ b/drivers/i2c/busses/i2c-omap.c
> @@ -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);
>  }
>  
> -- 
> 2.1.4
> 

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH] i2c: omap: fix bus recovery setup
@ 2015-07-14 11:10     ` Wolfram Sang
  0 siblings, 0 replies; 16+ messages in thread
From: Wolfram Sang @ 2015-07-14 11:10 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Jul 08, 2015 at 04:35:27PM +0200, Jan Luebbe wrote:
> At least on the AM335x, enabling OMAP_I2C_SYSTEST_ST_EN is not enough to

Felipe: it seems you did not need this; is this AM335x specific?

> 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 <jlu@pengutronix.de>
> ---
>  drivers/i2c/busses/i2c-omap.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
> index d1c22e3fdd14..fc9bf7f30e35 100644
> --- a/drivers/i2c/busses/i2c-omap.c
> +++ b/drivers/i2c/busses/i2c-omap.c
> @@ -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);
>  }
>  
> -- 
> 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>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH] i2c: omap: fix bus recovery setup
  2015-07-14 11:10     ` Wolfram Sang
@ 2015-07-14 12:10       ` Grygorii Strashko
  -1 siblings, 0 replies; 16+ messages in thread
From: Grygorii Strashko @ 2015-07-14 12:10 UTC (permalink / raw)
  To: Wolfram Sang, Jan Luebbe
  Cc: Tony Lindgren, Felipe Balbi, linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-omap-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	kernel-bIcnvbaLZ9MEGnE8C9+IrQ

Hi Wolfram,

On 07/14/2015 02:10 PM, Wolfram Sang wrote:
> On Wed, Jul 08, 2015 at 04:35:27PM +0200, Jan Luebbe wrote:
>> At least on the AM335x, enabling OMAP_I2C_SYSTEST_ST_EN is not enough to
> 
> Felipe: 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.

> 
>> 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.

Reviewed-by: Grygorii Strashko <grygorii.strashko-l0cyMroinI0@public.gmane.org> 

>>
>> Signed-off-by: Jan Luebbe <jlu-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
>> ---
>>   drivers/i2c/busses/i2c-omap.c | 11 +++++++++++
>>   1 file changed, 11 insertions(+)
>>
>> diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
>> index d1c22e3fdd14..fc9bf7f30e35 100644
>> --- a/drivers/i2c/busses/i2c-omap.c
>> +++ b/drivers/i2c/busses/i2c-omap.c
>> @@ -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);
>>   }
>>   
>> -- 
>> 2.1.4
>>


-- 
regards,
-grygorii

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH] i2c: omap: fix bus recovery setup
@ 2015-07-14 12:10       ` Grygorii Strashko
  0 siblings, 0 replies; 16+ messages in thread
From: Grygorii Strashko @ 2015-07-14 12:10 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Wolfram,

On 07/14/2015 02:10 PM, Wolfram Sang wrote:
> On Wed, Jul 08, 2015 at 04:35:27PM +0200, Jan Luebbe wrote:
>> At least on the AM335x, enabling OMAP_I2C_SYSTEST_ST_EN is not enough to
> 
> Felipe: 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.

> 
>> 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.

Reviewed-by: Grygorii Strashko <grygorii.strashko@ti.com> 

>>
>> Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
>> ---
>>   drivers/i2c/busses/i2c-omap.c | 11 +++++++++++
>>   1 file changed, 11 insertions(+)
>>
>> diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
>> index d1c22e3fdd14..fc9bf7f30e35 100644
>> --- a/drivers/i2c/busses/i2c-omap.c
>> +++ b/drivers/i2c/busses/i2c-omap.c
>> @@ -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);
>>   }
>>   
>> -- 
>> 2.1.4
>>


-- 
regards,
-grygorii

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH] i2c: omap: fix bus recovery setup
  2015-07-14 12:10       ` Grygorii Strashko
@ 2015-07-14 12:12           ` Wolfram Sang
  -1 siblings, 0 replies; 16+ messages in thread
From: Wolfram Sang @ 2015-07-14 12:12 UTC (permalink / raw)
  To: Grygorii Strashko
  Cc: Jan Luebbe, Tony Lindgren, Felipe Balbi,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-omap-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	kernel-bIcnvbaLZ9MEGnE8C9+IrQ

[-- Attachment #1: Type: text/plain, Size: 559 bytes --]

On Tue, Jul 14, 2015 at 03:10:01PM +0300, Grygorii Strashko wrote:
> Hi Wolfram,
> 
> On 07/14/2015 02:10 PM, Wolfram Sang wrote:
> > On Wed, Jul 08, 2015 at 04:35:27PM +0200, Jan Luebbe wrote:
> >> At least on the AM335x, enabling OMAP_I2C_SYSTEST_ST_EN is not enough to
> > 
> > Felipe: 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?

> It's not AM335x specific. TMODE has to be configured for all OMAP4+ SoCs too.

Okay, thanks for the stepping in!


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH] i2c: omap: fix bus recovery setup
@ 2015-07-14 12:12           ` Wolfram Sang
  0 siblings, 0 replies; 16+ messages in thread
From: Wolfram Sang @ 2015-07-14 12:12 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, Jul 14, 2015 at 03:10:01PM +0300, Grygorii Strashko wrote:
> Hi Wolfram,
> 
> On 07/14/2015 02:10 PM, Wolfram Sang wrote:
> > On Wed, Jul 08, 2015 at 04:35:27PM +0200, Jan Luebbe wrote:
> >> At least on the AM335x, enabling OMAP_I2C_SYSTEST_ST_EN is not enough to
> > 
> > Felipe: 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?

> 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>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH] i2c: omap: fix bus recovery setup
  2015-07-14 12:12           ` Wolfram Sang
@ 2015-07-29 10:27             ` Jan Lübbe
  -1 siblings, 0 replies; 16+ messages in thread
From: Jan Lübbe @ 2015-07-29 10:27 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: Grygorii Strashko, Tony Lindgren, Felipe Balbi,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-omap-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	kernel-bIcnvbaLZ9MEGnE8C9+IrQ

On Di, 2015-07-14 at 14:12 +0200, Wolfram Sang wrote:
> On Tue, Jul 14, 2015 at 03:10:01PM +0300, Grygorii Strashko wrote:
> > Hi Wolfram,
> > 
> > On 07/14/2015 02:10 PM, Wolfram Sang wrote:
> > > On Wed, Jul 08, 2015 at 04:35:27PM +0200, Jan Luebbe wrote:
> > >> At least on the AM335x, enabling OMAP_I2C_SYSTEST_ST_EN is not enough to
> > > 
> > > Felipe: 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?
> 
> > 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
-- 
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 |

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH] i2c: omap: fix bus recovery setup
@ 2015-07-29 10:27             ` Jan Lübbe
  0 siblings, 0 replies; 16+ messages in thread
From: Jan Lübbe @ 2015-07-29 10:27 UTC (permalink / raw)
  To: linux-arm-kernel

On Di, 2015-07-14 at 14:12 +0200, Wolfram Sang wrote:
> On Tue, Jul 14, 2015 at 03:10:01PM +0300, Grygorii Strashko wrote:
> > Hi Wolfram,
> > 
> > On 07/14/2015 02:10 PM, Wolfram Sang wrote:
> > > On Wed, Jul 08, 2015 at 04:35:27PM +0200, Jan Luebbe wrote:
> > >> At least on the AM335x, enabling OMAP_I2C_SYSTEST_ST_EN is not enough to
> > > 
> > > Felipe: 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?
> 
> > 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
-- 
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 |

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH] i2c: omap: fix bus recovery setup
  2015-07-29 10:27             ` Jan Lübbe
@ 2015-07-31 10:49                 ` Wolfram Sang
  -1 siblings, 0 replies; 16+ messages in thread
From: Wolfram Sang @ 2015-07-31 10:49 UTC (permalink / raw)
  To: Jan Lübbe
  Cc: Grygorii Strashko, Tony Lindgren, Felipe Balbi,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-omap-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	kernel-bIcnvbaLZ9MEGnE8C9+IrQ

[-- Attachment #1: Type: text/plain, Size: 919 bytes --]

On Wed, Jul 29, 2015 at 12:27:30PM +0200, Jan Lübbe wrote:
> On Di, 2015-07-14 at 14:12 +0200, Wolfram Sang wrote:
> > On Tue, Jul 14, 2015 at 03:10:01PM +0300, Grygorii Strashko wrote:
> > > Hi Wolfram,
> > > 
> > > On 07/14/2015 02:10 PM, Wolfram Sang wrote:
> > > > On Wed, Jul 08, 2015 at 04:35:27PM +0200, Jan Luebbe wrote:
> > > >> At least on the AM335x, enabling OMAP_I2C_SYSTEST_ST_EN is not enough to
> > > > 
> > > > Felipe: 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?
> > 
> > > 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.



[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH] i2c: omap: fix bus recovery setup
@ 2015-07-31 10:49                 ` Wolfram Sang
  0 siblings, 0 replies; 16+ messages in thread
From: Wolfram Sang @ 2015-07-31 10:49 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Jul 29, 2015 at 12:27:30PM +0200, Jan L?bbe wrote:
> On Di, 2015-07-14 at 14:12 +0200, Wolfram Sang wrote:
> > On Tue, Jul 14, 2015 at 03:10:01PM +0300, Grygorii Strashko wrote:
> > > Hi Wolfram,
> > > 
> > > On 07/14/2015 02:10 PM, Wolfram Sang wrote:
> > > > On Wed, Jul 08, 2015 at 04:35:27PM +0200, Jan Luebbe wrote:
> > > >> At least on the AM335x, enabling OMAP_I2C_SYSTEST_ST_EN is not enough to
> > > > 
> > > > Felipe: 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?
> > 
> > > 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>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH] i2c: omap: fix bus recovery setup
  2015-07-08 14:35 ` Jan Luebbe
@ 2015-07-31 10:51     ` Wolfram Sang
  -1 siblings, 0 replies; 16+ messages in thread
From: Wolfram Sang @ 2015-07-31 10:51 UTC (permalink / raw)
  To: Jan Luebbe
  Cc: Tony Lindgren, Felipe Balbi, linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-omap-u79uwXL29TY76Z2rM5mHXA,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	kernel-bIcnvbaLZ9MEGnE8C9+IrQ

[-- Attachment #1: Type: text/plain, Size: 685 bytes --]

On Wed, Jul 08, 2015 at 04:35:27PM +0200, Jan Luebbe wrote:
> 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 <jlu-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>

Applied to for-current, thanks!


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH] i2c: omap: fix bus recovery setup
@ 2015-07-31 10:51     ` Wolfram Sang
  0 siblings, 0 replies; 16+ messages in thread
From: Wolfram Sang @ 2015-07-31 10:51 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Jul 08, 2015 at 04:35:27PM +0200, Jan Luebbe wrote:
> 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 <jlu@pengutronix.de>

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>

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2015-07-31 10:51 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-08 14:35 [PATCH] i2c: omap: fix bus recovery setup Jan Luebbe
2015-07-08 14:35 ` Jan Luebbe
     [not found] ` <1436366127-24756-1-git-send-email-jlu-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2015-07-12 15:32   ` Alexander Sverdlin
2015-07-12 15:32     ` Alexander Sverdlin
2015-07-14 11:10   ` Wolfram Sang
2015-07-14 11:10     ` Wolfram Sang
2015-07-14 12:10     ` Grygorii Strashko
2015-07-14 12:10       ` Grygorii Strashko
     [not found]       ` <55A4FC19.4040709-l0cyMroinI0@public.gmane.org>
2015-07-14 12:12         ` Wolfram Sang
2015-07-14 12:12           ` Wolfram Sang
2015-07-29 10:27           ` Jan Lübbe
2015-07-29 10:27             ` Jan Lübbe
     [not found]             ` <1438165650.20986.2.camel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2015-07-31 10:49               ` Wolfram Sang
2015-07-31 10:49                 ` Wolfram Sang
2015-07-31 10:51   ` Wolfram Sang
2015-07-31 10:51     ` Wolfram Sang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.