mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: barebox@lists.infradead.org, kernel@pengutronix.de
Subject: Re: [PATCH] [RFC] i2c-imx: send a soft bus reset during probe
Date: Fri, 28 Sep 2012 16:19:15 +0200	[thread overview]
Message-ID: <20120928141915.GF16606@pengutronix.de> (raw)
In-Reply-To: <20120927095312.GU1322@pengutronix.de>

Hello,

On Thu, Sep 27, 2012 at 11:53:12AM +0200, Sascha Hauer wrote:
> Sounds good. We often have this problem.
> 
> I wonder if it's worth to have this as a general callback in the i2c
> layer.
Unfortunately my patch doesn't work. The problem is that if an i2c slave
is stuck with sda low the imx diagnoses a loss of arbitration before
even trying to start pulling SDA low to create a start indication.

So I have to use gpio bitbanging and there is no chance to implement
this in generic code only.

> On Thu, Sep 27, 2012 at 12:56:46AM +0200, Uwe Kleine-König wrote:
> > If an i2c slave pulls SDA low when the SoC wants to start a transfer, it
> > cannot get the bus. This can happen for example if the SoC is reset when
> > it just successfully addressed a slave but before it rises SCL for the
> > slave to ack. Currently this makes the driver refuse to do anything. You
> > can force this situation with the following code assuming you have a
> > device on address 0x50:
> > 
BTW, part of the reason I first thought my patch would help is that this
recipe is wrong...

> > 	/* generate a start condition */
> > 	gpio_direction_input(I2CSCL);
> > 	gpio_direction_input(I2CSDA);
> > 	mdelay(1);
> > 	gpio_direction_output(I2CSDA, 0);
> > 
> > 	mdelay(1);
> > 
> > 	/* address device 0x50 */
> > 	for (i = 0; i < 8; ++i) {
> > 		gpio_direction_output(I2CSCL, 0);
> > 		mdelay(1);
> > 		if ((0x50 << 1) >> (7 - i))
... This has to read: if ((0x50 << 1) & (1 << (7 - i))) to actually
stuck the device with address 0x50.

> > 			gpio_direction_input(I2CSDA);
> > 		else
> > 			gpio_direction_output(I2CSDA, 0);
> > 		mdelay(1);
> > 		gpio_direction_input(I2CSCL);
> > 		mdelay(1);
> > 	}
> > 	gpio_direction_output(I2CSCL, 0);
> > 
> > 	reset_cpu(0);
> > 
(And my bus reset used to help because I asserted that the pinmuxing is
right before the reset but not after this stuck recipe, sigh ⊙_◎.)

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

      parent reply	other threads:[~2012-09-28 14:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-26 22:56 Uwe Kleine-König
2012-09-27  9:53 ` Sascha Hauer
2012-09-27 10:33   ` Johannes Stezenbach
2012-09-28 10:10     ` Uwe Kleine-König
2012-09-27 11:02   ` Wolfram Sang
2012-09-28 14:19   ` Uwe Kleine-König [this message]

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=20120928141915.GF16606@pengutronix.de \
    --to=u.kleine-koenig@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=kernel@pengutronix.de \
    --cc=s.hauer@pengutronix.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox