[PATCH u-boot-mvebu 22/31] arm: mvebu: Always use BootROM for loading the rest of U-Boot's binary

Marek Behún marek.behun at nic.cz
Thu Jul 8 19:30:23 CEST 2021


From: Pali Rohár <pali at kernel.org>

Now that proper load and execution addresses are set in v1 kwbimage, we
can use BootROM to continue loading main U-Boot binary instead of
U-Boot's SPL code.

This also reduces the size of U-Boot's SPL image.

The v1 kwbimage contains two separate executable parts: DDR training
code (contains SPL) and bootloader (contains main U-Boot). BootROM first
loads the first part, executes it and expects that the code returns back.
Afterwards it loads the second part and executes it.

The current SPL code (used for the first part) for non-UART/NAND boots
never returns back to BootROM and loads main U-Boot from external storage
itself, and it lets BootROM think that it is still executing the first
part - DDR training code.

With this change the SPL always returns execution back to BootROM and
lets BootROM to load and execute U-Boot, like it was already done when
booting from UART and NAND.

Note that the config options CONFIG_SPL_SPI_FLASH_SUPPORT,
CONFIG_SPL_SPI_LOAD and CONFIG_SPL_SPI_SUPPORT needs to be enabled as
config option CONFIG_SYS_U_BOOT_OFFS (used by kwbimage) depends on it.

Signed-off-by: Pali Rohár <pali at kernel.org>
Reviewed-by: Marek Behún <marek.behun at nic.cz>
---
 arch/arm/mach-mvebu/Kconfig |  9 ----
 arch/arm/mach-mvebu/spl.c   | 84 +------------------------------------
 2 files changed, 1 insertion(+), 92 deletions(-)

diff --git a/arch/arm/mach-mvebu/Kconfig b/arch/arm/mach-mvebu/Kconfig
index 2133d9a172..46ac43c7a0 100644
--- a/arch/arm/mach-mvebu/Kconfig
+++ b/arch/arm/mach-mvebu/Kconfig
@@ -253,7 +253,6 @@ choice
 config MVEBU_SPL_BOOT_DEVICE_SPI
 	bool "SPI NOR flash"
 	imply ENV_IS_IN_SPI_FLASH
-	select SPL_DM_SPI
 	select SPL_SPI_FLASH_SUPPORT
 	select SPL_SPI_LOAD
 	select SPL_SPI_SUPPORT
@@ -262,18 +261,10 @@ config MVEBU_SPL_BOOT_DEVICE_SPI
 config MVEBU_SPL_BOOT_DEVICE_MMC
 	bool "SDIO/MMC card"
 	imply ENV_IS_IN_MMC
-	# GPIO needed for eMMC/SD card presence detection
-	select SPL_DM_GPIO
-	select SPL_DM_MMC
-	select SPL_GPIO_SUPPORT
-	select SPL_LIBDISK_SUPPORT
-	select SPL_MMC_SUPPORT
 	select SPL_BOOTROM_SUPPORT
 
 config MVEBU_SPL_BOOT_DEVICE_SATA
 	bool "SATA"
-	select SPL_SATA_SUPPORT
-	select SPL_LIBDISK_SUPPORT
 	select SPL_BOOTROM_SUPPORT
 
 config MVEBU_SPL_BOOT_DEVICE_UART
diff --git a/arch/arm/mach-mvebu/spl.c b/arch/arm/mach-mvebu/spl.c
index 3551c9de42..b13621b46a 100644
--- a/arch/arm/mach-mvebu/spl.c
+++ b/arch/arm/mach-mvebu/spl.c
@@ -16,91 +16,9 @@
 #include <asm/arch/cpu.h>
 #include <asm/arch/soc.h>
 
-static u32 get_boot_device(void)
-{
-	u32 val;
-	u32 boot_device;
-
-	/*
-	 * First check, if UART boot-mode is active. This can only
-	 * be done, via the bootrom error register. Here the
-	 * MSB marks if the UART mode is active.
-	 */
-	val = readl(CONFIG_BOOTROM_ERR_REG);
-	boot_device = (val & BOOTROM_ERR_MODE_MASK) >> BOOTROM_ERR_MODE_OFFS;
-	debug("BOOTROM_REG=0x%08x boot_device=0x%x\n", val, boot_device);
-	if (boot_device == BOOTROM_ERR_MODE_UART)
-		return BOOT_DEVICE_UART;
-
-#ifdef CONFIG_ARMADA_38X
-	/*
-	 * If the bootrom error code contains any other than zeros it's an
-	 * error condition and the bootROM has fallen back to UART boot
-	 */
-	boot_device = (val & BOOTROM_ERR_CODE_MASK) >> BOOTROM_ERR_CODE_OFFS;
-	if (boot_device)
-		return BOOT_DEVICE_UART;
-#endif
-
-	/*
-	 * Now check the SAR register for the strapped boot-device
-	 */
-	val = readl(CONFIG_SAR_REG);	/* SAR - Sample At Reset */
-	boot_device = (val & BOOT_DEV_SEL_MASK) >> BOOT_DEV_SEL_OFFS;
-	debug("SAR_REG=0x%08x boot_device=0x%x\n", val, boot_device);
-	switch (boot_device) {
-#if defined(CONFIG_ARMADA_38X)
-	case BOOT_FROM_NAND:
-		return BOOT_DEVICE_NAND;
-#endif
-#ifdef CONFIG_SPL_MMC_SUPPORT
-	case BOOT_FROM_MMC:
-	case BOOT_FROM_MMC_ALT:
-		return BOOT_DEVICE_MMC1;
-#endif
-	case BOOT_FROM_UART:
-#ifdef BOOT_FROM_UART_ALT
-	case BOOT_FROM_UART_ALT:
-#endif
-		return BOOT_DEVICE_UART;
-#ifdef BOOT_FROM_SATA
-	case BOOT_FROM_SATA:
-	case BOOT_FROM_SATA_ALT:
-		return BOOT_DEVICE_SATA;
-#endif
-	case BOOT_FROM_SPI:
-	default:
-		return BOOT_DEVICE_SPI;
-	};
-}
-
 u32 spl_boot_device(void)
 {
-	u32 boot_device = get_boot_device();
-
-	/*
-	 * Return to the BootROM to continue the Marvell xmodem
-	 * UART boot protocol. As initiated by the kwboot tool.
-	 *
-	 * This can only be done by the BootROM and not by the
-	 * U-Boot SPL infrastructure, since the beginning of the
-	 * image is already read and interpreted by the BootROM.
-	 * SPL has no chance to receive this information. So we
-	 * need to return to the BootROM to enable this xmodem
-	 * UART download.
-	 *
-	 * If booting from NAND lets let the BootROM load the
-	 * rest of the bootloader.
-	 */
-	switch (boot_device) {
-		case BOOT_DEVICE_UART:
-#if defined(CONFIG_ARMADA_38X)
-		case BOOT_DEVICE_NAND:
-#endif
-			return BOOT_DEVICE_BOOTROM;
-		default:
-			return boot_device;
-	}
+	return BOOT_DEVICE_BOOTROM;
 }
 
 int board_return_to_bootrom(struct spl_image_info *spl_image,
-- 
2.31.1



More information about the U-Boot mailing list