aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mmc
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mmc')
-rw-r--r--drivers/mmc/core/block.c10
-rw-r--r--drivers/mmc/core/host.c2
-rw-r--r--drivers/mmc/host/Kconfig4
-rw-r--r--drivers/mmc/host/bcm2835.c2
-rw-r--r--drivers/mmc/host/dw_mmc-bluefield.c5
-rw-r--r--drivers/mmc/host/meson-gx-mmc.c33
-rw-r--r--drivers/mmc/host/mtk-sd.c2
-rw-r--r--drivers/mmc/host/sdhci-iproc.c5
-rw-r--r--drivers/mmc/host/sdhci.c5
-rw-r--r--drivers/mmc/host/sunxi-mmc.c26
10 files changed, 68 insertions, 26 deletions
diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c
index aef1185f383d..14f3fdb8c6bb 100644
--- a/drivers/mmc/core/block.c
+++ b/drivers/mmc/core/block.c
@@ -2112,7 +2112,7 @@ static void mmc_blk_mq_req_done(struct mmc_request *mrq)
2112 if (waiting) 2112 if (waiting)
2113 wake_up(&mq->wait); 2113 wake_up(&mq->wait);
2114 else 2114 else
2115 kblockd_schedule_work(&mq->complete_work); 2115 queue_work(mq->card->complete_wq, &mq->complete_work);
2116 2116
2117 return; 2117 return;
2118 } 2118 }
@@ -2924,6 +2924,13 @@ static int mmc_blk_probe(struct mmc_card *card)
2924 2924
2925 mmc_fixup_device(card, mmc_blk_fixups); 2925 mmc_fixup_device(card, mmc_blk_fixups);
2926 2926
2927 card->complete_wq = alloc_workqueue("mmc_complete",
2928 WQ_MEM_RECLAIM | WQ_HIGHPRI, 0);
2929 if (unlikely(!card->complete_wq)) {
2930 pr_err("Failed to create mmc completion workqueue");
2931 return -ENOMEM;
2932 }
2933
2927 md = mmc_blk_alloc(card); 2934 md = mmc_blk_alloc(card);
2928 if (IS_ERR(md)) 2935 if (IS_ERR(md))
2929 return PTR_ERR(md); 2936 return PTR_ERR(md);
@@ -2987,6 +2994,7 @@ static void mmc_blk_remove(struct mmc_card *card)
2987 pm_runtime_put_noidle(&card->dev); 2994 pm_runtime_put_noidle(&card->dev);
2988 mmc_blk_remove_req(md); 2995 mmc_blk_remove_req(md);
2989 dev_set_drvdata(&card->dev, NULL); 2996 dev_set_drvdata(&card->dev, NULL);
2997 destroy_workqueue(card->complete_wq);
2990} 2998}
2991 2999
2992static int _mmc_blk_suspend(struct mmc_card *card) 3000static int _mmc_blk_suspend(struct mmc_card *card)
diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c
index f57f5de54206..cf58ccaf22d5 100644
--- a/drivers/mmc/core/host.c
+++ b/drivers/mmc/core/host.c
@@ -234,7 +234,7 @@ int mmc_of_parse(struct mmc_host *host)
234 if (device_property_read_bool(dev, "broken-cd")) 234 if (device_property_read_bool(dev, "broken-cd"))
235 host->caps |= MMC_CAP_NEEDS_POLL; 235 host->caps |= MMC_CAP_NEEDS_POLL;
236 236
237 ret = mmc_gpiod_request_cd(host, "cd", 0, true, 237 ret = mmc_gpiod_request_cd(host, "cd", 0, false,
238 cd_debounce_delay_ms * 1000, 238 cd_debounce_delay_ms * 1000,
239 &cd_gpio_invert); 239 &cd_gpio_invert);
240 if (!ret) 240 if (!ret)
diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig
index e26b8145efb3..a44ec8bb5418 100644
--- a/drivers/mmc/host/Kconfig
+++ b/drivers/mmc/host/Kconfig
@@ -116,7 +116,7 @@ config MMC_RICOH_MMC
116 116
117config MMC_SDHCI_ACPI 117config MMC_SDHCI_ACPI
118 tristate "SDHCI support for ACPI enumerated SDHCI controllers" 118 tristate "SDHCI support for ACPI enumerated SDHCI controllers"
119 depends on MMC_SDHCI && ACPI 119 depends on MMC_SDHCI && ACPI && PCI
120 select IOSF_MBI if X86 120 select IOSF_MBI if X86
121 help 121 help
122 This selects support for ACPI enumerated SDHCI controllers, 122 This selects support for ACPI enumerated SDHCI controllers,
@@ -978,7 +978,7 @@ config MMC_SDHCI_OMAP
978 tristate "TI SDHCI Controller Support" 978 tristate "TI SDHCI Controller Support"
979 depends on MMC_SDHCI_PLTFM && OF 979 depends on MMC_SDHCI_PLTFM && OF
980 select THERMAL 980 select THERMAL
981 select TI_SOC_THERMAL 981 imply TI_SOC_THERMAL
982 help 982 help
983 This selects the Secure Digital Host Controller Interface (SDHCI) 983 This selects the Secure Digital Host Controller Interface (SDHCI)
984 support present in TI's DRA7 SOCs. The controller supports 984 support present in TI's DRA7 SOCs. The controller supports
diff --git a/drivers/mmc/host/bcm2835.c b/drivers/mmc/host/bcm2835.c
index 50293529d6de..c9e7aa50bb0a 100644
--- a/drivers/mmc/host/bcm2835.c
+++ b/drivers/mmc/host/bcm2835.c
@@ -1431,6 +1431,8 @@ static int bcm2835_probe(struct platform_device *pdev)
1431 1431
1432err: 1432err:
1433 dev_dbg(dev, "%s -> err %d\n", __func__, ret); 1433 dev_dbg(dev, "%s -> err %d\n", __func__, ret);
1434 if (host->dma_chan_rxtx)
1435 dma_release_channel(host->dma_chan_rxtx);
1434 mmc_free_host(mmc); 1436 mmc_free_host(mmc);
1435 1437
1436 return ret; 1438 return ret;
diff --git a/drivers/mmc/host/dw_mmc-bluefield.c b/drivers/mmc/host/dw_mmc-bluefield.c
index ed8f2254b66a..aa38b1a8017e 100644
--- a/drivers/mmc/host/dw_mmc-bluefield.c
+++ b/drivers/mmc/host/dw_mmc-bluefield.c
@@ -1,11 +1,6 @@
1// SPDX-License-Identifier: GPL-2.0 1// SPDX-License-Identifier: GPL-2.0
2/* 2/*
3 * Copyright (C) 2018 Mellanox Technologies. 3 * Copyright (C) 2018 Mellanox Technologies.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 */ 4 */
10 5
11#include <linux/bitfield.h> 6#include <linux/bitfield.h>
diff --git a/drivers/mmc/host/meson-gx-mmc.c b/drivers/mmc/host/meson-gx-mmc.c
index c2690c1a50ff..2eba507790e4 100644
--- a/drivers/mmc/host/meson-gx-mmc.c
+++ b/drivers/mmc/host/meson-gx-mmc.c
@@ -179,6 +179,8 @@ struct meson_host {
179 struct sd_emmc_desc *descs; 179 struct sd_emmc_desc *descs;
180 dma_addr_t descs_dma_addr; 180 dma_addr_t descs_dma_addr;
181 181
182 int irq;
183
182 bool vqmmc_enabled; 184 bool vqmmc_enabled;
183}; 185};
184 186
@@ -738,6 +740,11 @@ static int meson_mmc_clk_phase_tuning(struct mmc_host *mmc, u32 opcode,
738static int meson_mmc_execute_tuning(struct mmc_host *mmc, u32 opcode) 740static int meson_mmc_execute_tuning(struct mmc_host *mmc, u32 opcode)
739{ 741{
740 struct meson_host *host = mmc_priv(mmc); 742 struct meson_host *host = mmc_priv(mmc);
743 int adj = 0;
744
745 /* enable signal resampling w/o delay */
746 adj = ADJUST_ADJ_EN;
747 writel(adj, host->regs + host->data->adjust);
741 748
742 return meson_mmc_clk_phase_tuning(mmc, opcode, host->rx_clk); 749 return meson_mmc_clk_phase_tuning(mmc, opcode, host->rx_clk);
743} 750}
@@ -768,6 +775,9 @@ static void meson_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
768 if (!IS_ERR(mmc->supply.vmmc)) 775 if (!IS_ERR(mmc->supply.vmmc))
769 mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, ios->vdd); 776 mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, ios->vdd);
770 777
778 /* disable signal resampling */
779 writel(0, host->regs + host->data->adjust);
780
771 /* Reset rx phase */ 781 /* Reset rx phase */
772 clk_set_phase(host->rx_clk, 0); 782 clk_set_phase(host->rx_clk, 0);
773 783
@@ -1166,7 +1176,7 @@ static int meson_mmc_get_cd(struct mmc_host *mmc)
1166 1176
1167static void meson_mmc_cfg_init(struct meson_host *host) 1177static void meson_mmc_cfg_init(struct meson_host *host)
1168{ 1178{
1169 u32 cfg = 0, adj = 0; 1179 u32 cfg = 0;
1170 1180
1171 cfg |= FIELD_PREP(CFG_RESP_TIMEOUT_MASK, 1181 cfg |= FIELD_PREP(CFG_RESP_TIMEOUT_MASK,
1172 ilog2(SD_EMMC_CFG_RESP_TIMEOUT)); 1182 ilog2(SD_EMMC_CFG_RESP_TIMEOUT));
@@ -1177,10 +1187,6 @@ static void meson_mmc_cfg_init(struct meson_host *host)
1177 cfg |= CFG_ERR_ABORT; 1187 cfg |= CFG_ERR_ABORT;
1178 1188
1179 writel(cfg, host->regs + SD_EMMC_CFG); 1189 writel(cfg, host->regs + SD_EMMC_CFG);
1180
1181 /* enable signal resampling w/o delay */
1182 adj = ADJUST_ADJ_EN;
1183 writel(adj, host->regs + host->data->adjust);
1184} 1190}
1185 1191
1186static int meson_mmc_card_busy(struct mmc_host *mmc) 1192static int meson_mmc_card_busy(struct mmc_host *mmc)
@@ -1231,7 +1237,7 @@ static int meson_mmc_probe(struct platform_device *pdev)
1231 struct resource *res; 1237 struct resource *res;
1232 struct meson_host *host; 1238 struct meson_host *host;
1233 struct mmc_host *mmc; 1239 struct mmc_host *mmc;
1234 int ret, irq; 1240 int ret;
1235 1241
1236 mmc = mmc_alloc_host(sizeof(struct meson_host), &pdev->dev); 1242 mmc = mmc_alloc_host(sizeof(struct meson_host), &pdev->dev);
1237 if (!mmc) 1243 if (!mmc)
@@ -1276,8 +1282,8 @@ static int meson_mmc_probe(struct platform_device *pdev)
1276 goto free_host; 1282 goto free_host;
1277 } 1283 }
1278 1284
1279 irq = platform_get_irq(pdev, 0); 1285 host->irq = platform_get_irq(pdev, 0);
1280 if (irq <= 0) { 1286 if (host->irq <= 0) {
1281 dev_err(&pdev->dev, "failed to get interrupt resource.\n"); 1287 dev_err(&pdev->dev, "failed to get interrupt resource.\n");
1282 ret = -EINVAL; 1288 ret = -EINVAL;
1283 goto free_host; 1289 goto free_host;
@@ -1331,9 +1337,9 @@ static int meson_mmc_probe(struct platform_device *pdev)
1331 writel(IRQ_CRC_ERR | IRQ_TIMEOUTS | IRQ_END_OF_CHAIN, 1337 writel(IRQ_CRC_ERR | IRQ_TIMEOUTS | IRQ_END_OF_CHAIN,
1332 host->regs + SD_EMMC_IRQ_EN); 1338 host->regs + SD_EMMC_IRQ_EN);
1333 1339
1334 ret = devm_request_threaded_irq(&pdev->dev, irq, meson_mmc_irq, 1340 ret = request_threaded_irq(host->irq, meson_mmc_irq,
1335 meson_mmc_irq_thread, IRQF_SHARED, 1341 meson_mmc_irq_thread, IRQF_SHARED,
1336 NULL, host); 1342 dev_name(&pdev->dev), host);
1337 if (ret) 1343 if (ret)
1338 goto err_init_clk; 1344 goto err_init_clk;
1339 1345
@@ -1351,7 +1357,7 @@ static int meson_mmc_probe(struct platform_device *pdev)
1351 if (host->bounce_buf == NULL) { 1357 if (host->bounce_buf == NULL) {
1352 dev_err(host->dev, "Unable to map allocate DMA bounce buffer.\n"); 1358 dev_err(host->dev, "Unable to map allocate DMA bounce buffer.\n");
1353 ret = -ENOMEM; 1359 ret = -ENOMEM;
1354 goto err_init_clk; 1360 goto err_free_irq;
1355 } 1361 }
1356 1362
1357 host->descs = dma_alloc_coherent(host->dev, SD_EMMC_DESC_BUF_LEN, 1363 host->descs = dma_alloc_coherent(host->dev, SD_EMMC_DESC_BUF_LEN,
@@ -1370,6 +1376,8 @@ static int meson_mmc_probe(struct platform_device *pdev)
1370err_bounce_buf: 1376err_bounce_buf:
1371 dma_free_coherent(host->dev, host->bounce_buf_size, 1377 dma_free_coherent(host->dev, host->bounce_buf_size,
1372 host->bounce_buf, host->bounce_dma_addr); 1378 host->bounce_buf, host->bounce_dma_addr);
1379err_free_irq:
1380 free_irq(host->irq, host);
1373err_init_clk: 1381err_init_clk:
1374 clk_disable_unprepare(host->mmc_clk); 1382 clk_disable_unprepare(host->mmc_clk);
1375err_core_clk: 1383err_core_clk:
@@ -1387,6 +1395,7 @@ static int meson_mmc_remove(struct platform_device *pdev)
1387 1395
1388 /* disable interrupts */ 1396 /* disable interrupts */
1389 writel(0, host->regs + SD_EMMC_IRQ_EN); 1397 writel(0, host->regs + SD_EMMC_IRQ_EN);
1398 free_irq(host->irq, host);
1390 1399
1391 dma_free_coherent(host->dev, SD_EMMC_DESC_BUF_LEN, 1400 dma_free_coherent(host->dev, SD_EMMC_DESC_BUF_LEN,
1392 host->descs, host->descs_dma_addr); 1401 host->descs, host->descs_dma_addr);
diff --git a/drivers/mmc/host/mtk-sd.c b/drivers/mmc/host/mtk-sd.c
index 8afeaf81ae66..833ef0590af8 100644
--- a/drivers/mmc/host/mtk-sd.c
+++ b/drivers/mmc/host/mtk-sd.c
@@ -846,7 +846,7 @@ static void msdc_set_mclk(struct msdc_host *host, unsigned char timing, u32 hz)
846 846
847 if (timing == MMC_TIMING_MMC_HS400 && 847 if (timing == MMC_TIMING_MMC_HS400 &&
848 host->dev_comp->hs400_tune) 848 host->dev_comp->hs400_tune)
849 sdr_set_field(host->base + PAD_CMD_TUNE, 849 sdr_set_field(host->base + tune_reg,
850 MSDC_PAD_TUNE_CMDRRDLY, 850 MSDC_PAD_TUNE_CMDRRDLY,
851 host->hs400_cmd_int_delay); 851 host->hs400_cmd_int_delay);
852 dev_dbg(host->dev, "sclk: %d, timing: %d\n", host->mmc->actual_clock, 852 dev_dbg(host->dev, "sclk: %d, timing: %d\n", host->mmc->actual_clock,
diff --git a/drivers/mmc/host/sdhci-iproc.c b/drivers/mmc/host/sdhci-iproc.c
index 0db99057c44f..9d12c06c7fd6 100644
--- a/drivers/mmc/host/sdhci-iproc.c
+++ b/drivers/mmc/host/sdhci-iproc.c
@@ -296,7 +296,10 @@ static int sdhci_iproc_probe(struct platform_device *pdev)
296 296
297 iproc_host->data = iproc_data; 297 iproc_host->data = iproc_data;
298 298
299 mmc_of_parse(host->mmc); 299 ret = mmc_of_parse(host->mmc);
300 if (ret)
301 goto err;
302
300 sdhci_get_property(pdev); 303 sdhci_get_property(pdev);
301 304
302 host->mmc->caps |= iproc_host->data->mmc_caps; 305 host->mmc->caps |= iproc_host->data->mmc_caps;
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index a22e11a65658..eba9bcc92ad3 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -3763,8 +3763,9 @@ int sdhci_setup_host(struct sdhci_host *host)
3763 * Use zalloc to zero the reserved high 32-bits of 128-bit 3763 * Use zalloc to zero the reserved high 32-bits of 128-bit
3764 * descriptors so that they never need to be written. 3764 * descriptors so that they never need to be written.
3765 */ 3765 */
3766 buf = dma_zalloc_coherent(mmc_dev(mmc), host->align_buffer_sz + 3766 buf = dma_alloc_coherent(mmc_dev(mmc),
3767 host->adma_table_sz, &dma, GFP_KERNEL); 3767 host->align_buffer_sz + host->adma_table_sz,
3768 &dma, GFP_KERNEL);
3768 if (!buf) { 3769 if (!buf) {
3769 pr_warn("%s: Unable to allocate ADMA buffers - falling back to standard DMA\n", 3770 pr_warn("%s: Unable to allocate ADMA buffers - falling back to standard DMA\n",
3770 mmc_hostname(mmc)); 3771 mmc_hostname(mmc));
diff --git a/drivers/mmc/host/sunxi-mmc.c b/drivers/mmc/host/sunxi-mmc.c
index 279e326e397e..70fadc976795 100644
--- a/drivers/mmc/host/sunxi-mmc.c
+++ b/drivers/mmc/host/sunxi-mmc.c
@@ -1399,13 +1399,37 @@ static int sunxi_mmc_probe(struct platform_device *pdev)
1399 mmc->caps |= MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED | 1399 mmc->caps |= MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED |
1400 MMC_CAP_ERASE | MMC_CAP_SDIO_IRQ; 1400 MMC_CAP_ERASE | MMC_CAP_SDIO_IRQ;
1401 1401
1402 if (host->cfg->clk_delays || host->use_new_timings) 1402 /*
1403 * Some H5 devices do not have signal traces precise enough to
1404 * use HS DDR mode for their eMMC chips.
1405 *
1406 * We still enable HS DDR modes for all the other controller
1407 * variants that support them.
1408 */
1409 if ((host->cfg->clk_delays || host->use_new_timings) &&
1410 !of_device_is_compatible(pdev->dev.of_node,
1411 "allwinner,sun50i-h5-emmc"))
1403 mmc->caps |= MMC_CAP_1_8V_DDR | MMC_CAP_3_3V_DDR; 1412 mmc->caps |= MMC_CAP_1_8V_DDR | MMC_CAP_3_3V_DDR;
1404 1413
1405 ret = mmc_of_parse(mmc); 1414 ret = mmc_of_parse(mmc);
1406 if (ret) 1415 if (ret)
1407 goto error_free_dma; 1416 goto error_free_dma;
1408 1417
1418 /*
1419 * If we don't support delay chains in the SoC, we can't use any
1420 * of the higher speed modes. Mask them out in case the device
1421 * tree specifies the properties for them, which gets added to
1422 * the caps by mmc_of_parse() above.
1423 */
1424 if (!(host->cfg->clk_delays || host->use_new_timings)) {
1425 mmc->caps &= ~(MMC_CAP_3_3V_DDR | MMC_CAP_1_8V_DDR |
1426 MMC_CAP_1_2V_DDR | MMC_CAP_UHS);
1427 mmc->caps2 &= ~MMC_CAP2_HS200;
1428 }
1429
1430 /* TODO: This driver doesn't support HS400 mode yet */
1431 mmc->caps2 &= ~MMC_CAP2_HS400;
1432
1409 ret = sunxi_mmc_init_host(host); 1433 ret = sunxi_mmc_init_host(host);
1410 if (ret) 1434 if (ret)
1411 goto error_free_dma; 1435 goto error_free_dma;