mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Jonas Rebmann <jre@pengutronix.de>,
	Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH] ARM: boards: colibri-imx6: make BBU setting independent of DT alias
Date: Mon, 27 Jan 2025 12:02:52 +0100	[thread overview]
Message-ID: <20250127110252.735402-1-a.fatoum@pengutronix.de> (raw)

Different baseboards may shuffle around the eMMC/SD aliases differently
and thus the barebox update handler registration may not be correct
across all of them.

Instead of hardcoding the eMMC device and SD device, let's derive the
correct index dynamically at runtime using the mapping that the barebox
bootsource code is already using.

Reported-by: Jonas Rebmann <jre@pengutronix.de>
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
Jonas, can you give this a test and see if it works for you?
---
 arch/arm/boards/toradex-colibri-imx6/board.c | 24 +++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/arch/arm/boards/toradex-colibri-imx6/board.c b/arch/arm/boards/toradex-colibri-imx6/board.c
index f3a6173e5064..5771b08cbacb 100644
--- a/arch/arm/boards/toradex-colibri-imx6/board.c
+++ b/arch/arm/boards/toradex-colibri-imx6/board.c
@@ -9,6 +9,14 @@
 #include <mach/imx/imx6.h>
 #include <mfd/imx6q-iomuxc-gpr.h>
 
+/*
+ * The upstream device tree shuffles around the eMMC/SD indices, so the
+ * board code here takes care to use the numbering of the SoC reference
+ * manual
+ */
+#define COLIBRI_MMC_INSTANCE_SD		0
+#define COLIBRI_MMC_INSTANCE_EMMC	2
+
 static void eth_init(void)
 {
 	void __iomem *iomux = IOMEM(MX6_IOMUXC_BASE_ADDR);
@@ -22,9 +30,19 @@ static void eth_init(void)
 
 static int colibri_imx6_probe(struct device *dev)
 {
-	imx6_bbu_internal_mmcboot_register_handler("emmc", "/dev/mmc0",
-			BBU_HANDLER_FLAG_DEFAULT);
-	imx6_bbu_internal_mmc_register_handler("sd", "/dev/mmc1", 0);
+	int emmc_alias, sd_alias;
+
+	emmc_alias = bootsource_of_alias_xlate(BOOTSOURCE_MMC, COLIBRI_MMC_INSTANCE_EMMC);
+	if (emmc_alias >= 0)
+		imx6_bbu_internal_mmcboot_register_handler("emmc",
+							   basprintf("/dev/mmc%u", emmc_alias),
+							   BBU_HANDLER_FLAG_DEFAULT);
+
+	sd_alias = bootsource_of_alias_xlate(BOOTSOURCE_MMC, COLIBRI_MMC_INSTANCE_SD);
+	if (sd_alias >= 0)
+		imx6_bbu_internal_mmc_register_handler("sd",
+						       basprintf("/dev/mmc%u", sd_alias),
+						       0);
 
 	barebox_set_hostname("colibri-imx6");
 
-- 
2.39.5




             reply	other threads:[~2025-01-27 11:03 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-27 11:02 Ahmad Fatoum [this message]
2025-01-27 15:24 ` Jonas Rebmann
2025-01-28 10:08 ` 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=20250127110252.735402-1-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=jre@pengutronix.de \
    /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