Skip to contentSkip to conversation

sunxi: boot0.h: allow RVBAR MMIO address customisation

PATCH In review Andre Przywara 2 participants 5 messages Apr 5, 2023 – Apr 11, 2023

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

PATCH 1/2 sunxi: boot0.h: allow RVBAR MMIO address customisation

To switch the ARMv8 Allwinner SoCs into the 64-bit AArch64 ISA, we need to program the 64-bit start code address into an MMIO mapped register that shadows the architectural RVBAR register.
This address is SoC specific, with just two versions out there so far. Now a third address emerged, on a *variant* of an existing SoC (H616).

Change the boot0.h start code to make this address a Kconfig selectable option, to allow easier maintenance.
We make this address user-visible (even though it shouldn't be), to allow putting this in defconfig. This is needed because there are apparently revisions of the H616 SoC out there using different addresses, so this becomes a per-board decision.

---
 arch/arm/include/asm/arch-sunxi/boot0.h |  7 ++-----
 arch/arm/mach-sunxi/Kconfig             | 12 ++++++++++++
 2 files changed, 14 insertions(+), 5 deletions(-)
arch/arm/include/asm/arch-sunxi/boot0.h +2 -5
index 46b7e073b59..59ea75a96b5 100644
@@ -39,11 +39,8 @@
 	.word	0xf57ff06f	// isb     sy
 	.word	0xe320f003	// wfi
 	.word	0xeafffffd	// b       @wfi
-#ifndef CONFIG_SUN50I_GEN_H6
-	.word	0x017000a0	// writeable RVBAR mapping address
-#else
-	.word	0x09010040	// writeable RVBAR mapping address
-#endif
+
+	.word	CONFIG_SUNXI_RVBAR_ADDRESS	// writable RVBAR mapping addr
 #ifdef CONFIG_SPL_BUILD
 	.word	CONFIG_SPL_TEXT_BASE
 #else
arch/arm/mach-sunxi/Kconfig +12 -0
index 6417aee944b..b46667ce01e 100644
@@ -110,6 +110,18 @@ config SUNXI_SRAM_ADDRESS
 	Some newer SoCs map the boot ROM at address 0 instead and move the
 	SRAM to a different address.
 
+config SUNXI_RVBAR_ADDRESS
+	hex "RVBAR address"
+	depends on ARM64
+	default 0x09010040 if SUN50I_GEN_H6
+	default 0x017000a0
+	---help---
+	The read-only RVBAR system register holds the address of the first
+	instruction to execute after a reset. Allwinner cores provide a
+	writable MMIO backing store for this register, to allow to set the
+	entry point when switching to AArch64. This store is on different
+	addresses, depending on the SoC.
+
 config SUNXI_A64_TIMER_ERRATUM
 	bool
 
Signature · 1 line
2.25.1
#1 lore raw

PATCH 2/2 sunxi: remove support for boot0 header reservation

In the early days of the Allwinner A64 U-Boot support, we relied on a vendor provided "boot0" binary to perform the DRAM initialisation. This replaced the SPL, and required to equip the U-Boot (proper) binary with a vendor specific header to be recognised as a valid boot0 payload. Fortunately these days are long gone (we gained SPL and DRAM support in early 2017!), and we never needed to use that hack on any later 64-bit Allwinner SoC.

Since this is highly obsolete by now, remove the Kconfig option and the small pieces of "code" associated with it.

Provide some comments about the purpose of the remaining boot0 code on the way.

---
 arch/arm/include/asm/arch-sunxi/boot0.h | 18 +++++++++++-------
 arch/arm/mach-sunxi/Kconfig             |  9 ---------
 configs/a64-olinuxino-emmc_defconfig    |  1 -
 configs/a64-olinuxino_defconfig         |  1 -
 configs/amarula_a64_relic_defconfig     |  1 -
 configs/bananapi_m64_defconfig          |  1 -
 configs/nanopi_a64_defconfig            |  1 -
 configs/oceanic_5205_5inmfd_defconfig   |  1 -
 configs/orangepi_win_defconfig          |  1 -
 configs/pine64_plus_defconfig           |  1 -
 configs/sopine_baseboard_defconfig      |  1 -
 11 files changed, 11 insertions(+), 25 deletions(-)
arch/arm/include/asm/arch-sunxi/boot0.h +11 -7
index 59ea75a96b5..1a396f78488 100644
@@ -1,13 +1,17 @@
 /* SPDX-License-Identifier: GPL-2.0+ */
 /*
- * Configuration settings for the Allwinner A64 (sun50i) CPU
+ * Very early code for Allwinner 64-bit CPUs.
+ *
+ * The BROM runs entirely in AArch32 state, so the SPL is entered using this
+ * ISA. Depending on the rest of the firmware stack, this may also be true
+ * for U-Boot proper.
+ * Provide the "RMR reset into 64-bit" sequence, in AArch32 machine language,
+ * so that we can have all of U-Boot in AArch64. The first instruction is
+ * chosen so that if the CPU is already using AArch64, it will skip the code
+ * and jump straight to the reset vector.
  */
 
-#if defined(CONFIG_RESERVE_ALLWINNER_BOOT0_HEADER) && !defined(CONFIG_SPL_BUILD)
-/* reserve space for BOOT0 header information */
-	b	reset
-	.space	1532
-#elif defined(CONFIG_ARM_BOOT_HOOK_RMR)
+#ifdef CONFIG_ARM_BOOT_HOOK_RMR
 /*
  * Switch into AArch64 if needed.
  * Refer to arch/arm/mach-sunxi/rmr_switch.S for the original source.
@@ -47,7 +51,7 @@
 	.word   CONFIG_TEXT_BASE
 #endif
 	.word	fel_stash - .
-#else
+#else	/* !CONFIG_ARM_BOOT_HOOK_RMR */
 /* normal execution */
 	b	reset
 #endif
arch/arm/mach-sunxi/Kconfig +0 -9
index b46667ce01e..0527b3863a7 100644
@@ -386,15 +386,6 @@ config MACH_SUN8I
 	default y if MACH_SUN8I_R40
 	default y if MACH_SUN8I_V3S
 
-config RESERVE_ALLWINNER_BOOT0_HEADER
-	bool "reserve space for Allwinner boot0 header"
-	select ENABLE_ARM_SOC_BOOT0_HOOK
-	---help---
-	Prepend a 1536 byte (empty) header to the U-Boot image file, to be
-	filled with magic values post build. The Allwinner provided boot0
-	blob relies on this information to load and execute U-Boot.
-	Only needed on 64-bit Allwinner boards so far when using boot0.
-
 config ARM_BOOT_HOOK_RMR
 	bool
 	depends on ARM64
configs/a64-olinuxino-emmc_defconfig +0 -1
index 8ec9eb3e9c2..a5989fab1c6 100644
@@ -3,7 +3,6 @@ CONFIG_ARCH_SUNXI=y
 CONFIG_DEFAULT_DEVICE_TREE="sun50i-a64-olinuxino-emmc"
 CONFIG_SPL=y
 CONFIG_MACH_SUN50I=y
-CONFIG_RESERVE_ALLWINNER_BOOT0_HEADER=y
 CONFIG_MMC_SUNXI_SLOT_EXTRA=2
 # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
 CONFIG_SUPPORT_EMMC_BOOT=y
configs/a64-olinuxino_defconfig +0 -1
index 16cef18beef..0b469c25d0d 100644
@@ -3,7 +3,6 @@ CONFIG_ARCH_SUNXI=y
 CONFIG_DEFAULT_DEVICE_TREE="sun50i-a64-olinuxino"
 CONFIG_SPL=y
 CONFIG_MACH_SUN50I=y
-CONFIG_RESERVE_ALLWINNER_BOOT0_HEADER=y
 CONFIG_MMC_SUNXI_SLOT_EXTRA=2
 # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
 CONFIG_SUN8I_EMAC=y
configs/amarula_a64_relic_defconfig +0 -1
index ae44b66d109..292af6e372e 100644
@@ -3,7 +3,6 @@ CONFIG_ARCH_SUNXI=y
 CONFIG_DEFAULT_DEVICE_TREE="sun50i-a64-amarula-relic"
 CONFIG_SPL=y
 CONFIG_MACH_SUN50I=y
-CONFIG_RESERVE_ALLWINNER_BOOT0_HEADER=y
 CONFIG_MMC_SUNXI_SLOT_EXTRA=2
 # CONFIG_VIDEO_DE2 is not set
 # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
configs/bananapi_m64_defconfig +0 -1
index 99dc2f7d209..d957071cb13 100644
@@ -3,7 +3,6 @@ CONFIG_ARCH_SUNXI=y
 CONFIG_DEFAULT_DEVICE_TREE="sun50i-a64-bananapi-m64"
 CONFIG_SPL=y
 CONFIG_MACH_SUN50I=y
-CONFIG_RESERVE_ALLWINNER_BOOT0_HEADER=y
 CONFIG_MMC_SUNXI_SLOT_EXTRA=2
 # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
 CONFIG_SUPPORT_EMMC_BOOT=y
configs/nanopi_a64_defconfig +0 -1
index 70fc257eebd..608238757ba 100644
@@ -3,7 +3,6 @@ CONFIG_ARCH_SUNXI=y
 CONFIG_DEFAULT_DEVICE_TREE="sun50i-a64-nanopi-a64"
 CONFIG_SPL=y
 CONFIG_MACH_SUN50I=y
-CONFIG_RESERVE_ALLWINNER_BOOT0_HEADER=y
 # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
 CONFIG_SUN8I_EMAC=y
 CONFIG_USB_EHCI_HCD=y
configs/oceanic_5205_5inmfd_defconfig +0 -1
index 2ebca673808..6cdcf782bee 100644
@@ -3,7 +3,6 @@ CONFIG_ARCH_SUNXI=y
 CONFIG_DEFAULT_DEVICE_TREE="sun50i-a64-oceanic-5205-5inmfd"
 CONFIG_SPL=y
 CONFIG_MACH_SUN50I=y
-CONFIG_RESERVE_ALLWINNER_BOOT0_HEADER=y
 CONFIG_SUNXI_DRAM_LPDDR3_STOCK=y
 CONFIG_DRAM_CLK=552
 CONFIG_DRAM_ZQ=3881949
configs/orangepi_win_defconfig +0 -1
index 3b78ad7e52d..df11ad8c8fd 100644
@@ -3,7 +3,6 @@ CONFIG_ARCH_SUNXI=y
 CONFIG_DEFAULT_DEVICE_TREE="sun50i-a64-orangepi-win"
 CONFIG_SPL=y
 CONFIG_MACH_SUN50I=y
-CONFIG_RESERVE_ALLWINNER_BOOT0_HEADER=y
 CONFIG_MACPWR="PD14"
 CONFIG_SPL_SPI_SUNXI=y
 # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
configs/pine64_plus_defconfig +0 -1
index f42f4e5923a..08c13b58a1e 100644
@@ -3,7 +3,6 @@ CONFIG_ARCH_SUNXI=y
 CONFIG_DEFAULT_DEVICE_TREE="sun50i-a64-pine64-plus"
 CONFIG_SPL=y
 CONFIG_MACH_SUN50I=y
-CONFIG_RESERVE_ALLWINNER_BOOT0_HEADER=y
 CONFIG_PINE64_DT_SELECTION=y
 # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
 CONFIG_OF_LIST="sun50i-a64-pine64 sun50i-a64-pine64-plus"
configs/sopine_baseboard_defconfig +0 -1
index a5e1478c117..d9b0eb37c54 100644
@@ -3,7 +3,6 @@ CONFIG_ARCH_SUNXI=y
 CONFIG_DEFAULT_DEVICE_TREE="sun50i-a64-sopine-baseboard"
 CONFIG_SPL=y
 CONFIG_MACH_SUN50I=y
-CONFIG_RESERVE_ALLWINNER_BOOT0_HEADER=y
 CONFIG_SUNXI_DRAM_LPDDR3_STOCK=y
 CONFIG_DRAM_CLK=552
 CONFIG_DRAM_ZQ=3881949
Signature · 1 line
2.25.1
maintainer Reviewed-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] sunxi: remove support for boot0 header reservation

