Skip to contentSkip to conversation

mmc: sdhci-of-esdhc: make sure delay chain locked for HS400

PATCH In review Yangbo Lu 3 participants 6 messages Oct 20, 2020 – Oct 29, 2020

Subsystems (2)
lore
Share & tools
lore

Yangbo Lu

author
#0 lore raw

PATCH v3 1/1 mmc: sdhci-of-esdhc: make sure delay chain locked for HS400

For eMMC HS400 mode initialization, the DLL reset is a required step if DLL is enabled to use previously, like in bootloader. This step has not been documented in reference manual, but the RM will be fixed sooner or later.

This patch is to add the step of DLL reset, and make sure delay chain locked for HS400.

---
Changes for v2:
- Converted to use read_poll_timeout.
Changes for v3:
- Included iopoll.h.

---
 drivers/mmc/host/sdhci-esdhc.h    |  2 ++
 drivers/mmc/host/sdhci-of-esdhc.c | 17 +++++++++++++++++
 2 files changed, 19 insertions(+)
drivers/mmc/host/sdhci-esdhc.h +2 -0
index a30796e..6de02f0 100644
@@ -5,6 +5,7 @@
  * Copyright (c) 2007 Freescale Semiconductor, Inc.
  * Copyright (c) 2009 MontaVista Software, Inc.
  * Copyright (c) 2010 Pengutronix e.K.
+ * Copyright 2020 NXP
  *   Author: Wolfram Sang <[email protected]>
  */
 
@@ -88,6 +89,7 @@
 /* DLL Config 0 Register */
 #define ESDHC_DLLCFG0			0x160
 #define ESDHC_DLL_ENABLE		0x80000000
+#define ESDHC_DLL_RESET			0x40000000
 #define ESDHC_DLL_FREQ_SEL		0x08000000
 
 /* DLL Config 1 Register */
drivers/mmc/host/sdhci-of-esdhc.c +17 -0
index 0b45eff..90e6085 100644
@@ -4,6 +4,7 @@
  *
  * Copyright (c) 2007, 2010, 2012 Freescale Semiconductor, Inc.
  * Copyright (c) 2009 MontaVista Software, Inc.
+ * Copyright 2020 NXP
  *
  * Authors: Xiaobo Xie <[email protected]>
  *	    Anton Vorontsov <[email protected]>
@@ -19,6 +20,7 @@
 #include <linux/clk.h>
 #include <linux/ktime.h>
 #include <linux/dma-mapping.h>
+#include <linux/iopoll.h>
 #include <linux/mmc/host.h>
 #include <linux/mmc/mmc.h>
 #include "sdhci-pltfm.h"
@@ -743,6 +745,21 @@ static void esdhc_of_set_clock(struct sdhci_host *host, unsigned int clock)
 		if (host->mmc->actual_clock == MMC_HS200_MAX_DTR)
 			temp |= ESDHC_DLL_FREQ_SEL;
 		sdhci_writel(host, temp, ESDHC_DLLCFG0);
+
+		temp |= ESDHC_DLL_RESET;
+		sdhci_writel(host, temp, ESDHC_DLLCFG0);
+		udelay(1);
+		temp &= ~ESDHC_DLL_RESET;
+		sdhci_writel(host, temp, ESDHC_DLLCFG0);
+
+		/* Wait max 20 ms */
+		if (read_poll_timeout(sdhci_readl, temp,
+				      temp & ESDHC_DLL_STS_SLV_LOCK,
+				      10, 20000, false,
+				      host, ESDHC_DLLSTAT0))
+			pr_err("%s: timeout for delay chain lock.\n",
+			       mmc_hostname(host->mmc));
+
 		temp = sdhci_readl(host, ESDHC_TBCTL);
 		sdhci_writel(host, temp | ESDHC_HS400_WNDW_ADJUST, ESDHC_TBCTL);
 
Signature · 1 line
2.7.4
maintainer Acked-by on v3 1/1
#1 lore raw
Quoted 9 lines · Yangbo Lu

For eMMC HS400 mode initialization, the DLL reset is a required step if DLL is enabled to use previously, like in bootloader. This step has not been documented in reference manual, but the RM will be fixed sooner or later.

This patch is to add the step of DLL reset, and make sure delay chain locked for HS400.

Quoted 73 lines

---
Changes for v2:
- Converted to use read_poll_timeout.
Changes for v3:
- Included iopoll.h.

---
 drivers/mmc/host/sdhci-esdhc.h    |  2 ++
 drivers/mmc/host/sdhci-of-esdhc.c | 17 +++++++++++++++++
 2 files changed, 19 insertions(+)
drivers/mmc/host/sdhci-esdhc.h +2 -0
index a30796e..6de02f0 100644
@@ -5,6 +5,7 @@
  * Copyright (c) 2007 Freescale Semiconductor, Inc.
  * Copyright (c) 2009 MontaVista Software, Inc.
  * Copyright (c) 2010 Pengutronix e.K.
