All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] i2c-bfin-twi: handle faulty slave devices better
@ 2010-05-09 11:04 ` Mike Frysinger
  0 siblings, 0 replies; 11+ messages in thread
From: Mike Frysinger @ 2010-05-09 11:04 UTC (permalink / raw)
  To: linux-i2c, Ben Dooks
  Cc: linux-kernel, Andrew Morton, uclinux-dist-devel, Michael Hennerich

From: Michael Hennerich <michael.hennerich@analog.com>

Faulty slave devices might drive SDA low after a transfer finishes.  So,
when this scenario is detected, have the master generate up to 8 extra
clocks until the SDA is properly released.

Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
Note: this requires the existing Blackfin TWI patches already sent out

 drivers/i2c/busses/i2c-bfin-twi.c |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/drivers/i2c/busses/i2c-bfin-twi.c b/drivers/i2c/busses/i2c-bfin-twi.c
index fb26e5c..f9c05e1 100644
--- a/drivers/i2c/busses/i2c-bfin-twi.c
+++ b/drivers/i2c/busses/i2c-bfin-twi.c
@@ -20,6 +20,7 @@
 #include <linux/completion.h>
 #include <linux/interrupt.h>
 #include <linux/platform_device.h>
+#include <linux/delay.h>
 
 #include <asm/blackfin.h>
 #include <asm/portmux.h>
@@ -159,6 +160,27 @@ static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface,
 		if (mast_stat & BUFWRERR)
 			dev_dbg(&iface->adap.dev, "Buffer Write Error\n");
 
+		/* Faulty salve devices, may drive SDA low after a transfer
+		 * finishes. To release the bus this code generates up to 8
+		 * extra clocks until SDA is released.
+		 */
+
+		if (read_MASTER_STAT(iface) & SDASEN) {
+			int cnt = 8;
+			do {
+				write_MASTER_CTL(iface, SCLOVR);
+				udelay(6);
+				write_MASTER_CTL(iface, 0);
+				udelay(6);
+			} while ((read_MASTER_STAT(iface) & SDASEN) && cnt--);
+
+			write_MASTER_CTL(iface, SDAOVR | SCLOVR);
+			udelay(6);
+			write_MASTER_CTL(iface, SDAOVR);
+			udelay(6);
+			write_MASTER_CTL(iface, 0);
+		}
+
 		/* If it is a quick transfer, only address without data,
 		 * not an err, return 1.
 		 */
-- 
1.7.1


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

* [PATCH] i2c-bfin-twi: handle faulty slave devices better
@ 2010-05-09 11:04 ` Mike Frysinger
  0 siblings, 0 replies; 11+ messages in thread
From: Mike Frysinger @ 2010-05-09 11:04 UTC (permalink / raw)
  To: linux-i2c-u79uwXL29TY76Z2rM5mHXA, Ben Dooks
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA, Andrew Morton,
	uclinux-dist-devel-ZG0+EudsQA8dtHy/vicBwGD2FQJk+8+b,
	Michael Hennerich

From: Michael Hennerich <michael.hennerich-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org>

Faulty slave devices might drive SDA low after a transfer finishes.  So,
when this scenario is detected, have the master generate up to 8 extra
clocks until the SDA is properly released.

Signed-off-by: Michael Hennerich <michael.hennerich-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org>
Signed-off-by: Mike Frysinger <vapier-aBrp7R+bbdUdnm+yROfE0A@public.gmane.org>
---
Note: this requires the existing Blackfin TWI patches already sent out

 drivers/i2c/busses/i2c-bfin-twi.c |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/drivers/i2c/busses/i2c-bfin-twi.c b/drivers/i2c/busses/i2c-bfin-twi.c
index fb26e5c..f9c05e1 100644
--- a/drivers/i2c/busses/i2c-bfin-twi.c
+++ b/drivers/i2c/busses/i2c-bfin-twi.c
@@ -20,6 +20,7 @@
 #include <linux/completion.h>
 #include <linux/interrupt.h>
 #include <linux/platform_device.h>
