Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'mmc-v4.5' of git://git.linaro.org/people/ulf.hansson/mmc

Pull MMC updates from Ulf Hansson:
"MMC core:
- Optimize boot time by detecting cards simultaneously
- Make runtime resume default behavior for MMC/SD
- Enable MMC/SD/SDIO devices to suspend/resume asynchronously
- Allow more than 8 partitions per card
- Introduce MMC_CAP2_NO_SDIO to prevent unsupported SDIO commands
- Support the standard DT wakeup-source property
- Fix driver strength switching for HS200 and HS400
- Fix switch command timeout
- Fix invalid vdd in voltage switch power cycle for SDIO

MMC host:
- sdhci: Restore behavior when setting VDD via external regulator
- sdhci: A couple of changes/fixes related to the dma support
- sdhci-tegra: Add Tegra210 support
- sdhci-tegra: Support for UHS-I cards including tuning support
- sdhci-of-at91: Add PM support
- sh_mmcif: Rework dma channel handling
- mvsdio: Delete platform data code path"

* tag 'mmc-v4.5' of git://git.linaro.org/people/ulf.hansson/mmc: (52 commits)
mmc: dw_mmc: remove the unused quirks
mmc: sdhci-pci: use to_pci_dev()
mmc: cb710: use to_platform_device()
mmc: tegra: use correct accessor for misc ctrl register
mmc: tegra: enable UHS-I modes
mmc: tegra: implement UHS tuning
mmc: tegra: disable SPI_MODE_CLKEN
mmc: tegra: implement module external clock change
mmc: sdhci: restore behavior when setting VDD via external regulator
mmc: It is not an error for the card to be removed while suspended
mmc: block: Allow more than 8 partitions per card
mmc: core: Optimize boot time by detecting cards simultaneously
mmc: dw_mmc: use resource_size_t to store physical address
mmc: core: fix __mmc_switch timeout caused by preempt
mmc: usdhi6rol0: handle NULL data in timeout
mmc: of_mmc_spi: Add IRQF_ONESHOT to interrupt flags
mmc: mediatek: change some dev_err to dev_dbg
mmc: enable MMC/SD/SDIO device to suspend/resume asynchronously
mmc: sdhci: Fix sdhci_runtime_pm_bus_on/off()
mmc: sdhci: 64-bit DMA actually has 4-byte alignment
...

