linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mmc: sdhci-of-at91: fix cd-gpios for SAMA5D2
@ 2020-03-15 16:44 Michał Mirosław
  2020-03-17  9:57 ` Adrian Hunter
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Michał Mirosław @ 2020-03-15 16:44 UTC (permalink / raw)
  To: Ludovic Desroches, Ulf Hansson, Adrian Hunter, Nicolas Ferre,
	Alexandre Belloni
  Cc: linux-mmc, linux-kernel

SAMA5D2x doesn't drive CMD line if GPIO is used as CD line (at least
SAMA5D27 doesn't). Fix this by forcing card-detect in the module
if module-controlled CD is not used.

Fixed commit addresses the problem only for non-removable cards. This
amends it to also cover gpio-cd case.

Cc: stable@vger.kernel.org
Fixes: 7a1e3f143176 ("mmc: sdhci-of-at91: force card detect value for non removable devices")
Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
 drivers/mmc/host/sdhci-of-at91.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/host/sdhci-of-at91.c b/drivers/mmc/host/sdhci-of-at91.c
index d90f4ed18283..8f8da2fe48a9 100644
--- a/drivers/mmc/host/sdhci-of-at91.c
+++ b/drivers/mmc/host/sdhci-of-at91.c
@@ -185,7 +185,8 @@ static void sdhci_at91_reset(struct sdhci_host *host, u8 mask)
 
 	sdhci_reset(host, mask);
 
-	if (host->mmc->caps & MMC_CAP_NONREMOVABLE)
+	if ((host->mmc->caps & MMC_CAP_NONREMOVABLE)
+	    || mmc_gpio_get_cd(host->mmc) >= 0)
 		sdhci_at91_set_force_card_detect(host);
 
 	if (priv->cal_always_on && (mask & SDHCI_RESET_ALL))
@@ -487,8 +488,11 @@ static int sdhci_at91_probe(struct platform_device *pdev)
 	 * detection procedure using the SDMCC_CD signal is bypassed.
 	 * This bit is reset when a software reset for all command is performed
 	 * so we need to implement our own reset function to set back this bit.
+	 *
+	 * WA: SAMA5D2 doesn't drive CMD if using CD GPIO line.
 	 */
-	if (host->mmc->caps & MMC_CAP_NONREMOVABLE)
+	if ((host->mmc->caps & MMC_CAP_NONREMOVABLE)
+	    || mmc_gpio_get_cd(host->mmc) >= 0)
 		sdhci_at91_set_force_card_detect(host);
 
 	pm_runtime_put_autosuspend(&pdev->dev);
-- 
2.20.1


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

* Re: [PATCH] mmc: sdhci-of-at91: fix cd-gpios for SAMA5D2
  2020-03-15 16:44 [PATCH] mmc: sdhci-of-at91: fix cd-gpios for SAMA5D2 Michał Mirosław
@ 2020-03-17  9:57 ` Adrian Hunter
  2020-03-17 11:58 ` Ulf Hansson
  2020-03-23 20:23 ` Ludovic.Desroches
  2 siblings, 0 replies; 4+ messages in thread
From: Adrian Hunter @ 2020-03-17  9:57 UTC (permalink / raw)
  To: Michał Mirosław, Ludovic Desroches, Ulf Hansson,
	Nicolas Ferre, Alexandre Belloni
  Cc: linux-mmc, linux-kernel

On 15/03/20 6:44 pm, Michał Mirosław wrote:
> SAMA5D2x doesn't drive CMD line if GPIO is used as CD line (at least
> SAMA5D27 doesn't). Fix this by forcing card-detect in the module
> if module-controlled CD is not used.
> 
> Fixed commit addresses the problem only for non-removable cards. This
> amends it to also cover gpio-cd case.
> 
> Cc: stable@vger.kernel.org
> Fixes: 7a1e3f143176 ("mmc: sdhci-of-at91: force card detect value for non removable devices")
> Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>

Acked-by: Adrian Hunter <adrian.hunter@intel.com>