Dne sreda, 05. april 2023 ob 16:27:31 CEST je Andre Przywara napisal(a):

Quoted 8 lines

In the early days of the Allwinner A64 U-Boot support, we relied on a vendor provided "boot0" binary to perform the DRAM initialisation. This replaced the SPL, and required to equip the U-Boot (proper) binary with a vendor specific header to be recognised as a valid boot0 payload. Fortunately these days are long gone (we gained SPL and DRAM support in early 2017!), and we never needed to use that hack on any later 64-bit Allwinner SoC.

Quoted 7 lines

Since this is highly obsolete by now, remove the Kconfig option and the small pieces of "code" associated with it.

Provide some comments about the purpose of the remaining boot0 code on the way.

I think it's time to remove this code too.

Best regards,
Jernej

Quoted 183 lines
---
 arch/arm/include/asm/arch-sunxi/boot0.h | 18 +++++++++++-------
 arch/arm/mach-sunxi/Kconfig             |  9 ---------
 configs/a64-olinuxino-emmc_defconfig    |  1 -
 configs/a64-olinuxino_defconfig         |  1 -
 configs/amarula_a64_relic_defconfig     |  1 -
 configs/bananapi_m64_defconfig          |  1 -
 configs/nanopi_a64_defconfig            |  1 -
 configs/oceanic_5205_5inmfd_defconfig   |  1 -
 configs/orangepi_win_defconfig          |  1 -
 configs/pine64_plus_defconfig           |  1 -
 configs/sopine_baseboard_defconfig      |  1 -
 11 files changed, 11 insertions(+), 25 deletions(-)
