public inbox for linuxppc-dev@ozlabs.org 
 help / color / mirror / Atom feed
From: Domen Puncer <domen.puncer@telargo•com>
To: linuxppc-embedded@ozlabs•org
Subject: Re: Howto read I2C on MPC5200 Lite
Date: Thu, 15 Mar 2007 10:57:58 +0100	[thread overview]
Message-ID: <20070315095758.GE14658@moe.telargo.com> (raw)
In-Reply-To: <20070311005535.GA39488@server.idefix.lan>

On 11/03/07 01:55 +0100, Matthias Fechner wrote:
> Hi,
> 
> * Matthias Fechner <idefix@fechner•net> [10-03-07 00:42]:
> > It seems now that everything works fine. I will check it for the next
> > days. And will give some feedback.
> 
> ok, I checked now the driver some time at it failed. So it seems that
> that the patch had not solved the problem.
> 
> I have attached the programm to check it.

But not for built-in eeprom :-P
Anyway, I managed to reproduce some problems, and hopefully "fix" them.
One problem seems to be fixed by disabling i2c on stop,
another looks like it's:
http://ozlabs.org/pipermail/linuxppc-embedded/2005-July/019038.html

Can you please try following patch.


	Domen


diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
index ee65aa1..522f485 100644
--- a/drivers/i2c/busses/i2c-mpc.c
+++ b/drivers/i2c/busses/i2c-mpc.c
@@ -75,6 +75,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;
@@ -154,6 +168,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();
 }
 
 static int mpc_write(struct mpc_i2c *i2c, int target,
@@ -246,6 +263,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-03-15  9:58 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-07 12:24 Howto read I2C on MPC5200 Lite Matthias Fechner
2007-03-07 21:17 ` John Rigby
2007-03-09 11:35   ` Matthias Fechner
2007-03-09 17:11     ` John Rigby
2007-03-09 23:42       ` Matthias Fechner
2007-03-10  2:18         ` where and how to get the latest 2.6 kernel Nick Droogh
2007-03-11  1:01           ` Matthias Fechner
2007-03-11  0:55         ` Howto read I2C on MPC5200 Lite Matthias Fechner
2007-03-15  9:57           ` Domen Puncer [this message]
2007-03-16  4:33             ` Matthias Fechner
2007-03-17  8:57             ` Matthias Fechner
2007-03-18 19:06               ` Charles Krinke
2007-03-18 19:11                 ` gdb question regarding step vs breakpoint Charles Krinke
2007-03-18 23:28                   ` Matthias Fechner
2007-03-19  0:14                 ` Howto read I2C on MPC5200 Lite Wolfgang Denk
2007-03-19  1:11                 ` A question regarding step and breakpoints Charles Krinke
2007-03-21  8:34               ` Howto read I2C on MPC5200 Lite Matthias Fechner
2007-04-04  8:49                 ` Domen Puncer
2007-04-25 18:48                   ` Matthias Fechner

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=20070315095758.GE14658@moe.telargo.com \
    --to=domen.puncer@telargo$(echo .)com \
    --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