mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2026-09-22 09:34:56 +02:00
mmc: sdhci-of-dwcmshc: Disable clock before DLL configuration
commit6546a49bbeupstream. According to the ASIC design recommendations, the clock must be disabled before operating the DLL to prevent glitches that could affect the internal digital logic. In extreme cases, failing to do so may cause the controller to malfunction completely. Adds a step to disable the clock before DLL configuration and re-enables it at the end. Fixes:08f3dff799("mmc: sdhci-of-dwcmshc: add rockchip platform support") Cc: stable@vger.kernel.org Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com> Acked-by: Adrian Hunter <adrian.hunter@intel.com> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
0aaa431986
commit
00b1d0f4e7
@@ -243,12 +243,15 @@ static void dwcmshc_rk3568_set_clock(struct sdhci_host *host, unsigned int clock
|
||||
extra &= ~BIT(0);
|
||||
sdhci_writel(host, extra, reg);
|
||||
|
||||
/* Disable clock while config DLL */
|
||||
sdhci_writew(host, 0, SDHCI_CLOCK_CONTROL);
|
||||
|
||||
if (clock <= 52000000) {
|
||||
if (host->mmc->ios.timing == MMC_TIMING_MMC_HS200 ||
|
||||
host->mmc->ios.timing == MMC_TIMING_MMC_HS400) {
|
||||
dev_err(mmc_dev(host->mmc),
|
||||
"Can't reduce the clock below 52MHz in HS200/HS400 mode");
|
||||
return;
|
||||
goto enable_clk;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -268,7 +271,7 @@ static void dwcmshc_rk3568_set_clock(struct sdhci_host *host, unsigned int clock
|
||||
DLL_STRBIN_DELAY_NUM_SEL |
|
||||
DLL_STRBIN_DELAY_NUM_DEFAULT << DLL_STRBIN_DELAY_NUM_OFFSET;
|
||||
sdhci_writel(host, extra, DWCMSHC_EMMC_DLL_STRBIN);
|
||||
return;
|
||||
goto enable_clk;
|
||||
}
|
||||
|
||||
/* Reset DLL */
|
||||
@@ -295,7 +298,7 @@ static void dwcmshc_rk3568_set_clock(struct sdhci_host *host, unsigned int clock
|
||||
500 * USEC_PER_MSEC);
|
||||
if (err) {
|
||||
dev_err(mmc_dev(host->mmc), "DLL lock timeout!\n");
|
||||
return;
|
||||
goto enable_clk;
|
||||
}
|
||||
|
||||
extra = 0x1 << 16 | /* tune clock stop en */
|
||||
@@ -328,6 +331,16 @@ static void dwcmshc_rk3568_set_clock(struct sdhci_host *host, unsigned int clock
|
||||
DLL_STRBIN_TAPNUM_DEFAULT |
|
||||
DLL_STRBIN_TAPNUM_FROM_SW;
|
||||
sdhci_writel(host, extra, DWCMSHC_EMMC_DLL_STRBIN);
|
||||
|
||||
enable_clk:
|
||||
/*
|
||||
* The sdclk frequency select bits in SDHCI_CLOCK_CONTROL are not functional
|
||||
* on Rockchip's SDHCI implementation. Instead, the clock frequency is fully
|
||||
* controlled via external clk provider by calling clk_set_rate(). Consequently,
|
||||
* passing 0 to sdhci_enable_clk() only re-enables the already-configured clock,
|
||||
* which matches the hardware's actual behavior.
|
||||
*/
|
||||
sdhci_enable_clk(host, 0);
|
||||
}
|
||||
|
||||
static void rk35xx_sdhci_reset(struct sdhci_host *host, u8 mask)
|
||||
|
||||
Reference in New Issue
Block a user