From owner-p4-projects@FreeBSD.ORG Sat Jul 1 06:37:28 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 8D13516A416; Sat, 1 Jul 2006 06:37:28 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 38B2B16A412 for ; Sat, 1 Jul 2006 06:37:28 +0000 (UTC) (envelope-from imp@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id EE11E43D45 for ; Sat, 1 Jul 2006 06:37:27 +0000 (GMT) (envelope-from imp@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id k616bRWq042313 for ; Sat, 1 Jul 2006 06:37:27 GMT (envelope-from imp@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id k616bRaO042310 for perforce@freebsd.org; Sat, 1 Jul 2006 06:37:27 GMT (envelope-from imp@freebsd.org) Date: Sat, 1 Jul 2006 06:37:27 GMT Message-Id: <200607010637.k616bRaO042310@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to imp@freebsd.org using -f From: Warner Losh To: Perforce Change Reviews Cc: Subject: PERFORCE change 100383 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 01 Jul 2006 06:37:28 -0000 http://perforce.freebsd.org/chv.cgi?CH=100383 Change 100383 by imp@imp_lighthouse on 2006/07/01 06:36:29 Revert the passing of an address. There are differences in accessing the two different kinds of EEPROMs that the 4370 and Kwikbyte use. The AT24C164 (4370) will need different code than the AT24C02 (Kwikbyte). Affected files ... .. //depot/projects/arm/src/sys/boot/arm/at91/bootiic/env_vars.c#12 edit .. //depot/projects/arm/src/sys/boot/arm/at91/bootspi/loader_prompt.c#14 edit .. //depot/projects/arm/src/sys/boot/arm/at91/bootspi/loader_prompt.h#7 edit .. //depot/projects/arm/src/sys/boot/arm/at91/libat91/eeprom.c#6 edit .. //depot/projects/arm/src/sys/boot/arm/at91/libat91/lib.h#12 edit Differences ... ==== //depot/projects/arm/src/sys/boot/arm/at91/bootiic/env_vars.c#12 (text+ko) ==== @@ -98,8 +98,9 @@ *cPtr++ = 0; } - WriteEEPROM(0, (unsigned)&BootCommandSection, env_table, - sizeof(env_table)); + /* We're executing in low RAM so addr in ram == offset in eeprom */ + WriteEEPROM((unsigned)&BootCommandSection, env_table, + sizeof(env_table)); } ==== //depot/projects/arm/src/sys/boot/arm/at91/bootspi/loader_prompt.c#14 (text+ko) ==== @@ -62,6 +62,7 @@ {COMMAND_REPLACE_KERNEL_VIA_XMODEM, "K"}, {COMMAND_REPLACE_FLASH_VIA_XMODEM, "I"}, {COMMAND_REPLACE_FPGA_VIA_XMODEM, "F"}, + {COMMAND_REPLACE_ID_EEPROM, "E"}, {COMMAND_FINAL_FLAG, 0} }; @@ -173,6 +174,18 @@ static void +UpdateEEProm(int eeaddr) +{ + char *addr = (char *)SDRAM_BASE + (1 << 20); /* Load to base + 1MB */ + int len; + + while ((len = xmodem_rx(addr)) == -1) + continue; + printf("\r\nDownloaded %u bytes.\r\n", len); + WriteEEPROM(eeaddr, 0, addr, len); +} + +static void UpdateFlash(int offset) { char *addr = (char *)SDRAM_BASE + (1 << 20); /* Load to base + 1MB */ @@ -309,6 +322,11 @@ printf("Updating FLASH image\r\n"); UpdateFlash(FLASH_OFFSET); break; + + case COMMAND_REPLACE_ID_EEPROM: + printf("Updating ID EEPROM image\r\n"); + UpdateEEProm(2); + break; default: break; } ==== //depot/projects/arm/src/sys/boot/arm/at91/bootspi/loader_prompt.h#7 (text+ko) ==== @@ -45,6 +45,7 @@ COMMAND_REPLACE_KERNEL_VIA_XMODEM, COMMAND_REPLACE_FLASH_VIA_XMODEM, COMMAND_REPLACE_FPGA_VIA_XMODEM, + COMMAND_REPLACE_ID_EEPROM, COMMAND_FINAL_FLAG } e_cmd_t; ==== //depot/projects/arm/src/sys/boot/arm/at91/libat91/eeprom.c#6 (text+ko) ==== @@ -83,7 +83,7 @@ * .KB_C_FN_DEFINITION_END */ void -ReadEEPROM(unsigned addr, unsigned ee_off, char *data_addr, unsigned size) +ReadEEPROM(unsigned ee_off, char *data_addr, unsigned size) { const AT91PS_TWI twiPtr = AT91C_BASE_TWI; unsigned int status; @@ -92,7 +92,7 @@ status = twiPtr->TWI_RHR; // Set the TWI Master Mode Register - twiPtr->TWI_MMR = ((TWSI_EEPROM_ADDRESS | addr) << 16) | + twiPtr->TWI_MMR = (TWSI_EEPROM_ADDRESS << 16) | AT91C_TWI_IADRSZ_2_BYTE | AT91C_TWI_MREAD; // Set TWI Internal Address Register @@ -137,7 +137,7 @@ * .KB_C_FN_DEFINITION_END */ void -WriteEEPROM(unsigned addr, unsigned ee_off, char *data_addr, unsigned size) +WriteEEPROM(unsigned ee_off, char *data_addr, unsigned size) { const AT91PS_TWI twiPtr = AT91C_BASE_TWI; unsigned status; @@ -148,7 +148,7 @@ putchar('.'); // Set the TWI Master Mode Register - twiPtr->TWI_MMR = (((TWSI_EEPROM_ADDRESS | addr) << 16) | + twiPtr->TWI_MMR = ((TWSI_EEPROM_ADDRESS << 16) | AT91C_TWI_IADRSZ_2_BYTE) & ~AT91C_TWI_MREAD; // Set TWI Internal Address Register @@ -173,7 +173,7 @@ continue; // wait for write operation to complete - ReadEEPROM(addr, ee_off, &test_data, 1); + ReadEEPROM(ee_off, &test_data, 1); } putchar('\r'); ==== //depot/projects/arm/src/sys/boot/arm/at91/libat91/lib.h#12 (text) ==== @@ -33,9 +33,8 @@ /* The following function write eeprom at ee_addr using data */ /* from data_add for size bytes. */ -void ReadEEPROM(unsigned addr, unsigned eeoff, char *data_addr, unsigned size); -void WriteEEPROM(unsigned addr, unsigned eeoff, char *data_addr, - unsigned size); +void ReadEEPROM(unsigned eeoff, char *data_addr, unsigned size); +void WriteEEPROM(unsigned eeoff, char *data_addr, unsigned size); void InitEEPROM(void); /* XMODEM protocol */