xilinx: Move zynq_board_read_rom_ethaddr to shared location
authorMichal Simek <michal.simek@xilinx.com>
Mon, 21 Jan 2019 14:25:02 +0000 (15:25 +0100)
committerMichal Simek <michal.simek@xilinx.com>
Thu, 14 Feb 2019 13:31:09 +0000 (14:31 +0100)
Zynq and ZynqMP are sharing similar code and there is no reason to do
code duplication. Move zynq_board_read_rom_ethaddr() to common file for
easier conversion to DM.
Use ZynqMP version that's why also add CONFIG_ZYNQ_EEPROM_BUS to Syzygy
which is only one Zynq board which is using this feature.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
board/opalkelly/zynq/board.c
board/xilinx/common/board.c [new file with mode: 0644]
board/xilinx/zynq/Makefile
board/xilinx/zynq/board.c
board/xilinx/zynqmp/Makefile
board/xilinx/zynqmp/zynqmp.c
include/configs/syzygy_hub.h

index a95c9d1eff0f9a3ade8faaf1b6fd6030c9bdef4e..ee666185ec09f729ea729fb0ac86ad468c103243 100644 (file)
@@ -1 +1,3 @@
+#include "../../xilinx/common/board.c"
+
 #include "../../xilinx/zynq/board.c"
diff --git a/board/xilinx/common/board.c b/board/xilinx/common/board.c
new file mode 100644 (file)
index 0000000..7e813d8
--- /dev/null
@@ -0,0 +1,25 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2014 - 2019 Xilinx, Inc.
+ * Michal Simek <michal.simek@xilinx.com>
+ */
+
+#include <common.h>
+#include <dm/uclass.h>
+#include <i2c.h>
+
+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;
+}
index e7645be189c3c070da8c4319b90b0079a2f2008c..8d3301543959d17022915ebfd33b28074a11d8d6 100644 (file)
@@ -4,6 +4,7 @@
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 
 obj-y  := board.o
+obj-y  += ../common/board.o
 
 ifneq ($(CONFIG_XILINX_PS_INIT_FILE),"")
 PS_INIT_FILE := $(shell cd $(srctree); readlink -f $(CONFIG_XILINX_PS_INIT_FILE))
index 614d93c082a6867eab005bbf5dde8f1d28c23bc5..f9973840bf205de0749d713d9ce084f6b79ca8af 100644 (file)
@@ -77,19 +77,6 @@ int board_late_init(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)
-       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)
 int dram_init_banksize(void)
 {
index 960b81fc58530e8e15f074348ba0bb0987be5a9a..80f8ca7e1e4be798c82b444c4b1d084cd7f9f964 100644 (file)
@@ -4,6 +4,7 @@
 # Michal Simek <michal.simek@xilinx.com>
 
 obj-y  := zynqmp.o
+obj-y  += ../common/board.o
 
 ifneq ($(CONFIG_XILINX_PS_INIT_FILE),"")
 PS_INIT_FILE := $(shell cd $(srctree); readlink -f $(CONFIG_XILINX_PS_INIT_FILE))
index 41e88b03f9d160ec126d8e7a66d84b5ab49e9227..e7dfd49a3ccf1af0b44922805aa480bbc7d1e7a8 100644 (file)
@@ -20,7 +20,6 @@
 #include <usb.h>
 #include <dwc3-uboot.h>
 #include <zynqmppl.h>
-#include <i2c.h>
 #include <g_dnl.h>
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -409,22 +408,6 @@ 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;
-}
-
 unsigned long do_go_exec(ulong (*entry)(int, char * const []), int argc,
                         char * const argv[])
 {
index 88ee77284890ebad4ab4202ff8624fb592960701..75036977d48655199b14295c4b1b6908ce2a011c 100644 (file)
@@ -12,6 +12,7 @@
 
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1
 #define CONFIG_ZYNQ_GEM_EEPROM_ADDR    0x57
+#define CONFIG_ZYNQ_EEPROM_BUS         0
 
 #define CONFIG_EXTRA_ENV_SETTINGS       \
        "fit_image=fit.itb\0"           \