public inbox for linuxppc-dev@ozlabs.org 
 help / color / mirror / Atom feed
From: Domen Puncer <domen.puncer@telargo•com>
To: Guennadi Liakhovetski <g.liakhovetski@gmx•de>
Cc: khali@linux-fr•org, i2c@lm-sensors•org, linuxppc-embedded@ozlabs•org
Subject: [PATCH] i2c-mpc: don't disable I2C module on stop condition.
Date: Tue, 24 Jul 2007 07:14:31 +0200	[thread overview]
Message-ID: <20070724051431.GF4529@moe.telargo.com> (raw)
In-Reply-To: <Pine.LNX.4.60.0707210154330.3946@poirot.grange>

Disabling module on stop doesn't work on some CPUs (ie. mpc8241,
as reported by Guennadi Liakhovetski), so remove that.

Disable I2C module on errors/interrupts to prevent it from
locking up on mpc5200b.


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

So I fixed i2c on one board, and broke it on another :-(
This patch works on both Guennadi's and mine (hey, it might break
a third one!).
Jean, can you please push this, if there are no objections
and "doesn't work for me" reports.


	Domen


 drivers/i2c/busses/i2c-mpc.c |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

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
@@ -105,6 +105,7 @@ static int i2c_wait(struct mpc_i2c *i2c,
 			schedule();
 			if (time_after(jiffies, orig_jiffies + timeout)) {
 				pr_debug("I2C: timeout\n");
+				writeccr(i2c, 0);
 				result = -EIO;
 				break;
 			}
@@ -116,10 +117,12 @@ static int i2c_wait(struct mpc_i2c *i2c,
 		result = wait_event_interruptible_timeout(i2c->queue,
 			(i2c->interrupt & CSR_MIF), timeout * HZ);
 
-		if (unlikely(result < 0))
+		if (unlikely(result < 0)) {
 			pr_debug("I2C: wait interrupted\n");
-		else if (unlikely(!(i2c->interrupt & CSR_MIF))) {
+			writeccr(i2c, 0);
+		} else if (unlikely(!(i2c->interrupt & CSR_MIF))) {
 			pr_debug("I2C: wait timeout\n");
+			writeccr(i2c, 0);
 			result = -ETIMEDOUT;
 		}
 
@@ -172,7 +175,6 @@ 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,
@@ -261,6 +263,7 @@ static int mpc_xfer(struct i2c_adapter *
 	while (readb(i2c->base + MPC_I2C_SR) & CSR_MBB) {
 		if (signal_pending(current)) {
 			pr_debug("I2C: Interrupted\n");
+			writeccr(i2c, 0);
 			return -EINTR;
 		}
 		if (time_after(jiffies, orig_jiffies + HZ)) {

  reply	other threads:[~2007-07-24  5:14 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
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   ` Domen Puncer [this message]
2007-08-08 17:19     ` [PATCH] i2c-mpc: don't disable I2C module on stop condition 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=20070724051431.GF4529@moe.telargo.com \
    --to=domen.puncer@telargo$(echo .)com \
    --cc=g.liakhovetski@gmx$(echo .)de \
    --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