PERFORCE change 110655 for review
Warner Losh
imp at FreeBSD.org
Tue Nov 28 23:09:45 PST 2006
http://perforce.freebsd.org/chv.cgi?CH=110655
Change 110655 by imp at 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);
}
More information about the p4-projects
mailing list