aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-03-24 16:37:40 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2017-03-24 16:37:40 -0400
commit9a31328f310d6281a8afbcf9e15832aef8e0695e (patch)
tree8358631cf8178bf25df3446685d6b8a6c3861bbb
parente88711860dee6ce0dba459abf6be446ccfc64443 (diff)
parent027fb89e61054b4aedd962adb3e2003dec78a716 (diff)
Merge tag 'mmc-v4.11-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc
Pull mmc fixes from Ulf Hansson: "Here are a couple of mmc fixes intended for v4.11 rc4. MMC core: - Fix initialization of HS400-ES eMMC cards - A couple of fixes for the mmc block device driver - Resolved a compiler warning MMC host: - sdhci: Do not disable IRQs while waiting for clock - sdhci-pci: Do not disable IRQs in sdhci_intel_set_power - sdhci-of-arasan: Fix incorrect timeout clock - mediatek: Fix bug for setting wrong clock frequency - sdhci-of-at91: Use regulator to fix cmd timeout errors - ushc: Fix NULL-deref at probe - rockchip-dw-mshc: Rename RK1108 to RV1108 in DT" * tag 'mmc-v4.11-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc: mmc: sdhci-pci: Do not disable interrupts in sdhci_intel_set_power mmc: sdhci: Do not disable interrupts while waiting for clock mmc: ushc: fix NULL-deref at probe mmc: sdhci-of-at91: Support external regulators mmc: core: mmc_blk_rw_cmd_err - remove unused variable mmc: mediatek: Fixed bug where clock frequency could be set wrong mmc: block: Fix cmd error reset failure path mmc: block: Fix is_waiting_last_req set incorrectly mmc: core: Fix access to HS400-ES devices mmc: sdhci-of-arasan: fix incorrect timeout clock dt-bindings: rockchip-dw-mshc: rename RK1108 to RV1108
-rw-r--r--Documentation/devicetree/bindings/mmc/rockchip-dw-mshc.txt2
-rw-r--r--drivers/mmc/core/block.c7
-rw-r--r--drivers/mmc/core/mmc.c2
-rw-r--r--drivers/mmc/host/mtk-sd.c4
-rw-r--r--drivers/mmc/host/sdhci-of-arasan.c14
-rw-r--r--drivers/mmc/host/sdhci-of-at91.c19
-rw-r--r--drivers/mmc/host/sdhci-pci-core.c4
-rw-r--r--drivers/mmc/host/sdhci.c4
-rw-r--r--drivers/mmc/host/ushc.c3
9 files changed, 41 insertions, 18 deletions
diff --git a/Documentation/devicetree/bindings/mmc/rockchip-dw-mshc.txt b/Documentation/devicetree/bindings/mmc/rockchip-dw-mshc.txt
index ea9c1c9607f6..520d61dad6dd 100644
--- a/Documentation/devicetree/bindings/mmc/rockchip-dw-mshc.txt
+++ b/Documentation/devicetree/bindings/mmc/rockchip-dw-mshc.txt
@@ -13,7 +13,7 @@ Required Properties:
13 - "rockchip,rk2928-dw-mshc": for Rockchip RK2928 and following, 13 - "rockchip,rk2928-dw-mshc": for Rockchip RK2928 and following,
14 before RK3288 14 before RK3288
15 - "rockchip,rk3288-dw-mshc": for Rockchip RK3288 15 - "rockchip,rk3288-dw-mshc": for Rockchip RK3288
16 - "rockchip,rk1108-dw-mshc", "rockchip,rk3288-dw-mshc": for Rockchip RK1108 16 - "rockchip,rv1108-dw-mshc", "rockchip,rk3288-dw-mshc": for Rockchip RV1108
17 - "rockchip,rk3036-dw-mshc", "rockchip,rk3288-dw-mshc": for Rockchip RK3036 17 - "rockchip,rk3036-dw-mshc", "rockchip,rk3288-dw-mshc": for Rockchip RK3036
18 - "rockchip,rk3368-dw-mshc", "rockchip,rk3288-dw-mshc": for Rockchip RK3368 18 - "rockchip,rk3368-dw-mshc", "rockchip,rk3288-dw-mshc": for Rockchip RK3368
19 - "rockchip,rk3399-dw-mshc", "rockchip,rk3288-dw-mshc": for Rockchip RK3399 19 - "rockchip,rk3399-dw-mshc", "rockchip,rk3288-dw-mshc": for Rockchip RK3399
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
1822out: 1821out:
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
164static unsigned int sdhci_arasan_get_timeout_clock(struct sdhci_host *host) 160static 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..7fd964256faa 100644
--- a/drivers/mmc/host/sdhci-of-at91.c
+++ b/drivers/mmc/host/sdhci-of-at91.c
@@ -85,11 +85,30 @@ static void sdhci_at91_set_clock(struct sdhci_host *host, unsigned int clock)
85 sdhci_writew(host, clk, SDHCI_CLOCK_CONTROL); 85 sdhci_writew(host, clk, SDHCI_CLOCK_CONTROL);
86} 86}
87 87
88/*
89 * In this specific implementation of the SDHCI controller, the power register
90 * needs to have a valid voltage set even when the power supply is managed by
91 * an external regulator.
92 */
93static void sdhci_at91_set_power(struct sdhci_host *host, unsigned char mode,
94 unsigned short vdd)
95{
96 if (!IS_ERR(host->mmc->supply.vmmc)) {
97 struct mmc_host *mmc = host->mmc;
98
99 spin_unlock_irq(&host->lock);
100 mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, vdd);
101 spin_lock_irq(&host->lock);
102 }
103 sdhci_set_power_noreg(host, mode, vdd);
104}
105
88static const struct sdhci_ops sdhci_at91_sama5d2_ops = { 106static const struct sdhci_ops sdhci_at91_sama5d2_ops = {
89 .set_clock = sdhci_at91_set_clock, 107 .set_clock = sdhci_at91_set_clock,
90 .set_bus_width = sdhci_set_bus_width, 108 .set_bus_width = sdhci_set_bus_width,
91 .reset = sdhci_reset, 109 .reset = sdhci_reset,
92 .set_uhs_signaling = sdhci_set_uhs_signaling, 110 .set_uhs_signaling = sdhci_set_uhs_signaling,
111 .set_power = sdhci_at91_set_power,
93}; 112};
94 113
95static const struct sdhci_pltfm_data soc_data_sama5d2 = { 114static 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
468static const struct sdhci_ops sdhci_intel_byt_ops = { 472static const struct sdhci_ops sdhci_intel_byt_ops = {
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 6fdd7a70f229..9c1a099afbbe 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;
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;