diff options
author | Adrian Hunter <adrian.hunter@intel.com> | 2016-06-29 16:24:18 +0300 |
---|---|---|
committer | Ulf Hansson <ulf.hansson@linaro.org> | 2016-07-25 10:34:35 +0200 |
commit | 6132a3bf0711a13bcfc34cafc0a745adf868dfac (patch) | |
tree | 7890301bf946d0bdb0d389b3e68ff487bcc3a5c0 /drivers/mmc/host/sdhci.c | |
parent | 28da35899e6075ad0376f977c23dcefb815e77db (diff) | |
download | lwn-6132a3bf0711a13bcfc34cafc0a745adf868dfac.tar.gz lwn-6132a3bf0711a13bcfc34cafc0a745adf868dfac.zip |
mmc: sdhci: Add sdhci_read_caps()
Add sdhci_read_caps() and __sdhci_read_caps() to make it easier for drivers
to fix the version and capabilities registers.
Pedantically, the SDHCI specification states that the capabilities
registers are valid when the host controller resets the Software Reset For
All bit. That requirement has always been satisfied by performing a reset
at the start of initialization, and consequently that is now part of the
new functions.
Although the SDHCI_QUIRK_MISSING_CAPS quirk has not yet been removed,
drivers that want to provide their own caps can now use these functions
instead of that quirk.
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Diffstat (limited to 'drivers/mmc/host/sdhci.c')
-rw-r--r-- | drivers/mmc/host/sdhci.c | 48 |
1 files changed, 33 insertions, 15 deletions
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 185dbf27689e..44cdb6d035f2 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -2841,6 +2841,38 @@ static int sdhci_set_dma_mask(struct sdhci_host *host) return ret; } +void __sdhci_read_caps(struct sdhci_host *host, u16 *ver, u32 *caps, u32 *caps1) +{ + u16 v; + + if (host->read_caps) + return; + + host->read_caps = true; + + if (debug_quirks) + host->quirks = debug_quirks; + + if (debug_quirks2) + host->quirks2 = debug_quirks2; + + sdhci_do_reset(host, SDHCI_RESET_ALL); + + v = ver ? *ver : sdhci_readw(host, SDHCI_HOST_VERSION); + host->version = (v & SDHCI_SPEC_VER_MASK) >> SDHCI_SPEC_VER_SHIFT; + + if (host->quirks & SDHCI_QUIRK_MISSING_CAPS) + return; + + host->caps = caps ? *caps : sdhci_readl(host, SDHCI_CAPABILITIES); + + if (host->version < SDHCI_SPEC_300) + return; + + host->caps1 = caps1 ? *caps1 : sdhci_readl(host, SDHCI_CAPABILITIES_1); +} +EXPORT_SYMBOL_GPL(__sdhci_read_caps); + int sdhci_setup_host(struct sdhci_host *host) { struct mmc_host *mmc; @@ -2856,29 +2888,15 @@ int sdhci_setup_host(struct sdhci_host *host) mmc = host->mmc; - if (debug_quirks) - host->quirks = debug_quirks; - if (debug_quirks2) - host->quirks2 = debug_quirks2; + sdhci_read_caps(host); override_timeout_clk = host->timeout_clk; - sdhci_do_reset(host, SDHCI_RESET_ALL); - - host->version = sdhci_readw(host, SDHCI_HOST_VERSION); - host->version = (host->version & SDHCI_SPEC_VER_MASK) - >> SDHCI_SPEC_VER_SHIFT; if (host->version > SDHCI_SPEC_300) { pr_err("%s: Unknown controller version (%d). You may experience problems.\n", mmc_hostname(mmc), host->version); } - if (!(host->quirks & SDHCI_QUIRK_MISSING_CAPS)) { - host->caps = sdhci_readl(host, SDHCI_CAPABILITIES); - if (host->version >= SDHCI_SPEC_300) - host->caps1 = sdhci_readl(host, SDHCI_CAPABILITIES_1); - } - if (host->quirks & SDHCI_QUIRK_FORCE_DMA) host->flags |= SDHCI_USE_SDMA; else if (!(host->caps & SDHCI_CAN_DO_SDMA)) |