+#include <linux/delay.h>
 
 #include <asm/blackfin.h>
 #include <asm/portmux.h>
@@ -159,6 +160,27 @@ static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface,
 		if (mast_stat & BUFWRERR)
 			dev_dbg(&iface->adap.dev, "Buffer Write Error\n");
 
+		/* Faulty salve devices, may drive SDA low after a transfer
+		 * finishes. To release the bus this code generates up to 8
+		 * extra clocks until SDA is released.
+		 */
+
+		if (read_MASTER_STAT(iface) & SDASEN) {
+			int cnt = 8;
+			do {
+				write_MASTER_CTL(iface, SCLOVR);
+				udelay(6);
+				write_MASTER_CTL(iface, 0);
+				udelay(6);
+			} while ((read_MASTER_STAT(iface) & SDASEN) && cnt--);
+
+			write_MASTER_CTL(iface, SDAOVR | SCLOVR);
+			udelay(6);
+			write_MASTER_CTL(iface, SDAOVR);
+			udelay(6);
+			write_MASTER_CTL(iface, 0);
+		}
+
 		/* If it is a quick transfer, only address without data,
 		 * not an err, return 1.
 		 */
-- 
1.7.1

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

* Re: [PATCH] i2c-bfin-twi: handle faulty slave devices better
  2010-05-09 11:04 ` Mike Frysinger
  (?)
@ 2010-05-09 11:34 ` Ben Dooks
  2010-05-09 18:23     ` Mike Frysinger
  -1 siblings, 1 reply; 11+ messages in thread
From: Ben Dooks @ 2010-05-09 11:34 UTC (permalink / raw)
  To: Mike Frysinger
  Cc: linux-i2c, Ben Dooks, linux-kernel, Andrew Morton,
	uclinux-dist-devel, Michael Hennerich

On Sun, May 09, 2010 at 07:04:47AM -0400, Mike Frysinger wrote:
> From: Michael Hennerich <michael.hennerich@analog.com>
> 
> Faulty slave devices might drive SDA low after a transfer finishes.  So,
> when this scenario is detected, have the master generate up to 8 extra
> clocks until the SDA is properly released.
> 
> Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
> ---
> Note: this requires the existing Blackfin TWI patches already sent out

hmm, it is late in the -rc series for anything other than critical
bugfixes, will update series tomorrow.
 
>  drivers/i2c/busses/i2c-bfin-twi.c |   22 ++++++++++++++++++++++
>  1 files changed, 22 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-bfin-twi.c b/drivers/i2c/busses/i2c-bfin-twi.c
> index fb26e5c..f9c05e1 100644
> --- a/drivers/i2c/busses/i2c-bfin-twi.c
> +++ b/drivers/i2c/busses/i2c-bfin-twi.c
> @@ -20,6 +20,7 @@
>  #include <linux/completion.h>
>  #include <linux/interrupt.h>
>  #include <linux/platform_device.h>
> +#include <linux/delay.h>
>  
>  #include <asm/blackfin.h>
>  #include <asm/portmux.h>
> @@ -159,6 +160,27 @@ static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface,
>  		if (mast_stat & BUFWRERR)
>  			dev_dbg(&iface->adap.dev, "Buffer Write Error\n");
>  
> +		/* Faulty salve devices, may drive SDA low after a transfer
spello: slave

> +		 * finishes. To release the bus this code generates up to 8
> +		 * extra clocks until SDA is released.
> +		 */
> +
> +		if (read_MASTER_STAT(iface) & SDASEN) {
> +			int cnt = 8;
> +			do {
> +				write_MASTER_CTL(iface, SCLOVR);
> +				udelay(6);
> +				write_MASTER_CTL(iface, 0);
> +				udelay(6);
> +			} while ((read_MASTER_STAT(iface) & SDASEN) && cnt--);
> +
> +			write_MASTER_CTL(iface, SDAOVR | SCLOVR);
> +			udelay(6);
> +			write_MASTER_CTL(iface, SDAOVR);
> +			udelay(6);
> +			write_MASTER_CTL(iface, 0);
> +		}
> +
>  		/* If it is a quick transfer, only address without data,
>  		 * not an err, return 1.
>  		 */
> -- 
> 1.7.1
> 

-- 
-- 
Ben

Q:      What's a light-year?
A:      One-third less calories than a regular year.


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

* Re: [PATCH] i2c-bfin-twi: handle faulty slave devices better
@ 2010-05-09 18:23     ` Mike Frysinger
  0 siblings, 0 replies; 11+ messages in thread
