Skip to contentSkip to conversation

ARM: zynq: add MMC aliases

PATCH Applied Lucas Stach 2 participants 10 messages Dec 13, 2024 – Dec 16, 2024

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/9 ARM: zynq: add MMC aliases

The upstream DT doesn't include those, yet. Make sure MMC controllers end up with a deterministic numbering.

---
 arch/arm/dts/zynq-7000.dtsi | 7 +++++++
 1 file changed, 7 insertions(+)
arch/arm/dts/zynq-7000.dtsi +7 -0
index f7a0d70babef..90b0c098fc82 100644
@@ -1,4 +1,11 @@
 
+/ {
+	aliases {
+		mmc0 = &sdhci0;
+		mmc1 = &sdhci1;
+	};
+};
+
 &amba {
 	qspi: spi@e000d000 {
 		compatible = "xlnx,zynq-qspi-1.0";
Signature · 1 line
2.47.1
#1 lore raw

PATCH 2/9 ARM: zynq: zed: define SDHCI bus-width

The SDHCI controller on the Zedboard is routed to a SD card slot. Define bus-width to allow the controller to use the full bandwidth.

---
 arch/arm/dts/zynq-zed.dts | 4 ++++
 1 file changed, 4 insertions(+)
arch/arm/dts/zynq-zed.dts +4 -0
index 465758ebf62f..25b4d6df2937 100644
@@ -7,6 +7,10 @@ chosen {
 	};
 };
 
+&sdhci0 {
+	bus-width = <4>;
+};
+
 &qspi {
 	status = "okay";
 	num-cs = <1>;
Signature · 1 line
2.47.1
#2 lore raw

PATCH 3/9 ARM: zynq: zed: guard board initcall

In reply to Lucas Stach

Make sure the board initcall is only executed on a compatible board.

---
 arch/arm/boards/avnet-zedboard/board.c | 3 +++
 1 file changed, 3 insertions(+)
arch/arm/boards/avnet-zedboard/board.c +3 -0
index 15332189ca09..faa0bacf0ce1 100644
@@ -12,6 +12,9 @@
 
 static int zedboard_console_init(void)
 {
+	if (!of_machine_is_compatible("avnet,zynq-zed"))
+		return 0;
+
 	barebox_set_hostname("zedboard");
 
 	return 0;
Signature · 1 line
2.47.1
#3 lore raw

PATCH 4/9 ARM: zynq: zed: add environment

In reply to Lucas Stach

This adds support for a persistent environment on the first FAT partition on the SD card, next to the barebox binary.

---
 arch/arm/dts/zynq-zed.dts | 6 ++++++
 1 file changed, 6 insertions(+)
arch/arm/dts/zynq-zed.dts +6 -0
index 25b4d6df2937..2a166189d683 100644
@@ -4,6 +4,12 @@
 / {
 	chosen {
 		stdout-path = &uart1;
+
+		environment-sd {
+			compatible = "barebox,environment";
+			device-path = &sdhci0, "partname:0";
+			file-path = "barebox.env";
+		};
 	};
 };
 
Signature · 1 line
2.47.1
#4 lore raw

PATCH 5/9 ARM: zynq: zed: add Barebox update handler

In reply to Lucas Stach

Add a BBU handler for easy updating.

---
 arch/arm/boards/avnet-zedboard/board.c | 4 ++++
 1 file changed, 4 insertions(+)
arch/arm/boards/avnet-zedboard/board.c +4 -0
index faa0bacf0ce1..b19b26bfb307 100644
@@ -2,6 +2,7 @@
 // SPDX-FileCopyrightText: 2013 Steffen Trumtrar <[email protected]>
 
 #include <asm/armlinux.h>
+#include <bbu.h>
 #include <common.h>
 #include <environment.h>
 #include <asm/mach-types.h>
@@ -17,6 +18,9 @@ static int zedboard_console_init(void)
 
 	barebox_set_hostname("zedboard");
 
+	bbu_register_std_file_update("SD", BBU_HANDLER_FLAG_DEFAULT,
+				     "/boot/BOOT.bin", filetype_zynq_image);
+
 	return 0;
 }
 console_initcall(zedboard_console_init);
Signature · 1 line
2.47.1
#5 lore raw

PATCH 6/9 ARM: zynq: enable some useful things in defconfig

In reply to Lucas Stach

The default bootsource for the Zedboard is the SD card. Enable Arasan SDHCI, FAT support, Barebox update and environment in FS support to be able to update the Barebox image and store the environment on the card.

---
 arch/arm/configs/zynq_defconfig | 7 +++++++
 1 file changed, 7 insertions(+)
arch/arm/configs/zynq_defconfig +7 -0
index 226942e6b40b..1a1378d3e079 100644
@@ -37,13 +37,20 @@ CONFIG_CMD_MENU_MANAGEMENT=y
 CONFIG_CMD_READLINE=y
 CONFIG_CMD_TIMEOUT=y
 CONFIG_CMD_CLK=y
+CONFIG_CMD_BAREBOX_UPDATE=y
 CONFIG_CMD_OFTREE=y
 CONFIG_CMD_TIME=y
 CONFIG_NET=y
+CONFIG_OF_BAREBOX_DRIVERS=y
+CONFIG_OF_BAREBOX_ENV_IN_FS=y
 CONFIG_DRIVER_SERIAL_CADENCE=y
 CONFIG_DRIVER_NET_MACB=y
 # CONFIG_SPI is not set
+CONFIG_MCI=y
+CONFIG_MCI_ARASAN=y
 CONFIG_GPIO_ZYNQ=y
 # CONFIG_PINCTRL is not set
 CONFIG_FS_TFTP=y
+CONFIG_FS_FAT=y
+CONFIG_FS_FAT_WRITE=y
 CONFIG_DIGEST=y
Signature · 1 line
2.47.1
#6 lore raw

PATCH 7/9 ARM: zynq: zed: switch to entry function with stack

In reply to Lucas Stach

Use the upper non-contiguous OCM region vacated by the BootROM as the entry stack.

---
 arch/arm/boards/avnet-zedboard/lowlevel.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/boards/avnet-zedboard/lowlevel.c +1 -1
index 6e5a17d7eff5..c681764bd009 100644
@@ -286,7 +286,7 @@ static void avnet_zedboard_pbl_console_init(void)
 	pr_debug("\nAvnet ZedBoard PBL\n");
 }
 
-ENTRY_FUNCTION(start_avnet_zedboard, r0, r1, r2)
+ENTRY_FUNCTION_WITHSTACK(start_avnet_zedboard, 0xfffff000, r0, r1, r2)
 {
 
 	void *fdt = __dtb_z_zynq_zed_start + get_runtime_offset();
Signature · 1 line
2.47.1
#7 lore raw

PATCH 8/9 ARM: zynq: call common arm lowlevel init from zynq lowlevel init

In reply to Lucas Stach

This had previously been reverted as it may cause some stack usage. Now that we have a stack on entry, it should be safe to so.

---
 arch/arm/boards/avnet-zedboard/lowlevel.c | 1 -
 arch/arm/mach-zynq/cpu_init.c             | 2 ++
 2 files changed, 2 insertions(+), 1 deletion(-)
arch/arm/boards/avnet-zedboard/lowlevel.c +0 -1
index c681764bd009..1ecddf24085f 100644
@@ -301,7 +301,6 @@ ENTRY_FUNCTION_WITHSTACK(start_avnet_zedboard, 0xfffff000, r0, r1, r2)
 	writel((1<<7), 0xe000a208 );    // Output enable
 	writel((1<<7), 0xe000a040 );    // DATA Register
 
-	arm_cpu_lowlevel_init();
 	zynq_cpu_lowlevel_init();
 
 	avnet_zedboard_ps7_init();
arch/arm/mach-zynq/cpu_init.c +2 -0
index 7194c7e21627..cc7b8d1142a9 100644
@@ -7,6 +7,8 @@
 
 void zynq_cpu_lowlevel_init(void)
 {
+	arm_cpu_lowlevel_init();
+
 	enable_arm_errata_761320_war();
 	enable_arm_errata_794072_war();
 	enable_arm_errata_845369_war();
Signature · 1 line
2.47.1
#8 lore raw

PATCH 9/9 ARM: zynq: zed: always relocate in PBL

In reply to Lucas Stach

The PBL console is currently broken, as the setup relocates the running code, invalidating the previously computed FDT address. Relocate always to avoid those differences in behavior.

---
 arch/arm/boards/avnet-zedboard/lowlevel.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)
arch/arm/boards/avnet-zedboard/lowlevel.c +5 -8
index 1ecddf24085f..026a03d04be8 100644
@@ -276,10 +276,6 @@ static void avnet_zedboard_ps7_init(void)
 
 static void avnet_zedboard_pbl_console_init(void)
 {
-	relocate_to_current_adr();
-	setup_c();
-	barrier();
-
 	cadence_uart_init((void *)ZYNQ_UART1_BASE_ADDR);
 	pbl_set_putc(cadence_uart_putc, (void *)ZYNQ_UART1_BASE_ADDR);
 
@@ -288,9 +284,6 @@ static void avnet_zedboard_pbl_console_init(void)
 
 ENTRY_FUNCTION_WITHSTACK(start_avnet_zedboard, 0xfffff000, r0, r1, r2)
 {
-
-	void *fdt = __dtb_z_zynq_zed_start + get_runtime_offset();
-
 	/* MIO_07 in GPIO Mode 3.3V VIO, can be uncomented because it is the default value */
 	writel(0x0000DF0D, ZYNQ_SLCR_UNLOCK);
 	writel(0x00000600, 0xF800071C );
@@ -305,8 +298,12 @@ ENTRY_FUNCTION_WITHSTACK(start_avnet_zedboard, 0xfffff000, r0, r1, r2)
 
 	avnet_zedboard_ps7_init();
 
+	relocate_to_current_adr();
+	setup_c();
+	barrier();
+
 	if (IS_ENABLED(CONFIG_PBL_CONSOLE))
 		avnet_zedboard_pbl_console_init();
 
-	barebox_arm_entry(0, SZ_512M, fdt);
+	barebox_arm_entry(0, SZ_512M, __dtb_z_zynq_zed_start);
 }
Signature · 1 line
2.47.1
Applied
#9 lore raw
In reply to Lucas Stach
Quoted 4 lines · Lucas Stach

The upstream DT doesn't include those, yet. Make sure MMC controllers end up with a deterministic numbering.

Applied, thanks!

[1/9] ARM: zynq: add MMC aliases
https://git.pengutronix.de/cgit/barebox/commit/?id=2382be74da92 (link may not be stable)
[2/9] ARM: zynq: zed: define SDHCI bus-width
https://git.pengutronix.de/cgit/barebox/commit/?id=b3e5d422c70a (link may not be stable)
[3/9] ARM: zynq: zed: guard board initcall
https://git.pengutronix.de/cgit/barebox/commit/?id=d07d89b423fd (link may not be stable)
[4/9] ARM: zynq: zed: add environment
https://git.pengutronix.de/cgit/barebox/commit/?id=745d8db539f8 (link may not be stable)
[5/9] ARM: zynq: zed: add Barebox update handler
https://git.pengutronix.de/cgit/barebox/commit/?id=3a33d49dafe2 (link may not be stable)
[6/9] ARM: zynq: enable some useful things in defconfig
https://git.pengutronix.de/cgit/barebox/commit/?id=8651c3304b9a (link may not be stable)
[7/9] ARM: zynq: zed: switch to entry function with stack
https://git.pengutronix.de/cgit/barebox/commit/?id=5d9d50da97de (link may not be stable)
[8/9] ARM: zynq: call common arm lowlevel init from zynq lowlevel init
https://git.pengutronix.de/cgit/barebox/commit/?id=33582abd435c (link may not be stable)
[9/9] ARM: zynq: zed: always relocate in PBL
https://git.pengutronix.de/cgit/barebox/commit/?id=4cd14313773e (link may not be stable)

Best regards,

Signature · 1 line
Sascha Hauer <[email protected]>