public inbox for linuxppc-dev@ozlabs.org 
 help / color / mirror / Atom feed
From: Domen Puncer <domen.puncer@telargo•com>
To: Grant Likely <grant.likely@secretlab•ca>
Cc: khali@linux-fr•org, i2c@lm-sensors•org, linuxppc-embedded@ozlabs•org
Subject: Re: [PATCH] i2c-mpc: work around missing-9th-clock-pulse bug
Date: Tue, 10 Jul 2007 08:17:36 +0200	[thread overview]
Message-ID: <20070710061736.GG4186@moe.telargo.com> (raw)
In-Reply-To: <fa686aa40707090853j6079b0c7rbcff7c449baa15e0@mail.gmail.com>

On 09/07/07 09:53 -0600, Grant Likely wrote:
> On 7/9/07, Domen Puncer <domen.puncer@telargo•com> wrote:
> >Work around a problem reported on:
> >http://ozlabs.org/pipermail/linuxppc-embedded/2005-July/019038.html
> >Without this patch I2C on mpc5200 becomes unusable after a while.
> >Tested on mpc5200 based boards by Matthias and me.
> >
> >Index: work-powerpc.git/drivers/i2c/busses/i2c-mpc.c
> >===================================================================
> >--- work-powerpc.git.orig/drivers/i2c/busses/i2c-mpc.c
> >+++ work-powerpc.git/drivers/i2c/busses/i2c-mpc.c
> >@@ -153,6 +167,9 @@ static void mpc_i2c_start(struct mpc_i2c
> > static void mpc_i2c_stop(struct mpc_i2c *i2c)
> > {
> >        writeccr(i2c, CCR_MEN);
> >+       mb();
> >+       writeccr(i2c, 0);
> >+       mb();
> > }
> 
> Are the mb() calls necessary?  The writeccr path includes eieio; is
> that not sufficient?

Right, v2:


Work around a problem reported on:
http://ozlabs.org/pipermail/linuxppc-embedded/2005-July/019038.html
Without this patch I2C on mpc5200 becomes unusable after a while.
Tested on mpc5200 boards by Matthias and me.


Signed-off-by: Domen Puncer <domen.puncer@telargo•com>

---
 drivers/i2c/busses/i2c-mpc.c |   17 +++++++++++++++++
 1 file changed, 17 insertions(+)

Index: work-powerpc.git/drivers/i2c/busses/i2c-mpc.c
===================================================================
--- work-powerpc.git.orig/drivers/i2c/busses/i2c-mpc.c
+++ work-powerpc.git/drivers/i2c/busses/i2c-mpc.c
@@ -74,6 +74,20 @@ static irqreturn_t mpc_i2c_isr(int irq, 
 	return IRQ_HANDLED;
 }
 
+static void mpc_i2c_fixup(struct mpc_i2c *i2c)
+{
+	writeccr(i2c, 0);
+	udelay(30);
+	writeccr(i2c, CCR_MEN);
+	udelay(30);
+	writeccr(i2c, CCR_MSTA | CCR_MTX);
+	udelay(30);
+	writeccr(i2c, CCR_MSTA | CCR_MTX | CCR_MEN);
+	udelay(30);
+	writeccr(i2c, CCR_MEN);
+	udelay(30);
+}
+
 static int i2c_wait(struct mpc_i2c *i2c, unsigned timeout, int writing)
 {
 	unsigned long orig_jiffies = jiffies;
@@ -153,6 +167,7 @@ static void mpc_i2c_start(struct mpc_i2c
 static void mpc_i2c_stop(struct mpc_i2c *i2c)
 {
 	writeccr(i2c, CCR_MEN);
+	writeccr(i2c, 0);
 }
 
 static int mpc_write(struct mpc_i2c *i2c, int target,
@@ -245,6 +260,8 @@ static int mpc_xfer(struct i2c_adapter *
 		}
 		if (time_after(jiffies, orig_jiffies + HZ)) {
 			pr_debug("I2C: timeout\n");
+			if (readb(i2c->base + MPC_I2C_SR) == (CSR_MCF | CSR_MBB | CSR_RXAK))
+				mpc_i2c_fixup(i2c);
 			return -EIO;
 		}
 		schedule();

  reply	other threads:[~2007-07-10  6:17 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-09  7:19 [PATCH] i2c-mpc: work around missing-9th-clock-pulse bug Domen Puncer
2007-07-09 15:53 ` Grant Likely
2007-07-10  6:17   ` Domen Puncer [this message]
2007-07-10  6:22     ` Grant Likely
2007-07-10 12:40       ` Jean Delvare
2007-07-11  5:49         ` Domen Puncer
2007-07-11  6:03           ` Grant Likely
2007-07-11  6:33             ` Domen Puncer
2007-07-11 11:40               ` Jean Delvare
2007-07-21  0:03 ` [i2c] " Guennadi Liakhovetski
2007-07-24  5:14   ` [PATCH] i2c-mpc: don't disable I2C module on stop condition Domen Puncer
2007-08-08 17:19     ` Jean Delvare
2007-08-08 18:33       ` Guennadi Liakhovetski

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=20070710061736.GG4186@moe.telargo.com \
    --to=domen.puncer@telargo$(echo .)com \
    --cc=grant.likely@secretlab$(echo .)ca \
    --cc=i2c@lm-sensors$(echo .)org \
    --cc=khali@linux-fr$(echo .)org \
    --cc=linuxppc-embedded@ozlabs$(echo .)org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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