]> git.ipfire.org Git - people/ms/u-boot.git/commitdiff
ARM64: zynqmp: Add support for reading MAC from eeprom
authorMichal Simek <michal.simek@xilinx.com>
Fri, 22 Apr 2016 09:48:49 +0000 (11:48 +0200)
committerMichal Simek <michal.simek@xilinx.com>
Tue, 24 May 2016 09:15:00 +0000 (11:15 +0200)
Add support for on board eeprom with programmed MAC for using in u-boot
to have uniq address for every board.
Most of the time uniq MAC address is on a label on the board.
If address is not programmed use these command to program it.

On zcu102:
ZynqMP> mm.b 0
00000000: 00 ? 00
00000001: a0 ? 0a
00000002: 35 ? 35
00000003: 02 ? 02
00000004: 00 ? ef
00000005: 00 ? 67
00000006: 00 ? q
i2c dev 5
i2c write 0 54 20 6
i2c md 54 20

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
board/xilinx/zynqmp/zynqmp.c
include/configs/xilinx_zynqmp_zcu102.h

index 132d724fbdf8a9638dbe21a8d95d867fe8fb186d..4623cd49e9c797f309540fb618e5076a2bee82a8 100644 (file)
@@ -15,6 +15,7 @@
 #include <asm/io.h>
 #include <usb.h>
 #include <dwc3-uboot.h>
+#include <i2c.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -50,6 +51,22 @@ int board_early_init_r(void)
        return 0;
 }
 
+int zynq_board_read_rom_ethaddr(unsigned char *ethaddr)
+{
+#if defined(CONFIG_ZYNQ_GEM_EEPROM_ADDR) && \
+    defined(CONFIG_ZYNQ_GEM_I2C_MAC_OFFSET) && \
+    defined(CONFIG_ZYNQ_EEPROM_BUS)
+       i2c_set_bus_num(CONFIG_ZYNQ_EEPROM_BUS);
+
+       if (eeprom_read(CONFIG_ZYNQ_GEM_EEPROM_ADDR,
+                       CONFIG_ZYNQ_GEM_I2C_MAC_OFFSET,
+                       ethaddr, 6))
+               printf("I2C EEPROM MAC address read failed\n");
+#endif
+
+       return 0;
+}
+
 #if !defined(CONFIG_SYS_SDRAM_BASE) && !defined(CONFIG_SYS_SDRAM_SIZE)
 /*
  * fdt_get_reg - Fill buffer by information from DT
index 30db2e453246113d6805eacfdea76e5400d35fd3..81079fe7d8b239c91420c309e23713608c530374 100644 (file)
 
 #define CONFIG_IDENT_STRING    " Xilinx ZynqMP ZCU102"
 
+#define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1
+#define CONFIG_CMD_EEPROM
+#define CONFIG_ZYNQ_EEPROM_BUS         5
+#define CONFIG_ZYNQ_GEM_EEPROM_ADDR    0x54
+#define CONFIG_ZYNQ_GEM_I2C_MAC_OFFSET 0x20
+
 #define CONFIG_KERNEL_FDT_OFST_SIZE \
        "kernel_offset=0x180000\0" \
        "fdt_offset=0x100000\0" \