blob: 62dafe0f90582b454d040f9c92cf7fb3f39464a0 [file] [log] [blame]
Michal Simek9755e3d2019-01-21 15:25:02 +01001// 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 Simek829e8c72019-01-21 16:29:07 +010011int 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 Erkiagafec657b2019-10-02 15:57:36 +010039
40#if defined(CONFIG_OF_BOARD)
41void *board_fdt_blob_setup(void)
42{
Michal Simekdb5b2532019-12-19 17:43:07 +010043 static void *fdt_blob = (void *)CONFIG_XILINX_OF_BOARD_DTB_ADDR;
Ibai Erkiagafec657b2019-10-02 15:57:36 +010044
Michal Simekdb5b2532019-12-19 17:43:07 +010045 if (fdt_magic(fdt_blob) != FDT_MAGIC) {
46 printf("DTB is not passed via %p\n", fdt_blob);
Ibai Erkiagafec657b2019-10-02 15:57:36 +010047 return NULL;
48 }
49
Michal Simekdb5b2532019-12-19 17:43:07 +010050 return fdt_blob;
Ibai Erkiagafec657b2019-10-02 15:57:36 +010051}
52#endif