diff mbox series

mmc/host: Re-enable card en only after UHS mode changed for spreadtrum chipset.

Message ID 20220307023425.8687-1-lzx.stg@gmail.com
State New
Headers show
Series mmc/host: Re-enable card en only after UHS mode changed for spreadtrum chipset. | expand

Commit Message

Zhenxiong Lai March 7, 2022, 2:34 a.m. UTC
From: Zhenxiong Lai <zhenxiong.lai@unisoc.com>

DLL locked status probably couldn't come out in a certain time on
Sharkl3 platform sometimes.
It can be workaround if re-anable card en bit only
rather than calling ->set_clock() after UHS timing changed.

Signed-off-by: Zhenxiong Lai <zhenxiong.lai@unisoc.com>
---
 drivers/mmc/host/sdhci.c | 7 ++++++-
 drivers/mmc/host/sdhci.h | 2 ++
 2 files changed, 8 insertions(+), 1 deletion(-)

Comments

Adrian Hunter March 7, 2022, 12:49 p.m. UTC | #1
On 07/03/2022 04:34, Zhenxiong Lai wrote:
> From: Zhenxiong Lai <zhenxiong.lai@unisoc.com>
> 
> DLL locked status probably couldn't come out in a certain time on
> Sharkl3 platform sometimes.
> It can be workaround if re-anable card en bit only
> rather than calling ->set_clock() after UHS timing changed.
> 
> Signed-off-by: Zhenxiong Lai <zhenxiong.lai@unisoc.com>
> ---
>  drivers/mmc/host/sdhci.c | 7 ++++++-
>  drivers/mmc/host/sdhci.h | 2 ++

This is an SDHCI patch so it would be better if the subject
begins with "mmc: sdhci: "

>  2 files changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> index 07c6da1f2f0f..c415d00304fe 100644
> --- a/drivers/mmc/host/sdhci.c
> +++ b/drivers/mmc/host/sdhci.c
> @@ -2396,7 +2396,12 @@ void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
>  		}
>  
>  		/* Re-enable SD Clock */
> -		host->ops->set_clock(host, host->clock);
> +		if (host->quirks2 & SDHCI_QUIRK2_RE_ENABLE_CARD_EN) {
> +			clk = sdhci_readw(host, SDHCI_CLOCK_CONTROL);
> +			clk |= SDHCI_CLOCK_CARD_EN;
> +			sdhci_writew(host, clk, SDHCI_CLOCK_CONTROL);

We like to try and avoid quirks whenever possible.
Why can't this be done in the driver's ->set_clock() callback?

> +		} else
> +			host->ops->set_clock(host, host->clock);
>  	} else
>  		sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL);
>  
> diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
> index d7929d725730..3d4ab68f133f 100644
> --- a/drivers/mmc/host/sdhci.h
> +++ b/drivers/mmc/host/sdhci.h
> @@ -477,6 +477,8 @@ struct sdhci_host {
>   * block count.
>   */
>  #define SDHCI_QUIRK2_USE_32BIT_BLK_CNT			(1<<18)
> +/* controller only need to enable card en again after UHS timing was changed */
> +#define SDHCI_QUIRK2_RE_ENABLE_CARD_EN			(1<<19)

A quirk without any users is not useful.  Please also send the driver
change that uses this quirk, although as I wrote above, the ->set_clock()
callback should be used instead.

>  
>  	int irq;		/* Device IRQ */
>  	void __iomem *ioaddr;	/* Mapped address */
diff mbox series

Patch

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 07c6da1f2f0f..c415d00304fe 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -2396,7 +2396,12 @@  void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
 		}
 
 		/* Re-enable SD Clock */
-		host->ops->set_clock(host, host->clock);
+		if (host->quirks2 & SDHCI_QUIRK2_RE_ENABLE_CARD_EN) {
+			clk = sdhci_readw(host, SDHCI_CLOCK_CONTROL);
+			clk |= SDHCI_CLOCK_CARD_EN;
+			sdhci_writew(host, clk, SDHCI_CLOCK_CONTROL);
+		} else
+			host->ops->set_clock(host, host->clock);
 	} else
 		sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL);
 
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
index d7929d725730..3d4ab68f133f 100644
--- a/drivers/mmc/host/sdhci.h
+++ b/drivers/mmc/host/sdhci.h
@@ -477,6 +477,8 @@  struct sdhci_host {
  * block count.
  */
 #define SDHCI_QUIRK2_USE_32BIT_BLK_CNT			(1<<18)
+/* controller only need to enable card en again after UHS timing was changed */
+#define SDHCI_QUIRK2_RE_ENABLE_CARD_EN			(1<<19)
 
 	int irq;		/* Device IRQ */
 	void __iomem *ioaddr;	/* Mapped address */