From bd5fc32fda50b75f94ea4e403c8a6fba570e1d60 Mon Sep 17 00:00:00 2001 From: R Raj Kumar Date: Mon, 10 Aug 2015 14:57:09 +0530 Subject: [PATCH] mmc: tegra: Disable SD_CLK before calibration start Disabled SD_CLK before auto-calibration start and enabled it after completion of auto-calibration Bug 1670647 Change-Id: I3e0d2dd757430cb6f29c1dfeabcf55c96f0a29f5 Signed-off-by: R Raj Kumar Reviewed-on: http://git-master/r/781006 Reviewed-on: http://git-master/r/823882 GVS: Gerrit_Virtual_Submit Reviewed-by: Winnie Hsu Reviewed-by: Shreshtha Sahu Tested-by: Shreshtha Sahu --- drivers/mmc/host/sdhci-tegra.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/mmc/host/sdhci-tegra.c b/drivers/mmc/host/sdhci-tegra.c index 60324b2acd6..7a7db0ea827 100644 --- a/drivers/mmc/host/sdhci-tegra.c +++ b/drivers/mmc/host/sdhci-tegra.c @@ -2011,6 +2011,8 @@ static void tegra_sdhci_do_calibration(struct sdhci_host *sdhci, unsigned int pulldown_code; unsigned int pullup_code; unsigned long pin_config; + u16 clk; + bool card_clk_enabled; int err; /* No Calibration for sdmmc4 */ @@ -2020,6 +2022,13 @@ static void tegra_sdhci_do_calibration(struct sdhci_host *sdhci, if (unlikely(soc_data->nvquirks & NVQUIRK_DISABLE_AUTO_CALIBRATION)) return; + clk = sdhci_readw(sdhci, SDHCI_CLOCK_CONTROL); + card_clk_enabled = clk & SDHCI_CLOCK_CARD_EN; + if (card_clk_enabled) { + clk &= ~SDHCI_CLOCK_CARD_EN; + sdhci_writew(sdhci, clk, SDHCI_CLOCK_CONTROL); + } + val = sdhci_readl(sdhci, SDMMC_SDMEMCOMPPADCTRL); val &= ~SDMMC_SDMEMCOMPPADCTRL_VREF_SEL_MASK; if (soc_data->nvquirks & NVQUIRK_SET_PAD_E_INPUT_OR_E_PWRD) @@ -2089,6 +2098,11 @@ static void tegra_sdhci_do_calibration(struct sdhci_host *sdhci, if (soc_data->nvquirks & NVQUIRK_SET_PAD_E_INPUT_OR_E_PWRD) tegra_sdhci_configure_e_input(sdhci, false); + if (card_clk_enabled) { + clk |= SDHCI_CLOCK_CARD_EN; + sdhci_writew(sdhci, clk, SDHCI_CLOCK_CONTROL); + } + if (unlikely(soc_data->nvquirks & NVQUIRK_SET_DRIVE_STRENGTH)) { /* Disable Auto calibration */ val = sdhci_readl(sdhci, SDMMC_AUTO_CAL_CONFIG); @@ -2124,6 +2138,7 @@ static void tegra_sdhci_do_calibration(struct sdhci_host *sdhci, pullup_code, err); } } + if (tegra_host->plat->en_periodic_calib) { tegra_host->timestamp = ktime_get(); sdhci->timestamp = ktime_get(); -- 2.39.2