Booting from eMMC on K3 SoCs requires some special handling. With SD card boot we put the environment in the boot FAT partition whereas with eMMC boot we want to put it into the raw eMMC device. Also with eMMC boot we have to load the subsequent stages from the eMMC boot partitions and from the boot FAT otherwise. Add a function to detect eMMC boot to base these decisions on. Signed-off-by: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx> --- arch/arm/mach-k3/common.c | 13 +++++++++++++ include/mach/k3/common.h | 1 + 2 files changed, 14 insertions(+) diff --git a/arch/arm/mach-k3/common.c b/arch/arm/mach-k3/common.c index c779e873c9..7ded1f3f04 100644 --- a/arch/arm/mach-k3/common.c +++ b/arch/arm/mach-k3/common.c @@ -162,6 +162,19 @@ void am625_get_bootsource(enum bootsource *src, int *instance) k3_get_bootsource(devstat, src, instance); } +bool k3_boot_is_emmc(void) +{ + u32 bootmode = readl(AM625_BOOT_PARAM_TABLE_INDEX_OCRAM); + u32 devstat = readl(AM625_CTRLMMR_MAIN_DEVSTAT); + + if (bootmode != K3_PRIMARY_BOOTMODE) + return false; + if (FIELD_GET(MAIN_DEVSTAT_PRIMARY_BOOTMODE, devstat) != BOOT_DEVICE_EMMC) + return false; + + return true; +} + static void of_delete_node_path(struct device_node *root, const char *path) { struct device_node *np; diff --git a/include/mach/k3/common.h b/include/mach/k3/common.h index 3377dc8895..7f0796f7f4 100644 --- a/include/mach/k3/common.h +++ b/include/mach/k3/common.h @@ -4,6 +4,7 @@ #include <bootsource.h> void am625_get_bootsource(enum bootsource *src, int *instance); +bool k3_boot_is_emmc(void); u64 am625_sdram_size(void); void am625_register_dram(void); void am625_enable_32k_crystal(void); -- 2.39.5