110-zybo-z7-read-mac-address-from-SPI-flash-memory.patch 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. From ac8fcc92d87436715ce85f39a4fe4f07c3bfa15e Mon Sep 17 00:00:00 2001
  2. From: Luis Araneda <[email protected]>
  3. Date: Sun, 22 Jul 2018 02:52:41 -0400
  4. Subject: [U-Boot] [RFC PATCH] arm: zynq: read mac address from SPI flash memory
  5. Implement a method for reading the MAC address from an
  6. SPI flash memory.
  7. In particular, this method is used by the Zybo Z7 board
  8. to read the MAC address from the OTP region in the SPI NOR
  9. memory
  10. Signed-off-by: Luis Araneda <[email protected]>
  11. ---
  12. As of 2018-08-23, this patch has been sent to U-Boot's mailing list
  13. and is being reviewed. Some changes on the implementation are expected,
  14. but the functionality should not change
  15. ---
  16. board/xilinx/zynq/board.c | 28 ++++++++++++++++++++++++++++
  17. configs/zynq_zybo_z7_defconfig | 3 +++
  18. drivers/misc/Kconfig | 17 +++++++++++++++++
  19. 3 files changed, 48 insertions(+)
  20. --- a/board/xilinx/zynq/board.c
  21. +++ b/board/xilinx/zynq/board.c
  22. @@ -6,9 +6,12 @@
  23. #include <common.h>
  24. #include <dm/uclass.h>
  25. +#include <dm/device.h>
  26. +#include <dm/device-internal.h>
  27. #include <fdtdec.h>
  28. #include <fpga.h>
  29. #include <mmc.h>
  30. +#include <spi_flash.h>
  31. #include <watchdog.h>
  32. #include <wdt.h>
  33. #include <zynqpl.h>
  34. @@ -83,6 +86,31 @@ int zynq_board_read_rom_ethaddr(unsigned
  35. printf("I2C EEPROM MAC address read failed\n");
  36. #endif
  37. +#if defined(CONFIG_MAC_ADDR_IN_SPI_FLASH)
  38. + struct spi_flash *flash;
  39. + struct udevice *dev;
  40. + int ret;
  41. +
  42. + ret = spi_flash_probe_bus_cs(CONFIG_SF_DEFAULT_BUS,
  43. + CONFIG_SF_DEFAULT_CS,
  44. + 0, 0, &dev);
  45. + if (ret) {
  46. + printf("SPI(bus:%u cs:%u) probe failed\n",
  47. + CONFIG_SF_DEFAULT_BUS,
  48. + CONFIG_SF_DEFAULT_CS);
  49. + return 0;
  50. + }
  51. +
  52. + flash = dev_get_uclass_priv(dev);
  53. + flash->read_cmd = CONFIG_MAC_ADDR_SPI_FLASH_READ_CMD;
  54. +
  55. + if (spi_flash_read_dm(dev,
  56. + CONFIG_MAC_ADDR_SPI_FLASH_DATA_OFFSET,
  57. + 6, ethaddr))
  58. + printf("SPI MAC address read failed\n");
  59. +
  60. + device_remove(dev, DM_REMOVE_NORMAL);
  61. +#endif
  62. return 0;
  63. }
  64. --- a/configs/zynq_zybo_z7_defconfig
  65. +++ b/configs/zynq_zybo_z7_defconfig
  66. @@ -44,6 +44,9 @@ CONFIG_DM_GPIO=y
  67. CONFIG_SYS_I2C_ZYNQ=y
  68. CONFIG_ZYNQ_I2C0=y
  69. CONFIG_ZYNQ_I2C1=y
  70. +CONFIG_MAC_ADDR_IN_SPI_FLASH=y
  71. +CONFIG_MAC_ADDR_SPI_FLASH_READ_CMD=0x4b
  72. +CONFIG_MAC_ADDR_SPI_FLASH_DATA_OFFSET=0x20
  73. CONFIG_MMC_SDHCI=y
  74. CONFIG_MMC_SDHCI_ZYNQ=y
  75. CONFIG_SPI_FLASH=y
  76. --- a/drivers/misc/Kconfig
  77. +++ b/drivers/misc/Kconfig
  78. @@ -272,6 +272,23 @@ config SYS_I2C_EEPROM_ADDR_OVERFLOW
  79. endif
  80. +config MAC_ADDR_IN_SPI_FLASH
  81. + bool "MAC address in SPI flash"
  82. + help
  83. + Read MAC address from an SPI flash memory
  84. +
  85. +if MAC_ADDR_IN_SPI_FLASH
  86. +
  87. +config MAC_ADDR_SPI_FLASH_READ_CMD
  88. + hex "Read command for the SPI flash memory"
  89. + default 0
  90. +
  91. +config MAC_ADDR_SPI_FLASH_DATA_OFFSET
  92. + hex "Offset of MAC data in SPI flash memory"
  93. + default 0
  94. +
  95. +endif
  96. +
  97. config GDSYS_RXAUI_CTRL
  98. bool "Enable gdsys RXAUI control driver"
  99. depends on MISC