|
@@ -1820,21 +1820,16 @@ static int sdhci_card_busy(struct mmc_host *mmc)
|
|
|
|
|
|
static int sdhci_execute_tuning(struct mmc_host *mmc, u32 opcode)
|
|
static int sdhci_execute_tuning(struct mmc_host *mmc, u32 opcode)
|
|
{
|
|
{
|
|
- struct sdhci_host *host;
|
|
|
|
|
|
+ struct sdhci_host *host = mmc_priv(mmc);
|
|
u16 ctrl;
|
|
u16 ctrl;
|
|
int tuning_loop_counter = MAX_TUNING_LOOP;
|
|
int tuning_loop_counter = MAX_TUNING_LOOP;
|
|
unsigned long timeout;
|
|
unsigned long timeout;
|
|
int err = 0;
|
|
int err = 0;
|
|
- bool requires_tuning_nonuhs = false;
|
|
|
|
unsigned long flags;
|
|
unsigned long flags;
|
|
|
|
|
|
- host = mmc_priv(mmc);
|
|
|
|
-
|
|
|
|
sdhci_runtime_pm_get(host);
|
|
sdhci_runtime_pm_get(host);
|
|
spin_lock_irqsave(&host->lock, flags);
|
|
spin_lock_irqsave(&host->lock, flags);
|
|
|
|
|
|
- ctrl = sdhci_readw(host, SDHCI_HOST_CONTROL2);
|
|
|
|
-
|
|
|
|
/*
|
|
/*
|
|
* The Host Controller needs tuning only in case of SDR104 mode
|
|
* The Host Controller needs tuning only in case of SDR104 mode
|
|
* and for SDR50 mode when Use Tuning for SDR50 is set in the
|
|
* and for SDR50 mode when Use Tuning for SDR50 is set in the
|
|
@@ -1842,16 +1837,18 @@ static int sdhci_execute_tuning(struct mmc_host *mmc, u32 opcode)
|
|
* If the Host Controller supports the HS200 mode then the
|
|
* If the Host Controller supports the HS200 mode then the
|
|
* tuning function has to be executed.
|
|
* tuning function has to be executed.
|
|
*/
|
|
*/
|
|
- if (host->timing == MMC_TIMING_UHS_SDR50 &&
|
|
|
|
- (host->flags & SDHCI_SDR50_NEEDS_TUNING ||
|
|
|
|
- host->flags & SDHCI_SDR104_NEEDS_TUNING))
|
|
|
|
- requires_tuning_nonuhs = true;
|
|
|
|
-
|
|
|
|
- if (host->timing == MMC_TIMING_MMC_HS200 ||
|
|
|
|
- host->timing == MMC_TIMING_UHS_SDR104 ||
|
|
|
|
- requires_tuning_nonuhs)
|
|
|
|
- ctrl |= SDHCI_CTRL_EXEC_TUNING;
|
|
|
|
- else {
|
|
|
|
|
|
+ switch (host->timing) {
|
|
|
|
+ case MMC_TIMING_MMC_HS200:
|
|
|
|
+ case MMC_TIMING_UHS_SDR104:
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case MMC_TIMING_UHS_SDR50:
|
|
|
|
+ if (host->flags & SDHCI_SDR50_NEEDS_TUNING ||
|
|
|
|
+ host->flags & SDHCI_SDR104_NEEDS_TUNING)
|
|
|
|
+ break;
|
|
|
|
+ /* FALLTHROUGH */
|
|
|
|
+
|
|
|
|
+ default:
|
|
spin_unlock_irqrestore(&host->lock, flags);
|
|
spin_unlock_irqrestore(&host->lock, flags);
|
|
sdhci_runtime_pm_put(host);
|
|
sdhci_runtime_pm_put(host);
|
|
return 0;
|
|
return 0;
|
|
@@ -1864,6 +1861,8 @@ static int sdhci_execute_tuning(struct mmc_host *mmc, u32 opcode)
|
|
return err;
|
|
return err;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ ctrl = sdhci_readw(host, SDHCI_HOST_CONTROL2);
|
|
|
|
+ ctrl |= SDHCI_CTRL_EXEC_TUNING;
|
|
sdhci_writew(host, ctrl, SDHCI_HOST_CONTROL2);
|
|
sdhci_writew(host, ctrl, SDHCI_HOST_CONTROL2);
|
|
|
|
|
|
/*
|
|
/*
|