]> git.ipfire.org Git - people/ms/u-boot.git/commitdiff
fsl: Update the number of ethxaddr in reading system eeprom
authorHaiying Wang <Haiying.Wang@freescale.com>
Thu, 4 Jun 2009 20:12:40 +0000 (16:12 -0400)
committerKumar Gala <galak@kernel.crashing.org>
Fri, 12 Jun 2009 22:17:01 +0000 (17:17 -0500)
We support up to 8 mac addresses in system eeprom, so we define the macro
MAX_NUM_PORTS to limit the mac_count to 8, and update the number of ethxaddr
according to mac_count.

Signed-off-by: Haiying Wang <Haiying.Wang@freescale.com>
Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
board/freescale/common/sys_eeprom.c

index 988cb94aa137f57202778fa07d2b0b5f97387fe0..ae5304a9b45ed42ec1e038374fef7941f3e11ba8 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2006, 2008 Freescale Semiconductor
+ * Copyright 2006, 2008-2009 Freescale Semiconductor
  * York Sun (yorksun@freescale.com)
  * Haiying Wang (haiying.wang@freescale.com)
  * Timur Tabi (timur@freescale.com)
@@ -34,6 +34,8 @@
 #error "Please define either CONFIG_SYS_I2C_EEPROM_CCID or CONFIG_SYS_I2C_EEPROM_NXID"
 #endif
 
+#define MAX_NUM_PORTS  8       /* This value must be 8 as defined in doc */
+
 /**
  * static eeprom: EEPROM layout for CCID or NXID formats
  *
@@ -50,7 +52,7 @@ static struct __attribute__ ((__packed__)) eeprom {
        u8 res_0[40];     /* 0x18 - 0x3f Reserved */
        u8 mac_count;     /* 0x40        Number of MAC addresses */
        u8 mac_flag;      /* 0x41        MAC table flags */
-       u8 mac[8][6];     /* 0x42 - 0x71 MAC addresses */
+       u8 mac[MAX_NUM_PORTS][6];     /* 0x42 - 0x71 MAC addresses */
        u32 crc;          /* 0x72        CRC32 checksum */
 #endif
 #ifdef CONFIG_SYS_I2C_EEPROM_NXID
@@ -66,7 +68,7 @@ static struct __attribute__ ((__packed__)) eeprom {
        u8 res_1[21];     /* 0x2b - 0x3f Reserved */
        u8 mac_count;     /* 0x40        Number of MAC addresses */
        u8 mac_flag;      /* 0x41        MAC table flags */
-       u8 mac[8][6];     /* 0x42 - 0x71 MAC addresses */
+       u8 mac[MAX_NUM_PORTS][6];     /* 0x42 - 0x71 MAC addresses */
        u32 crc;          /* 0x72        CRC32 checksum */
 #endif
 } e;
@@ -119,7 +121,8 @@ static void show_eeprom(void)
                e.date[3] & 0x80 ? "PM" : "");
 
        /* Show MAC addresses  */
-       for (i = 0; i < min(e.mac_count, 8); i++) {
+       for (i = 0; i < min(e.mac_count, MAX_NUM_PORTS); i++) {
+
                u8 *p = e.mac[i];
 
                printf("Eth%u: %02x:%02x:%02x:%02x:%02x:%02x\n", i,
@@ -404,7 +407,17 @@ int mac_read_from_eeprom(void)
                }
        }
 
-       for (i = 0; i < min(4, e.mac_count); i++) {
+       /* Check the number of MAC addresses which is limited to
+        * MAX_NUM_PORTS.
+        */
+       if (e.mac_count > MAX_NUM_PORTS) {
+               printf("Warning: The number of MAC addresses is greater"
+                       " than %u, force it to %u.\n", MAX_NUM_PORTS,
+                       MAX_NUM_PORTS);
+               e.mac_count = MAX_NUM_PORTS;
+       }
+
+       for (i = 0; i < e.mac_count; i++) {
                if (memcmp(&e.mac[i], "\0\0\0\0\0\0", 6) &&
                    memcmp(&e.mac[i], "\xFF\xFF\xFF\xFF\xFF\xFF", 6)) {
                        char ethaddr[18];