Skip to contentSkip to conversation

mmc: sdhci-sprd: Wait until DLL locked after being configured

PATCH In review Chunyan Zhang 3 participants 3 messages Sep 26, 2021 – Sep 27, 2021

Subsystems (3)
lore
Share & tools
lore

Chunyan Zhang

author reviewer
#0 lore raw

PATCH v2 1/1 mmc: sdhci-sprd: Wait until DLL locked after being configured

From: Zhenxiong Lai <[email protected]>

According to the specification, DLL status has to be locked before using it.

---
Changes since v1:
* Use read_poll_timeout() instead of while loop.

---
 drivers/mmc/host/sdhci-sprd.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
drivers/mmc/host/sdhci-sprd.c +13 -0
index 11e375579cfb..f33e9349e4e6 100644
@@ -8,6 +8,7 @@
 #include <linux/delay.h>
 #include <linux/dma-mapping.h>
 #include <linux/highmem.h>
+#include <linux/iopoll.h>
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_device.h>
@@ -39,6 +40,9 @@
 #define  SDHCI_SPRD_BIT_POSRD_DLY_INV		BIT(21)
 #define  SDHCI_SPRD_BIT_NEGRD_DLY_INV		BIT(29)
 
+#define SDHCI_SPRD_REG_32_DLL_STS0	0x210
+#define SDHCI_SPRD_DLL_LOCKED		BIT(18)
+
 #define SDHCI_SPRD_REG_32_BUSY_POSI		0x250
 #define  SDHCI_SPRD_BIT_OUTR_CLK_AUTO_EN	BIT(25)
 #define  SDHCI_SPRD_BIT_INNR_CLK_AUTO_EN	BIT(24)
@@ -256,6 +260,15 @@ static void sdhci_sprd_enable_phy_dll(struct sdhci_host *host)
 	sdhci_writel(host, tmp, SDHCI_SPRD_REG_32_DLL_CFG);
 	/* wait 1ms */
 	usleep_range(1000, 1250);
+
+	if (read_poll_timeout(sdhci_readl, tmp, (tmp & SDHCI_SPRD_DLL_LOCKED),
+		2000, USEC_PER_SEC, false, host, SDHCI_SPRD_REG_32_DLL_STS0)) {
+		pr_err("%s: DLL locked fail!\n", mmc_hostname(host->mmc));
+		pr_info("%s: DLL_STS0 : 0x%x, DLL_CFG : 0x%x\n",
+			 mmc_hostname(host->mmc),
+			 sdhci_readl(host, SDHCI_SPRD_REG_32_DLL_STS0),
+			 sdhci_readl(host, SDHCI_SPRD_REG_32_DLL_CFG));
+	}
 }
 
 static void sdhci_sprd_set_clock(struct sdhci_host *host, unsigned int clock)
Signature · 1 line
2.25.1
maintainer Acked-by on v2 1/1
#1 lore raw
Quoted 6 lines · Chunyan Zhang

From: Zhenxiong Lai <[email protected]>

According to the specification, DLL status has to be locked before using it.

Quoted 46 lines

---
Changes since v1:
* Use read_poll_timeout() instead of while loop.

---
 drivers/mmc/host/sdhci-sprd.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
drivers/mmc/host/sdhci-sprd.c +13 -0
index 11e375579cfb..f33e9349e4e6 100644
@@ -8,6 +8,7 @@
 #include <linux/delay.h>
 #include <linux/dma-mapping.h>
 #include <linux/highmem.h>
+#include <linux/iopoll.h>
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_device.h>
@@ -39,6 +40,9 @@
 #define  SDHCI_SPRD_BIT_POSRD_DLY_INV		BIT(21)
 #define  SDHCI_SPRD_BIT_NEGRD_DLY_INV		BIT(29)
 
