[U-Boot] [PATCH] arm: zynq: Add support to store environment in EEPROM

Michal Simek michal.simek at xilinx.com
Fri Dec 1 14:32:37 UTC 2017


From: Siva Durga Prasad Paladugu <siva.durga.paladugu at xilinx.com>

Added support to store environment in EEPROM.
Set the mux to select EEPROM during board init so
that the env can be read from EEPROM later.

Signed-off-by: Siva Durga Prasad Paladugu <sivadur at xilinx.com>
Signed-off-by: Michal Simek <michal.simek at xilinx.com>
---

 board/xilinx/zynq/board.c     | 8 +++++++-
 include/configs/zynq-common.h | 2 ++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/board/xilinx/zynq/board.c b/board/xilinx/zynq/board.c
index e59038106aa6..28394bef0567 100644
--- a/board/xilinx/zynq/board.c
+++ b/board/xilinx/zynq/board.c
@@ -34,6 +34,9 @@ static xilinx_desc fpga100 = XILINX_XC7Z100_DESC(0x100);
 
 int board_init(void)
 {
+#if defined(CONFIG_ENV_IS_IN_EEPROM) && !defined(CONFIG_SPL_BUILD)
+	unsigned char eepromsel = CONFIG_SYS_I2C_MUX_EEPROM_SEL;
+#endif
 #if (defined(CONFIG_FPGA) && !defined(CONFIG_SPL_BUILD)) || \
     (defined(CONFIG_SPL_FPGA_SUPPORT) && defined(CONFIG_SPL_BUILD))
 	u32 idcode;
@@ -79,7 +82,10 @@ int board_init(void)
 	fpga_init();
 	fpga_add(fpga_xilinx, &fpga);
 #endif
-
+#if defined(CONFIG_ENV_IS_IN_EEPROM) && !defined(CONFIG_SPL_BUILD)
+	if (eeprom_write(CONFIG_SYS_I2C_MUX_ADDR, 0, &eepromsel, 1))
+		puts("I2C:EEPROM selection failed\n");
+#endif
 	return 0;
 }
 
diff --git a/include/configs/zynq-common.h b/include/configs/zynq-common.h
index b10cb3f57220..547f447a46fd 100644
--- a/include/configs/zynq-common.h
+++ b/include/configs/zynq-common.h
@@ -146,6 +146,8 @@
 # define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS	4
 # define CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS	5
 # define CONFIG_SYS_EEPROM_SIZE			1024 /* Bytes */
+# define CONFIG_SYS_I2C_MUX_ADDR		0x74
+# define CONFIG_SYS_I2C_MUX_EEPROM_SEL		0x4
 #endif
 
 /* Total Size of Environment Sector */
-- 
1.9.1



More information about the U-Boot mailing list