Skip to contentSkip to conversation

mmc: sdhci-esdhc-imx: disable clocks before changing frequency

PATCH Applied Stefan Agner 4 participants 7 messages Jul 12, 2018 – Jul 16, 2018

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

PATCH v2 1/2 mmc: sdhci-esdhc-imx: disable clocks before changing frequency

In the uSDHC case (e.g. i.MX 6) clocks only get disabled if frequency is set to 0. However, it could be that the stack asks for a frequency change while clocks are on. In that case the function clears the divider registers (by clearing ESDHC_CLOCK_MASK) while the clock is enabled! This causes a short period of time where the clock is undivided (on a i.MX 6DL a clock of 196MHz has been measured).

For older IP variants the driver disables clock by clearing some bits in ESDHC_SYSTEM_CONTROL.

Make sure to disable card clock before changing frequency for uSDHC IP variants too.

---
 drivers/mmc/host/sdhci-esdhc-imx.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/mmc/host/sdhci-esdhc-imx.c +6 -6
index 85fd5a8b0b6d..acacd8481473 100644
@@ -708,14 +708,14 @@ static inline void esdhc_pltfm_set_clock(struct sdhci_host *host,
 	int div = 1;
 	u32 temp, val;
 
+	if (esdhc_is_usdhc(imx_data)) {
+		val = readl(host->ioaddr + ESDHC_VENDOR_SPEC);
+		writel(val & ~ESDHC_VENDOR_SPEC_FRC_SDCLK_ON,
+			host->ioaddr + ESDHC_VENDOR_SPEC);
+	}
+
 	if (clock == 0) {
 		host->mmc->actual_clock = 0;
-
-		if (esdhc_is_usdhc(imx_data)) {
-			val = readl(host->ioaddr + ESDHC_VENDOR_SPEC);
-			writel(val & ~ESDHC_VENDOR_SPEC_FRC_SDCLK_ON,
-					host->ioaddr + ESDHC_VENDOR_SPEC);
-		}
 		return;
 	}
 
Signature · 1 line
2.18.0
#1 lore raw

PATCH v2 2/2 mmc: sdhci-esdhc-imx: fix indent

Fix indent. This also makes disable/enable clock blocks look alike.

---
 drivers/mmc/host/sdhci-esdhc-imx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/host/sdhci-esdhc-imx.c +1 -1
index acacd8481473..aa48f4b2541a 100644
@@ -761,7 +761,7 @@ static inline void esdhc_pltfm_set_clock(struct sdhci_host *host,
 	if (esdhc_is_usdhc(imx_data)) {
 		val = readl(host->ioaddr + ESDHC_VENDOR_SPEC);
 		writel(val | ESDHC_VENDOR_SPEC_FRC_SDCLK_ON,
-		host->ioaddr + ESDHC_VENDOR_SPEC);
+			host->ioaddr + ESDHC_VENDOR_SPEC);
 	}
 
 	mdelay(1);
Signature · 1 line
2.18.0
Acked-by on v2 2/2
#2 lore raw

RE: [PATCH v2 2/2] mmc: sdhci-esdhc-imx: fix indent

Quoted 10 lines

-----Original Message-----
From: Stefan Agner [mailto:[email protected]]
Sent: Thursday, July 12, 2018 4:07 PM
To: [email protected]; [email protected]
Cc: Fabio Estevam <[email protected]>; Bough Chen <[email protected]>; A.s. Dong <[email protected]>; linux- [email protected]; [email protected]; Stefan Agner <[email protected]>
Subject: [PATCH v2 2/2] mmc: sdhci-esdhc-imx: fix indent

Quoted 3 lines

Fix indent. This also makes disable/enable clock blocks look alike.

Regards
Dong Aisheng

maintainer Acked-by on v2 2/2
#3 lore raw

Re: [PATCH v2 2/2] mmc: sdhci-esdhc-imx: fix indent

In reply to Stefan Agner
Quoted 4 lines · Stefan Agner

Fix indent. This also makes disable/enable clock blocks look alike.

Quoted 18 lines
---
 drivers/mmc/host/sdhci-esdhc-imx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/host/sdhci-esdhc-imx.c +1 -1
index acacd8481473..aa48f4b2541a 100644
@@ -761,7 +761,7 @@ static inline void esdhc_pltfm_set_clock(struct sdhci_host *host,
 	if (esdhc_is_usdhc(imx_data)) {
 		val = readl(host->ioaddr + ESDHC_VENDOR_SPEC);
 		writel(val | ESDHC_VENDOR_SPEC_FRC_SDCLK_ON,
-		host->ioaddr + ESDHC_VENDOR_SPEC);
+			host->ioaddr + ESDHC_VENDOR_SPEC);
 	}
 
 	mdelay(1);
Applied
#4 lore raw

Re: [PATCH v2 2/2] mmc: sdhci-esdhc-imx: fix indent

In reply to Stefan Agner
Quoted 4 lines · Stefan Agner

Fix indent. This also makes disable/enable clock blocks look alike.

Thanks, applied for next!

Kind regards
Uffe

Quoted 20 lines
---
 drivers/mmc/host/sdhci-esdhc-imx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/host/sdhci-esdhc-imx.c +1 -2
index acacd8481473..aa48f4b2541a 100644
@@ -761,7 +761,7 @@ static inline void esdhc_pltfm_set_clock(struct sdhci_host *host,
        if (esdhc_is_usdhc(imx_data)) {
                val = readl(host->ioaddr + ESDHC_VENDOR_SPEC);
                writel(val | ESDHC_VENDOR_SPEC_FRC_SDCLK_ON,
-               host->ioaddr + ESDHC_VENDOR_SPEC);
+                       host->ioaddr + ESDHC_VENDOR_SPEC);
        }
 
        mdelay(1);
--

2.18.0

Acked-by on v2 1/2
#5 lore raw
In reply to Stefan Agner
Quoted 18 lines

-----Original Message-----
From: Stefan Agner [mailto:[email protected]]
Sent: Thursday, July 12, 2018 4:07 PM
To: [email protected]; [email protected]
Cc: Fabio Estevam <[email protected]>; Bough Chen <[email protected]>; A.s. Dong <[email protected]>; linux- [email protected]; [email protected]; Stefan Agner <[email protected]>
Subject: [PATCH v2 1/2] mmc: sdhci-esdhc-imx: disable clocks before changing frequency

In the uSDHC case (e.g. i.MX 6) clocks only get disabled if frequency is set to 0. However, it could be that the stack asks for a frequency change while clocks are on. In that case the function clears the divider registers (by clearing ESDHC_CLOCK_MASK) while the clock is enabled! This causes a short period of time where the clock is undivided (on a i.MX 6DL a clock of 196MHz has been measured).

Quoted 5 lines

For older IP variants the driver disables clock by clearing some bits in ESDHC_SYSTEM_CONTROL.

Make sure to disable card clock before changing frequency for uSDHC IP variants too.

Looks ok to me.

Regards
Dong Aisheng

Quoted 36 lines
---
 drivers/mmc/host/sdhci-esdhc-imx.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/mmc/host/sdhci- renamed from drivers/mmc/host/sdhci-esdhc-imx.c +0 -0

esdhc-imx.c
index 85fd5a8b0b6d..acacd8481473 100644

drivers/mmc/host/sdhci-esdhc-imx.c +6 -6
@@ -708,14 +708,14 @@ static inline void esdhc_pltfm_set_clock(struct
 sdhci_host *host,
 	int div = 1;
 	u32 temp, val;
 
+	if (esdhc_is_usdhc(imx_data)) {
+		val = readl(host->ioaddr + ESDHC_VENDOR_SPEC);
+		writel(val & ~ESDHC_VENDOR_SPEC_FRC_SDCLK_ON,
+			host->ioaddr + ESDHC_VENDOR_SPEC);
+	}
+
 	if (clock == 0) {
 		host->mmc->actual_clock = 0;
-
-		if (esdhc_is_usdhc(imx_data)) {
-			val = readl(host->ioaddr + ESDHC_VENDOR_SPEC);
-			writel(val & ~ESDHC_VENDOR_SPEC_FRC_SDCLK_ON,
-					host->ioaddr +
 ESDHC_VENDOR_SPEC);
-		}
 		return;

}

--
2.18.0

maintainer Acked-by on v2 1/2
#6 lore raw
In reply to Stefan Agner
Quoted 7 lines · Stefan Agner

In the uSDHC case (e.g. i.MX 6) clocks only get disabled if frequency is set to 0. However, it could be that the stack asks for a frequency change while clocks are on. In that case the function clears the divider registers (by clearing ESDHC_CLOCK_MASK) while the clock is enabled! This causes a short period of time where the clock is undivided (on a i.MX 6DL a clock of 196MHz has been measured).

Quoted 7 lines

For older IP variants the driver disables clock by clearing some bits in ESDHC_SYSTEM_CONTROL.

Make sure to disable card clock before changing frequency for uSDHC IP variants too.

Quoted 30 lines
---
 drivers/mmc/host/sdhci-esdhc-imx.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/mmc/host/sdhci-esdhc-imx.c +6 -6
index 85fd5a8b0b6d..acacd8481473 100644
@@ -708,14 +708,14 @@ static inline void esdhc_pltfm_set_clock(struct sdhci_host *host,
 	int div = 1;
 	u32 temp, val;
 
+	if (esdhc_is_usdhc(imx_data)) {
+		val = readl(host->ioaddr + ESDHC_VENDOR_SPEC);
+		writel(val & ~ESDHC_VENDOR_SPEC_FRC_SDCLK_ON,
+			host->ioaddr + ESDHC_VENDOR_SPEC);
+	}
+
 	if (clock == 0) {
 		host->mmc->actual_clock = 0;
-
-		if (esdhc_is_usdhc(imx_data)) {
-			val = readl(host->ioaddr + ESDHC_VENDOR_SPEC);
-			writel(val & ~ESDHC_VENDOR_SPEC_FRC_SDCLK_ON,
-					host->ioaddr + ESDHC_VENDOR_SPEC);
-		}
 		return;
 	}