Skip to content

Commit

Permalink
Revert "mmc: sdhci: Fix voltage switch delay"
Browse files Browse the repository at this point in the history
This reverts commit 56536cb.
  • Loading branch information
raystef66 committed Dec 12, 2022
1 parent 460a8c4 commit 62ee7af
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 57 deletions.
63 changes: 8 additions & 55 deletions drivers/mmc/host/sdhci.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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;

Expand All @@ -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;
Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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);

Expand Down
2 changes: 0 additions & 2 deletions drivers/mmc/host/sdhci.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down

0 comments on commit 62ee7af

Please sign in to comment.