linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH ] i2c: omap: recover from Bus Busy condition
@ 2011-10-24  6:51 Shubhrajyoti D
       [not found] ` <1319439118-3800-1-git-send-email-shubhrajyoti-l0cyMroinI0@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Shubhrajyoti D @ 2011-10-24  6:51 UTC (permalink / raw)
  To: linux-i2c-u79uwXL29TY76Z2rM5mHXA
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA, Vikram Pandita,
	Shubhrajyoti D

From: Vikram Pandita <vikram.pandita-l0cyMroinI0@public.gmane.org>

    In case a peripheral is holding the DATA bus low, provide a 400Khz
    constant clock output using the TEST register.

    Also soft reset the I2C controller so that there is no stale state
    left in the HW state machine.

    A WARN_ON() will be generated when a BB timeout happens.

Signed-off-by: Vikram Pandita <vikram.pandita-l0cyMroinI0@public.gmane.org>
Signed-off-by: Shubhrajyoti D <shubhrajyoti-l0cyMroinI0@public.gmane.org>
---
 drivers/i2c/busses/i2c-omap.c |   15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index 2dfb631..b6fcd08 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -143,7 +143,6 @@ enum {
 #define OMAP_I2C_SCLH_HSSCLH	8
 
 /* I2C System Test Register (OMAP_I2C_SYSTEST): */
-#ifdef DEBUG
 #define OMAP_I2C_SYSTEST_ST_EN		(1 << 15)	/* System test enable */
 #define OMAP_I2C_SYSTEST_FREE		(1 << 14)	/* Free running mode */
 #define OMAP_I2C_SYSTEST_TMODE_MASK	(3 << 12)	/* Test mode select */
@@ -152,7 +151,6 @@ enum {
 #define OMAP_I2C_SYSTEST_SCL_O		(1 << 2)	/* SCL line drive out */
 #define OMAP_I2C_SYSTEST_SDA_I		(1 << 1)	/* SDA line sense in */
 #define OMAP_I2C_SYSTEST_SDA_O		(1 << 0)	/* SDA line drive out */
-#endif
 
 /* OCP_SYSSTATUS bit definitions */
 #define SYSS_RESETDONE_MASK		(1 << 0)
@@ -641,10 +639,23 @@ omap_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)
 	struct omap_i2c_dev *dev = i2c_get_adapdata(adap);
 	int i;
 	int r;
+	u16 val;
 
 	omap_i2c_unidle(dev);
 
 	r = omap_i2c_wait_for_bb(dev);
+	/* If timeout, try to again check after soft reset of I2C block */
+	if (WARN_ON(r == -ETIMEDOUT)) {
+		/* Provide a permanent clock to recover the peripheral */
+		val = omap_i2c_read_reg(dev, OMAP_I2C_SYSTEST_REG);
+		val |= (OMAP_I2C_SYSTEST_ST_EN |
+				OMAP_I2C_SYSTEST_FREE |
+				(2 << OMAP_I2C_SYSTEST_TMODE_SHIFT));
+		omap_i2c_write_reg(dev, OMAP_I2C_SYSTEST_REG, val);
+		msleep(1);
+		omap_i2c_init(dev);
+		r = omap_i2c_wait_for_bb(dev);
+	}
 	if (r < 0)
 		goto out;
 
-- 
1.7.1

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

* Re: [PATCH ] i2c: omap: recover from Bus Busy condition
       [not found] ` <1319439118-3800-1-git-send-email-shubhrajyoti-l0cyMroinI0@public.gmane.org>
@ 2011-10-24  7:10   ` Rajeev kumar
       [not found]     ` <4EA50F7F.6000400-qxv4g6HH51o@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Rajeev kumar @ 2011-10-24  7:10 UTC (permalink / raw)
  To: Shubhrajyoti D
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Vikram Pandita

On 10/24/2011 12:21 PM, Shubhrajyoti D wrote:
> From: Vikram Pandita<vikram.pandita-l0cyMroinI0@public.gmane.org>
>
>      In case a peripheral is holding the DATA bus low, provide a 400Khz
>      constant clock output using the TEST register.
>
>      Also soft reset the I2C controller so that there is no stale state
>      left in the HW state machine.
>
>      A WARN_ON() will be generated when a BB timeout happens.
>
> Signed-off-by: Vikram Pandita<vikram.pandita-l0cyMroinI0@public.gmane.org>
> Signed-off-by: Shubhrajyoti D<shubhrajyoti-l0cyMroinI0@public.gmane.org>
> ---
>   drivers/i2c/busses/i2c-omap.c |   15 +++++++++++++--
>   1 files changed, 13 insertions(+), 2 deletions(-)


Reviewed-by: Rajeev Kumar <rajeev-dlh.kumar-qxv4g6HH51o@public.gmane.org>


~Rajeev

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

* Re: [PATCH ] i2c: omap: recover from Bus Busy condition
       [not found]     ` <4EA50F7F.6000400-qxv4g6HH51o@public.gmane.org>
@ 2011-10-25 13:09       ` Shubhrajyoti
  0 siblings, 0 replies; 3+ messages in thread
From: Shubhrajyoti @ 2011-10-25 13:09 UTC (permalink / raw)
  To: Rajeev kumar
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Vikram Pandita

On Monday 24 October 2011 12:40 PM, Rajeev kumar wrote:
> On 10/24/2011 12:21 PM, Shubhrajyoti D wrote:
>> From: Vikram Pandita<vikram.pandita-l0cyMroinI0@public.gmane.org>
>>
>>      In case a peripheral is holding the DATA bus low, provide a 400Khz
>>      constant clock output using the TEST register.
>>
>>      Also soft reset the I2C controller so that there is no stale state
>>      left in the HW state machine.
>>
>>      A WARN_ON() will be generated when a BB timeout happens.
>>
>> Signed-off-by: Vikram Pandita<vikram.pandita-l0cyMroinI0@public.gmane.org>
>> Signed-off-by: Shubhrajyoti D<shubhrajyoti-l0cyMroinI0@public.gmane.org>
>> ---
>>   drivers/i2c/busses/i2c-omap.c |   15 +++++++++++++--
>>   1 files changed, 13 insertions(+), 2 deletions(-)
>
>
> Reviewed-by: Rajeev Kumar <rajeev-dlh.kumar-qxv4g6HH51o@public.gmane.org>

Thanks for your review.
>
>
> ~Rajeev

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

end of thread, other threads:[~2011-10-25 13:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-24  6:51 [PATCH ] i2c: omap: recover from Bus Busy condition Shubhrajyoti D
     [not found] ` <1319439118-3800-1-git-send-email-shubhrajyoti-l0cyMroinI0@public.gmane.org>
2011-10-24  7:10   ` Rajeev kumar
     [not found]     ` <4EA50F7F.6000400-qxv4g6HH51o@public.gmane.org>
2011-10-25 13:09       ` Shubhrajyoti

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).