summaryrefslogtreecommitdiff
path: root/arch/arm/mach-stm32mp
diff options
context:
space:
mode:
authorPatrick Delaunay <patrick.delaunay@foss.st.com>2021-07-06 17:19:45 +0200
committerPatrick Delaunay <patrick.delaunay@foss.st.com>2021-07-16 09:28:46 +0200
commit3c1057c5480cf74b91f782627d6edc08b18f2b0b (patch)
treee5f9c4f6022231ba054e009a010452a6955a8a6e /arch/arm/mach-stm32mp
parentb18c3abdea847aac4ad143c1ff150c2765f5b5ae (diff)
stm32mp: use device sequence number in boot_instance variable
Use the device sequence number in boot_instance variable and no more the SDMMC instance provided by ROM code/TF-A. After this patch we don't need to define the mmc alias in device tree, for example: mmc0 = &sdmmc1; mmc1 = &sdmmc2; mmc2 = &sdmmc3; to have a correct mapping between the ROM code boot device = "${boot_device}${boot_instance}" and the MMC device in U-Boot. With this patch the 'mmc0' device (used in mmc commands) is always used when only one instance sdmmc is activated in device tree, even if it is only the sdmmc2 or sdmmc3. Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com> Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
Diffstat (limited to 'arch/arm/mach-stm32mp')
-rw-r--r--arch/arm/mach-stm32mp/cpu.c16
-rw-r--r--arch/arm/mach-stm32mp/include/mach/stm32.h4
2 files changed, 19 insertions, 1 deletions
diff --git a/arch/arm/mach-stm32mp/cpu.c b/arch/arm/mach-stm32mp/cpu.c
index 592bfd413d..f6ed2ce0e4 100644
--- a/arch/arm/mach-stm32mp/cpu.c
+++ b/arch/arm/mach-stm32mp/cpu.c
@@ -483,6 +483,11 @@ static void setup_boot_mode(void)
STM32_UART7_BASE,
STM32_UART8_BASE
};
+ const u32 sdmmc_addr[] = {
+ STM32_SDMMC1_BASE,
+ STM32_SDMMC2_BASE,
+ STM32_SDMMC3_BASE
+ };
char cmd[60];
u32 boot_ctx = readl(TAMP_BOOT_CONTEXT);
u32 boot_mode =
@@ -525,7 +530,16 @@ static void setup_boot_mode(void)
break;
case BOOT_FLASH_SD:
case BOOT_FLASH_EMMC:
- sprintf(cmd, "%d", instance);
+ if (instance > ARRAY_SIZE(sdmmc_addr))
+ break;
+ /* search associated sdmmc node in devicetree */
+ sprintf(cmd, "mmc@%x", sdmmc_addr[instance]);
+ if (uclass_get_device_by_name(UCLASS_MMC, cmd, &dev)) {
+ printf("mmc%d = %s not found in device tree!\n",
+ instance, cmd);
+ break;
+ }
+ sprintf(cmd, "%d", dev_seq(dev));
env_set("boot_device", "mmc");
env_set("boot_instance", cmd);
break;
diff --git a/arch/arm/mach-stm32mp/include/mach/stm32.h b/arch/arm/mach-stm32mp/include/mach/stm32.h
index 5fdb893b0e..c11a9903f2 100644
--- a/arch/arm/mach-stm32mp/include/mach/stm32.h
+++ b/arch/arm/mach-stm32mp/include/mach/stm32.h
@@ -32,6 +32,10 @@
#define STM32_UART7_BASE 0x40018000
#define STM32_UART8_BASE 0x40019000
+#define STM32_SDMMC1_BASE 0x58005000
+#define STM32_SDMMC2_BASE 0x58007000
+#define STM32_SDMMC3_BASE 0x48004000
+
#define STM32_SYSRAM_BASE 0x2FFC0000
#define STM32_SYSRAM_SIZE SZ_256K