mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] ARM: boards: colibri-imx6: make BBU setting independent of DT alias
@ 2025-01-27 11:02 Ahmad Fatoum
  2025-01-27 15:24 ` Jonas Rebmann
  2025-01-28 10:08 ` Sascha Hauer
  0 siblings, 2 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2025-01-27 11:02 UTC (permalink / raw)
  To: barebox; +Cc: Jonas Rebmann, Ahmad Fatoum

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




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

* Re: [PATCH] ARM: boards: colibri-imx6: make BBU setting independent of DT alias
  2025-01-27 11:02 [PATCH] ARM: boards: colibri-imx6: make BBU setting independent of DT alias Ahmad Fatoum
@ 2025-01-27 15:24 ` Jonas Rebmann
  2025-01-28 10:08 ` Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Jonas Rebmann @ 2025-01-27 15:24 UTC (permalink / raw)
  To: Ahmad Fatoum, barebox

Hi Ahmad,

On 1/27/25 12:02 PM, Ahmad Fatoum wrote:
> 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>

Reviewed-by: Jonas Rebmann <jre@pengutronix.de>

> ---
> Jonas, can you give this a test and see if it works for you?

Works as it should, thank 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");
>   




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

* Re: [PATCH] ARM: boards: colibri-imx6: make BBU setting independent of DT alias
  2025-01-27 11:02 [PATCH] ARM: boards: colibri-imx6: make BBU setting independent of DT alias Ahmad Fatoum
  2025-01-27 15:24 ` Jonas Rebmann
@ 2025-01-28 10:08 ` Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2025-01-28 10:08 UTC (permalink / raw)
  To: barebox, Ahmad Fatoum; +Cc: Jonas Rebmann


On Mon, 27 Jan 2025 12:02:52 +0100, Ahmad Fatoum wrote:
> 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.
> 
> [...]

Applied, thanks!

[1/1] ARM: boards: colibri-imx6: make BBU setting independent of DT alias
      https://git.pengutronix.de/cgit/barebox/commit/?id=9b5c984e0fb2 (link may not be stable)

Best regards,
-- 
Sascha Hauer <s.hauer@pengutronix.de>




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

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

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-27 11:02 [PATCH] ARM: boards: colibri-imx6: make BBU setting independent of DT alias Ahmad Fatoum
2025-01-27 15:24 ` Jonas Rebmann
2025-01-28 10:08 ` Sascha Hauer

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