From: Mike Frysinger @ 2010-05-09 18:23 UTC (permalink / raw)
  To: Ben Dooks
  Cc: linux-i2c, linux-kernel, Andrew Morton, uclinux-dist-devel,
	Michael Hennerich

On Sun, May 9, 2010 at 07:34, Ben Dooks wrote:
> On Sun, May 09, 2010 at 07:04:47AM -0400, Mike Frysinger wrote:
>> From: Michael Hennerich <michael.hennerich@analog.com>
>>
>> Faulty slave devices might drive SDA low after a transfer finishes.  So,
>> when this scenario is detected, have the master generate up to 8 extra
>> clocks until the SDA is properly released.
>>
>> Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
>> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
>> ---
>> Note: this requires the existing Blackfin TWI patches already sent out
>
> hmm, it is late in the -rc series for anything other than critical
> bugfixes, will update series tomorrow.

this patch is fine for 2.6.35, but the rest of the series should have
been merged for like 2.6.33 ...

>>  drivers/i2c/busses/i2c-bfin-twi.c |   22 ++++++++++++++++++++++
>>  1 files changed, 22 insertions(+), 0 deletions(-)
>>
>> diff --git a/drivers/i2c/busses/i2c-bfin-twi.c b/drivers/i2c/busses/i2c-bfin-twi.c
>> index fb26e5c..f9c05e1 100644
>> --- a/drivers/i2c/busses/i2c-bfin-twi.c
>> +++ b/drivers/i2c/busses/i2c-bfin-twi.c
>> @@ -20,6 +20,7 @@
>>  #include <linux/completion.h>
>>  #include <linux/interrupt.h>
>>  #include <linux/platform_device.h>
>> +#include <linux/delay.h>
>>
>>  #include <asm/blackfin.h>
>>  #include <asm/portmux.h>
>> @@ -159,6 +160,27 @@ static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface,
>>               if (mast_stat & BUFWRERR)
>>                       dev_dbg(&iface->adap.dev, "Buffer Write Error\n");
>>
>> +             /* Faulty salve devices, may drive SDA low after a transfer
> spello: slave

ok, i'll resend in a bit
-mike

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

* Re: [PATCH] i2c-bfin-twi: handle faulty slave devices better
@ 2010-05-09 18:23     ` Mike Frysinger
  0 siblings, 0 replies; 11+ messages in thread
From: Mike Frysinger @ 2010-05-09 18:23 UTC (permalink / raw)
  To: Ben Dooks
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, Andrew Morton,
	uclinux-dist-devel-ZG0+EudsQA8dtHy/vicBwGD2FQJk+8+b,
	Michael Hennerich

On Sun, May 9, 2010 at 07:34, Ben Dooks wrote:
> On Sun, May 09, 2010 at 07:04:47AM -0400, Mike Frysinger wrote:
>> From: Michael Hennerich <michael.hennerich-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org>
>>
>> Faulty slave devices might drive SDA low after a transfer finishes.  So,
>> when this scenario is detected, have the master generate up to 8 extra
>> clocks until the SDA is properly released.
>>
>> Signed-off-by: Michael Hennerich <michael.hennerich-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org>
>> Signed-off-by: Mike Frysinger <vapier-aBrp7R+bbdUdnm+yROfE0A@public.gmane.org>
>> ---
>> Note: this requires the existing Blackfin TWI patches already sent out
>
> hmm, it is late in the -rc series for anything other than critical
> bugfixes, will update series tomorrow.

this patch is fine for 2.6.35, but the rest of the series should have
been merged for like 2.6.33 ...

>>  drivers/i2c/busses/i2c-bfin-twi.c |   22 ++++++++++++++++++++++
>>  1 files changed, 22 insertions(+), 0 deletions(-)
>>
>> diff --git a/drivers/i2c/busses/i2c-bfin-twi.c b/drivers/i2c/busses/i2c-bfin-twi.c
>> index fb26e5c..f9c05e1 100644
>> --- a/drivers/i2c/busses/i2c-bfin-twi.c
>> +++ b/drivers/i2c/busses/i2c-bfin-twi.c
>> @@ -20,6 +20,7 @@
>>  #include <linux/completion.h>
>>  #include <linux/interrupt.h>
>>  #include <linux/platform_device.h>
>> +#include <linux/delay.h>
>>
>>  #include <asm/blackfin.h>
>>  #include <asm/portmux.h>
>> @@ -159,6 +160,27 @@ static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface,
>>               if (mast_stat & BUFWRERR)
>>                       dev_dbg(&iface->adap.dev, "Buffer Write Error\n");
>>
>> +             /* Faulty salve devices, may drive SDA low after a transfer
> spello: slave

ok, i'll resend in a bit
-mike

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

* [PATCH v2] i2c-bfin-twi: handle faulty slave devices better
@ 2010-05-10 15:33   ` Mike Frysinger
  0 siblings, 0 replies; 11+ messages in thread
From: Mike Frysinger @ 2010-05-10 15:33 UTC (permalink / raw)
  To: linux-i2c, Ben Dooks
  Cc: uclinux-dist-devel, linux-kernel, Andrew Morton, Michael Hennerich

From: Michael Hennerich <michael.hennerich@analog.com>

Faulty slave devices might drive SDA low after a transfer finishes.  So,
when this scenario is detected, have the master generate up to 9 extra
clocks until the SDA is properly released.

Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
v2
	- fix typo in comment pointed out by Ben
	- use 9 clocks rather than 8 to cover a possible NACK pointed out by Michael

 drivers/i2c/busses/i2c-bfin-twi.c |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/drivers/i2c/busses/i2c-bfin-twi.c b/drivers/i2c/busses/i2c-bfin-twi.c
index fb26e5c..1ee9d5a 100644
--- a/drivers/i2c/busses/i2c-bfin-twi.c
+++ b/drivers/i2c/busses/i2c-bfin-twi.c
@@ -20,6 +20,7 @@
 #include <linux/completion.h>
 #include <linux/interrupt.h>
 #include <linux/platform_device.h>
+#include <linux/delay.h>
 
 #include <asm/blackfin.h>
 #include <asm/portmux.h>
@@ -159,6 +160,27 @@ static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface,
 		if (mast_stat & BUFWRERR)
 			dev_dbg(&iface->adap.dev, "Buffer Write Error\n");
 
+		/* Faulty slave devices, may drive SDA low after a transfer
+		 * finishes. To release the bus this code generates up to 9
+		 * extra clocks until SDA is released.
+		 */
+
+		if (read_MASTER_STAT(iface) & SDASEN) {
+			int cnt = 9;
+			do {
+				write_MASTER_CTL(iface, SCLOVR);
+				udelay(6);
+				write_MASTER_CTL(iface, 0);
+				udelay(6);
+			} while ((read_MASTER_STAT(iface) & SDASEN) && cnt--);
+
+			write_MASTER_CTL(iface, SDAOVR | SCLOVR);
+			udelay(6);
+			write_MASTER_CTL(iface, SDAOVR);
+			udelay(6);
+			write_MASTER_CTL(iface, 0);
+		}
+
 		/* If it is a quick transfer, only address without data,
 		 * not an err, return 1.
 		 */
