linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mmc: sdhci-sprd: Disable CLK_AUTO when the clock is less than 400K
@ 2022-12-07  5:19 Wenchao Chen
  2022-12-09  9:33 ` Ulf Hansson
  0 siblings, 1 reply; 2+ messages in thread
From: Wenchao Chen @ 2022-12-07  5:19 UTC (permalink / raw)
  To: adrian.hunter, ulf.hansson, orsonzhai, baolin.wang, zhang.lyra
  Cc: linux-mmc, linux-kernel, zhenxiong.lai, yuelin.tang

When the clock is less than 400K, some SD cards fail to initialize
because CLK_AUTO is enabled.

Fixes: fb8bd90f83c4 ("mmc: sdhci-sprd: Add Spreadtrum's initial host controller")
Signed-off-by: Wenchao Chen <wenchao.chen@unisoc.com>
---
 drivers/mmc/host/sdhci-sprd.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/mmc/host/sdhci-sprd.c b/drivers/mmc/host/sdhci-sprd.c
index bec3f9e3cd3f..525f979e2a97 100644
--- a/drivers/mmc/host/sdhci-sprd.c
+++ b/drivers/mmc/host/sdhci-sprd.c
@@ -228,13 +228,15 @@ static inline void _sdhci_sprd_set_clock(struct sdhci_host *host,
 	div = ((div & 0x300) >> 2) | ((div & 0xFF) << 8);
 	sdhci_enable_clk(host, div);
 
-	/* enable auto gate sdhc_enable_auto_gate */
-	val = sdhci_readl(host, SDHCI_SPRD_REG_32_BUSY_POSI);
-	mask = SDHCI_SPRD_BIT_OUTR_CLK_AUTO_EN |
-	       SDHCI_SPRD_BIT_INNR_CLK_AUTO_EN;
-	if (mask != (val & mask)) {
-		val |= mask;
-		sdhci_writel(host, val, SDHCI_SPRD_REG_32_BUSY_POSI);
+	/* Enable CLK_AUTO when the clock is greater than 400K. */
+	if (clk > 400000) {
+		val = sdhci_readl(host, SDHCI_SPRD_REG_32_BUSY_POSI);
+		mask = SDHCI_SPRD_BIT_OUTR_CLK_AUTO_EN |
+			SDHCI_SPRD_BIT_INNR_CLK_AUTO_EN;
+		if (mask != (val & mask)) {
+			val |= mask;
+			sdhci_writel(host, val, SDHCI_SPRD_REG_32_BUSY_POSI);
+		}
 	}
 }
 
-- 
2.17.1


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

* Re: [PATCH] mmc: sdhci-sprd: Disable CLK_AUTO when the clock is less than 400K
  2022-12-07  5:19 [PATCH] mmc: sdhci-sprd: Disable CLK_AUTO when the clock is less than 400K Wenchao Chen
@ 2022-12-09  9:33 ` Ulf Hansson
  0 siblings, 0 replies; 2+ messages in thread
From: Ulf Hansson @ 2022-12-09  9:33 UTC (permalink / raw)
  To: Wenchao Chen
  Cc: adrian.hunter, orsonzhai, baolin.wang, zhang.lyra, linux-mmc,
	linux-kernel, zhenxiong.lai, yuelin.tang

On Wed, 7 Dec 2022 at 06:20, Wenchao Chen <wenchao.chen@unisoc.com> wrote:
>
> When the clock is less than 400K, some SD cards fail to initialize
> because CLK_AUTO is enabled.
>
> Fixes: fb8bd90f83c4 ("mmc: sdhci-sprd: Add Spreadtrum's initial host controller")
> Signed-off-by: Wenchao Chen <wenchao.chen@unisoc.com>

Applied for next, and by adding a stable tag, thanks!

Kind regards
Uffe

> ---
>  drivers/mmc/host/sdhci-sprd.c | 16 +++++++++-------
>  1 file changed, 9 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/mmc/host/sdhci-sprd.c b/drivers/mmc/host/sdhci-sprd.c
> index bec3f9e3cd3f..525f979e2a97 100644
> --- a/drivers/mmc/host/sdhci-sprd.c
> +++ b/drivers/mmc/host/sdhci-sprd.c
> @@ -228,13 +228,15 @@ static inline void _sdhci_sprd_set_clock(struct sdhci_host *host,
>         div = ((div & 0x300) >> 2) | ((div & 0xFF) << 8);
>         sdhci_enable_clk(host, div);
>
> -       /* enable auto gate sdhc_enable_auto_gate */
> -       val = sdhci_readl(host, SDHCI_SPRD_REG_32_BUSY_POSI);
> -       mask = SDHCI_SPRD_BIT_OUTR_CLK_AUTO_EN |
> -              SDHCI_SPRD_BIT_INNR_CLK_AUTO_EN;
> -       if (mask != (val & mask)) {
> -               val |= mask;
> -               sdhci_writel(host, val, SDHCI_SPRD_REG_32_BUSY_POSI);
> +       /* Enable CLK_AUTO when the clock is greater than 400K. */
> +       if (clk > 400000) {
> +               val = sdhci_readl(host, SDHCI_SPRD_REG_32_BUSY_POSI);
> +               mask = SDHCI_SPRD_BIT_OUTR_CLK_AUTO_EN |
> +                       SDHCI_SPRD_BIT_INNR_CLK_AUTO_EN;
> +               if (mask != (val & mask)) {
> +                       val |= mask;
> +                       sdhci_writel(host, val, SDHCI_SPRD_REG_32_BUSY_POSI);
> +               }
>         }
>  }
>
> --
> 2.17.1
>

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

end of thread, other threads:[~2022-12-09  9:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-07  5:19 [PATCH] mmc: sdhci-sprd: Disable CLK_AUTO when the clock is less than 400K Wenchao Chen
2022-12-09  9:33 ` Ulf Hansson

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).