]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - board/freescale/common/sys_eeprom.c
Merge branch 'master' of git://git.denx.de/u-boot-usb
[karo-tx-uboot.git] / board / freescale / common / sys_eeprom.c
index 9c18dd824248a072a558197eb3426b6d5eae1e26..5cb7570c8b8a82c6bf6233fd753c8b991cdcb689 100644 (file)
@@ -21,7 +21,7 @@
 /* some boards with non-256-bytes EEPROM have special define */
 /* for MAX_NUM_PORTS in board-specific file */
 #ifndef MAX_NUM_PORTS
-#define MAX_NUM_PORTS  23
+#define MAX_NUM_PORTS  16
 #endif
 #define NXID_VERSION   1
 #endif
@@ -58,8 +58,9 @@ 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[MAX_NUM_PORTS][6];     /* 0x42 - x MAC addresses */
-       u32 crc;          /* x+1         CRC32 checksum */
+       u8 mac[MAX_NUM_PORTS][6];     /* 0x42 - 0xa1 MAC addresses */
+       u8 res_2[90];     /* 0xa2 - 0xfb Reserved */    
+       u32 crc;          /* 0xfc - 0xff CRC32 checksum */
 #endif
 } e;
 
@@ -89,7 +90,7 @@ static void show_eeprom(void)
        /* EEPROM tag ID, either CCID or NXID */
 #ifdef CONFIG_SYS_I2C_EEPROM_NXID
        printf("ID: %c%c%c%c v%u\n", e.id[0], e.id[1], e.id[2], e.id[3],
-               be32_to_cpu(e.version));
+              e.version);
 #else
        printf("ID: %c%c%c%c\n", e.id[0], e.id[1], e.id[2], e.id[3]);
 #endif
@@ -113,7 +114,7 @@ static void show_eeprom(void)
                e.date[3] & 0x80 ? "PM" : "");
 
        /* Show MAC addresses  */
-       for (i = 0; i < min(e.mac_count, MAX_NUM_PORTS); i++) {
+       for (i = 0; i < min(e.mac_count, (u8)MAX_NUM_PORTS); i++) {
 
                u8 *p = e.mac[i];
 
@@ -222,7 +223,7 @@ static int prog_eeprom(void)
         */
        for (i = 0, p = &e; i < sizeof(e); i += 8, p += 8) {
                ret = i2c_write(CONFIG_SYS_I2C_EEPROM_ADDR, i, CONFIG_SYS_I2C_EEPROM_ADDR_LEN,
-                       p, min((sizeof(e) - i), 8));
+                               p, min((int)(sizeof(e) - i), 8));
                if (ret)
                        break;
                udelay(5000);   /* 5ms write cycle timing */
@@ -425,13 +426,13 @@ int mac_read_from_eeprom(void)
 
        if (read_eeprom()) {
                printf("Read failed.\n");
-               return -1;
+               return 0;
        }
 
        if (!is_valid) {
                printf("Invalid ID (%02x %02x %02x %02x)\n",
                       e.id[0], e.id[1], e.id[2], e.id[3]);
-               return -1;
+               return 0;
        }
 
 #ifdef CONFIG_SYS_I2C_EEPROM_NXID
@@ -447,7 +448,7 @@ int mac_read_from_eeprom(void)
        crcp = (void *)&e + crc_offset;
        if (crc != be32_to_cpu(*crcp)) {
                printf("CRC mismatch (%08x != %08x)\n", crc, be32_to_cpu(e.crc));
-               return -1;
+               return 0;
        }
 
 #ifdef CONFIG_SYS_I2C_EEPROM_NXID
@@ -460,7 +461,7 @@ int mac_read_from_eeprom(void)
                memset(e.mac[8], 0xff, 6);
 #endif
 
-       for (i = 0; i < min(e.mac_count, MAX_NUM_PORTS); i++) {
+       for (i = 0; i < min(e.mac_count, (u8)MAX_NUM_PORTS); 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];
@@ -484,7 +485,7 @@ int mac_read_from_eeprom(void)
 
 #ifdef CONFIG_SYS_I2C_EEPROM_NXID
        printf("%c%c%c%c v%u\n", e.id[0], e.id[1], e.id[2], e.id[3],
-               be32_to_cpu(e.version));
+              e.version);
 #else
        printf("%c%c%c%c\n", e.id[0], e.id[1], e.id[2], e.id[3]);
 #endif