+ * Copyright 2020 NXP
  *   Author: Wolfram Sang <[email protected]>
  */
 
@@ -88,6 +89,7 @@
 /* DLL Config 0 Register */
 #define ESDHC_DLLCFG0			0x160
 #define ESDHC_DLL_ENABLE		0x80000000
+#define ESDHC_DLL_RESET			0x40000000
 #define ESDHC_DLL_FREQ_SEL		0x08000000
 
 /* DLL Config 1 Register */
drivers/mmc/host/sdhci-of-esdhc.c +17 -0
index 0b45eff..90e6085 100644
@@ -4,6 +4,7 @@
  *
  * Copyright (c) 2007, 2010, 2012 Freescale Semiconductor, Inc.
  * Copyright (c) 2009 MontaVista Software, Inc.
+ * Copyright 2020 NXP
  *
  * Authors: Xiaobo Xie <[email protected]>
  *	    Anton Vorontsov <[email protected]>
@@ -19,6 +20,7 @@
 #include <linux/clk.h>
 #include <linux/ktime.h>
 #include <linux/dma-mapping.h>
+#include <linux/iopoll.h>
 #include <linux/mmc/host.h>
 #include <linux/mmc/mmc.h>
 #include "sdhci-pltfm.h"
@@ -743,6 +745,21 @@ static void esdhc_of_set_clock(struct sdhci_host *host, unsigned int clock)
 		if (host->mmc->actual_clock == MMC_HS200_MAX_DTR)
 			temp |= ESDHC_DLL_FREQ_SEL;
 		sdhci_writel(host, temp, ESDHC_DLLCFG0);
+
+		temp |= ESDHC_DLL_RESET;
+		sdhci_writel(host, temp, ESDHC_DLLCFG0);
+		udelay(1);
+		temp &= ~ESDHC_DLL_RESET;
+		sdhci_writel(host, temp, ESDHC_DLLCFG0);
+
+		/* Wait max 20 ms */
+		if (read_poll_timeout(sdhci_readl, temp,
+				      temp & ESDHC_DLL_STS_SLV_LOCK,
+				      10, 20000, false,
+				      host, ESDHC_DLLSTAT0))
+			pr_err("%s: timeout for delay chain lock.\n",
+			       mmc_hostname(host->mmc));
+
 		temp = sdhci_readl(host, ESDHC_TBCTL);
 		sdhci_writel(host, temp | ESDHC_HS400_WNDW_ADJUST, ESDHC_TBCTL);
 
#2 lore raw
In reply to Yangbo Lu
Quoted 10 lines · Yangbo Lu

For eMMC HS400 mode initialization, the DLL reset is a required step if DLL is enabled to use previously, like in bootloader. This step has not been documented in reference manual, but the RM will be fixed sooner or later.

This patch is to add the step of DLL reset, and make sure delay chain locked for HS400.

Applied for next (please tell if you think this deserves to be tagged for stable), thanks!

Kind regards
Uffe

Quoted 75 lines

---
Changes for v2:
- Converted to use read_poll_timeout.
Changes for v3:
- Included iopoll.h.

---
 drivers/mmc/host/sdhci-esdhc.h    |  2 ++
 drivers/mmc/host/sdhci-of-esdhc.c | 17 +++++++++++++++++
 2 files changed, 19 insertions(+)
drivers/mmc/host/sdhci-esdhc.h +2 -0
index a30796e..6de02f0 100644
@@ -5,6 +5,7 @@
  * Copyright (c) 2007 Freescale Semiconductor, Inc.
  * Copyright (c) 2009 MontaVista Software, Inc.
  * Copyright (c) 2010 Pengutronix e.K.
+ * Copyright 2020 NXP
  *   Author: Wolfram Sang <[email protected]>
  */
 
@@ -88,6 +89,7 @@
 /* DLL Config 0 Register */
 #define ESDHC_DLLCFG0                  0x160
 #define ESDHC_DLL_ENABLE               0x80000000
+#define ESDHC_DLL_RESET                        0x40000000
 #define ESDHC_DLL_FREQ_SEL             0x08000000
 
 /* DLL Config 1 Register */
drivers/mmc/host/sdhci-of-esdhc.c +17 -1
index 0b45eff..90e6085 100644
@@ -4,6 +4,7 @@
  *
  * Copyright (c) 2007, 2010, 2012 Freescale Semiconductor, Inc.
  * Copyright (c) 2009 MontaVista Software, Inc.
+ * Copyright 2020 NXP
  *
  * Authors: Xiaobo Xie <[email protected]>
  *         Anton Vorontsov <[email protected]>
