[i2c] [PATCH 04/12] i2c-au1550: Fix timeout problem

Jean Delvare khali at linux-fr.org
Sun Aug 13 23:35:40 CEST 2006


From: Domen Puncer <domen.puncer at ultra.si>
Content-Disposition: inline; filename=i2c-au1550-fix-timeout-problem.patch

i2c-au1550: Fix timeout problem

Fix from Jordan Crouse:
If the transmit and recieve FIFOS are not empty, forceably flush them
rather then waiting for them to drain on their own.

This solves at least a problem reported by Clem Taylor:
http://www.linux-mips.org/archives/linux-mips/2006-05/msg00240.html
(1% of I2C transactions would timeout)

Signed-off-by: Domen Puncer <domen.puncer at ultra.si>
Signed-off-by: Jean Delvare <khali at linux-fr.org>
---
 drivers/i2c/busses/i2c-au1550.c |   14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

--- linux-2.6.17-git.orig/drivers/i2c/busses/i2c-au1550.c	2006-07-03 09:32:13.000000000 +0200
+++ linux-2.6.17-git/drivers/i2c/busses/i2c-au1550.c	2006-07-05 18:35:32.000000000 +0200
@@ -118,13 +118,19 @@
 
 	/* Reset the FIFOs, clear events.
 	*/
-	sp->psc_smbpcr = PSC_SMBPCR_DC;
+	stat = sp->psc_smbstat;
 	sp->psc_smbevnt = PSC_SMBEVNT_ALLCLR;
 	au_sync();
-	do {
-		stat = sp->psc_smbpcr;
+
+	if (!(stat & PSC_SMBSTAT_TE) || !(stat & PSC_SMBSTAT_RE)) {
+		sp->psc_smbpcr = PSC_SMBPCR_DC;
 		au_sync();
-	} while ((stat & PSC_SMBPCR_DC) != 0);
+		do {
+			stat = sp->psc_smbpcr;
+			au_sync();
+		} while ((stat & PSC_SMBPCR_DC) != 0);
+		udelay(50);
+	}
 
 	/* Write out the i2c chip address and specify operation
 	*/

-- 
Jean Delvare



More information about the i2c mailing list