Michal Simek | 9755e3d | 2019-01-21 15:25:02 +0100 | [diff] [blame] | 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 | |
Michal Simek | 829e8c7 | 2019-01-21 16:29:07 +0100 | [diff] [blame] | 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 | } |
Ibai Erkiaga | fec657b | 2019-10-02 15:57:36 +0100 | [diff] [blame] | 39 | |
| 40 | #if defined(CONFIG_OF_BOARD) |
| 41 | void *board_fdt_blob_setup(void) |
| 42 | { |
Michal Simek | db5b253 | 2019-12-19 17:43:07 +0100 | [diff] [blame^] | 43 | static void *fdt_blob = (void *)CONFIG_XILINX_OF_BOARD_DTB_ADDR; |
Ibai Erkiaga | fec657b | 2019-10-02 15:57:36 +0100 | [diff] [blame] | 44 | |
Michal Simek | db5b253 | 2019-12-19 17:43:07 +0100 | [diff] [blame^] | 45 | if (fdt_magic(fdt_blob) != FDT_MAGIC) { |
| 46 | printf("DTB is not passed via %p\n", fdt_blob); |
Ibai Erkiaga | fec657b | 2019-10-02 15:57:36 +0100 | [diff] [blame] | 47 | return NULL; |
| 48 | } |
| 49 | |
Michal Simek | db5b253 | 2019-12-19 17:43:07 +0100 | [diff] [blame^] | 50 | return fdt_blob; |
Ibai Erkiaga | fec657b | 2019-10-02 15:57:36 +0100 | [diff] [blame] | 51 | } |
| 52 | #endif |