aboutsummaryrefslogtreecommitdiff
path: root/board/xilinx
diff options
context:
space:
mode:
authorMichal Simek2019-01-21 16:29:07 +0100
committerMichal Simek2019-02-14 14:31:09 +0100
commit829e8c73dd75eb49c00a6916963ec7b0b1a771c5 (patch)
tree65ed0e35b28810f8778ffa6bc63f1b433ec11520 /board/xilinx
parent9755e3db8b1223699954146dfb171df75ec89ab3 (diff)
xilinx: common: Add support for DM_I2C zynq_board_read_rom_ethaddr()
It is much easier to point to eeprom which stores information like MAC address directly via DT. eeprom which contains this information is pointed by /chosen/xlnx,eeprom parameter. For example: chosen { bootargs = "earlycon"; stdout-path = "serial0:115200n8"; + xlnx,eeprom = &eeprom; }; Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Diffstat (limited to 'board/xilinx')
-rw-r--r--board/xilinx/common/board.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/board/xilinx/common/board.c b/board/xilinx/common/board.c
index 7e813d85640..b14f530c72c 100644
--- a/board/xilinx/common/board.c
+++ b/board/xilinx/common/board.c
@@ -8,6 +8,7 @@
#include <dm/uclass.h>
#include <i2c.h>
+#if !defined(CONFIG_DM_I2C)
int zynq_board_read_rom_ethaddr(unsigned char *ethaddr)
{
#if defined(CONFIG_ZYNQ_GEM_EEPROM_ADDR) && \
@@ -23,3 +24,34 @@ int zynq_board_read_rom_ethaddr(unsigned char *ethaddr)
return 0;
}
+
+#else
+int zynq_board_read_rom_ethaddr(unsigned char *ethaddr)
+{
+ int ret = -EINVAL;
+
+#if defined(CONFIG_ZYNQ_GEM_I2C_MAC_OFFSET)
+ struct udevice *dev;
+ ofnode eeprom;
+
+ eeprom = ofnode_get_chosen_node("xlnx,eeprom");
+ if (!ofnode_valid(eeprom))
+ return -ENODEV;
+
+ debug("%s: Path to EEPROM %s\n", __func__,
+ ofnode_get_chosen_prop("xlnx,eeprom"));
+
+ ret = uclass_get_device_by_ofnode(UCLASS_I2C_EEPROM, eeprom, &dev);
+ if (ret)
+ return ret;
+
+ ret = dm_i2c_read(dev, CONFIG_ZYNQ_GEM_I2C_MAC_OFFSET, ethaddr, 6);
+ if (ret)
+ debug("%s: I2C EEPROM MAC address read failed\n", __func__);
+ else
+ debug("%s: I2C EEPROM MAC %pM\n", __func__, ethaddr);
+#endif
+
+ return ret;
+}
+#endif