[PATCH 2/2] ARM: k3: add FAT environment support

Sascha Hauer s.hauer at pengutronix.de
Tue Sep 9 23:18:24 PDT 2025


The am62x loads the environment from the SD boot partition when the
bootsource is SD but not eMMC. Implement the same behaviour for am62lx.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 arch/arm/mach-k3/am62lx.c | 28 ++++++++++++++++++++++++++++
 include/mach/k3/common.h  |  1 +
 2 files changed, 29 insertions(+)

diff --git a/arch/arm/mach-k3/am62lx.c b/arch/arm/mach-k3/am62lx.c
index 38a88ea7cf..88a008d628 100644
--- a/arch/arm/mach-k3/am62lx.c
+++ b/arch/arm/mach-k3/am62lx.c
@@ -137,6 +137,19 @@ void am62lx_get_bootsource(enum bootsource *src, int *instance)
 		am62lx_get_backup_bootsource(devstat, src, instance);
 }
 
+bool am62lx_boot_is_emmc(void)
+{
+	u32 bootmode = readl(AM62LX_BOOT_PARAM_TABLE_INDEX_OCRAM);
+	u32 devstat = readl(AM62LX_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 int am62lx_init(void)
 {
 	enum bootsource src = BOOTSOURCE_UNKNOWN;
@@ -153,3 +166,18 @@ static int am62lx_init(void)
 	return 0;
 }
 postcore_initcall(am62lx_init);
+
+static int am62x_env_init(void)
+{
+	if (!of_machine_is_compatible("ti,am62l3"))
+		return 0;
+
+	if (bootsource_get() != BOOTSOURCE_MMC)
+		return 0;
+
+	if (am62lx_boot_is_emmc())
+		return 0;
+
+	return k3_env_init();
+}
+late_initcall(am62x_env_init);
diff --git a/include/mach/k3/common.h b/include/mach/k3/common.h
index bb6c4f1576..65d71ee890 100644
--- a/include/mach/k3/common.h
+++ b/include/mach/k3/common.h
@@ -11,6 +11,7 @@
 void am62x_get_bootsource(enum bootsource *src, int *instance);
 void am62lx_get_bootsource(enum bootsource *src, int *instance);
 bool am62x_boot_is_emmc(void);
+bool am62lx_boot_is_emmc(void);
 u64 am62x_sdram_size(void);
 void am62x_register_dram(void);
 void am62x_enable_32k_crystal(void);
-- 
2.47.3




More information about the barebox mailing list