@@ -19,6 +20,7 @@
 #include <linux/clk.h>
 #include <linux/ktime.h>
 #include <linux/dma-mapping.h>
+#include <linux/iopoll.h>
 #include <linux/mmc/host.h>
 #include <linux/mmc/mmc.h>
 #include "sdhci-pltfm.h"
@@ -743,6 +745,21 @@ static void esdhc_of_set_clock(struct sdhci_host *host, unsigned int clock)
                if (host->mmc->actual_clock == MMC_HS200_MAX_DTR)
                        temp |= ESDHC_DLL_FREQ_SEL;
                sdhci_writel(host, temp, ESDHC_DLLCFG0);
+
+               temp |= ESDHC_DLL_RESET;
+               sdhci_writel(host, temp, ESDHC_DLLCFG0);
+               udelay(1);
+               temp &= ~ESDHC_DLL_RESET;
+               sdhci_writel(host, temp, ESDHC_DLLCFG0);
+
+               /* Wait max 20 ms */
+               if (read_poll_timeout(sdhci_readl, temp,
+                                     temp & ESDHC_DLL_STS_SLV_LOCK,
+                                     10, 20000, false,
+                                     host, ESDHC_DLLSTAT0))
+                       pr_err("%s: timeout for delay chain lock.\n",
+                              mmc_hostname(host->mmc));
+
                temp = sdhci_readl(host, ESDHC_TBCTL);
                sdhci_writel(host, temp | ESDHC_HS400_WNDW_ADJUST, ESDHC_TBCTL);
 
--

2.7.4

author
#3 lore raw

Hi Uffe,

Quoted 14 lines

-----Original Message-----
From: Ulf Hansson <[email protected]>
Sent: Tuesday, October 27, 2020 9:42 PM
To: Y.b. Lu <[email protected]>
Cc: [email protected]; Adrian Hunter <[email protected]>
Subject: Re: [v3] mmc: sdhci-of-esdhc: make sure delay chain locked for HS400

Quoted 6 lines · Yangbo Lu

For eMMC HS400 mode initialization, the DLL reset is a required step if DLL is enabled to use previously, like in bootloader. This step has not been documented in reference manual, but the RM will be fixed sooner or later.

Quoted 7 lines
Quoted 4 lines

This patch is to add the step of DLL reset, and make sure delay chain locked for HS400.

Applied for next (please tell if you think this deserves to be tagged for stable), thanks!

Thanks!
Please help to tag for stable. The latest u-boot just supporting eSDHC HS400, may cause kernel HS400 issue without this patch.

Quoted 86 lines

Kind regards
Uffe

Review

Quoted 11 lines

---
Changes for v2:
- Converted to use read_poll_timeout.
Changes for v3:
- Included iopoll.h.

---
 drivers/mmc/host/sdhci-esdhc.h    |  2 ++
 drivers/mmc/host/sdhci-of-esdhc.c | 17 +++++++++++++++++
 2 files changed, 19 insertions(+)
(quoted diff) +0 -0

b/drivers/mmc/host/sdhci-esdhc.h

Review

Quoted 20 lines

index a30796e..6de02f0 100644

drivers/mmc/host/sdhci-esdhc.h +2 -0
@@ -5,6 +5,7 @@
  * Copyright (c) 2007 Freescale Semiconductor, Inc.
  * Copyright (c) 2009 MontaVista Software, Inc.
  * Copyright (c) 2010 Pengutronix e.K.
+ * Copyright 2020 NXP
  *   Author: Wolfram Sang <[email protected]>
  */
 
@@ -88,6 +89,7 @@
 /* DLL Config 0 Register */
 #define ESDHC_DLLCFG0                  0x160
 #define ESDHC_DLL_ENABLE               0x80000000
+#define ESDHC_DLL_RESET                        0x40000000
 #define ESDHC_DLL_FREQ_SEL             0x08000000
 
 /* DLL Config 1 Register */
(quoted diff) +0 -0

b/drivers/mmc/host/sdhci-of-esdhc.c