+628 -551
+1
Documentation/devicetree/bindings/mmc/renesas,mmcif.txt
··· 11 11 - "renesas,mmcif-r8a7740" for the MMCIF found in r8a7740 SoCs 12 12 - "renesas,mmcif-r8a7790" for the MMCIF found in r8a7790 SoCs 13 13 - "renesas,mmcif-r8a7791" for the MMCIF found in r8a7791 SoCs 14 + - "renesas,mmcif-r8a7793" for the MMCIF found in r8a7793 SoCs 14 15 - "renesas,mmcif-r8a7794" for the MMCIF found in r8a7794 SoCs 15 16 16 17 - clocks: reference to the functional clock
-1
MAINTAINERS
··· 1896 1896 M: Ludovic Desroches <ludovic.desroches@atmel.com> 1897 1897 S: Maintained 1898 1898 F: drivers/mmc/host/atmel-mci.c 1899 - F: drivers/mmc/host/atmel-mci-regs.h 1900 1899 1901 1900 ATMEL AT91 / AT32 SERIAL DRIVER 1902 1901 M: Nicolas Ferre <nicolas.ferre@atmel.com>
+4 -7
drivers/mmc/card/block.c
··· 171 171 172 172 static inline int mmc_get_devidx(struct gendisk *disk) 173 173 { 174 - int devmaj = MAJOR(disk_devt(disk)); 175 - int devidx = MINOR(disk_devt(disk)) / perdev_minors; 176 - 177 - if (!devmaj) 178 - devidx = disk->first_minor / perdev_minors; 174 + int devidx = disk->first_minor / perdev_minors; 179 175 return devidx; 180 176 } 181 177 ··· 340 344 struct mmc_blk_ioc_data *idata; 341 345 int err; 342 346 343 - idata = kzalloc(sizeof(*idata), GFP_KERNEL); 347 + idata = kmalloc(sizeof(*idata), GFP_KERNEL); 344 348 if (!idata) { 345 349 err = -ENOMEM; 346 350 goto out; ··· 360 364 if (!idata->buf_bytes) 361 365 return idata; 362 366 363 - idata->buf = kzalloc(idata->buf_bytes, GFP_KERNEL); 367 + idata->buf = kmalloc(idata->buf_bytes, GFP_KERNEL); 364 368 if (!idata->buf) { 365 369 err = -ENOMEM; 366 370 goto idata_err; ··· 2240 2244 md->disk->queue = md->queue.queue; 2241 2245 md->disk->driverfs_dev = parent; 2242 2246 set_disk_ro(md->disk, md->read_only || default_ro); 2247 + md->disk->flags = GENHD_FL_EXT_DEVT; 2243 2248 if (area_type & (MMC_BLK_DATA_AREA_RPMB | MMC_BLK_DATA_AREA_BOOT)) 2244 2249 md->disk->flags |= GENHD_FL_NO_PART_SCAN; 2245 2250
+2
drivers/mmc/core/bus.c
··· 349 349 350 350 card->dev.of_node = mmc_of_find_child_device(card->host, 0); 351 351 352 + device_enable_async_suspend(&card->dev); 353 + 352 354 ret = device_add(&card->dev); 353 355 if (ret) 354 356 return ret;
+43 -42
drivers/mmc/core/core.c
··· 55 55 */ 56 56 #define MMC_BKOPS_MAX_TIMEOUT (4 * 60 * 1000) /* max time to wait in ms */ 57 57 58 - static struct workqueue_struct *workqueue; 59 58 static const unsigned freqs[] = { 400000, 300000, 200000, 100000 }; 60 59 61 60 /* ··· 65 66 bool use_spi_crc = 1; 66 67 module_param(use_spi_crc, bool, 0); 67 68 68 - /* 69 - * Internal function. Schedule delayed work in the MMC work queue. 70 - */ 71 69 static int mmc_schedule_delayed_work(struct delayed_work *work, 72 70 unsigned long delay) 73 71 { 74 - return queue_delayed_work(workqueue, work, delay); 75 - } 76 - 77 - /* 78 - * Internal function. Flush all scheduled work from the MMC work queue. 79 - */ 80 - static void mmc_flush_scheduled_work(void) 81 - { 82 - flush_workqueue(workqueue); 72 + /* 73 + * We use the system_freezable_wq, because of two reasons. 74 + * First, it allows several works (not the same work item) to be 75 + * executed simultaneously. Second, the queue becomes frozen when 76 + * userspace becomes frozen during system PM. 77 + */ 78 + return queue_delayed_work(system_freezable_wq, work, delay); 83 79 } 84 80 85 81 #ifdef CONFIG_FAIL_MMC_REQUEST ··· 1479 1485 if (IS_ERR(mmc->supply.vmmc)) { 1480 1486 if (PTR_ERR(mmc->supply.vmmc) == -EPROBE_DEFER) 1481 1487 return -EPROBE_DEFER; 1482 - dev_info(dev, "No vmmc regulator found\n"); 1488 + dev_dbg(dev, "No vmmc regulator found\n"); 1483 1489 } else { 1484 1490 ret = mmc_regulator_get_ocrmask(mmc->supply.vmmc); 1485 1491 if (ret > 0) ··· 1491 1497 if (IS_ERR(mmc->supply.vqmmc)) { 1492 1498 if (PTR_ERR(mmc->supply.vqmmc) == -EPROBE_DEFER) 1493 1499 return -EPROBE_DEFER; 1494 - dev_info(dev, "No vqmmc regulator found\n"); 1500 + dev_dbg(dev, "No vqmmc regulator found\n"); 1495 1501 } 1496 1502 1497 1503 return 0; ··· 2470 2476 * sdio_reset sends CMD52 to reset card. Since we do not know 2471 2477 * if the card is being re-initialized, just send it. CMD52 2472 2478 * should be ignored by SD/eMMC cards. 2479 + * Skip it if we already know that we do not support SDIO commands 2473 2480 */ 2474 - sdio_reset(host); 2481 + if (!(host->caps2 & MMC_CAP2_NO_SDIO)) 2482 + sdio_reset(host); 2483 + 2475 2484 mmc_go_idle(host); 2476 2485 2477 2486 mmc_send_if_cond(host, host->ocr_avail); 2478 2487 2479 2488 /* Order's important: probe SDIO, then SD, then MMC */ 2480 - if (!mmc_attach_sdio(host)) 2481 - return 0; 2489 + if (!(host->caps2 & MMC_CAP2_NO_SDIO)) 2490 + if (!mmc_attach_sdio(host)) 2491 + return 0; 2492 + 2482 2493 if (!mmc_attach_sd(host)) 2483 2494 return 0; 2484 2495 if (!mmc_attach_mmc(host)) ··· 2496 2497 int _mmc_detect_card_removed(struct mmc_host *host) 2497 2498 { 2498 2499 int ret; 2499 - 2500 - if (host->caps & MMC_CAP_NONREMOVABLE) 2501 - return 0; 2502 2500 2503 2501 if (!host->card || mmc_card_removed(host->card)) 2504 2502 return 1; ··· 2532 2536 if (!card) 2533 2537 return 1; 2534 2538 2539 + if (host->caps & MMC_CAP_NONREMOVABLE) 2540 + return 0; 2541 + 2535 2542 ret = mmc_card_removed(card); 2536 2543 /* 2537 2544 * The card will be considered unchanged unless we have been asked to ··· 2566 2567 container_of(work, struct mmc_host, detect.work); 2567 2568 int i; 2568 2569 2569 - if (host->trigger_card_event && host->ops->card_event) { 2570 - host->ops->card_event(host); 2571 - host->trigger_card_event = false; 2572 - } 2573 - 2574 2570 if (host->rescan_disable) 2575 2571 return; 2576 2572 ··· 2573 2579 if ((host->caps & MMC_CAP_NONREMOVABLE) && host->rescan_entered) 2574 2580 return; 2575 2581 host->rescan_entered = 1; 2582 + 2583 + if (host->trigger_card_event && host->ops->card_event) { 2584 + mmc_claim_host(host); 2585 + host->ops->card_event(host); 2586 + mmc_release_host(host); 2587 + host->trigger_card_event = false; 2588 + } 2576 2589 2577 2590 mmc_bus_get(host); 2578 2591 ··· 2612 2611 */ 2613 2612 mmc_bus_put(host); 2614 2613 2614 + mmc_claim_host(host); 2615 2615 if (!(host->caps & MMC_CAP_NONREMOVABLE) && host->ops->get_cd && 2616 2616 host->ops->get_cd(host) == 0) { 2617 - mmc_claim_host(host); 2618 2617 mmc_power_off(host); 2619 2618 mmc_release_host(host); 2620 2619 goto out; 2621 2620 } 2622 2621 2623 - mmc_claim_host(host); 2624 2622 for (i = 0; i < ARRAY_SIZE(freqs); i++) { 2625 2623 if (!mmc_rescan_try_freq(host, max(freqs[i], host->f_min))) 2626 2624 break; ··· 2663 2663 2664 2664 host->rescan_disable = 1; 2665 2665 cancel_delayed_work_sync(&host->detect); 2666 - mmc_flush_scheduled_work(); 2667 2666 2668 2667 /* clear pm flags now and let card drivers set them as needed */ 2669 2668 host->pm_flags = 0; ··· 2758 2759 } 2759 2760 EXPORT_SYMBOL(mmc_flush_cache); 2760 2761 2761 - #ifdef CONFIG_PM 2762 - 2762 + #ifdef CONFIG_PM_SLEEP 2763 2763 /* Do the card removal on suspend if card is assumed removeable 2764 2764 * Do that in pm notifier while userspace isn't yet frozen, so we will be able 2765 2765 to sync the card. 2766 2766 */ 2767 - int mmc_pm_notify(struct notifier_block *notify_block, 2768 - unsigned long mode, void *unused) 2767 + static int mmc_pm_notify(struct notifier_block *notify_block, 2768 + unsigned long mode, void *unused) 2769 2769 { 2770 2770 struct mmc_host *host = container_of( 2771 2771 notify_block, struct mmc_host, pm_notify); ··· 2811 2813 2812 2814 return 0; 2813 2815 } 2816 + 2817 + void mmc_register_pm_notifier(struct mmc_host *host) 2818 + { 2819 + host->pm_notify.notifier_call = mmc_pm_notify; 2820 + register_pm_notifier(&host->pm_notify); 2821 + } 2822 + 2823 + void mmc_unregister_pm_notifier(struct mmc_host *host) 2824 + { 2825 + unregister_pm_notifier(&host->pm_notify); 2826 + } 2814 2827 #endif 2815 2828 2816 2829 /** ··· 2845 2836 { 2846 2837 int ret; 2847 2838 2848 - workqueue = alloc_ordered_workqueue("kmmcd", 0); 2849 - if (!workqueue) 2850 - return -ENOMEM; 2851 - 2852 2839 ret = mmc_register_bus(); 2853 2840 if (ret) 2854 - goto destroy_workqueue; 2841 + return ret; 2855 2842 2856 2843 ret = mmc_register_host_class(); 2857 2844 if (ret) ··· 2863 2858 mmc_unregister_host_class(); 2864 2859 unregister_bus: 2865 2860 mmc_unregister_bus(); 2866 - destroy_workqueue: 2867 - destroy_workqueue(workqueue); 2868 - 2869 2861 return ret; 2870 2862 } 2871 2863 ··· 2871 2869 sdio_unregister_bus(); 2872 2870 mmc_unregister_host_class(); 2873 2871 mmc_unregister_bus(); 2874 - destroy_workqueue(workqueue); 2875 2872 } 2876 2873 2877 2874 subsys_initcall(mmc_init);
+8
drivers/mmc/core/core.h
··· 90 90 int mmc_hs200_to_hs400(struct mmc_card *card); 91 91 int mmc_hs400_to_hs200(struct mmc_card *card); 92 92 93 + #ifdef CONFIG_PM_SLEEP 94 + void mmc_register_pm_notifier(struct mmc_host *host); 95 + void mmc_unregister_pm_notifier(struct mmc_host *host); 96 + #else 97 + static inline void mmc_register_pm_notifier(struct mmc_host *host) { } 98 + static inline void mmc_unregister_pm_notifier(struct mmc_host *host) { } 99 + #endif 100 + 93 101 #endif 94 102
+4 -7
drivers/mmc/core/host.c
··· 21 21 #include <linux/export.h> 22 22 #include <linux/leds.h> 23 23 #include <linux/slab.h> 24 - #include <linux/suspend.h> 25 24 26 25 #include <linux/mmc/host.h> 27 26 #include <linux/mmc/card.h> ··· 274 275 host->caps2 |= MMC_CAP2_FULL_PWR_CYCLE; 275 276 if (of_property_read_bool(np, "keep-power-in-suspend")) 276 277 host->pm_caps |= MMC_PM_KEEP_POWER; 277 - if (of_property_read_bool(np, "enable-sdio-wakeup")) 278 + if (of_property_read_bool(np, "wakeup-source") || 279 + of_property_read_bool(np, "enable-sdio-wakeup")) /* legacy */ 278 280 host->pm_caps |= MMC_PM_WAKE_SDIO_IRQ; 279 281 if (of_property_read_bool(np, "mmc-ddr-1_8v")) 280 282 host->caps |= MMC_CAP_1_8V_DDR; ··· 348 348 spin_lock_init(&host->lock); 349 349 init_waitqueue_head(&host->wq); 350 350 INIT_DELAYED_WORK(&host->detect, mmc_rescan); 351 - #ifdef CONFIG_PM 352 - host->pm_notify.notifier_call = mmc_pm_notify; 353 - #endif 354 351 setup_timer(&host->retune_timer, mmc_retune_timer, (unsigned long)host); 355 352 356 353 /* ··· 392 395 #endif 393 396 394 397 mmc_start_host(host); 395 - register_pm_notifier(&host->pm_notify); 398 + mmc_register_pm_notifier(host); 396 399 397 400 return 0; 398 401 } ··· 409 412 */ 410 413 void mmc_remove_host(struct mmc_host *host) 411 414 { 412 - unregister_pm_notifier(&host->pm_notify); 415 + mmc_unregister_pm_notifier(host); 413 416 mmc_stop_host(host); 414 417 415 418 #ifdef CONFIG_DEBUG_FS
+5 -18
drivers/mmc/core/mmc.c
··· 1076 1076 mmc_set_clock(host, max_dtr); 1077 1077 1078 1078 /* Switch card to HS mode */ 1079 - val = EXT_CSD_TIMING_HS | 1080 - card->drive_strength << EXT_CSD_DRV_STR_SHIFT; 1079 + val = EXT_CSD_TIMING_HS; 1081 1080 err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, 1082 1081 EXT_CSD_HS_TIMING, val, 1083 1082 card->ext_csd.generic_cmd6_time, ··· 1159 1160 mmc_set_clock(host, max_dtr); 1160 1161 1161 1162 /* Switch HS400 to HS DDR */ 1162 - val = EXT_CSD_TIMING_HS | 1163 - card->drive_strength << EXT_CSD_DRV_STR_SHIFT; 1163 + val = EXT_CSD_TIMING_HS; 1164 1164 err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_HS_TIMING, 1165 1165 val, card->ext_csd.generic_cmd6_time, 1166 1166 true, send_status, true); ··· 1905 1907 */ 1906 1908 static int mmc_resume(struct mmc_host *host) 1907 1909 { 1908 - int err = 0; 1909 - 1910 - if (!(host->caps & MMC_CAP_RUNTIME_RESUME)) { 1911 - err = _mmc_resume(host); 1912 - pm_runtime_set_active(&host->card->dev); 1913 - pm_runtime_mark_last_busy(&host->card->dev); 1914 - } 1915 1910 pm_runtime_enable(&host->card->dev); 1916 - 1917 - return err; 1911 + return 0; 1918 1912 } 1919 1913 1920 1914 /* ··· 1934 1944 { 1935 1945 int err; 1936 1946 1937 - if (!(host->caps & (MMC_CAP_AGGRESSIVE_PM | MMC_CAP_RUNTIME_RESUME))) 1938 - return 0; 1939 - 1940 1947 err = _mmc_resume(host); 1941 - if (err) 1942 - pr_err("%s: error %d doing aggressive resume\n", 1948 + if (err && err != -ENOMEDIUM) 1949 + pr_err("%s: error %d doing runtime resume\n", 1943 1950 mmc_hostname(host), err); 1944 1951 1945 1952 return 0;
+8 -1
drivers/mmc/core/mmc_ops.c
··· 489 489 unsigned long timeout; 490 490 u32 status = 0; 491 491 bool use_r1b_resp = use_busy_signal; 492 + bool expired = false; 492 493 493 494 mmc_retune_hold(host); 494 495 ··· 546 545 timeout = jiffies + msecs_to_jiffies(timeout_ms); 547 546 do { 548 547 if (send_status) { 548 + /* 549 + * Due to the possibility of being preempted after 550 + * sending the status command, check the expiration 551 + * time first. 552 + */ 553 + expired = time_after(jiffies, timeout); 549 554 err = __mmc_send_status(card, &status, ignore_crc); 550 555 if (err) 551 556 goto out; ··· 572 565 } 573 566 574 567 /* Timeout if the device never leaves the program state. */ 575 - if (time_after(jiffies, timeout)) { 568 + if (expired && R1_CURRENT_STATE(status) == R1_STATE_PRG) { 576 569 pr_err("%s: Card stuck in programming state! %s\n", 577 570 mmc_hostname(host), __func__); 578 571 err = -ETIMEDOUT;
+1 -1
drivers/mmc/core/pwrseq.h
··· 16 16 }; 17 17 18 18 struct mmc_pwrseq { 19 - struct mmc_pwrseq_ops *ops; 19 + const struct mmc_pwrseq_ops *ops; 20 20 }; 21 21 22 22 #ifdef CONFIG_OF
+1 -1
drivers/mmc/core/pwrseq_emmc.c
··· 51 51 kfree(pwrseq); 52 52 } 53 53 54 - static struct mmc_pwrseq_ops mmc_pwrseq_emmc_ops = { 54 + static const struct mmc_pwrseq_ops mmc_pwrseq_emmc_ops = { 55 55 .post_power_on = mmc_pwrseq_emmc_reset, 56 56 .free = mmc_pwrseq_emmc_free, 57 57 };
+1 -1
drivers/mmc/core/pwrseq_simple.c
··· 87 87 kfree(pwrseq); 88 88 } 89 89 90 - static struct mmc_pwrseq_ops mmc_pwrseq_simple_ops = { 90 + static const struct mmc_pwrseq_ops mmc_pwrseq_simple_ops = { 91 91 .pre_power_on = mmc_pwrseq_simple_pre_power_on, 92 92 .post_power_on = mmc_pwrseq_simple_post_power_on, 93 93 .power_off = mmc_pwrseq_simple_power_off,
+3 -14
drivers/mmc/core/sd.c
··· 1128 1128 */ 1129 1129 static int mmc_sd_resume(struct mmc_host *host) 1130 1130 { 1131 - int err = 0; 1132 - 1133 - if (!(host->caps & MMC_CAP_RUNTIME_RESUME)) { 1134 - err = _mmc_sd_resume(host); 1135 - pm_runtime_set_active(&host->card->dev); 1136 - pm_runtime_mark_last_busy(&host->card->dev); 1137 - } 1138 1131 pm_runtime_enable(&host->card->dev); 1139 - 1140 - return err; 1132 + return 0; 1141 1133 } 1142 1134 1143 1135 /* ··· 1157 1165 { 1158 1166 int err; 1159 1167 1160 - if (!(host->caps & (MMC_CAP_AGGRESSIVE_PM | MMC_CAP_RUNTIME_RESUME))) 1161 - return 0; 1162 - 1163 1168 err = _mmc_sd_resume(host); 1164 - if (err) 1165 - pr_err("%s: error %d doing aggressive resume\n", 1169 + if (err && err != -ENOMEDIUM) 1170 + pr_err("%s: error %d doing runtime resume\n", 1166 1171 mmc_hostname(host), err); 1167 1172 1168 1173 return 0;
+1 -1
drivers/mmc/core/sdio.c
··· 630 630 */ 631 631 if (!powered_resume && (rocr & ocr & R4_18V_PRESENT)) { 632 632 err = mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_180, 633 - ocr); 633 + ocr_card); 634 634 if (err == -EAGAIN) { 635 635 sdio_reset(host); 636 636 mmc_go_idle(host);
+1
drivers/mmc/core/sdio_bus.c
··· 322 322 323 323 sdio_set_of_node(func); 324 324 sdio_acpi_set_handle(func); 325 + device_enable_async_suspend(&func->dev); 325 326 ret = device_add(&func->dev); 326 327 if (ret == 0) 327 328 sdio_func_set_present(func);
+1
drivers/mmc/host/Kconfig
··· 455 455 config MMC_MVSDIO 456 456 tristate "Marvell MMC/SD/SDIO host driver" 457 457 depends on PLAT_ORION 458 + depends on OF 458 459 ---help--- 459 460 This selects the Marvell SDIO host driver. 460 461 SDIO may currently be found on the Kirkwood 88F6281 and 88F6192
-171
drivers/mmc/host/atmel-mci-regs.h
··· 1 - /* 2 - * Atmel MultiMedia Card Interface driver 3 - * 4 - * Copyright (C) 2004-2006 Atmel Corporation 5 - * 6 - * This program is free software; you can redistribute it and/or modify 7 - * it under the terms of the GNU General Public License version 2 as 8 - * published by the Free Software Foundation. 9 - */ 10 - 11 - /* 12 - * Superset of MCI IP registers integrated in Atmel AVR32 and AT91 Processors 13 - * Registers and bitfields marked with [2] are only available in MCI2 14 - */ 15 - 16 - #ifndef __DRIVERS_MMC_ATMEL_MCI_H__ 17 - #define __DRIVERS_MMC_ATMEL_MCI_H__ 18 - 19 - /* MCI Register Definitions */ 20 - #define ATMCI_CR 0x0000 /* Control */ 21 - # define ATMCI_CR_MCIEN ( 1 << 0) /* MCI Enable */ 22 - # define ATMCI_CR_MCIDIS ( 1 << 1) /* MCI Disable */ 23 - # define ATMCI_CR_PWSEN ( 1 << 2) /* Power Save Enable */ 24 - # define ATMCI_CR_PWSDIS ( 1 << 3) /* Power Save Disable */ 25 - # define ATMCI_CR_SWRST ( 1 << 7) /* Software Reset */ 26 - #define ATMCI_MR 0x0004 /* Mode */ 27 - # define ATMCI_MR_CLKDIV(x) ((x) << 0) /* Clock Divider */ 28 - # define ATMCI_MR_PWSDIV(x) ((x) << 8) /* Power Saving Divider */ 29 - # define ATMCI_MR_RDPROOF ( 1 << 11) /* Read Proof */ 30 - # define ATMCI_MR_WRPROOF ( 1 << 12) /* Write Proof */ 31 - # define ATMCI_MR_PDCFBYTE ( 1 << 13) /* Force Byte Transfer */ 32 - # define ATMCI_MR_PDCPADV ( 1 << 14) /* Padding Value */ 33 - # define ATMCI_MR_PDCMODE ( 1 << 15) /* PDC-oriented Mode */ 34 - # define ATMCI_MR_CLKODD(x) ((x) << 16) /* LSB of Clock Divider */ 35 - #define ATMCI_DTOR 0x0008 /* Data Timeout */ 36 - # define ATMCI_DTOCYC(x) ((x) << 0) /* Data Timeout Cycles */ 37 - # define ATMCI_DTOMUL(x) ((x) << 4) /* Data Timeout Multiplier */ 38 - #define ATMCI_SDCR 0x000c /* SD Card / SDIO */ 39 - # define ATMCI_SDCSEL_SLOT_A ( 0 << 0) /* Select SD slot A */ 40 - # define ATMCI_SDCSEL_SLOT_B ( 1 << 0) /* Select SD slot A */ 41 - # define ATMCI_SDCSEL_MASK ( 3 << 0) 42 - # define ATMCI_SDCBUS_1BIT ( 0 << 6) /* 1-bit data bus */ 43 - # define ATMCI_SDCBUS_4BIT ( 2 << 6) /* 4-bit data bus */ 44 - # define ATMCI_SDCBUS_8BIT ( 3 << 6) /* 8-bit data bus[2] */ 45 - # define ATMCI_SDCBUS_MASK ( 3 << 6) 46 - #define ATMCI_ARGR 0x0010 /* Command Argument */ 47 - #define ATMCI_CMDR 0x0014 /* Command */ 48 - # define ATMCI_CMDR_CMDNB(x) ((x) << 0) /* Command Opcode */ 49 - # define ATMCI_CMDR_RSPTYP_NONE ( 0 << 6) /* No response */ 50 - # define ATMCI_CMDR_RSPTYP_48BIT ( 1 << 6) /* 48-bit response */ 51 - # define ATMCI_CMDR_RSPTYP_136BIT ( 2 << 6) /* 136-bit response */ 52 - # define ATMCI_CMDR_SPCMD_INIT ( 1 << 8) /* Initialization command */ 53 - # define ATMCI_CMDR_SPCMD_SYNC ( 2 << 8) /* Synchronized command */ 54 - # define ATMCI_CMDR_SPCMD_INT ( 4 << 8) /* Interrupt command */ 55 - # define ATMCI_CMDR_SPCMD_INTRESP ( 5 << 8) /* Interrupt response */ 56 - # define ATMCI_CMDR_OPDCMD ( 1 << 11) /* Open Drain */ 57 - # define ATMCI_CMDR_MAXLAT_5CYC ( 0 << 12) /* Max latency 5 cycles */ 58 - # define ATMCI_CMDR_MAXLAT_64CYC ( 1 << 12) /* Max latency 64 cycles */ 59 - # define ATMCI_CMDR_START_XFER ( 1 << 16) /* Start data transfer */ 60 - # define ATMCI_CMDR_STOP_XFER ( 2 << 16) /* Stop data transfer */ 61 - # define ATMCI_CMDR_TRDIR_WRITE ( 0 << 18) /* Write data */ 62 - # define ATMCI_CMDR_TRDIR_READ ( 1 << 18) /* Read data */ 63 - # define ATMCI_CMDR_BLOCK ( 0 << 19) /* Single-block transfer */ 64 - # define ATMCI_CMDR_MULTI_BLOCK ( 1 << 19) /* Multi-block transfer */ 65 - # define ATMCI_CMDR_STREAM ( 2 << 19) /* MMC Stream transfer */ 66 - # define ATMCI_CMDR_SDIO_BYTE ( 4 << 19) /* SDIO Byte transfer */ 67 - # define ATMCI_CMDR_SDIO_BLOCK ( 5 << 19) /* SDIO Block transfer */ 68 - # define ATMCI_CMDR_SDIO_SUSPEND ( 1 << 24) /* SDIO Suspend Command */ 69 - # define ATMCI_CMDR_SDIO_RESUME ( 2 << 24) /* SDIO Resume Command */ 70 - #define ATMCI_BLKR 0x0018 /* Block */ 71 - # define ATMCI_BCNT(x) ((x) << 0) /* Data Block Count */ 72 - # define ATMCI_BLKLEN(x) ((x) << 16) /* Data Block Length */ 73 - #define ATMCI_CSTOR 0x001c /* Completion Signal Timeout[2] */ 74 - # define ATMCI_CSTOCYC(x) ((x) << 0) /* CST cycles */ 75 - # define ATMCI_CSTOMUL(x) ((x) << 4) /* CST multiplier */ 76 - #define ATMCI_RSPR 0x0020 /* Response 0 */ 77 - #define ATMCI_RSPR1 0x0024 /* Response 1 */ 78 - #define ATMCI_RSPR2 0x0028 /* Response 2 */ 79 - #define ATMCI_RSPR3 0x002c /* Response 3 */ 80 - #define ATMCI_RDR 0x0030 /* Receive Data */ 81 - #define ATMCI_TDR 0x0034 /* Transmit Data */ 82 - #define ATMCI_SR 0x0040 /* Status */ 83 - #define ATMCI_IER 0x0044 /* Interrupt Enable */ 84 - #define ATMCI_IDR 0x0048 /* Interrupt Disable */ 85 - #define ATMCI_IMR 0x004c /* Interrupt Mask */ 86 - # define ATMCI_CMDRDY ( 1 << 0) /* Command Ready */ 87 - # define ATMCI_RXRDY ( 1 << 1) /* Receiver Ready */ 88 - # define ATMCI_TXRDY ( 1 << 2) /* Transmitter Ready */ 89 - # define ATMCI_BLKE ( 1 << 3) /* Data Block Ended */ 90 - # define ATMCI_DTIP ( 1 << 4) /* Data Transfer In Progress */ 91 - # define ATMCI_NOTBUSY ( 1 << 5) /* Data Not Busy */ 92 - # define ATMCI_ENDRX ( 1 << 6) /* End of RX Buffer */ 93 - # define ATMCI_ENDTX ( 1 << 7) /* End of TX Buffer */ 94 - # define ATMCI_SDIOIRQA ( 1 << 8) /* SDIO IRQ in slot A */ 95 - # define ATMCI_SDIOIRQB ( 1 << 9) /* SDIO IRQ in slot B */ 96 - # define ATMCI_SDIOWAIT ( 1 << 12) /* SDIO Read Wait Operation Status */ 97 - # define ATMCI_CSRCV ( 1 << 13) /* CE-ATA Completion Signal Received */ 98 - # define ATMCI_RXBUFF ( 1 << 14) /* RX Buffer Full */ 99 - # define ATMCI_TXBUFE ( 1 << 15) /* TX Buffer Empty */ 100 - # define ATMCI_RINDE ( 1 << 16) /* Response Index Error */ 101 - # define ATMCI_RDIRE ( 1 << 17) /* Response Direction Error */ 102 - # define ATMCI_RCRCE ( 1 << 18) /* Response CRC Error */ 103 - # define ATMCI_RENDE ( 1 << 19) /* Response End Bit Error */ 104 - # define ATMCI_RTOE ( 1 << 20) /* Response Time-Out Error */ 105 - # define ATMCI_DCRCE ( 1 << 21) /* Data CRC Error */ 106 - # define ATMCI_DTOE ( 1 << 22) /* Data Time-Out Error */ 107 - # define ATMCI_CSTOE ( 1 << 23) /* Completion Signal Time-out Error */ 108 - # define ATMCI_BLKOVRE ( 1 << 24) /* DMA Block Overrun Error */ 109 - # define ATMCI_DMADONE ( 1 << 25) /* DMA Transfer Done */ 110 - # define ATMCI_FIFOEMPTY ( 1 << 26) /* FIFO Empty Flag */ 111 - # define ATMCI_XFRDONE ( 1 << 27) /* Transfer Done Flag */ 112 - # define ATMCI_ACKRCV ( 1 << 28) /* Boot Operation Acknowledge Received */ 113 - # define ATMCI_ACKRCVE ( 1 << 29) /* Boot Operation Acknowledge Error */ 114 - # define ATMCI_OVRE ( 1 << 30) /* RX Overrun Error */ 115 - # define ATMCI_UNRE ( 1 << 31) /* TX Underrun Error */ 116 - #define ATMCI_DMA 0x0050 /* DMA Configuration[2] */ 117 - # define ATMCI_DMA_OFFSET(x) ((x) << 0) /* DMA Write Buffer Offset */ 118 - # define ATMCI_DMA_CHKSIZE(x) ((x) << 4) /* DMA Channel Read and Write Chunk Size */ 119 - # define ATMCI_DMAEN ( 1 << 8) /* DMA Hardware Handshaking Enable */ 120 - #define ATMCI_CFG 0x0054 /* Configuration[2] */ 121 - # define ATMCI_CFG_FIFOMODE_1DATA ( 1 << 0) /* MCI Internal FIFO control mode */ 122 - # define ATMCI_CFG_FERRCTRL_COR ( 1 << 4) /* Flow Error flag reset control mode */ 123 - # define ATMCI_CFG_HSMODE ( 1 << 8) /* High Speed Mode */ 124 - # define ATMCI_CFG_LSYNC ( 1 << 12) /* Synchronize on the last block */ 125 - #define ATMCI_WPMR 0x00e4 /* Write Protection Mode[2] */ 126 - # define ATMCI_WP_EN ( 1 << 0) /* WP Enable */ 127 - # define ATMCI_WP_KEY (0x4d4349 << 8) /* WP Key */ 128 - #define ATMCI_WPSR 0x00e8 /* Write Protection Status[2] */ 129 - # define ATMCI_GET_WP_VS(x) ((x) & 0x0f) 130 - # define ATMCI_GET_WP_VSRC(x) (((x) >> 8) & 0xffff) 131 - #define ATMCI_VERSION 0x00FC /* Version */ 132 - #define ATMCI_FIFO_APERTURE 0x0200 /* FIFO Aperture[2] */ 133 - 134 - /* This is not including the FIFO Aperture on MCI2 */ 135 - #define ATMCI_REGS_SIZE 0x100 136 - 137 - /* Register access macros */ 138 - #ifdef CONFIG_AVR32 139 - #define atmci_readl(port, reg) \ 140 - __raw_readl((port)->regs + reg) 141 - #define atmci_writel(port, reg, value) \ 142 - __raw_writel((value), (port)->regs + reg) 143 - #else 144 - #define atmci_readl(port, reg) \ 145 - readl_relaxed((port)->regs + reg) 146 - #define atmci_writel(port, reg, value) \ 147 - writel_relaxed((value), (port)->regs + reg) 148 - #endif 149 - 150 - /* On AVR chips the Peripheral DMA Controller is not connected to MCI. */ 151 - #ifdef CONFIG_AVR32 152 - # define ATMCI_PDC_CONNECTED 0 153 - #else 154 - # define ATMCI_PDC_CONNECTED 1 155 - #endif 156 - 157 - /* 158 - * Fix sconfig's burst size according to atmel MCI. We need to convert them as: 159 - * 1 -> 0, 4 -> 1, 8 -> 2, 16 -> 3. 160 - * 161 - * This can be done by finding most significant bit set. 162 - */ 163 - static inline unsigned int atmci_convert_chksize(unsigned int maxburst) 164 - { 165 - if (maxburst > 1) 166 - return fls(maxburst) - 2; 167 - else 168 - return 0; 169 - } 170 - 171 - #endif /* __DRIVERS_MMC_ATMEL_MCI_H__ */
+162 -3
drivers/mmc/host/atmel-mci.c
··· 44 44 #include <asm/io.h> 45 45 #include <asm/unaligned.h> 46 46 47 - #include "atmel-mci-regs.h" 47 + /* 48 + * Superset of MCI IP registers integrated in Atmel AVR32 and AT91 Processors 49 + * Registers and bitfields marked with [2] are only available in MCI2 50 + */ 51 + 52 + /* MCI Register Definitions */ 53 + #define ATMCI_CR 0x0000 /* Control */ 54 + #define ATMCI_CR_MCIEN BIT(0) /* MCI Enable */ 55 + #define ATMCI_CR_MCIDIS BIT(1) /* MCI Disable */ 56 + #define ATMCI_CR_PWSEN BIT(2) /* Power Save Enable */ 57 + #define ATMCI_CR_PWSDIS BIT(3) /* Power Save Disable */ 58 + #define ATMCI_CR_SWRST BIT(7) /* Software Reset */ 59 + #define ATMCI_MR 0x0004 /* Mode */ 60 + #define ATMCI_MR_CLKDIV(x) ((x) << 0) /* Clock Divider */ 61 + #define ATMCI_MR_PWSDIV(x) ((x) << 8) /* Power Saving Divider */ 62 + #define ATMCI_MR_RDPROOF BIT(11) /* Read Proof */ 63 + #define ATMCI_MR_WRPROOF BIT(12) /* Write Proof */ 64 + #define ATMCI_MR_PDCFBYTE BIT(13) /* Force Byte Transfer */ 65 + #define ATMCI_MR_PDCPADV BIT(14) /* Padding Value */ 66 + #define ATMCI_MR_PDCMODE BIT(15) /* PDC-oriented Mode */ 67 + #define ATMCI_MR_CLKODD(x) ((x) << 16) /* LSB of Clock Divider */ 68 + #define ATMCI_DTOR 0x0008 /* Data Timeout */ 69 + #define ATMCI_DTOCYC(x) ((x) << 0) /* Data Timeout Cycles */ 70 + #define ATMCI_DTOMUL(x) ((x) << 4) /* Data Timeout Multiplier */ 71 + #define ATMCI_SDCR 0x000c /* SD Card / SDIO */ 72 + #define ATMCI_SDCSEL_SLOT_A (0 << 0) /* Select SD slot A */ 73 + #define ATMCI_SDCSEL_SLOT_B (1 << 0) /* Select SD slot A */ 74 + #define ATMCI_SDCSEL_MASK (3 << 0) 75 + #define ATMCI_SDCBUS_1BIT (0 << 6) /* 1-bit data bus */ 76 + #define ATMCI_SDCBUS_4BIT (2 << 6) /* 4-bit data bus */ 77 + #define ATMCI_SDCBUS_8BIT (3 << 6) /* 8-bit data bus[2] */ 78 + #define ATMCI_SDCBUS_MASK (3 << 6) 79 + #define ATMCI_ARGR 0x0010 /* Command Argument */ 80 + #define ATMCI_CMDR 0x0014 /* Command */ 81 + #define ATMCI_CMDR_CMDNB(x) ((x) << 0) /* Command Opcode */ 82 + #define ATMCI_CMDR_RSPTYP_NONE (0 << 6) /* No response */ 83 + #define ATMCI_CMDR_RSPTYP_48BIT (1 << 6) /* 48-bit response */ 84 + #define ATMCI_CMDR_RSPTYP_136BIT (2 << 6) /* 136-bit response */ 85 + #define ATMCI_CMDR_SPCMD_INIT (1 << 8) /* Initialization command */ 86 + #define ATMCI_CMDR_SPCMD_SYNC (2 << 8) /* Synchronized command */ 87 + #define ATMCI_CMDR_SPCMD_INT (4 << 8) /* Interrupt command */ 88 + #define ATMCI_CMDR_SPCMD_INTRESP (5 << 8) /* Interrupt response */ 89 + #define ATMCI_CMDR_OPDCMD (1 << 11) /* Open Drain */ 90 + #define ATMCI_CMDR_MAXLAT_5CYC (0 << 12) /* Max latency 5 cycles */ 91 + #define ATMCI_CMDR_MAXLAT_64CYC (1 << 12) /* Max latency 64 cycles */ 92 + #define ATMCI_CMDR_START_XFER (1 << 16) /* Start data transfer */ 93 + #define ATMCI_CMDR_STOP_XFER (2 << 16) /* Stop data transfer */ 94 + #define ATMCI_CMDR_TRDIR_WRITE (0 << 18) /* Write data */ 95 + #define ATMCI_CMDR_TRDIR_READ (1 << 18) /* Read data */ 96 + #define ATMCI_CMDR_BLOCK (0 << 19) /* Single-block transfer */ 97 + #define ATMCI_CMDR_MULTI_BLOCK (1 << 19) /* Multi-block transfer */ 98 + #define ATMCI_CMDR_STREAM (2 << 19) /* MMC Stream transfer */ 99 + #define ATMCI_CMDR_SDIO_BYTE (4 << 19) /* SDIO Byte transfer */ 100 + #define ATMCI_CMDR_SDIO_BLOCK (5 << 19) /* SDIO Block transfer */ 101 + #define ATMCI_CMDR_SDIO_SUSPEND (1 << 24) /* SDIO Suspend Command */ 102 + #define ATMCI_CMDR_SDIO_RESUME (2 << 24) /* SDIO Resume Command */ 103 + #define ATMCI_BLKR 0x0018 /* Block */ 104 + #define ATMCI_BCNT(x) ((x) << 0) /* Data Block Count */ 105 + #define ATMCI_BLKLEN(x) ((x) << 16) /* Data Block Length */ 106 + #define ATMCI_CSTOR 0x001c /* Completion Signal Timeout[2] */ 107 + #define ATMCI_CSTOCYC(x) ((x) << 0) /* CST cycles */ 108 + #define ATMCI_CSTOMUL(x) ((x) << 4) /* CST multiplier */ 109 + #define ATMCI_RSPR 0x0020 /* Response 0 */ 110 + #define ATMCI_RSPR1 0x0024 /* Response 1 */ 111 + #define ATMCI_RSPR2 0x0028 /* Response 2 */ 112 + #define ATMCI_RSPR3 0x002c /* Response 3 */ 113 + #define ATMCI_RDR 0x0030 /* Receive Data */ 114 + #define ATMCI_TDR 0x0034 /* Transmit Data */ 115 + #define ATMCI_SR 0x0040 /* Status */ 116 + #define ATMCI_IER 0x0044 /* Interrupt Enable */ 117 + #define ATMCI_IDR 0x0048 /* Interrupt Disable */ 118 + #define ATMCI_IMR 0x004c /* Interrupt Mask */ 119 + #define ATMCI_CMDRDY BIT(0) /* Command Ready */ 120 + #define ATMCI_RXRDY BIT(1) /* Receiver Ready */ 121 + #define ATMCI_TXRDY BIT(2) /* Transmitter Ready */ 122 + #define ATMCI_BLKE BIT(3) /* Data Block Ended */ 123 + #define ATMCI_DTIP BIT(4) /* Data Transfer In Progress */ 124 + #define ATMCI_NOTBUSY BIT(5) /* Data Not Busy */ 125 + #define ATMCI_ENDRX BIT(6) /* End of RX Buffer */ 126 + #define ATMCI_ENDTX BIT(7) /* End of TX Buffer */ 127 + #define ATMCI_SDIOIRQA BIT(8) /* SDIO IRQ in slot A */ 128 + #define ATMCI_SDIOIRQB BIT(9) /* SDIO IRQ in slot B */ 129 + #define ATMCI_SDIOWAIT BIT(12) /* SDIO Read Wait Operation Status */ 130 + #define ATMCI_CSRCV BIT(13) /* CE-ATA Completion Signal Received */ 131 + #define ATMCI_RXBUFF BIT(14) /* RX Buffer Full */ 132 + #define ATMCI_TXBUFE BIT(15) /* TX Buffer Empty */ 133 + #define ATMCI_RINDE BIT(16) /* Response Index Error */ 134 + #define ATMCI_RDIRE BIT(17) /* Response Direction Error */ 135 + #define ATMCI_RCRCE BIT(18) /* Response CRC Error */ 136 + #define ATMCI_RENDE BIT(19) /* Response End Bit Error */ 137 + #define ATMCI_RTOE BIT(20) /* Response Time-Out Error */ 138 + #define ATMCI_DCRCE BIT(21) /* Data CRC Error */ 139 + #define ATMCI_DTOE BIT(22) /* Data Time-Out Error */ 140 + #define ATMCI_CSTOE BIT(23) /* Completion Signal Time-out Error */ 141 + #define ATMCI_BLKOVRE BIT(24) /* DMA Block Overrun Error */ 142 + #define ATMCI_DMADONE BIT(25) /* DMA Transfer Done */ 143 + #define ATMCI_FIFOEMPTY BIT(26) /* FIFO Empty Flag */ 144 + #define ATMCI_XFRDONE BIT(27) /* Transfer Done Flag */ 145 + #define ATMCI_ACKRCV BIT(28) /* Boot Operation Acknowledge Received */ 146 + #define ATMCI_ACKRCVE BIT(29) /* Boot Operation Acknowledge Error */ 147 + #define ATMCI_OVRE BIT(30) /* RX Overrun Error */ 148 + #define ATMCI_UNRE BIT(31) /* TX Underrun Error */ 149 + #define ATMCI_DMA 0x0050 /* DMA Configuration[2] */ 150 + #define ATMCI_DMA_OFFSET(x) ((x) << 0) /* DMA Write Buffer Offset */ 151 + #define ATMCI_DMA_CHKSIZE(x) ((x) << 4) /* DMA Channel Read and Write Chunk Size */ 152 + #define ATMCI_DMAEN BIT(8) /* DMA Hardware Handshaking Enable */ 153 + #define ATMCI_CFG 0x0054 /* Configuration[2] */ 154 + #define ATMCI_CFG_FIFOMODE_1DATA BIT(0) /* MCI Internal FIFO control mode */ 155 + #define ATMCI_CFG_FERRCTRL_COR BIT(4) /* Flow Error flag reset control mode */ 156 + #define ATMCI_CFG_HSMODE BIT(8) /* High Speed Mode */ 157 + #define ATMCI_CFG_LSYNC BIT(12) /* Synchronize on the last block */ 158 + #define ATMCI_WPMR 0x00e4 /* Write Protection Mode[2] */ 159 + #define ATMCI_WP_EN BIT(0) /* WP Enable */ 160 + #define ATMCI_WP_KEY (0x4d4349 << 8) /* WP Key */ 161 + #define ATMCI_WPSR 0x00e8 /* Write Protection Status[2] */ 162 + #define ATMCI_GET_WP_VS(x) ((x) & 0x0f) 163 + #define ATMCI_GET_WP_VSRC(x) (((x) >> 8) & 0xffff) 164 + #define ATMCI_VERSION 0x00FC /* Version */ 165 + #define ATMCI_FIFO_APERTURE 0x0200 /* FIFO Aperture[2] */ 166 + 167 + /* This is not including the FIFO Aperture on MCI2 */ 168 + #define ATMCI_REGS_SIZE 0x100 169 + 170 + /* Register access macros */ 171 + #define atmci_readl(port, reg) \ 172 + __raw_readl((port)->regs + reg) 173 + #define atmci_writel(port, reg, value) \ 174 + __raw_writel((value), (port)->regs + reg) 175 + 176 + /* On AVR chips the Peripheral DMA Controller is not connected to MCI. */ 177 + #ifdef CONFIG_AVR32 178 + # define ATMCI_PDC_CONNECTED 0 179 + #else 180 + # define ATMCI_PDC_CONNECTED 1 181 + #endif 48 182 49 183 #define AUTOSUSPEND_DELAY 50 50 184 ··· 718 584 return atmci_readl(host, ATMCI_VERSION) & 0x00000fff; 719 585 } 720 586 587 + /* 588 + * Fix sconfig's burst size according to atmel MCI. We need to convert them as: 589 + * 1 -> 0, 4 -> 1, 8 -> 2, 16 -> 3. 590 + * With version 0x600, we need to convert them as: 1 -> 0, 2 -> 1, 4 -> 2, 591 + * 8 -> 3, 16 -> 4. 592 + * 593 + * This can be done by finding most significant bit set. 594 + */ 595 + static inline unsigned int atmci_convert_chksize(struct atmel_mci *host, 596 + unsigned int maxburst) 597 + { 598 + unsigned int version = atmci_get_version(host); 599 + unsigned int offset = 2; 600 + 601 + if (version >= 0x600) 602 + offset = 1; 603 + 604 + if (maxburst > 1) 605 + return fls(maxburst) - offset; 606 + else 607 + return 0; 608 + } 609 + 721 610 static void atmci_timeout_timer(unsigned long data) 722 611 { 723 612 struct atmel_mci *host; ··· 1191 1034 if (data->flags & MMC_DATA_READ) { 1192 1035 direction = DMA_FROM_DEVICE; 1193 1036 host->dma_conf.direction = slave_dirn = DMA_DEV_TO_MEM; 1194 - maxburst = atmci_convert_chksize(host->dma_conf.src_maxburst); 1037 + maxburst = atmci_convert_chksize(host, 1038 + host->dma_conf.src_maxburst); 1195 1039 } else { 1196 1040 direction = DMA_TO_DEVICE; 1197 1041 host->dma_conf.direction = slave_dirn = DMA_MEM_TO_DEV; 1198 - maxburst = atmci_convert_chksize(host->dma_conf.dst_maxburst); 1042 + maxburst = atmci_convert_chksize(host, 1043 + host->dma_conf.dst_maxburst); 1199 1044 } 1200 1045 1201 1046 if (host->caps.has_dma_conf_reg)
+1 -2
drivers/mmc/host/cb710-mmc.h
··· 29 29 30 30 static inline struct cb710_slot *cb710_mmc_to_slot(struct mmc_host *mmc) 31 31 { 32 - struct platform_device *pdev = container_of(mmc_dev(mmc), 33 - struct platform_device, dev); 32 + struct platform_device *pdev = to_platform_device(mmc_dev(mmc)); 34 33 return cb710_pdev_to_slot(pdev); 35 34 } 36 35
+1 -1
drivers/mmc/host/dw_mmc-pltfm.c
··· 60 60 61 61 regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); 62 62 /* Get registers' physical base address */ 63 - host->phy_regs = (void *)(regs->start); 63 + host->phy_regs = regs->start; 64 64 host->regs = devm_ioremap_resource(&pdev->dev, regs); 65 65 if (IS_ERR(host->regs)) 66 66 return PTR_ERR(host->regs);
-8
drivers/mmc/host/dw_mmc-rockchip.c
··· 239 239 return 0; 240 240 } 241 241 242 - /* Common capabilities of RK3288 SoC */ 243 - static unsigned long dw_mci_rk3288_dwmmc_caps[4] = { 244 - MMC_CAP_RUNTIME_RESUME, /* emmc */ 245 - MMC_CAP_RUNTIME_RESUME, /* sdmmc */ 246 - MMC_CAP_RUNTIME_RESUME, /* sdio0 */ 247 - MMC_CAP_RUNTIME_RESUME, /* sdio1 */ 248 - }; 249 242 static const struct dw_mci_drv_data rk2928_drv_data = { 250 243 .prepare_command = dw_mci_rockchip_prepare_command, 251 244 .init = dw_mci_rockchip_init, 252 245 }; 253 246 254 247 static const struct dw_mci_drv_data rk3288_drv_data = { 255 - .caps = dw_mci_rk3288_dwmmc_caps, 256 248 .prepare_command = dw_mci_rockchip_prepare_command, 257 249 .set_ios = dw_mci_rk3288_set_ios, 258 250 .execute_tuning = dw_mci_rk3288_execute_tuning,
+1 -20
drivers/mmc/host/dw_mmc.c
··· 699 699 int ret = 0; 700 700 701 701 /* Set external dma config: burst size, burst width */ 702 - cfg.dst_addr = (dma_addr_t)(host->phy_regs + fifo_offset); 702 + cfg.dst_addr = host->phy_regs + fifo_offset; 703 703 cfg.src_addr = cfg.dst_addr; 704 704 cfg.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; 705 705 cfg.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; ··· 1634 1634 else 1635 1635 cmd->error = 0; 1636 1636 1637 - if (cmd->error) { 1638 - /* newer ip versions need a delay between retries */ 1639 - if (host->quirks & DW_MCI_QUIRK_RETRY_DELAY) 1640 - mdelay(20); 1641 - } 1642 - 1643 1637 return cmd->error; 1644 1638 } 1645 1639 ··· 2348 2354 int i; 2349 2355 2350 2356 pending = mci_readl(host, MINTSTS); /* read-only mask reg */ 2351 - 2352 - /* 2353 - * DTO fix - version 2.10a and below, and only if internal DMA 2354 - * is configured. 2355 - */ 2356 - if (host->quirks & DW_MCI_QUIRK_IDMAC_DTO) { 2357 - if (!pending && 2358 - ((mci_readl(host, STATUS) >> 17) & 0x1fff)) 2359 - pending |= SDMMC_INT_DATA_OVER; 2360 - } 2361 2357 2362 2358 if (pending) { 2363 2359 /* Check volt switch first, since it can look like an error */ ··· 3148 3164 3149 3165 /* Now that slots are all setup, we can enable card detect */ 3150 3166 dw_mci_enable_cd(host); 3151 - 3152 - if (host->quirks & DW_MCI_QUIRK_IDMAC_DTO) 3153 - dev_info(host->dev, "Internal DMAC interrupt fix enabled.\n"); 3154 3167 3155 3168 return 0; 3156 3169
+4 -5
drivers/mmc/host/mtk-sd.c
··· 972 972 if ((events & MSDC_INT_XFER_COMPL) && (!stop || !stop->error)) { 973 973 data->bytes_xfered = data->blocks * data->blksz; 974 974 } else { 975 - dev_err(host->dev, "interrupt events: %x\n", events); 975 + dev_dbg(host->dev, "interrupt events: %x\n", events); 976 976 msdc_reset_hw(host); 977 977 host->error |= REQ_DAT_ERR; 978 978 data->bytes_xfered = 0; ··· 982 982 else if (events & MSDC_INT_DATCRCERR) 983 983 data->error = -EILSEQ; 984 984 985 - dev_err(host->dev, "%s: cmd=%d; blocks=%d", 985 + dev_dbg(host->dev, "%s: cmd=%d; blocks=%d", 986 986 __func__, mrq->cmd->opcode, data->blocks); 987 - dev_err(host->dev, "data_error=%d xfer_size=%d\n", 988 - (int)data->error, data->bytes_xfered); 987 + dev_dbg(host->dev, "data_error=%d xfer_size=%d\n", 988 + (int)data->error, data->bytes_xfered); 989 989 } 990 990 991 991 msdc_data_xfer_next(host, mrq, data); ··· 1543 1543 mmc->f_min = host->src_clk_freq / (4 * 255); 1544 1544 1545 1545 mmc->caps |= MMC_CAP_ERASE | MMC_CAP_CMD23; 1546 - mmc->caps |= MMC_CAP_RUNTIME_RESUME; 1547 1546 /* MMC core transfer sizes tunable parameters */ 1548 1547 mmc->max_segs = MAX_BD_NUM; 1549 1548 mmc->max_seg_size = BDMA_DESC_BUFLEN;
+14 -44
drivers/mmc/host/mvsdio.c
··· 20 20 #include <linux/scatterlist.h> 21 21 #include <linux/irq.h> 22 22 #include <linux/clk.h> 23 - #include <linux/gpio.h> 24 - #include <linux/of_gpio.h> 25 23 #include <linux/of_irq.h> 26 24 #include <linux/mmc/host.h> 27 25 #include <linux/mmc/slot-gpio.h> 28 26 29 27 #include <asm/sizes.h> 30 28 #include <asm/unaligned.h> 31 - #include <linux/platform_data/mmc-mvsdio.h> 32 29 33 30 #include "mvsdio.h" 34 31 ··· 701 704 struct resource *r; 702 705 int ret, irq; 703 706 707 + if (!np) { 708 + dev_err(&pdev->dev, "no DT node\n"); 709 + return -ENODEV; 710 + } 704 711 r = platform_get_resource(pdev, IORESOURCE_MEM, 0); 705 712 irq = platform_get_irq(pdev, 0); 706 713 if (!r || irq < 0) ··· 728 727 * fixed rate clock). 729 728 */ 730 729 host->clk = devm_clk_get(&pdev->dev, NULL); 731 - if (!IS_ERR(host->clk)) 732 - clk_prepare_enable(host->clk); 730 + if (IS_ERR(host->clk)) { 731 + dev_err(&pdev->dev, "no clock associated\n"); 732 + ret = -EINVAL; 733 + goto out; 734 + } 735 + clk_prepare_enable(host->clk); 733 736 734 737 mmc->ops = &mvsd_ops; 735 738 ··· 749 744 mmc->max_seg_size = mmc->max_blk_size * mmc->max_blk_count; 750 745 mmc->max_req_size = mmc->max_blk_size * mmc->max_blk_count; 751 746 752 - if (np) { 753 - if (IS_ERR(host->clk)) { 754 - dev_err(&pdev->dev, "DT platforms must have a clock associated\n"); 755 - ret = -EINVAL; 756 - goto out; 757 - } 758 - 759 - host->base_clock = clk_get_rate(host->clk) / 2; 760 - ret = mmc_of_parse(mmc); 761 - if (ret < 0) 762 - goto out; 763 - } else { 764 - const struct mvsdio_platform_data *mvsd_data; 765 - 766 - mvsd_data = pdev->dev.platform_data; 767 - if (!mvsd_data) { 768 - ret = -ENXIO; 769 - goto out; 770 - } 771 - mmc->caps = MMC_CAP_4_BIT_DATA | MMC_CAP_SDIO_IRQ | 772 - MMC_CAP_SD_HIGHSPEED | MMC_CAP_MMC_HIGHSPEED; 773 - host->base_clock = mvsd_data->clock / 2; 774 - /* GPIO 0 regarded as invalid for backward compatibility */ 775 - if (mvsd_data->gpio_card_detect && 776 - gpio_is_valid(mvsd_data->gpio_card_detect)) { 777 - ret = mmc_gpio_request_cd(mmc, 778 - mvsd_data->gpio_card_detect, 779 - 0); 780 - if (ret) 781 - goto out; 782 - } else { 783 - mmc->caps |= MMC_CAP_NEEDS_POLL; 784 - } 785 - 786 - if (mvsd_data->gpio_write_protect && 787 - gpio_is_valid(mvsd_data->gpio_write_protect)) 788 - mmc_gpio_request_ro(mmc, mvsd_data->gpio_write_protect); 789 - } 790 - 747 + host->base_clock = clk_get_rate(host->clk) / 2; 748 + ret = mmc_of_parse(mmc); 749 + if (ret < 0) 750 + goto out; 791 751 if (maxfreq) 792 752 mmc->f_max = maxfreq; 793 753
+2 -2
drivers/mmc/host/of_mmc_spi.c
··· 55 55 { 56 56 struct of_mmc_spi *oms = to_of_mmc_spi(dev); 57 57 58 - return request_threaded_irq(oms->detect_irq, NULL, irqhandler, 0, 59 - dev_name(dev), mmc); 58 + return request_threaded_irq(oms->detect_irq, NULL, irqhandler, 59 + IRQF_ONESHOT, dev_name(dev), mmc); 60 60 } 61 61 62 62 static void of_mmc_spi_exit(struct device *dev, void *mmc)
+2 -4
drivers/mmc/host/omap_hsmmc.c
··· 2250 2250 pm_runtime_get_sync(host->dev); 2251 2251 mmc_remove_host(host->mmc); 2252 2252 2253 - if (host->tx_chan) 2254 - dma_release_channel(host->tx_chan); 2255 - if (host->rx_chan) 2256 - dma_release_channel(host->rx_chan); 2253 + dma_release_channel(host->tx_chan); 2254 + dma_release_channel(host->rx_chan); 2257 2255 2258 2256 pm_runtime_put_sync(host->dev); 2259 2257 pm_runtime_disable(host->dev);
+5 -2
drivers/mmc/host/sdhci-esdhc-imx.c
··· 76 76 #define ESDHC_STD_TUNING_EN (1 << 24) 77 77 /* NOTE: the minimum valid tuning start tap for mx6sl is 1 */ 78 78 #define ESDHC_TUNING_START_TAP 0x1 79 + #define ESDHC_TUNING_STEP_MASK 0x00070000 79 80 #define ESDHC_TUNING_STEP_SHIFT 16 80 81 81 82 /* pinctrl state */ ··· 490 489 m |= ESDHC_MIX_CTRL_FBCLK_SEL; 491 490 tuning_ctrl = readl(host->ioaddr + ESDHC_TUNING_CTRL); 492 491 tuning_ctrl |= ESDHC_STD_TUNING_EN | ESDHC_TUNING_START_TAP; 493 - if (imx_data->boarddata.tuning_step) 492 + if (imx_data->boarddata.tuning_step) { 493 + tuning_ctrl &= ~ESDHC_TUNING_STEP_MASK; 494 494 tuning_ctrl |= imx_data->boarddata.tuning_step << ESDHC_TUNING_STEP_SHIFT; 495 - writel(tuning_ctrl, host->ioaddr + ESDHC_TUNING_CTRL); 495 + } 496 + writel(tuning_ctrl, host->ioaddr + ESDHC_TUNING_CTRL); 496 497 } else { 497 498 v &= ~ESDHC_MIX_CTRL_EXE_TUNE; 498 499 }
+73 -2
drivers/mmc/host/sdhci-of-at91.c
··· 21 21 #include <linux/module.h> 22 22 #include <linux/of.h> 23 23 #include <linux/of_device.h> 24 + #include <linux/pm.h> 25 + #include <linux/pm_runtime.h> 24 26 25 27 #include "sdhci-pltfm.h" 26 28 ··· 51 49 static const struct of_device_id sdhci_at91_dt_match[] = { 52 50 { .compatible = "atmel,sama5d2-sdhci", .data = &soc_data_sama5d2 }, 53 51 {} 52 + }; 53 + 54 + #ifdef CONFIG_PM 55 + static int sdhci_at91_runtime_suspend(struct device *dev) 56 + { 57 + struct sdhci_host *host = dev_get_drvdata(dev); 58 + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); 59 + struct sdhci_at91_priv *priv = pltfm_host->priv; 60 + int ret; 61 + 62 + ret = sdhci_runtime_suspend_host(host); 63 + 64 + clk_disable_unprepare(priv->gck); 65 + clk_disable_unprepare(priv->hclock); 66 + clk_disable_unprepare(priv->mainck); 67 + 68 + return ret; 69 + } 70 + 71 + static int sdhci_at91_runtime_resume(struct device *dev) 72 + { 73 + struct sdhci_host *host = dev_get_drvdata(dev); 74 + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); 75 + struct sdhci_at91_priv *priv = pltfm_host->priv; 76 + int ret; 77 + 78 + ret = clk_prepare_enable(priv->mainck); 79 + if (ret) { 80 + dev_err(dev, "can't enable mainck\n"); 81 + return ret; 82 + } 83 + 84 + ret = clk_prepare_enable(priv->hclock); 85 + if (ret) { 86 + dev_err(dev, "can't enable hclock\n"); 87 + return ret; 88 + } 89 + 90 + ret = clk_prepare_enable(priv->gck); 91 + if (ret) { 92 + dev_err(dev, "can't enable gck\n"); 93 + return ret; 94 + } 95 + 96 + return sdhci_runtime_resume_host(host); 97 + } 98 + #endif /* CONFIG_PM */ 99 + 100 + static const struct dev_pm_ops sdhci_at91_dev_pm_ops = { 101 + SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, 102 + pm_runtime_force_resume) 103 + SET_RUNTIME_PM_OPS(sdhci_at91_runtime_suspend, 104 + sdhci_at91_runtime_resume, 105 + NULL) 54 106 }; 55 107 56 108 static int sdhci_at91_probe(struct platform_device *pdev) ··· 200 144 201 145 sdhci_get_of_property(pdev); 202 146 147 + pm_runtime_get_noresume(&pdev->dev); 148 + pm_runtime_set_active(&pdev->dev); 149 + pm_runtime_enable(&pdev->dev); 150 + pm_runtime_set_autosuspend_delay(&pdev->dev, 50); 151 + pm_runtime_use_autosuspend(&pdev->dev); 152 + 203 153 ret = sdhci_add_host(host); 204 154 if (ret) 205 - goto clocks_disable_unprepare; 155 + goto pm_runtime_disable; 156 + 157 + pm_runtime_put_autosuspend(&pdev->dev); 206 158 207 159 return 0; 208 160 161 + pm_runtime_disable: 162 + pm_runtime_disable(&pdev->dev); 163 + pm_runtime_set_suspended(&pdev->dev); 209 164 clocks_disable_unprepare: 210 165 clk_disable_unprepare(priv->gck); 211 166 clk_disable_unprepare(priv->mainck); ··· 232 165 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); 233 166 struct sdhci_at91_priv *priv = pltfm_host->priv; 234 167 168 + pm_runtime_get_sync(&pdev->dev); 169 + pm_runtime_disable(&pdev->dev); 170 + pm_runtime_put_noidle(&pdev->dev); 171 + 235 172 sdhci_pltfm_unregister(pdev); 236 173 237 174 clk_disable_unprepare(priv->gck); ··· 249 178 .driver = { 250 179 .name = "sdhci-at91", 251 180 .of_match_table = sdhci_at91_dt_match, 252 - .pm = SDHCI_PLTFM_PMOPS, 181 + .pm = &sdhci_at91_dev_pm_ops, 253 182 }, 254 183 .probe = sdhci_at91_probe, 255 184 .remove = sdhci_at91_remove,
+10
drivers/mmc/host/sdhci-of-esdhc.c
··· 584 584 { 585 585 struct sdhci_host *host; 586 586 struct device_node *np; 587 + struct sdhci_pltfm_host *pltfm_host; 588 + struct sdhci_esdhc *esdhc; 587 589 int ret; 588 590 589 591 np = pdev->dev.of_node; ··· 601 599 esdhc_init(pdev, host); 602 600 603 601 sdhci_get_of_property(pdev); 602 + 603 + pltfm_host = sdhci_priv(host); 604 + esdhc = pltfm_host->priv; 605 + if (esdhc->vendor_ver == VENDOR_V_22) 606 + host->quirks2 |= SDHCI_QUIRK2_HOST_NO_CMD23; 607 + 608 + if (esdhc->vendor_ver > VENDOR_V_22) 609 + host->quirks &= ~SDHCI_QUIRK_NO_BUSY_IRQ; 604 610 605 611 if (of_device_is_compatible(np, "fsl,p5040-esdhc") || 606 612 of_device_is_compatible(np, "fsl,p5020-esdhc") ||
+3 -3
drivers/mmc/host/sdhci-pci-core.c
··· 277 277 if (sdhci_pci_spt_drive_strength > 0) 278 278 drive_strength = sdhci_pci_spt_drive_strength & 0xf; 279 279 else 280 - drive_strength = 1; /* 33-ohm */ 280 + drive_strength = 0; /* Default 50-ohm */ 281 281 282 282 if ((mmc_driver_type_mask(drive_strength) & card_drv) == 0) 283 283 drive_strength = 0; /* Default 50-ohm */ ··· 1464 1464 1465 1465 static int sdhci_pci_runtime_suspend(struct device *dev) 1466 1466 { 1467 - struct pci_dev *pdev = container_of(dev, struct pci_dev, dev); 1467 + struct pci_dev *pdev = to_pci_dev(dev); 1468 1468 struct sdhci_pci_chip *chip; 1469 1469 struct sdhci_pci_slot *slot; 1470 1470 int i, ret; ··· 1500 1500 1501 1501 static int sdhci_pci_runtime_resume(struct device *dev) 1502 1502 { 1503 - struct pci_dev *pdev = container_of(dev, struct pci_dev, dev); 1503 + struct pci_dev *pdev = to_pci_dev(dev); 1504 1504 struct sdhci_pci_chip *chip; 1505 1505 struct sdhci_pci_slot *slot; 1506 1506 int i, ret;
+2 -1
drivers/mmc/host/sdhci-pltfm.c
··· 104 104 if (of_find_property(np, "keep-power-in-suspend", NULL)) 105 105 host->mmc->pm_caps |= MMC_PM_KEEP_POWER; 106 106 107 - if (of_find_property(np, "enable-sdio-wakeup", NULL)) 107 + if (of_property_read_bool(np, "wakeup-source") || 108 + of_property_read_bool(np, "enable-sdio-wakeup")) /* legacy */ 108 109 host->mmc->pm_caps |= MMC_PM_WAKE_SDIO_IRQ; 109 110 } 110 111 #else
+151 -27
drivers/mmc/host/sdhci-tegra.c
··· 22 22 #include <linux/of_device.h> 23 23 #include <linux/mmc/card.h> 24 24 #include <linux/mmc/host.h> 25 + #include <linux/mmc/mmc.h> 25 26 #include <linux/mmc/slot-gpio.h> 26 27 #include <linux/gpio/consumer.h> 27 28 28 29 #include "sdhci-pltfm.h" 29 30 30 31 /* Tegra SDHOST controller vendor register definitions */ 32 + #define SDHCI_TEGRA_VENDOR_CLOCK_CTRL 0x100 33 + #define SDHCI_CLOCK_CTRL_TAP_MASK 0x00ff0000 34 + #define SDHCI_CLOCK_CTRL_TAP_SHIFT 16 35 + #define SDHCI_CLOCK_CTRL_SDR50_TUNING_OVERRIDE BIT(5) 36 + #define SDHCI_CLOCK_CTRL_PADPIPE_CLKEN_OVERRIDE BIT(3) 37 + #define SDHCI_CLOCK_CTRL_SPI_MODE_CLKEN_OVERRIDE BIT(2) 38 + 31 39 #define SDHCI_TEGRA_VENDOR_MISC_CTRL 0x120 32 40 #define SDHCI_MISC_CTRL_ENABLE_SDR104 0x8 33 41 #define SDHCI_MISC_CTRL_ENABLE_SDR50 0x10 ··· 45 37 #define NVQUIRK_FORCE_SDHCI_SPEC_200 BIT(0) 46 38 #define NVQUIRK_ENABLE_BLOCK_GAP_DET BIT(1) 47 39 #define NVQUIRK_ENABLE_SDHCI_SPEC_300 BIT(2) 48 - #define NVQUIRK_DISABLE_SDR50 BIT(3) 49 - #define NVQUIRK_DISABLE_SDR104 BIT(4) 50 - #define NVQUIRK_DISABLE_DDR50 BIT(5) 40 + #define NVQUIRK_ENABLE_SDR50 BIT(3) 41 + #define NVQUIRK_ENABLE_SDR104 BIT(4) 42 + #define NVQUIRK_ENABLE_DDR50 BIT(5) 51 43 52 44 struct sdhci_tegra_soc_data { 53 45 const struct sdhci_pltfm_data *pdata; ··· 57 49 struct sdhci_tegra { 58 50 const struct sdhci_tegra_soc_data *soc_data; 59 51 struct gpio_desc *power_gpio; 52 + bool ddr_signaling; 60 53 }; 61 54 62 55 static u16 tegra_sdhci_readw(struct sdhci_host *host, int reg) ··· 133 124 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); 134 125 struct sdhci_tegra *tegra_host = pltfm_host->priv; 135 126 const struct sdhci_tegra_soc_data *soc_data = tegra_host->soc_data; 136 - u32 misc_ctrl; 127 + u32 misc_ctrl, clk_ctrl; 137 128 138 129 sdhci_reset(host, mask); 139 130 140 131 if (!(mask & SDHCI_RESET_ALL)) 141 132 return; 142 133 143 - misc_ctrl = sdhci_readw(host, SDHCI_TEGRA_VENDOR_MISC_CTRL); 134 + misc_ctrl = sdhci_readl(host, SDHCI_TEGRA_VENDOR_MISC_CTRL); 144 135 /* Erratum: Enable SDHCI spec v3.00 support */ 145 136 if (soc_data->nvquirks & NVQUIRK_ENABLE_SDHCI_SPEC_300) 146 137 misc_ctrl |= SDHCI_MISC_CTRL_ENABLE_SDHCI_SPEC_300; 147 - /* Don't advertise UHS modes which aren't supported yet */ 148 - if (soc_data->nvquirks & NVQUIRK_DISABLE_SDR50) 149 - misc_ctrl &= ~SDHCI_MISC_CTRL_ENABLE_SDR50; 150 - if (soc_data->nvquirks & NVQUIRK_DISABLE_DDR50) 151 - misc_ctrl &= ~SDHCI_MISC_CTRL_ENABLE_DDR50; 152 - if (soc_data->nvquirks & NVQUIRK_DISABLE_SDR104) 153 - misc_ctrl &= ~SDHCI_MISC_CTRL_ENABLE_SDR104; 154 - sdhci_writew(host, misc_ctrl, SDHCI_TEGRA_VENDOR_MISC_CTRL); 138 + /* Advertise UHS modes as supported by host */ 139 + if (soc_data->nvquirks & NVQUIRK_ENABLE_SDR50) 140 + misc_ctrl |= SDHCI_MISC_CTRL_ENABLE_SDR50; 141 + if (soc_data->nvquirks & NVQUIRK_ENABLE_DDR50) 142 + misc_ctrl |= SDHCI_MISC_CTRL_ENABLE_DDR50; 143 + if (soc_data->nvquirks & NVQUIRK_ENABLE_SDR104) 144 + misc_ctrl |= SDHCI_MISC_CTRL_ENABLE_SDR104; 145 + sdhci_writel(host, misc_ctrl, SDHCI_TEGRA_VENDOR_MISC_CTRL); 146 + 147 + clk_ctrl = sdhci_readl(host, SDHCI_TEGRA_VENDOR_CLOCK_CTRL); 148 + clk_ctrl &= ~SDHCI_CLOCK_CTRL_SPI_MODE_CLKEN_OVERRIDE; 149 + if (soc_data->nvquirks & SDHCI_MISC_CTRL_ENABLE_SDR50) 150 + clk_ctrl |= SDHCI_CLOCK_CTRL_SDR50_TUNING_OVERRIDE; 151 + sdhci_writel(host, clk_ctrl, SDHCI_TEGRA_VENDOR_CLOCK_CTRL); 152 + 153 + tegra_host->ddr_signaling = false; 155 154 } 156 155 157 156 static void tegra_sdhci_set_bus_width(struct sdhci_host *host, int bus_width) ··· 181 164 sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL); 182 165 } 183 166 167 + static void tegra_sdhci_set_clock(struct sdhci_host *host, unsigned int clock) 168 + { 169 + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); 170 + struct sdhci_tegra *tegra_host = pltfm_host->priv; 171 + unsigned long host_clk; 172 + 173 + if (!clock) 174 + return; 175 + 176 + host_clk = tegra_host->ddr_signaling ? clock * 2 : clock; 177 + clk_set_rate(pltfm_host->clk, host_clk); 178 + host->max_clk = clk_get_rate(pltfm_host->clk); 179 + 180 + return sdhci_set_clock(host, clock); 181 + } 182 + 183 + static void tegra_sdhci_set_uhs_signaling(struct sdhci_host *host, 184 + unsigned timing) 185 + { 186 + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); 187 + struct sdhci_tegra *tegra_host = pltfm_host->priv; 188 + 189 + if (timing == MMC_TIMING_UHS_DDR50) 190 + tegra_host->ddr_signaling = true; 191 + 192 + return sdhci_set_uhs_signaling(host, timing); 193 + } 194 + 195 + static unsigned int tegra_sdhci_get_max_clock(struct sdhci_host *host) 196 + { 197 + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); 198 + 199 + /* 200 + * DDR modes require the host to run at double the card frequency, so 201 + * the maximum rate we can support is half of the module input clock. 202 + */ 203 + return clk_round_rate(pltfm_host->clk, UINT_MAX) / 2; 204 + } 205 + 206 + static void tegra_sdhci_set_tap(struct sdhci_host *host, unsigned int tap) 207 + { 208 + u32 reg; 209 + 210 + reg = sdhci_readl(host, SDHCI_TEGRA_VENDOR_CLOCK_CTRL); 211 + reg &= ~SDHCI_CLOCK_CTRL_TAP_MASK; 212 + reg |= tap << SDHCI_CLOCK_CTRL_TAP_SHIFT; 213 + sdhci_writel(host, reg, SDHCI_TEGRA_VENDOR_CLOCK_CTRL); 214 + } 215 + 216 + static int tegra_sdhci_execute_tuning(struct sdhci_host *host, u32 opcode) 217 + { 218 + unsigned int min, max; 219 + 220 + /* 221 + * Start search for minimum tap value at 10, as smaller values are 222 + * may wrongly be reported as working but fail at higher speeds, 223 + * according to the TRM. 224 + */ 225 + min = 10; 226 + while (min < 255) { 227 + tegra_sdhci_set_tap(host, min); 228 + if (!mmc_send_tuning(host->mmc, opcode, NULL)) 229 + break; 230 + min++; 231 + } 232 + 233 + /* Find the maximum tap value that still passes. */ 234 + max = min + 1; 235 + while (max < 255) { 236 + tegra_sdhci_set_tap(host, max); 237 + if (mmc_send_tuning(host->mmc, opcode, NULL)) { 238 + max--; 239 + break; 240 + } 241 + max++; 242 + } 243 + 244 + /* The TRM states the ideal tap value is at 75% in the passing range. */ 245 + tegra_sdhci_set_tap(host, min + ((max - min) * 3 / 4)); 246 + 247 + return mmc_send_tuning(host->mmc, opcode, NULL); 248 + } 249 + 184 250 static const struct sdhci_ops tegra_sdhci_ops = { 185 251 .get_ro = tegra_sdhci_get_ro, 186 252 .read_w = tegra_sdhci_readw, 187 253 .write_l = tegra_sdhci_writel, 188 - .set_clock = sdhci_set_clock, 254 + .set_clock = tegra_sdhci_set_clock, 189 255 .set_bus_width = tegra_sdhci_set_bus_width, 190 256 .reset = tegra_sdhci_reset, 191 - .set_uhs_signaling = sdhci_set_uhs_signaling, 192 - .get_max_clock = sdhci_pltfm_clk_get_max_clock, 257 + .platform_execute_tuning = tegra_sdhci_execute_tuning, 258 + .set_uhs_signaling = tegra_sdhci_set_uhs_signaling, 259 + .get_max_clock = tegra_sdhci_get_max_clock, 193 260 }; 194 261 195 262 static const struct sdhci_pltfm_data sdhci_tegra20_pdata = { ··· 285 184 .ops = &tegra_sdhci_ops, 286 185 }; 287 186 288 - static struct sdhci_tegra_soc_data soc_data_tegra20 = { 187 + static const struct sdhci_tegra_soc_data soc_data_tegra20 = { 289 188 .pdata = &sdhci_tegra20_pdata, 290 189 .nvquirks = NVQUIRK_FORCE_SDHCI_SPEC_200 | 291 190 NVQUIRK_ENABLE_BLOCK_GAP_DET, ··· 298 197 SDHCI_QUIRK_NO_HISPD_BIT | 299 198 SDHCI_QUIRK_BROKEN_ADMA_ZEROLEN_DESC | 300 199 SDHCI_QUIRK_CAP_CLOCK_BASE_BROKEN, 200 + .quirks2 = SDHCI_QUIRK2_PRESET_VALUE_BROKEN, 301 201 .ops = &tegra_sdhci_ops, 302 202 }; 303 203 304 - static struct sdhci_tegra_soc_data soc_data_tegra30 = { 204 + static const struct sdhci_tegra_soc_data soc_data_tegra30 = { 305 205 .pdata = &sdhci_tegra30_pdata, 306 206 .nvquirks = NVQUIRK_ENABLE_SDHCI_SPEC_300 | 307 - NVQUIRK_DISABLE_SDR50 | 308 - NVQUIRK_DISABLE_SDR104, 207 + NVQUIRK_ENABLE_SDR50 | 208 + NVQUIRK_ENABLE_SDR104, 309 209 }; 310 210 311 211 static const struct sdhci_ops tegra114_sdhci_ops = { ··· 314 212 .read_w = tegra_sdhci_readw, 315 213 .write_w = tegra_sdhci_writew, 316 214 .write_l = tegra_sdhci_writel, 317 - .set_clock = sdhci_set_clock, 215 + .set_clock = tegra_sdhci_set_clock, 318 216 .set_bus_width = tegra_sdhci_set_bus_width, 319 217 .reset = tegra_sdhci_reset, 320 - .set_uhs_signaling = sdhci_set_uhs_signaling, 321 - .get_max_clock = sdhci_pltfm_clk_get_max_clock, 218 + .platform_execute_tuning = tegra_sdhci_execute_tuning, 219 + .set_uhs_signaling = tegra_sdhci_set_uhs_signaling, 220 + .get_max_clock = tegra_sdhci_get_max_clock, 322 221 }; 323 222 324 223 static const struct sdhci_pltfm_data sdhci_tegra114_pdata = { ··· 329 226 SDHCI_QUIRK_NO_HISPD_BIT | 330 227 SDHCI_QUIRK_BROKEN_ADMA_ZEROLEN_DESC | 331 228 SDHCI_QUIRK_CAP_CLOCK_BASE_BROKEN, 229 + .quirks2 = SDHCI_QUIRK2_PRESET_VALUE_BROKEN, 332 230 .ops = &tegra114_sdhci_ops, 333 231 }; 334 232 335 - static struct sdhci_tegra_soc_data soc_data_tegra114 = { 233 + static const struct sdhci_tegra_soc_data soc_data_tegra114 = { 336 234 .pdata = &sdhci_tegra114_pdata, 337 - .nvquirks = NVQUIRK_DISABLE_SDR50 | 338 - NVQUIRK_DISABLE_DDR50 | 339 - NVQUIRK_DISABLE_SDR104, 235 + .nvquirks = NVQUIRK_ENABLE_SDR50 | 236 + NVQUIRK_ENABLE_DDR50 | 237 + NVQUIRK_ENABLE_SDR104, 238 + }; 239 + 240 + static const struct sdhci_pltfm_data sdhci_tegra210_pdata = { 241 + .quirks = SDHCI_QUIRK_BROKEN_TIMEOUT_VAL | 242 + SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK | 243 + SDHCI_QUIRK_SINGLE_POWER_WRITE | 244 + SDHCI_QUIRK_NO_HISPD_BIT | 245 + SDHCI_QUIRK_BROKEN_ADMA_ZEROLEN_DESC | 246 + SDHCI_QUIRK_CAP_CLOCK_BASE_BROKEN, 247 + .quirks2 = SDHCI_QUIRK2_PRESET_VALUE_BROKEN, 248 + .ops = &tegra114_sdhci_ops, 249 + }; 250 + 251 + static const struct sdhci_tegra_soc_data soc_data_tegra210 = { 252 + .pdata = &sdhci_tegra210_pdata, 340 253 }; 341 254 342 255 static const struct of_device_id sdhci_tegra_dt_match[] = { 256 + { .compatible = "nvidia,tegra210-sdhci", .data = &soc_data_tegra210 }, 343 257 { .compatible = "nvidia,tegra124-sdhci", .data = &soc_data_tegra114 }, 344 258 { .compatible = "nvidia,tegra114-sdhci", .data = &soc_data_tegra114 }, 345 259 { .compatible = "nvidia,tegra30-sdhci", .data = &soc_data_tegra30 }, ··· 391 271 rc = -ENOMEM; 392 272 goto err_alloc_tegra_host; 393 273 } 274 + tegra_host->ddr_signaling = false; 394 275 tegra_host->soc_data = soc_data; 395 276 pltfm_host->priv = tegra_host; 396 277 397 278 rc = mmc_of_parse(host->mmc); 398 279 if (rc) 399 280 goto err_parse_dt; 281 + 282 + if (tegra_host->soc_data->nvquirks & NVQUIRK_ENABLE_DDR50) 283 + host->mmc->caps |= MMC_CAP_1_8V_DDR; 400 284 401 285 tegra_host->power_gpio = devm_gpiod_get_optional(&pdev->dev, "power", 402 286 GPIOD_OUT_HIGH);
+52 -72
drivers/mmc/host/sdhci.c
··· 492 492 host->align_buffer, host->align_buffer_sz, direction); 493 493 if (dma_mapping_error(mmc_dev(host->mmc), host->align_addr)) 494 494 goto fail; 495 - BUG_ON(host->align_addr & host->align_mask); 495 + BUG_ON(host->align_addr & SDHCI_ADMA2_MASK); 496 496 497 497 host->sg_count = sdhci_pre_dma_transfer(host, data); 498 498 if (host->sg_count < 0) ··· 514 514 * the (up to three) bytes that screw up the 515 515 * alignment. 516 516 */ 517 - offset = (host->align_sz - (addr & host->align_mask)) & 518 - host->align_mask; 517 + offset = (SDHCI_ADMA2_ALIGN - (addr & SDHCI_ADMA2_MASK)) & 518 + SDHCI_ADMA2_MASK; 519 519 if (offset) { 520 520 if (data->flags & MMC_DATA_WRITE) { 521 521 buffer = sdhci_kmap_atomic(sg, &flags); ··· 529 529 530 530 BUG_ON(offset > 65536); 531 531 532 - align += host->align_sz; 533 - align_addr += host->align_sz; 532 + align += SDHCI_ADMA2_ALIGN; 533 + align_addr += SDHCI_ADMA2_ALIGN; 534 534 535 535 desc += host->desc_sz; 536 536 ··· 540 540 541 541 BUG_ON(len > 65536); 542 542 543 - /* tran, valid */ 544 - sdhci_adma_write_desc(host, desc, addr, len, ADMA2_TRAN_VALID); 545 - desc += host->desc_sz; 543 + if (len) { 544 + /* tran, valid */ 545 + sdhci_adma_write_desc(host, desc, addr, len, 546 + ADMA2_TRAN_VALID); 547 + desc += host->desc_sz; 548 + } 546 549 547 550 /* 548 551 * If this triggers then we have a calculation bug ··· 611 608 /* Do a quick scan of the SG list for any unaligned mappings */ 612 609 has_unaligned = false; 613 610 for_each_sg(data->sg, sg, host->sg_count, i) 614 - if (sg_dma_address(sg) & host->align_mask) { 611 + if (sg_dma_address(sg) & SDHCI_ADMA2_MASK) { 615 612 has_unaligned = true; 616 613 break; 617 614 } ··· 623 620 align = host->align_buffer; 624 621 625 622 for_each_sg(data->sg, sg, host->sg_count, i) { 626 - if (sg_dma_address(sg) & host->align_mask) { 627 - size = host->align_sz - 628 - (sg_dma_address(sg) & host->align_mask); 623 + if (sg_dma_address(sg) & SDHCI_ADMA2_MASK) { 624 + size = SDHCI_ADMA2_ALIGN - 625 + (sg_dma_address(sg) & SDHCI_ADMA2_MASK); 629 626 630 627 buffer = sdhci_kmap_atomic(sg, &flags); 631 628 memcpy(buffer, align, size); 632 629 sdhci_kunmap_atomic(buffer, &flags); 633 630 634 - align += host->align_sz; 631 + align += SDHCI_ADMA2_ALIGN; 635 632 } 636 633 } 637 634 } ··· 771 768 if (unlikely(broken)) { 772 769 for_each_sg(data->sg, sg, data->sg_len, i) { 773 770 if (sg->length & 0x3) { 774 - DBG("Reverting to PIO because of " 775 - "transfer size (%d)\n", 771 + DBG("Reverting to PIO because of transfer size (%d)\n", 776 772 sg->length); 777 773 host->flags &= ~SDHCI_REQ_USE_DMA; 778 774 break; ··· 805 803 if (unlikely(broken)) { 806 804 for_each_sg(data->sg, sg, data->sg_len, i) { 807 805 if (sg->offset & 0x3) { 808 - DBG("Reverting to PIO because of " 809 - "bad alignment\n"); 806 + DBG("Reverting to PIO because of bad alignment\n"); 810 807 host->flags &= ~SDHCI_REQ_USE_DMA; 811 808 break; 812 809 } ··· 1017 1016 1018 1017 while (sdhci_readl(host, SDHCI_PRESENT_STATE) & mask) { 1019 1018 if (timeout == 0) { 1020 - pr_err("%s: Controller never released " 1021 - "inhibit bit(s).\n", mmc_hostname(host->mmc)); 1019 + pr_err("%s: Controller never released inhibit bit(s).\n", 1020 + mmc_hostname(host->mmc)); 1022 1021 sdhci_dumpregs(host); 1023 1022 cmd->error = -EIO; 1024 1023 tasklet_schedule(&host->finish_tasklet); ··· 1255 1254 while (!((clk = sdhci_readw(host, SDHCI_CLOCK_CONTROL)) 1256 1255 & SDHCI_CLOCK_INT_STABLE)) { 1257 1256 if (timeout == 0) { 1258 - pr_err("%s: Internal clock never " 1259 - "stabilised.\n", mmc_hostname(host->mmc)); 1257 + pr_err("%s: Internal clock never stabilised.\n", 1258 + mmc_hostname(host->mmc)); 1260 1259 sdhci_dumpregs(host); 1261 1260 return; 1262 1261 } ··· 1275 1274 struct mmc_host *mmc = host->mmc; 1276 1275 u8 pwr = 0; 1277 1276 1278 - if (!IS_ERR(mmc->supply.vmmc)) { 1279 - spin_unlock_irq(&host->lock); 1280 - mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, vdd); 1281 - spin_lock_irq(&host->lock); 1282 - 1283 - if (mode != MMC_POWER_OFF) 1284 - sdhci_writeb(host, SDHCI_POWER_ON, SDHCI_POWER_CONTROL); 1285 - else 1286 - sdhci_writeb(host, 0, SDHCI_POWER_CONTROL); 1287 - 1288 - return; 1289 - } 1290 - 1291 1277 if (mode != MMC_POWER_OFF) { 1292 1278 switch (1 << vdd) { 1293 1279 case MMC_VDD_165_195: ··· 1289 1301 pwr = SDHCI_POWER_330; 1290 1302 break; 1291 1303 default: 1292 - BUG(); 1304 + WARN(1, "%s: Invalid vdd %#x\n", 1305 + mmc_hostname(host->mmc), vdd); 1306 + break; 1293 1307 } 1294 1308 } 1295 1309 ··· 1334 1344 */ 1335 1345 if (host->quirks & SDHCI_QUIRK_DELAY_AFTER_POWER) 1336 1346 mdelay(10); 1347 + } 1348 + 1349 + if (!IS_ERR(mmc->supply.vmmc)) { 1350 + spin_unlock_irq(&host->lock); 1351 + mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, vdd); 1352 + spin_lock_irq(&host->lock); 1337 1353 } 1338 1354 } 1339 1355 ··· 1536 1540 else if (ios->drv_type == MMC_SET_DRIVER_TYPE_D) 1537 1541 ctrl_2 |= SDHCI_CTRL_DRV_TYPE_D; 1538 1542 else { 1539 - pr_warn("%s: invalid driver type, default to " 1540 - "driver type B\n", mmc_hostname(mmc)); 1543 + pr_warn("%s: invalid driver type, default to driver type B\n", 1544 + mmc_hostname(mmc)); 1541 1545 ctrl_2 |= SDHCI_CTRL_DRV_TYPE_B; 1542 1546 } 1543 1547 ··· 2011 2015 spin_lock_irqsave(&host->lock, flags); 2012 2016 2013 2017 if (!host->tuning_done) { 2014 - pr_info(DRIVER_NAME ": Timeout waiting for " 2015 - "Buffer Read Ready interrupt during tuning " 2016 - "procedure, falling back to fixed sampling " 2017 - "clock\n"); 2018 + pr_info(DRIVER_NAME ": Timeout waiting for Buffer Read Ready interrupt during tuning procedure, falling back to fixed sampling clock\n"); 2018 2019 ctrl = sdhci_readw(host, SDHCI_HOST_CONTROL2); 2019 2020 ctrl &= ~SDHCI_CTRL_TUNED_CLK; 2020 2021 ctrl &= ~SDHCI_CTRL_EXEC_TUNING; ··· 2039 2046 sdhci_writew(host, ctrl, SDHCI_HOST_CONTROL2); 2040 2047 } 2041 2048 if (!(ctrl & SDHCI_CTRL_TUNED_CLK)) { 2042 - pr_info(DRIVER_NAME ": Tuning procedure" 2043 - " failed, falling back to fixed sampling" 2044 - " clock\n"); 2049 + pr_info(DRIVER_NAME ": Tuning procedure failed, falling back to fixed sampling clock\n"); 2045 2050 err = -EIO; 2046 2051 } 2047 2052 ··· 2284 2293 spin_lock_irqsave(&host->lock, flags); 2285 2294 2286 2295 if (host->mrq) { 2287 - pr_err("%s: Timeout waiting for hardware " 2288 - "interrupt.\n", mmc_hostname(host->mmc)); 2296 + pr_err("%s: Timeout waiting for hardware interrupt.\n", 2297 + mmc_hostname(host->mmc)); 2289 2298 sdhci_dumpregs(host); 2290 2299 2291 2300 if (host->data) { ··· 2316 2325 BUG_ON(intmask == 0); 2317 2326 2318 2327 if (!host->cmd) { 2319 - pr_err("%s: Got command interrupt 0x%08x even " 2320 - "though no command operation was in progress.\n", 2321 - mmc_hostname(host->mmc), (unsigned)intmask); 2328 + pr_err("%s: Got command interrupt 0x%08x even though no command operation was in progress.\n", 2329 + mmc_hostname(host->mmc), (unsigned)intmask); 2322 2330 sdhci_dumpregs(host); 2323 2331 return; 2324 2332 } ··· 2346 2356 */ 2347 2357 if (host->cmd->flags & MMC_RSP_BUSY) { 2348 2358 if (host->cmd->data) 2349 - DBG("Cannot wait for busy signal when also " 2350 - "doing a data transfer"); 2359 + DBG("Cannot wait for busy signal when also doing a data transfer"); 2351 2360 else if (!(host->quirks & SDHCI_QUIRK_NO_BUSY_IRQ) 2352 2361 && !host->busy_handle) { 2353 2362 /* Mark that command complete before busy is ended */ ··· 2440 2451 } 2441 2452 } 2442 2453 2443 - pr_err("%s: Got data interrupt 0x%08x even " 2444 - "though no data operation was in progress.\n", 2445 - mmc_hostname(host->mmc), (unsigned)intmask); 2454 + pr_err("%s: Got data interrupt 0x%08x even though no data operation was in progress.\n", 2455 + mmc_hostname(host->mmc), (unsigned)intmask); 2446 2456 sdhci_dumpregs(host); 2447 2457 2448 2458 return; ··· 2748 2760 2749 2761 static void sdhci_runtime_pm_bus_on(struct sdhci_host *host) 2750 2762 { 2751 - if (host->runtime_suspended || host->bus_on) 2763 + if (host->bus_on) 2752 2764 return; 2753 2765 host->bus_on = true; 2754 2766 pm_runtime_get_noresume(host->mmc->parent); ··· 2756 2768 2757 2769 static void sdhci_runtime_pm_bus_off(struct sdhci_host *host) 2758 2770 { 2759 - if (host->runtime_suspended || !host->bus_on) 2771 + if (!host->bus_on) 2760 2772 return; 2761 2773 host->bus_on = false; 2762 2774 pm_runtime_put_noidle(host->mmc->parent); ··· 2884 2896 host->version = (host->version & SDHCI_SPEC_VER_MASK) 2885 2897 >> SDHCI_SPEC_VER_SHIFT; 2886 2898 if (host->version > SDHCI_SPEC_300) { 2887 - pr_err("%s: Unknown controller version (%d). " 2888 - "You may experience problems.\n", mmc_hostname(mmc), 2889 - host->version); 2899 + pr_err("%s: Unknown controller version (%d). You may experience problems.\n", 2900 + mmc_hostname(mmc), host->version); 2890 2901 } 2891 2902 2892 2903 caps[0] = (host->quirks & SDHCI_QUIRK_MISSING_CAPS) ? host->caps : ··· 2954 2967 if (host->flags & SDHCI_USE_64_BIT_DMA) { 2955 2968 host->adma_table_sz = (SDHCI_MAX_SEGS * 2 + 1) * 2956 2969 SDHCI_ADMA2_64_DESC_SZ; 2957 - host->align_buffer_sz = SDHCI_MAX_SEGS * 2958 - SDHCI_ADMA2_64_ALIGN; 2959 2970 host->desc_sz = SDHCI_ADMA2_64_DESC_SZ; 2960 - host->align_sz = SDHCI_ADMA2_64_ALIGN; 2961 - host->align_mask = SDHCI_ADMA2_64_ALIGN - 1; 2962 2971 } else { 2963 2972 host->adma_table_sz = (SDHCI_MAX_SEGS * 2 + 1) * 2964 2973 SDHCI_ADMA2_32_DESC_SZ; 2965 - host->align_buffer_sz = SDHCI_MAX_SEGS * 2966 - SDHCI_ADMA2_32_ALIGN; 2967 2974 host->desc_sz = SDHCI_ADMA2_32_DESC_SZ; 2968 - host->align_sz = SDHCI_ADMA2_32_ALIGN; 2969 - host->align_mask = SDHCI_ADMA2_32_ALIGN - 1; 2970 2975 } 2971 2976 host->adma_table = dma_alloc_coherent(mmc_dev(mmc), 2972 2977 host->adma_table_sz, 2973 2978 &host->adma_addr, 2974 2979 GFP_KERNEL); 2980 + host->align_buffer_sz = SDHCI_MAX_SEGS * SDHCI_ADMA2_ALIGN; 2975 2981 host->align_buffer = kmalloc(host->align_buffer_sz, GFP_KERNEL); 2976 2982 if (!host->adma_table || !host->align_buffer) { 2977 2983 if (host->adma_table) ··· 2978 2998 host->flags &= ~SDHCI_USE_ADMA; 2979 2999 host->adma_table = NULL; 2980 3000 host->align_buffer = NULL; 2981 - } else if (host->adma_addr & host->align_mask) { 3001 + } else if (host->adma_addr & (SDHCI_ADMA2_DESC_ALIGN - 1)) { 2982 3002 pr_warn("%s: unable to allocate aligned ADMA descriptor\n", 2983 3003 mmc_hostname(mmc)); 2984 3004 host->flags &= ~SDHCI_USE_ADMA; ··· 3011 3031 if (host->max_clk == 0 || host->quirks & 3012 3032 SDHCI_QUIRK_CAP_CLOCK_BASE_BROKEN) { 3013 3033 if (!host->ops->get_max_clock) { 3014 - pr_err("%s: Hardware doesn't specify base clock " 3015 - "frequency.\n", mmc_hostname(mmc)); 3034 + pr_err("%s: Hardware doesn't specify base clock frequency.\n", 3035 + mmc_hostname(mmc)); 3016 3036 return -ENODEV; 3017 3037 } 3018 3038 host->max_clk = host->ops->get_max_clock(host); ··· 3274 3294 mmc->ocr_avail_mmc &= host->ocr_avail_mmc; 3275 3295 3276 3296 if (mmc->ocr_avail == 0) { 3277 - pr_err("%s: Hardware doesn't report any " 3278 - "support voltages.\n", mmc_hostname(mmc)); 3297 + pr_err("%s: Hardware doesn't report any support voltages.\n", 3298 + mmc_hostname(mmc)); 3279 3299 return -ENODEV; 3280 3300 } 3281 3301
+12 -9
drivers/mmc/host/sdhci.h
··· 272 272 /* ADMA2 32-bit DMA descriptor size */ 273 273 #define SDHCI_ADMA2_32_DESC_SZ 8 274 274 275 - /* ADMA2 32-bit DMA alignment */ 276 - #define SDHCI_ADMA2_32_ALIGN 4 277 - 278 275 /* ADMA2 32-bit descriptor */ 279 276 struct sdhci_adma2_32_desc { 280 277 __le16 cmd; 281 278 __le16 len; 282 279 __le32 addr; 283 - } __packed __aligned(SDHCI_ADMA2_32_ALIGN); 280 + } __packed __aligned(4); 281 + 282 + /* ADMA2 data alignment */ 283 + #define SDHCI_ADMA2_ALIGN 4 284 + #define SDHCI_ADMA2_MASK (SDHCI_ADMA2_ALIGN - 1) 285 + 286 + /* 287 + * ADMA2 descriptor alignment. Some controllers (e.g. Intel) require 8 byte 288 + * alignment for the descriptor table even in 32-bit DMA mode. Memory 289 + * allocation is at least 8 byte aligned anyway, so just stipulate 8 always. 290 + */ 291 + #define SDHCI_ADMA2_DESC_ALIGN 8 284 292 285 293 /* ADMA2 64-bit DMA descriptor size */ 286 294 #define SDHCI_ADMA2_64_DESC_SZ 12 287 - 288 - /* ADMA2 64-bit DMA alignment */ 289 - #define SDHCI_ADMA2_64_ALIGN 8 290 295 291 296 /* 292 297 * ADMA2 64-bit descriptor. Note 12-byte descriptor can't always be 8-byte ··· 487 482 dma_addr_t align_addr; /* Mapped bounce buffer */ 488 483 489 484 unsigned int desc_sz; /* ADMA descriptor size */ 490 - unsigned int align_sz; /* ADMA alignment */ 491 - unsigned int align_mask; /* ADMA alignment mask */ 492 485 493 486 struct tasklet_struct finish_tasklet; /* Tasklet structures */ 494 487
+40 -48
drivers/mmc/host/sh_mmcif.c
··· 397 397 } 398 398 399 399 static struct dma_chan * 400 - sh_mmcif_request_dma_one(struct sh_mmcif_host *host, 401 - struct sh_mmcif_plat_data *pdata, 402 - enum dma_transfer_direction direction) 400 + sh_mmcif_request_dma_pdata(struct sh_mmcif_host *host, uintptr_t slave_id) 403 401 { 404 - struct dma_slave_config cfg = { 0, }; 405 - struct dma_chan *chan; 406 - void *slave_data = NULL; 407 - struct resource *res; 408 - struct device *dev = sh_mmcif_host_to_dev(host); 409 402 dma_cap_mask_t mask; 410 - int ret; 411 403 412 404 dma_cap_zero(mask); 413 405 dma_cap_set(DMA_SLAVE, mask); 414 - 415 - if (pdata) 416 - slave_data = direction == DMA_MEM_TO_DEV ? 417 - (void *)pdata->slave_id_tx : 418 - (void *)pdata->slave_id_rx; 419 - 420 - chan = dma_request_slave_channel_compat(mask, shdma_chan_filter, 421 - slave_data, dev, 422 - direction == DMA_MEM_TO_DEV ? "tx" : "rx"); 423 - 424 - dev_dbg(dev, "%s: %s: got channel %p\n", __func__, 425 - direction == DMA_MEM_TO_DEV ? "TX" : "RX", chan); 426 - 427 - if (!chan) 406 + if (slave_id <= 0) 428 407 return NULL; 429 408 430 - res = platform_get_resource(host->pd, IORESOURCE_MEM, 0); 409 + return dma_request_channel(mask, shdma_chan_filter, (void *)slave_id); 410 + } 431 411 412 + static int sh_mmcif_dma_slave_config(struct sh_mmcif_host *host, 413 + struct dma_chan *chan, 414 + enum dma_transfer_direction direction) 415 + { 416 + struct resource *res; 417 + struct dma_slave_config cfg = { 0, }; 418 + 419 + res = platform_get_resource(host->pd, IORESOURCE_MEM, 0); 432 420 cfg.direction = direction; 433 421 434 422 if (direction == DMA_DEV_TO_MEM) { ··· 427 439 cfg.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; 428 440 } 429 441 430 - ret = dmaengine_slave_config(chan, &cfg); 431 - if (ret < 0) { 432 - dma_release_channel(chan); 433 - return NULL; 434 - } 435 - 436 - return chan; 442 + return dmaengine_slave_config(chan, &cfg); 437 443 } 438 444 439 - static void sh_mmcif_request_dma(struct sh_mmcif_host *host, 440 - struct sh_mmcif_plat_data *pdata) 445 + static void sh_mmcif_request_dma(struct sh_mmcif_host *host) 441 446 { 442 447 struct device *dev = sh_mmcif_host_to_dev(host); 443 448 host->dma_active = false; 444 449 445 - if (pdata) { 446 - if (pdata->slave_id_tx <= 0 || pdata->slave_id_rx <= 0) 447 - return; 448 - } else if (!dev->of_node) { 449 - return; 450 - } 451 - 452 450 /* We can only either use DMA for both Tx and Rx or not use it at all */ 453 - host->chan_tx = sh_mmcif_request_dma_one(host, pdata, DMA_MEM_TO_DEV); 454 - if (!host->chan_tx) 455 - return; 451 + if (IS_ENABLED(CONFIG_SUPERH) && dev->platform_data) { 452 + struct sh_mmcif_plat_data *pdata = dev->platform_data; 456 453 457 - host->chan_rx = sh_mmcif_request_dma_one(host, pdata, DMA_DEV_TO_MEM); 458 - if (!host->chan_rx) { 459 - dma_release_channel(host->chan_tx); 460 - host->chan_tx = NULL; 454 + host->chan_tx = sh_mmcif_request_dma_pdata(host, 455 + pdata->slave_id_tx); 456 + host->chan_rx = sh_mmcif_request_dma_pdata(host, 457 + pdata->slave_id_rx); 458 + } else { 459 + host->chan_tx = dma_request_slave_channel(dev, "tx"); 460 + host->chan_tx = dma_request_slave_channel(dev, "rx"); 461 461 } 462 + dev_dbg(dev, "%s: got channel TX %p RX %p\n", __func__, host->chan_tx, 463 + host->chan_rx); 464 + 465 + if (!host->chan_tx || !host->chan_rx || 466 + sh_mmcif_dma_slave_config(host, host->chan_tx, DMA_MEM_TO_DEV) || 467 + sh_mmcif_dma_slave_config(host, host->chan_rx, DMA_DEV_TO_MEM)) 468 + goto error; 469 + 470 + return; 471 + 472 + error: 473 + if (host->chan_tx) 474 + dma_release_channel(host->chan_tx); 475 + if (host->chan_rx) 476 + dma_release_channel(host->chan_rx); 477 + host->chan_tx = host->chan_rx = NULL; 462 478 } 463 479 464 480 static void sh_mmcif_release_dma(struct sh_mmcif_host *host) ··· 1094 1102 if (ios->power_mode == MMC_POWER_UP) { 1095 1103 if (!host->card_present) { 1096 1104 /* See if we also get DMA */ 1097 - sh_mmcif_request_dma(host, dev->platform_data); 1105 + sh_mmcif_request_dma(host); 1098 1106 host->card_present = true; 1099 1107 } 1100 1108 sh_mmcif_set_power(host, ios);
+2 -1
drivers/mmc/host/usdhi6rol0.c
··· 1634 1634 struct usdhi6_host *host = container_of(d, struct usdhi6_host, timeout_work); 1635 1635 struct mmc_request *mrq = host->mrq; 1636 1636 struct mmc_data *data = mrq ? mrq->data : NULL; 1637 - struct scatterlist *sg = host->sg ?: data->sg; 1637 + struct scatterlist *sg; 1638 1638 1639 1639 dev_warn(mmc_dev(host->mmc), 1640 1640 "%s timeout wait %u CMD%d: IRQ 0x%08x:0x%08x, last IRQ 0x%08x\n", ··· 1666 1666 case USDHI6_WAIT_FOR_MWRITE: 1667 1667 case USDHI6_WAIT_FOR_READ: 1668 1668 case USDHI6_WAIT_FOR_WRITE: 1669 + sg = host->sg ?: data->sg; 1669 1670 dev_dbg(mmc_dev(host->mmc), 1670 1671 "%c: page #%u @ +0x%zx %ux%u in SG%u. Current SG %u bytes @ %u\n", 1671 1672 data->flags & MMC_DATA_READ ? 'R' : 'W', host->page_idx,
+3 -9
include/linux/mmc/dw_mmc.h
··· 172 172 /* For edmac */ 173 173 struct dw_mci_dma_slave *dms; 174 174 /* Registers's physical base address */ 175 - void *phy_regs; 175 + resource_size_t phy_regs; 176 176 177 177 u32 cmd_status; 178 178 u32 data_status; ··· 235 235 }; 236 236 237 237 /* IP Quirks/flags. */ 238 - /* DTO fix for command transmission with IDMAC configured */ 239 - #define DW_MCI_QUIRK_IDMAC_DTO BIT(0) 240 - /* delay needed between retries on some 2.11a implementations */ 241 - #define DW_MCI_QUIRK_RETRY_DELAY BIT(1) 242 - /* High Speed Capable - Supports HS cards (up to 50MHz) */ 243 - #define DW_MCI_QUIRK_HIGHSPEED BIT(2) 244 238 /* Unreliable card detection */ 245 - #define DW_MCI_QUIRK_BROKEN_CARD_DETECTION BIT(3) 239 + #define DW_MCI_QUIRK_BROKEN_CARD_DETECTION BIT(0) 246 240 /* Timer for broken data transfer over scheme */ 247 - #define DW_MCI_QUIRK_BROKEN_DTO BIT(4) 241 + #define DW_MCI_QUIRK_BROKEN_DTO BIT(1) 248 242 249 243 struct dma_pdata; 250 244
+3 -3
include/linux/mmc/host.h
··· 212 212 u32 ocr_avail_sdio; /* SDIO-specific OCR */ 213 213 u32 ocr_avail_sd; /* SD-specific OCR */ 214 214 u32 ocr_avail_mmc; /* MMC-specific OCR */ 215 + #ifdef CONFIG_PM_SLEEP 215 216 struct notifier_block pm_notify; 217 + #endif 216 218 u32 max_current_330; 217 219 u32 max_current_300; 218 220 u32 max_current_180; ··· 261 259 #define MMC_CAP_UHS_SDR50 (1 << 17) /* Host supports UHS SDR50 mode */ 262 260 #define MMC_CAP_UHS_SDR104 (1 << 18) /* Host supports UHS SDR104 mode */ 263 261 #define MMC_CAP_UHS_DDR50 (1 << 19) /* Host supports UHS DDR50 mode */ 264 - #define MMC_CAP_RUNTIME_RESUME (1 << 20) /* Resume at runtime_resume. */ 265 262 #define MMC_CAP_DRIVER_TYPE_A (1 << 23) /* Host supports Driver Type A */ 266 263 #define MMC_CAP_DRIVER_TYPE_C (1 << 24) /* Host supports Driver Type C */ 267 264 #define MMC_CAP_DRIVER_TYPE_D (1 << 25) /* Host supports Driver Type D */ ··· 290 289 #define MMC_CAP2_HSX00_1_2V (MMC_CAP2_HS200_1_2V_SDR | MMC_CAP2_HS400_1_2V) 291 290 #define MMC_CAP2_SDIO_IRQ_NOTHREAD (1 << 17) 292 291 #define MMC_CAP2_NO_WRITE_PROTECT (1 << 18) /* No physical write protect pin, assume that card is always read-write */ 292 + #define MMC_CAP2_NO_SDIO (1 << 19) /* Do not send SDIO commands during initialization */ 293 293 294 294 mmc_pm_flag_t pm_caps; /* supported pm features */ 295 295 ··· 435 433 #endif 436 434 437 435 int mmc_regulator_get_supply(struct mmc_host *mmc); 438 - 439 - int mmc_pm_notify(struct notifier_block *notify_block, unsigned long, void *); 440 436 441 437 static inline int mmc_card_is_removable(struct mmc_host *host) 442 438 {
-18
include/linux/platform_data/mmc-mvsdio.h
··· 1 - /* 2 - * This file is licensed under the terms of the GNU General Public 3 - * License version 2. This program is licensed "as is" without any 4 - * warranty of any kind, whether express or implied. 5 - */ 6 - 7 - #ifndef __MMC_MVSDIO_H 8 - #define __MMC_MVSDIO_H 9 - 10 - #include <linux/mbus.h> 11 - 12 - struct mvsdio_platform_data { 13 - unsigned int clock; 14 - int gpio_card_detect; 15 - int gpio_write_protect; 16 - }; 17 - 18 - #endif
+1 -2
lib/Kconfig.debug
··· 1534 1534 1535 1535 config FAIL_MMC_REQUEST 1536 1536 bool "Fault-injection capability for MMC IO" 1537 - select DEBUG_FS 1538 - depends on FAULT_INJECTION && MMC 1537 + depends on FAULT_INJECTION_DEBUG_FS && MMC 1539 1538 help 1540 1539 Provide fault-injection capability for MMC IO. 1541 1540 This will make the mmc core return data errors. This is