]> git.karo-electronics.de Git - karo-tx-uboot.git/blobdiff - board/cm_t35/eeprom.c
cm-t35: fix incorrect BOARD_REV_SIZE value
[karo-tx-uboot.git] / board / cm_t35 / eeprom.c
index b3d332f3ac1f30b5b912c8af9efca2cdd01d6567..60538117c505a0d54d82776243f41792aac80df6 100644 (file)
@@ -27,8 +27,9 @@
 #define BOARD_SERIAL_OFFSET_LEGACY     8
 #define BOARD_REV_OFFSET               0
 #define BOARD_REV_OFFSET_LEGACY                6
-#define BOARD_REV_SIZE                 4
-#define BOARD_REV_SIZE_LEGACY          2
+#define BOARD_REV_SIZE                 2
+#define MAC_ADDR_OFFSET                        4
+#define MAC_ADDR_OFFSET_LEGACY         0
 
 #define LAYOUT_INVALID 0
 #define LAYOUT_LEGACY  0xff
@@ -81,6 +82,22 @@ void get_board_serial(struct tag_serialnr *serialnr)
        }
 }
 
+/*
+ * Routine: cm_t3x_eeprom_read_mac_addr
+ * Description: read mac address and store it in buf.
+ */
+int cm_t3x_eeprom_read_mac_addr(uchar *buf)
+{
+       uint offset;
+
+       if (eeprom_setup_layout())
+               return 0;
+
+       offset = (eeprom_layout != LAYOUT_LEGACY) ?
+                       MAC_ADDR_OFFSET : MAC_ADDR_OFFSET_LEGACY;
+       return cm_t3x_eeprom_read(offset, buf, 6);
+}
+
 /*
  * Routine: get_board_rev
  * Description: read system revision
@@ -89,17 +106,14 @@ u32 get_board_rev(void)
 {
        u32 rev = 0;
        uint offset = BOARD_REV_OFFSET_LEGACY;
-       int len = BOARD_REV_SIZE_LEGACY;
 
        if (eeprom_setup_layout())
                return 0;
 
-       if (eeprom_layout != LAYOUT_LEGACY) {
+       if (eeprom_layout != LAYOUT_LEGACY)
                offset = BOARD_REV_OFFSET;
-               len = BOARD_REV_SIZE;
-       }
 
-       if (cm_t3x_eeprom_read(offset, (uchar *)&rev, len))
+       if (cm_t3x_eeprom_read(offset, (uchar *)&rev, BOARD_REV_SIZE))
                return 0;
 
        return rev;