> ---
>  drivers/mmc/host/sdhci-of-at91.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mmc/host/sdhci-of-at91.c b/drivers/mmc/host/sdhci-of-at91.c
> index d90f4ed18283..8f8da2fe48a9 100644
> --- a/drivers/mmc/host/sdhci-of-at91.c
> +++ b/drivers/mmc/host/sdhci-of-at91.c
> @@ -185,7 +185,8 @@ static void sdhci_at91_reset(struct sdhci_host *host, u8 mask)
>  
>  	sdhci_reset(host, mask);
>  
> -	if (host->mmc->caps & MMC_CAP_NONREMOVABLE)
> +	if ((host->mmc->caps & MMC_CAP_NONREMOVABLE)
> +	    || mmc_gpio_get_cd(host->mmc) >= 0)
>  		sdhci_at91_set_force_card_detect(host);
>  
>  	if (priv->cal_always_on && (mask & SDHCI_RESET_ALL))
> @@ -487,8 +488,11 @@ static int sdhci_at91_probe(struct platform_device *pdev)
>  	 * detection procedure using the SDMCC_CD signal is bypassed.
>  	 * This bit is reset when a software reset for all command is performed
>  	 * so we need to implement our own reset function to set back this bit.
> +	 *
> +	 * WA: SAMA5D2 doesn't drive CMD if using CD GPIO line.
>  	 */
> -	if (host->mmc->caps & MMC_CAP_NONREMOVABLE)
> +	if ((host->mmc->caps & MMC_CAP_NONREMOVABLE)
> +	    || mmc_gpio_get_cd(host->mmc) >= 0)
>  		sdhci_at91_set_force_card_detect(host);
>  
>  	pm_runtime_put_autosuspend(&pdev->dev);
> 


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

* Re: [PATCH] mmc: sdhci-of-at91: fix cd-gpios for SAMA5D2
  2020-03-15 16:44 [PATCH] mmc: sdhci-of-at91: fix cd-gpios for SAMA5D2 Michał Mirosław
  2020-03-17  9:57 ` Adrian Hunter
@ 2020-03-17 11:58 ` Ulf Hansson
  2020-03-23 20:23 ` Ludovic.Desroches
  2 siblings, 0 replies; 4+ messages in thread
From: Ulf Hansson @ 2020-03-17 11:58 UTC (permalink / raw)
  To: Michał Mirosław
  Cc: Ludovic Desroches, Adrian Hunter, Nicolas Ferre,
	Alexandre Belloni, linux-mmc, Linux Kernel Mailing List

On Sun, 15 Mar 2020 at 17:44, Michał Mirosław <mirq-linux@rere.qmqm.pl> wrote:
>
> SAMA5D2x doesn't drive CMD line if GPIO is used as CD line (at least
> SAMA5D27 doesn't). Fix this by forcing card-detect in the module
> if module-controlled CD is not used.
>
> Fixed commit addresses the problem only for non-removable cards. This
> amends it to also cover gpio-cd case.
>
> Cc: stable@vger.kernel.org
> Fixes: 7a1e3f143176 ("mmc: sdhci-of-at91: force card detect value for non removable devices")
> Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>

Applied for fixes, thanks!

Kind regards
Uffe


> ---
>  drivers/mmc/host/sdhci-of-at91.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/mmc/host/sdhci-of-at91.c b/drivers/mmc/host/sdhci-of-at91.c
> index d90f4ed18283..8f8da2fe48a9 100644
> --- a/drivers/mmc/host/sdhci-of-at91.c
> +++ b/drivers/mmc/host/sdhci-of-at91.c
> @@ -185,7 +185,8 @@ static void sdhci_at91_reset(struct sdhci_host *host, u8 mask)
>
>         sdhci_reset(host, mask);
>
> -       if (host->mmc->caps & MMC_CAP_NONREMOVABLE)
> +       if ((host->mmc->caps & MMC_CAP_NONREMOVABLE)
> +           || mmc_gpio_get_cd(host->mmc) >= 0)
>                 sdhci_at91_set_force_card_detect(host);
>
>         if (priv->cal_always_on && (mask & SDHCI_RESET_ALL))
> @@ -487,8 +488,11 @@ static int sdhci_at91_probe(struct platform_device *pdev)
>          * detection procedure using the SDMCC_CD signal is bypassed.
>          * This bit is reset when a software reset for all command is performed
>          * so we need to implement our own reset function to set back this bit.
> +        *
> +        * WA: SAMA5D2 doesn't drive CMD if using CD GPIO line.
>          */
> -       if (host->mmc->caps & MMC_CAP_NONREMOVABLE)
> +       if ((host->mmc->caps & MMC_CAP_NONREMOVABLE)
> +           || mmc_gpio_get_cd(host->mmc) >= 0)
>                 sdhci_at91_set_force_card_detect(host);
>
>         pm_runtime_put_autosuspend(&pdev->dev);
> --
> 2.20.1
>

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

* Re: [PATCH] mmc: sdhci-of-at91: fix cd-gpios for SAMA5D2
  2020-03-15 16:44 [PATCH] mmc: sdhci-of-at91: fix cd-gpios for SAMA5D2 Michał Mirosław
  2020-03-17  9:57 ` Adrian Hunter
  2020-03-17 11:58 ` Ulf Hansson
@ 2020-03-23 20:23 ` Ludovic.Desroches
  2 siblings, 0 replies; 4+ messages in thread
