diff mbox series

[3/5] sunxi: Simplify eMMC boot partition booting

Message ID 20201108131409.14320-4-andre.przywara@arm.com
State New
Delegated to: Andre Przywara
Headers show
Series sunxi: enable automatic eMMC boot partition support | expand

Commit Message

André Przywara Nov. 8, 2020, 1:14 p.m. UTC
The Allwinner BROM also supports loading the SPL from the eMMC boot
partition, for this we have to set the CONFIG_SUPPORT_EMMC_BOOT Kconfig
symbol. But on top of that a user has to manually adjust the raw sector
to load U-Boot proper from: CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR.

To simplify this, we adjust the sector offset dynamically, whenever we
find CONFIG_SUPPORT_EMMC_BOOT enabled and are booting from the eMMC.

Unfortunately the BROM sets the same boot source code as for the boot
from the normal eMMC user data partition, so we can't tell those two
cases apart easily (yet).

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
 arch/arm/mach-sunxi/board.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
diff mbox series


diff --git a/arch/arm/mach-sunxi/board.c b/arch/arm/mach-sunxi/board.c
index f40fccd8f8b..586af24535d 100644
--- a/arch/arm/mach-sunxi/board.c
+++ b/arch/arm/mach-sunxi/board.c
@@ -279,21 +279,29 @@  uint32_t sunxi_get_boot_device(void)
  * The eGON SPL image can be located at 8KB or at 128KB into an SD card or
- * an eMMC device. The boot source has bit 4 set in the latter case.
+ * an eMMC user partition. The boot source has bit 4 set in the latter case.
  * By adding 120KB to the normal offset when booting from a "high" location
  * we can support both cases.
+ * In an eMMC boot partition the SPL is located at offset 0, so we subtract
+ * the usual 8K offset.
 unsigned long spl_mmc_get_uboot_raw_sector(struct mmc *mmc)
 	unsigned long sector = CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR;
 	switch (sunxi_get_boot_source()) {
+			sector -= 8 * 2;
+		break;
 		sector += (128 - 8) * 2;
+	debug("loading U-Boot proper from sector 0x%lx\n", sector);
 	return sector;