(quoted diff) +0 -0

b/arch/arm/include/asm/arch-sunxi/boot0.h index 59ea75a96b5..1a396f78488 100644

arch/arm/include/asm/arch-sunxi/boot0.h +3 -1
@@ -1,13 +1,17 @@
 /* SPDX-License-Identifier: GPL-2.0+ */
 /*
- * Configuration settings for the Allwinner A64 (sun50i) CPU
+ * Very early code for Allwinner 64-bit CPUs.
+ *
+ * The BROM runs entirely in AArch32 state, so the SPL is entered using

this + * ISA. Depending on the rest of the firmware stack, this may also be true + * for U-Boot proper.
+ * Provide the "RMR reset into 64-bit" sequence, in AArch32 machine language, + * so that we can have all of U-Boot in AArch64. The first instruction is + * chosen so that if the CPU is already using AArch64, it will skip the code + * and jump straight to the reset vector. */

-#if defined(CONFIG_RESERVE_ALLWINNER_BOOT0_HEADER) && !defined(CONFIG_SPL_BUILD) -/* reserve space for BOOT0 header information */

arch/arm/include/asm/arch-sunxi/boot0.h +2 -4
-	b	reset
-	.space	1532
-#elif defined(CONFIG_ARM_BOOT_HOOK_RMR)
+#ifdef CONFIG_ARM_BOOT_HOOK_RMR
 /*
  * Switch into AArch64 if needed.
  * Refer to arch/arm/mach-sunxi/rmr_switch.S for the original source.
@@ -47,7 +51,7 @@
 	.word   CONFIG_TEXT_BASE
 #endif
 	.word	fel_stash - .
-#else
+#else	/* !CONFIG_ARM_BOOT_HOOK_RMR */
 /* normal execution */
 	b	reset
 #endif
