From 62ee7afd72bf99c9f475a7e6272b8f8c6b99c820 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C2=A8raystef66=C2=A8?= Date: Mon, 12 Dec 2022 09:40:24 +0100 Subject: [PATCH] Revert "mmc: sdhci: Fix voltage switch delay" This reverts commit 56536cb602eaf2f2f59c72d8f31de8112ce315ff. --- drivers/mmc/host/sdhci.c | 63 +++++----------------------------------- drivers/mmc/host/sdhci.h | 2 -- 2 files changed, 8 insertions(+), 57 deletions(-) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index c0c8060e643e..3250215a4af8 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -345,7 +345,6 @@ static void sdhci_init(struct sdhci_host *host, int soft) if (soft) { /* force clock reconfiguration */ host->clock = 0; - host->reinit_uhs = true; mmc->ops->set_ios(mmc, &mmc->ios); } } @@ -2057,48 +2056,13 @@ void sdhci_cfg_irq(struct sdhci_host *host, bool enable, bool sync) } EXPORT_SYMBOL(sdhci_cfg_irq); -static bool sdhci_timing_has_preset(unsigned char timing) -{ - switch (timing) { - case MMC_TIMING_UHS_SDR12: - case MMC_TIMING_UHS_SDR25: - case MMC_TIMING_UHS_SDR50: - case MMC_TIMING_UHS_SDR104: - case MMC_TIMING_UHS_DDR50: - case MMC_TIMING_MMC_DDR52: - return true; - }; - return false; -} - -static bool sdhci_preset_needed(struct sdhci_host *host, unsigned char timing) -{ - return !(host->quirks2 & SDHCI_QUIRK2_PRESET_VALUE_BROKEN) && - sdhci_timing_has_preset(timing); -} - -static bool sdhci_presetable_values_change(struct sdhci_host *host, struct mmc_ios *ios) -{ - /* - * Preset Values are: Driver Strength, Clock Generator and SDCLK/RCLK - * Frequency. Check if preset values need to be enabled, or the Driver - * Strength needs updating. Note, clock changes are handled separately. - */ - return !host->preset_enabled && - (sdhci_preset_needed(host, ios->timing) || host->drv_type != ios->drv_type); -} - void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) { struct sdhci_host *host = mmc_priv(mmc); unsigned long flags; - bool reinit_uhs = host->reinit_uhs; - bool turning_on_clk = false; u8 ctrl; int ret; - host->reinit_uhs = false; - if (ios->power_mode == MMC_POWER_UNDEFINED) return; @@ -2119,11 +2083,9 @@ void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) mmc_card_sdio(host->mmc->card)) sdhci_cfg_irq(host, false, false); - if (ios->clock && + if (ios->clock && ((ios->clock != host->clock) || (ios->timing != host->timing))) { spin_unlock_irqrestore(&host->lock, flags); - turning_on_clk = ios->clock && !host->clock; - host->ops->set_clock(host, ios->clock); spin_lock_irqsave(&host->lock, flags); host->clock = ios->clock; @@ -2188,17 +2150,6 @@ void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) host->ops->set_bus_width(host, ios->bus_width); - /* - * Special case to avoid multiple clock changes during voltage - * switching. - */ - if (!reinit_uhs && - turning_on_clk && - host->timing == ios->timing && - host->version >= SDHCI_SPEC_300 && - !sdhci_presetable_values_change(host, ios)) - return; - ctrl = sdhci_readb(host, SDHCI_HOST_CONTROL); if (!(host->quirks & SDHCI_QUIRK_NO_HISPD_BIT)) { @@ -2242,7 +2193,6 @@ void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) } sdhci_writew(host, ctrl_2, SDHCI_HOST_CONTROL2); - host->drv_type = ios->drv_type; } else { /* * According to SDHC Spec v3.00, if the Preset Value @@ -2274,14 +2224,19 @@ void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) host->ops->set_uhs_signaling(host, ios->timing); host->timing = ios->timing; - if (sdhci_preset_needed(host, ios->timing)) { + if (!(host->quirks2 & SDHCI_QUIRK2_PRESET_VALUE_BROKEN) && + ((ios->timing == MMC_TIMING_UHS_SDR12) || + (ios->timing == MMC_TIMING_UHS_SDR25) || + (ios->timing == MMC_TIMING_UHS_SDR50) || + (ios->timing == MMC_TIMING_UHS_SDR104) || + (ios->timing == MMC_TIMING_UHS_DDR50) || + (ios->timing == MMC_TIMING_MMC_DDR52))) { u16 preset; sdhci_enable_preset_value(host, true); preset = sdhci_get_preset_value(host); ios->drv_type = FIELD_GET(SDHCI_PRESET_DRV_MASK, preset); - host->drv_type = ios->drv_type; } /* Re-enable SD Clock */ @@ -3787,7 +3742,6 @@ int sdhci_resume_host(struct sdhci_host *host) sdhci_init(host, 0); host->pwr = 0; host->clock = 0; - host->reinit_uhs = true; mmc->ops->set_ios(mmc, &mmc->ios); } else { sdhci_init(host, (host->mmc->pm_flags & MMC_PM_KEEP_POWER)); @@ -3851,7 +3805,6 @@ int sdhci_runtime_resume_host(struct sdhci_host *host) /* Force clock and power re-program */ host->pwr = 0; host->clock = 0; - host->reinit_uhs = true; mmc->ops->start_signal_voltage_switch(mmc, &mmc->ios); mmc->ops->set_ios(mmc, &mmc->ios); diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h index 0c5680703a10..7de9281a60da 100644 --- a/drivers/mmc/host/sdhci.h +++ b/drivers/mmc/host/sdhci.h @@ -598,8 +598,6 @@ struct sdhci_host { unsigned int clock; /* Current clock (MHz) */ u8 pwr; /* Current voltage */ - u8 drv_type; /* Current UHS-I driver type */ - bool reinit_uhs; /* Force UHS-related re-initialization */ bool runtime_suspended; /* Host is runtime suspended */ bool bus_on; /* Bus power prevents runtime suspend */