+#define SDHCI_SPRD_REG_32_DLL_STS0	0x210
+#define SDHCI_SPRD_DLL_LOCKED		BIT(18)
+
 #define SDHCI_SPRD_REG_32_BUSY_POSI		0x250
 #define  SDHCI_SPRD_BIT_OUTR_CLK_AUTO_EN	BIT(25)
 #define  SDHCI_SPRD_BIT_INNR_CLK_AUTO_EN	BIT(24)
@@ -256,6 +260,15 @@ static void sdhci_sprd_enable_phy_dll(struct sdhci_host *host)
 	sdhci_writel(host, tmp, SDHCI_SPRD_REG_32_DLL_CFG);
 	/* wait 1ms */
 	usleep_range(1000, 1250);
+
+	if (read_poll_timeout(sdhci_readl, tmp, (tmp & SDHCI_SPRD_DLL_LOCKED),
+		2000, USEC_PER_SEC, false, host, SDHCI_SPRD_REG_32_DLL_STS0)) {
+		pr_err("%s: DLL locked fail!\n", mmc_hostname(host->mmc));
+		pr_info("%s: DLL_STS0 : 0x%x, DLL_CFG : 0x%x\n",
+			 mmc_hostname(host->mmc),
+			 sdhci_readl(host, SDHCI_SPRD_REG_32_DLL_STS0),
+			 sdhci_readl(host, SDHCI_SPRD_REG_32_DLL_CFG));
+	}
 }
 
 static void sdhci_sprd_set_clock(struct sdhci_host *host, unsigned int clock)
#2 lore raw
In reply to Chunyan Zhang
Quoted 7 lines · Chunyan Zhang

From: Zhenxiong Lai <[email protected]>

According to the specification, DLL status has to be locked before using it.

Applied for next, thanks!

Kind regards
Uffe

Quoted 48 lines

---
Changes since v1:
* Use read_poll_timeout() instead of while loop.

---
 drivers/mmc/host/sdhci-sprd.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
drivers/mmc/host/sdhci-sprd.c +13 -1
index 11e375579cfb..f33e9349e4e6 100644
@@ -8,6 +8,7 @@
 #include <linux/delay.h>
 #include <linux/dma-mapping.h>
 #include <linux/highmem.h>
+#include <linux/iopoll.h>
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_device.h>
@@ -39,6 +40,9 @@
 #define  SDHCI_SPRD_BIT_POSRD_DLY_INV          BIT(21)
 #define  SDHCI_SPRD_BIT_NEGRD_DLY_INV          BIT(29)
 
+#define SDHCI_SPRD_REG_32_DLL_STS0     0x210
+#define SDHCI_SPRD_DLL_LOCKED          BIT(18)
+
 #define SDHCI_SPRD_REG_32_BUSY_POSI            0x250
 #define  SDHCI_SPRD_BIT_OUTR_CLK_AUTO_EN       BIT(25)
 #define  SDHCI_SPRD_BIT_INNR_CLK_AUTO_EN       BIT(24)
@@ -256,6 +260,15 @@ static void sdhci_sprd_enable_phy_dll(struct sdhci_host *host)
        sdhci_writel(host, tmp, SDHCI_SPRD_REG_32_DLL_CFG);
        /* wait 1ms */
        usleep_range(1000, 1250);
+
+       if (read_poll_timeout(sdhci_readl, tmp, (tmp & SDHCI_SPRD_DLL_LOCKED),
+               2000, USEC_PER_SEC, false, host, SDHCI_SPRD_REG_32_DLL_STS0)) {
+               pr_err("%s: DLL locked fail!\n", mmc_hostname(host->mmc));
+               pr_info("%s: DLL_STS0 : 0x%x, DLL_CFG : 0x%x\n",
+                        mmc_hostname(host->mmc),
+                        sdhci_readl(host, SDHCI_SPRD_REG_32_DLL_STS0),
+                        sdhci_readl(host, SDHCI_SPRD_REG_32_DLL_CFG));
+       }
 }
 
 static void sdhci_sprd_set_clock(struct sdhci_host *host, unsigned int clock)
--

2.25.1