arch/arm/mach-sunxi/Kconfig +0 -9
index b46667ce01e..0527b3863a7 100644
@@ -386,15 +386,6 @@ config MACH_SUN8I
 	default y if MACH_SUN8I_R40
 	default y if MACH_SUN8I_V3S
 
-config RESERVE_ALLWINNER_BOOT0_HEADER
-	bool "reserve space for Allwinner boot0 header"
-	select ENABLE_ARM_SOC_BOOT0_HOOK
-	---help---
-	Prepend a 1536 byte (empty) header to the U-Boot image file, to be
-	filled with magic values post build. The Allwinner provided boot0
-	blob relies on this information to load and execute U-Boot.
-	Only needed on 64-bit Allwinner boards so far when using boot0.
-
 config ARM_BOOT_HOOK_RMR
 	bool
 	depends on ARM64
(quoted diff) +0 -0

b/configs/a64-olinuxino-emmc_defconfig index 8ec9eb3e9c2..a5989fab1c6 100644

configs/a64-olinuxino-emmc_defconfig +0 -1
@@ -3,7 +3,6 @@ CONFIG_ARCH_SUNXI=y
 CONFIG_DEFAULT_DEVICE_TREE="sun50i-a64-olinuxino-emmc"
 CONFIG_SPL=y
 CONFIG_MACH_SUN50I=y
-CONFIG_RESERVE_ALLWINNER_BOOT0_HEADER=y
 CONFIG_MMC_SUNXI_SLOT_EXTRA=2
 # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
 CONFIG_SUPPORT_EMMC_BOOT=y
(quoted diff) +0 -0

b/configs/a64-olinuxino_defconfig index 16cef18beef..0b469c25d0d 100644

configs/a64-olinuxino_defconfig +0 -1
@@ -3,7 +3,6 @@ CONFIG_ARCH_SUNXI=y
 CONFIG_DEFAULT_DEVICE_TREE="sun50i-a64-olinuxino"
 CONFIG_SPL=y
 CONFIG_MACH_SUN50I=y
-CONFIG_RESERVE_ALLWINNER_BOOT0_HEADER=y
 CONFIG_MMC_SUNXI_SLOT_EXTRA=2
 # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
 CONFIG_SUN8I_EMAC=y
(quoted diff) +0 -0

b/configs/amarula_a64_relic_defconfig index ae44b66d109..292af6e372e 100644

