summaryrefslogtreecommitdiff
path: root/cpu
diff options
context:
space:
mode:
authorwdenk <wdenk>2004-10-10 18:03:33 +0000
committerwdenk <wdenk>2004-10-10 18:03:33 +0000
commitb65085130aed33584d95502c20317ad4379c1ca6 (patch)
treeeed2284bd6c1d9336df1ba926a1c6f2be8b876ff /cpu
parent2cbe571a5676a41aa32ff98e9b1a2934e3922574 (diff)
downloadu-boot-imx-b65085130aed33584d95502c20317ad4379c1ca6.zip
u-boot-imx-b65085130aed33584d95502c20317ad4379c1ca6.tar.gz
u-boot-imx-b65085130aed33584d95502c20317ad4379c1ca6.tar.bz2
Code Cleanup
Patch by Gary Jennejohn, 04 Oct 2004: - fix I2C on at91rm9200 - add support for Ricoh RS5C372A RTC
Diffstat (limited to 'cpu')
-rw-r--r--cpu/at91rm9200/i2c.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/cpu/at91rm9200/i2c.c b/cpu/at91rm9200/i2c.c
index d5d6268d..515792c 100644
--- a/cpu/at91rm9200/i2c.c
+++ b/cpu/at91rm9200/i2c.c
@@ -60,7 +60,6 @@ at91_xfer(unsigned char chip, unsigned int addr, int alen,
AT91PS_TWI twi = (AT91PS_TWI) AT91_TWI_BASE;
int length;
unsigned char *buf;
-
/* Set the TWI Master Mode Register */
twi->TWI_MMR = (chip << 16) | (alen << 8)
| ((rw == 1) ? AT91C_TWI_MREAD : 0);
@@ -126,13 +125,15 @@ int
i2c_read(unsigned char chip, unsigned int addr, int alen,
unsigned char *buffer, int len)
{
+#ifdef CFG_I2C_EEPROM_ADDR_OVERFLOW
/* we only allow one address byte */
if (alen > 1)
return 1;
-#ifdef CFG_I2C_EEPROM_ADDR_OVERFLOW
/* XXX assume an ATMEL AT24C16 */
if (alen == 1) {
+#if 0 /* EEPROM code already sets this correctly */
chip |= (addr >> 8) & 0xff;
+#endif
addr = addr & 0xff;
}
#endif
@@ -146,22 +147,25 @@ i2c_write(unsigned char chip, unsigned int addr, int alen,
int i;
unsigned char *buf;
+#ifdef CFG_I2C_EEPROM_ADDR_OVERFLOW
/* we only allow one address byte */
if (alen > 1)
return 1;
-#ifdef CFG_I2C_EEPROM_ADDR_OVERFLOW
/* XXX assume an ATMEL AT24C16 */
if (alen == 1) {
buf = buffer;
/* do single byte writes */
for (i = 0; i < len; i++) {
+#if 0 /* EEPROM code already sets this correctly */
chip |= (addr >> 8) & 0xff;
+#endif
addr = addr & 0xff;
if (at91_xfer(chip, addr, alen, buf++, 1, 0))
return 1;
+ addr++;
}
+ return 0;
}
- return 0;
#endif
return at91_xfer(chip, addr, alen, buffer, len, 0);
}