[PATCH v2] atmel_sdhci: Force card-detect if MMC_CAP_NONREMOVABLE.

Eugen Hristev eugen.hristev at collabora.com
Wed May 17 15:29:11 CEST 2023


Hi Zixun,

On 5/15/23 15:07, Zixun LI wrote:
> Signed-off-by:  Zixun LI <zli at ogga.fr>

Can you provide a small explanation about what is the commit doing and why ?
It will be recorded in the commit message for future reference.


Can you also fix this warning:


WARNING: Use a single space after Signed-off-by:
#124:
Signed-off-by:  Zixun LI <zli at ogga.fr>


> ---
>   drivers/mmc/atmel_sdhci.c | 40 +++++++++++++++++++++++++++++++++++++--
>   1 file changed, 38 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mmc/atmel_sdhci.c b/drivers/mmc/atmel_sdhci.c
> index 37b0beeed4..ae56266f57 100644
> --- a/drivers/mmc/atmel_sdhci.c
> +++ b/drivers/mmc/atmel_sdhci.c
> @@ -15,6 +15,9 @@
>   #define ATMEL_SDHC_MIN_FREQ	400000
>   #define ATMEL_SDHC_GCK_RATE	240000000
>   
> +#define ATMEL_SDHC_MC1R 0x204
> +#define ATMEL_SDHC_MC1R_FCD	0x80
> +
>   #ifndef CONFIG_DM_MMC
>   int atmel_sdhci_init(void *regbase, u32 id)
>   {
> @@ -52,11 +55,38 @@ struct atmel_sdhci_plat {
>   	struct mmc mmc;
>   };
>   
> +static void atmel_sdhci_config_fcd(struct sdhci_host *host)
> +{
> +	u8 mc1r;
> +
> +	/* If nonremovable, assume that the card is always present.
> +	 *
> +	 * WA: SAMA5D2 doesn't drive CMD if using CD GPIO line.
> +	 */
> +	if ((host->mmc->cfg->host_caps & MMC_CAP_NONREMOVABLE)
> +#if CONFIG_IS_ENABLED(DM_GPIO)

Can
(CONFIG_IS_ENABLED(DM_REGULATOR)) be used here directly (without the #if 
... #else ) ?

Have you tried it ?

I am not sure whether it works or not, but if it does, it will remove 
the preprocessor directives and it will be more readable

> +		|| dm_gpio_get_value(&host->cd_gpio) >= 0
> +#endif
> +	   )
> +	{

ERROR: that open brace { should be on the previous line

Fix this as well please


> +		sdhci_readb(host, ATMEL_SDHC_MC1R);
> +		mc1r |= ATMEL_SDHC_MC1R_FCD;
> +		sdhci_writeb(host, mc1r, ATMEL_SDHC_MC1R);
> +	}
> +}
> +
>   static int atmel_sdhci_deferred_probe(struct sdhci_host *host)
>   {
>   	struct udevice *dev = host->mmc->dev;
> +	int ret;
>   
> -	return sdhci_probe(dev);
> +	ret = sdhci_probe(dev);
> +	if (ret)
> +		return ret;
> +
> +	atmel_sdhci_config_fcd(host);
> +
> +	return 0;
>   }
>   
>   static const struct sdhci_ops atmel_sdhci_ops = {
> @@ -120,7 +150,13 @@ static int atmel_sdhci_probe(struct udevice *dev)
>   
>   	clk_free(&clk);
>   
> -	return sdhci_probe(dev);
> +	ret = sdhci_probe(dev);
> +	if (ret)
> +		return ret;
> +
> +	atmel_sdhci_config_fcd(host);
> +
> +	return 0;
>   }
>   
>   static int atmel_sdhci_bind(struct udevice *dev)


The patch looks good, however, any changes in the at91 tree at the 
moment are difficult to do because some of the boards get an overflow on 
the SPL memory size. So your patch has to go after that is fixed 
(pending...)

Eugen


More information about the U-Boot mailing list