drivers/mmc/host/sdhci-of-esdhc.c static void esdhc_of_set_clock(struct sdhci_host

Quoted 20 lines

index 0b45eff..90e6085 100644

drivers/mmc/host/sdhci-of-esdhc.c +2 -0
@@ -4,6 +4,7 @@
  *
  * Copyright (c) 2007, 2010, 2012 Freescale Semiconductor, Inc.
  * Copyright (c) 2009 MontaVista Software, Inc.
+ * Copyright 2020 NXP
  *
  * Authors: Xiaobo Xie <[email protected]>
  *         Anton Vorontsov <[email protected]>
@@ -19,6 +20,7 @@
 #include <linux/clk.h>
 #include <linux/ktime.h>
 #include <linux/dma-mapping.h>
+#include <linux/iopoll.h>
 #include <linux/mmc/host.h>
 #include <linux/mmc/mmc.h>
 #include "sdhci-pltfm.h"
@@ -743,6 +745,21 @@ static void esdhc_of_set_clock(struct sdhci_host

*host, unsigned int clock)

drivers/mmc/host/sdhci-of-esdhc.c static void esdhc_of_set_clock(struct sdhci_host *host, unsigned int clock)

Quoted 13 lines
drivers/mmc/host/sdhci-of-esdhc.c +10 -0
                if (host->mmc->actual_clock == MMC_HS200_MAX_DTR)
                        temp |= ESDHC_DLL_FREQ_SEL;
                sdhci_writel(host, temp, ESDHC_DLLCFG0);
+
+               temp |= ESDHC_DLL_RESET;
+               sdhci_writel(host, temp, ESDHC_DLLCFG0);
+               udelay(1);
+               temp &= ~ESDHC_DLL_RESET;
+               sdhci_writel(host, temp, ESDHC_DLLCFG0);
+
+               /* Wait max 20 ms */
+               if (read_poll_timeout(sdhci_readl, temp,
+                                     temp &

ESDHC_DLL_STS_SLV_LOCK,

drivers/mmc/host/sdhci-of-esdhc.c static void esdhc_of_set_clock(struct sdhci_host *host, unsigned int clock)

Quoted 7 lines
drivers/mmc/host/sdhci-of-esdhc.c +5 -0
+                                     10, 20000, false,
+                                     host, ESDHC_DLLSTAT0))
+                       pr_err("%s: timeout for delay chain lock.\n",
+                              mmc_hostname(host->mmc));
+
                temp = sdhci_readl(host, ESDHC_TBCTL);
                sdhci_writel(host, temp |

ESDHC_HS400_WNDW_ADJUST, ESDHC_TBCTL);

Quoted 4 lines
drivers/mmc/host/sdhci-of-esdhc.c +0 -1
--

2.7.4

#4 lore raw
Quoted 20 lines · Y.b. Lu

Hi Uffe,

Quoted 17 lines

-----Original Message-----
From: Ulf Hansson <[email protected]>
Sent: Tuesday, October 27, 2020 9:42 PM
To: Y.b. Lu <[email protected]>
Cc: [email protected]; Adrian Hunter <[email protected]>
Subject: Re: [v3] mmc: sdhci-of-esdhc: make sure delay chain locked for HS400

Quoted 9 lines · Yangbo Lu

For eMMC HS400 mode initialization, the DLL reset is a required step if DLL is enabled to use previously, like in bootloader. This step has not been documented in reference manual, but the RM will be fixed sooner or later.

This patch is to add the step of DLL reset, and make sure delay chain locked for HS400.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Applied for next (please tell if you think this deserves to be tagged for stable), thanks!

Thanks!
Please help to tag for stable. The latest u-boot just supporting eSDHC HS400, may cause kernel HS400 issue without this patch.

I have added a stable and a fixes tag. Additionally I have moved the patch to my fixes branch.

Please have a look in my git to make sure it looks good to you.

[...]

Kind regards
Uffe

author
#5 lore raw
Quoted 34 lines

-----Original Message-----
From: Ulf Hansson <[email protected]>
Sent: Wednesday, October 28, 2020 6:21 PM
To: Y.b. Lu <[email protected]>
Cc: [email protected]; Adrian Hunter <[email protected]>
Subject: Re: [v3] mmc: sdhci-of-esdhc: make sure delay chain locked for HS400

Quoted 9 lines · Y.b. Lu

Hi Uffe,

Quoted 6 lines

-----Original Message-----
From: Ulf Hansson <[email protected]>
Sent: Tuesday, October 27, 2020 9:42 PM
To: Y.b. Lu <[email protected]>
Cc: [email protected]; Adrian Hunter <[email protected]>
Subject: Re: [v3] mmc: sdhci-of-esdhc: make sure delay chain locked for

HS400

Quoted 16 lines
Quoted 15 lines · Yangbo Lu
Quoted 10 lines

For eMMC HS400 mode initialization, the DLL reset is a required step if DLL is enabled to use previously, like in bootloader. This step has not been documented in reference manual, but the RM will be fixed sooner or later.

This patch is to add the step of DLL reset, and make sure delay chain locked for HS400.

Applied for next (please tell if you think this deserves to be tagged for stable), thanks!

Quoted 8 lines
Quoted 2 lines

Thanks!
Please help to tag for stable. The latest u-boot just supporting eSDHC HS400,

may cause kernel HS400 issue without this patch.

I have added a stable and a fixes tag. Additionally I have moved the patch to my fixes branch.

Please have a look in my git to make sure it looks good to you.

Thank you Uffe. It looks fine.

Quoted 5 lines

[...]

Kind regards
Uffe