aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mmc/host/sdhci.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mmc/host/sdhci.c')
-rw-r--r--drivers/mmc/host/sdhci.c53
1 files changed, 24 insertions, 29 deletions
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index c31a3343340d..0e02cc1df12e 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -628,12 +628,11 @@ static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_command *cmd)
628 /* timeout in us */ 628 /* timeout in us */
629 if (!data) 629 if (!data)
630 target_timeout = cmd->cmd_timeout_ms * 1000; 630 target_timeout = cmd->cmd_timeout_ms * 1000;
631 else 631 else {
632 target_timeout = data->timeout_ns / 1000 + 632 target_timeout = data->timeout_ns / 1000;
633 data->timeout_clks / host->clock; 633 if (host->clock)
634 634 target_timeout += data->timeout_clks / host->clock;
635 if (host->quirks & SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK) 635 }
636 host->timeout_clk = host->clock / 1000;
637 636
638 /* 637 /*
639 * Figure out needed cycles. 638 * Figure out needed cycles.
@@ -645,7 +644,6 @@ static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_command *cmd)
645 * => 644 * =>
646 * (1) / (2) > 2^6 645 * (1) / (2) > 2^6
647 */ 646 */
648 BUG_ON(!host->timeout_clk);
649 count = 0; 647 count = 0;
650 current_timeout = (1 << 13) * 1000 / host->timeout_clk; 648 current_timeout = (1 << 13) * 1000 / host->timeout_clk;
651 while (current_timeout < target_timeout) { 649 while (current_timeout < target_timeout) {
@@ -1867,9 +1865,6 @@ static void sdhci_tasklet_finish(unsigned long param)
1867 1865
1868 del_timer(&host->timer); 1866 del_timer(&host->timer);
1869 1867
1870 if (host->version >= SDHCI_SPEC_300)
1871 del_timer(&host->tuning_timer);
1872
1873 mrq = host->mrq; 1868 mrq = host->mrq;
1874 1869
1875 /* 1870 /*
@@ -2461,22 +2456,6 @@ int sdhci_add_host(struct sdhci_host *host)
2461 host->max_clk = host->ops->get_max_clock(host); 2456 host->max_clk = host->ops->get_max_clock(host);
2462 } 2457 }
2463 2458
2464 host->timeout_clk =
2465 (caps[0] & SDHCI_TIMEOUT_CLK_MASK) >> SDHCI_TIMEOUT_CLK_SHIFT;
2466 if (host->timeout_clk == 0) {
2467 if (host->ops->get_timeout_clock) {
2468 host->timeout_clk = host->ops->get_timeout_clock(host);
2469 } else if (!(host->quirks &
2470 SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK)) {
2471 printk(KERN_ERR
2472 "%s: Hardware doesn't specify timeout clock "
2473 "frequency.\n", mmc_hostname(mmc));
2474 return -ENODEV;
2475 }
2476 }
2477 if (caps[0] & SDHCI_TIMEOUT_CLK_UNIT)
2478 host->timeout_clk *= 1000;
2479
2480 /* 2459 /*
2481 * In case of Host Controller v3.00, find out whether clock 2460 * In case of Host Controller v3.00, find out whether clock
2482 * multiplier is supported. 2461 * multiplier is supported.
@@ -2509,10 +2488,26 @@ int sdhci_add_host(struct sdhci_host *host)
2509 } else 2488 } else
2510 mmc->f_min = host->max_clk / SDHCI_MAX_DIV_SPEC_200; 2489 mmc->f_min = host->max_clk / SDHCI_MAX_DIV_SPEC_200;
2511 2490
2491 host->timeout_clk =
2492 (caps[0] & SDHCI_TIMEOUT_CLK_MASK) >> SDHCI_TIMEOUT_CLK_SHIFT;
2493 if (host->timeout_clk == 0) {
2494 if (host->ops->get_timeout_clock) {
2495 host->timeout_clk = host->ops->get_timeout_clock(host);
2496 } else if (!(host->quirks &
2497 SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK)) {
2498 printk(KERN_ERR
2499 "%s: Hardware doesn't specify timeout clock "
2500 "frequency.\n", mmc_hostname(mmc));
2501 return -ENODEV;
2502 }
2503 }
2504 if (caps[0] & SDHCI_TIMEOUT_CLK_UNIT)
2505 host->timeout_clk *= 1000;
2506
2512 if (host->quirks & SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK) 2507 if (host->quirks & SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK)
2513 mmc->max_discard_to = (1 << 27) / (mmc->f_max / 1000); 2508 host->timeout_clk = mmc->f_max / 1000;
2514 else 2509
2515 mmc->max_discard_to = (1 << 27) / host->timeout_clk; 2510 mmc->max_discard_to = (1 << 27) / host->timeout_clk;
2516 2511
2517 mmc->caps |= MMC_CAP_SDIO_IRQ | MMC_CAP_ERASE | MMC_CAP_CMD23; 2512 mmc->caps |= MMC_CAP_SDIO_IRQ | MMC_CAP_ERASE | MMC_CAP_CMD23;
2518 2513