mmc: sdhci-esdhc-imx: disable clocks before changing frequency
Subsystems (4)
PATCH 1/1 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 chainging frequency for uSDHC IP variants too. Also fix indent to make disable/enable clock look alike.
--- drivers/mmc/host/sdhci-esdhc-imx.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/mmc/host/sdhci-esdhc-imx.c +7 -7
@@ -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 ; }
@@ -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
Adrian Hunter
maintainerQuoted 11 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).For older IP variants the driver disables clock by clearing some bits in
ESDHC_SYSTEM_CONTROL.Make sure to disable card clock before chainging frequency for uSDHC
chainging -> changing
Quoted 34 lines
IP variants too. Also fix indent to make disable/enable clock look alike.
Signed-off-by Stefan Agner <[email protected]>--- drivers/mmc/host/sdhci-esdhc-imx.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)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 ; }
drivers/mmc/host/sdhci-esdhc-imx.c static inline void esdhc_pltfm_set_clock(struct sdhci_host *host, · line 764
Quoted 5 lines
drivers/mmc/host/sdhci-esdhc-imx.c +1
-1@@ -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 );
Ideally each patch does only 1 thing. Please make white-space fix-up a separate patch.
Quoted 4 lines
drivers/mmc/host/sdhci-esdhc-imx.c +0
-0}mdelay (1 );
Quoted 48 lines · Adrian Hunter
Quoted 11 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).For older IP variants the driver disables clock by clearing some bits in
ESDHC_SYSTEM_CONTROL.Make sure to disable card clock before chainging frequency for uSDHC
chainging -> changing
Quoted 33 lines
IP variants too. Also fix indent to make disable/enable clock look alike.
Signed-off-by Stefan Agner <[email protected]>--- drivers/mmc/host/sdhci-esdhc-imx.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)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 ; }
Quoted 15 lines
drivers/mmc/host/sdhci-esdhc-imx.c static inline void esdhc_pltfm_set_clock(struct sdhci_host *host, · line 764
Quoted 6 lines
drivers/mmc/host/sdhci-esdhc-imx.c +1
-1@@ -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 );Ideally each patch does only 1 thing. Please make white-space fix-up a separate patch.
Quoted 4 lines
drivers/mmc/host/sdhci-esdhc-imx.c +0
-0}mdelay (1 );
It turned out that I had already applied this one. I am going to re-base my next branch next week, so dropping the patch by then.
Until then, the patch is reverted.
Stefan, please send a new version addressing Adrian's comments.
Kind regards
Uffe