configs/amarula_a64_relic_defconfig +0 -1
@@ -3,7 +3,6 @@ CONFIG_ARCH_SUNXI=y
 CONFIG_DEFAULT_DEVICE_TREE="sun50i-a64-amarula-relic"
 CONFIG_SPL=y
 CONFIG_MACH_SUN50I=y
-CONFIG_RESERVE_ALLWINNER_BOOT0_HEADER=y
 CONFIG_MMC_SUNXI_SLOT_EXTRA=2
 # CONFIG_VIDEO_DE2 is not set
 # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
configs/bananapi_m64_defconfig +0 -1
index 99dc2f7d209..d957071cb13 100644
@@ -3,7 +3,6 @@ CONFIG_ARCH_SUNXI=y
 CONFIG_DEFAULT_DEVICE_TREE="sun50i-a64-bananapi-m64"
 CONFIG_SPL=y
 CONFIG_MACH_SUN50I=y
-CONFIG_RESERVE_ALLWINNER_BOOT0_HEADER=y
 CONFIG_MMC_SUNXI_SLOT_EXTRA=2
 # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
 CONFIG_SUPPORT_EMMC_BOOT=y
configs/nanopi_a64_defconfig +0 -1
index 70fc257eebd..608238757ba 100644
@@ -3,7 +3,6 @@ CONFIG_ARCH_SUNXI=y
 CONFIG_DEFAULT_DEVICE_TREE="sun50i-a64-nanopi-a64"
 CONFIG_SPL=y
 CONFIG_MACH_SUN50I=y
-CONFIG_RESERVE_ALLWINNER_BOOT0_HEADER=y
 # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
 CONFIG_SUN8I_EMAC=y
 CONFIG_USB_EHCI_HCD=y
(quoted diff) +0 -0

b/configs/oceanic_5205_5inmfd_defconfig index 2ebca673808..6cdcf782bee 100644

configs/oceanic_5205_5inmfd_defconfig +0 -1
@@ -3,7 +3,6 @@ CONFIG_ARCH_SUNXI=y
 CONFIG_DEFAULT_DEVICE_TREE="sun50i-a64-oceanic-5205-5inmfd"
 CONFIG_SPL=y
 CONFIG_MACH_SUN50I=y
-CONFIG_RESERVE_ALLWINNER_BOOT0_HEADER=y
 CONFIG_SUNXI_DRAM_LPDDR3_STOCK=y
 CONFIG_DRAM_CLK=552
 CONFIG_DRAM_ZQ=3881949
configs/orangepi_win_defconfig +0 -1
index 3b78ad7e52d..df11ad8c8fd 100644
@@ -3,7 +3,6 @@ CONFIG_ARCH_SUNXI=y
 CONFIG_DEFAULT_DEVICE_TREE="sun50i-a64-orangepi-win"
 CONFIG_SPL=y
 CONFIG_MACH_SUN50I=y
-CONFIG_RESERVE_ALLWINNER_BOOT0_HEADER=y
 CONFIG_MACPWR="PD14"
 CONFIG_SPL_SPI_SUNXI=y
 # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
configs/pine64_plus_defconfig +0 -1
index f42f4e5923a..08c13b58a1e 100644
@@ -3,7 +3,6 @@ CONFIG_ARCH_SUNXI=y
 CONFIG_DEFAULT_DEVICE_TREE="sun50i-a64-pine64-plus"
 CONFIG_SPL=y
 CONFIG_MACH_SUN50I=y
-CONFIG_RESERVE_ALLWINNER_BOOT0_HEADER=y
 CONFIG_PINE64_DT_SELECTION=y
 # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
 CONFIG_OF_LIST="sun50i-a64-pine64 sun50i-a64-pine64-plus"
(quoted diff) +0 -0

b/configs/sopine_baseboard_defconfig index a5e1478c117..d9b0eb37c54 100644

configs/sopine_baseboard_defconfig +0 -1
@@ -3,7 +3,6 @@ CONFIG_ARCH_SUNXI=y
 CONFIG_DEFAULT_DEVICE_TREE="sun50i-a64-sopine-baseboard"
 CONFIG_SPL=y
 CONFIG_MACH_SUN50I=y
-CONFIG_RESERVE_ALLWINNER_BOOT0_HEADER=y
 CONFIG_SUNXI_DRAM_LPDDR3_STOCK=y
 CONFIG_DRAM_CLK=552
 CONFIG_DRAM_ZQ=3881949
#3 lore raw

Re: [PATCH 2/2] sunxi: remove support for boot0 header reservation

