OpenWrt – Blame information for rev 4

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