From: Ludovic.Desroches @ 2020-03-23 20:23 UTC (permalink / raw)
  To: mirq-linux, ulf.hansson, adrian.hunter, Nicolas.Ferre, alexandre.belloni
  Cc: linux-mmc, linux-kernel

Hi,


On 3/15/2020 5:44 PM, Michał Mirosław wrote
> SAMA5D2x doesn't drive CMD line if GPIO is used as CD line (at least
> SAMA5D27 doesn't). Fix this by forcing card-detect in the module
> if module-controlled CD is not used.
>
> Fixed commit addresses the problem only for non-removable cards. This
> amends it to also cover gpio-cd case.
>
> Cc: stable@vger.kernel.org
> Fixes: 7a1e3f143176 ("mmc: sdhci-of-at91: force card detect value for non removable devices")
> Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>

Even if it's too late, I agree with this patch. Thanks, I didn't expect 
someone will use a GPIO CD instead of the

one of the controller so this case was missing.

In fact, the whole SAMA5D2 family is concerned depending on the revision 
of the SoC. From the top of my head,

for rev A, if the pin is muxed to another function than the SDMMC 
controller, the default value is card present.

For rev B and later, the default value is no card present, that's why 
the CMD line is not driven.

Regards

Ludovic


> ---
>   drivers/mmc/host/sdhci-of-at91.c | 8 ++++++--
>   1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/mmc/host/sdhci-of-at91.c b/drivers/mmc/host/sdhci-of-at91.c
> index d90f4ed18283..8f8da2fe48a9 100644
> --- a/drivers/mmc/host/sdhci-of-at91.c
> +++ b/drivers/mmc/host/sdhci-of-at91.c
> @@ -185,7 +185,8 @@ static void sdhci_at91_reset(struct sdhci_host *host, u8 mask)
>
>          sdhci_reset(host, mask);
>
> -       if (host->mmc->caps & MMC_CAP_NONREMOVABLE)
> +       if ((host->mmc->caps & MMC_CAP_NONREMOVABLE)
> +           || mmc_gpio_get_cd(host->mmc) >= 0)
>                  sdhci_at91_set_force_card_detect(host);
>
>          if (priv->cal_always_on && (mask & SDHCI_RESET_ALL))
> @@ -487,8 +488,11 @@ static int sdhci_at91_probe(struct platform_device *pdev)
>           * detection procedure using the SDMCC_CD signal is bypassed.
>           * This bit is reset when a software reset for all command is performed
>           * so we need to implement our own reset function to set back this bit.
> +        *
> +        * WA: SAMA5D2 doesn't drive CMD if using CD GPIO line.
>           */
> -       if (host->mmc->caps & MMC_CAP_NONREMOVABLE)
> +       if ((host->mmc->caps & MMC_CAP_NONREMOVABLE)
> +           || mmc_gpio_get_cd(host->mmc) >= 0)
>                  sdhci_at91_set_force_card_detect(host);
>
>          pm_runtime_put_autosuspend(&pdev->dev);
> --
> 2.20.1
>


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

end of thread, other threads:[~2020-03-23 20:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-15 16:44 [PATCH] mmc: sdhci-of-at91: fix cd-gpios for SAMA5D2 Michał Mirosław
2020-03-17  9:57 ` Adrian Hunter
2020-03-17 11:58 ` Ulf Hansson
2020-03-23 20:23 ` Ludovic.Desroches

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).