On Sat, 08 Apr 2023 08:19:16 +0200
Jernej Škrabec <[email protected]> wrote:

Hi,

Quoted 12 lines

Dne sreda, 05. april 2023 ob 16:27:31 CEST je Andre Przywara napisal(a):

Quoted 11 lines

In the early days of the Allwinner A64 U-Boot support, we relied on a vendor provided "boot0" binary to perform the DRAM initialisation. This replaced the SPL, and required to equip the U-Boot (proper) binary with a vendor specific header to be recognised as a valid boot0 payload. Fortunately these days are long gone (we gained SPL and DRAM support in early 2017!), and we never needed to use that hack on any later 64-bit Allwinner SoC.

Since this is highly obsolete by now, remove the Kconfig option and the small pieces of "code" associated with it.

Quoted 8 lines
Quoted 4 lines

Provide some comments about the purpose of the remaining boot0 code on the way.

I think it's time to remove this code too.

Many thanks! So I kept the "code" in for now, to appease Piotr, but removed the symbols from the A64's defconfigs. I will propose that removal then again at a later time.

Queued for sunxi/master.

Cheers,
Andre

Quoted 189 lines
Quoted 184 lines
---
 arch/arm/include/asm/arch-sunxi/boot0.h | 18 +++++++++++-------
 arch/arm/mach-sunxi/Kconfig             |  9 ---------
 configs/a64-olinuxino-emmc_defconfig    |  1 -
 configs/a64-olinuxino_defconfig         |  1 -
 configs/amarula_a64_relic_defconfig     |  1 -
 configs/bananapi_m64_defconfig          |  1 -
 configs/nanopi_a64_defconfig            |  1 -
 configs/oceanic_5205_5inmfd_defconfig   |  1 -
 configs/orangepi_win_defconfig          |  1 -
 configs/pine64_plus_defconfig           |  1 -
 configs/sopine_baseboard_defconfig      |  1 -
 11 files changed, 11 insertions(+), 25 deletions(-)
(quoted diff) +0 -0

b/arch/arm/include/asm/arch-sunxi/boot0.h index 59ea75a96b5..1a396f78488 100644

arch/arm/include/asm/arch-sunxi/boot0.h +3 -1
@@ -1,13 +1,17 @@
 /* SPDX-License-Identifier: GPL-2.0+ */
 /*
- * Configuration settings for the Allwinner A64 (sun50i) CPU
+ * Very early code for Allwinner 64-bit CPUs.
+ *
+ * The BROM runs entirely in AArch32 state, so the SPL is entered using

this + * ISA. Depending on the rest of the firmware stack, this may also be true + * for U-Boot proper.
+ * Provide the "RMR reset into 64-bit" sequence, in AArch32 machine language, + * so that we can have all of U-Boot in AArch64. The first instruction is + * chosen so that if the CPU is already using AArch64, it will skip the code + * and jump straight to the reset vector. */

-#if defined(CONFIG_RESERVE_ALLWINNER_BOOT0_HEADER) && !defined(CONFIG_SPL_BUILD) -/* reserve space for BOOT0 header information */

arch/arm/include/asm/arch-sunxi/boot0.h +2 -4
-	b	reset
-	.space	1532
-#elif defined(CONFIG_ARM_BOOT_HOOK_RMR)
+#ifdef CONFIG_ARM_BOOT_HOOK_RMR
 /*
  * Switch into AArch64 if needed.
  * Refer to arch/arm/mach-sunxi/rmr_switch.S for the original source.
@@ -47,7 +51,7 @@
 	.word   CONFIG_TEXT_BASE
 #endif
 	.word	fel_stash - .
-#else
+#else	/* !CONFIG_ARM_BOOT_HOOK_RMR */
 /* normal execution */
 	b	reset
 #endif
arch/arm/mach-sunxi/Kconfig +0 -9
index b46667ce01e..0527b3863a7 100644
@@ -386,15 +386,6 @@ config MACH_SUN8I
 	default y if MACH_SUN8I_R40
 	default y if MACH_SUN8I_V3S
 
-config RESERVE_ALLWINNER_BOOT0_HEADER
-	bool "reserve space for Allwinner boot0 header"
-	select ENABLE_ARM_SOC_BOOT0_HOOK
-	---help---
-	Prepend a 1536 byte (empty) header to the U-Boot image file, to be
-	filled with magic values post build. The Allwinner provided boot0
-	blob relies on this information to load and execute U-Boot.
-	Only needed on 64-bit Allwinner boards so far when using boot0.
-
 config ARM_BOOT_HOOK_RMR
 	bool
 	depends on ARM64
