board.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * (C) Copyright 2014 - 2019 Xilinx, Inc.
  4. * Michal Simek <michal.simek@xilinx.com>
  5. */
  6. #include <common.h>
  7. #include <asm/sections.h>
  8. #include <dm/uclass.h>
  9. #include <i2c.h>
  10. #include <linux/sizes.h>
  11. #include "board.h"
  12. int zynq_board_read_rom_ethaddr(unsigned char *ethaddr)
  13. {
  14. int ret = -EINVAL;
  15. #if defined(CONFIG_ZYNQ_GEM_I2C_MAC_OFFSET)
  16. struct udevice *dev;
  17. ofnode eeprom;
  18. eeprom = ofnode_get_chosen_node("xlnx,eeprom");
  19. if (!ofnode_valid(eeprom))
  20. return -ENODEV;
  21. debug("%s: Path to EEPROM %s\n", __func__,
  22. ofnode_read_chosen_string("xlnx,eeprom"));
  23. ret = uclass_get_device_by_ofnode(UCLASS_I2C_EEPROM, eeprom, &dev);
  24. if (ret)
  25. return ret;
  26. ret = dm_i2c_read(dev, CONFIG_ZYNQ_GEM_I2C_MAC_OFFSET, ethaddr, 6);
  27. if (ret)
  28. debug("%s: I2C EEPROM MAC address read failed\n", __func__);
  29. else
  30. debug("%s: I2C EEPROM MAC %pM\n", __func__, ethaddr);
  31. #endif
  32. return ret;
  33. }
  34. #if defined(CONFIG_OF_BOARD) || defined(CONFIG_OF_SEPARATE)
  35. void *board_fdt_blob_setup(void)
  36. {
  37. static void *fdt_blob;
  38. #if !defined(CONFIG_VERSAL_NO_DDR) && !defined(CONFIG_ZYNQMP_NO_DDR)
  39. fdt_blob = (void *)CONFIG_XILINX_OF_BOARD_DTB_ADDR;
  40. if (fdt_magic(fdt_blob) == FDT_MAGIC)
  41. return fdt_blob;
  42. debug("DTB is not passed via %p\n", fdt_blob);
  43. #endif
  44. #ifdef CONFIG_SPL_BUILD
  45. /* FDT is at end of BSS unless it is in a different memory region */
  46. if (IS_ENABLED(CONFIG_SPL_SEPARATE_BSS))
  47. fdt_blob = (ulong *)&_image_binary_end;
  48. else
  49. fdt_blob = (ulong *)&__bss_end;
  50. #else
  51. /* FDT is at end of image */
  52. fdt_blob = (ulong *)&_end;
  53. #endif
  54. if (fdt_magic(fdt_blob) == FDT_MAGIC)
  55. return fdt_blob;
  56. debug("DTB is also not passed via %p\n", fdt_blob);
  57. return NULL;
  58. }
  59. #endif
  60. int board_late_init_xilinx(void)
  61. {
  62. ulong initrd_hi;
  63. env_set_hex("script_offset_f", CONFIG_BOOT_SCRIPT_OFFSET);
  64. initrd_hi = gd->start_addr_sp - CONFIG_STACK_SIZE;
  65. initrd_hi = round_down(initrd_hi, SZ_16M);
  66. env_set_addr("initrd_high", (void *)initrd_hi);
  67. return 0;
  68. }