2019-01-21 14:25:02 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
|
|
|
/*
|
|
|
|
* (C) Copyright 2014 - 2019 Xilinx, Inc.
|
|
|
|
* Michal Simek <michal.simek@xilinx.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
2020-05-10 17:40:03 +00:00
|
|
|
#include <env.h>
|
2020-05-10 17:40:05 +00:00
|
|
|
#include <log.h>
|
2019-12-19 16:45:15 +00:00
|
|
|
#include <asm/sections.h>
|
2019-01-21 14:25:02 +00:00
|
|
|
#include <dm/uclass.h>
|
|
|
|
#include <i2c.h>
|
2020-04-08 08:51:36 +00:00
|
|
|
#include <linux/sizes.h>
|
2020-03-31 10:39:37 +00:00
|
|
|
#include "board.h"
|
2019-01-21 14:25:02 +00:00
|
|
|
|
2020-08-03 10:59:28 +00:00
|
|
|
#if defined(CONFIG_ZYNQ_GEM_I2C_MAC_OFFSET)
|
2019-01-21 15:29:07 +00:00
|
|
|
int zynq_board_read_rom_ethaddr(unsigned char *ethaddr)
|
|
|
|
{
|
|
|
|
int ret = -EINVAL;
|
|
|
|
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__,
|
2020-01-27 15:49:43 +00:00
|
|
|
ofnode_read_chosen_string("xlnx,eeprom"));
|
2019-01-21 15:29:07 +00:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
2020-08-03 10:59:28 +00:00
|
|
|
#endif
|
2019-10-02 14:57:36 +00:00
|
|
|
|
2019-12-19 16:45:15 +00:00
|
|
|
#if defined(CONFIG_OF_BOARD) || defined(CONFIG_OF_SEPARATE)
|
2019-10-02 14:57:36 +00:00
|
|
|
void *board_fdt_blob_setup(void)
|
|
|
|
{
|
2020-09-04 14:21:47 +00:00
|
|
|
void *fdt_blob;
|
2020-03-19 09:23:56 +00:00
|
|
|
|
|
|
|
#if !defined(CONFIG_VERSAL_NO_DDR) && !defined(CONFIG_ZYNQMP_NO_DDR)
|
|
|
|
fdt_blob = (void *)CONFIG_XILINX_OF_BOARD_DTB_ADDR;
|
2019-10-02 14:57:36 +00:00
|
|
|
|
2019-12-19 16:45:15 +00:00
|
|
|
if (fdt_magic(fdt_blob) == FDT_MAGIC)
|
|
|
|
return fdt_blob;
|
2019-10-02 14:57:36 +00:00
|
|
|
|
2019-12-19 16:45:15 +00:00
|
|
|
debug("DTB is not passed via %p\n", fdt_blob);
|
2020-03-19 09:23:56 +00:00
|
|
|
#endif
|
2019-12-19 16:45:15 +00:00
|
|
|
|
|
|
|
#ifdef CONFIG_SPL_BUILD
|
|
|
|
/* FDT is at end of BSS unless it is in a different memory region */
|
|
|
|
if (IS_ENABLED(CONFIG_SPL_SEPARATE_BSS))
|
|
|
|
fdt_blob = (ulong *)&_image_binary_end;
|
|
|
|
else
|
|
|
|
fdt_blob = (ulong *)&__bss_end;
|
|
|
|
#else
|
|
|
|
/* FDT is at end of image */
|
|
|
|
fdt_blob = (ulong *)&_end;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (fdt_magic(fdt_blob) == FDT_MAGIC)
|
|
|
|
return fdt_blob;
|
|
|
|
|
|
|
|
debug("DTB is also not passed via %p\n", fdt_blob);
|
|
|
|
|
|
|
|
return NULL;
|
2019-10-02 14:57:36 +00:00
|
|
|
}
|
|
|
|
#endif
|
2020-03-31 10:39:37 +00:00
|
|
|
|
|
|
|
int board_late_init_xilinx(void)
|
|
|
|
{
|
2020-08-12 10:16:49 +00:00
|
|
|
u32 ret = 0;
|
2020-08-12 10:17:53 +00:00
|
|
|
phys_size_t bootm_size = gd->ram_size;
|
|
|
|
|
|
|
|
if (CONFIG_IS_ENABLED(ARCH_ZYNQ))
|
|
|
|
bootm_size = min(bootm_size, (phys_size_t)(SZ_512M + SZ_256M));
|
2020-03-31 10:39:37 +00:00
|
|
|
|
2020-08-12 10:16:49 +00:00
|
|
|
ret |= env_set_hex("script_offset_f", CONFIG_BOOT_SCRIPT_OFFSET);
|
|
|
|
|
|
|
|
ret |= env_set_addr("bootm_low", (void *)gd->ram_base);
|
2020-08-12 10:17:53 +00:00
|
|
|
ret |= env_set_addr("bootm_size", (void *)bootm_size);
|
2020-08-12 10:16:49 +00:00
|
|
|
|
|
|
|
if (ret)
|
|
|
|
printf("%s: Saving run time variables FAILED\n", __func__);
|
2020-07-09 13:57:56 +00:00
|
|
|
|
2020-03-31 10:39:37 +00:00
|
|
|
return 0;
|
|
|
|
}
|