From: Sascha Hauer <s.hauer@pengutronix.de>
To: "open list:BAREBOX" <barebox@lists.infradead.org>
Subject: [PATCH 2/9] ARM: k3: add function to detect eMMC boot
Date: Wed, 05 Feb 2025 10:48:10 +0100 [thread overview]
Message-ID: <20250205-k3-emmc-v1-2-06679246be41@pengutronix.de> (raw)
In-Reply-To: <20250205-k3-emmc-v1-0-06679246be41@pengutronix.de>
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@pengutronix.de>
---
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
next prev parent reply other threads:[~2025-02-05 9:49 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-05 9:48 [PATCH 0/9] ARM: K3 updates Sascha Hauer
2025-02-05 9:48 ` [PATCH 1/9] ARM: k3: Add function to enable 32k crystal Sascha Hauer
2025-02-05 9:48 ` Sascha Hauer [this message]
2025-02-05 9:48 ` [PATCH 3/9] ARM: k3: do not mount /boot when booting from eMMC Sascha Hauer
2025-02-05 9:48 ` [PATCH 4/9] ARM: k3: r5: add USB DFU and eMMC boot support Sascha Hauer
2025-02-05 9:48 ` [PATCH 5/9] ARM: am625-sk: enable 32k crystal Sascha Hauer
2025-02-05 9:48 ` [PATCH 6/9] mci: am654: parse generic mmc node properties Sascha Hauer
2025-02-05 9:48 ` [PATCH 7/9] ARM: k3: limit eMMC frequency to 25MHz Sascha Hauer
2025-02-05 9:48 ` [PATCH 8/9] ARM: am625-sk: put environment on eMMC when booting from it Sascha Hauer
2025-02-05 9:48 ` [PATCH 9/9] serial: omap: Use ttyS as Linux console name Sascha Hauer
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=20250205-k3-emmc-v1-2-06679246be41@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