[PATCH v3 3/3] arm: mvebu: clearfog: Detect MMC vs SDHC and fixup fdt

Stefan Roese sr at denx.de
Thu Mar 30 06:58:26 CEST 2023


On 3/27/23 13:24, Martin Rowe wrote:
> [upstream of vendor commit 19a96f7c40a8fc1d0a6546ac2418d966e5840a99]
> 
> The Clearfog devices have only one SDHC device. This is either eMMC if
> it is populated on the SOM or SDHC if not. The Linux device tree assumes
> the SDHC case. Detect if the device is an eMMC and fixup the device-tree
> so it will be detected by Linux.
> 
> Ported from vendor repo at https://github.com/SolidRun/u-boot
> 
> Signed-off-by: Martin Rowe <martin.p.rowe at gmail.com>

Reviewed-by: Stefan Roese <sr at denx.de>

Thanks,
Stefan

> ---
> Resend with correct header
> Fixed spacing and removed __maybe_unused
> 
>   arch/arm/mach-mvebu/Kconfig        |  1 +
>   board/solidrun/clearfog/clearfog.c | 33 ++++++++++++++++++++++++++++++
>   2 files changed, 34 insertions(+)
> 
> diff --git a/arch/arm/mach-mvebu/Kconfig b/arch/arm/mach-mvebu/Kconfig
> index 1f0dbef1c6..b1f2e97ae7 100644
> --- a/arch/arm/mach-mvebu/Kconfig
> +++ b/arch/arm/mach-mvebu/Kconfig
> @@ -107,6 +107,7 @@ config TARGET_CLEARFOG
>   	bool "Support ClearFog"
>   	select 88F6820
>   	select BOARD_LATE_INIT
> +	select OF_BOARD_SETUP
>   
>   config TARGET_HELIOS4
>   	bool "Support Helios4"
> diff --git a/board/solidrun/clearfog/clearfog.c b/board/solidrun/clearfog/clearfog.c
> index 03adb591d8..6edb422155 100644
> --- a/board/solidrun/clearfog/clearfog.c
> +++ b/board/solidrun/clearfog/clearfog.c
> @@ -10,6 +10,7 @@
>   #include <miiphy.h>
>   #include <net.h>
>   #include <netdev.h>
> +#include <mmc.h>
>   #include <asm/global_data.h>
>   #include <asm/io.h>
>   #include <asm/arch/cpu.h>
> @@ -261,3 +262,35 @@ int board_late_init(void)
>   
>   	return 0;
>   }
> +
> +static bool has_emmc(void)
> +{
> +	struct mmc *mmc;
> +
> +	mmc = find_mmc_device(0);
> +	if (!mmc)
> +		return 0;
> +	return (!mmc_init(mmc) && IS_MMC(mmc)) ? true : false;
> +}
> +
> +/*
> + * The Clearfog devices have only one SDHC device. This is either eMMC
> + * if it is populated on the SOM or SDHC if not. The Linux device tree
> + * assumes the SDHC case. Detect if the device is an eMMC and fixup the
> + * device-tree, so that it will be detected by Linux.
> + */
> +int ft_board_setup(void *blob, struct bd_info *bd)
> +{
> +	int node;
> +
> +	if (has_emmc()) {
> +		node = fdt_node_offset_by_compatible(blob, -1, "marvell,armada-380-sdhci");
> +		if (node < 0)
> +			return 0; /* Unexpected eMMC device; patching not supported */
> +
> +		puts("Patching FDT so that eMMC is detected by OS\n");
> +		return fdt_setprop_empty(blob, node, "non-removable");
> +	}
> +
> +	return 0;
> +}

Viele Grüße,
Stefan Roese

-- 
DENX Software Engineering GmbH,      Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr at denx.de


More information about the U-Boot mailing list