1 // SPDX-License-Identifier: GPL-2.0+ 2 /* 3 * (C) Copyright 2014 - 2019 Xilinx, Inc. 4 * Michal Simek <michal.simek@xilinx.com> 5 */ 6 7 #include <common.h> 8 #include <dm/uclass.h> 9 #include <i2c.h> 10 11 int zynq_board_read_rom_ethaddr(unsigned char *ethaddr) 12 { 13 int ret = -EINVAL; 14 15 #if defined(CONFIG_ZYNQ_GEM_I2C_MAC_OFFSET) 16 struct udevice *dev; 17 ofnode eeprom; 18 19 eeprom = ofnode_get_chosen_node("xlnx,eeprom"); 20 if (!ofnode_valid(eeprom)) 21 return -ENODEV; 22 23 debug("%s: Path to EEPROM %s\n", __func__, 24 ofnode_get_chosen_prop("xlnx,eeprom")); 25 26 ret = uclass_get_device_by_ofnode(UCLASS_I2C_EEPROM, eeprom, &dev); 27 if (ret) 28 return ret; 29 30 ret = dm_i2c_read(dev, CONFIG_ZYNQ_GEM_I2C_MAC_OFFSET, ethaddr, 6); 31 if (ret) 32 debug("%s: I2C EEPROM MAC address read failed\n", __func__); 33 else 34 debug("%s: I2C EEPROM MAC %pM\n", __func__, ethaddr); 35 #endif 36 37 return ret; 38 } 39