(quoted diff) +0 -0

b/configs/a64-olinuxino-emmc_defconfig index 8ec9eb3e9c2..a5989fab1c6 100644

configs/a64-olinuxino-emmc_defconfig +0 -1
@@ -3,7 +3,6 @@ CONFIG_ARCH_SUNXI=y
 CONFIG_DEFAULT_DEVICE_TREE="sun50i-a64-olinuxino-emmc"
 CONFIG_SPL=y
 CONFIG_MACH_SUN50I=y
-CONFIG_RESERVE_ALLWINNER_BOOT0_HEADER=y
 CONFIG_MMC_SUNXI_SLOT_EXTRA=2
 # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
 CONFIG_SUPPORT_EMMC_BOOT=y
(quoted diff) +0 -0

b/configs/a64-olinuxino_defconfig index 16cef18beef..0b469c25d0d 100644

configs/a64-olinuxino_defconfig +0 -1
@@ -3,7 +3,6 @@ CONFIG_ARCH_SUNXI=y
 CONFIG_DEFAULT_DEVICE_TREE="sun50i-a64-olinuxino"
 CONFIG_SPL=y
 CONFIG_MACH_SUN50I=y
-CONFIG_RESERVE_ALLWINNER_BOOT0_HEADER=y
 CONFIG_MMC_SUNXI_SLOT_EXTRA=2
 # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
 CONFIG_SUN8I_EMAC=y
(quoted diff) +0 -0

b/configs/amarula_a64_relic_defconfig index ae44b66d109..292af6e372e 100644

configs/amarula_a64_relic_defconfig +0 -1
@@ -3,7 +3,6 @@ CONFIG_ARCH_SUNXI=y
 CONFIG_DEFAULT_DEVICE_TREE="sun50i-a64-amarula-relic"
 CONFIG_SPL=y
 CONFIG_MACH_SUN50I=y
-CONFIG_RESERVE_ALLWINNER_BOOT0_HEADER=y
 CONFIG_MMC_SUNXI_SLOT_EXTRA=2
 # CONFIG_VIDEO_DE2 is not set
 # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
configs/bananapi_m64_defconfig +0 -1
index 99dc2f7d209..d957071cb13 100644
@@ -3,7 +3,6 @@ CONFIG_ARCH_SUNXI=y
 CONFIG_DEFAULT_DEVICE_TREE="sun50i-a64-bananapi-m64"
 CONFIG_SPL=y
 CONFIG_MACH_SUN50I=y
-CONFIG_RESERVE_ALLWINNER_BOOT0_HEADER=y
 CONFIG_MMC_SUNXI_SLOT_EXTRA=2
 # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
 CONFIG_SUPPORT_EMMC_BOOT=y
configs/nanopi_a64_defconfig +0 -1
index 70fc257eebd..608238757ba 100644
@@ -3,7 +3,6 @@ CONFIG_ARCH_SUNXI=y
 CONFIG_DEFAULT_DEVICE_TREE="sun50i-a64-nanopi-a64"
 CONFIG_SPL=y
 CONFIG_MACH_SUN50I=y
-CONFIG_RESERVE_ALLWINNER_BOOT0_HEADER=y
 # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
 CONFIG_SUN8I_EMAC=y
 CONFIG_USB_EHCI_HCD=y
(quoted diff) +0 -0

b/configs/oceanic_5205_5inmfd_defconfig index 2ebca673808..6cdcf782bee 100644

configs/oceanic_5205_5inmfd_defconfig +0 -1
@@ -3,7 +3,6 @@ CONFIG_ARCH_SUNXI=y
 CONFIG_DEFAULT_DEVICE_TREE="sun50i-a64-oceanic-5205-5inmfd"
 CONFIG_SPL=y
 CONFIG_MACH_SUN50I=y
-CONFIG_RESERVE_ALLWINNER_BOOT0_HEADER=y
 CONFIG_SUNXI_DRAM_LPDDR3_STOCK=y
 CONFIG_DRAM_CLK=552
 CONFIG_DRAM_ZQ=3881949
configs/orangepi_win_defconfig +0 -1
index 3b78ad7e52d..df11ad8c8fd 100644
@@ -3,7 +3,6 @@ CONFIG_ARCH_SUNXI=y
 CONFIG_DEFAULT_DEVICE_TREE="sun50i-a64-orangepi-win"
 CONFIG_SPL=y
 CONFIG_MACH_SUN50I=y
