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