-- 
1.7.1


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

* [PATCH v2] i2c-bfin-twi: handle faulty slave devices better
@ 2010-05-10 15:33   ` Mike Frysinger
  0 siblings, 0 replies; 11+ messages in thread
From: Mike Frysinger @ 2010-05-10 15:33 UTC (permalink / raw)
  To: linux-i2c-u79uwXL29TY76Z2rM5mHXA, Ben Dooks
  Cc: uclinux-dist-devel-ZG0+EudsQA8dtHy/vicBwGD2FQJk+8+b,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, Andrew Morton,
	Michael Hennerich

From: Michael Hennerich <michael.hennerich-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org>

Faulty slave devices might drive SDA low after a transfer finishes.  So,
when this scenario is detected, have the master generate up to 9 extra
clocks until the SDA is properly released.

Signed-off-by: Michael Hennerich <michael.hennerich-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org>
Signed-off-by: Mike Frysinger <vapier-aBrp7R+bbdUdnm+yROfE0A@public.gmane.org>
---
v2
	- fix typo in comment pointed out by Ben
	- use 9 clocks rather than 8 to cover a possible NACK pointed out by Michael

 drivers/i2c/busses/i2c-bfin-twi.c |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/drivers/i2c/busses/i2c-bfin-twi.c b/drivers/i2c/busses/i2c-bfin-twi.c
index fb26e5c..1ee9d5a 100644
--- a/drivers/i2c/busses/i2c-bfin-twi.c
+++ b/drivers/i2c/busses/i2c-bfin-twi.c
@@ -20,6 +20,7 @@
 #include <linux/completion.h>
 #include <linux/interrupt.h>
 #include <linux/platform_device.h>
+#include <linux/delay.h>
 
 #include <asm/blackfin.h>
 #include <asm/portmux.h>
@@ -159,6 +160,27 @@ static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface,
 		if (mast_stat & BUFWRERR)
 			dev_dbg(&iface->adap.dev, "Buffer Write Error\n");
 
+		/* Faulty slave devices, may drive SDA low after a transfer
+		 * finishes. To release the bus this code generates up to 9
+		 * extra clocks until SDA is released.
+		 */
+
+		if (read_MASTER_STAT(iface) & SDASEN) {
+			int cnt = 9;
+			do {
+				write_MASTER_CTL(iface, SCLOVR);
+				udelay(6);
+				write_MASTER_CTL(iface, 0);
+				udelay(6);
+			} while ((read_MASTER_STAT(iface) & SDASEN) && cnt--);
+
+			write_MASTER_CTL(iface, SDAOVR | SCLOVR);
+			udelay(6);
+			write_MASTER_CTL(iface, SDAOVR);
+			udelay(6);
+			write_MASTER_CTL(iface, 0);
+		}
+
 		/* If it is a quick transfer, only address without data,
 		 * not an err, return 1.
 		 */
-- 
1.7.1

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

* Re: [PATCH v2] i2c-bfin-twi: handle faulty slave devices better
@ 2010-05-11 23:09     ` Ben Dooks
  0 siblings, 0 replies; 11+ messages in thread
