diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-03-28 23:59:45 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-03-28 23:59:45 -0400 |
commit | b5174fa3a7f4f8f150bfa3b917c92608953dfa0f (patch) | |
tree | 5efd32dd52fe55f760094e78f18acd3ff869751d /drivers/mmc | |
parent | afb9bd704c7116076879352a2cc2c43aa12c1e14 (diff) | |
parent | 135111cc5595c6a24dd826d503e2d2bae92da1c4 (diff) |
Merge tag 'mmc-merge-for-3.4-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/cjb/mmc
Pull MMC updates from Chris Ball:
Core:
* Support for MMC 4.5 Data Tag feature -- we tag REQ_META, so devices
that support Data Tag will provide increased throughput for metadata.
* Faster detection of card removal on I/O errors.
Drivers:
* dw_mmc now supports eMMC Power Off Notify, has PCI support, and
implements pre_req and post_req for asynchronous requests.
* omap_hsmmc now supports device tree.
* esdhc now has power management support.
* sdhci-tegra now supports Tegra30 devices.
* sdhci-spear now supports hibernation.
* tmio_mmc now supports using a GPIO for card detection.
* Intel PCH now supports 8-bit bus transfers.
* tag 'mmc-merge-for-3.4-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/cjb/mmc: (53 commits)
mmc: sh_mmcif: simplify bitmask macros
mmc: sh_mobile_sdhi: support modular mmc-core with non-standard hotplug
mmc: sh_mobile_sdhi: add a callback for board specific init code
mmc: tmio: cosmetic: prettify the tmio_mmc_set_ios() function
mmc: sh_mobile_sdhi: do not manage PM clocks manually
mmc: tmio_mmc: remove unused sdio_irq_enabled flag
mmc: tmio_mmc: power status flag doesn't have to be exposed in platform data
mmc: sh_mobile_sdhi: pass card hotplug GPIO number to TMIO MMC
mmc: tmio_mmc: support the generic MMC GPIO card hotplug helper
mmc: tmio: calculate the native hotplug condition only once
mmc: simplify mmc_cd_gpio_request() by removing two parameters
mmc: sdhci-pci: allow 8-bit bus width for Intel PCH
mmc: sdhci: check interrupt flags in ISR again
mmc: sdhci-pci: Add MSI support
mmc: core: warn when card doesn't support HPI
mmc: davinci: Poll status for small size transfers
mmc: davinci: Eliminate spurious interrupts
mmc: omap_hsmmc: Avoid a regulator voltage change with dt
mmc: omap_hsmmc: Convert hsmmc driver to use device tree
mmc: sdhci-pci: add SDHCI_QUIRK2_HOST_OFF_CARD_ON for Medfield SDIO
...
Diffstat (limited to 'drivers/mmc')
26 files changed, 1058 insertions, 645 deletions
diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c index 4c3b2847e47c..eed213a5c8cb 100644 --- a/drivers/mmc/card/block.c +++ b/drivers/mmc/card/block.c | |||
@@ -1079,6 +1079,7 @@ static void mmc_blk_rw_rq_prep(struct mmc_queue_req *mqrq, | |||
1079 | struct mmc_blk_request *brq = &mqrq->brq; | 1079 | struct mmc_blk_request *brq = &mqrq->brq; |
1080 | struct request *req = mqrq->req; | 1080 | struct request *req = mqrq->req; |
1081 | struct mmc_blk_data *md = mq->data; | 1081 | struct mmc_blk_data *md = mq->data; |
1082 | bool do_data_tag; | ||
1082 | 1083 | ||
1083 | /* | 1084 | /* |
1084 | * Reliable writes are used to implement Forced Unit Access and | 1085 | * Reliable writes are used to implement Forced Unit Access and |
@@ -1155,6 +1156,16 @@ static void mmc_blk_rw_rq_prep(struct mmc_queue_req *mqrq, | |||
1155 | mmc_apply_rel_rw(brq, card, req); | 1156 | mmc_apply_rel_rw(brq, card, req); |
1156 | 1157 | ||
1157 | /* | 1158 | /* |
1159 | * Data tag is used only during writing meta data to speed | ||
1160 | * up write and any subsequent read of this meta data | ||
1161 | */ | ||
1162 | do_data_tag = (card->ext_csd.data_tag_unit_size) && | ||
1163 | (req->cmd_flags & REQ_META) && | ||
1164 | (rq_data_dir(req) == WRITE) && | ||
1165 | ((brq->data.blocks * brq->data.blksz) >= | ||
1166 | card->ext_csd.data_tag_unit_size); | ||
1167 | |||
1168 | /* | ||
1158 | * Pre-defined multi-block transfers are preferable to | 1169 | * Pre-defined multi-block transfers are preferable to |
1159 | * open ended-ones (and necessary for reliable writes). | 1170 | * open ended-ones (and necessary for reliable writes). |
1160 | * However, it is not sufficient to just send CMD23, | 1171 | * However, it is not sufficient to just send CMD23, |
@@ -1172,13 +1183,13 @@ static void mmc_blk_rw_rq_prep(struct mmc_queue_req *mqrq, | |||
1172 | * We'll avoid using CMD23-bounded multiblock writes for | 1183 | * We'll avoid using CMD23-bounded multiblock writes for |
1173 | * these, while retaining features like reliable writes. | 1184 | * these, while retaining features like reliable writes. |
1174 | */ | 1185 | */ |
1175 | 1186 | if ((md->flags & MMC_BLK_CMD23) && mmc_op_multi(brq->cmd.opcode) && | |
1176 | if ((md->flags & MMC_BLK_CMD23) && | 1187 | (do_rel_wr || !(card->quirks & MMC_QUIRK_BLK_NO_CMD23) || |
1177 | mmc_op_multi(brq->cmd.opcode) && | 1188 | do_data_tag)) { |
1178 | (do_rel_wr || !(card->quirks & MMC_QUIRK_BLK_NO_CMD23))) { | ||
1179 | brq->sbc.opcode = MMC_SET_BLOCK_COUNT; | 1189 | brq->sbc.opcode = MMC_SET_BLOCK_COUNT; |
1180 | brq->sbc.arg = brq->data.blocks | | 1190 | brq->sbc.arg = brq->data.blocks | |
1181 | (do_rel_wr ? (1 << 31) : 0); | 1191 | (do_rel_wr ? (1 << 31) : 0) | |
1192 | (do_data_tag ? (1 << 29) : 0); | ||
1182 | brq->sbc.flags = MMC_RSP_R1 | MMC_CMD_AC; | 1193 | brq->sbc.flags = MMC_RSP_R1 | MMC_CMD_AC; |
1183 | brq->mrq.sbc = &brq->sbc; | 1194 | brq->mrq.sbc = &brq->sbc; |
1184 | } | 1195 | } |
diff --git a/drivers/mmc/core/cd-gpio.c b/drivers/mmc/core/cd-gpio.c index 082202ae4a03..29de31e260dd 100644 --- a/drivers/mmc/core/cd-gpio.c +++ b/drivers/mmc/core/cd-gpio.c | |||
@@ -28,13 +28,17 @@ static irqreturn_t mmc_cd_gpio_irqt(int irq, void *dev_id) | |||
28 | return IRQ_HANDLED; | 28 | return IRQ_HANDLED; |
29 | } | 29 | } |
30 | 30 | ||
31 | int mmc_cd_gpio_request(struct mmc_host *host, unsigned int gpio, | 31 | int mmc_cd_gpio_request(struct mmc_host *host, unsigned int gpio) |
32 | unsigned int irq, unsigned long flags) | ||
33 | { | 32 | { |
34 | size_t len = strlen(dev_name(host->parent)) + 4; | 33 | size_t len = strlen(dev_name(host->parent)) + 4; |
35 | struct mmc_cd_gpio *cd = kmalloc(sizeof(*cd) + len, GFP_KERNEL); | 34 | struct mmc_cd_gpio *cd; |
35 | int irq = gpio_to_irq(gpio); | ||
36 | int ret; | 36 | int ret; |
37 | 37 | ||
38 | if (irq < 0) | ||
39 | return irq; | ||
40 | |||
41 | cd = kmalloc(sizeof(*cd) + len, GFP_KERNEL); | ||
38 | if (!cd) | 42 | if (!cd) |
39 | return -ENOMEM; | 43 | return -ENOMEM; |
40 | 44 | ||
@@ -45,7 +49,8 @@ int mmc_cd_gpio_request(struct mmc_host *host, unsigned int gpio, | |||
45 | goto egpioreq; | 49 | goto egpioreq; |
46 | 50 | ||
47 | ret = request_threaded_irq(irq, NULL, mmc_cd_gpio_irqt, | 51 | ret = request_threaded_irq(irq, NULL, mmc_cd_gpio_irqt, |
48 | flags, cd->label, host); | 52 | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, |
53 | cd->label, host); | ||
49 | if (ret < 0) | 54 | if (ret < 0) |
50 | goto eirqreq; | 55 | goto eirqreq; |
51 | 56 | ||
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 132378b89d76..14f262e9246d 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c | |||
@@ -188,6 +188,12 @@ mmc_start_request(struct mmc_host *host, struct mmc_request *mrq) | |||
188 | struct scatterlist *sg; | 188 | struct scatterlist *sg; |
189 | #endif | 189 | #endif |
190 | 190 | ||
191 | if (mrq->sbc) { | ||
192 | pr_debug("<%s: starting CMD%u arg %08x flags %08x>\n", | ||
193 | mmc_hostname(host), mrq->sbc->opcode, | ||
194 | mrq->sbc->arg, mrq->sbc->flags); | ||
195 | } | ||
196 | |||
191 | pr_debug("%s: starting CMD%u arg %08x flags %08x\n", | 197 | pr_debug("%s: starting CMD%u arg %08x flags %08x\n", |
192 | mmc_hostname(host), mrq->cmd->opcode, | 198 | mmc_hostname(host), mrq->cmd->opcode, |
193 | mrq->cmd->arg, mrq->cmd->flags); | 199 | mrq->cmd->arg, mrq->cmd->flags); |
@@ -243,16 +249,17 @@ static void mmc_wait_done(struct mmc_request *mrq) | |||
243 | complete(&mrq->completion); | 249 | complete(&mrq->completion); |
244 | } | 250 | } |
245 | 251 | ||
246 | static void __mmc_start_req(struct mmc_host *host, struct mmc_request *mrq) | 252 | static int __mmc_start_req(struct mmc_host *host, struct mmc_request *mrq) |
247 | { | 253 | { |
248 | init_completion(&mrq->completion); | 254 | init_completion(&mrq->completion); |
249 | mrq->done = mmc_wait_done; | 255 | mrq->done = mmc_wait_done; |
250 | if (mmc_card_removed(host->card)) { | 256 | if (mmc_card_removed(host->card)) { |
251 | mrq->cmd->error = -ENOMEDIUM; | 257 | mrq->cmd->error = -ENOMEDIUM; |
252 | complete(&mrq->completion); | 258 | complete(&mrq->completion); |
253 | return; | 259 | return -ENOMEDIUM; |
254 | } | 260 | } |
255 | mmc_start_request(host, mrq); | 261 | mmc_start_request(host, mrq); |
262 | return 0; | ||
256 | } | 263 | } |
257 | 264 | ||
258 | static void mmc_wait_for_req_done(struct mmc_host *host, | 265 | static void mmc_wait_for_req_done(struct mmc_host *host, |
@@ -336,6 +343,7 @@ struct mmc_async_req *mmc_start_req(struct mmc_host *host, | |||
336 | struct mmc_async_req *areq, int *error) | 343 | struct mmc_async_req *areq, int *error) |
337 | { | 344 | { |
338 | int err = 0; | 345 | int err = 0; |
346 | int start_err = 0; | ||
339 | struct mmc_async_req *data = host->areq; | 347 | struct mmc_async_req *data = host->areq; |
340 | 348 | ||
341 | /* Prepare a new request */ | 349 | /* Prepare a new request */ |
@@ -345,30 +353,23 @@ struct mmc_async_req *mmc_start_req(struct mmc_host *host, | |||
345 | if (host->areq) { | 353 | if (host->areq) { |
346 | mmc_wait_for_req_done(host, host->areq->mrq); | 354 | mmc_wait_for_req_done(host, host->areq->mrq); |
347 | err = host->areq->err_check(host->card, host->areq); | 355 | err = host->areq->err_check(host->card, host->areq); |
348 | if (err) { | ||
349 | /* post process the completed failed request */ | ||
350 | mmc_post_req(host, host->areq->mrq, 0); | ||
351 | if (areq) | ||
352 | /* | ||
353 | * Cancel the new prepared request, because | ||
354 | * it can't run until the failed | ||
355 | * request has been properly handled. | ||
356 | */ | ||
357 | mmc_post_req(host, areq->mrq, -EINVAL); | ||
358 | |||
359 | host->areq = NULL; | ||
360 | goto out; | ||
361 | } | ||
362 | } | 356 | } |
363 | 357 | ||
364 | if (areq) | 358 | if (!err && areq) |
365 | __mmc_start_req(host, areq->mrq); | 359 | start_err = __mmc_start_req(host, areq->mrq); |
366 | 360 | ||
367 | if (host->areq) | 361 | if (host->areq) |
368 | mmc_post_req(host, host->areq->mrq, 0); | 362 | mmc_post_req(host, host->areq->mrq, 0); |
369 | 363 | ||
370 | host->areq = areq; | 364 | /* Cancel a prepared request if it was not started. */ |
371 | out: | 365 | if ((err || start_err) && areq) |
366 | mmc_post_req(host, areq->mrq, -EINVAL); | ||
367 | |||
368 | if (err) | ||
369 | host->areq = NULL; | ||
370 | else | ||
371 | host->areq = areq; | ||
372 | |||
372 | if (error) | 373 | if (error) |
373 | *error = err; | 374 | *error = err; |
374 | return data; | 375 | return data; |
@@ -599,105 +600,6 @@ unsigned int mmc_align_data_size(struct mmc_card *card, unsigned int sz) | |||
599 | EXPORT_SYMBOL(mmc_align_data_size); | 600 | EXPORT_SYMBOL(mmc_align_data_size); |
600 | 601 | ||
601 | /** | 602 | /** |
602 | * mmc_host_enable - enable a host. | ||
603 | * @host: mmc host to enable | ||
604 | * | ||
605 | * Hosts that support power saving can use the 'enable' and 'disable' | ||
606 | * methods to exit and enter power saving states. For more information | ||
607 | * see comments for struct mmc_host_ops. | ||
608 | */ | ||
609 | int mmc_host_enable(struct mmc_host *host) | ||
610 | { | ||
611 | if (!(host->caps & MMC_CAP_DISABLE)) | ||
612 | return 0; | ||
613 | |||
614 | if (host->en_dis_recurs) | ||
615 | return 0; | ||
616 | |||
617 | if (host->nesting_cnt++) | ||
618 | return 0; | ||
619 | |||
620 | cancel_delayed_work_sync(&host->disable); | ||
621 | |||
622 | if (host->enabled) | ||
623 | return 0; | ||
624 | |||
625 | if (host->ops->enable) { | ||
626 | int err; | ||
627 | |||
628 | host->en_dis_recurs = 1; | ||
629 | mmc_host_clk_hold(host); | ||
630 | err = host->ops->enable(host); | ||
631 | mmc_host_clk_release(host); | ||
632 | host->en_dis_recurs = 0; | ||
633 | |||
634 | if (err) { | ||
635 | pr_debug("%s: enable error %d\n", | ||
636 | mmc_hostname(host), err); | ||
637 | return err; | ||
638 | } | ||
639 | } | ||
640 | host->enabled = 1; | ||
641 | return 0; | ||
642 | } | ||
643 | EXPORT_SYMBOL(mmc_host_enable); | ||
644 | |||
645 | static int mmc_host_do_disable(struct mmc_host *host, int lazy) | ||
646 | { | ||
647 | if (host->ops->disable) { | ||
648 | int err; | ||
649 | |||
650 | host->en_dis_recurs = 1; | ||
651 | mmc_host_clk_hold(host); | ||
652 | err = host->ops->disable(host, lazy); | ||
653 | mmc_host_clk_release(host); | ||
654 | host->en_dis_recurs = 0; | ||
655 | |||
656 | if (err < 0) { | ||
657 | pr_debug("%s: disable error %d\n", | ||
658 | mmc_hostname(host), err); | ||
659 | return err; | ||
660 | } | ||
661 | if (err > 0) { | ||
662 | unsigned long delay = msecs_to_jiffies(err); | ||
663 | |||
664 | mmc_schedule_delayed_work(&host->disable, delay); | ||
665 | } | ||
666 | } | ||
667 | host->enabled = 0; | ||
668 | return 0; | ||
669 | } | ||
670 | |||
671 | /** | ||
672 | * mmc_host_disable - disable a host. | ||
673 | * @host: mmc host to disable | ||
674 | * | ||
675 | * Hosts that support power saving can use the 'enable' and 'disable' | ||
676 | * methods to exit and enter power saving states. For more information | ||
677 | * see comments for struct mmc_host_ops. | ||
678 | */ | ||
679 | int mmc_host_disable(struct mmc_host *host) | ||
680 | { | ||
681 | int err; | ||
682 | |||
683 | if (!(host->caps & MMC_CAP_DISABLE)) | ||
684 | return 0; | ||
685 | |||
686 | if (host->en_dis_recurs) | ||
687 | return 0; | ||
688 | |||
689 | if (--host->nesting_cnt) | ||
690 | return 0; | ||
691 | |||
692 | if (!host->enabled) | ||
693 | return 0; | ||
694 | |||
695 | err = mmc_host_do_disable(host, 0); | ||
696 | return err; | ||
697 | } | ||
698 | EXPORT_SYMBOL(mmc_host_disable); | ||
699 | |||
700 | /** | ||
701 | * __mmc_claim_host - exclusively claim a host | 603 | * __mmc_claim_host - exclusively claim a host |
702 | * @host: mmc host to claim | 604 | * @host: mmc host to claim |
703 | * @abort: whether or not the operation should be aborted | 605 | * @abort: whether or not the operation should be aborted |
@@ -735,8 +637,8 @@ int __mmc_claim_host(struct mmc_host *host, atomic_t *abort) | |||
735 | wake_up(&host->wq); | 637 | wake_up(&host->wq); |
736 | spin_unlock_irqrestore(&host->lock, flags); | 638 | spin_unlock_irqrestore(&host->lock, flags); |
737 | remove_wait_queue(&host->wq, &wait); | 639 | remove_wait_queue(&host->wq, &wait); |
738 | if (!stop) | 640 | if (host->ops->enable && !stop && host->claim_cnt == 1) |
739 | mmc_host_enable(host); | 641 | host->ops->enable(host); |
740 | return stop; | 642 | return stop; |
741 | } | 643 | } |
742 | 644 | ||
@@ -761,21 +663,28 @@ int mmc_try_claim_host(struct mmc_host *host) | |||
761 | claimed_host = 1; | 663 | claimed_host = 1; |
762 | } | 664 | } |
763 | spin_unlock_irqrestore(&host->lock, flags); | 665 | spin_unlock_irqrestore(&host->lock, flags); |
666 | if (host->ops->enable && claimed_host && host->claim_cnt == 1) | ||
667 | host->ops->enable(host); | ||
764 | return claimed_host; | 668 | return claimed_host; |
765 | } | 669 | } |
766 | EXPORT_SYMBOL(mmc_try_claim_host); | 670 | EXPORT_SYMBOL(mmc_try_claim_host); |
767 | 671 | ||
768 | /** | 672 | /** |
769 | * mmc_do_release_host - release a claimed host | 673 | * mmc_release_host - release a host |
770 | * @host: mmc host to release | 674 | * @host: mmc host to release |
771 | * | 675 | * |
772 | * If you successfully claimed a host, this function will | 676 | * Release a MMC host, allowing others to claim the host |
773 | * release it again. | 677 | * for their operations. |
774 | */ | 678 | */ |
775 | void mmc_do_release_host(struct mmc_host *host) | 679 | void mmc_release_host(struct mmc_host *host) |
776 | { | 680 | { |
777 | unsigned long flags; | 681 | unsigned long flags; |
778 | 682 | ||
683 | WARN_ON(!host->claimed); | ||
684 | |||
685 | if (host->ops->disable && host->claim_cnt == 1) | ||
686 | host->ops->disable(host); | ||
687 | |||
779 | spin_lock_irqsave(&host->lock, flags); | 688 | spin_lock_irqsave(&host->lock, flags); |
780 | if (--host->claim_cnt) { | 689 | if (--host->claim_cnt) { |
781 | /* Release for nested claim */ | 690 | /* Release for nested claim */ |
@@ -787,67 +696,6 @@ void mmc_do_release_host(struct mmc_host *host) | |||
787 | wake_up(&host->wq); | 696 | wake_up(&host->wq); |
788 | } | 697 | } |
789 | } | 698 | } |
790 | EXPORT_SYMBOL(mmc_do_release_host); | ||
791 | |||
792 | void mmc_host_deeper_disable(struct work_struct *work) | ||
793 | { | ||
794 | struct mmc_host *host = | ||
795 | container_of(work, struct mmc_host, disable.work); | ||
796 | |||
797 | /* If the host is claimed then we do not want to disable it anymore */ | ||
798 | if (!mmc_try_claim_host(host)) | ||
799 | return; | ||
800 | mmc_host_do_disable(host, 1); | ||
801 | mmc_do_release_host(host); | ||
802 | } | ||
803 | |||
804 | /** | ||
805 | * mmc_host_lazy_disable - lazily disable a host. | ||
806 | * @host: mmc host to disable | ||
807 | * | ||
808 | * Hosts that support power saving can use the 'enable' and 'disable' | ||
809 | * methods to exit and enter power saving states. For more information | ||
810 | * see comments for struct mmc_host_ops. | ||
811 | */ | ||
812 | int mmc_host_lazy_disable(struct mmc_host *host) | ||
813 | { | ||
814 | if (!(host->caps & MMC_CAP_DISABLE)) | ||
815 | return 0; | ||
816 | |||
817 | if (host->en_dis_recurs) | ||
818 | return 0; | ||
819 | |||
820 | if (--host->nesting_cnt) | ||
821 | return 0; | ||
822 | |||
823 | if (!host->enabled) | ||
824 | return 0; | ||
825 | |||
826 | if (host->disable_delay) { | ||
827 | mmc_schedule_delayed_work(&host->disable, | ||
828 | msecs_to_jiffies(host->disable_delay)); | ||
829 | return 0; | ||
830 | } else | ||
831 | return mmc_host_do_disable(host, 1); | ||
832 | } | ||
833 | EXPORT_SYMBOL(mmc_host_lazy_disable); | ||
834 | |||
835 | /** | ||
836 | * mmc_release_host - release a host | ||
837 | * @host: mmc host to release | ||
838 | * | ||
839 | * Release a MMC host, allowing others to claim the host | ||
840 | * for their operations. | ||
841 | */ | ||
842 | void mmc_release_host(struct mmc_host *host) | ||
843 | { | ||
844 | WARN_ON(!host->claimed); | ||
845 | |||
846 | mmc_host_lazy_disable(host); | ||
847 | |||
848 | mmc_do_release_host(host); | ||
849 | } | ||
850 | |||
851 | EXPORT_SYMBOL(mmc_release_host); | 699 | EXPORT_SYMBOL(mmc_release_host); |
852 | 700 | ||
853 | /* | 701 | /* |
@@ -2115,18 +1963,36 @@ int _mmc_detect_card_removed(struct mmc_host *host) | |||
2115 | int mmc_detect_card_removed(struct mmc_host *host) | 1963 | int mmc_detect_card_removed(struct mmc_host *host) |
2116 | { | 1964 | { |
2117 | struct mmc_card *card = host->card; | 1965 | struct mmc_card *card = host->card; |
1966 | int ret; | ||
2118 | 1967 | ||
2119 | WARN_ON(!host->claimed); | 1968 | WARN_ON(!host->claimed); |
1969 | |||
1970 | if (!card) | ||
1971 | return 1; | ||
1972 | |||
1973 | ret = mmc_card_removed(card); | ||
2120 | /* | 1974 | /* |
2121 | * The card will be considered unchanged unless we have been asked to | 1975 | * The card will be considered unchanged unless we have been asked to |
2122 | * detect a change or host requires polling to provide card detection. | 1976 | * detect a change or host requires polling to provide card detection. |
2123 | */ | 1977 | */ |
2124 | if (card && !host->detect_change && !(host->caps & MMC_CAP_NEEDS_POLL)) | 1978 | if (!host->detect_change && !(host->caps & MMC_CAP_NEEDS_POLL) && |
2125 | return mmc_card_removed(card); | 1979 | !(host->caps2 & MMC_CAP2_DETECT_ON_ERR)) |
1980 | return ret; | ||
2126 | 1981 | ||
2127 | host->detect_change = 0; | 1982 | host->detect_change = 0; |
1983 | if (!ret) { | ||
1984 | ret = _mmc_detect_card_removed(host); | ||
1985 | if (ret && (host->caps2 & MMC_CAP2_DETECT_ON_ERR)) { | ||
1986 | /* | ||
1987 | * Schedule a detect work as soon as possible to let a | ||
1988 | * rescan handle the card removal. | ||
1989 | */ | ||
1990 | cancel_delayed_work(&host->detect); | ||
1991 | mmc_detect_change(host, 0); | ||
1992 | } | ||
1993 | } | ||
2128 | 1994 | ||
2129 | return _mmc_detect_card_removed(host); | 1995 | return ret; |
2130 | } | 1996 | } |
2131 | EXPORT_SYMBOL(mmc_detect_card_removed); | 1997 | EXPORT_SYMBOL(mmc_detect_card_removed); |
2132 | 1998 | ||
@@ -2203,8 +2069,6 @@ void mmc_stop_host(struct mmc_host *host) | |||
2203 | spin_unlock_irqrestore(&host->lock, flags); | 2069 | spin_unlock_irqrestore(&host->lock, flags); |
2204 | #endif | 2070 | #endif |
2205 | 2071 | ||
2206 | if (host->caps & MMC_CAP_DISABLE) | ||
2207 | cancel_delayed_work(&host->disable); | ||
2208 | cancel_delayed_work_sync(&host->detect); | 2072 | cancel_delayed_work_sync(&host->detect); |
2209 | mmc_flush_scheduled_work(); | 2073 | mmc_flush_scheduled_work(); |
2210 | 2074 | ||
@@ -2399,13 +2263,11 @@ int mmc_suspend_host(struct mmc_host *host) | |||
2399 | { | 2263 | { |
2400 | int err = 0; | 2264 | int err = 0; |
2401 | 2265 | ||
2402 | if (host->caps & MMC_CAP_DISABLE) | ||
2403 | cancel_delayed_work(&host->disable); | ||
2404 | cancel_delayed_work(&host->detect); | 2266 | cancel_delayed_work(&host->detect); |
2405 | mmc_flush_scheduled_work(); | 2267 | mmc_flush_scheduled_work(); |
2406 | if (mmc_try_claim_host(host)) { | 2268 | if (mmc_try_claim_host(host)) { |
2407 | err = mmc_cache_ctrl(host, 0); | 2269 | err = mmc_cache_ctrl(host, 0); |
2408 | mmc_do_release_host(host); | 2270 | mmc_release_host(host); |
2409 | } else { | 2271 | } else { |
2410 | err = -EBUSY; | 2272 | err = -EBUSY; |
2411 | } | 2273 | } |
@@ -2426,7 +2288,7 @@ int mmc_suspend_host(struct mmc_host *host) | |||
2426 | if (host->bus_ops->suspend) { | 2288 | if (host->bus_ops->suspend) { |
2427 | err = host->bus_ops->suspend(host); | 2289 | err = host->bus_ops->suspend(host); |
2428 | } | 2290 | } |
2429 | mmc_do_release_host(host); | 2291 | mmc_release_host(host); |
2430 | 2292 | ||
2431 | if (err == -ENOSYS || !host->bus_ops->resume) { | 2293 | if (err == -ENOSYS || !host->bus_ops->resume) { |
2432 | /* | 2294 | /* |
diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c index c3704e293a7b..91c84c7a1829 100644 --- a/drivers/mmc/core/host.c +++ b/drivers/mmc/core/host.c | |||
@@ -330,7 +330,6 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *dev) | |||
330 | spin_lock_init(&host->lock); | 330 | spin_lock_init(&host->lock); |
331 | init_waitqueue_head(&host->wq); | 331 | init_waitqueue_head(&host->wq); |
332 | INIT_DELAYED_WORK(&host->detect, mmc_rescan); | 332 | INIT_DELAYED_WORK(&host->detect, mmc_rescan); |
333 | INIT_DELAYED_WORK_DEFERRABLE(&host->disable, mmc_host_deeper_disable); | ||
334 | #ifdef CONFIG_PM | 333 | #ifdef CONFIG_PM |
335 | host->pm_notify.notifier_call = mmc_pm_notify; | 334 | host->pm_notify.notifier_call = mmc_pm_notify; |
336 | #endif | 335 | #endif |
diff --git a/drivers/mmc/core/host.h b/drivers/mmc/core/host.h index 08a7852ade44..f2ab9e578126 100644 --- a/drivers/mmc/core/host.h +++ b/drivers/mmc/core/host.h | |||
@@ -14,7 +14,6 @@ | |||
14 | 14 | ||
15 | int mmc_register_host_class(void); | 15 | int mmc_register_host_class(void); |
16 | void mmc_unregister_host_class(void); | 16 | void mmc_unregister_host_class(void); |
17 | void mmc_host_deeper_disable(struct work_struct *work); | ||
18 | 17 | ||
19 | #endif | 18 | #endif |
20 | 19 | ||
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index 2b9ed1401dc4..02914d609a91 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c | |||
@@ -519,6 +519,20 @@ static int mmc_read_ext_csd(struct mmc_card *card, u8 *ext_csd) | |||
519 | ext_csd[EXT_CSD_CACHE_SIZE + 1] << 8 | | 519 | ext_csd[EXT_CSD_CACHE_SIZE + 1] << 8 | |
520 | ext_csd[EXT_CSD_CACHE_SIZE + 2] << 16 | | 520 | ext_csd[EXT_CSD_CACHE_SIZE + 2] << 16 | |
521 | ext_csd[EXT_CSD_CACHE_SIZE + 3] << 24; | 521 | ext_csd[EXT_CSD_CACHE_SIZE + 3] << 24; |
522 | |||
523 | if (ext_csd[EXT_CSD_DATA_SECTOR_SIZE] == 1) | ||
524 | card->ext_csd.data_sector_size = 4096; | ||
525 | else | ||
526 | card->ext_csd.data_sector_size = 512; | ||
527 | |||
528 | if ((ext_csd[EXT_CSD_DATA_TAG_SUPPORT] & 1) && | ||
529 | (ext_csd[EXT_CSD_TAG_UNIT_SIZE] <= 8)) { | ||
530 | card->ext_csd.data_tag_unit_size = | ||
531 | ((unsigned int) 1 << ext_csd[EXT_CSD_TAG_UNIT_SIZE]) * | ||
532 | (card->ext_csd.data_sector_size); | ||
533 | } else { | ||
534 | card->ext_csd.data_tag_unit_size = 0; | ||
535 | } | ||
522 | } | 536 | } |
523 | 537 | ||
524 | out: | 538 | out: |
@@ -938,7 +952,8 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, | |||
938 | * If enhanced_area_en is TRUE, host needs to enable ERASE_GRP_DEF | 952 | * If enhanced_area_en is TRUE, host needs to enable ERASE_GRP_DEF |
939 | * bit. This bit will be lost every time after a reset or power off. | 953 | * bit. This bit will be lost every time after a reset or power off. |
940 | */ | 954 | */ |
941 | if (card->ext_csd.enhanced_area_en) { | 955 | if (card->ext_csd.enhanced_area_en || |
956 | (card->ext_csd.rev >= 3 && (host->caps2 & MMC_CAP2_HC_ERASE_SZ))) { | ||
942 | err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, | 957 | err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, |
943 | EXT_CSD_ERASE_GROUP_DEF, 1, | 958 | EXT_CSD_ERASE_GROUP_DEF, 1, |
944 | card->ext_csd.generic_cmd6_time); | 959 | card->ext_csd.generic_cmd6_time); |
@@ -1033,22 +1048,6 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, | |||
1033 | } | 1048 | } |
1034 | 1049 | ||
1035 | /* | 1050 | /* |
1036 | * Enable HPI feature (if supported) | ||
1037 | */ | ||
1038 | if (card->ext_csd.hpi) { | ||
1039 | err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, | ||
1040 | EXT_CSD_HPI_MGMT, 1, 0); | ||
1041 | if (err && err != -EBADMSG) | ||
1042 | goto free_card; | ||
1043 | if (err) { | ||
1044 | pr_warning("%s: Enabling HPI failed\n", | ||
1045 | mmc_hostname(card->host)); | ||
1046 | err = 0; | ||
1047 | } else | ||
1048 | card->ext_csd.hpi_en = 1; | ||
1049 | } | ||
1050 | |||
1051 | /* | ||
1052 | * Compute bus speed. | 1051 | * Compute bus speed. |
1053 | */ | 1052 | */ |
1054 | max_dtr = (unsigned int)-1; | 1053 | max_dtr = (unsigned int)-1; |
@@ -1097,9 +1096,12 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, | |||
1097 | * 4. execute tuning for HS200 | 1096 | * 4. execute tuning for HS200 |
1098 | */ | 1097 | */ |
1099 | if ((host->caps2 & MMC_CAP2_HS200) && | 1098 | if ((host->caps2 & MMC_CAP2_HS200) && |
1100 | card->host->ops->execute_tuning) | 1099 | card->host->ops->execute_tuning) { |
1100 | mmc_host_clk_hold(card->host); | ||
1101 | err = card->host->ops->execute_tuning(card->host, | 1101 | err = card->host->ops->execute_tuning(card->host, |
1102 | MMC_SEND_TUNING_BLOCK_HS200); | 1102 | MMC_SEND_TUNING_BLOCK_HS200); |
1103 | mmc_host_clk_release(card->host); | ||
1104 | } | ||
1103 | if (err) { | 1105 | if (err) { |
1104 | pr_warning("%s: tuning execution failed\n", | 1106 | pr_warning("%s: tuning execution failed\n", |
1105 | mmc_hostname(card->host)); | 1107 | mmc_hostname(card->host)); |
@@ -1219,6 +1221,23 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, | |||
1219 | } | 1221 | } |
1220 | 1222 | ||
1221 | /* | 1223 | /* |
1224 | * Enable HPI feature (if supported) | ||
1225 | */ | ||
1226 | if (card->ext_csd.hpi) { | ||
1227 | err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, | ||
1228 | EXT_CSD_HPI_MGMT, 1, | ||
1229 | card->ext_csd.generic_cmd6_time); | ||
1230 | if (err && err != -EBADMSG) | ||
1231 | goto free_card; | ||
1232 | if (err) { | ||
1233 | pr_warning("%s: Enabling HPI failed\n", | ||
1234 | mmc_hostname(card->host)); | ||
1235 | err = 0; | ||
1236 | } else | ||
1237 | card->ext_csd.hpi_en = 1; | ||
1238 | } | ||
1239 | |||
1240 | /* | ||
1222 | * If cache size is higher than 0, this indicates | 1241 | * If cache size is higher than 0, this indicates |
1223 | * the existence of cache and it can be turned on. | 1242 | * the existence of cache and it can be turned on. |
1224 | */ | 1243 | */ |
diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c index 4d41fa984c93..69370f494e05 100644 --- a/drivers/mmc/core/mmc_ops.c +++ b/drivers/mmc/core/mmc_ops.c | |||
@@ -553,18 +553,22 @@ int mmc_send_hpi_cmd(struct mmc_card *card, u32 *status) | |||
553 | { | 553 | { |
554 | struct mmc_command cmd = {0}; | 554 | struct mmc_command cmd = {0}; |
555 | unsigned int opcode; | 555 | unsigned int opcode; |
556 | unsigned int flags; | ||
557 | int err; | 556 | int err; |
558 | 557 | ||
558 | if (!card->ext_csd.hpi) { | ||
559 | pr_warning("%s: Card didn't support HPI command\n", | ||
560 | mmc_hostname(card->host)); | ||
561 | return -EINVAL; | ||
562 | } | ||
563 | |||
559 | opcode = card->ext_csd.hpi_cmd; | 564 | opcode = card->ext_csd.hpi_cmd; |
560 | if (opcode == MMC_STOP_TRANSMISSION) | 565 | if (opcode == MMC_STOP_TRANSMISSION) |
561 | flags = MMC_RSP_R1 | MMC_CMD_AC; | 566 | cmd.flags = MMC_RSP_R1B | MMC_CMD_AC; |
562 | else if (opcode == MMC_SEND_STATUS) | 567 | else if (opcode == MMC_SEND_STATUS) |
563 | flags = MMC_RSP_R1 | MMC_CMD_AC; | 568 | cmd.flags = MMC_RSP_R1 | MMC_CMD_AC; |
564 | 569 | ||
565 | cmd.opcode = opcode; | 570 | cmd.opcode = opcode; |
566 | cmd.arg = card->rca << 16 | 1; | 571 | cmd.arg = card->rca << 16 | 1; |
567 | cmd.flags = flags; | ||
568 | cmd.cmd_timeout_ms = card->ext_csd.out_of_int_time; | 572 | cmd.cmd_timeout_ms = card->ext_csd.out_of_int_time; |
569 | 573 | ||
570 | err = mmc_wait_for_cmd(card->host, &cmd, 0); | 574 | err = mmc_wait_for_cmd(card->host, &cmd, 0); |
diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig index ecbee9bf87b2..2bc06e7344db 100644 --- a/drivers/mmc/host/Kconfig +++ b/drivers/mmc/host/Kconfig | |||
@@ -533,6 +533,31 @@ config MMC_DW_IDMAC | |||
533 | Designware Mobile Storage IP block. This disables the external DMA | 533 | Designware Mobile Storage IP block. This disables the external DMA |
534 | interface. | 534 | interface. |
535 | 535 | ||
536 | config MMC_DW_PLTFM | ||
537 | tristate "Synopsys Designware MCI Support as platform device" | ||
538 | depends on MMC_DW | ||
539 | default y | ||
540 | help | ||
541 | This selects the common helper functions support for Host Controller | ||
542 | Interface based platform driver. Please select this option if the IP | ||
543 | is present as a platform device. This is the common interface for the | ||
544 | Synopsys Designware IP. | ||
545 | |||
546 | If you have a controller with this interface, say Y or M here. | ||
547 | |||
548 | If unsure, say Y. | ||
549 | |||
550 | config MMC_DW_PCI | ||
551 | tristate "Synopsys Designware MCI support on PCI bus" | ||
552 | depends on MMC_DW && PCI | ||
553 | help | ||
554 | This selects the PCI bus for the Synopsys Designware Mobile Storage IP. | ||
555 | Select this option if the IP is present on PCI platform. | ||
556 | |||
557 | If you have a controller with this interface, say Y or M here. | ||
558 | |||
559 | If unsure, say N. | ||
560 | |||
536 | config MMC_SH_MMCIF | 561 | config MMC_SH_MMCIF |
537 | tristate "SuperH Internal MMCIF support" | 562 | tristate "SuperH Internal MMCIF support" |
538 | depends on MMC_BLOCK && (SUPERH || ARCH_SHMOBILE) | 563 | depends on MMC_BLOCK && (SUPERH || ARCH_SHMOBILE) |
diff --git a/drivers/mmc/host/Makefile b/drivers/mmc/host/Makefile index 745f8fce2519..3e7e26d08073 100644 --- a/drivers/mmc/host/Makefile +++ b/drivers/mmc/host/Makefile | |||
@@ -39,6 +39,8 @@ obj-$(CONFIG_MMC_CB710) += cb710-mmc.o | |||
39 | obj-$(CONFIG_MMC_VIA_SDMMC) += via-sdmmc.o | 39 | obj-$(CONFIG_MMC_VIA_SDMMC) += via-sdmmc.o |
40 | obj-$(CONFIG_SDH_BFIN) += bfin_sdh.o | 40 | obj-$(CONFIG_SDH_BFIN) += bfin_sdh.o |
41 | obj-$(CONFIG_MMC_DW) += dw_mmc.o | 41 | obj-$(CONFIG_MMC_DW) += dw_mmc.o |
42 | obj-$(CONFIG_MMC_DW_PLTFM) += dw_mmc-pltfm.o | ||
43 | obj-$(CONFIG_MMC_DW_PCI) += dw_mmc-pci.o | ||
42 | obj-$(CONFIG_MMC_SH_MMCIF) += sh_mmcif.o | 44 | obj-$(CONFIG_MMC_SH_MMCIF) += sh_mmcif.o |
43 | obj-$(CONFIG_MMC_JZ4740) += jz4740_mmc.o | 45 | obj-$(CONFIG_MMC_JZ4740) += jz4740_mmc.o |
44 | obj-$(CONFIG_MMC_VUB300) += vub300.o | 46 | obj-$(CONFIG_MMC_VUB300) += vub300.o |
diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c index e4449a54ae8f..390863e7efbd 100644 --- a/drivers/mmc/host/atmel-mci.c +++ b/drivers/mmc/host/atmel-mci.c | |||
@@ -1975,7 +1975,7 @@ static bool atmci_configure_dma(struct atmel_mci *host) | |||
1975 | return false; | 1975 | return false; |
1976 | } else { | 1976 | } else { |
1977 | dev_info(&host->pdev->dev, | 1977 | dev_info(&host->pdev->dev, |
1978 | "Using %s for DMA transfers\n", | 1978 | "using %s for DMA transfers\n", |
1979 | dma_chan_name(host->dma.chan)); | 1979 | dma_chan_name(host->dma.chan)); |
1980 | return true; | 1980 | return true; |
1981 | } | 1981 | } |
diff --git a/drivers/mmc/host/davinci_mmc.c b/drivers/mmc/host/davinci_mmc.c index 64a8325a4a8a..c1f3673ae1ef 100644 --- a/drivers/mmc/host/davinci_mmc.c +++ b/drivers/mmc/host/davinci_mmc.c | |||
@@ -160,6 +160,16 @@ module_param(rw_threshold, uint, S_IRUGO); | |||
160 | MODULE_PARM_DESC(rw_threshold, | 160 | MODULE_PARM_DESC(rw_threshold, |
161 | "Read/Write threshold. Default = 32"); | 161 | "Read/Write threshold. Default = 32"); |
162 | 162 | ||
163 | static unsigned poll_threshold = 128; | ||
164 | module_param(poll_threshold, uint, S_IRUGO); | ||
165 | MODULE_PARM_DESC(poll_threshold, | ||
166 | "Polling transaction size threshold. Default = 128"); | ||
167 | |||
168 | static unsigned poll_loopcount = 32; | ||
169 | module_param(poll_loopcount, uint, S_IRUGO); | ||
170 | MODULE_PARM_DESC(poll_loopcount, | ||
171 | "Maximum polling loop count. Default = 32"); | ||
172 | |||
163 | static unsigned __initdata use_dma = 1; | 173 | static unsigned __initdata use_dma = 1; |
164 | module_param(use_dma, uint, 0); | 174 | module_param(use_dma, uint, 0); |
165 | MODULE_PARM_DESC(use_dma, "Whether to use DMA or not. Default = 1"); | 175 | MODULE_PARM_DESC(use_dma, "Whether to use DMA or not. Default = 1"); |
@@ -193,6 +203,7 @@ struct mmc_davinci_host { | |||
193 | bool use_dma; | 203 | bool use_dma; |
194 | bool do_dma; | 204 | bool do_dma; |
195 | bool sdio_int; | 205 | bool sdio_int; |
206 | bool active_request; | ||
196 | 207 | ||
197 | /* Scatterlist DMA uses one or more parameter RAM entries: | 208 | /* Scatterlist DMA uses one or more parameter RAM entries: |
198 | * the main one (associated with rxdma or txdma) plus zero or | 209 | * the main one (associated with rxdma or txdma) plus zero or |
@@ -219,6 +230,7 @@ struct mmc_davinci_host { | |||
219 | #endif | 230 | #endif |
220 | }; | 231 | }; |
221 | 232 | ||
233 | static irqreturn_t mmc_davinci_irq(int irq, void *dev_id); | ||
222 | 234 | ||
223 | /* PIO only */ | 235 | /* PIO only */ |
224 | static void mmc_davinci_sg_to_buf(struct mmc_davinci_host *host) | 236 | static void mmc_davinci_sg_to_buf(struct mmc_davinci_host *host) |
@@ -376,7 +388,20 @@ static void mmc_davinci_start_command(struct mmc_davinci_host *host, | |||
376 | 388 | ||
377 | writel(cmd->arg, host->base + DAVINCI_MMCARGHL); | 389 | writel(cmd->arg, host->base + DAVINCI_MMCARGHL); |
378 | writel(cmd_reg, host->base + DAVINCI_MMCCMD); | 390 | writel(cmd_reg, host->base + DAVINCI_MMCCMD); |
379 | writel(im_val, host->base + DAVINCI_MMCIM); | 391 | |
392 | host->active_request = true; | ||
393 | |||
394 | if (!host->do_dma && host->bytes_left <= poll_threshold) { | ||
395 | u32 count = poll_loopcount; | ||
396 | |||
397 | while (host->active_request && count--) { | ||
398 | mmc_davinci_irq(0, host); | ||
399 | cpu_relax(); | ||
400 | } | ||
401 | } | ||
402 | |||
403 | if (host->active_request) | ||
404 | writel(im_val, host->base + DAVINCI_MMCIM); | ||
380 | } | 405 | } |
381 | 406 | ||
382 | /*----------------------------------------------------------------------*/ | 407 | /*----------------------------------------------------------------------*/ |
@@ -915,6 +940,7 @@ mmc_davinci_xfer_done(struct mmc_davinci_host *host, struct mmc_data *data) | |||
915 | if (!data->stop || (host->cmd && host->cmd->error)) { | 940 | if (!data->stop || (host->cmd && host->cmd->error)) { |
916 | mmc_request_done(host->mmc, data->mrq); | 941 | mmc_request_done(host->mmc, data->mrq); |
917 | writel(0, host->base + DAVINCI_MMCIM); | 942 | writel(0, host->base + DAVINCI_MMCIM); |
943 | host->active_request = false; | ||
918 | } else | 944 | } else |
919 | mmc_davinci_start_command(host, data->stop); | 945 | mmc_davinci_start_command(host, data->stop); |
920 | } | 946 | } |
@@ -942,6 +968,7 @@ static void mmc_davinci_cmd_done(struct mmc_davinci_host *host, | |||
942 | cmd->mrq->cmd->retries = 0; | 968 | cmd->mrq->cmd->retries = 0; |
943 | mmc_request_done(host->mmc, cmd->mrq); | 969 | mmc_request_done(host->mmc, cmd->mrq); |
944 | writel(0, host->base + DAVINCI_MMCIM); | 970 | writel(0, host->base + DAVINCI_MMCIM); |
971 | host->active_request = false; | ||
945 | } | 972 | } |
946 | } | 973 | } |
947 | 974 | ||
@@ -1009,12 +1036,33 @@ static irqreturn_t mmc_davinci_irq(int irq, void *dev_id) | |||
1009 | * by read. So, it is not unbouned loop even in the case of | 1036 | * by read. So, it is not unbouned loop even in the case of |
1010 | * non-dma. | 1037 | * non-dma. |
1011 | */ | 1038 | */ |
1012 | while (host->bytes_left && (status & (MMCST0_DXRDY | MMCST0_DRRDY))) { | 1039 | if (host->bytes_left && (status & (MMCST0_DXRDY | MMCST0_DRRDY))) { |
1013 | davinci_fifo_data_trans(host, rw_threshold); | 1040 | unsigned long im_val; |
1014 | status = readl(host->base + DAVINCI_MMCST0); | 1041 | |
1015 | if (!status) | 1042 | /* |
1016 | break; | 1043 | * If interrupts fire during the following loop, they will be |
1017 | qstatus |= status; | 1044 | * handled by the handler, but the PIC will still buffer these. |
1045 | * As a result, the handler will be called again to serve these | ||
1046 | * needlessly. In order to avoid these spurious interrupts, | ||
1047 | * keep interrupts masked during the loop. | ||
1048 | */ | ||
1049 | im_val = readl(host->base + DAVINCI_MMCIM); | ||
1050 | writel(0, host->base + DAVINCI_MMCIM); | ||
1051 | |||
1052 | do { | ||
1053 | davinci_fifo_data_trans(host, rw_threshold); | ||
1054 | status = readl(host->base + DAVINCI_MMCST0); | ||
1055 | qstatus |= status; | ||
1056 | } while (host->bytes_left && | ||
1057 | (status & (MMCST0_DXRDY | MMCST0_DRRDY))); | ||
1058 | |||
1059 | /* | ||
1060 | * If an interrupt is pending, it is assumed it will fire when | ||
1061 | * it is unmasked. This assumption is also taken when the MMCIM | ||
1062 | * is first set. Otherwise, writing to MMCIM after reading the | ||
1063 | * status is race-prone. | ||
1064 | */ | ||
1065 | writel(im_val, host->base + DAVINCI_MMCIM); | ||
1018 | } | 1066 | } |
1019 | 1067 | ||
1020 | if (qstatus & MMCST0_DATDNE) { | 1068 | if (qstatus & MMCST0_DATDNE) { |
@@ -1418,17 +1466,14 @@ static int davinci_mmcsd_suspend(struct device *dev) | |||
1418 | struct mmc_davinci_host *host = platform_get_drvdata(pdev); | 1466 | struct mmc_davinci_host *host = platform_get_drvdata(pdev); |
1419 | int ret; | 1467 | int ret; |
1420 | 1468 | ||
1421 | mmc_host_enable(host->mmc); | ||
1422 | ret = mmc_suspend_host(host->mmc); | 1469 | ret = mmc_suspend_host(host->mmc); |
1423 | if (!ret) { | 1470 | if (!ret) { |
1424 | writel(0, host->base + DAVINCI_MMCIM); | 1471 | writel(0, host->base + DAVINCI_MMCIM); |
1425 | mmc_davinci_reset_ctrl(host, 1); | 1472 | mmc_davinci_reset_ctrl(host, 1); |
1426 | mmc_host_disable(host->mmc); | ||
1427 | clk_disable(host->clk); | 1473 | clk_disable(host->clk); |
1428 | host->suspended = 1; | 1474 | host->suspended = 1; |
1429 | } else { | 1475 | } else { |
1430 | host->suspended = 0; | 1476 | host->suspended = 0; |
1431 | mmc_host_disable(host->mmc); | ||
1432 | } | 1477 | } |
1433 | 1478 | ||
1434 | return ret; | 1479 | return ret; |
@@ -1444,7 +1489,6 @@ static int davinci_mmcsd_resume(struct device *dev) | |||
1444 | return 0; | 1489 | return 0; |
1445 | 1490 | ||
1446 | clk_enable(host->clk); | 1491 | clk_enable(host->clk); |
1447 | mmc_host_enable(host->mmc); | ||
1448 | 1492 | ||
1449 | mmc_davinci_reset_ctrl(host, 0); | 1493 | mmc_davinci_reset_ctrl(host, 0); |
1450 | ret = mmc_resume_host(host->mmc); | 1494 | ret = mmc_resume_host(host->mmc); |
diff --git a/drivers/mmc/host/dw_mmc-pci.c b/drivers/mmc/host/dw_mmc-pci.c new file mode 100644 index 000000000000..dc0d25a013e0 --- /dev/null +++ b/drivers/mmc/host/dw_mmc-pci.c | |||
@@ -0,0 +1,158 @@ | |||
1 | /* | ||
2 | * Synopsys DesignWare Multimedia Card PCI Interface driver | ||
3 | * | ||
4 | * Copyright (C) 2012 Vayavya Labs Pvt. Ltd. | ||
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 as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | */ | ||
11 | |||
12 | #include <linux/interrupt.h> | ||
13 | #include <linux/module.h> | ||
14 | #include <linux/io.h> | ||
15 | #include <linux/irq.h> | ||
16 | #include <linux/pci.h> | ||
17 | #include <linux/slab.h> | ||
18 | #include <linux/mmc/host.h> | ||
19 | #include <linux/mmc/mmc.h> | ||
20 | #include <linux/mmc/dw_mmc.h> | ||
21 | #include "dw_mmc.h" | ||
22 | |||
23 | #define PCI_BAR_NO 2 | ||
24 | #define COMPLETE_BAR 0 | ||
25 | #define SYNOPSYS_DW_MCI_VENDOR_ID 0x700 | ||
26 | #define SYNOPSYS_DW_MCI_DEVICE_ID 0x1107 | ||
27 | /* Defining the Capabilities */ | ||
28 | #define DW_MCI_CAPABILITIES (MMC_CAP_4_BIT_DATA | MMC_CAP_MMC_HIGHSPEED |\ | ||
29 | MMC_CAP_SD_HIGHSPEED | MMC_CAP_8_BIT_DATA |\ | ||
30 | MMC_CAP_SDIO_IRQ) | ||
31 | |||
32 | static struct dw_mci_board pci_board_data = { | ||
33 | .num_slots = 1, | ||
34 | .caps = DW_MCI_CAPABILITIES, | ||
35 | .bus_hz = 33 * 1000 * 1000, | ||
36 | .detect_delay_ms = 200, | ||
37 | .fifo_depth = 32, | ||
38 | }; | ||
39 | |||
40 | static int __devinit dw_mci_pci_probe(struct pci_dev *pdev, | ||
41 | const struct pci_device_id *entries) | ||
42 | { | ||
43 | struct dw_mci *host; | ||
44 | int ret; | ||
45 | |||
46 | ret = pci_enable_device(pdev); | ||
47 | if (ret) | ||
48 | return ret; | ||
49 | if (pci_request_regions(pdev, "dw_mmc_pci")) { | ||
50 | ret = -ENODEV; | ||
51 | goto err_disable_dev; | ||
52 | } | ||
53 | |||
54 | host = kzalloc(sizeof(struct dw_mci), GFP_KERNEL); | ||
55 | if (!host) { | ||
56 | ret = -ENOMEM; | ||
57 | goto err_release; | ||
58 | } | ||
59 | |||
60 | host->irq = pdev->irq; | ||
61 | host->irq_flags = IRQF_SHARED; | ||
62 | host->dev = pdev->dev; | ||
63 | host->pdata = &pci_board_data; | ||
64 | |||
65 | host->regs = pci_iomap(pdev, PCI_BAR_NO, COMPLETE_BAR); | ||
66 | if (!host->regs) { | ||
67 | ret = -EIO; | ||
68 | goto err_unmap; | ||
69 | } | ||
70 | |||
71 | pci_set_drvdata(pdev, host); | ||
72 | ret = dw_mci_probe(host); | ||
73 | if (ret) | ||
74 | goto err_probe_failed; | ||
75 | return ret; | ||
76 | |||
77 | err_probe_failed: | ||
78 | pci_iounmap(pdev, host->regs); | ||
79 | err_unmap: | ||
80 | kfree(host); | ||
81 | err_release: | ||
82 | pci_release_regions(pdev); | ||
83 | err_disable_dev: | ||
84 | pci_disable_device(pdev); | ||
85 | return ret; | ||
86 | } | ||
87 | |||
88 | static void __devexit dw_mci_pci_remove(struct pci_dev *pdev) | ||
89 | { | ||
90 | struct dw_mci *host = pci_get_drvdata(pdev); | ||
91 | |||
92 | dw_mci_remove(host); | ||
93 | pci_set_drvdata(pdev, NULL); | ||
94 | pci_release_regions(pdev); | ||
95 | pci_iounmap(pdev, host->regs); | ||
96 | kfree(host); | ||
97 | pci_disable_device(pdev); | ||
98 | } | ||
99 | |||
100 | #ifdef CONFIG_PM_SLEEP | ||
101 | static int dw_mci_pci_suspend(struct device *dev) | ||
102 | { | ||
103 | int ret; | ||
104 | struct pci_dev *pdev = to_pci_dev(dev); | ||
105 | struct dw_mci *host = pci_get_drvdata(pdev); | ||
106 | |||
107 | ret = dw_mci_suspend(host); | ||
108 | return ret; | ||
109 | } | ||
110 | |||
111 | static int dw_mci_pci_resume(struct device *dev) | ||
112 | { | ||
113 | int ret; | ||
114 | struct pci_dev *pdev = to_pci_dev(dev); | ||
115 | struct dw_mci *host = pci_get_drvdata(pdev); | ||
116 | |||
117 | ret = dw_mci_resume(host); | ||
118 | return ret; | ||
119 | } | ||
120 | #else | ||
121 | #define dw_mci_pci_suspend NULL | ||
122 | #define dw_mci_pci_resume NULL | ||
123 | #endif /* CONFIG_PM_SLEEP */ | ||
124 | |||
125 | static SIMPLE_DEV_PM_OPS(dw_mci_pci_pmops, dw_mci_pci_suspend, dw_mci_pci_resume); | ||
126 | |||
127 | static DEFINE_PCI_DEVICE_TABLE(dw_mci_pci_id) = { | ||
128 | { PCI_DEVICE(SYNOPSYS_DW_MCI_VENDOR_ID, SYNOPSYS_DW_MCI_DEVICE_ID) }, | ||
129 | {} | ||
130 | }; | ||
131 | MODULE_DEVICE_TABLE(pci, dw_mci_pci_id); | ||
132 | |||
133 | static struct pci_driver dw_mci_pci_driver = { | ||
134 | .name = "dw_mmc_pci", | ||
135 | .id_table = dw_mci_pci_id, | ||
136 | .probe = dw_mci_pci_probe, | ||
137 | .remove = dw_mci_pci_remove, | ||
138 | .driver = { | ||
139 | .pm = &dw_mci_pci_pmops | ||
140 | }, | ||
141 | }; | ||
142 | |||
143 | static int __init dw_mci_init(void) | ||
144 | { | ||
145 | return pci_register_driver(&dw_mci_pci_driver); | ||
146 | } | ||
147 | |||
148 | static void __exit dw_mci_exit(void) | ||
149 | { | ||
150 | pci_unregister_driver(&dw_mci_pci_driver); | ||
151 | } | ||
152 | |||
153 | module_init(dw_mci_init); | ||
154 | module_exit(dw_mci_exit); | ||
155 | |||
156 | MODULE_DESCRIPTION("DW Multimedia Card PCI Interface driver"); | ||
157 | MODULE_AUTHOR("Shashidhar Hiremath <shashidharh@vayavyalabs.com>"); | ||
158 | MODULE_LICENSE("GPL v2"); | ||
diff --git a/drivers/mmc/host/dw_mmc-pltfm.c b/drivers/mmc/host/dw_mmc-pltfm.c new file mode 100644 index 000000000000..92ec3eb3aae7 --- /dev/null +++ b/drivers/mmc/host/dw_mmc-pltfm.c | |||
@@ -0,0 +1,134 @@ | |||
1 | /* | ||
2 | * Synopsys DesignWare Multimedia Card Interface driver | ||
3 | * | ||
4 | * Copyright (C) 2009 NXP Semiconductors | ||
5 | * Copyright (C) 2009, 2010 Imagination Technologies Ltd. | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | */ | ||
12 | |||
13 | #include <linux/interrupt.h> | ||
14 | #include <linux/module.h> | ||
15 | #include <linux/io.h> | ||
16 | #include <linux/irq.h> | ||
17 | #include <linux/platform_device.h> | ||
18 | #include <linux/slab.h> | ||
19 | #include <linux/mmc/host.h> | ||
20 | #include <linux/mmc/mmc.h> | ||
21 | #include <linux/mmc/dw_mmc.h> | ||
22 | #include "dw_mmc.h" | ||
23 | |||
24 | static int dw_mci_pltfm_probe(struct platform_device *pdev) | ||
25 | { | ||
26 | struct dw_mci *host; | ||
27 | struct resource *regs; | ||
28 | int ret; | ||
29 | |||
30 | host = kzalloc(sizeof(struct dw_mci), GFP_KERNEL); | ||
31 | if (!host) | ||
32 | return -ENOMEM; | ||
33 | |||
34 | regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
35 | if (!regs) { | ||
36 | ret = -ENXIO; | ||
37 | goto err_free; | ||
38 | } | ||
39 | |||
40 | host->irq = platform_get_irq(pdev, 0); | ||
41 | if (host->irq < 0) { | ||
42 | ret = host->irq; | ||
43 | goto err_free; | ||
44 | } | ||
45 | |||
46 | host->dev = pdev->dev; | ||
47 | host->irq_flags = 0; | ||
48 | host->pdata = pdev->dev.platform_data; | ||
49 | ret = -ENOMEM; | ||
50 | host->regs = ioremap(regs->start, resource_size(regs)); | ||
51 | if (!host->regs) | ||
52 | goto err_free; | ||
53 | platform_set_drvdata(pdev, host); | ||
54 | ret = dw_mci_probe(host); | ||
55 | if (ret) | ||
56 | goto err_out; | ||
57 | return ret; | ||
58 | err_out: | ||
59 | iounmap(host->regs); | ||
60 | err_free: | ||
61 | kfree(host); | ||
62 | return ret; | ||
63 | } | ||
64 | |||
65 | static int __exit dw_mci_pltfm_remove(struct platform_device *pdev) | ||
66 | { | ||
67 | struct dw_mci *host = platform_get_drvdata(pdev); | ||
68 | |||
69 | platform_set_drvdata(pdev, NULL); | ||
70 | dw_mci_remove(host); | ||
71 | iounmap(host->regs); | ||
72 | kfree(host); | ||
73 | return 0; | ||
74 | } | ||
75 | |||
76 | #ifdef CONFIG_PM_SLEEP | ||
77 | /* | ||
78 | * TODO: we should probably disable the clock to the card in the suspend path. | ||
79 | */ | ||
80 | static int dw_mci_pltfm_suspend(struct device *dev) | ||
81 | { | ||
82 | int ret; | ||
83 | struct dw_mci *host = dev_get_drvdata(dev); | ||
84 | |||
85 | ret = dw_mci_suspend(host); | ||
86 | if (ret) | ||
87 | return ret; | ||
88 | |||
89 | return 0; | ||
90 | } | ||
91 | |||
92 | static int dw_mci_pltfm_resume(struct device *dev) | ||
93 | { | ||
94 | int ret; | ||
95 | struct dw_mci *host = dev_get_drvdata(dev); | ||
96 | |||
97 | ret = dw_mci_resume(host); | ||
98 | if (ret) | ||
99 | return ret; | ||
100 | |||
101 | return 0; | ||
102 | } | ||
103 | #else | ||
104 | #define dw_mci_pltfm_suspend NULL | ||
105 | #define dw_mci_pltfm_resume NULL | ||
106 | #endif /* CONFIG_PM_SLEEP */ | ||
107 | |||
108 | static SIMPLE_DEV_PM_OPS(dw_mci_pltfm_pmops, dw_mci_pltfm_suspend, dw_mci_pltfm_resume); | ||
109 | |||
110 | static struct platform_driver dw_mci_pltfm_driver = { | ||
111 | .remove = __exit_p(dw_mci_pltfm_remove), | ||
112 | .driver = { | ||
113 | .name = "dw_mmc", | ||
114 | .pm = &dw_mci_pltfm_pmops, | ||
115 | }, | ||
116 | }; | ||
117 | |||
118 | static int __init dw_mci_init(void) | ||
119 | { | ||
120 | return platform_driver_probe(&dw_mci_pltfm_driver, dw_mci_pltfm_probe); | ||
121 | } | ||
122 | |||
123 | static void __exit dw_mci_exit(void) | ||
124 | { | ||
125 | platform_driver_unregister(&dw_mci_pltfm_driver); | ||
126 | } | ||
127 | |||
128 | module_init(dw_mci_init); | ||
129 | module_exit(dw_mci_exit); | ||
130 | |||
131 | MODULE_DESCRIPTION("DW Multimedia Card Interface driver"); | ||
132 | MODULE_AUTHOR("NXP Semiconductor VietNam"); | ||
133 | MODULE_AUTHOR("Imagination Technologies Ltd"); | ||
134 | MODULE_LICENSE("GPL v2"); | ||
diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c index 8bec1c36b159..bf3c9b456aaf 100644 --- a/drivers/mmc/host/dw_mmc.c +++ b/drivers/mmc/host/dw_mmc.c | |||
@@ -268,7 +268,7 @@ static void dw_mci_start_command(struct dw_mci *host, | |||
268 | struct mmc_command *cmd, u32 cmd_flags) | 268 | struct mmc_command *cmd, u32 cmd_flags) |
269 | { | 269 | { |
270 | host->cmd = cmd; | 270 | host->cmd = cmd; |
271 | dev_vdbg(&host->pdev->dev, | 271 | dev_vdbg(&host->dev, |
272 | "start command: ARGR=0x%08x CMDR=0x%08x\n", | 272 | "start command: ARGR=0x%08x CMDR=0x%08x\n", |
273 | cmd->arg, cmd_flags); | 273 | cmd->arg, cmd_flags); |
274 | 274 | ||
@@ -295,15 +295,25 @@ static void dw_mci_stop_dma(struct dw_mci *host) | |||
295 | } | 295 | } |
296 | } | 296 | } |
297 | 297 | ||
298 | static int dw_mci_get_dma_dir(struct mmc_data *data) | ||
299 | { | ||
300 | if (data->flags & MMC_DATA_WRITE) | ||
301 | return DMA_TO_DEVICE; | ||
302 | else | ||
303 | return DMA_FROM_DEVICE; | ||
304 | } | ||
305 | |||
298 | #ifdef CONFIG_MMC_DW_IDMAC | 306 | #ifdef CONFIG_MMC_DW_IDMAC |
299 | static void dw_mci_dma_cleanup(struct dw_mci *host) | 307 | static void dw_mci_dma_cleanup(struct dw_mci *host) |
300 | { | 308 | { |
301 | struct mmc_data *data = host->data; | 309 | struct mmc_data *data = host->data; |
302 | 310 | ||
303 | if (data) | 311 | if (data) |
304 | dma_unmap_sg(&host->pdev->dev, data->sg, data->sg_len, | 312 | if (!data->host_cookie) |
305 | ((data->flags & MMC_DATA_WRITE) | 313 | dma_unmap_sg(&host->dev, |
306 | ? DMA_TO_DEVICE : DMA_FROM_DEVICE)); | 314 | data->sg, |
315 | data->sg_len, | ||
316 | dw_mci_get_dma_dir(data)); | ||
307 | } | 317 | } |
308 | 318 | ||
309 | static void dw_mci_idmac_stop_dma(struct dw_mci *host) | 319 | static void dw_mci_idmac_stop_dma(struct dw_mci *host) |
@@ -326,7 +336,7 @@ static void dw_mci_idmac_complete_dma(struct dw_mci *host) | |||
326 | { | 336 | { |
327 | struct mmc_data *data = host->data; | 337 | struct mmc_data *data = host->data; |
328 | 338 | ||
329 | dev_vdbg(&host->pdev->dev, "DMA complete\n"); | 339 | dev_vdbg(&host->dev, "DMA complete\n"); |
330 | 340 | ||
331 | host->dma_ops->cleanup(host); | 341 | host->dma_ops->cleanup(host); |
332 | 342 | ||
@@ -428,17 +438,15 @@ static struct dw_mci_dma_ops dw_mci_idmac_ops = { | |||
428 | }; | 438 | }; |
429 | #endif /* CONFIG_MMC_DW_IDMAC */ | 439 | #endif /* CONFIG_MMC_DW_IDMAC */ |
430 | 440 | ||
431 | static int dw_mci_submit_data_dma(struct dw_mci *host, struct mmc_data *data) | 441 | static int dw_mci_pre_dma_transfer(struct dw_mci *host, |
442 | struct mmc_data *data, | ||
443 | bool next) | ||
432 | { | 444 | { |
433 | struct scatterlist *sg; | 445 | struct scatterlist *sg; |
434 | unsigned int i, direction, sg_len; | 446 | unsigned int i, sg_len; |
435 | u32 temp; | ||
436 | 447 | ||
437 | host->using_dma = 0; | 448 | if (!next && data->host_cookie) |
438 | 449 | return data->host_cookie; | |
439 | /* If we don't have a channel, we can't do DMA */ | ||
440 | if (!host->use_dma) | ||
441 | return -ENODEV; | ||
442 | 450 | ||
443 | /* | 451 | /* |
444 | * We don't do DMA on "complex" transfers, i.e. with | 452 | * We don't do DMA on "complex" transfers, i.e. with |
@@ -447,6 +455,7 @@ static int dw_mci_submit_data_dma(struct dw_mci *host, struct mmc_data *data) | |||
447 | */ | 455 | */ |
448 | if (data->blocks * data->blksz < DW_MCI_DMA_THRESHOLD) | 456 | if (data->blocks * data->blksz < DW_MCI_DMA_THRESHOLD) |
449 | return -EINVAL; | 457 | return -EINVAL; |
458 | |||
450 | if (data->blksz & 3) | 459 | if (data->blksz & 3) |
451 | return -EINVAL; | 460 | return -EINVAL; |
452 | 461 | ||
@@ -455,17 +464,74 @@ static int dw_mci_submit_data_dma(struct dw_mci *host, struct mmc_data *data) | |||
455 | return -EINVAL; | 464 | return -EINVAL; |
456 | } | 465 | } |
457 | 466 | ||
458 | host->using_dma = 1; | 467 | sg_len = dma_map_sg(&host->dev, |
468 | data->sg, | ||
469 | data->sg_len, | ||
470 | dw_mci_get_dma_dir(data)); | ||
471 | if (sg_len == 0) | ||
472 | return -EINVAL; | ||
459 | 473 | ||
460 | if (data->flags & MMC_DATA_READ) | 474 | if (next) |
461 | direction = DMA_FROM_DEVICE; | 475 | data->host_cookie = sg_len; |
462 | else | ||
463 | direction = DMA_TO_DEVICE; | ||
464 | 476 | ||
465 | sg_len = dma_map_sg(&host->pdev->dev, data->sg, data->sg_len, | 477 | return sg_len; |
466 | direction); | 478 | } |
467 | 479 | ||
468 | dev_vdbg(&host->pdev->dev, | 480 | static void dw_mci_pre_req(struct mmc_host *mmc, |
481 | struct mmc_request *mrq, | ||
482 | bool is_first_req) | ||
483 | { | ||
484 | struct dw_mci_slot *slot = mmc_priv(mmc); | ||
485 | struct mmc_data *data = mrq->data; | ||
486 | |||
487 | if (!slot->host->use_dma || !data) | ||
488 | return; | ||
489 | |||
490 | if (data->host_cookie) { | ||
491 | data->host_cookie = 0; | ||
492 | return; | ||
493 | } | ||
494 | |||
495 | if (dw_mci_pre_dma_transfer(slot->host, mrq->data, 1) < 0) | ||
496 | data->host_cookie = 0; | ||
497 | } | ||
498 | |||
499 | static void dw_mci_post_req(struct mmc_host *mmc, | ||
500 | struct mmc_request *mrq, | ||
501 | int err) | ||
502 | { | ||
503 | struct dw_mci_slot *slot = mmc_priv(mmc); | ||
504 | struct mmc_data *data = mrq->data; | ||
505 | |||
506 | if (!slot->host->use_dma || !data) | ||
507 | return; | ||
508 | |||
509 | if (data->host_cookie) | ||
510 | dma_unmap_sg(&slot->host->dev, | ||
511 | data->sg, | ||
512 | data->sg_len, | ||
513 | dw_mci_get_dma_dir(data)); | ||
514 | data->host_cookie = 0; | ||
515 | } | ||
516 | |||
517 | static int dw_mci_submit_data_dma(struct dw_mci *host, struct mmc_data *data) | ||
518 | { | ||
519 | int sg_len; | ||
520 | u32 temp; | ||
521 | |||
522 | host->using_dma = 0; | ||
523 | |||
524 | /* If we don't have a channel, we can't do DMA */ | ||
525 | if (!host->use_dma) | ||
526 | return -ENODEV; | ||
527 | |||
528 | sg_len = dw_mci_pre_dma_transfer(host, data, 0); | ||
529 | if (sg_len < 0) | ||
530 | return sg_len; | ||
531 | |||
532 | host->using_dma = 1; | ||
533 | |||
534 | dev_vdbg(&host->dev, | ||
469 | "sd sg_cpu: %#lx sg_dma: %#lx sg_len: %d\n", | 535 | "sd sg_cpu: %#lx sg_dma: %#lx sg_len: %d\n", |
470 | (unsigned long)host->sg_cpu, (unsigned long)host->sg_dma, | 536 | (unsigned long)host->sg_cpu, (unsigned long)host->sg_dma, |
471 | sg_len); | 537 | sg_len); |
@@ -579,8 +645,8 @@ static void dw_mci_setup_bus(struct dw_mci_slot *slot) | |||
579 | SDMMC_CMD_UPD_CLK | SDMMC_CMD_PRV_DAT_WAIT, 0); | 645 | SDMMC_CMD_UPD_CLK | SDMMC_CMD_PRV_DAT_WAIT, 0); |
580 | 646 | ||
581 | /* enable clock */ | 647 | /* enable clock */ |
582 | mci_writel(host, CLKENA, SDMMC_CLKEN_ENABLE | | 648 | mci_writel(host, CLKENA, ((SDMMC_CLKEN_ENABLE | |
583 | SDMMC_CLKEN_LOW_PWR); | 649 | SDMMC_CLKEN_LOW_PWR) << slot->id)); |
584 | 650 | ||
585 | /* inform CIU */ | 651 | /* inform CIU */ |
586 | mci_send_cmd(slot, | 652 | mci_send_cmd(slot, |
@@ -800,6 +866,8 @@ static void dw_mci_enable_sdio_irq(struct mmc_host *mmc, int enb) | |||
800 | 866 | ||
801 | static const struct mmc_host_ops dw_mci_ops = { | 867 | static const struct mmc_host_ops dw_mci_ops = { |
802 | .request = dw_mci_request, | 868 | .request = dw_mci_request, |
869 | .pre_req = dw_mci_pre_req, | ||
870 | .post_req = dw_mci_post_req, | ||
803 | .set_ios = dw_mci_set_ios, | 871 | .set_ios = dw_mci_set_ios, |
804 | .get_ro = dw_mci_get_ro, | 872 | .get_ro = dw_mci_get_ro, |
805 | .get_cd = dw_mci_get_cd, | 873 | .get_cd = dw_mci_get_cd, |
@@ -821,12 +889,12 @@ static void dw_mci_request_end(struct dw_mci *host, struct mmc_request *mrq) | |||
821 | slot = list_entry(host->queue.next, | 889 | slot = list_entry(host->queue.next, |
822 | struct dw_mci_slot, queue_node); | 890 | struct dw_mci_slot, queue_node); |
823 | list_del(&slot->queue_node); | 891 | list_del(&slot->queue_node); |
824 | dev_vdbg(&host->pdev->dev, "list not empty: %s is next\n", | 892 | dev_vdbg(&host->dev, "list not empty: %s is next\n", |
825 | mmc_hostname(slot->mmc)); | 893 | mmc_hostname(slot->mmc)); |
826 | host->state = STATE_SENDING_CMD; | 894 | host->state = STATE_SENDING_CMD; |
827 | dw_mci_start_request(host, slot); | 895 | dw_mci_start_request(host, slot); |
828 | } else { | 896 | } else { |
829 | dev_vdbg(&host->pdev->dev, "list empty\n"); | 897 | dev_vdbg(&host->dev, "list empty\n"); |
830 | host->state = STATE_IDLE; | 898 | host->state = STATE_IDLE; |
831 | } | 899 | } |
832 | 900 | ||
@@ -965,7 +1033,7 @@ static void dw_mci_tasklet_func(unsigned long priv) | |||
965 | data->bytes_xfered = 0; | 1033 | data->bytes_xfered = 0; |
966 | data->error = -ETIMEDOUT; | 1034 | data->error = -ETIMEDOUT; |
967 | } else { | 1035 | } else { |
968 | dev_err(&host->pdev->dev, | 1036 | dev_err(&host->dev, |
969 | "data FIFO error " | 1037 | "data FIFO error " |
970 | "(status=%08x)\n", | 1038 | "(status=%08x)\n", |
971 | status); | 1039 | status); |
@@ -1682,7 +1750,7 @@ static int __init dw_mci_init_slot(struct dw_mci *host, unsigned int id) | |||
1682 | struct mmc_host *mmc; | 1750 | struct mmc_host *mmc; |
1683 | struct dw_mci_slot *slot; | 1751 | struct dw_mci_slot *slot; |
1684 | 1752 | ||
1685 | mmc = mmc_alloc_host(sizeof(struct dw_mci_slot), &host->pdev->dev); | 1753 | mmc = mmc_alloc_host(sizeof(struct dw_mci_slot), &host->dev); |
1686 | if (!mmc) | 1754 | if (!mmc) |
1687 | return -ENOMEM; | 1755 | return -ENOMEM; |
1688 | 1756 | ||
@@ -1720,13 +1788,11 @@ static int __init dw_mci_init_slot(struct dw_mci *host, unsigned int id) | |||
1720 | if (host->pdata->quirks & DW_MCI_QUIRK_HIGHSPEED) | 1788 | if (host->pdata->quirks & DW_MCI_QUIRK_HIGHSPEED) |
1721 | mmc->caps |= MMC_CAP_SD_HIGHSPEED | MMC_CAP_MMC_HIGHSPEED; | 1789 | mmc->caps |= MMC_CAP_SD_HIGHSPEED | MMC_CAP_MMC_HIGHSPEED; |
1722 | 1790 | ||
1723 | #ifdef CONFIG_MMC_DW_IDMAC | 1791 | if (mmc->caps2 & MMC_CAP2_POWEROFF_NOTIFY) |
1724 | mmc->max_segs = host->ring_size; | 1792 | mmc->power_notify_type = MMC_HOST_PW_NOTIFY_SHORT; |
1725 | mmc->max_blk_size = 65536; | 1793 | else |
1726 | mmc->max_blk_count = host->ring_size; | 1794 | mmc->power_notify_type = MMC_HOST_PW_NOTIFY_NONE; |
1727 | mmc->max_seg_size = 0x1000; | 1795 | |
1728 | mmc->max_req_size = mmc->max_seg_size * mmc->max_blk_count; | ||
1729 | #else | ||
1730 | if (host->pdata->blk_settings) { | 1796 | if (host->pdata->blk_settings) { |
1731 | mmc->max_segs = host->pdata->blk_settings->max_segs; | 1797 | mmc->max_segs = host->pdata->blk_settings->max_segs; |
1732 | mmc->max_blk_size = host->pdata->blk_settings->max_blk_size; | 1798 | mmc->max_blk_size = host->pdata->blk_settings->max_blk_size; |
@@ -1735,13 +1801,20 @@ static int __init dw_mci_init_slot(struct dw_mci *host, unsigned int id) | |||
1735 | mmc->max_seg_size = host->pdata->blk_settings->max_seg_size; | 1801 | mmc->max_seg_size = host->pdata->blk_settings->max_seg_size; |
1736 | } else { | 1802 | } else { |
1737 | /* Useful defaults if platform data is unset. */ | 1803 | /* Useful defaults if platform data is unset. */ |
1804 | #ifdef CONFIG_MMC_DW_IDMAC | ||
1805 | mmc->max_segs = host->ring_size; | ||
1806 | mmc->max_blk_size = 65536; | ||
1807 | mmc->max_blk_count = host->ring_size; | ||
1808 | mmc->max_seg_size = 0x1000; | ||
1809 | mmc->max_req_size = mmc->max_seg_size * mmc->max_blk_count; | ||
1810 | #else | ||
1738 | mmc->max_segs = 64; | 1811 | mmc->max_segs = 64; |
1739 | mmc->max_blk_size = 65536; /* BLKSIZ is 16 bits */ | 1812 | mmc->max_blk_size = 65536; /* BLKSIZ is 16 bits */ |
1740 | mmc->max_blk_count = 512; | 1813 | mmc->max_blk_count = 512; |
1741 | mmc->max_req_size = mmc->max_blk_size * mmc->max_blk_count; | 1814 | mmc->max_req_size = mmc->max_blk_size * mmc->max_blk_count; |
1742 | mmc->max_seg_size = mmc->max_req_size; | 1815 | mmc->max_seg_size = mmc->max_req_size; |
1743 | } | ||
1744 | #endif /* CONFIG_MMC_DW_IDMAC */ | 1816 | #endif /* CONFIG_MMC_DW_IDMAC */ |
1817 | } | ||
1745 | 1818 | ||
1746 | host->vmmc = regulator_get(mmc_dev(mmc), "vmmc"); | 1819 | host->vmmc = regulator_get(mmc_dev(mmc), "vmmc"); |
1747 | if (IS_ERR(host->vmmc)) { | 1820 | if (IS_ERR(host->vmmc)) { |
@@ -1789,10 +1862,10 @@ static void dw_mci_cleanup_slot(struct dw_mci_slot *slot, unsigned int id) | |||
1789 | static void dw_mci_init_dma(struct dw_mci *host) | 1862 | static void dw_mci_init_dma(struct dw_mci *host) |
1790 | { | 1863 | { |
1791 | /* Alloc memory for sg translation */ | 1864 | /* Alloc memory for sg translation */ |
1792 | host->sg_cpu = dma_alloc_coherent(&host->pdev->dev, PAGE_SIZE, | 1865 | host->sg_cpu = dma_alloc_coherent(&host->dev, PAGE_SIZE, |
1793 | &host->sg_dma, GFP_KERNEL); | 1866 | &host->sg_dma, GFP_KERNEL); |
1794 | if (!host->sg_cpu) { | 1867 | if (!host->sg_cpu) { |
1795 | dev_err(&host->pdev->dev, "%s: could not alloc DMA memory\n", | 1868 | dev_err(&host->dev, "%s: could not alloc DMA memory\n", |
1796 | __func__); | 1869 | __func__); |
1797 | goto no_dma; | 1870 | goto no_dma; |
1798 | } | 1871 | } |
@@ -1800,7 +1873,7 @@ static void dw_mci_init_dma(struct dw_mci *host) | |||
1800 | /* Determine which DMA interface to use */ | 1873 | /* Determine which DMA interface to use */ |
1801 | #ifdef CONFIG_MMC_DW_IDMAC | 1874 | #ifdef CONFIG_MMC_DW_IDMAC |
1802 | host->dma_ops = &dw_mci_idmac_ops; | 1875 | host->dma_ops = &dw_mci_idmac_ops; |
1803 | dev_info(&host->pdev->dev, "Using internal DMA controller.\n"); | 1876 | dev_info(&host->dev, "Using internal DMA controller.\n"); |
1804 | #endif | 1877 | #endif |
1805 | 1878 | ||
1806 | if (!host->dma_ops) | 1879 | if (!host->dma_ops) |
@@ -1808,12 +1881,12 @@ static void dw_mci_init_dma(struct dw_mci *host) | |||
1808 | 1881 | ||
1809 | if (host->dma_ops->init) { | 1882 | if (host->dma_ops->init) { |
1810 | if (host->dma_ops->init(host)) { | 1883 | if (host->dma_ops->init(host)) { |
1811 | dev_err(&host->pdev->dev, "%s: Unable to initialize " | 1884 | dev_err(&host->dev, "%s: Unable to initialize " |
1812 | "DMA Controller.\n", __func__); | 1885 | "DMA Controller.\n", __func__); |
1813 | goto no_dma; | 1886 | goto no_dma; |
1814 | } | 1887 | } |
1815 | } else { | 1888 | } else { |
1816 | dev_err(&host->pdev->dev, "DMA initialization not found.\n"); | 1889 | dev_err(&host->dev, "DMA initialization not found.\n"); |
1817 | goto no_dma; | 1890 | goto no_dma; |
1818 | } | 1891 | } |
1819 | 1892 | ||
@@ -1821,7 +1894,7 @@ static void dw_mci_init_dma(struct dw_mci *host) | |||
1821 | return; | 1894 | return; |
1822 | 1895 | ||
1823 | no_dma: | 1896 | no_dma: |
1824 | dev_info(&host->pdev->dev, "Using PIO mode.\n"); | 1897 | dev_info(&host->dev, "Using PIO mode.\n"); |
1825 | host->use_dma = 0; | 1898 | host->use_dma = 0; |
1826 | return; | 1899 | return; |
1827 | } | 1900 | } |
@@ -1847,61 +1920,37 @@ static bool mci_wait_reset(struct device *dev, struct dw_mci *host) | |||
1847 | return false; | 1920 | return false; |
1848 | } | 1921 | } |
1849 | 1922 | ||
1850 | static int dw_mci_probe(struct platform_device *pdev) | 1923 | int dw_mci_probe(struct dw_mci *host) |
1851 | { | 1924 | { |
1852 | struct dw_mci *host; | 1925 | int width, i, ret = 0; |
1853 | struct resource *regs; | ||
1854 | struct dw_mci_board *pdata; | ||
1855 | int irq, ret, i, width; | ||
1856 | u32 fifo_size; | 1926 | u32 fifo_size; |
1857 | 1927 | ||
1858 | regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 1928 | if (!host->pdata || !host->pdata->init) { |
1859 | if (!regs) | 1929 | dev_err(&host->dev, |
1860 | return -ENXIO; | ||
1861 | |||
1862 | irq = platform_get_irq(pdev, 0); | ||
1863 | if (irq < 0) | ||
1864 | return irq; | ||
1865 | |||
1866 | host = kzalloc(sizeof(struct dw_mci), GFP_KERNEL); | ||
1867 | if (!host) | ||
1868 | return -ENOMEM; | ||
1869 | |||
1870 | host->pdev = pdev; | ||
1871 | host->pdata = pdata = pdev->dev.platform_data; | ||
1872 | if (!pdata || !pdata->init) { | ||
1873 | dev_err(&pdev->dev, | ||
1874 | "Platform data must supply init function\n"); | 1930 | "Platform data must supply init function\n"); |
1875 | ret = -ENODEV; | 1931 | return -ENODEV; |
1876 | goto err_freehost; | ||
1877 | } | 1932 | } |
1878 | 1933 | ||
1879 | if (!pdata->select_slot && pdata->num_slots > 1) { | 1934 | if (!host->pdata->select_slot && host->pdata->num_slots > 1) { |
1880 | dev_err(&pdev->dev, | 1935 | dev_err(&host->dev, |
1881 | "Platform data must supply select_slot function\n"); | 1936 | "Platform data must supply select_slot function\n"); |
1882 | ret = -ENODEV; | 1937 | return -ENODEV; |
1883 | goto err_freehost; | ||
1884 | } | 1938 | } |
1885 | 1939 | ||
1886 | if (!pdata->bus_hz) { | 1940 | if (!host->pdata->bus_hz) { |
1887 | dev_err(&pdev->dev, | 1941 | dev_err(&host->dev, |
1888 | "Platform data must supply bus speed\n"); | 1942 | "Platform data must supply bus speed\n"); |
1889 | ret = -ENODEV; | 1943 | return -ENODEV; |
1890 | goto err_freehost; | ||
1891 | } | 1944 | } |
1892 | 1945 | ||
1893 | host->bus_hz = pdata->bus_hz; | 1946 | host->bus_hz = host->pdata->bus_hz; |
1894 | host->quirks = pdata->quirks; | 1947 | host->quirks = host->pdata->quirks; |
1895 | 1948 | ||
1896 | spin_lock_init(&host->lock); | 1949 | spin_lock_init(&host->lock); |
1897 | INIT_LIST_HEAD(&host->queue); | 1950 | INIT_LIST_HEAD(&host->queue); |
1898 | 1951 | ||
1899 | ret = -ENOMEM; | ||
1900 | host->regs = ioremap(regs->start, resource_size(regs)); | ||
1901 | if (!host->regs) | ||
1902 | goto err_freehost; | ||
1903 | 1952 | ||
1904 | host->dma_ops = pdata->dma_ops; | 1953 | host->dma_ops = host->pdata->dma_ops; |
1905 | dw_mci_init_dma(host); | 1954 | dw_mci_init_dma(host); |
1906 | 1955 | ||
1907 | /* | 1956 | /* |
@@ -1931,7 +1980,7 @@ static int dw_mci_probe(struct platform_device *pdev) | |||
1931 | } | 1980 | } |
1932 | 1981 | ||
1933 | /* Reset all blocks */ | 1982 | /* Reset all blocks */ |
1934 | if (!mci_wait_reset(&pdev->dev, host)) { | 1983 | if (!mci_wait_reset(&host->dev, host)) { |
1935 | ret = -ENODEV; | 1984 | ret = -ENODEV; |
1936 | goto err_dmaunmap; | 1985 | goto err_dmaunmap; |
1937 | } | 1986 | } |
@@ -1974,13 +2023,10 @@ static int dw_mci_probe(struct platform_device *pdev) | |||
1974 | if (!dw_mci_card_workqueue) | 2023 | if (!dw_mci_card_workqueue) |
1975 | goto err_dmaunmap; | 2024 | goto err_dmaunmap; |
1976 | INIT_WORK(&host->card_work, dw_mci_work_routine_card); | 2025 | INIT_WORK(&host->card_work, dw_mci_work_routine_card); |
1977 | 2026 | ret = request_irq(host->irq, dw_mci_interrupt, host->irq_flags, "dw-mci", host); | |
1978 | ret = request_irq(irq, dw_mci_interrupt, 0, "dw-mci", host); | ||
1979 | if (ret) | 2027 | if (ret) |
1980 | goto err_workqueue; | 2028 | goto err_workqueue; |
1981 | 2029 | ||
1982 | platform_set_drvdata(pdev, host); | ||
1983 | |||
1984 | if (host->pdata->num_slots) | 2030 | if (host->pdata->num_slots) |
1985 | host->num_slots = host->pdata->num_slots; | 2031 | host->num_slots = host->pdata->num_slots; |
1986 | else | 2032 | else |
@@ -2000,7 +2046,7 @@ static int dw_mci_probe(struct platform_device *pdev) | |||
2000 | * Need to check the version-id and set data-offset for DATA register. | 2046 | * Need to check the version-id and set data-offset for DATA register. |
2001 | */ | 2047 | */ |
2002 | host->verid = SDMMC_GET_VERID(mci_readl(host, VERID)); | 2048 | host->verid = SDMMC_GET_VERID(mci_readl(host, VERID)); |
2003 | dev_info(&pdev->dev, "Version ID is %04x\n", host->verid); | 2049 | dev_info(&host->dev, "Version ID is %04x\n", host->verid); |
2004 | 2050 | ||
2005 | if (host->verid < DW_MMC_240A) | 2051 | if (host->verid < DW_MMC_240A) |
2006 | host->data_offset = DATA_OFFSET; | 2052 | host->data_offset = DATA_OFFSET; |
@@ -2017,12 +2063,12 @@ static int dw_mci_probe(struct platform_device *pdev) | |||
2017 | DW_MCI_ERROR_FLAGS | SDMMC_INT_CD); | 2063 | DW_MCI_ERROR_FLAGS | SDMMC_INT_CD); |
2018 | mci_writel(host, CTRL, SDMMC_CTRL_INT_ENABLE); /* Enable mci interrupt */ | 2064 | mci_writel(host, CTRL, SDMMC_CTRL_INT_ENABLE); /* Enable mci interrupt */ |
2019 | 2065 | ||
2020 | dev_info(&pdev->dev, "DW MMC controller at irq %d, " | 2066 | dev_info(&host->dev, "DW MMC controller at irq %d, " |
2021 | "%d bit host data width, " | 2067 | "%d bit host data width, " |
2022 | "%u deep fifo\n", | 2068 | "%u deep fifo\n", |
2023 | irq, width, fifo_size); | 2069 | host->irq, width, fifo_size); |
2024 | if (host->quirks & DW_MCI_QUIRK_IDMAC_DTO) | 2070 | if (host->quirks & DW_MCI_QUIRK_IDMAC_DTO) |
2025 | dev_info(&pdev->dev, "Internal DMAC interrupt fix enabled.\n"); | 2071 | dev_info(&host->dev, "Internal DMAC interrupt fix enabled.\n"); |
2026 | 2072 | ||
2027 | return 0; | 2073 | return 0; |
2028 | 2074 | ||
@@ -2033,7 +2079,7 @@ err_init_slot: | |||
2033 | dw_mci_cleanup_slot(host->slot[i], i); | 2079 | dw_mci_cleanup_slot(host->slot[i], i); |
2034 | i--; | 2080 | i--; |
2035 | } | 2081 | } |
2036 | free_irq(irq, host); | 2082 | free_irq(host->irq, host); |
2037 | 2083 | ||
2038 | err_workqueue: | 2084 | err_workqueue: |
2039 | destroy_workqueue(dw_mci_card_workqueue); | 2085 | destroy_workqueue(dw_mci_card_workqueue); |
@@ -2041,33 +2087,26 @@ err_workqueue: | |||
2041 | err_dmaunmap: | 2087 | err_dmaunmap: |
2042 | if (host->use_dma && host->dma_ops->exit) | 2088 | if (host->use_dma && host->dma_ops->exit) |
2043 | host->dma_ops->exit(host); | 2089 | host->dma_ops->exit(host); |
2044 | dma_free_coherent(&host->pdev->dev, PAGE_SIZE, | 2090 | dma_free_coherent(&host->dev, PAGE_SIZE, |
2045 | host->sg_cpu, host->sg_dma); | 2091 | host->sg_cpu, host->sg_dma); |
2046 | iounmap(host->regs); | ||
2047 | 2092 | ||
2048 | if (host->vmmc) { | 2093 | if (host->vmmc) { |
2049 | regulator_disable(host->vmmc); | 2094 | regulator_disable(host->vmmc); |
2050 | regulator_put(host->vmmc); | 2095 | regulator_put(host->vmmc); |
2051 | } | 2096 | } |
2052 | |||
2053 | |||
2054 | err_freehost: | ||
2055 | kfree(host); | ||
2056 | return ret; | 2097 | return ret; |
2057 | } | 2098 | } |
2099 | EXPORT_SYMBOL(dw_mci_probe); | ||
2058 | 2100 | ||
2059 | static int __exit dw_mci_remove(struct platform_device *pdev) | 2101 | void dw_mci_remove(struct dw_mci *host) |
2060 | { | 2102 | { |
2061 | struct dw_mci *host = platform_get_drvdata(pdev); | ||
2062 | int i; | 2103 | int i; |
2063 | 2104 | ||
2064 | mci_writel(host, RINTSTS, 0xFFFFFFFF); | 2105 | mci_writel(host, RINTSTS, 0xFFFFFFFF); |
2065 | mci_writel(host, INTMASK, 0); /* disable all mmc interrupt first */ | 2106 | mci_writel(host, INTMASK, 0); /* disable all mmc interrupt first */ |
2066 | 2107 | ||
2067 | platform_set_drvdata(pdev, NULL); | ||
2068 | |||
2069 | for (i = 0; i < host->num_slots; i++) { | 2108 | for (i = 0; i < host->num_slots; i++) { |
2070 | dev_dbg(&pdev->dev, "remove slot %d\n", i); | 2109 | dev_dbg(&host->dev, "remove slot %d\n", i); |
2071 | if (host->slot[i]) | 2110 | if (host->slot[i]) |
2072 | dw_mci_cleanup_slot(host->slot[i], i); | 2111 | dw_mci_cleanup_slot(host->slot[i], i); |
2073 | } | 2112 | } |
@@ -2076,9 +2115,9 @@ static int __exit dw_mci_remove(struct platform_device *pdev) | |||
2076 | mci_writel(host, CLKENA, 0); | 2115 | mci_writel(host, CLKENA, 0); |
2077 | mci_writel(host, CLKSRC, 0); | 2116 | mci_writel(host, CLKSRC, 0); |
2078 | 2117 | ||
2079 | free_irq(platform_get_irq(pdev, 0), host); | 2118 | free_irq(host->irq, host); |
2080 | destroy_workqueue(dw_mci_card_workqueue); | 2119 | destroy_workqueue(dw_mci_card_workqueue); |
2081 | dma_free_coherent(&pdev->dev, PAGE_SIZE, host->sg_cpu, host->sg_dma); | 2120 | dma_free_coherent(&host->dev, PAGE_SIZE, host->sg_cpu, host->sg_dma); |
2082 | 2121 | ||
2083 | if (host->use_dma && host->dma_ops->exit) | 2122 | if (host->use_dma && host->dma_ops->exit) |
2084 | host->dma_ops->exit(host); | 2123 | host->dma_ops->exit(host); |
@@ -2088,20 +2127,18 @@ static int __exit dw_mci_remove(struct platform_device *pdev) | |||
2088 | regulator_put(host->vmmc); | 2127 | regulator_put(host->vmmc); |
2089 | } | 2128 | } |
2090 | 2129 | ||
2091 | iounmap(host->regs); | ||
2092 | |||
2093 | kfree(host); | ||
2094 | return 0; | ||
2095 | } | 2130 | } |
2131 | EXPORT_SYMBOL(dw_mci_remove); | ||
2132 | |||
2133 | |||
2096 | 2134 | ||
2097 | #ifdef CONFIG_PM_SLEEP | 2135 | #ifdef CONFIG_PM_SLEEP |
2098 | /* | 2136 | /* |
2099 | * TODO: we should probably disable the clock to the card in the suspend path. | 2137 | * TODO: we should probably disable the clock to the card in the suspend path. |
2100 | */ | 2138 | */ |
2101 | static int dw_mci_suspend(struct device *dev) | 2139 | int dw_mci_suspend(struct dw_mci *host) |
2102 | { | 2140 | { |
2103 | int i, ret; | 2141 | int i, ret = 0; |
2104 | struct dw_mci *host = dev_get_drvdata(dev); | ||
2105 | 2142 | ||
2106 | for (i = 0; i < host->num_slots; i++) { | 2143 | for (i = 0; i < host->num_slots; i++) { |
2107 | struct dw_mci_slot *slot = host->slot[i]; | 2144 | struct dw_mci_slot *slot = host->slot[i]; |
@@ -2123,11 +2160,11 @@ static int dw_mci_suspend(struct device *dev) | |||
2123 | 2160 | ||
2124 | return 0; | 2161 | return 0; |
2125 | } | 2162 | } |
2163 | EXPORT_SYMBOL(dw_mci_suspend); | ||
2126 | 2164 | ||
2127 | static int dw_mci_resume(struct device *dev) | 2165 | int dw_mci_resume(struct dw_mci *host) |
2128 | { | 2166 | { |
2129 | int i, ret; | 2167 | int i, ret; |
2130 | struct dw_mci *host = dev_get_drvdata(dev); | ||
2131 | 2168 | ||
2132 | if (host->vmmc) | 2169 | if (host->vmmc) |
2133 | regulator_enable(host->vmmc); | 2170 | regulator_enable(host->vmmc); |
@@ -2135,7 +2172,7 @@ static int dw_mci_resume(struct device *dev) | |||
2135 | if (host->dma_ops->init) | 2172 | if (host->dma_ops->init) |
2136 | host->dma_ops->init(host); | 2173 | host->dma_ops->init(host); |
2137 | 2174 | ||
2138 | if (!mci_wait_reset(dev, host)) { | 2175 | if (!mci_wait_reset(&host->dev, host)) { |
2139 | ret = -ENODEV; | 2176 | ret = -ENODEV; |
2140 | return ret; | 2177 | return ret; |
2141 | } | 2178 | } |
@@ -2157,32 +2194,19 @@ static int dw_mci_resume(struct device *dev) | |||
2157 | if (ret < 0) | 2194 | if (ret < 0) |
2158 | return ret; | 2195 | return ret; |
2159 | } | 2196 | } |
2160 | |||
2161 | return 0; | 2197 | return 0; |
2162 | } | 2198 | } |
2163 | #else | 2199 | EXPORT_SYMBOL(dw_mci_resume); |
2164 | #define dw_mci_suspend NULL | ||
2165 | #define dw_mci_resume NULL | ||
2166 | #endif /* CONFIG_PM_SLEEP */ | 2200 | #endif /* CONFIG_PM_SLEEP */ |
2167 | 2201 | ||
2168 | static SIMPLE_DEV_PM_OPS(dw_mci_pmops, dw_mci_suspend, dw_mci_resume); | ||
2169 | |||
2170 | static struct platform_driver dw_mci_driver = { | ||
2171 | .remove = __exit_p(dw_mci_remove), | ||
2172 | .driver = { | ||
2173 | .name = "dw_mmc", | ||
2174 | .pm = &dw_mci_pmops, | ||
2175 | }, | ||
2176 | }; | ||
2177 | |||
2178 | static int __init dw_mci_init(void) | 2202 | static int __init dw_mci_init(void) |
2179 | { | 2203 | { |
2180 | return platform_driver_probe(&dw_mci_driver, dw_mci_probe); | 2204 | printk(KERN_INFO "Synopsys Designware Multimedia Card Interface Driver"); |
2205 | return 0; | ||
2181 | } | 2206 | } |
2182 | 2207 | ||
2183 | static void __exit dw_mci_exit(void) | 2208 | static void __exit dw_mci_exit(void) |
2184 | { | 2209 | { |
2185 | platform_driver_unregister(&dw_mci_driver); | ||
2186 | } | 2210 | } |
2187 | 2211 | ||
2188 | module_init(dw_mci_init); | 2212 | module_init(dw_mci_init); |
diff --git a/drivers/mmc/host/dw_mmc.h b/drivers/mmc/host/dw_mmc.h index df392a1143f2..15c27e17c23f 100644 --- a/drivers/mmc/host/dw_mmc.h +++ b/drivers/mmc/host/dw_mmc.h | |||
@@ -175,4 +175,11 @@ | |||
175 | (*(volatile u64 __force *)((dev)->regs + SDMMC_##reg) = (value)) | 175 | (*(volatile u64 __force *)((dev)->regs + SDMMC_##reg) = (value)) |
176 | #endif | 176 | #endif |
177 | 177 | ||
178 | extern int dw_mci_probe(struct dw_mci *host); | ||
179 | extern void dw_mci_remove(struct dw_mci *host); | ||
180 | #ifdef CONFIG_PM | ||
181 | extern int dw_mci_suspend(struct dw_mci *host); | ||
182 | extern int dw_mci_resume(struct dw_mci *host); | ||
183 | #endif | ||
184 | |||
178 | #endif /* _DW_MMC_H_ */ | 185 | #endif /* _DW_MMC_H_ */ |
diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c index fd0c661bbad3..47adb161d3ad 100644 --- a/drivers/mmc/host/omap_hsmmc.c +++ b/drivers/mmc/host/omap_hsmmc.c | |||
@@ -26,6 +26,9 @@ | |||
26 | #include <linux/platform_device.h> | 26 | #include <linux/platform_device.h> |
27 | #include <linux/timer.h> | 27 | #include <linux/timer.h> |
28 | #include <linux/clk.h> | 28 | #include <linux/clk.h> |
29 | #include <linux/of.h> | ||
30 | #include <linux/of_gpio.h> | ||
31 | #include <linux/of_device.h> | ||
29 | #include <linux/mmc/host.h> | 32 | #include <linux/mmc/host.h> |
30 | #include <linux/mmc/core.h> | 33 | #include <linux/mmc/core.h> |
31 | #include <linux/mmc/mmc.h> | 34 | #include <linux/mmc/mmc.h> |
@@ -106,17 +109,6 @@ | |||
106 | #define SOFTRESET (1 << 1) | 109 | #define SOFTRESET (1 << 1) |
107 | #define RESETDONE (1 << 0) | 110 | #define RESETDONE (1 << 0) |
108 | 111 | ||
109 | /* | ||
110 | * FIXME: Most likely all the data using these _DEVID defines should come | ||
111 | * from the platform_data, or implemented in controller and slot specific | ||
112 | * functions. | ||
113 | */ | ||
114 | #define OMAP_MMC1_DEVID 0 | ||
115 | #define OMAP_MMC2_DEVID 1 | ||
116 | #define OMAP_MMC3_DEVID 2 | ||
117 | #define OMAP_MMC4_DEVID 3 | ||
118 | #define OMAP_MMC5_DEVID 4 | ||
119 | |||
120 | #define MMC_AUTOSUSPEND_DELAY 100 | 112 | #define MMC_AUTOSUSPEND_DELAY 100 |
121 | #define MMC_TIMEOUT_MS 20 | 113 | #define MMC_TIMEOUT_MS 20 |
122 | #define OMAP_MMC_MIN_CLOCK 400000 | 114 | #define OMAP_MMC_MIN_CLOCK 400000 |
@@ -164,7 +156,6 @@ struct omap_hsmmc_host { | |||
164 | void __iomem *base; | 156 | void __iomem *base; |
165 | resource_size_t mapbase; | 157 | resource_size_t mapbase; |
166 | spinlock_t irq_lock; /* Prevent races with irq handler */ | 158 | spinlock_t irq_lock; /* Prevent races with irq handler */ |
167 | unsigned int id; | ||
168 | unsigned int dma_len; | 159 | unsigned int dma_len; |
169 | unsigned int dma_sg_idx; | 160 | unsigned int dma_sg_idx; |
170 | unsigned char bus_mode; | 161 | unsigned char bus_mode; |
@@ -179,7 +170,6 @@ struct omap_hsmmc_host { | |||
179 | int got_dbclk; | 170 | int got_dbclk; |
180 | int response_busy; | 171 | int response_busy; |
181 | int context_loss; | 172 | int context_loss; |
182 | int dpm_state; | ||
183 | int vdd; | 173 | int vdd; |
184 | int protect_card; | 174 | int protect_card; |
185 | int reqs_blocked; | 175 | int reqs_blocked; |
@@ -241,28 +231,7 @@ static int omap_hsmmc_resume_cdirq(struct device *dev, int slot) | |||
241 | 231 | ||
242 | #ifdef CONFIG_REGULATOR | 232 | #ifdef CONFIG_REGULATOR |
243 | 233 | ||
244 | static int omap_hsmmc_1_set_power(struct device *dev, int slot, int power_on, | 234 | static int omap_hsmmc_set_power(struct device *dev, int slot, int power_on, |
245 | int vdd) | ||
246 | { | ||
247 | struct omap_hsmmc_host *host = | ||
248 | platform_get_drvdata(to_platform_device(dev)); | ||
249 | int ret; | ||
250 | |||
251 | if (mmc_slot(host).before_set_reg) | ||
252 | mmc_slot(host).before_set_reg(dev, slot, power_on, vdd); | ||
253 | |||
254 | if (power_on) | ||
255 | ret = mmc_regulator_set_ocr(host->mmc, host->vcc, vdd); | ||
256 | else | ||
257 | ret = mmc_regulator_set_ocr(host->mmc, host->vcc, 0); | ||
258 | |||
259 | if (mmc_slot(host).after_set_reg) | ||
260 | mmc_slot(host).after_set_reg(dev, slot, power_on, vdd); | ||
261 | |||
262 | return ret; | ||
263 | } | ||
264 | |||
265 | static int omap_hsmmc_235_set_power(struct device *dev, int slot, int power_on, | ||
266 | int vdd) | 235 | int vdd) |
267 | { | 236 | { |
268 | struct omap_hsmmc_host *host = | 237 | struct omap_hsmmc_host *host = |
@@ -275,6 +244,13 @@ static int omap_hsmmc_235_set_power(struct device *dev, int slot, int power_on, | |||
275 | */ | 244 | */ |
276 | if (!host->vcc) | 245 | if (!host->vcc) |
277 | return 0; | 246 | return 0; |
247 | /* | ||
248 | * With DT, never turn OFF the regulator. This is because | ||
249 | * the pbias cell programming support is still missing when | ||
250 | * booting with Device tree | ||
251 | */ | ||
252 | if (of_have_populated_dt() && !vdd) | ||
253 | return 0; | ||
278 | 254 | ||
279 | if (mmc_slot(host).before_set_reg) | 255 | if (mmc_slot(host).before_set_reg) |
280 | mmc_slot(host).before_set_reg(dev, slot, power_on, vdd); | 256 | mmc_slot(host).before_set_reg(dev, slot, power_on, vdd); |
@@ -318,106 +294,16 @@ static int omap_hsmmc_235_set_power(struct device *dev, int slot, int power_on, | |||
318 | return ret; | 294 | return ret; |
319 | } | 295 | } |
320 | 296 | ||
321 | static int omap_hsmmc_4_set_power(struct device *dev, int slot, int power_on, | ||
322 | int vdd) | ||
323 | { | ||
324 | return 0; | ||
325 | } | ||
326 | |||
327 | static int omap_hsmmc_1_set_sleep(struct device *dev, int slot, int sleep, | ||
328 | int vdd, int cardsleep) | ||
329 | { | ||
330 | struct omap_hsmmc_host *host = | ||
331 | platform_get_drvdata(to_platform_device(dev)); | ||
332 | int mode = sleep ? REGULATOR_MODE_STANDBY : REGULATOR_MODE_NORMAL; | ||
333 | |||
334 | return regulator_set_mode(host->vcc, mode); | ||
335 | } | ||
336 | |||
337 | static int omap_hsmmc_235_set_sleep(struct device *dev, int slot, int sleep, | ||
338 | int vdd, int cardsleep) | ||
339 | { | ||
340 | struct omap_hsmmc_host *host = | ||
341 | platform_get_drvdata(to_platform_device(dev)); | ||
342 | int err, mode; | ||
343 | |||
344 | /* | ||
345 | * If we don't see a Vcc regulator, assume it's a fixed | ||
346 | * voltage always-on regulator. | ||
347 | */ | ||
348 | if (!host->vcc) | ||
349 | return 0; | ||
350 | |||
351 | mode = sleep ? REGULATOR_MODE_STANDBY : REGULATOR_MODE_NORMAL; | ||
352 | |||
353 | if (!host->vcc_aux) | ||
354 | return regulator_set_mode(host->vcc, mode); | ||
355 | |||
356 | if (cardsleep) { | ||
357 | /* VCC can be turned off if card is asleep */ | ||
358 | if (sleep) | ||
359 | err = mmc_regulator_set_ocr(host->mmc, host->vcc, 0); | ||
360 | else | ||
361 | err = mmc_regulator_set_ocr(host->mmc, host->vcc, vdd); | ||
362 | } else | ||
363 | err = regulator_set_mode(host->vcc, mode); | ||
364 | if (err) | ||
365 | return err; | ||
366 | |||
367 | if (!mmc_slot(host).vcc_aux_disable_is_sleep) | ||
368 | return regulator_set_mode(host->vcc_aux, mode); | ||
369 | |||
370 | if (sleep) | ||
371 | return regulator_disable(host->vcc_aux); | ||
372 | else | ||
373 | return regulator_enable(host->vcc_aux); | ||
374 | } | ||
375 | |||
376 | static int omap_hsmmc_4_set_sleep(struct device *dev, int slot, int sleep, | ||
377 | int vdd, int cardsleep) | ||
378 | { | ||
379 | return 0; | ||
380 | } | ||
381 | |||
382 | static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host) | 297 | static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host) |
383 | { | 298 | { |
384 | struct regulator *reg; | 299 | struct regulator *reg; |
385 | int ret = 0; | ||
386 | int ocr_value = 0; | 300 | int ocr_value = 0; |
387 | 301 | ||
388 | switch (host->id) { | 302 | mmc_slot(host).set_power = omap_hsmmc_set_power; |
389 | case OMAP_MMC1_DEVID: | ||
390 | /* On-chip level shifting via PBIAS0/PBIAS1 */ | ||
391 | mmc_slot(host).set_power = omap_hsmmc_1_set_power; | ||
392 | mmc_slot(host).set_sleep = omap_hsmmc_1_set_sleep; | ||
393 | break; | ||
394 | case OMAP_MMC2_DEVID: | ||
395 | case OMAP_MMC3_DEVID: | ||
396 | case OMAP_MMC5_DEVID: | ||
397 | /* Off-chip level shifting, or none */ | ||
398 | mmc_slot(host).set_power = omap_hsmmc_235_set_power; | ||
399 | mmc_slot(host).set_sleep = omap_hsmmc_235_set_sleep; | ||
400 | break; | ||
401 | case OMAP_MMC4_DEVID: | ||
402 | mmc_slot(host).set_power = omap_hsmmc_4_set_power; | ||
403 | mmc_slot(host).set_sleep = omap_hsmmc_4_set_sleep; | ||
404 | default: | ||
405 | pr_err("MMC%d configuration not supported!\n", host->id); | ||
406 | return -EINVAL; | ||
407 | } | ||
408 | 303 | ||
409 | reg = regulator_get(host->dev, "vmmc"); | 304 | reg = regulator_get(host->dev, "vmmc"); |
410 | if (IS_ERR(reg)) { | 305 | if (IS_ERR(reg)) { |
411 | dev_dbg(host->dev, "vmmc regulator missing\n"); | 306 | dev_dbg(host->dev, "vmmc regulator missing\n"); |
412 | /* | ||
413 | * HACK: until fixed.c regulator is usable, | ||
414 | * we don't require a main regulator | ||
415 | * for MMC2 or MMC3 | ||
416 | */ | ||
417 | if (host->id == OMAP_MMC1_DEVID) { | ||
418 | ret = PTR_ERR(reg); | ||
419 | goto err; | ||
420 | } | ||
421 | } else { | 307 | } else { |
422 | host->vcc = reg; | 308 | host->vcc = reg; |
423 | ocr_value = mmc_regulator_get_ocrmask(reg); | 309 | ocr_value = mmc_regulator_get_ocrmask(reg); |
@@ -425,8 +311,8 @@ static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host) | |||
425 | mmc_slot(host).ocr_mask = ocr_value; | 311 | mmc_slot(host).ocr_mask = ocr_value; |
426 | } else { | 312 | } else { |
427 | if (!(mmc_slot(host).ocr_mask & ocr_value)) { | 313 | if (!(mmc_slot(host).ocr_mask & ocr_value)) { |
428 | pr_err("MMC%d ocrmask %x is not supported\n", | 314 | dev_err(host->dev, "ocrmask %x is not supported\n", |
429 | host->id, mmc_slot(host).ocr_mask); | 315 | mmc_slot(host).ocr_mask); |
430 | mmc_slot(host).ocr_mask = 0; | 316 | mmc_slot(host).ocr_mask = 0; |
431 | return -EINVAL; | 317 | return -EINVAL; |
432 | } | 318 | } |
@@ -459,11 +345,6 @@ static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host) | |||
459 | } | 345 | } |
460 | 346 | ||
461 | return 0; | 347 | return 0; |
462 | |||
463 | err: | ||
464 | mmc_slot(host).set_power = NULL; | ||
465 | mmc_slot(host).set_sleep = NULL; | ||
466 | return ret; | ||
467 | } | 348 | } |
468 | 349 | ||
469 | static void omap_hsmmc_reg_put(struct omap_hsmmc_host *host) | 350 | static void omap_hsmmc_reg_put(struct omap_hsmmc_host *host) |
@@ -471,7 +352,6 @@ static void omap_hsmmc_reg_put(struct omap_hsmmc_host *host) | |||
471 | regulator_put(host->vcc); | 352 | regulator_put(host->vcc); |
472 | regulator_put(host->vcc_aux); | 353 | regulator_put(host->vcc_aux); |
473 | mmc_slot(host).set_power = NULL; | 354 | mmc_slot(host).set_power = NULL; |
474 | mmc_slot(host).set_sleep = NULL; | ||
475 | } | 355 | } |
476 | 356 | ||
477 | static inline int omap_hsmmc_have_reg(void) | 357 | static inline int omap_hsmmc_have_reg(void) |
@@ -710,7 +590,7 @@ static int omap_hsmmc_context_restore(struct omap_hsmmc_host *host) | |||
710 | OMAP_HSMMC_WRITE(host->base, SYSCONFIG, | 590 | OMAP_HSMMC_WRITE(host->base, SYSCONFIG, |
711 | OMAP_HSMMC_READ(host->base, SYSCONFIG) | AUTOIDLE); | 591 | OMAP_HSMMC_READ(host->base, SYSCONFIG) | AUTOIDLE); |
712 | 592 | ||
713 | if (host->id == OMAP_MMC1_DEVID) { | 593 | if (host->pdata->controller_flags & OMAP_HSMMC_SUPPORTS_DUAL_VOLT) { |
714 | if (host->power_mode != MMC_POWER_OFF && | 594 | if (host->power_mode != MMC_POWER_OFF && |
715 | (1 << ios->vdd) <= MMC_VDD_23_24) | 595 | (1 << ios->vdd) <= MMC_VDD_23_24) |
716 | hctl = SDVS18; | 596 | hctl = SDVS18; |
@@ -1261,14 +1141,14 @@ static void omap_hsmmc_protect_card(struct omap_hsmmc_host *host) | |||
1261 | host->reqs_blocked = 0; | 1141 | host->reqs_blocked = 0; |
1262 | if (mmc_slot(host).get_cover_state(host->dev, host->slot_id)) { | 1142 | if (mmc_slot(host).get_cover_state(host->dev, host->slot_id)) { |
1263 | if (host->protect_card) { | 1143 | if (host->protect_card) { |
1264 | pr_info("%s: cover is closed, " | 1144 | dev_info(host->dev, "%s: cover is closed, " |
1265 | "card is now accessible\n", | 1145 | "card is now accessible\n", |
1266 | mmc_hostname(host->mmc)); | 1146 | mmc_hostname(host->mmc)); |
1267 | host->protect_card = 0; | 1147 | host->protect_card = 0; |
1268 | } | 1148 | } |
1269 | } else { | 1149 | } else { |
1270 | if (!host->protect_card) { | 1150 | if (!host->protect_card) { |
1271 | pr_info("%s: cover is open, " | 1151 | dev_info(host->dev, "%s: cover is open, " |
1272 | "card is now inaccessible\n", | 1152 | "card is now inaccessible\n", |
1273 | mmc_hostname(host->mmc)); | 1153 | mmc_hostname(host->mmc)); |
1274 | host->protect_card = 1; | 1154 | host->protect_card = 1; |
@@ -1405,7 +1285,7 @@ static int omap_hsmmc_pre_dma_transfer(struct omap_hsmmc_host *host, | |||
1405 | 1285 | ||
1406 | if (!next && data->host_cookie && | 1286 | if (!next && data->host_cookie && |
1407 | data->host_cookie != host->next_data.cookie) { | 1287 | data->host_cookie != host->next_data.cookie) { |
1408 | pr_warning("[%s] invalid cookie: data->host_cookie %d" | 1288 | dev_warn(host->dev, "[%s] invalid cookie: data->host_cookie %d" |
1409 | " host->next_data.cookie %d\n", | 1289 | " host->next_data.cookie %d\n", |
1410 | __func__, data->host_cookie, host->next_data.cookie); | 1290 | __func__, data->host_cookie, host->next_data.cookie); |
1411 | data->host_cookie = 0; | 1291 | data->host_cookie = 0; |
@@ -1663,7 +1543,13 @@ static void omap_hsmmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) | |||
1663 | * of external transceiver; but they all handle 1.8V. | 1543 | * of external transceiver; but they all handle 1.8V. |
1664 | */ | 1544 | */ |
1665 | if ((OMAP_HSMMC_READ(host->base, HCTL) & SDVSDET) && | 1545 | if ((OMAP_HSMMC_READ(host->base, HCTL) & SDVSDET) && |
1666 | (ios->vdd == DUAL_VOLT_OCR_BIT)) { | 1546 | (ios->vdd == DUAL_VOLT_OCR_BIT) && |
1547 | /* | ||
1548 | * With pbias cell programming missing, this | ||
1549 | * can't be allowed when booting with device | ||
1550 | * tree. | ||
1551 | */ | ||
1552 | (!of_have_populated_dt())) { | ||
1667 | /* | 1553 | /* |
1668 | * The mmc_select_voltage fn of the core does | 1554 | * The mmc_select_voltage fn of the core does |
1669 | * not seem to set the power_mode to | 1555 | * not seem to set the power_mode to |
@@ -1748,7 +1634,7 @@ static int omap_hsmmc_enable_fclk(struct mmc_host *mmc) | |||
1748 | return 0; | 1634 | return 0; |
1749 | } | 1635 | } |
1750 | 1636 | ||
1751 | static int omap_hsmmc_disable_fclk(struct mmc_host *mmc, int lazy) | 1637 | static int omap_hsmmc_disable_fclk(struct mmc_host *mmc) |
1752 | { | 1638 | { |
1753 | struct omap_hsmmc_host *host = mmc_priv(mmc); | 1639 | struct omap_hsmmc_host *host = mmc_priv(mmc); |
1754 | 1640 | ||
@@ -1782,15 +1668,8 @@ static int omap_hsmmc_regs_show(struct seq_file *s, void *data) | |||
1782 | if (host->pdata->get_context_loss_count) | 1668 | if (host->pdata->get_context_loss_count) |
1783 | context_loss = host->pdata->get_context_loss_count(host->dev); | 1669 | context_loss = host->pdata->get_context_loss_count(host->dev); |
1784 | 1670 | ||
1785 | seq_printf(s, "mmc%d:\n" | 1671 | seq_printf(s, "mmc%d:\n ctx_loss:\t%d:%d\n\nregs:\n", |
1786 | " enabled:\t%d\n" | 1672 | mmc->index, host->context_loss, context_loss); |
1787 | " dpm_state:\t%d\n" | ||
1788 | " nesting_cnt:\t%d\n" | ||
1789 | " ctx_loss:\t%d:%d\n" | ||
1790 | "\nregs:\n", | ||
1791 | mmc->index, mmc->enabled ? 1 : 0, | ||
1792 | host->dpm_state, mmc->nesting_cnt, | ||
1793 | host->context_loss, context_loss); | ||
1794 | 1673 | ||
1795 | if (host->suspended) { | 1674 | if (host->suspended) { |
1796 | seq_printf(s, "host suspended, can't read registers\n"); | 1675 | seq_printf(s, "host suspended, can't read registers\n"); |
@@ -1847,6 +1726,65 @@ static void omap_hsmmc_debugfs(struct mmc_host *mmc) | |||
1847 | 1726 | ||
1848 | #endif | 1727 | #endif |
1849 | 1728 | ||
1729 | #ifdef CONFIG_OF | ||
1730 | static u16 omap4_reg_offset = 0x100; | ||
1731 | |||
1732 | static const struct of_device_id omap_mmc_of_match[] = { | ||
1733 | { | ||
1734 | .compatible = "ti,omap2-hsmmc", | ||
1735 | }, | ||
1736 | { | ||
1737 | .compatible = "ti,omap3-hsmmc", | ||
1738 | }, | ||
1739 | { | ||
1740 | .compatible = "ti,omap4-hsmmc", | ||
1741 | .data = &omap4_reg_offset, | ||
1742 | }, | ||
1743 | {}, | ||
1744 | } | ||
1745 | MODULE_DEVICE_TABLE(of, omap_mmc_of_match); | ||
1746 | |||
1747 | static struct omap_mmc_platform_data *of_get_hsmmc_pdata(struct device *dev) | ||
1748 | { | ||
1749 | struct omap_mmc_platform_data *pdata; | ||
1750 | struct device_node *np = dev->of_node; | ||
1751 | u32 bus_width; | ||
1752 | |||
1753 | pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); | ||
1754 | if (!pdata) | ||
1755 | return NULL; /* out of memory */ | ||
1756 | |||
1757 | if (of_find_property(np, "ti,dual-volt", NULL)) | ||
1758 | pdata->controller_flags |= OMAP_HSMMC_SUPPORTS_DUAL_VOLT; | ||
1759 | |||
1760 | /* This driver only supports 1 slot */ | ||
1761 | pdata->nr_slots = 1; | ||
1762 | pdata->slots[0].switch_pin = of_get_named_gpio(np, "cd-gpios", 0); | ||
1763 | pdata->slots[0].gpio_wp = of_get_named_gpio(np, "wp-gpios", 0); | ||
1764 | |||
1765 | if (of_find_property(np, "ti,non-removable", NULL)) { | ||
1766 | pdata->slots[0].nonremovable = true; | ||
1767 | pdata->slots[0].no_regulator_off_init = true; | ||
1768 | } | ||
1769 | of_property_read_u32(np, "ti,bus-width", &bus_width); | ||
1770 | if (bus_width == 4) | ||
1771 | pdata->slots[0].caps |= MMC_CAP_4_BIT_DATA; | ||
1772 | else if (bus_width == 8) | ||
1773 | pdata->slots[0].caps |= MMC_CAP_8_BIT_DATA; | ||
1774 | |||
1775 | if (of_find_property(np, "ti,needs-special-reset", NULL)) | ||
1776 | pdata->slots[0].features |= HSMMC_HAS_UPDATED_RESET; | ||
1777 | |||
1778 | return pdata; | ||
1779 | } | ||
1780 | #else | ||
1781 | static inline struct omap_mmc_platform_data | ||
1782 | *of_get_hsmmc_pdata(struct device *dev) | ||
1783 | { | ||
1784 | return NULL; | ||
1785 | } | ||
1786 | #endif | ||
1787 | |||
1850 | static int __init omap_hsmmc_probe(struct platform_device *pdev) | 1788 | static int __init omap_hsmmc_probe(struct platform_device *pdev) |
1851 | { | 1789 | { |
1852 | struct omap_mmc_platform_data *pdata = pdev->dev.platform_data; | 1790 | struct omap_mmc_platform_data *pdata = pdev->dev.platform_data; |
@@ -1854,6 +1792,16 @@ static int __init omap_hsmmc_probe(struct platform_device *pdev) | |||
1854 | struct omap_hsmmc_host *host = NULL; | 1792 | struct omap_hsmmc_host *host = NULL; |
1855 | struct resource *res; | 1793 | struct resource *res; |
1856 | int ret, irq; | 1794 | int ret, irq; |
1795 | const struct of_device_id *match; | ||
1796 | |||
1797 | match = of_match_device(of_match_ptr(omap_mmc_of_match), &pdev->dev); | ||
1798 | if (match) { | ||
1799 | pdata = of_get_hsmmc_pdata(&pdev->dev); | ||
1800 | if (match->data) { | ||
1801 | u16 *offsetp = match->data; | ||
1802 | pdata->reg_offset = *offsetp; | ||
1803 | } | ||
1804 | } | ||
1857 | 1805 | ||
1858 | if (pdata == NULL) { | 1806 | if (pdata == NULL) { |
1859 | dev_err(&pdev->dev, "Platform Data is missing\n"); | 1807 | dev_err(&pdev->dev, "Platform Data is missing\n"); |
@@ -1894,7 +1842,6 @@ static int __init omap_hsmmc_probe(struct platform_device *pdev) | |||
1894 | host->dev->dma_mask = &pdata->dma_mask; | 1842 | host->dev->dma_mask = &pdata->dma_mask; |
1895 | host->dma_ch = -1; | 1843 | host->dma_ch = -1; |
1896 | host->irq = irq; | 1844 | host->irq = irq; |
1897 | host->id = pdev->id; | ||
1898 | host->slot_id = 0; | 1845 | host->slot_id = 0; |
1899 | host->mapbase = res->start; | 1846 | host->mapbase = res->start; |
1900 | host->base = ioremap(host->mapbase, SZ_4K); | 1847 | host->base = ioremap(host->mapbase, SZ_4K); |
@@ -1912,8 +1859,12 @@ static int __init omap_hsmmc_probe(struct platform_device *pdev) | |||
1912 | if (mmc_slot(host).vcc_aux_disable_is_sleep) | 1859 | if (mmc_slot(host).vcc_aux_disable_is_sleep) |
1913 | mmc_slot(host).no_off = 1; | 1860 | mmc_slot(host).no_off = 1; |
1914 | 1861 | ||
1915 | mmc->f_min = OMAP_MMC_MIN_CLOCK; | 1862 | mmc->f_min = OMAP_MMC_MIN_CLOCK; |
1916 | mmc->f_max = OMAP_MMC_MAX_CLOCK; | 1863 | |
1864 | if (pdata->max_freq > 0) | ||
1865 | mmc->f_max = pdata->max_freq; | ||
1866 | else | ||
1867 | mmc->f_max = OMAP_MMC_MAX_CLOCK; | ||
1917 | 1868 | ||
1918 | spin_lock_init(&host->irq_lock); | 1869 | spin_lock_init(&host->irq_lock); |
1919 | 1870 | ||
@@ -1926,7 +1877,6 @@ static int __init omap_hsmmc_probe(struct platform_device *pdev) | |||
1926 | 1877 | ||
1927 | omap_hsmmc_context_save(host); | 1878 | omap_hsmmc_context_save(host); |
1928 | 1879 | ||
1929 | mmc->caps |= MMC_CAP_DISABLE; | ||
1930 | if (host->pdata->controller_flags & OMAP_HSMMC_BROKEN_MULTIBLOCK_READ) { | 1880 | if (host->pdata->controller_flags & OMAP_HSMMC_BROKEN_MULTIBLOCK_READ) { |
1931 | dev_info(&pdev->dev, "multiblock reads disabled due to 35xx erratum 2.1.1.128; MMC read performance may suffer\n"); | 1881 | dev_info(&pdev->dev, "multiblock reads disabled due to 35xx erratum 2.1.1.128; MMC read performance may suffer\n"); |
1932 | mmc->caps2 |= MMC_CAP2_NO_MULTI_READ; | 1882 | mmc->caps2 |= MMC_CAP2_NO_MULTI_READ; |
@@ -1977,32 +1927,19 @@ static int __init omap_hsmmc_probe(struct platform_device *pdev) | |||
1977 | 1927 | ||
1978 | omap_hsmmc_conf_bus_power(host); | 1928 | omap_hsmmc_conf_bus_power(host); |
1979 | 1929 | ||
1980 | /* Select DMA lines */ | 1930 | res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "tx"); |
1981 | switch (host->id) { | 1931 | if (!res) { |
1982 | case OMAP_MMC1_DEVID: | 1932 | dev_err(mmc_dev(host->mmc), "cannot get DMA TX channel\n"); |
1983 | host->dma_line_tx = OMAP24XX_DMA_MMC1_TX; | 1933 | goto err_irq; |
1984 | host->dma_line_rx = OMAP24XX_DMA_MMC1_RX; | 1934 | } |
1985 | break; | 1935 | host->dma_line_tx = res->start; |
1986 | case OMAP_MMC2_DEVID: | 1936 | |
1987 | host->dma_line_tx = OMAP24XX_DMA_MMC2_TX; | 1937 | res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "rx"); |
1988 | host->dma_line_rx = OMAP24XX_DMA_MMC2_RX; | 1938 | if (!res) { |
1989 | break; | 1939 | dev_err(mmc_dev(host->mmc), "cannot get DMA RX channel\n"); |
1990 | case OMAP_MMC3_DEVID: | ||
1991 | host->dma_line_tx = OMAP34XX_DMA_MMC3_TX; | ||
1992 | host->dma_line_rx = OMAP34XX_DMA_MMC3_RX; | ||
1993 | break; | ||
1994 | case OMAP_MMC4_DEVID: | ||
1995 | host->dma_line_tx = OMAP44XX_DMA_MMC4_TX; | ||
1996 | host->dma_line_rx = OMAP44XX_DMA_MMC4_RX; | ||
1997 | break; | ||
1998 | case OMAP_MMC5_DEVID: | ||
1999 | host->dma_line_tx = OMAP44XX_DMA_MMC5_TX; | ||
2000 | host->dma_line_rx = OMAP44XX_DMA_MMC5_RX; | ||
2001 | break; | ||
2002 | default: | ||
2003 | dev_err(mmc_dev(host->mmc), "Invalid MMC id\n"); | ||
2004 | goto err_irq; | 1940 | goto err_irq; |
2005 | } | 1941 | } |
1942 | host->dma_line_rx = res->start; | ||
2006 | 1943 | ||
2007 | /* Request IRQ for MMC operations */ | 1944 | /* Request IRQ for MMC operations */ |
2008 | ret = request_irq(host->irq, omap_hsmmc_irq, 0, | 1945 | ret = request_irq(host->irq, omap_hsmmc_irq, 0, |
@@ -2083,6 +2020,7 @@ err_irq_cd_init: | |||
2083 | err_irq: | 2020 | err_irq: |
2084 | pm_runtime_mark_last_busy(host->dev); | 2021 | pm_runtime_mark_last_busy(host->dev); |
2085 | pm_runtime_put_autosuspend(host->dev); | 2022 | pm_runtime_put_autosuspend(host->dev); |
2023 | pm_runtime_disable(host->dev); | ||
2086 | clk_put(host->fclk); | 2024 | clk_put(host->fclk); |
2087 | if (host->got_dbclk) { | 2025 | if (host->got_dbclk) { |
2088 | clk_disable(host->dbclk); | 2026 | clk_disable(host->dbclk); |
@@ -2269,6 +2207,7 @@ static struct platform_driver omap_hsmmc_driver = { | |||
2269 | .name = DRIVER_NAME, | 2207 | .name = DRIVER_NAME, |
2270 | .owner = THIS_MODULE, | 2208 | .owner = THIS_MODULE, |
2271 | .pm = &omap_hsmmc_dev_pm_ops, | 2209 | .pm = &omap_hsmmc_dev_pm_ops, |
2210 | .of_match_table = of_match_ptr(omap_mmc_of_match), | ||
2272 | }, | 2211 | }, |
2273 | }; | 2212 | }; |
2274 | 2213 | ||
diff --git a/drivers/mmc/host/sdhci-of-esdhc.c b/drivers/mmc/host/sdhci-of-esdhc.c index 5d876ff86f37..f8eb1fb0c921 100644 --- a/drivers/mmc/host/sdhci-of-esdhc.c +++ b/drivers/mmc/host/sdhci-of-esdhc.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Freescale eSDHC controller driver. | 2 | * Freescale eSDHC controller driver. |
3 | * | 3 | * |
4 | * Copyright (c) 2007, 2010 Freescale Semiconductor, Inc. | 4 | * Copyright (c) 2007, 2010, 2012 Freescale Semiconductor, Inc. |
5 | * Copyright (c) 2009 MontaVista Software, Inc. | 5 | * Copyright (c) 2009 MontaVista Software, Inc. |
6 | * | 6 | * |
7 | * Authors: Xiaobo Xie <X.Xie@freescale.com> | 7 | * Authors: Xiaobo Xie <X.Xie@freescale.com> |
@@ -14,6 +14,7 @@ | |||
14 | */ | 14 | */ |
15 | 15 | ||
16 | #include <linux/io.h> | 16 | #include <linux/io.h> |
17 | #include <linux/of.h> | ||
17 | #include <linux/delay.h> | 18 | #include <linux/delay.h> |
18 | #include <linux/module.h> | 19 | #include <linux/module.h> |
19 | #include <linux/mmc/host.h> | 20 | #include <linux/mmc/host.h> |
@@ -114,6 +115,34 @@ static unsigned int esdhc_of_get_min_clock(struct sdhci_host *host) | |||
114 | return pltfm_host->clock / 256 / 16; | 115 | return pltfm_host->clock / 256 / 16; |
115 | } | 116 | } |
116 | 117 | ||
118 | static void esdhc_of_set_clock(struct sdhci_host *host, unsigned int clock) | ||
119 | { | ||
120 | /* Workaround to reduce the clock frequency for p1010 esdhc */ | ||
121 | if (of_find_compatible_node(NULL, NULL, "fsl,p1010-esdhc")) { | ||
122 | if (clock > 20000000) | ||
123 | clock -= 5000000; | ||
124 | if (clock > 40000000) | ||
125 | clock -= 5000000; | ||
126 | } | ||
127 | |||
128 | /* Set the clock */ | ||
129 | esdhc_set_clock(host, clock); | ||
130 | } | ||
131 | |||
132 | #ifdef CONFIG_PM | ||
133 | static u32 esdhc_proctl; | ||
134 | static void esdhc_of_suspend(struct sdhci_host *host) | ||
135 | { | ||
136 | esdhc_proctl = sdhci_be32bs_readl(host, SDHCI_HOST_CONTROL); | ||
137 | } | ||
138 | |||
139 | static void esdhc_of_resume(struct sdhci_host *host) | ||
140 | { | ||
141 | esdhc_of_enable_dma(host); | ||
142 | sdhci_be32bs_writel(host, esdhc_proctl, SDHCI_HOST_CONTROL); | ||
143 | } | ||
144 | #endif | ||
145 | |||
117 | static struct sdhci_ops sdhci_esdhc_ops = { | 146 | static struct sdhci_ops sdhci_esdhc_ops = { |
118 | .read_l = sdhci_be32bs_readl, | 147 | .read_l = sdhci_be32bs_readl, |
119 | .read_w = esdhc_readw, | 148 | .read_w = esdhc_readw, |
@@ -121,10 +150,14 @@ static struct sdhci_ops sdhci_esdhc_ops = { | |||
121 | .write_l = sdhci_be32bs_writel, | 150 | .write_l = sdhci_be32bs_writel, |
122 | .write_w = esdhc_writew, | 151 | .write_w = esdhc_writew, |
123 | .write_b = esdhc_writeb, | 152 | .write_b = esdhc_writeb, |
124 | .set_clock = esdhc_set_clock, | 153 | .set_clock = esdhc_of_set_clock, |
125 | .enable_dma = esdhc_of_enable_dma, | 154 | .enable_dma = esdhc_of_enable_dma, |
126 | .get_max_clock = esdhc_of_get_max_clock, | 155 | .get_max_clock = esdhc_of_get_max_clock, |
127 | .get_min_clock = esdhc_of_get_min_clock, | 156 | .get_min_clock = esdhc_of_get_min_clock, |
157 | #ifdef CONFIG_PM | ||
158 | .platform_suspend = esdhc_of_suspend, | ||
159 | .platform_resume = esdhc_of_resume, | ||
160 | #endif | ||
128 | }; | 161 | }; |
129 | 162 | ||
130 | static struct sdhci_pltfm_data sdhci_esdhc_pdata = { | 163 | static struct sdhci_pltfm_data sdhci_esdhc_pdata = { |
diff --git a/drivers/mmc/host/sdhci-pci.c b/drivers/mmc/host/sdhci-pci.c index 6ebdc4010e7c..fbbebe251e01 100644 --- a/drivers/mmc/host/sdhci-pci.c +++ b/drivers/mmc/host/sdhci-pci.c | |||
@@ -29,6 +29,12 @@ | |||
29 | #include "sdhci.h" | 29 | #include "sdhci.h" |
30 | 30 | ||
31 | /* | 31 | /* |
32 | * PCI device IDs | ||
33 | */ | ||
34 | #define PCI_DEVICE_ID_INTEL_PCH_SDIO0 0x8809 | ||
35 | #define PCI_DEVICE_ID_INTEL_PCH_SDIO1 0x880a | ||
36 | |||
37 | /* | ||
32 | * PCI registers | 38 | * PCI registers |
33 | */ | 39 | */ |
34 | 40 | ||
@@ -47,6 +53,7 @@ struct sdhci_pci_slot; | |||
47 | 53 | ||
48 | struct sdhci_pci_fixes { | 54 | struct sdhci_pci_fixes { |
49 | unsigned int quirks; | 55 | unsigned int quirks; |
56 | unsigned int quirks2; | ||
50 | bool allow_runtime_pm; | 57 | bool allow_runtime_pm; |
51 | 58 | ||
52 | int (*probe) (struct sdhci_pci_chip *); | 59 | int (*probe) (struct sdhci_pci_chip *); |
@@ -73,6 +80,7 @@ struct sdhci_pci_chip { | |||
73 | struct pci_dev *pdev; | 80 | struct pci_dev *pdev; |
74 | 81 | ||
75 | unsigned int quirks; | 82 | unsigned int quirks; |
83 | unsigned int quirks2; | ||
76 | bool allow_runtime_pm; | 84 | bool allow_runtime_pm; |
77 | const struct sdhci_pci_fixes *fixes; | 85 | const struct sdhci_pci_fixes *fixes; |
78 | 86 | ||
@@ -172,6 +180,12 @@ static int mrst_hc_probe(struct sdhci_pci_chip *chip) | |||
172 | return 0; | 180 | return 0; |
173 | } | 181 | } |
174 | 182 | ||
183 | static int pch_hc_probe_slot(struct sdhci_pci_slot *slot) | ||
184 | { | ||
185 | slot->host->mmc->caps |= MMC_CAP_8_BIT_DATA; | ||
186 | return 0; | ||
187 | } | ||
188 | |||
175 | #ifdef CONFIG_PM_RUNTIME | 189 | #ifdef CONFIG_PM_RUNTIME |
176 | 190 | ||
177 | static irqreturn_t sdhci_pci_sd_cd(int irq, void *dev_id) | 191 | static irqreturn_t sdhci_pci_sd_cd(int irq, void *dev_id) |
@@ -244,7 +258,8 @@ static inline void sdhci_pci_remove_own_cd(struct sdhci_pci_slot *slot) | |||
244 | static int mfd_emmc_probe_slot(struct sdhci_pci_slot *slot) | 258 | static int mfd_emmc_probe_slot(struct sdhci_pci_slot *slot) |
245 | { | 259 | { |
246 | slot->host->mmc->caps |= MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE; | 260 | slot->host->mmc->caps |= MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE; |
247 | slot->host->mmc->caps2 = MMC_CAP2_BOOTPART_NOACC; | 261 | slot->host->mmc->caps2 |= MMC_CAP2_BOOTPART_NOACC | |
262 | MMC_CAP2_HC_ERASE_SZ; | ||
248 | return 0; | 263 | return 0; |
249 | } | 264 | } |
250 | 265 | ||
@@ -271,6 +286,7 @@ static const struct sdhci_pci_fixes sdhci_intel_mfd_sd = { | |||
271 | 286 | ||
272 | static const struct sdhci_pci_fixes sdhci_intel_mfd_sdio = { | 287 | static const struct sdhci_pci_fixes sdhci_intel_mfd_sdio = { |
273 | .quirks = SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC, | 288 | .quirks = SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC, |
289 | .quirks2 = SDHCI_QUIRK2_HOST_OFF_CARD_ON, | ||
274 | .allow_runtime_pm = true, | 290 | .allow_runtime_pm = true, |
275 | .probe_slot = mfd_sdio_probe_slot, | 291 | .probe_slot = mfd_sdio_probe_slot, |
276 | }; | 292 | }; |
@@ -281,6 +297,11 @@ static const struct sdhci_pci_fixes sdhci_intel_mfd_emmc = { | |||
281 | .probe_slot = mfd_emmc_probe_slot, | 297 | .probe_slot = mfd_emmc_probe_slot, |
282 | }; | 298 | }; |
283 | 299 | ||
300 | static const struct sdhci_pci_fixes sdhci_intel_pch_sdio = { | ||
301 | .quirks = SDHCI_QUIRK_BROKEN_ADMA, | ||
302 | .probe_slot = pch_hc_probe_slot, | ||
303 | }; | ||
304 | |||
284 | /* O2Micro extra registers */ | 305 | /* O2Micro extra registers */ |
285 | #define O2_SD_LOCK_WP 0xD3 | 306 | #define O2_SD_LOCK_WP 0xD3 |
286 | #define O2_SD_MULTI_VCC3V 0xEE | 307 | #define O2_SD_MULTI_VCC3V 0xEE |
@@ -817,6 +838,22 @@ static const struct pci_device_id pci_ids[] __devinitdata = { | |||
817 | }, | 838 | }, |
818 | 839 | ||
819 | { | 840 | { |
841 | .vendor = PCI_VENDOR_ID_INTEL, | ||
842 | .device = PCI_DEVICE_ID_INTEL_PCH_SDIO0, | ||
843 | .subvendor = PCI_ANY_ID, | ||
844 | .subdevice = PCI_ANY_ID, | ||
845 | .driver_data = (kernel_ulong_t)&sdhci_intel_pch_sdio, | ||
846 | }, | ||
847 | |||
848 | { | ||
849 | .vendor = PCI_VENDOR_ID_INTEL, | ||
850 | .device = PCI_DEVICE_ID_INTEL_PCH_SDIO1, | ||
851 | .subvendor = PCI_ANY_ID, | ||
852 | .subdevice = PCI_ANY_ID, | ||
853 | .driver_data = (kernel_ulong_t)&sdhci_intel_pch_sdio, | ||
854 | }, | ||
855 | |||
856 | { | ||
820 | .vendor = PCI_VENDOR_ID_O2, | 857 | .vendor = PCI_VENDOR_ID_O2, |
821 | .device = PCI_DEVICE_ID_O2_8120, | 858 | .device = PCI_DEVICE_ID_O2_8120, |
822 | .subvendor = PCI_ANY_ID, | 859 | .subvendor = PCI_ANY_ID, |
@@ -1206,6 +1243,7 @@ static struct sdhci_pci_slot * __devinit sdhci_pci_probe_slot( | |||
1206 | host->hw_name = "PCI"; | 1243 | host->hw_name = "PCI"; |
1207 | host->ops = &sdhci_pci_ops; | 1244 | host->ops = &sdhci_pci_ops; |
1208 | host->quirks = chip->quirks; | 1245 | host->quirks = chip->quirks; |
1246 | host->quirks2 = chip->quirks2; | ||
1209 | 1247 | ||
1210 | host->irq = pdev->irq; | 1248 | host->irq = pdev->irq; |
1211 | 1249 | ||
@@ -1365,6 +1403,7 @@ static int __devinit sdhci_pci_probe(struct pci_dev *pdev, | |||
1365 | chip->fixes = (const struct sdhci_pci_fixes *)ent->driver_data; | 1403 | chip->fixes = (const struct sdhci_pci_fixes *)ent->driver_data; |
1366 | if (chip->fixes) { | 1404 | if (chip->fixes) { |
1367 | chip->quirks = chip->fixes->quirks; | 1405 | chip->quirks = chip->fixes->quirks; |
1406 | chip->quirks2 = chip->fixes->quirks2; | ||
1368 | chip->allow_runtime_pm = chip->fixes->allow_runtime_pm; | 1407 | chip->allow_runtime_pm = chip->fixes->allow_runtime_pm; |
1369 | } | 1408 | } |
1370 | chip->num_slots = slots; | 1409 | chip->num_slots = slots; |
@@ -1379,6 +1418,8 @@ static int __devinit sdhci_pci_probe(struct pci_dev *pdev, | |||
1379 | 1418 | ||
1380 | slots = chip->num_slots; /* Quirk may have changed this */ | 1419 | slots = chip->num_slots; /* Quirk may have changed this */ |
1381 | 1420 | ||
1421 | pci_enable_msi(pdev); | ||
1422 | |||
1382 | for (i = 0; i < slots; i++) { | 1423 | for (i = 0; i < slots; i++) { |
1383 | slot = sdhci_pci_probe_slot(pdev, chip, first_bar, i); | 1424 | slot = sdhci_pci_probe_slot(pdev, chip, first_bar, i); |
1384 | if (IS_ERR(slot)) { | 1425 | if (IS_ERR(slot)) { |
@@ -1397,6 +1438,8 @@ static int __devinit sdhci_pci_probe(struct pci_dev *pdev, | |||
1397 | return 0; | 1438 | return 0; |
1398 | 1439 | ||
1399 | free: | 1440 | free: |
1441 | pci_disable_msi(pdev); | ||
1442 | |||
1400 | pci_set_drvdata(pdev, NULL); | 1443 | pci_set_drvdata(pdev, NULL); |
1401 | kfree(chip); | 1444 | kfree(chip); |
1402 | 1445 | ||
@@ -1419,6 +1462,8 @@ static void __devexit sdhci_pci_remove(struct pci_dev *pdev) | |||
1419 | for (i = 0; i < chip->num_slots; i++) | 1462 | for (i = 0; i < chip->num_slots; i++) |
1420 | sdhci_pci_remove_slot(chip->slots[i]); | 1463 | sdhci_pci_remove_slot(chip->slots[i]); |
1421 | 1464 | ||
1465 | pci_disable_msi(pdev); | ||
1466 | |||
1422 | pci_set_drvdata(pdev, NULL); | 1467 | pci_set_drvdata(pdev, NULL); |
1423 | kfree(chip); | 1468 | kfree(chip); |
1424 | } | 1469 | } |
diff --git a/drivers/mmc/host/sdhci-spear.c b/drivers/mmc/host/sdhci-spear.c index b7f8b33c5f19..6dfa82e03c7e 100644 --- a/drivers/mmc/host/sdhci-spear.c +++ b/drivers/mmc/host/sdhci-spear.c | |||
@@ -300,20 +300,15 @@ static int sdhci_resume(struct device *dev) | |||
300 | 300 | ||
301 | return sdhci_resume_host(host); | 301 | return sdhci_resume_host(host); |
302 | } | 302 | } |
303 | |||
304 | const struct dev_pm_ops sdhci_pm_ops = { | ||
305 | .suspend = sdhci_suspend, | ||
306 | .resume = sdhci_resume, | ||
307 | }; | ||
308 | #endif | 303 | #endif |
309 | 304 | ||
305 | static SIMPLE_DEV_PM_OPS(sdhci_pm_ops, sdhci_suspend, sdhci_resume); | ||
306 | |||
310 | static struct platform_driver sdhci_driver = { | 307 | static struct platform_driver sdhci_driver = { |
311 | .driver = { | 308 | .driver = { |
312 | .name = "sdhci", | 309 | .name = "sdhci", |
313 | .owner = THIS_MODULE, | 310 | .owner = THIS_MODULE, |
314 | #ifdef CONFIG_PM | ||
315 | .pm = &sdhci_pm_ops, | 311 | .pm = &sdhci_pm_ops, |
316 | #endif | ||
317 | }, | 312 | }, |
318 | .probe = sdhci_probe, | 313 | .probe = sdhci_probe, |
319 | .remove = __devexit_p(sdhci_remove), | 314 | .remove = __devexit_p(sdhci_remove), |
diff --git a/drivers/mmc/host/sdhci-tegra.c b/drivers/mmc/host/sdhci-tegra.c index cb348569454b..53b26502f6e2 100644 --- a/drivers/mmc/host/sdhci-tegra.c +++ b/drivers/mmc/host/sdhci-tegra.c | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <linux/clk.h> | 19 | #include <linux/clk.h> |
20 | #include <linux/io.h> | 20 | #include <linux/io.h> |
21 | #include <linux/of.h> | 21 | #include <linux/of.h> |
22 | #include <linux/of_device.h> | ||
22 | #include <linux/of_gpio.h> | 23 | #include <linux/of_gpio.h> |
23 | #include <linux/gpio.h> | 24 | #include <linux/gpio.h> |
24 | #include <linux/mmc/card.h> | 25 | #include <linux/mmc/card.h> |
@@ -31,6 +32,19 @@ | |||
31 | 32 | ||
32 | #include "sdhci-pltfm.h" | 33 | #include "sdhci-pltfm.h" |
33 | 34 | ||
35 | #define NVQUIRK_FORCE_SDHCI_SPEC_200 BIT(0) | ||
36 | #define NVQUIRK_ENABLE_BLOCK_GAP_DET BIT(1) | ||
37 | |||
38 | struct sdhci_tegra_soc_data { | ||
39 | struct sdhci_pltfm_data *pdata; | ||
40 | u32 nvquirks; | ||
41 | }; | ||
42 | |||
43 | struct sdhci_tegra { | ||
44 | const struct tegra_sdhci_platform_data *plat; | ||
45 | const struct sdhci_tegra_soc_data *soc_data; | ||
46 | }; | ||
47 | |||
34 | static u32 tegra_sdhci_readl(struct sdhci_host *host, int reg) | 48 | static u32 tegra_sdhci_readl(struct sdhci_host *host, int reg) |
35 | { | 49 | { |
36 | u32 val; | 50 | u32 val; |
@@ -46,7 +60,12 @@ static u32 tegra_sdhci_readl(struct sdhci_host *host, int reg) | |||
46 | 60 | ||
47 | static u16 tegra_sdhci_readw(struct sdhci_host *host, int reg) | 61 | static u16 tegra_sdhci_readw(struct sdhci_host *host, int reg) |
48 | { | 62 | { |
49 | if (unlikely(reg == SDHCI_HOST_VERSION)) { | 63 | struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); |
64 | struct sdhci_tegra *tegra_host = pltfm_host->priv; | ||
65 | const struct sdhci_tegra_soc_data *soc_data = tegra_host->soc_data; | ||
66 | |||
67 | if (unlikely((soc_data->nvquirks & NVQUIRK_FORCE_SDHCI_SPEC_200) && | ||
68 | (reg == SDHCI_HOST_VERSION))) { | ||
50 | /* Erratum: Version register is invalid in HW. */ | 69 | /* Erratum: Version register is invalid in HW. */ |
51 | return SDHCI_SPEC_200; | 70 | return SDHCI_SPEC_200; |
52 | } | 71 | } |
@@ -56,6 +75,10 @@ static u16 tegra_sdhci_readw(struct sdhci_host *host, int reg) | |||
56 | 75 | ||
57 | static void tegra_sdhci_writel(struct sdhci_host *host, u32 val, int reg) | 76 | static void tegra_sdhci_writel(struct sdhci_host *host, u32 val, int reg) |
58 | { | 77 | { |
78 | struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); | ||
79 | struct sdhci_tegra *tegra_host = pltfm_host->priv; | ||
80 | const struct sdhci_tegra_soc_data *soc_data = tegra_host->soc_data; | ||
81 | |||
59 | /* Seems like we're getting spurious timeout and crc errors, so | 82 | /* Seems like we're getting spurious timeout and crc errors, so |
60 | * disable signalling of them. In case of real errors software | 83 | * disable signalling of them. In case of real errors software |
61 | * timers should take care of eventually detecting them. | 84 | * timers should take care of eventually detecting them. |
@@ -65,7 +88,8 @@ static void tegra_sdhci_writel(struct sdhci_host *host, u32 val, int reg) | |||
65 | 88 | ||
66 | writel(val, host->ioaddr + reg); | 89 | writel(val, host->ioaddr + reg); |
67 | 90 | ||
68 | if (unlikely(reg == SDHCI_INT_ENABLE)) { | 91 | if (unlikely((soc_data->nvquirks & NVQUIRK_ENABLE_BLOCK_GAP_DET) && |
92 | (reg == SDHCI_INT_ENABLE))) { | ||
69 | /* Erratum: Must enable block gap interrupt detection */ | 93 | /* Erratum: Must enable block gap interrupt detection */ |
70 | u8 gap_ctrl = readb(host->ioaddr + SDHCI_BLOCK_GAP_CONTROL); | 94 | u8 gap_ctrl = readb(host->ioaddr + SDHCI_BLOCK_GAP_CONTROL); |
71 | if (val & SDHCI_INT_CARD_INT) | 95 | if (val & SDHCI_INT_CARD_INT) |
@@ -76,10 +100,11 @@ static void tegra_sdhci_writel(struct sdhci_host *host, u32 val, int reg) | |||
76 | } | 100 | } |
77 | } | 101 | } |
78 | 102 | ||
79 | static unsigned int tegra_sdhci_get_ro(struct sdhci_host *sdhci) | 103 | static unsigned int tegra_sdhci_get_ro(struct sdhci_host *host) |
80 | { | 104 | { |
81 | struct sdhci_pltfm_host *pltfm_host = sdhci_priv(sdhci); | 105 | struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); |
82 | struct tegra_sdhci_platform_data *plat = pltfm_host->priv; | 106 | struct sdhci_tegra *tegra_host = pltfm_host->priv; |
107 | const struct tegra_sdhci_platform_data *plat = tegra_host->plat; | ||
83 | 108 | ||
84 | if (!gpio_is_valid(plat->wp_gpio)) | 109 | if (!gpio_is_valid(plat->wp_gpio)) |
85 | return -1; | 110 | return -1; |
@@ -98,7 +123,8 @@ static irqreturn_t carddetect_irq(int irq, void *data) | |||
98 | static int tegra_sdhci_8bit(struct sdhci_host *host, int bus_width) | 123 | static int tegra_sdhci_8bit(struct sdhci_host *host, int bus_width) |
99 | { | 124 | { |
100 | struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); | 125 | struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); |
101 | struct tegra_sdhci_platform_data *plat = pltfm_host->priv; | 126 | struct sdhci_tegra *tegra_host = pltfm_host->priv; |
127 | const struct tegra_sdhci_platform_data *plat = tegra_host->plat; | ||
102 | u32 ctrl; | 128 | u32 ctrl; |
103 | 129 | ||
104 | ctrl = sdhci_readb(host, SDHCI_HOST_CONTROL); | 130 | ctrl = sdhci_readb(host, SDHCI_HOST_CONTROL); |
@@ -124,16 +150,44 @@ static struct sdhci_ops tegra_sdhci_ops = { | |||
124 | .platform_8bit_width = tegra_sdhci_8bit, | 150 | .platform_8bit_width = tegra_sdhci_8bit, |
125 | }; | 151 | }; |
126 | 152 | ||
127 | static struct sdhci_pltfm_data sdhci_tegra_pdata = { | 153 | #ifdef CONFIG_ARCH_TEGRA_2x_SOC |
154 | static struct sdhci_pltfm_data sdhci_tegra20_pdata = { | ||
155 | .quirks = SDHCI_QUIRK_BROKEN_TIMEOUT_VAL | | ||
156 | SDHCI_QUIRK_SINGLE_POWER_WRITE | | ||
157 | SDHCI_QUIRK_NO_HISPD_BIT | | ||
158 | SDHCI_QUIRK_BROKEN_ADMA_ZEROLEN_DESC, | ||
159 | .ops = &tegra_sdhci_ops, | ||
160 | }; | ||
161 | |||
162 | static struct sdhci_tegra_soc_data soc_data_tegra20 = { | ||
163 | .pdata = &sdhci_tegra20_pdata, | ||
164 | .nvquirks = NVQUIRK_FORCE_SDHCI_SPEC_200 | | ||
165 | NVQUIRK_ENABLE_BLOCK_GAP_DET, | ||
166 | }; | ||
167 | #endif | ||
168 | |||
169 | #ifdef CONFIG_ARCH_TEGRA_3x_SOC | ||
170 | static struct sdhci_pltfm_data sdhci_tegra30_pdata = { | ||
128 | .quirks = SDHCI_QUIRK_BROKEN_TIMEOUT_VAL | | 171 | .quirks = SDHCI_QUIRK_BROKEN_TIMEOUT_VAL | |
172 | SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK | | ||
129 | SDHCI_QUIRK_SINGLE_POWER_WRITE | | 173 | SDHCI_QUIRK_SINGLE_POWER_WRITE | |
130 | SDHCI_QUIRK_NO_HISPD_BIT | | 174 | SDHCI_QUIRK_NO_HISPD_BIT | |
131 | SDHCI_QUIRK_BROKEN_ADMA_ZEROLEN_DESC, | 175 | SDHCI_QUIRK_BROKEN_ADMA_ZEROLEN_DESC, |
132 | .ops = &tegra_sdhci_ops, | 176 | .ops = &tegra_sdhci_ops, |
133 | }; | 177 | }; |
134 | 178 | ||
179 | static struct sdhci_tegra_soc_data soc_data_tegra30 = { | ||
180 | .pdata = &sdhci_tegra30_pdata, | ||
181 | }; | ||
182 | #endif | ||
183 | |||
135 | static const struct of_device_id sdhci_tegra_dt_match[] __devinitdata = { | 184 | static const struct of_device_id sdhci_tegra_dt_match[] __devinitdata = { |
136 | { .compatible = "nvidia,tegra20-sdhci", }, | 185 | #ifdef CONFIG_ARCH_TEGRA_3x_SOC |
186 | { .compatible = "nvidia,tegra30-sdhci", .data = &soc_data_tegra30 }, | ||
187 | #endif | ||
188 | #ifdef CONFIG_ARCH_TEGRA_2x_SOC | ||
189 | { .compatible = "nvidia,tegra20-sdhci", .data = &soc_data_tegra20 }, | ||
190 | #endif | ||
137 | {} | 191 | {} |
138 | }; | 192 | }; |
139 | MODULE_DEVICE_TABLE(of, sdhci_dt_ids); | 193 | MODULE_DEVICE_TABLE(of, sdhci_dt_ids); |
@@ -164,13 +218,22 @@ static struct tegra_sdhci_platform_data * __devinit sdhci_tegra_dt_parse_pdata( | |||
164 | 218 | ||
165 | static int __devinit sdhci_tegra_probe(struct platform_device *pdev) | 219 | static int __devinit sdhci_tegra_probe(struct platform_device *pdev) |
166 | { | 220 | { |
221 | const struct of_device_id *match; | ||
222 | const struct sdhci_tegra_soc_data *soc_data; | ||
223 | struct sdhci_host *host; | ||
167 | struct sdhci_pltfm_host *pltfm_host; | 224 | struct sdhci_pltfm_host *pltfm_host; |
168 | struct tegra_sdhci_platform_data *plat; | 225 | struct tegra_sdhci_platform_data *plat; |
169 | struct sdhci_host *host; | 226 | struct sdhci_tegra *tegra_host; |
170 | struct clk *clk; | 227 | struct clk *clk; |
171 | int rc; | 228 | int rc; |
172 | 229 | ||
173 | host = sdhci_pltfm_init(pdev, &sdhci_tegra_pdata); | 230 | match = of_match_device(sdhci_tegra_dt_match, &pdev->dev); |
231 | if (match) | ||
232 | soc_data = match->data; | ||
233 | else | ||
234 | soc_data = &soc_data_tegra20; | ||
235 | |||
236 | host = sdhci_pltfm_init(pdev, soc_data->pdata); | ||
174 | if (IS_ERR(host)) | 237 | if (IS_ERR(host)) |
175 | return PTR_ERR(host); | 238 | return PTR_ERR(host); |
176 | 239 | ||
@@ -187,7 +250,17 @@ static int __devinit sdhci_tegra_probe(struct platform_device *pdev) | |||
187 | goto err_no_plat; | 250 | goto err_no_plat; |
188 | } | 251 | } |
189 | 252 | ||
190 | pltfm_host->priv = plat; | 253 | tegra_host = devm_kzalloc(&pdev->dev, sizeof(*tegra_host), GFP_KERNEL); |
254 | if (!tegra_host) { | ||
255 | dev_err(mmc_dev(host->mmc), "failed to allocate tegra_host\n"); | ||
256 | rc = -ENOMEM; | ||
257 | goto err_no_plat; | ||
258 | } | ||
259 | |||
260 | tegra_host->plat = plat; | ||
261 | tegra_host->soc_data = soc_data; | ||
262 | |||
263 | pltfm_host->priv = tegra_host; | ||
191 | 264 | ||
192 | if (gpio_is_valid(plat->power_gpio)) { | 265 | if (gpio_is_valid(plat->power_gpio)) { |
193 | rc = gpio_request(plat->power_gpio, "sdhci_power"); | 266 | rc = gpio_request(plat->power_gpio, "sdhci_power"); |
@@ -283,7 +356,8 @@ static int __devexit sdhci_tegra_remove(struct platform_device *pdev) | |||
283 | { | 356 | { |
284 | struct sdhci_host *host = platform_get_drvdata(pdev); | 357 | struct sdhci_host *host = platform_get_drvdata(pdev); |
285 | struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); | 358 | struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); |
286 | struct tegra_sdhci_platform_data *plat = pltfm_host->priv; | 359 | struct sdhci_tegra *tegra_host = pltfm_host->priv; |
360 | const struct tegra_sdhci_platform_data *plat = tegra_host->plat; | ||
287 | int dead = (readl(host->ioaddr + SDHCI_INT_STATUS) == 0xffffffff); | 361 | int dead = (readl(host->ioaddr + SDHCI_INT_STATUS) == 0xffffffff); |
288 | 362 | ||
289 | sdhci_remove_host(host, dead); | 363 | sdhci_remove_host(host, dead); |
@@ -326,5 +400,5 @@ static struct platform_driver sdhci_tegra_driver = { | |||
326 | module_platform_driver(sdhci_tegra_driver); | 400 | module_platform_driver(sdhci_tegra_driver); |
327 | 401 | ||
328 | MODULE_DESCRIPTION("SDHCI driver for Tegra"); | 402 | MODULE_DESCRIPTION("SDHCI driver for Tegra"); |
329 | MODULE_AUTHOR(" Google, Inc."); | 403 | MODULE_AUTHOR("Google, Inc."); |
330 | MODULE_LICENSE("GPL v2"); | 404 | MODULE_LICENSE("GPL v2"); |
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 8d66706824a6..8262cadfdab7 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c | |||
@@ -2267,8 +2267,8 @@ static irqreturn_t sdhci_irq(int irq, void *dev_id) | |||
2267 | { | 2267 | { |
2268 | irqreturn_t result; | 2268 | irqreturn_t result; |
2269 | struct sdhci_host *host = dev_id; | 2269 | struct sdhci_host *host = dev_id; |
2270 | u32 intmask; | 2270 | u32 intmask, unexpected = 0; |
2271 | int cardint = 0; | 2271 | int cardint = 0, max_loops = 16; |
2272 | 2272 | ||
2273 | spin_lock(&host->lock); | 2273 | spin_lock(&host->lock); |
2274 | 2274 | ||
@@ -2286,6 +2286,7 @@ static irqreturn_t sdhci_irq(int irq, void *dev_id) | |||
2286 | goto out; | 2286 | goto out; |
2287 | } | 2287 | } |
2288 | 2288 | ||
2289 | again: | ||
2289 | DBG("*** %s got interrupt: 0x%08x\n", | 2290 | DBG("*** %s got interrupt: 0x%08x\n", |
2290 | mmc_hostname(host->mmc), intmask); | 2291 | mmc_hostname(host->mmc), intmask); |
2291 | 2292 | ||
@@ -2344,19 +2345,23 @@ static irqreturn_t sdhci_irq(int irq, void *dev_id) | |||
2344 | intmask &= ~SDHCI_INT_CARD_INT; | 2345 | intmask &= ~SDHCI_INT_CARD_INT; |
2345 | 2346 | ||
2346 | if (intmask) { | 2347 | if (intmask) { |
2347 | pr_err("%s: Unexpected interrupt 0x%08x.\n", | 2348 | unexpected |= intmask; |
2348 | mmc_hostname(host->mmc), intmask); | ||
2349 | sdhci_dumpregs(host); | ||
2350 | |||
2351 | sdhci_writel(host, intmask, SDHCI_INT_STATUS); | 2349 | sdhci_writel(host, intmask, SDHCI_INT_STATUS); |
2352 | } | 2350 | } |
2353 | 2351 | ||
2354 | result = IRQ_HANDLED; | 2352 | result = IRQ_HANDLED; |
2355 | 2353 | ||
2356 | mmiowb(); | 2354 | intmask = sdhci_readl(host, SDHCI_INT_STATUS); |
2355 | if (intmask && --max_loops) | ||
2356 | goto again; | ||
2357 | out: | 2357 | out: |
2358 | spin_unlock(&host->lock); | 2358 | spin_unlock(&host->lock); |
2359 | 2359 | ||
2360 | if (unexpected) { | ||
2361 | pr_err("%s: Unexpected interrupt 0x%08x.\n", | ||
2362 | mmc_hostname(host->mmc), unexpected); | ||
2363 | sdhci_dumpregs(host); | ||
2364 | } | ||
2360 | /* | 2365 | /* |
2361 | * We have to delay this as it calls back into the driver. | 2366 | * We have to delay this as it calls back into the driver. |
2362 | */ | 2367 | */ |
@@ -2379,6 +2384,9 @@ int sdhci_suspend_host(struct sdhci_host *host) | |||
2379 | int ret; | 2384 | int ret; |
2380 | bool has_tuning_timer; | 2385 | bool has_tuning_timer; |
2381 | 2386 | ||
2387 | if (host->ops->platform_suspend) | ||
2388 | host->ops->platform_suspend(host); | ||
2389 | |||
2382 | sdhci_disable_card_detection(host); | 2390 | sdhci_disable_card_detection(host); |
2383 | 2391 | ||
2384 | /* Disable tuning since we are suspending */ | 2392 | /* Disable tuning since we are suspending */ |
@@ -2423,12 +2431,24 @@ int sdhci_resume_host(struct sdhci_host *host) | |||
2423 | if (ret) | 2431 | if (ret) |
2424 | return ret; | 2432 | return ret; |
2425 | 2433 | ||
2426 | sdhci_init(host, (host->mmc->pm_flags & MMC_PM_KEEP_POWER)); | 2434 | if ((host->mmc->pm_flags & MMC_PM_KEEP_POWER) && |
2427 | mmiowb(); | 2435 | (host->quirks2 & SDHCI_QUIRK2_HOST_OFF_CARD_ON)) { |
2436 | /* Card keeps power but host controller does not */ | ||
2437 | sdhci_init(host, 0); | ||
2438 | host->pwr = 0; | ||
2439 | host->clock = 0; | ||
2440 | sdhci_do_set_ios(host, &host->mmc->ios); | ||
2441 | } else { | ||
2442 | sdhci_init(host, (host->mmc->pm_flags & MMC_PM_KEEP_POWER)); | ||
2443 | mmiowb(); | ||
2444 | } | ||
2428 | 2445 | ||
2429 | ret = mmc_resume_host(host->mmc); | 2446 | ret = mmc_resume_host(host->mmc); |
2430 | sdhci_enable_card_detection(host); | 2447 | sdhci_enable_card_detection(host); |
2431 | 2448 | ||
2449 | if (host->ops->platform_resume) | ||
2450 | host->ops->platform_resume(host); | ||
2451 | |||
2432 | /* Set the re-tuning expiration flag */ | 2452 | /* Set the re-tuning expiration flag */ |
2433 | if ((host->version >= SDHCI_SPEC_300) && host->tuning_count && | 2453 | if ((host->version >= SDHCI_SPEC_300) && host->tuning_count && |
2434 | (host->tuning_mode == SDHCI_TUNING_MODE_1)) | 2454 | (host->tuning_mode == SDHCI_TUNING_MODE_1)) |
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h index ad265b96b75b..f761f23d2a28 100644 --- a/drivers/mmc/host/sdhci.h +++ b/drivers/mmc/host/sdhci.h | |||
@@ -275,6 +275,8 @@ struct sdhci_ops { | |||
275 | void (*platform_reset_exit)(struct sdhci_host *host, u8 mask); | 275 | void (*platform_reset_exit)(struct sdhci_host *host, u8 mask); |
276 | int (*set_uhs_signaling)(struct sdhci_host *host, unsigned int uhs); | 276 | int (*set_uhs_signaling)(struct sdhci_host *host, unsigned int uhs); |
277 | void (*hw_reset)(struct sdhci_host *host); | 277 | void (*hw_reset)(struct sdhci_host *host); |
278 | void (*platform_suspend)(struct sdhci_host *host); | ||
279 | void (*platform_resume)(struct sdhci_host *host); | ||
278 | }; | 280 | }; |
279 | 281 | ||
280 | #ifdef CONFIG_MMC_SDHCI_IO_ACCESSORS | 282 | #ifdef CONFIG_MMC_SDHCI_IO_ACCESSORS |
diff --git a/drivers/mmc/host/sh_mmcif.c b/drivers/mmc/host/sh_mmcif.c index 75a485448796..60f205708f54 100644 --- a/drivers/mmc/host/sh_mmcif.c +++ b/drivers/mmc/host/sh_mmcif.c | |||
@@ -746,7 +746,6 @@ static u32 sh_mmcif_set_cmd(struct sh_mmcif_host *host, | |||
746 | case MMC_SET_WRITE_PROT: | 746 | case MMC_SET_WRITE_PROT: |
747 | case MMC_CLR_WRITE_PROT: | 747 | case MMC_CLR_WRITE_PROT: |
748 | case MMC_ERASE: | 748 | case MMC_ERASE: |
749 | case MMC_GEN_CMD: | ||
750 | tmp |= CMD_SET_RBSY; | 749 | tmp |= CMD_SET_RBSY; |
751 | break; | 750 | break; |
752 | } | 751 | } |
@@ -829,7 +828,6 @@ static void sh_mmcif_start_cmd(struct sh_mmcif_host *host, | |||
829 | case MMC_SET_WRITE_PROT: | 828 | case MMC_SET_WRITE_PROT: |
830 | case MMC_CLR_WRITE_PROT: | 829 | case MMC_CLR_WRITE_PROT: |
831 | case MMC_ERASE: | 830 | case MMC_ERASE: |
832 | case MMC_GEN_CMD: | ||
833 | mask = MASK_START_CMD | MASK_MRBSYE; | 831 | mask = MASK_START_CMD | MASK_MRBSYE; |
834 | break; | 832 | break; |
835 | default: | 833 | default: |
diff --git a/drivers/mmc/host/sh_mobile_sdhi.c b/drivers/mmc/host/sh_mobile_sdhi.c index 58da3c44acc5..934b68e9efc3 100644 --- a/drivers/mmc/host/sh_mobile_sdhi.c +++ b/drivers/mmc/host/sh_mobile_sdhi.c | |||
@@ -90,6 +90,15 @@ static int sh_mobile_sdhi_write16_hook(struct tmio_mmc_host *host, int addr) | |||
90 | return 0; | 90 | return 0; |
91 | } | 91 | } |
92 | 92 | ||
93 | static void sh_mobile_sdhi_cd_wakeup(const struct platform_device *pdev) | ||
94 | { | ||
95 | mmc_detect_change(dev_get_drvdata(&pdev->dev), msecs_to_jiffies(100)); | ||
96 | } | ||
97 | |||
98 | static const struct sh_mobile_sdhi_ops sdhi_ops = { | ||
99 | .cd_wakeup = sh_mobile_sdhi_cd_wakeup, | ||
100 | }; | ||
101 | |||
93 | static int __devinit sh_mobile_sdhi_probe(struct platform_device *pdev) | 102 | static int __devinit sh_mobile_sdhi_probe(struct platform_device *pdev) |
94 | { | 103 | { |
95 | struct sh_mobile_sdhi *priv; | 104 | struct sh_mobile_sdhi *priv; |
@@ -109,6 +118,12 @@ static int __devinit sh_mobile_sdhi_probe(struct platform_device *pdev) | |||
109 | mmc_data = &priv->mmc_data; | 118 | mmc_data = &priv->mmc_data; |
110 | p->pdata = mmc_data; | 119 | p->pdata = mmc_data; |
111 | 120 | ||
121 | if (p->init) { | ||
122 | ret = p->init(pdev, &sdhi_ops); | ||
123 | if (ret) | ||
124 | goto einit; | ||
125 | } | ||
126 | |||
112 | snprintf(clk_name, sizeof(clk_name), "sdhi%d", pdev->id); | 127 | snprintf(clk_name, sizeof(clk_name), "sdhi%d", pdev->id); |
113 | priv->clk = clk_get(&pdev->dev, clk_name); | 128 | priv->clk = clk_get(&pdev->dev, clk_name); |
114 | if (IS_ERR(priv->clk)) { | 129 | if (IS_ERR(priv->clk)) { |
@@ -117,8 +132,6 @@ static int __devinit sh_mobile_sdhi_probe(struct platform_device *pdev) | |||
117 | goto eclkget; | 132 | goto eclkget; |
118 | } | 133 | } |
119 | 134 | ||
120 | clk_enable(priv->clk); | ||
121 | |||
122 | mmc_data->hclk = clk_get_rate(priv->clk); | 135 | mmc_data->hclk = clk_get_rate(priv->clk); |
123 | mmc_data->set_pwr = sh_mobile_sdhi_set_pwr; | 136 | mmc_data->set_pwr = sh_mobile_sdhi_set_pwr; |
124 | mmc_data->get_cd = sh_mobile_sdhi_get_cd; | 137 | mmc_data->get_cd = sh_mobile_sdhi_get_cd; |
@@ -129,6 +142,7 @@ static int __devinit sh_mobile_sdhi_probe(struct platform_device *pdev) | |||
129 | mmc_data->write16_hook = sh_mobile_sdhi_write16_hook; | 142 | mmc_data->write16_hook = sh_mobile_sdhi_write16_hook; |
130 | mmc_data->ocr_mask = p->tmio_ocr_mask; | 143 | mmc_data->ocr_mask = p->tmio_ocr_mask; |
131 | mmc_data->capabilities |= p->tmio_caps; | 144 | mmc_data->capabilities |= p->tmio_caps; |
145 | mmc_data->cd_gpio = p->cd_gpio; | ||
132 | 146 | ||
133 | if (p->dma_slave_tx > 0 && p->dma_slave_rx > 0) { | 147 | if (p->dma_slave_tx > 0 && p->dma_slave_rx > 0) { |
134 | priv->param_tx.slave_id = p->dma_slave_tx; | 148 | priv->param_tx.slave_id = p->dma_slave_tx; |
@@ -211,7 +225,7 @@ static int __devinit sh_mobile_sdhi_probe(struct platform_device *pdev) | |||
211 | 225 | ||
212 | dev_info(&pdev->dev, "%s base at 0x%08lx clock rate %u MHz\n", | 226 | dev_info(&pdev->dev, "%s base at 0x%08lx clock rate %u MHz\n", |
213 | mmc_hostname(host->mmc), (unsigned long) | 227 | mmc_hostname(host->mmc), (unsigned long) |
214 | (platform_get_resource(pdev,IORESOURCE_MEM, 0)->start), | 228 | (platform_get_resource(pdev, IORESOURCE_MEM, 0)->start), |
215 | mmc_data->hclk / 1000000); | 229 | mmc_data->hclk / 1000000); |
216 | 230 | ||
217 | return ret; | 231 | return ret; |
@@ -232,9 +246,11 @@ eirq_sdio: | |||
232 | eirq_card_detect: | 246 | eirq_card_detect: |
233 | tmio_mmc_host_remove(host); | 247 | tmio_mmc_host_remove(host); |
234 | eprobe: | 248 | eprobe: |
235 | clk_disable(priv->clk); | ||
236 | clk_put(priv->clk); | 249 | clk_put(priv->clk); |
237 | eclkget: | 250 | eclkget: |
251 | if (p->cleanup) | ||
252 | p->cleanup(pdev); | ||
253 | einit: | ||
238 | kfree(priv); | 254 | kfree(priv); |
239 | return ret; | 255 | return ret; |
240 | } | 256 | } |
@@ -258,8 +274,11 @@ static int sh_mobile_sdhi_remove(struct platform_device *pdev) | |||
258 | free_irq(irq, host); | 274 | free_irq(irq, host); |
259 | } | 275 | } |
260 | 276 | ||
261 | clk_disable(priv->clk); | ||
262 | clk_put(priv->clk); | 277 | clk_put(priv->clk); |
278 | |||
279 | if (p->cleanup) | ||
280 | p->cleanup(pdev); | ||
281 | |||
263 | kfree(priv); | 282 | kfree(priv); |
264 | 283 | ||
265 | return 0; | 284 | return 0; |
diff --git a/drivers/mmc/host/tmio_mmc.h b/drivers/mmc/host/tmio_mmc.h index f96c536d130a..d857f5c6e7d9 100644 --- a/drivers/mmc/host/tmio_mmc.h +++ b/drivers/mmc/host/tmio_mmc.h | |||
@@ -47,16 +47,14 @@ struct tmio_mmc_host { | |||
47 | struct mmc_request *mrq; | 47 | struct mmc_request *mrq; |
48 | struct mmc_data *data; | 48 | struct mmc_data *data; |
49 | struct mmc_host *mmc; | 49 | struct mmc_host *mmc; |
50 | unsigned int sdio_irq_enabled; | 50 | |
51 | /* Controller power state */ | ||
52 | bool power; | ||
51 | 53 | ||
52 | /* Callbacks for clock / power control */ | 54 | /* Callbacks for clock / power control */ |
53 | void (*set_pwr)(struct platform_device *host, int state); | 55 | void (*set_pwr)(struct platform_device *host, int state); |
54 | void (*set_clk_div)(struct platform_device *host, int state); | 56 | void (*set_clk_div)(struct platform_device *host, int state); |
55 | 57 | ||
56 | int pm_error; | ||
57 | /* recognise system-wide suspend in runtime PM methods */ | ||
58 | bool pm_global; | ||
59 | |||
60 | /* pio related stuff */ | 58 | /* pio related stuff */ |
61 | struct scatterlist *sg_ptr; | 59 | struct scatterlist *sg_ptr; |
62 | struct scatterlist *sg_orig; | 60 | struct scatterlist *sg_orig; |
@@ -86,6 +84,7 @@ struct tmio_mmc_host { | |||
86 | spinlock_t lock; /* protect host private data */ | 84 | spinlock_t lock; /* protect host private data */ |
87 | unsigned long last_req_ts; | 85 | unsigned long last_req_ts; |
88 | struct mutex ios_lock; /* protect set_ios() context */ | 86 | struct mutex ios_lock; /* protect set_ios() context */ |
87 | bool native_hotplug; | ||
89 | }; | 88 | }; |
90 | 89 | ||
91 | int tmio_mmc_host_probe(struct tmio_mmc_host **host, | 90 | int tmio_mmc_host_probe(struct tmio_mmc_host **host, |
diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c index e21988901c36..9a7996ade58e 100644 --- a/drivers/mmc/host/tmio_mmc_pio.c +++ b/drivers/mmc/host/tmio_mmc_pio.c | |||
@@ -34,6 +34,7 @@ | |||
34 | #include <linux/io.h> | 34 | #include <linux/io.h> |
35 | #include <linux/irq.h> | 35 | #include <linux/irq.h> |
36 | #include <linux/mfd/tmio.h> | 36 | #include <linux/mfd/tmio.h> |
37 | #include <linux/mmc/cd-gpio.h> | ||
37 | #include <linux/mmc/host.h> | 38 | #include <linux/mmc/host.h> |
38 | #include <linux/mmc/tmio.h> | 39 | #include <linux/mmc/tmio.h> |
39 | #include <linux/module.h> | 40 | #include <linux/module.h> |
@@ -127,7 +128,6 @@ static void tmio_mmc_enable_sdio_irq(struct mmc_host *mmc, int enable) | |||
127 | struct tmio_mmc_host *host = mmc_priv(mmc); | 128 | struct tmio_mmc_host *host = mmc_priv(mmc); |
128 | 129 | ||
129 | if (enable) { | 130 | if (enable) { |
130 | host->sdio_irq_enabled = 1; | ||
131 | host->sdio_irq_mask = TMIO_SDIO_MASK_ALL & | 131 | host->sdio_irq_mask = TMIO_SDIO_MASK_ALL & |
132 | ~TMIO_SDIO_STAT_IOIRQ; | 132 | ~TMIO_SDIO_STAT_IOIRQ; |
133 | sd_ctrl_write16(host, CTL_TRANSACTION_CTL, 0x0001); | 133 | sd_ctrl_write16(host, CTL_TRANSACTION_CTL, 0x0001); |
@@ -136,7 +136,6 @@ static void tmio_mmc_enable_sdio_irq(struct mmc_host *mmc, int enable) | |||
136 | host->sdio_irq_mask = TMIO_SDIO_MASK_ALL; | 136 | host->sdio_irq_mask = TMIO_SDIO_MASK_ALL; |
137 | sd_ctrl_write16(host, CTL_SDIO_IRQ_MASK, host->sdio_irq_mask); | 137 | sd_ctrl_write16(host, CTL_SDIO_IRQ_MASK, host->sdio_irq_mask); |
138 | sd_ctrl_write16(host, CTL_TRANSACTION_CTL, 0x0000); | 138 | sd_ctrl_write16(host, CTL_TRANSACTION_CTL, 0x0000); |
139 | host->sdio_irq_enabled = 0; | ||
140 | } | 139 | } |
141 | } | 140 | } |
142 | 141 | ||
@@ -304,6 +303,7 @@ static int tmio_mmc_start_command(struct tmio_mmc_host *host, struct mmc_command | |||
304 | { | 303 | { |
305 | struct mmc_data *data = host->data; | 304 | struct mmc_data *data = host->data; |
306 | int c = cmd->opcode; | 305 | int c = cmd->opcode; |
306 | u32 irq_mask = TMIO_MASK_CMD; | ||
307 | 307 | ||
308 | /* Command 12 is handled by hardware */ | 308 | /* Command 12 is handled by hardware */ |
309 | if (cmd->opcode == 12 && !cmd->arg) { | 309 | if (cmd->opcode == 12 && !cmd->arg) { |
@@ -339,7 +339,9 @@ static int tmio_mmc_start_command(struct tmio_mmc_host *host, struct mmc_command | |||
339 | c |= TRANSFER_READ; | 339 | c |= TRANSFER_READ; |
340 | } | 340 | } |
341 | 341 | ||
342 | tmio_mmc_enable_mmc_irqs(host, TMIO_MASK_CMD); | 342 | if (!host->native_hotplug) |
343 | irq_mask &= ~(TMIO_STAT_CARD_REMOVE | TMIO_STAT_CARD_INSERT); | ||
344 | tmio_mmc_enable_mmc_irqs(host, irq_mask); | ||
343 | 345 | ||
344 | /* Fire off the command */ | 346 | /* Fire off the command */ |
345 | sd_ctrl_write32(host, CTL_ARG_REG, cmd->arg); | 347 | sd_ctrl_write32(host, CTL_ARG_REG, cmd->arg); |
@@ -758,7 +760,7 @@ fail: | |||
758 | static void tmio_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) | 760 | static void tmio_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) |
759 | { | 761 | { |
760 | struct tmio_mmc_host *host = mmc_priv(mmc); | 762 | struct tmio_mmc_host *host = mmc_priv(mmc); |
761 | struct tmio_mmc_data *pdata = host->pdata; | 763 | struct device *dev = &host->pdev->dev; |
762 | unsigned long flags; | 764 | unsigned long flags; |
763 | 765 | ||
764 | mutex_lock(&host->ios_lock); | 766 | mutex_lock(&host->ios_lock); |
@@ -766,13 +768,13 @@ static void tmio_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) | |||
766 | spin_lock_irqsave(&host->lock, flags); | 768 | spin_lock_irqsave(&host->lock, flags); |
767 | if (host->mrq) { | 769 | if (host->mrq) { |
768 | if (IS_ERR(host->mrq)) { | 770 | if (IS_ERR(host->mrq)) { |
769 | dev_dbg(&host->pdev->dev, | 771 | dev_dbg(dev, |
770 | "%s.%d: concurrent .set_ios(), clk %u, mode %u\n", | 772 | "%s.%d: concurrent .set_ios(), clk %u, mode %u\n", |
771 | current->comm, task_pid_nr(current), | 773 | current->comm, task_pid_nr(current), |
772 | ios->clock, ios->power_mode); | 774 | ios->clock, ios->power_mode); |
773 | host->mrq = ERR_PTR(-EINTR); | 775 | host->mrq = ERR_PTR(-EINTR); |
774 | } else { | 776 | } else { |
775 | dev_dbg(&host->pdev->dev, | 777 | dev_dbg(dev, |
776 | "%s.%d: CMD%u active since %lu, now %lu!\n", | 778 | "%s.%d: CMD%u active since %lu, now %lu!\n", |
777 | current->comm, task_pid_nr(current), | 779 | current->comm, task_pid_nr(current), |
778 | host->mrq->cmd->opcode, host->last_req_ts, jiffies); | 780 | host->mrq->cmd->opcode, host->last_req_ts, jiffies); |
@@ -788,13 +790,15 @@ static void tmio_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) | |||
788 | spin_unlock_irqrestore(&host->lock, flags); | 790 | spin_unlock_irqrestore(&host->lock, flags); |
789 | 791 | ||
790 | /* | 792 | /* |
791 | * pdata->power == false only if COLD_CD is available, otherwise only | 793 | * host->power toggles between false and true in both cases - either |
792 | * in short time intervals during probing or resuming | 794 | * or not the controller can be runtime-suspended during inactivity. |
795 | * But if the controller has to be kept on, the runtime-pm usage_count | ||
796 | * is kept positive, so no suspending actually takes place. | ||
793 | */ | 797 | */ |
794 | if (ios->power_mode == MMC_POWER_ON && ios->clock) { | 798 | if (ios->power_mode == MMC_POWER_ON && ios->clock) { |
795 | if (!pdata->power) { | 799 | if (!host->power) { |
796 | pm_runtime_get_sync(&host->pdev->dev); | 800 | pm_runtime_get_sync(dev); |
797 | pdata->power = true; | 801 | host->power = true; |
798 | } | 802 | } |
799 | tmio_mmc_set_clock(host, ios->clock); | 803 | tmio_mmc_set_clock(host, ios->clock); |
800 | /* power up SD bus */ | 804 | /* power up SD bus */ |
@@ -805,9 +809,9 @@ static void tmio_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) | |||
805 | } else if (ios->power_mode != MMC_POWER_UP) { | 809 | } else if (ios->power_mode != MMC_POWER_UP) { |
806 | if (host->set_pwr && ios->power_mode == MMC_POWER_OFF) | 810 | if (host->set_pwr && ios->power_mode == MMC_POWER_OFF) |
807 | host->set_pwr(host->pdev, 0); | 811 | host->set_pwr(host->pdev, 0); |
808 | if (pdata->power) { | 812 | if (host->power) { |
809 | pdata->power = false; | 813 | host->power = false; |
810 | pm_runtime_put(&host->pdev->dev); | 814 | pm_runtime_put(dev); |
811 | } | 815 | } |
812 | tmio_mmc_clk_stop(host); | 816 | tmio_mmc_clk_stop(host); |
813 | } | 817 | } |
@@ -913,7 +917,11 @@ int __devinit tmio_mmc_host_probe(struct tmio_mmc_host **host, | |||
913 | else | 917 | else |
914 | mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34; | 918 | mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34; |
915 | 919 | ||
916 | pdata->power = false; | 920 | _host->native_hotplug = !(pdata->flags & TMIO_MMC_USE_GPIO_CD || |
921 | mmc->caps & MMC_CAP_NEEDS_POLL || | ||
922 | mmc->caps & MMC_CAP_NONREMOVABLE); | ||
923 | |||
924 | _host->power = false; | ||
917 | pm_runtime_enable(&pdev->dev); | 925 | pm_runtime_enable(&pdev->dev); |
918 | ret = pm_runtime_resume(&pdev->dev); | 926 | ret = pm_runtime_resume(&pdev->dev); |
919 | if (ret < 0) | 927 | if (ret < 0) |
@@ -926,14 +934,13 @@ int __devinit tmio_mmc_host_probe(struct tmio_mmc_host **host, | |||
926 | * 3) a worker thread polls the sdhi - indicated by MMC_CAP_NEEDS_POLL | 934 | * 3) a worker thread polls the sdhi - indicated by MMC_CAP_NEEDS_POLL |
927 | * 4) the medium is non-removable - indicated by MMC_CAP_NONREMOVABLE | 935 | * 4) the medium is non-removable - indicated by MMC_CAP_NONREMOVABLE |
928 | * | 936 | * |
929 | * While we increment the rtpm counter for all scenarios when the mmc | 937 | * While we increment the runtime PM counter for all scenarios when |
930 | * core activates us by calling an appropriate set_ios(), we must | 938 | * the mmc core activates us by calling an appropriate set_ios(), we |
939 | * must additionally ensure that in case 2) the tmio mmc hardware stays | ||
931 | * additionally ensure that in case 2) the tmio mmc hardware stays | 940 | * additionally ensure that in case 2) the tmio mmc hardware stays |
932 | * powered on during runtime for the card detection to work. | 941 | * powered on during runtime for the card detection to work. |
933 | */ | 942 | */ |
934 | if (!(pdata->flags & TMIO_MMC_HAS_COLD_CD | 943 | if (_host->native_hotplug) |
935 | || mmc->caps & MMC_CAP_NEEDS_POLL | ||
936 | || mmc->caps & MMC_CAP_NONREMOVABLE)) | ||
937 | pm_runtime_get_noresume(&pdev->dev); | 944 | pm_runtime_get_noresume(&pdev->dev); |
938 | 945 | ||
939 | tmio_mmc_clk_stop(_host); | 946 | tmio_mmc_clk_stop(_host); |
@@ -963,9 +970,19 @@ int __devinit tmio_mmc_host_probe(struct tmio_mmc_host **host, | |||
963 | irq_mask |= TMIO_MASK_READOP; | 970 | irq_mask |= TMIO_MASK_READOP; |
964 | if (!_host->chan_tx) | 971 | if (!_host->chan_tx) |
965 | irq_mask |= TMIO_MASK_WRITEOP; | 972 | irq_mask |= TMIO_MASK_WRITEOP; |
973 | if (!_host->native_hotplug) | ||
974 | irq_mask &= ~(TMIO_STAT_CARD_REMOVE | TMIO_STAT_CARD_INSERT); | ||
966 | 975 | ||
967 | tmio_mmc_enable_mmc_irqs(_host, irq_mask); | 976 | tmio_mmc_enable_mmc_irqs(_host, irq_mask); |
968 | 977 | ||
978 | if (pdata->flags & TMIO_MMC_USE_GPIO_CD) { | ||
979 | ret = mmc_cd_gpio_request(mmc, pdata->cd_gpio); | ||
980 | if (ret < 0) { | ||
981 | tmio_mmc_host_remove(_host); | ||
982 | return ret; | ||
983 | } | ||
984 | } | ||
985 | |||
969 | *host = _host; | 986 | *host = _host; |
970 | 987 | ||
971 | return 0; | 988 | return 0; |
@@ -983,22 +1000,22 @@ EXPORT_SYMBOL(tmio_mmc_host_probe); | |||
983 | void tmio_mmc_host_remove(struct tmio_mmc_host *host) | 1000 | void tmio_mmc_host_remove(struct tmio_mmc_host *host) |
984 | { | 1001 | { |
985 | struct platform_device *pdev = host->pdev; | 1002 | struct platform_device *pdev = host->pdev; |
1003 | struct tmio_mmc_data *pdata = host->pdata; | ||
1004 | struct mmc_host *mmc = host->mmc; | ||
986 | 1005 | ||
987 | /* | 1006 | if (pdata->flags & TMIO_MMC_USE_GPIO_CD) |
988 | * We don't have to manipulate pdata->power here: if there is a card in | 1007 | /* |
989 | * the slot, the runtime PM is active and our .runtime_resume() will not | 1008 | * This means we can miss a card-eject, but this is anyway |
990 | * be run. If there is no card in the slot and the platform can suspend | 1009 | * possible, because of delayed processing of hotplug events. |
991 | * the controller, the runtime PM is suspended and pdata->power == false, | 1010 | */ |
992 | * so, our .runtime_resume() will not try to detect a card in the slot. | 1011 | mmc_cd_gpio_free(mmc); |
993 | */ | 1012 | |
994 | if (host->pdata->flags & TMIO_MMC_HAS_COLD_CD | 1013 | if (!host->native_hotplug) |
995 | || host->mmc->caps & MMC_CAP_NEEDS_POLL | ||
996 | || host->mmc->caps & MMC_CAP_NONREMOVABLE) | ||
997 | pm_runtime_get_sync(&pdev->dev); | 1014 | pm_runtime_get_sync(&pdev->dev); |
998 | 1015 | ||
999 | dev_pm_qos_hide_latency_limit(&pdev->dev); | 1016 | dev_pm_qos_hide_latency_limit(&pdev->dev); |
1000 | 1017 | ||
1001 | mmc_remove_host(host->mmc); | 1018 | mmc_remove_host(mmc); |
1002 | cancel_work_sync(&host->done); | 1019 | cancel_work_sync(&host->done); |
1003 | cancel_delayed_work_sync(&host->delayed_reset_work); | 1020 | cancel_delayed_work_sync(&host->delayed_reset_work); |
1004 | tmio_mmc_release_dma(host); | 1021 | tmio_mmc_release_dma(host); |
@@ -1007,7 +1024,7 @@ void tmio_mmc_host_remove(struct tmio_mmc_host *host) | |||
1007 | pm_runtime_disable(&pdev->dev); | 1024 | pm_runtime_disable(&pdev->dev); |
1008 | 1025 | ||
1009 | iounmap(host->ctl); | 1026 | iounmap(host->ctl); |
1010 | mmc_free_host(host->mmc); | 1027 | mmc_free_host(mmc); |
1011 | } | 1028 | } |
1012 | EXPORT_SYMBOL(tmio_mmc_host_remove); | 1029 | EXPORT_SYMBOL(tmio_mmc_host_remove); |
1013 | 1030 | ||
@@ -1021,8 +1038,6 @@ int tmio_mmc_host_suspend(struct device *dev) | |||
1021 | if (!ret) | 1038 | if (!ret) |
1022 | tmio_mmc_disable_mmc_irqs(host, TMIO_MASK_ALL); | 1039 | tmio_mmc_disable_mmc_irqs(host, TMIO_MASK_ALL); |
1023 | 1040 | ||
1024 | host->pm_error = pm_runtime_put_sync(dev); | ||
1025 | |||
1026 | return ret; | 1041 | return ret; |
1027 | } | 1042 | } |
1028 | EXPORT_SYMBOL(tmio_mmc_host_suspend); | 1043 | EXPORT_SYMBOL(tmio_mmc_host_suspend); |
@@ -1032,20 +1047,10 @@ int tmio_mmc_host_resume(struct device *dev) | |||
1032 | struct mmc_host *mmc = dev_get_drvdata(dev); | 1047 | struct mmc_host *mmc = dev_get_drvdata(dev); |
1033 | struct tmio_mmc_host *host = mmc_priv(mmc); | 1048 | struct tmio_mmc_host *host = mmc_priv(mmc); |
1034 | 1049 | ||
1035 | /* The MMC core will perform the complete set up */ | 1050 | tmio_mmc_reset(host); |
1036 | host->pdata->power = false; | 1051 | tmio_mmc_enable_dma(host, true); |
1037 | |||
1038 | host->pm_global = true; | ||
1039 | if (!host->pm_error) | ||
1040 | pm_runtime_get_sync(dev); | ||
1041 | |||
1042 | if (host->pm_global) { | ||
1043 | /* Runtime PM resume callback didn't run */ | ||
1044 | tmio_mmc_reset(host); | ||
1045 | tmio_mmc_enable_dma(host, true); | ||
1046 | host->pm_global = false; | ||
1047 | } | ||
1048 | 1052 | ||
1053 | /* The MMC core will perform the complete set up */ | ||
1049 | return mmc_resume_host(mmc); | 1054 | return mmc_resume_host(mmc); |
1050 | } | 1055 | } |
1051 | EXPORT_SYMBOL(tmio_mmc_host_resume); | 1056 | EXPORT_SYMBOL(tmio_mmc_host_resume); |
@@ -1062,19 +1067,10 @@ int tmio_mmc_host_runtime_resume(struct device *dev) | |||
1062 | { | 1067 | { |
1063 | struct mmc_host *mmc = dev_get_drvdata(dev); | 1068 | struct mmc_host *mmc = dev_get_drvdata(dev); |
1064 | struct tmio_mmc_host *host = mmc_priv(mmc); | 1069 | struct tmio_mmc_host *host = mmc_priv(mmc); |
1065 | struct tmio_mmc_data *pdata = host->pdata; | ||
1066 | 1070 | ||
1067 | tmio_mmc_reset(host); | 1071 | tmio_mmc_reset(host); |
1068 | tmio_mmc_enable_dma(host, true); | 1072 | tmio_mmc_enable_dma(host, true); |
1069 | 1073 | ||
1070 | if (pdata->power) { | ||
1071 | /* Only entered after a card-insert interrupt */ | ||
1072 | if (!mmc->card) | ||
1073 | tmio_mmc_set_ios(mmc, &mmc->ios); | ||
1074 | mmc_detect_change(mmc, msecs_to_jiffies(100)); | ||
1075 | } | ||
1076 | host->pm_global = false; | ||
1077 | |||
1078 | return 0; | 1074 | return 0; |
1079 | } | 1075 | } |
1080 | EXPORT_SYMBOL(tmio_mmc_host_runtime_resume); | 1076 | EXPORT_SYMBOL(tmio_mmc_host_runtime_resume); |