diff options
Diffstat (limited to 'drivers/mmc')
| -rw-r--r-- | drivers/mmc/core/block.c | 7 | ||||
| -rw-r--r-- | drivers/mmc/core/mmc.c | 2 | ||||
| -rw-r--r-- | drivers/mmc/host/mtk-sd.c | 4 | ||||
| -rw-r--r-- | drivers/mmc/host/sdhci-of-arasan.c | 14 | ||||
| -rw-r--r-- | drivers/mmc/host/sdhci-of-at91.c | 30 | ||||
| -rw-r--r-- | drivers/mmc/host/sdhci-pci-core.c | 4 | ||||
| -rw-r--r-- | drivers/mmc/host/sdhci.c | 10 | ||||
| -rw-r--r-- | drivers/mmc/host/ushc.c | 3 |
8 files changed, 56 insertions, 18 deletions
diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c index 1621fa08e206..ff3da960c473 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c | |||
| @@ -1560,11 +1560,8 @@ static bool mmc_blk_rw_cmd_err(struct mmc_blk_data *md, struct mmc_card *card, | |||
| 1560 | struct mmc_blk_request *brq, struct request *req, | 1560 | struct mmc_blk_request *brq, struct request *req, |
| 1561 | bool old_req_pending) | 1561 | bool old_req_pending) |
| 1562 | { | 1562 | { |
| 1563 | struct mmc_queue_req *mq_rq; | ||
| 1564 | bool req_pending; | 1563 | bool req_pending; |
| 1565 | 1564 | ||
| 1566 | mq_rq = container_of(brq, struct mmc_queue_req, brq); | ||
| 1567 | |||
| 1568 | /* | 1565 | /* |
| 1569 | * If this is an SD card and we're writing, we can first | 1566 | * If this is an SD card and we're writing, we can first |
| 1570 | * mark the known good sectors as ok. | 1567 | * mark the known good sectors as ok. |
| @@ -1701,7 +1698,8 @@ static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *new_req) | |||
| 1701 | case MMC_BLK_CMD_ERR: | 1698 | case MMC_BLK_CMD_ERR: |
| 1702 | req_pending = mmc_blk_rw_cmd_err(md, card, brq, old_req, req_pending); | 1699 | req_pending = mmc_blk_rw_cmd_err(md, card, brq, old_req, req_pending); |
| 1703 | if (mmc_blk_reset(md, card->host, type)) { | 1700 | if (mmc_blk_reset(md, card->host, type)) { |
| 1704 | mmc_blk_rw_cmd_abort(card, old_req); | 1701 | if (req_pending) |
| 1702 | mmc_blk_rw_cmd_abort(card, old_req); | ||
| 1705 | mmc_blk_rw_try_restart(mq, new_req); | 1703 | mmc_blk_rw_try_restart(mq, new_req); |
| 1706 | return; | 1704 | return; |
| 1707 | } | 1705 | } |
| @@ -1817,6 +1815,7 @@ void mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) | |||
| 1817 | mmc_blk_issue_flush(mq, req); | 1815 | mmc_blk_issue_flush(mq, req); |
| 1818 | } else { | 1816 | } else { |
| 1819 | mmc_blk_issue_rw_rq(mq, req); | 1817 | mmc_blk_issue_rw_rq(mq, req); |
| 1818 | card->host->context_info.is_waiting_last_req = false; | ||
| 1820 | } | 1819 | } |
| 1821 | 1820 | ||
| 1822 | out: | 1821 | out: |
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index 7fd722868875..b502601df228 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c | |||
| @@ -1730,7 +1730,7 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, | |||
| 1730 | err = mmc_select_hs400(card); | 1730 | err = mmc_select_hs400(card); |
| 1731 | if (err) | 1731 | if (err) |
| 1732 | goto free_card; | 1732 | goto free_card; |
| 1733 | } else { | 1733 | } else if (!mmc_card_hs400es(card)) { |
| 1734 | /* Select the desired bus width optionally */ | 1734 | /* Select the desired bus width optionally */ |
| 1735 | err = mmc_select_bus_width(card); | 1735 | err = mmc_select_bus_width(card); |
| 1736 | if (err > 0 && mmc_card_hs(card)) { | 1736 | if (err > 0 && mmc_card_hs(card)) { |
diff --git a/drivers/mmc/host/mtk-sd.c b/drivers/mmc/host/mtk-sd.c index 8e32580c12b5..b235d8da0602 100644 --- a/drivers/mmc/host/mtk-sd.c +++ b/drivers/mmc/host/mtk-sd.c | |||
| @@ -580,7 +580,7 @@ static void msdc_set_mclk(struct msdc_host *host, unsigned char timing, u32 hz) | |||
| 580 | } | 580 | } |
| 581 | } | 581 | } |
| 582 | sdr_set_field(host->base + MSDC_CFG, MSDC_CFG_CKMOD | MSDC_CFG_CKDIV, | 582 | sdr_set_field(host->base + MSDC_CFG, MSDC_CFG_CKMOD | MSDC_CFG_CKDIV, |
| 583 | (mode << 8) | (div % 0xff)); | 583 | (mode << 8) | div); |
| 584 | sdr_set_bits(host->base + MSDC_CFG, MSDC_CFG_CKPDN); | 584 | sdr_set_bits(host->base + MSDC_CFG, MSDC_CFG_CKPDN); |
| 585 | while (!(readl(host->base + MSDC_CFG) & MSDC_CFG_CKSTB)) | 585 | while (!(readl(host->base + MSDC_CFG) & MSDC_CFG_CKSTB)) |
| 586 | cpu_relax(); | 586 | cpu_relax(); |
| @@ -1559,7 +1559,7 @@ static int msdc_drv_probe(struct platform_device *pdev) | |||
| 1559 | host->src_clk_freq = clk_get_rate(host->src_clk); | 1559 | host->src_clk_freq = clk_get_rate(host->src_clk); |
| 1560 | /* Set host parameters to mmc */ | 1560 | /* Set host parameters to mmc */ |
| 1561 | mmc->ops = &mt_msdc_ops; | 1561 | mmc->ops = &mt_msdc_ops; |
| 1562 | mmc->f_min = host->src_clk_freq / (4 * 255); | 1562 | mmc->f_min = DIV_ROUND_UP(host->src_clk_freq, 4 * 255); |
| 1563 | 1563 | ||
| 1564 | mmc->caps |= MMC_CAP_ERASE | MMC_CAP_CMD23; | 1564 | mmc->caps |= MMC_CAP_ERASE | MMC_CAP_CMD23; |
| 1565 | /* MMC core transfer sizes tunable parameters */ | 1565 | /* MMC core transfer sizes tunable parameters */ |
diff --git a/drivers/mmc/host/sdhci-of-arasan.c b/drivers/mmc/host/sdhci-of-arasan.c index 410a55b1c25f..1cfd7f900339 100644 --- a/drivers/mmc/host/sdhci-of-arasan.c +++ b/drivers/mmc/host/sdhci-of-arasan.c | |||
| @@ -28,13 +28,9 @@ | |||
| 28 | #include "sdhci-pltfm.h" | 28 | #include "sdhci-pltfm.h" |
| 29 | #include <linux/of.h> | 29 | #include <linux/of.h> |
| 30 | 30 | ||
| 31 | #define SDHCI_ARASAN_CLK_CTRL_OFFSET 0x2c | ||
| 32 | #define SDHCI_ARASAN_VENDOR_REGISTER 0x78 | 31 | #define SDHCI_ARASAN_VENDOR_REGISTER 0x78 |
| 33 | 32 | ||
| 34 | #define VENDOR_ENHANCED_STROBE BIT(0) | 33 | #define VENDOR_ENHANCED_STROBE BIT(0) |
| 35 | #define CLK_CTRL_TIMEOUT_SHIFT 16 | ||
| 36 | #define CLK_CTRL_TIMEOUT_MASK (0xf << CLK_CTRL_TIMEOUT_SHIFT) | ||
| 37 | #define CLK_CTRL_TIMEOUT_MIN_EXP 13 | ||
| 38 | 34 | ||
| 39 | #define PHY_CLK_TOO_SLOW_HZ 400000 | 35 | #define PHY_CLK_TOO_SLOW_HZ 400000 |
| 40 | 36 | ||
| @@ -163,15 +159,15 @@ static int sdhci_arasan_syscon_write(struct sdhci_host *host, | |||
| 163 | 159 | ||
| 164 | static unsigned int sdhci_arasan_get_timeout_clock(struct sdhci_host *host) | 160 | static unsigned int sdhci_arasan_get_timeout_clock(struct sdhci_host *host) |
| 165 | { | 161 | { |
| 166 | u32 div; | ||
| 167 | unsigned long freq; | 162 | unsigned long freq; |
| 168 | struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); | 163 | struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); |
| 169 | 164 | ||
| 170 | div = readl(host->ioaddr + SDHCI_ARASAN_CLK_CTRL_OFFSET); | 165 | /* SDHCI timeout clock is in kHz */ |
| 171 | div = (div & CLK_CTRL_TIMEOUT_MASK) >> CLK_CTRL_TIMEOUT_SHIFT; | 166 | freq = DIV_ROUND_UP(clk_get_rate(pltfm_host->clk), 1000); |
| 172 | 167 | ||
| 173 | freq = clk_get_rate(pltfm_host->clk); | 168 | /* or in MHz */ |
| 174 | freq /= 1 << (CLK_CTRL_TIMEOUT_MIN_EXP + div); | 169 | if (host->caps & SDHCI_TIMEOUT_CLK_UNIT) |
| 170 | freq = DIV_ROUND_UP(freq, 1000); | ||
| 175 | 171 | ||
| 176 | return freq; | 172 | return freq; |
| 177 | } | 173 | } |
diff --git a/drivers/mmc/host/sdhci-of-at91.c b/drivers/mmc/host/sdhci-of-at91.c index 2f9ad213377a..d5430ed02a67 100644 --- a/drivers/mmc/host/sdhci-of-at91.c +++ b/drivers/mmc/host/sdhci-of-at91.c | |||
| @@ -29,6 +29,8 @@ | |||
| 29 | 29 | ||
| 30 | #include "sdhci-pltfm.h" | 30 | #include "sdhci-pltfm.h" |
| 31 | 31 | ||
| 32 | #define SDMMC_MC1R 0x204 | ||
| 33 | #define SDMMC_MC1R_DDR BIT(3) | ||
| 32 | #define SDMMC_CACR 0x230 | 34 | #define SDMMC_CACR 0x230 |
| 33 | #define SDMMC_CACR_CAPWREN BIT(0) | 35 | #define SDMMC_CACR_CAPWREN BIT(0) |
| 34 | #define SDMMC_CACR_KEY (0x46 << 8) | 36 | #define SDMMC_CACR_KEY (0x46 << 8) |
| @@ -85,11 +87,37 @@ static void sdhci_at91_set_clock(struct sdhci_host *host, unsigned int clock) | |||
| 85 | sdhci_writew(host, clk, SDHCI_CLOCK_CONTROL); | 87 | sdhci_writew(host, clk, SDHCI_CLOCK_CONTROL); |
| 86 | } | 88 | } |
| 87 | 89 | ||
| 90 | /* | ||
| 91 | * In this specific implementation of the SDHCI controller, the power register | ||
| 92 | * needs to have a valid voltage set even when the power supply is managed by | ||
| 93 | * an external regulator. | ||
| 94 | */ | ||
| 95 | static void sdhci_at91_set_power(struct sdhci_host *host, unsigned char mode, | ||
| 96 | unsigned short vdd) | ||
| 97 | { | ||
| 98 | if (!IS_ERR(host->mmc->supply.vmmc)) { | ||
| 99 | struct mmc_host *mmc = host->mmc; | ||
| 100 | |||
| 101 | spin_unlock_irq(&host->lock); | ||
| 102 | mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, vdd); | ||
| 103 | spin_lock_irq(&host->lock); | ||
| 104 | } | ||
| 105 | sdhci_set_power_noreg(host, mode, vdd); | ||
| 106 | } | ||
| 107 | |||
| 108 | void sdhci_at91_set_uhs_signaling(struct sdhci_host *host, unsigned int timing) | ||
| 109 | { | ||
| 110 | if (timing == MMC_TIMING_MMC_DDR52) | ||
| 111 | sdhci_writeb(host, SDMMC_MC1R_DDR, SDMMC_MC1R); | ||
| 112 | sdhci_set_uhs_signaling(host, timing); | ||
| 113 | } | ||
| 114 | |||
| 88 | static const struct sdhci_ops sdhci_at91_sama5d2_ops = { | 115 | static const struct sdhci_ops sdhci_at91_sama5d2_ops = { |
| 89 | .set_clock = sdhci_at91_set_clock, | 116 | .set_clock = sdhci_at91_set_clock, |
| 90 | .set_bus_width = sdhci_set_bus_width, | 117 | .set_bus_width = sdhci_set_bus_width, |
| 91 | .reset = sdhci_reset, | 118 | .reset = sdhci_reset, |
| 92 | .set_uhs_signaling = sdhci_set_uhs_signaling, | 119 | .set_uhs_signaling = sdhci_at91_set_uhs_signaling, |
| 120 | .set_power = sdhci_at91_set_power, | ||
| 93 | }; | 121 | }; |
| 94 | 122 | ||
| 95 | static const struct sdhci_pltfm_data soc_data_sama5d2 = { | 123 | static const struct sdhci_pltfm_data soc_data_sama5d2 = { |
diff --git a/drivers/mmc/host/sdhci-pci-core.c b/drivers/mmc/host/sdhci-pci-core.c index 982b3e349426..86560d590786 100644 --- a/drivers/mmc/host/sdhci-pci-core.c +++ b/drivers/mmc/host/sdhci-pci-core.c | |||
| @@ -451,6 +451,8 @@ static void sdhci_intel_set_power(struct sdhci_host *host, unsigned char mode, | |||
| 451 | if (mode == MMC_POWER_OFF) | 451 | if (mode == MMC_POWER_OFF) |
| 452 | return; | 452 | return; |
| 453 | 453 | ||
| 454 | spin_unlock_irq(&host->lock); | ||
| 455 | |||
| 454 | /* | 456 | /* |
| 455 | * Bus power might not enable after D3 -> D0 transition due to the | 457 | * Bus power might not enable after D3 -> D0 transition due to the |
| 456 | * present state not yet having propagated. Retry for up to 2ms. | 458 | * present state not yet having propagated. Retry for up to 2ms. |
| @@ -463,6 +465,8 @@ static void sdhci_intel_set_power(struct sdhci_host *host, unsigned char mode, | |||
| 463 | reg |= SDHCI_POWER_ON; | 465 | reg |= SDHCI_POWER_ON; |
| 464 | sdhci_writeb(host, reg, SDHCI_POWER_CONTROL); | 466 | sdhci_writeb(host, reg, SDHCI_POWER_CONTROL); |
| 465 | } | 467 | } |
| 468 | |||
| 469 | spin_lock_irq(&host->lock); | ||
| 466 | } | 470 | } |
| 467 | 471 | ||
| 468 | static const struct sdhci_ops sdhci_intel_byt_ops = { | 472 | static const struct sdhci_ops sdhci_intel_byt_ops = { |
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 6fdd7a70f229..63bc33a54d0d 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c | |||
| @@ -1362,7 +1362,9 @@ void sdhci_enable_clk(struct sdhci_host *host, u16 clk) | |||
| 1362 | return; | 1362 | return; |
| 1363 | } | 1363 | } |
| 1364 | timeout--; | 1364 | timeout--; |
| 1365 | mdelay(1); | 1365 | spin_unlock_irq(&host->lock); |
| 1366 | usleep_range(900, 1100); | ||
| 1367 | spin_lock_irq(&host->lock); | ||
| 1366 | } | 1368 | } |
| 1367 | 1369 | ||
| 1368 | clk |= SDHCI_CLOCK_CARD_EN; | 1370 | clk |= SDHCI_CLOCK_CARD_EN; |
| @@ -1828,6 +1830,9 @@ static void sdhci_enable_sdio_irq(struct mmc_host *mmc, int enable) | |||
| 1828 | struct sdhci_host *host = mmc_priv(mmc); | 1830 | struct sdhci_host *host = mmc_priv(mmc); |
| 1829 | unsigned long flags; | 1831 | unsigned long flags; |
| 1830 | 1832 | ||
| 1833 | if (enable) | ||
| 1834 | pm_runtime_get_noresume(host->mmc->parent); | ||
| 1835 | |||
| 1831 | spin_lock_irqsave(&host->lock, flags); | 1836 | spin_lock_irqsave(&host->lock, flags); |
| 1832 | if (enable) | 1837 | if (enable) |
| 1833 | host->flags |= SDHCI_SDIO_IRQ_ENABLED; | 1838 | host->flags |= SDHCI_SDIO_IRQ_ENABLED; |
| @@ -1836,6 +1841,9 @@ static void sdhci_enable_sdio_irq(struct mmc_host *mmc, int enable) | |||
| 1836 | 1841 | ||
| 1837 | sdhci_enable_sdio_irq_nolock(host, enable); | 1842 | sdhci_enable_sdio_irq_nolock(host, enable); |
| 1838 | spin_unlock_irqrestore(&host->lock, flags); | 1843 | spin_unlock_irqrestore(&host->lock, flags); |
| 1844 | |||
| 1845 | if (!enable) | ||
| 1846 | pm_runtime_put_noidle(host->mmc->parent); | ||
| 1839 | } | 1847 | } |
| 1840 | 1848 | ||
| 1841 | static int sdhci_start_signal_voltage_switch(struct mmc_host *mmc, | 1849 | static int sdhci_start_signal_voltage_switch(struct mmc_host *mmc, |
diff --git a/drivers/mmc/host/ushc.c b/drivers/mmc/host/ushc.c index d2c386f09d69..1d843357422e 100644 --- a/drivers/mmc/host/ushc.c +++ b/drivers/mmc/host/ushc.c | |||
| @@ -426,6 +426,9 @@ static int ushc_probe(struct usb_interface *intf, const struct usb_device_id *id | |||
| 426 | struct ushc_data *ushc; | 426 | struct ushc_data *ushc; |
| 427 | int ret; | 427 | int ret; |
| 428 | 428 | ||
| 429 | if (intf->cur_altsetting->desc.bNumEndpoints < 1) | ||
| 430 | return -ENODEV; | ||
| 431 | |||
| 429 | mmc = mmc_alloc_host(sizeof(struct ushc_data), &intf->dev); | 432 | mmc = mmc_alloc_host(sizeof(struct ushc_data), &intf->dev); |
| 430 | if (mmc == NULL) | 433 | if (mmc == NULL) |
| 431 | return -ENOMEM; | 434 | return -ENOMEM; |