-CONFIG_RESERVE_ALLWINNER_BOOT0_HEADER=y
 CONFIG_MACPWR="PD14"
 CONFIG_SPL_SPI_SUNXI=y
 # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
configs/pine64_plus_defconfig +0 -1
index f42f4e5923a..08c13b58a1e 100644
@@ -3,7 +3,6 @@ CONFIG_ARCH_SUNXI=y
 CONFIG_DEFAULT_DEVICE_TREE="sun50i-a64-pine64-plus"
 CONFIG_SPL=y
 CONFIG_MACH_SUN50I=y
-CONFIG_RESERVE_ALLWINNER_BOOT0_HEADER=y
 CONFIG_PINE64_DT_SELECTION=y
 # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
 CONFIG_OF_LIST="sun50i-a64-pine64 sun50i-a64-pine64-plus"
(quoted diff) +0 -0

b/configs/sopine_baseboard_defconfig index a5e1478c117..d9b0eb37c54 100644

configs/sopine_baseboard_defconfig +0 -1
@@ -3,7 +3,6 @@ CONFIG_ARCH_SUNXI=y
 CONFIG_DEFAULT_DEVICE_TREE="sun50i-a64-sopine-baseboard"
 CONFIG_SPL=y
 CONFIG_MACH_SUN50I=y
-CONFIG_RESERVE_ALLWINNER_BOOT0_HEADER=y
 CONFIG_SUNXI_DRAM_LPDDR3_STOCK=y
 CONFIG_DRAM_CLK=552
 CONFIG_DRAM_ZQ=3881949  
maintainer Reviewed-by on v1 1/2
#4 lore raw
In reply to Andre Przywara

Dne sreda, 05. april 2023 ob 16:27:30 CEST je Andre Przywara napisal(a):

Quoted 6 lines

To switch the ARMv8 Allwinner SoCs into the 64-bit AArch64 ISA, we need to program the 64-bit start code address into an MMIO mapped register that shadows the architectural RVBAR register.
This address is SoC specific, with just two versions out there so far. Now a third address emerged, on a *variant* of an existing SoC (H616).

Quoted 8 lines

Change the boot0.h start code to make this address a Kconfig selectable option, to allow easier maintenance.
We make this address user-visible (even though it shouldn't be), to allow putting this in defconfig. This is needed because there are apparently revisions of the H616 SoC out there using different addresses, so this becomes a per-board decision.

Best regards,
Jernej

Quoted 11 lines
---
 arch/arm/include/asm/arch-sunxi/boot0.h |  7 ++-----
 arch/arm/mach-sunxi/Kconfig             | 12 ++++++++++++
 2 files changed, 14 insertions(+), 5 deletions(-)
(quoted diff) +0 -0

b/arch/arm/include/asm/arch-sunxi/boot0.h index 46b7e073b59..59ea75a96b5 100644

arch/arm/include/asm/arch-sunxi/boot0.h line 43

Quoted 10 lines
arch/arm/include/asm/arch-sunxi/boot0.h +2 -5
@@ -39,11 +39,8 @@
 	.word	0xf57ff06f	// isb     sy
 	.word	0xe320f003	// wfi
 	.word	0xeafffffd	// b       @wfi
-#ifndef CONFIG_SUN50I_GEN_H6
-	.word	0x017000a0	// writeable RVBAR mapping address
-#else
-	.word	0x09010040	// writeable RVBAR mapping address
-#endif
+
+	.word	CONFIG_SUNXI_RVBAR_ADDRESS	// writable RVBAR mapping 

addr

Quoted 25 lines
arch/arm/include/asm/arch-sunxi/boot0.h +0 -0
 #ifdef CONFIG_SPL_BUILD
 	.word	CONFIG_SPL_TEXT_BASE
 #else
arch/arm/mach-sunxi/Kconfig +12 -0
index 6417aee944b..b46667ce01e 100644
@@ -110,6 +110,18 @@ config SUNXI_SRAM_ADDRESS
 	Some newer SoCs map the boot ROM at address 0 instead and move the
 	SRAM to a different address.
 
+config SUNXI_RVBAR_ADDRESS
+	hex "RVBAR address"
+	depends on ARM64
+	default 0x09010040 if SUN50I_GEN_H6
+	default 0x017000a0
+	---help---
+	The read-only RVBAR system register holds the address of the first
+	instruction to execute after a reset. Allwinner cores provide a
+	writable MMIO backing store for this register, to allow to set the
+	entry point when switching to AArch64. This store is on different
+	addresses, depending on the SoC.
+
 config SUNXI_A64_TIMER_ERRATUM
 	bool