Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 1 Jul 2006 06:37:27 GMT
From:      Warner Losh <imp@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 100383 for review
Message-ID:  <200607010637.k616bRaO042310@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
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 */



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