Message ID | 20221220183819.515667-2-martyn.welch@collabora.com |
---|---|
State | Accepted |
Commit | 7c34b71a42817173f3bccf8a85e8a234cc456c8f |
Delegated to: | Tom Rini |
Headers | show |
Series | Enable distroboot as a boot option for am62x | expand |
On Tue, Dec 20, 2022 at 06:38:18PM +0000, Martyn Welch wrote: > The boot mode detection assumes that BOOT_DEVICE_MMC2 should always > result in MMCSD_MODE_FS, but MMCSD_MODE_RAW is also a valid option for > this port. > > The current logic also avoids looking at the bootmode pin strapping, > which should be the primary means of determining whether a device is > being booted in MMCSD_MODE_EMMCBOOT mode. > > Switch around the logic to check the boot mode to determine whether the > eMMC boot mode is expected or MMC/SD boot mode. From there we can look > at the boot mode config if in MMC/SD boot mode to determine whether to > attempt RAW or FS based booting. > > This change allows U-Boot to also be successfully booted from RAW > offsets in addition to from a filesystem. > > Signed-off-by: Martyn Welch <martyn.welch@collabora.com> Applied to u-boot/master, thanks!
diff --git a/arch/arm/mach-k3/am625_init.c b/arch/arm/mach-k3/am625_init.c index da2229d0bf..a91c15ca4e 100644 --- a/arch/arm/mach-k3/am625_init.c +++ b/arch/arm/mach-k3/am625_init.c @@ -173,21 +173,20 @@ void board_init_f(ulong dummy) u32 spl_mmc_boot_mode(struct mmc *mmc, const u32 boot_device) { u32 devstat = readl(CTRLMMR_MAIN_DEVSTAT); + u32 bootmode = (devstat & MAIN_DEVSTAT_PRIMARY_BOOTMODE_MASK) >> + MAIN_DEVSTAT_PRIMARY_BOOTMODE_SHIFT; u32 bootmode_cfg = (devstat & MAIN_DEVSTAT_PRIMARY_BOOTMODE_CFG_MASK) >> MAIN_DEVSTAT_PRIMARY_BOOTMODE_CFG_SHIFT; - switch (boot_device) { - case BOOT_DEVICE_MMC1: - if ((bootmode_cfg & MAIN_DEVSTAT_PRIMARY_MMC_FS_RAW_MASK) >> - MAIN_DEVSTAT_PRIMARY_MMC_FS_RAW_SHIFT) - return MMCSD_MODE_EMMCBOOT; - return MMCSD_MODE_FS; - - case BOOT_DEVICE_MMC2: - return MMCSD_MODE_FS; + switch (bootmode) { + case BOOT_DEVICE_EMMC: + return MMCSD_MODE_EMMCBOOT; + case BOOT_DEVICE_MMC: + if (bootmode_cfg & MAIN_DEVSTAT_PRIMARY_MMC_FS_RAW_MASK) + return MMCSD_MODE_RAW; default: - return MMCSD_MODE_RAW; + return MMCSD_MODE_FS; } }
The boot mode detection assumes that BOOT_DEVICE_MMC2 should always result in MMCSD_MODE_FS, but MMCSD_MODE_RAW is also a valid option for this port. The current logic also avoids looking at the bootmode pin strapping, which should be the primary means of determining whether a device is being booted in MMCSD_MODE_EMMCBOOT mode. Switch around the logic to check the boot mode to determine whether the eMMC boot mode is expected or MMC/SD boot mode. From there we can look at the boot mode config if in MMC/SD boot mode to determine whether to attempt RAW or FS based booting. This change allows U-Boot to also be successfully booted from RAW offsets in addition to from a filesystem. Signed-off-by: Martyn Welch <martyn.welch@collabora.com> --- arch/arm/mach-k3/am625_init.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)