summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDong Aisheng <b29396@freescale.com>2013-11-22 20:34:38 +0800
committerNitin Garg <nitin.garg@freescale.com>2015-04-14 14:00:30 -0500
commitc4d054c9bfff913bec74f4a760fe464064d301d2 (patch)
tree025184fdd6a3a0400f46b05628331f8c20bd74ba
parent73558d3abfba4108e2e8e2b8c9bb4c4fd36f7dae (diff)
ENGR00289406-1 mmc: sdhci: add quirk for get max timeout counter
The max timeout counter of some SoCs like i.MX6 uSDHC may not be standard, add SDHCI_QUIRK2_NOSTD_TIMEOUT_COUNTER quirk to get the correct max timeout counter from platform specific code. Then we can calculate the correct max_discard_to value. Signed-off-by: Dong Aisheng <b29396@freescale.com> (cherry picked from commit 0469c7c4c683547f7923fb54882f681ad6d23ca8)
-rw-r--r--drivers/mmc/host/sdhci.c14
-rw-r--r--drivers/mmc/host/sdhci.h1
-rw-r--r--include/linux/mmc/sdhci.h1
3 files changed, 15 insertions, 1 deletions
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index ab8a9e749320..a43196216047 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -2951,7 +2951,19 @@ int sdhci_add_host(struct sdhci_host *host)
if (host->quirks & SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK)
host->timeout_clk = mmc->f_max / 1000;
- mmc->max_discard_to = (1 << 27) / host->timeout_clk;
+ if (host->quirks2 & SDHCI_QUIRK2_NOSTD_TIMEOUT_COUNTER) {
+ if (host->ops->get_max_timeout_counter) {
+ mmc->max_discard_to =
+ host->ops->get_max_timeout_counter(host)
+ / host->timeout_clk;
+ } else {
+ pr_err("%s: Hardware doesn't specify max timeout "
+ "counter\n", mmc_hostname(mmc));
+ return -ENODEV;
+ }
+ } else {
+ mmc->max_discard_to = (1 << 27) / host->timeout_clk;
+ }
mmc->caps |= MMC_CAP_SDIO_IRQ | MMC_CAP_ERASE | MMC_CAP_CMD23;
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
index 0a3ed01887db..51bd04abddc9 100644
--- a/drivers/mmc/host/sdhci.h
+++ b/drivers/mmc/host/sdhci.h
@@ -281,6 +281,7 @@ struct sdhci_ops {
unsigned int (*get_max_clock)(struct sdhci_host *host);
unsigned int (*get_min_clock)(struct sdhci_host *host);
unsigned int (*get_timeout_clock)(struct sdhci_host *host);
+ unsigned int (*get_max_timeout_counter)(struct sdhci_host *host);
int (*platform_bus_width)(struct sdhci_host *host,
int width);
void (*platform_send_init_74_clocks)(struct sdhci_host *host,
diff --git a/include/linux/mmc/sdhci.h b/include/linux/mmc/sdhci.h
index 362927c48f97..864c92f4c720 100644
--- a/include/linux/mmc/sdhci.h
+++ b/include/linux/mmc/sdhci.h
@@ -96,6 +96,7 @@ struct sdhci_host {
#define SDHCI_QUIRK2_NO_1_8_V (1<<2)
#define SDHCI_QUIRK2_PRESET_VALUE_BROKEN (1<<3)
#define SDHCI_QUIRK2_CARD_ON_NEEDS_BUS_ON (1<<4)
+#define SDHCI_QUIRK2_NOSTD_TIMEOUT_COUNTER (1<<5)
/* Controller has a non-standard host control register */
#define SDHCI_QUIRK2_BROKEN_HOST_CONTROL (1<<5)
/* Controller does not support HS200 */