All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mike Frysinger <vapier@gentoo.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] i2c: fix SDA contention in read_byte()
Date: Sun, 11 Jul 2010 18:55:04 -0400	[thread overview]
Message-ID: <201007111855.06308.vapier@gentoo.org> (raw)
In-Reply-To: <AANLkTikUom99jC9Wjc0jejiG814_zsGIq7DmjtAMp8Go@mail.gmail.com>

On Wednesday, July 07, 2010 00:45:42 Andrew Dyer wrote:
> On Tue, Jul 6, 2010 at 1:14 AM, Thomas Chou <thomas@wytron.com.tw> wrote:
> > We should not set SDA after TRISTATE, as it results in contention.
> > 
> > Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
> > ---
> >  drivers/i2c/soft_i2c.c |    2 +-
> >  1 files changed, 1 insertions(+), 1 deletions(-)
> > 
> > diff --git a/drivers/i2c/soft_i2c.c b/drivers/i2c/soft_i2c.c
> > index 847db76..344b7f8 100644
> > --- a/drivers/i2c/soft_i2c.c
> > +++ b/drivers/i2c/soft_i2c.c
> > @@ -305,8 +305,8 @@ static uchar read_byte(int ack)
> >        /*
> >         * Read 8 bits, MSB first.
> >         */
> > -       I2C_TRISTATE;
> >        I2C_SDA(1);
> > +       I2C_TRISTATE;
> >        data = 0;
> >        for(j = 0; j < 8; j++) {
> >                I2C_SCL(0);
> > --
> 
> I2C_TRISTATE is supposed to be persistent until I2C_ACTIVE is called,
> so in the original code it should still be in effect when I2C_SDA(1)
> is executed and there should be no contention.  This patch causes the
> code to actively drive SDA high at the same time the addressed device
> might be driving it low, causing contention until the I2C_TRISTATE
> takes effect.
> 
> In some sense the code is misleadingly written, as it is not allowed
> in the spec to actively drive a '1' on the bus, a chip is only
> supposed to drive 'z' or '0', and the platform is supposed to provide
> the pullup current.  This comes more into play if the i2c bus supports
> clock stretching or arbitration among multiple masters.

how do you propose we get i2c gpio working ?  it works fine under Linux.  we 
cannot tristate a pin (set the gpio to an input) and then turn around and 
attempt to drive it (set the gpio to an output with a specific value).  that 
is what the code currently does.

our end goal is simple: have i2c gpio bitbanging work under u-boot like under 
linux.  we dont really care about the exact way we get there.  this patch was 
just one idea.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20100711/63b1adc8/attachment.pgp 

  parent reply	other threads:[~2010-07-11 22:55 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-06  6:14 [U-Boot] [PATCH] i2c: fix SDA contention in read_byte() Thomas Chou
2010-07-07  4:45 ` Andrew Dyer
2010-07-07  5:00   ` Reinhard Meyer
2010-07-12  4:14     ` Thomas Chou
2010-07-12  5:00       ` Reinhard Meyer
2010-07-12  5:51         ` Thomas Chou
2010-07-12  6:49           ` Reinhard Meyer
2010-07-14  1:29             ` Thomas Chou
2010-07-14  6:31               ` Reinhard Meyer
2010-07-21 17:40       ` Mike Frysinger
2010-07-22  2:47         ` Thomas Chou
2010-07-11 22:55   ` Mike Frysinger [this message]
2010-07-12  3:47     ` Andrew Dyer

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=201007111855.06308.vapier@gentoo.org \
    --to=vapier@gentoo.org \
    --cc=u-boot@lists.denx.de \
    /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 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.