From: Ben Dooks @ 2010-05-11 23:09 UTC (permalink / raw)
  To: Mike Frysinger
  Cc: linux-i2c, Ben Dooks, uclinux-dist-devel, linux-kernel,
	Andrew Morton, Michael Hennerich

On Mon, May 10, 2010 at 11:33:44AM -0400, Mike Frysinger wrote:
> From: Michael Hennerich <michael.hennerich@analog.com>
> 
> Faulty slave devices might drive SDA low after a transfer finishes.  So,
> when this scenario is detected, have the master generate up to 9 extra
> clocks until the SDA is properly released.

This doesn't apply to my for-2635/i2c-bfin tree, can't find the BUFWERR
patch. will check to see if theres's something i've missed..
 
> Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
> ---
> v2
> 	- fix typo in comment pointed out by Ben
> 	- use 9 clocks rather than 8 to cover a possible NACK pointed out by Michael
> 
>  drivers/i2c/busses/i2c-bfin-twi.c |   22 ++++++++++++++++++++++
>  1 files changed, 22 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-bfin-twi.c b/drivers/i2c/busses/i2c-bfin-twi.c
> index fb26e5c..1ee9d5a 100644
> --- a/drivers/i2c/busses/i2c-bfin-twi.c
> +++ b/drivers/i2c/busses/i2c-bfin-twi.c
> @@ -20,6 +20,7 @@
>  #include <linux/completion.h>
>  #include <linux/interrupt.h>
>  #include <linux/platform_device.h>
> +#include <linux/delay.h>
>  
>  #include <asm/blackfin.h>
>  #include <asm/portmux.h>
> @@ -159,6 +160,27 @@ static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface,
>  		if (mast_stat & BUFWRERR)
>  			dev_dbg(&iface->adap.dev, "Buffer Write Error\n");
>  
> +		/* Faulty slave devices, may drive SDA low after a transfer
> +		 * finishes. To release the bus this code generates up to 9
> +		 * extra clocks until SDA is released.
> +		 */
> +
> +		if (read_MASTER_STAT(iface) & SDASEN) {
> +			int cnt = 9;
> +			do {
> +				write_MASTER_CTL(iface, SCLOVR);
> +				udelay(6);
> +				write_MASTER_CTL(iface, 0);
> +				udelay(6);
> +			} while ((read_MASTER_STAT(iface) & SDASEN) && cnt--);
> +
> +			write_MASTER_CTL(iface, SDAOVR | SCLOVR);
> +			udelay(6);
> +			write_MASTER_CTL(iface, SDAOVR);
> +			udelay(6);
> +			write_MASTER_CTL(iface, 0);
> +		}
> +
>  		/* If it is a quick transfer, only address without data,
>  		 * not an err, return 1.
>  		 */
> -- 
> 1.7.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
Ben (ben@fluff.org, http://www.fluff.org/)

  'a smiley only costs 4 bytes'

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

* Re: [PATCH v2] i2c-bfin-twi: handle faulty slave devices better
@ 2010-05-11 23:09     ` Ben Dooks
  0 siblings, 0 replies; 11+ messages in thread
From: Ben Dooks @ 2010-05-11 23:09 UTC (permalink / raw)
  To: Mike Frysinger
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA, Ben Dooks,
	uclinux-dist-devel-ZG0+EudsQA8dtHy/vicBwGD2FQJk+8+b,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, Andrew Morton,
	Michael Hennerich

On Mon, May 10, 2010 at 11:33:44AM -0400, Mike Frysinger wrote:
> From: Michael Hennerich <michael.hennerich-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org>
> 
> Faulty slave devices might drive SDA low after a transfer finishes.  So,
> when this scenario is detected, have the master generate up to 9 extra
> clocks until the SDA is properly released.

This doesn't apply to my for-2635/i2c-bfin tree, can't find the BUFWERR
patch. will check to see if theres's something i've missed..
 
> Signed-off-by: Michael Hennerich <michael.hennerich-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org>
> Signed-off-by: Mike Frysinger <vapier-aBrp7R+bbdUdnm+yROfE0A@public.gmane.org>
> ---
> v2
> 	- fix typo in comment pointed out by Ben
> 	- use 9 clocks rather than 8 to cover a possible NACK pointed out by Michael
> 
>  drivers/i2c/busses/i2c-bfin-twi.c |   22 ++++++++++++++++++++++
>  1 files changed, 22 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-bfin-twi.c b/drivers/i2c/busses/i2c-bfin-twi.c
> index fb26e5c..1ee9d5a 100644
> --- a/drivers/i2c/busses/i2c-bfin-twi.c
> +++ b/drivers/i2c/busses/i2c-bfin-twi.c
> @@ -20,6 +20,7 @@
>  #include <linux/completion.h>
>  #include <linux/interrupt.h>
>  #include <linux/platform_device.h>
> +#include <linux/delay.h>
>  
>  #include <asm/blackfin.h>
>  #include <asm/portmux.h>
> @@ -159,6 +160,27 @@ static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface,
>  		if (mast_stat & BUFWRERR)
>  			dev_dbg(&iface->adap.dev, "Buffer Write Error\n");
>  
> +		/* Faulty slave devices, may drive SDA low after a transfer
> +		 * finishes. To release the bus this code generates up to 9
> +		 * extra clocks until SDA is released.
> +		 */
> +
> +		if (read_MASTER_STAT(iface) & SDASEN) {
> +			int cnt = 9;
> +			do {
> +				write_MASTER_CTL(iface, SCLOVR);
> +				udelay(6);
> +				write_MASTER_CTL(iface, 0);
> +				udelay(6);
> +			} while ((read_MASTER_STAT(iface) & SDASEN) && cnt--);
> +
> +			write_MASTER_CTL(iface, SDAOVR | SCLOVR);
> +			udelay(6);
> +			write_MASTER_CTL(iface, SDAOVR);
> +			udelay(6);
> +			write_MASTER_CTL(iface, 0);
> +		}
> +
>  		/* If it is a quick transfer, only address without data,
>  		 * not an err, return 1.
>  		 */
> -- 
> 1.7.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
Ben (ben-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org, http://www.fluff.org/)

  'a smiley only costs 4 bytes'

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

* Re: [PATCH v2] i2c-bfin-twi: handle faulty slave devices better
@ 2010-05-12  0:03       ` Mike Frysinger
  0 siblings, 0 replies; 11+ messages in thread
From: Mike Frysinger @ 2010-05-12  0:03 UTC (permalink / raw)
  To: Ben Dooks
  Cc: linux-i2c, uclinux-dist-devel, linux-kernel, Andrew Morton,
	Michael Hennerich

On Tue, May 11, 2010 at 19:09, Ben Dooks wrote:
> On Mon, May 10, 2010 at 11:33:44AM -0400, Mike Frysinger wrote:
>> From: Michael Hennerich <michael.hennerich@analog.com>
>>
>> Faulty slave devices might drive SDA low after a transfer finishes.  So,
>> when this scenario is detected, have the master generate up to 9 extra
>> clocks until the SDA is properly released.
>
> This doesn't apply to my for-2635/i2c-bfin tree, can't find the BUFWERR
> patch. will check to see if theres's something i've missed..

have you applied the other Blackfin I2C patches yet ?  the bfin i2c
branch applies cleanly to linus' current tree:
  git://git.kernel.org/pub/scm/linux/kernel/git/vapier/blackfin.git for-i2c
-mike

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

* Re: [PATCH v2] i2c-bfin-twi: handle faulty slave devices better
@ 2010-05-12  0:03       ` Mike Frysinger
  0 siblings, 0 replies; 11+ messages in thread
From: Mike Frysinger @ 2010-05-12  0:03 UTC (permalink / raw)
  To: Ben Dooks
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	uclinux-dist-devel-ZG0+EudsQA8dtHy/vicBwGD2FQJk+8+b,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, Andrew Morton,
	Michael Hennerich

On Tue, May 11, 2010 at 19:09, Ben Dooks wrote:
> On Mon, May 10, 2010 at 11:33:44AM -0400, Mike Frysinger wrote:
>> From: Michael Hennerich <michael.hennerich-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org>
>>
>> Faulty slave devices might drive SDA low after a transfer finishes.  So,
>> when this scenario is detected, have the master generate up to 9 extra
>> clocks until the SDA is properly released.
>
> This doesn't apply to my for-2635/i2c-bfin tree, can't find the BUFWERR
> patch. will check to see if theres's something i've missed..

have you applied the other Blackfin I2C patches yet ?  the bfin i2c
branch applies cleanly to linus' current tree:
  git://git.kernel.org/pub/scm/linux/kernel/git/vapier/blackfin.git for-i2c
-mike

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

end of thread, other threads:[~2010-05-12  0:04 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-05-09 11:04 [PATCH] i2c-bfin-twi: handle faulty slave devices better Mike Frysinger
2010-05-09 11:04 ` Mike Frysinger
2010-05-09 11:34 ` Ben Dooks
2010-05-09 18:23   ` Mike Frysinger
2010-05-09 18:23     ` Mike Frysinger
2010-05-10 15:33 ` [PATCH v2] " Mike Frysinger
2010-05-10 15:33   ` Mike Frysinger
2010-05-11 23:09   ` Ben Dooks
2010-05-11 23:09     ` Ben Dooks
2010-05-12  0:03     ` Mike Frysinger
2010-05-12  0:03       ` Mike Frysinger

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.