[PATCH] ARM: boards: colibri-imx6: make BBU setting independent of DT alias

Jonas Rebmann jre at pengutronix.de
Mon Jan 27 07:24:50 PST 2025


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 at pengutronix.de>
> Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>

Reviewed-by: Jonas Rebmann <jre at 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");
>   




More information about the barebox mailing list