Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 29 Nov 2006 05:06:14 GMT
From:      Warner Losh <imp@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 110655 for review
Message-ID:  <200611290506.kAT56Eff099087@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=110655

Change 110655 by imp@imp_lighthouse on 2006/11/29 05:05:17

	
	Add some debug writes to try to track down why the eeprom
	hangs when we try to write to it when write enable is held
	high disabling write.  I'm unsure how to detect this, but it
	seems to require a power cycle to reset the eeprom.

Affected files ...

.. //depot/projects/arm/src/sys/arm/at91/at91_twi.c#34 edit

Differences ...

==== //depot/projects/arm/src/sys/arm/at91/at91_twi.c#34 (text+ko) ====

@@ -224,11 +224,16 @@
 {
 	int err = 0;
 	int counter = 100000;
+	uint32_t sr;
 
-	while (!(RD4(sc, TWI_SR) & bit) && counter-- > 0)
+	while (!((sr = RD4(sc, TWI_SR)) & bit) && counter-- > 0)
 		continue;
 	if (counter <= 0)
 		err = EBUSY;
+	else if (sr & TWI_SR_NACK)
+		err = EADDRNOTAVAIL;
+	if (sr & ~bit)
+		printf("status is %x\n", sr);
 	return (err);
 }
 
@@ -331,14 +336,20 @@
 				WR4(sc, TWI_THR, *buf++);
 				if (len == 0)
 					WR4(sc, TWI_CR, TWI_CR_STOP);
-				if ((err = at91_twi_wait(sc, TWI_SR_TXRDY)))
+				if ((err = at91_twi_wait(sc, TWI_SR_TXRDY))) {
+					printf("Len %d\n", len);
 					goto out;
+				}
 			}
 		}
 		if ((err = at91_twi_wait(sc, TWI_SR_TXCOMP)))
 			break;
 	}
 out:;
+	if (err) {
+		WR4(sc, TWI_CR, TWI_CR_STOP);
+		printf("Err is %d\n", err);
+	}
 	AT91_TWI_UNLOCK(sc);
 	return (err);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200611290506.kAT56Eff099087>