[PATCH v2 u-boot-mvebu 3/4] arm: mvebu: spl: Load proper U-Boot from correct eMMC partition

Pali Rohár pali at kernel.org
Thu Apr 13 22:57:49 CEST 2023


A38x BootROM completely ignores EXT_CSD_PART_CONF eMMC register and tries
to load SPL from any partition in defined order. Chosen partition can be
determined from the access bits in EXT_CSD_PART_CONF eMMC register.

So implement custom spl_mmc_emmc_boot_partition() function to always
returns eMMC partition from which BootROM loaded SPL. So this partition
would be used for loading proper U-Boot too.

Fixes: 2f27db2fbd6e ("arm: mvebu: spl: Load proper U-Boot from selected eMMC boot partition")
Signed-off-by: Pali Rohár <pali at kernel.org>
---
 arch/arm/mach-mvebu/spl.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-mvebu/spl.c b/arch/arm/mach-mvebu/spl.c
index 379daa88a4d8..0688601699f0 100644
--- a/arch/arm/mach-mvebu/spl.c
+++ b/arch/arm/mach-mvebu/spl.c
@@ -11,6 +11,7 @@
 #include <image.h>
 #include <init.h>
 #include <log.h>
+#include <mmc.h>
 #include <spl.h>
 #include <asm/global_data.h>
 #include <asm/io.h>
@@ -34,8 +35,9 @@
 
 /*
  * When loading U-Boot via SPL from eMMC, the kwbimage main header is stored at
- * sector 0 and either on HW boot partition or on data partition. Choice of HW
- * partition depends on what is configured in eMMC EXT_CSC register.
+ * sector 0 on some HW/boot partition. Choice of HW partition depends on what is
+ * set in PART_ACCESS_MASK bits of EXT_CSD_PART_CONF eMMC register. Partition
+ * access bits into EXT_CSD_PART_CONF are set by the BootROM.
  * When loading U-Boot via SPL from SD card, the kwbimage main header is stored
  * at sector 1.
  * Therefore MBR/GPT partition booting, fixed sector number and fixed eMMC HW
@@ -123,6 +125,10 @@ u32 spl_mmc_boot_mode(struct mmc *mmc, const u32 boot_device)
 {
 	return IS_SD(mmc) ? MMCSD_MODE_RAW : MMCSD_MODE_EMMCBOOT;
 }
+int spl_mmc_emmc_boot_partition(struct mmc *mmc)
+{
+	return EXT_CSD_EXTRACT_PARTITION_ACCESS(mmc->part_config);
+}
 unsigned long spl_mmc_get_uboot_raw_sector(struct mmc *mmc,
 					   unsigned long raw_sect)
 {
-- 
2.20.1



More information about the U-Boot mailing list