Skip to contentSkip to conversation

ARM: zynq: zedboard: split out PS7 init

PATCH Applied Lucas Stach 2 participants 5 messages Dec 10, 2019 – Dec 11, 2019

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

PATCH 1/4 ARM: zynq: zedboard: split out PS7 init

Move the PS7 inititalization into its own function. This helps readability and logically splits the FPGA toolchain generated setup from the reset of the board init.

Also execute the PS7 setup after the lowlevel CPU init, as this is the regular order used in the Barebox codebase.

---
 arch/arm/boards/avnet-zedboard/lowlevel.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
arch/arm/boards/avnet-zedboard/lowlevel.c +9 -4
index 93e4da96ecd4..b50c36b28869 100644
@@ -29,11 +29,8 @@
 
 extern char __dtb_zynq_zed_start[];
 
-ENTRY_FUNCTION(start_avnet_zedboard, r0, r1, r2)
+static void avnet_zedboard_ps7_init(void)
 {
-
-	void *fdt = __dtb_zynq_zed_start + get_runtime_offset();
-
 	/* open sesame */
 	writel(0x0000DF0D, ZYNQ_SLCR_UNLOCK);
 
@@ -260,8 +257,16 @@ ENTRY_FUNCTION(start_avnet_zedboard, r0, r1, r2)
 
 	/* lock up. secure, secure */
 	writel(0x0000767B, ZYNQ_SLCR_LOCK);
+}
+
+ENTRY_FUNCTION(start_avnet_zedboard, r0, r1, r2)
+{
+
+	void *fdt = __dtb_zynq_zed_start + get_runtime_offset();
 
 	arm_cpu_lowlevel_init();
 
+	avnet_zedboard_ps7_init();
+
 	barebox_arm_entry(0, SZ_512M, fdt);
 }
Signature · 7 lines
2.23.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#1 lore raw

PATCH 2/4 ARM: zynq: zedboard: allow lowlevel init to be called as second stage

If the code is already executing in DRAM, the PS7 init must not be executed, as it initializes the DRAM controller.

As the OCM can be configured to an address which aliases with the DRAM address space we can't reliably infer if we are running from OCM or DRAM from the execution address. So instead of using the address, look at the OCM mapping, as the BootROM leaves a quite unique mapping behind with 192KB OCM mapped at the low address and 64KB mapped to the high address.

---
 arch/arm/boards/avnet-zedboard/lowlevel.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
arch/arm/boards/avnet-zedboard/lowlevel.c +10 -0
index b50c36b28869..9b90ef112b46 100644
@@ -31,6 +31,16 @@ extern char __dtb_zynq_zed_start[];
 
 static void avnet_zedboard_ps7_init(void)
 {
+	/*
+	 * Read OCM mapping configuration, if only the upper 64 KByte are
+	 * mapped to the high address, it's very likely that we just got control
+	 * from the BootROM. If the mapping is changed something other than the
+	 * BootROM was running before us. Skip PS7 init to avoid cutting the
+	 * branch we are sitting on in that case.
+	 */
+	if ((readl(0xf8000910) & 0xf) != 0x8)
+		return;
+
 	/* open sesame */
 	writel(0x0000DF0D, ZYNQ_SLCR_UNLOCK);
 
Signature · 7 lines
2.23.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#2 lore raw

PATCH 3/4 filetype: add Zynq image type

In reply to Lucas Stach

Use the 2 invariant words (width detection and image identification) from the Zynq image header to detect the filetype.

---
 common/filetype.c  | 4 ++++
 include/filetype.h | 1 +
 2 files changed, 5 insertions(+)
common/filetype.c +4 -0
index 39fea45edff5..fd6e8e3d1c35 100644
@@ -80,6 +80,7 @@ static const struct filetype_str filetype_str[] = {
 	[filetype_ubootvar] = { "U-Boot environmemnt variable data",
 				"ubootvar" },
 	[filetype_stm32_image_v1] = { "STM32 image (v1)", "stm32-image-v1" },
+	[filetype_zynq_image] = { "Zynq image", "zynq-image" },
 };
 
 const char *file_type_to_string(enum filetype f)
@@ -392,6 +393,9 @@ enum filetype file_detect_type(const void *_buf, size_t bufsize)
 	if (is_imx_flash_header_v2(_buf))
 		return filetype_imx_image_v2;
 
+	if (buf[8] == 0xAA995566 && buf[9] == 0x584C4E58)
+		return filetype_zynq_image;
+
 	return filetype_unknown;
 }
 
include/filetype.h +1 -0
index 90a03de58105..db95fdaa0a5f 100644
@@ -49,6 +49,7 @@ enum filetype {
 	filetype_layerscape_qspi_image,
 	filetype_ubootvar,
 	filetype_stm32_image_v1,
+	filetype_zynq_image,
 	filetype_max,
 };
 
Signature · 7 lines
2.23.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#3 lore raw

PATCH 4/4 ARM: zynq: add Zynq image bootm handler

In reply to Lucas Stach

This adds a bootm handler for the Zynq image, to allow second stage booting of a unchanged Zynq boot image.

---
 arch/arm/mach-zynq/Makefile        |  2 +-
 arch/arm/mach-zynq/bootm-zynqimg.c | 49 ++++++++++++++++++++++++++++++
 2 files changed, 50 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/mach-zynq/bootm-zynqimg.c
arch/arm/mach-zynq/Makefile +1 -1
index 3252247d176d..c88ab4666f0f 100644
@@ -1 +1 @@
-obj-y += zynq.o
+obj-y += zynq.o bootm-zynqimg.o
arch/arm/mach-zynq/bootm-zynqimg.c new file +49 -0

49 lines not on this page · raw message

Signature · 7 lines
2.23.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Applied
#4 lore raw
In reply to Lucas Stach
Quoted 11 lines · Lucas Stach

Move the PS7 inititalization into its own function. This helps readability and logically splits the FPGA toolchain generated setup from the reset of the board init.

Also execute the PS7 setup after the lowlevel CPU init, as this is the regular order used in the Barebox codebase.

---
 arch/arm/boards/avnet-zedboard/lowlevel.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

Applied, thanks

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox