Skip to contentSkip to conversation

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

PATCH In review Zhenxiong Lai 2 participants 2 messages Mar 7, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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

From: Zhenxiong Lai <[email protected]>

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.

---
 drivers/mmc/host/sdhci.c | 7 ++++++-
 drivers/mmc/host/sdhci.h | 2 ++
 2 files changed, 8 insertions(+), 1 deletion(-)
drivers/mmc/host/sdhci.c +6 -1
index 07c6da1f2f0f..c415d00304fe 100644
@@ -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);
 
drivers/mmc/host/sdhci.h +2 -0
index d7929d725730..3d4ab68f133f 100644
@@ -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 */
Signature · 1 line
2.17.0
maintainer
#1 lore raw
Quoted 11 lines · Zhenxiong Lai

From: Zhenxiong Lai <[email protected]>

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.

---
 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: "

Quoted 7 lines
 2 files changed, 8 insertions(+), 1 deletion(-)
drivers/mmc/host/sdhci.c +0 -0
index 07c6da1f2f0f..c415d00304fe 100644

drivers/mmc/host/sdhci.c void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) · line 2402

Quoted 8 lines
drivers/mmc/host/sdhci.c +4 -1
@@ -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?

Quoted 10 lines
drivers/mmc/host/sdhci.c +2 -0
+		} else
+			host->ops->set_clock(host, host->clock);
 	} else
 		sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL);
 
drivers/mmc/host/sdhci.h +0 -0
index d7929d725730..3d4ab68f133f 100644

drivers/mmc/host/sdhci.h struct sdhci_host { · line 481

Quoted 5 lines
drivers/mmc/host/sdhci.h +2 -0
@@ -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.

Quoted 3 lines
drivers/mmc/host/sdhci.h +0 -0
 	int irq;		/* Device IRQ */
 	void __iomem *ioaddr;	/* Mapped address */