diff options
Diffstat (limited to 'drivers/mmc/host/sdhci.c')
-rw-r--r-- | drivers/mmc/host/sdhci.c | 54 |
1 files changed, 29 insertions, 25 deletions
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index fc96f8cb9c0b..c279fbc4c2e5 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c | |||
@@ -591,6 +591,9 @@ static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_data *data) | |||
591 | target_timeout = data->timeout_ns / 1000 + | 591 | target_timeout = data->timeout_ns / 1000 + |
592 | data->timeout_clks / host->clock; | 592 | data->timeout_clks / host->clock; |
593 | 593 | ||
594 | if (host->quirks & SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK) | ||
595 | host->timeout_clk = host->clock / 1000; | ||
596 | |||
594 | /* | 597 | /* |
595 | * Figure out needed cycles. | 598 | * Figure out needed cycles. |
596 | * We do this in steps in order to fit inside a 32 bit int. | 599 | * We do this in steps in order to fit inside a 32 bit int. |
@@ -652,7 +655,7 @@ static void sdhci_prepare_data(struct sdhci_host *host, struct mmc_data *data) | |||
652 | count = sdhci_calc_timeout(host, data); | 655 | count = sdhci_calc_timeout(host, data); |
653 | sdhci_writeb(host, count, SDHCI_TIMEOUT_CONTROL); | 656 | sdhci_writeb(host, count, SDHCI_TIMEOUT_CONTROL); |
654 | 657 | ||
655 | if (host->flags & SDHCI_USE_DMA) | 658 | if (host->flags & (SDHCI_USE_SDMA | SDHCI_USE_ADMA)) |
656 | host->flags |= SDHCI_REQ_USE_DMA; | 659 | host->flags |= SDHCI_REQ_USE_DMA; |
657 | 660 | ||
658 | /* | 661 | /* |
@@ -991,8 +994,8 @@ static void sdhci_set_clock(struct sdhci_host *host, unsigned int clock) | |||
991 | clk |= SDHCI_CLOCK_INT_EN; | 994 | clk |= SDHCI_CLOCK_INT_EN; |
992 | sdhci_writew(host, clk, SDHCI_CLOCK_CONTROL); | 995 | sdhci_writew(host, clk, SDHCI_CLOCK_CONTROL); |
993 | 996 | ||
994 | /* Wait max 10 ms */ | 997 | /* Wait max 20 ms */ |
995 | timeout = 10; | 998 | timeout = 20; |
996 | while (!((clk = sdhci_readw(host, SDHCI_CLOCK_CONTROL)) | 999 | while (!((clk = sdhci_readw(host, SDHCI_CLOCK_CONTROL)) |
997 | & SDHCI_CLOCK_INT_STABLE)) { | 1000 | & SDHCI_CLOCK_INT_STABLE)) { |
998 | if (timeout == 0) { | 1001 | if (timeout == 0) { |
@@ -1597,7 +1600,7 @@ int sdhci_resume_host(struct sdhci_host *host) | |||
1597 | { | 1600 | { |
1598 | int ret; | 1601 | int ret; |
1599 | 1602 | ||
1600 | if (host->flags & SDHCI_USE_DMA) { | 1603 | if (host->flags & (SDHCI_USE_SDMA | SDHCI_USE_ADMA)) { |
1601 | if (host->ops->enable_dma) | 1604 | if (host->ops->enable_dma) |
1602 | host->ops->enable_dma(host); | 1605 | host->ops->enable_dma(host); |
1603 | } | 1606 | } |
@@ -1678,23 +1681,20 @@ int sdhci_add_host(struct sdhci_host *host) | |||
1678 | caps = sdhci_readl(host, SDHCI_CAPABILITIES); | 1681 | caps = sdhci_readl(host, SDHCI_CAPABILITIES); |
1679 | 1682 | ||
1680 | if (host->quirks & SDHCI_QUIRK_FORCE_DMA) | 1683 | if (host->quirks & SDHCI_QUIRK_FORCE_DMA) |
1681 | host->flags |= SDHCI_USE_DMA; | 1684 | host->flags |= SDHCI_USE_SDMA; |
1682 | else if (!(caps & SDHCI_CAN_DO_DMA)) | 1685 | else if (!(caps & SDHCI_CAN_DO_SDMA)) |
1683 | DBG("Controller doesn't have DMA capability\n"); | 1686 | DBG("Controller doesn't have SDMA capability\n"); |
1684 | else | 1687 | else |
1685 | host->flags |= SDHCI_USE_DMA; | 1688 | host->flags |= SDHCI_USE_SDMA; |
1686 | 1689 | ||
1687 | if ((host->quirks & SDHCI_QUIRK_BROKEN_DMA) && | 1690 | if ((host->quirks & SDHCI_QUIRK_BROKEN_DMA) && |
1688 | (host->flags & SDHCI_USE_DMA)) { | 1691 | (host->flags & SDHCI_USE_SDMA)) { |
1689 | DBG("Disabling DMA as it is marked broken\n"); | 1692 | DBG("Disabling DMA as it is marked broken\n"); |
1690 | host->flags &= ~SDHCI_USE_DMA; | 1693 | host->flags &= ~SDHCI_USE_SDMA; |
1691 | } | 1694 | } |
1692 | 1695 | ||
1693 | if (host->flags & SDHCI_USE_DMA) { | 1696 | if ((host->version >= SDHCI_SPEC_200) && (caps & SDHCI_CAN_DO_ADMA2)) |
1694 | if ((host->version >= SDHCI_SPEC_200) && | 1697 | host->flags |= SDHCI_USE_ADMA; |
1695 | (caps & SDHCI_CAN_DO_ADMA2)) | ||
1696 | host->flags |= SDHCI_USE_ADMA; | ||
1697 | } | ||
1698 | 1698 | ||
1699 | if ((host->quirks & SDHCI_QUIRK_BROKEN_ADMA) && | 1699 | if ((host->quirks & SDHCI_QUIRK_BROKEN_ADMA) && |
1700 | (host->flags & SDHCI_USE_ADMA)) { | 1700 | (host->flags & SDHCI_USE_ADMA)) { |
@@ -1702,13 +1702,14 @@ int sdhci_add_host(struct sdhci_host *host) | |||
1702 | host->flags &= ~SDHCI_USE_ADMA; | 1702 | host->flags &= ~SDHCI_USE_ADMA; |
1703 | } | 1703 | } |
1704 | 1704 | ||
1705 | if (host->flags & SDHCI_USE_DMA) { | 1705 | if (host->flags & (SDHCI_USE_SDMA | SDHCI_USE_ADMA)) { |
1706 | if (host->ops->enable_dma) { | 1706 | if (host->ops->enable_dma) { |
1707 | if (host->ops->enable_dma(host)) { | 1707 | if (host->ops->enable_dma(host)) { |
1708 | printk(KERN_WARNING "%s: No suitable DMA " | 1708 | printk(KERN_WARNING "%s: No suitable DMA " |
1709 | "available. Falling back to PIO.\n", | 1709 | "available. Falling back to PIO.\n", |
1710 | mmc_hostname(mmc)); | 1710 | mmc_hostname(mmc)); |
1711 | host->flags &= ~(SDHCI_USE_DMA | SDHCI_USE_ADMA); | 1711 | host->flags &= |
1712 | ~(SDHCI_USE_SDMA | SDHCI_USE_ADMA); | ||
1712 | } | 1713 | } |
1713 | } | 1714 | } |
1714 | } | 1715 | } |
@@ -1736,7 +1737,7 @@ int sdhci_add_host(struct sdhci_host *host) | |||
1736 | * mask, but PIO does not need the hw shim so we set a new | 1737 | * mask, but PIO does not need the hw shim so we set a new |
1737 | * mask here in that case. | 1738 | * mask here in that case. |
1738 | */ | 1739 | */ |
1739 | if (!(host->flags & SDHCI_USE_DMA)) { | 1740 | if (!(host->flags & (SDHCI_USE_SDMA | SDHCI_USE_ADMA))) { |
1740 | host->dma_mask = DMA_BIT_MASK(64); | 1741 | host->dma_mask = DMA_BIT_MASK(64); |
1741 | mmc_dev(host->mmc)->dma_mask = &host->dma_mask; | 1742 | mmc_dev(host->mmc)->dma_mask = &host->dma_mask; |
1742 | } | 1743 | } |
@@ -1757,13 +1758,15 @@ int sdhci_add_host(struct sdhci_host *host) | |||
1757 | host->timeout_clk = | 1758 | host->timeout_clk = |
1758 | (caps & SDHCI_TIMEOUT_CLK_MASK) >> SDHCI_TIMEOUT_CLK_SHIFT; | 1759 | (caps & SDHCI_TIMEOUT_CLK_MASK) >> SDHCI_TIMEOUT_CLK_SHIFT; |
1759 | if (host->timeout_clk == 0) { | 1760 | if (host->timeout_clk == 0) { |
1760 | if (!host->ops->get_timeout_clock) { | 1761 | if (host->ops->get_timeout_clock) { |
1762 | host->timeout_clk = host->ops->get_timeout_clock(host); | ||
1763 | } else if (!(host->quirks & | ||
1764 | SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK)) { | ||
1761 | printk(KERN_ERR | 1765 | printk(KERN_ERR |
1762 | "%s: Hardware doesn't specify timeout clock " | 1766 | "%s: Hardware doesn't specify timeout clock " |
1763 | "frequency.\n", mmc_hostname(mmc)); | 1767 | "frequency.\n", mmc_hostname(mmc)); |
1764 | return -ENODEV; | 1768 | return -ENODEV; |
1765 | } | 1769 | } |
1766 | host->timeout_clk = host->ops->get_timeout_clock(host); | ||
1767 | } | 1770 | } |
1768 | if (caps & SDHCI_TIMEOUT_CLK_UNIT) | 1771 | if (caps & SDHCI_TIMEOUT_CLK_UNIT) |
1769 | host->timeout_clk *= 1000; | 1772 | host->timeout_clk *= 1000; |
@@ -1772,7 +1775,8 @@ int sdhci_add_host(struct sdhci_host *host) | |||
1772 | * Set host parameters. | 1775 | * Set host parameters. |
1773 | */ | 1776 | */ |
1774 | mmc->ops = &sdhci_ops; | 1777 | mmc->ops = &sdhci_ops; |
1775 | if (host->ops->get_min_clock) | 1778 | if (host->quirks & SDHCI_QUIRK_NONSTANDARD_CLOCK && |
1779 | host->ops->set_clock && host->ops->get_min_clock) | ||
1776 | mmc->f_min = host->ops->get_min_clock(host); | 1780 | mmc->f_min = host->ops->get_min_clock(host); |
1777 | else | 1781 | else |
1778 | mmc->f_min = host->max_clk / 256; | 1782 | mmc->f_min = host->max_clk / 256; |
@@ -1810,7 +1814,7 @@ int sdhci_add_host(struct sdhci_host *host) | |||
1810 | */ | 1814 | */ |
1811 | if (host->flags & SDHCI_USE_ADMA) | 1815 | if (host->flags & SDHCI_USE_ADMA) |
1812 | mmc->max_hw_segs = 128; | 1816 | mmc->max_hw_segs = 128; |
1813 | else if (host->flags & SDHCI_USE_DMA) | 1817 | else if (host->flags & SDHCI_USE_SDMA) |
1814 | mmc->max_hw_segs = 1; | 1818 | mmc->max_hw_segs = 1; |
1815 | else /* PIO */ | 1819 | else /* PIO */ |
1816 | mmc->max_hw_segs = 128; | 1820 | mmc->max_hw_segs = 128; |
@@ -1893,10 +1897,10 @@ int sdhci_add_host(struct sdhci_host *host) | |||
1893 | 1897 | ||
1894 | mmc_add_host(mmc); | 1898 | mmc_add_host(mmc); |
1895 | 1899 | ||
1896 | printk(KERN_INFO "%s: SDHCI controller on %s [%s] using %s%s\n", | 1900 | printk(KERN_INFO "%s: SDHCI controller on %s [%s] using %s\n", |
1897 | mmc_hostname(mmc), host->hw_name, dev_name(mmc_dev(mmc)), | 1901 | mmc_hostname(mmc), host->hw_name, dev_name(mmc_dev(mmc)), |
1898 | (host->flags & SDHCI_USE_ADMA)?"A":"", | 1902 | (host->flags & SDHCI_USE_ADMA) ? "ADMA" : |
1899 | (host->flags & SDHCI_USE_DMA)?"DMA":"PIO"); | 1903 | (host->flags & SDHCI_USE_SDMA) ? "DMA" : "PIO"); |
1900 | 1904 | ||
1901 | sdhci_enable_card_detection(host); | 1905 | sdhci_enable_card_detection(host); |
1902 | 1906 | ||