Date: Thu, 29 Jun 2006 21:05:17 GMT From: Warner Losh <imp@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 100315 for review Message-ID: <200606292105.k5TL5HkW022087@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=100315 Change 100315 by imp@imp_lighthouse on 2006/06/29 21:04:46 Add support for multiple EEPROM devices on the iic bus. Or at least for devices not at address 0. Affected files ... .. //depot/projects/arm/src/sys/boot/arm/at91/bootiic/env_vars.c#11 edit .. //depot/projects/arm/src/sys/boot/arm/at91/libat91/eeprom.c#5 edit .. //depot/projects/arm/src/sys/boot/arm/at91/libat91/lib.h#11 edit Differences ... ==== //depot/projects/arm/src/sys/boot/arm/at91/bootiic/env_vars.c#11 (text+ko) ==== @@ -98,7 +98,7 @@ *cPtr++ = 0; } - WriteEEPROM((unsigned)&BootCommandSection, env_table, + WriteEEPROM(0, (unsigned)&BootCommandSection, env_table, sizeof(env_table)); } ==== //depot/projects/arm/src/sys/boot/arm/at91/libat91/eeprom.c#5 (text+ko) ==== @@ -83,7 +83,7 @@ * .KB_C_FN_DEFINITION_END */ void -ReadEEPROM(unsigned ee_addr, char *data_addr, unsigned size) +ReadEEPROM(unsigned addr, unsigned ee_off, char *data_addr, unsigned size) { const AT91PS_TWI twiPtr = AT91C_BASE_TWI; unsigned int status; @@ -92,11 +92,11 @@ status = twiPtr->TWI_RHR; // Set the TWI Master Mode Register - twiPtr->TWI_MMR = (TWSI_EEPROM_ADDRESS << 16) | + twiPtr->TWI_MMR = ((TWSI_EEPROM_ADDRESS | addr) << 16) | AT91C_TWI_IADRSZ_2_BYTE | AT91C_TWI_MREAD; // Set TWI Internal Address Register - twiPtr->TWI_IADR = ee_addr; + twiPtr->TWI_IADR = ee_off; // Start transfer twiPtr->TWI_CR = AT91C_TWI_START; @@ -128,8 +128,8 @@ /* * .KB_C_FN_DEFINITION_START - * void WriteEEPROM(unsigned ee_addr, char *data_addr, unsigned size) - * This global function writes data to the eeprom at ee_addr using data + * void WriteEEPROM(unsigned ee_off, char *data_addr, unsigned size) + * This global function writes data to the eeprom at ee_off using data * from data_addr for size bytes. Assume the TWI has been initialized. * This function does not utilize the page write mode as the write time is * much greater than the time required to access the device for byte-write @@ -137,22 +137,22 @@ * .KB_C_FN_DEFINITION_END */ void -WriteEEPROM(unsigned ee_addr, char *data_addr, unsigned size) +WriteEEPROM(unsigned addr, unsigned ee_off, char *data_addr, unsigned size) { const AT91PS_TWI twiPtr = AT91C_BASE_TWI; unsigned status; char test_data; while (size--) { - if (!(ee_addr & 0x3f)) + if (!(ee_off & 0x3f)) putchar('.'); // Set the TWI Master Mode Register - twiPtr->TWI_MMR = ((TWSI_EEPROM_ADDRESS << 16) | + twiPtr->TWI_MMR = (((TWSI_EEPROM_ADDRESS | addr) << 16) | AT91C_TWI_IADRSZ_2_BYTE) & ~AT91C_TWI_MREAD; // Set TWI Internal Address Register - twiPtr->TWI_IADR = ee_addr++; + twiPtr->TWI_IADR = ee_off++; status = twiPtr->TWI_SR; @@ -173,7 +173,7 @@ continue; // wait for write operation to complete - ReadEEPROM(ee_addr, &test_data, 1); + ReadEEPROM(addr, ee_off, &test_data, 1); } putchar('\r'); ==== //depot/projects/arm/src/sys/boot/arm/at91/libat91/lib.h#11 (text) ==== @@ -33,8 +33,9 @@ /* The following function write eeprom at ee_addr using data */ /* from data_add for size bytes. */ -void ReadEEPROM(unsigned ee_addr, char *data_addr, unsigned size); -void WriteEEPROM(unsigned ee_addr, char *data_addr, unsigned size); +void ReadEEPROM(unsigned addr, unsigned eeoff, char *data_addr, unsigned size); +void WriteEEPROM(unsigned addr, unsigned eeoff, char *data_addr, + unsigned size); void InitEEPROM(void); /* XMODEM protocol */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200606292105.k5TL5HkW022087>