mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 2/2] ARM: k3: add FAT environment support
Date: Wed, 10 Sep 2025 08:18:24 +0200	[thread overview]
Message-ID: <20250910061824.2765659-2-s.hauer@pengutronix.de> (raw)
In-Reply-To: <20250910061824.2765659-1-s.hauer@pengutronix.de>

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@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




      reply	other threads:[~2025-09-10  6:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` Sascha Hauer [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250910061824.2765659-2-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox