mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/2] ARM: k3: move am62x specific bits out of common file
@ 2025-09-10  6:18 Sascha Hauer
  2025-09-10  6:18 ` [PATCH 2/2] ARM: k3: add FAT environment support Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Sascha Hauer @ 2025-09-10  6:18 UTC (permalink / raw)
  To: Barebox List

k3_boot_is_emmc() is called from common.c, but is really am62x specific
and only compiled in when am62x support is enabled. With this compiling
for am62lx only fails with an undefined reference to k3_boot_is_emmc().

Move the am62x specific files out of common.c: Move the initcall to
am62x.c and call omap_env_init() (renamed to k3_env_init()) from there
after checking the prerequisites. Also rename k3_boot_is_emmc() to
am62x_boot_is_emmc().

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/boards/am625-sk/board.c |  2 +-
 arch/arm/mach-k3/am62x.c         | 17 ++++++++++++++++-
 arch/arm/mach-k3/common.c        | 12 +-----------
 arch/arm/mach-k3/r5.c            |  2 +-
 include/mach/k3/common.h         |  3 ++-
 5 files changed, 21 insertions(+), 15 deletions(-)

diff --git a/arch/arm/boards/am625-sk/board.c b/arch/arm/boards/am625-sk/board.c
index d2fca2dae1..80be3b30b5 100644
--- a/arch/arm/boards/am625-sk/board.c
+++ b/arch/arm/boards/am625-sk/board.c
@@ -13,7 +13,7 @@ static int am625_sk_probe(struct device *dev)
 
 	k3_bbu_emmc_register("emmc", "/dev/mmc0", BBU_HANDLER_FLAG_DEFAULT);
 
-	if (k3_boot_is_emmc())
+	if (am62x_boot_is_emmc())
 		of_device_enable_path("/chosen/environment-emmc");
 
 	return 0;
diff --git a/arch/arm/mach-k3/am62x.c b/arch/arm/mach-k3/am62x.c
index 57f8efd74b..e8027ba9a8 100644
--- a/arch/arm/mach-k3/am62x.c
+++ b/arch/arm/mach-k3/am62x.c
@@ -142,7 +142,7 @@ void am62x_get_bootsource(enum bootsource *src, int *instance)
 		am62x_get_backup_bootsource(devstat, src, instance);
 }
 
-bool k3_boot_is_emmc(void)
+bool am62x_boot_is_emmc(void)
 {
 	u32 bootmode = readl(AM625_BOOT_PARAM_TABLE_INDEX_OCRAM);
 	u32 devstat = readl(AM625_CTRLMMR_MAIN_DEVSTAT);
@@ -254,3 +254,18 @@ static int am62x_init(void)
 	return 0;
 }
 postcore_initcall(am62x_init);
+
+static int am62x_env_init(void)
+{
+	if (!of_machine_is_compatible("ti,am625"))
+		return 0;
+
+	if (bootsource_get() != BOOTSOURCE_MMC)
+		return 0;
+
+	if (am62x_boot_is_emmc())
+		return 0;
+
+	return k3_env_init();
+}
+late_initcall(am62x_env_init);
diff --git a/arch/arm/mach-k3/common.c b/arch/arm/mach-k3/common.c
index aafd22453b..449075ba9b 100644
--- a/arch/arm/mach-k3/common.c
+++ b/arch/arm/mach-k3/common.c
@@ -28,22 +28,13 @@ static const struct of_device_id k3_of_match[] = {
 };
 BAREBOX_DEEP_PROBE_ENABLE(k3_of_match);
 
-static int omap_env_init(void)
+int k3_env_init(void)
 {
 	char *partname, *cdevname, *envpath;
 	struct cdev *cdev;
 	const char *rootpath;
 	int instance;
 
-	if (!of_machine_is_compatible("ti,am625"))
-		return 0;
-
-	if (bootsource_get() != BOOTSOURCE_MMC)
-		return 0;
-
-	if (k3_boot_is_emmc())
-		return 0;
-
 	instance = bootsource_get_instance();
 
 	cdevname = xasprintf("mmc%d", instance);
@@ -86,7 +77,6 @@ static int omap_env_init(void)
 
 	return 0;
 }
-late_initcall(omap_env_init);
 
 int k3_authenticate_image(void **buf, size_t *size)
 {
diff --git a/arch/arm/mach-k3/r5.c b/arch/arm/mach-k3/r5.c
index 83089b8444..b70cf18f8a 100644
--- a/arch/arm/mach-k3/r5.c
+++ b/arch/arm/mach-k3/r5.c
@@ -431,7 +431,7 @@ static int k3_r5_start_image(void)
 
 	if (IS_ENABLED(CONFIG_USB_GADGET_DFU) && bootsource_get() == BOOTSOURCE_SERIAL)
 		ret = do_dfu();
-	else if (k3_boot_is_emmc())
+	else if (am62x_boot_is_emmc())
 		ret = load_fip_emmc();
 	else
 		ret = load_fip("/boot/k3.fip", 0);
diff --git a/include/mach/k3/common.h b/include/mach/k3/common.h
index 5ce129f88c..bb6c4f1576 100644
--- a/include/mach/k3/common.h
+++ b/include/mach/k3/common.h
@@ -10,11 +10,12 @@
 
 void am62x_get_bootsource(enum bootsource *src, int *instance);
 void am62lx_get_bootsource(enum bootsource *src, int *instance);
-bool k3_boot_is_emmc(void);
+bool am62x_boot_is_emmc(void);
 u64 am62x_sdram_size(void);
 void am62x_register_dram(void);
 void am62x_enable_32k_crystal(void);
 int k3_authenticate_image(void **buf, size_t *size);
+int k3_env_init(void);
 
 #define K3_EMMC_BOOTPART_TIBOOT3_BIN_SIZE	SZ_1M
 
-- 
2.47.3




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-09-10  6:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-10  6:18 [PATCH 1/2] ARM: k3: move am62x specific bits out of common file Sascha Hauer
2025-09-10  6:18 ` [PATCH 2/2] ARM: k3: add FAT environment support Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox