From: Ben Dooks <ben-linux@fluff.org>
To: Mike Frysinger <vapier@gentoo.org>
Cc: linux-i2c@vger.kernel.org, Ben Dooks <ben-linux@fluff.org>,
uclinux-dist-devel@blackfin.uclinux.org,
linux-kernel@vger.kernel.org,
Andrew Morton <akpm@linux-foundation.org>,
Michael Hennerich <michael.hennerich@analog.com>
Subject: Re: [PATCH v2] i2c-bfin-twi: handle faulty slave devices better
Date: Wed, 12 May 2010 00:09:01 +0100 [thread overview]
Message-ID: <20100511230901.GA31325@fluff.org.uk> (raw)
In-Reply-To: <1273505624-30920-1-git-send-email-vapier@gentoo.org>
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'
next prev parent reply other threads:[~2010-05-11 23:09 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-09 11:04 [PATCH] " Mike Frysinger
2010-05-09 11:34 ` Ben Dooks
2010-05-09 18:23 ` Mike Frysinger
2010-05-10 15:33 ` [PATCH v2] " Mike Frysinger
2010-05-11 23:09 ` Ben Dooks [this message]
2010-05-12 0:03 ` Mike Frysinger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100511230901.GA31325@fluff.org.uk \
--to=ben-linux@fluff.org \
--cc=akpm@linux-foundation.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michael.hennerich@analog.com \
--cc=uclinux-dist-devel@blackfin.uclinux.org \
--cc=vapier@gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome