aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/mmc/host/mmci.c306
-rw-r--r--drivers/mmc/host/mmci.h3
2 files changed, 183 insertions, 126 deletions
diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
index 150772395cc6..372e921389c8 100644
--- a/drivers/mmc/host/mmci.c
+++ b/drivers/mmc/host/mmci.c
@@ -20,6 +20,7 @@
20#include <linux/err.h> 20#include <linux/err.h>
21#include <linux/highmem.h> 21#include <linux/highmem.h>
22#include <linux/log2.h> 22#include <linux/log2.h>
23#include <linux/mmc/pm.h>
23#include <linux/mmc/host.h> 24#include <linux/mmc/host.h>
24#include <linux/mmc/card.h> 25#include <linux/mmc/card.h>
25#include <linux/amba/bus.h> 26#include <linux/amba/bus.h>
@@ -59,6 +60,7 @@ static unsigned int fmax = 515633;
59 * @blksz_datactrl16: true if Block size is at b16..b30 position in datactrl register 60 * @blksz_datactrl16: true if Block size is at b16..b30 position in datactrl register
60 * @pwrreg_powerup: power up value for MMCIPOWER register 61 * @pwrreg_powerup: power up value for MMCIPOWER register
61 * @signal_direction: input/out direction of bus signals can be indicated 62 * @signal_direction: input/out direction of bus signals can be indicated
63 * @pwrreg_clkgate: MMCIPOWER register must be used to gate the clock
62 */ 64 */
63struct variant_data { 65struct variant_data {
64 unsigned int clkreg; 66 unsigned int clkreg;
@@ -71,6 +73,7 @@ struct variant_data {
71 bool blksz_datactrl16; 73 bool blksz_datactrl16;
72 u32 pwrreg_powerup; 74 u32 pwrreg_powerup;
73 bool signal_direction; 75 bool signal_direction;
76 bool pwrreg_clkgate;
74}; 77};
75 78
76static struct variant_data variant_arm = { 79static struct variant_data variant_arm = {
@@ -87,6 +90,14 @@ static struct variant_data variant_arm_extended_fifo = {
87 .pwrreg_powerup = MCI_PWR_UP, 90 .pwrreg_powerup = MCI_PWR_UP,
88}; 91};
89 92
93static struct variant_data variant_arm_extended_fifo_hwfc = {
94 .fifosize = 128 * 4,
95 .fifohalfsize = 64 * 4,
96 .clkreg_enable = MCI_ARM_HWFCEN,
97 .datalength_bits = 16,
98 .pwrreg_powerup = MCI_PWR_UP,
99};
100
90static struct variant_data variant_u300 = { 101static struct variant_data variant_u300 = {
91 .fifosize = 16 * 4, 102 .fifosize = 16 * 4,
92 .fifohalfsize = 8 * 4, 103 .fifohalfsize = 8 * 4,
@@ -95,6 +106,7 @@ static struct variant_data variant_u300 = {
95 .sdio = true, 106 .sdio = true,
96 .pwrreg_powerup = MCI_PWR_ON, 107 .pwrreg_powerup = MCI_PWR_ON,
97 .signal_direction = true, 108 .signal_direction = true,
109 .pwrreg_clkgate = true,
98}; 110};
99 111
100static struct variant_data variant_nomadik = { 112static struct variant_data variant_nomadik = {
@@ -106,6 +118,7 @@ static struct variant_data variant_nomadik = {
106 .st_clkdiv = true, 118 .st_clkdiv = true,
107 .pwrreg_powerup = MCI_PWR_ON, 119 .pwrreg_powerup = MCI_PWR_ON,
108 .signal_direction = true, 120 .signal_direction = true,
121 .pwrreg_clkgate = true,
109}; 122};
110 123
111static struct variant_data variant_ux500 = { 124static struct variant_data variant_ux500 = {
@@ -118,6 +131,7 @@ static struct variant_data variant_ux500 = {
118 .st_clkdiv = true, 131 .st_clkdiv = true,
119 .pwrreg_powerup = MCI_PWR_ON, 132 .pwrreg_powerup = MCI_PWR_ON,
120 .signal_direction = true, 133 .signal_direction = true,
134 .pwrreg_clkgate = true,
121}; 135};
122 136
123static struct variant_data variant_ux500v2 = { 137static struct variant_data variant_ux500v2 = {
@@ -131,9 +145,28 @@ static struct variant_data variant_ux500v2 = {
131 .blksz_datactrl16 = true, 145 .blksz_datactrl16 = true,
132 .pwrreg_powerup = MCI_PWR_ON, 146 .pwrreg_powerup = MCI_PWR_ON,
133 .signal_direction = true, 147 .signal_direction = true,
148 .pwrreg_clkgate = true,
134}; 149};
135 150
136/* 151/*
152 * Validate mmc prerequisites
153 */
154static int mmci_validate_data(struct mmci_host *host,
155 struct mmc_data *data)
156{
157 if (!data)
158 return 0;
159
160 if (!is_power_of_2(data->blksz)) {
161 dev_err(mmc_dev(host->mmc),
162 "unsupported block size (%d bytes)\n", data->blksz);
163 return -EINVAL;
164 }
165
166 return 0;
167}
168
169/*
137 * This must be called with host->lock held 170 * This must be called with host->lock held
138 */ 171 */
139static void mmci_write_clkreg(struct mmci_host *host, u32 clk) 172static void mmci_write_clkreg(struct mmci_host *host, u32 clk)
@@ -202,6 +235,9 @@ static void mmci_set_clkreg(struct mmci_host *host, unsigned int desired)
202 if (host->mmc->ios.bus_width == MMC_BUS_WIDTH_8) 235 if (host->mmc->ios.bus_width == MMC_BUS_WIDTH_8)
203 clk |= MCI_ST_8BIT_BUS; 236 clk |= MCI_ST_8BIT_BUS;
204 237
238 if (host->mmc->ios.timing == MMC_TIMING_UHS_DDR50)
239 clk |= MCI_ST_UX500_NEG_EDGE;
240
205 mmci_write_clkreg(host, clk); 241 mmci_write_clkreg(host, clk);
206} 242}
207 243
@@ -352,10 +388,33 @@ static inline void mmci_dma_release(struct mmci_host *host)
352 host->dma_rx_channel = host->dma_tx_channel = NULL; 388 host->dma_rx_channel = host->dma_tx_channel = NULL;
353} 389}
354 390
391static void mmci_dma_data_error(struct mmci_host *host)
392{
393 dev_err(mmc_dev(host->mmc), "error during DMA transfer!\n");
394 dmaengine_terminate_all(host->dma_current);
395 host->dma_current = NULL;
396 host->dma_desc_current = NULL;
397 host->data->host_cookie = 0;
398}
399
355static void mmci_dma_unmap(struct mmci_host *host, struct mmc_data *data) 400static void mmci_dma_unmap(struct mmci_host *host, struct mmc_data *data)
356{ 401{
357 struct dma_chan *chan = host->dma_current; 402 struct dma_chan *chan;
358 enum dma_data_direction dir; 403 enum dma_data_direction dir;
404
405 if (data->flags & MMC_DATA_READ) {
406 dir = DMA_FROM_DEVICE;
407 chan = host->dma_rx_channel;
408 } else {
409 dir = DMA_TO_DEVICE;
410 chan = host->dma_tx_channel;
411 }
412
413 dma_unmap_sg(chan->device->dev, data->sg, data->sg_len, dir);
414}
415
416static void mmci_dma_finalize(struct mmci_host *host, struct mmc_data *data)
417{
359 u32 status; 418 u32 status;
360 int i; 419 int i;
361 420
@@ -374,19 +433,13 @@ static void mmci_dma_unmap(struct mmci_host *host, struct mmc_data *data)
374 * contiguous buffers. On TX, we'll get a FIFO underrun error. 433 * contiguous buffers. On TX, we'll get a FIFO underrun error.
375 */ 434 */
376 if (status & MCI_RXDATAAVLBLMASK) { 435 if (status & MCI_RXDATAAVLBLMASK) {
377 dmaengine_terminate_all(chan); 436 mmci_dma_data_error(host);
378 if (!data->error) 437 if (!data->error)
379 data->error = -EIO; 438 data->error = -EIO;
380 } 439 }
381 440
382 if (data->flags & MMC_DATA_WRITE) {
383 dir = DMA_TO_DEVICE;
384 } else {
385 dir = DMA_FROM_DEVICE;
386 }
387
388 if (!data->host_cookie) 441 if (!data->host_cookie)
389 dma_unmap_sg(chan->device->dev, data->sg, data->sg_len, dir); 442 mmci_dma_unmap(host, data);
390 443
391 /* 444 /*
392 * Use of DMA with scatter-gather is impossible. 445 * Use of DMA with scatter-gather is impossible.
@@ -396,16 +449,15 @@ static void mmci_dma_unmap(struct mmci_host *host, struct mmc_data *data)
396 dev_err(mmc_dev(host->mmc), "buggy DMA detected. Taking evasive action.\n"); 449 dev_err(mmc_dev(host->mmc), "buggy DMA detected. Taking evasive action.\n");
397 mmci_dma_release(host); 450 mmci_dma_release(host);
398 } 451 }
399}
400 452
401static void mmci_dma_data_error(struct mmci_host *host) 453 host->dma_current = NULL;
402{ 454 host->dma_desc_current = NULL;
403 dev_err(mmc_dev(host->mmc), "error during DMA transfer!\n");
404 dmaengine_terminate_all(host->dma_current);
405} 455}
406 456
407static int mmci_dma_prep_data(struct mmci_host *host, struct mmc_data *data, 457/* prepares DMA channel and DMA descriptor, returns non-zero on failure */
408 struct mmci_host_next *next) 458static int __mmci_dma_prep_data(struct mmci_host *host, struct mmc_data *data,
459 struct dma_chan **dma_chan,
460 struct dma_async_tx_descriptor **dma_desc)
409{ 461{
410 struct variant_data *variant = host->variant; 462 struct variant_data *variant = host->variant;
411 struct dma_slave_config conf = { 463 struct dma_slave_config conf = {
@@ -423,16 +475,6 @@ static int mmci_dma_prep_data(struct mmci_host *host, struct mmc_data *data,
423 enum dma_data_direction buffer_dirn; 475 enum dma_data_direction buffer_dirn;
424 int nr_sg; 476 int nr_sg;
425 477
426 /* Check if next job is already prepared */
427 if (data->host_cookie && !next &&
428 host->dma_current && host->dma_desc_current)
429 return 0;
430
431 if (!next) {
432 host->dma_current = NULL;
433 host->dma_desc_current = NULL;
434 }
435
436 if (data->flags & MMC_DATA_READ) { 478 if (data->flags & MMC_DATA_READ) {
437 conf.direction = DMA_DEV_TO_MEM; 479 conf.direction = DMA_DEV_TO_MEM;
438 buffer_dirn = DMA_FROM_DEVICE; 480 buffer_dirn = DMA_FROM_DEVICE;
@@ -462,29 +504,41 @@ static int mmci_dma_prep_data(struct mmci_host *host, struct mmc_data *data,
462 if (!desc) 504 if (!desc)
463 goto unmap_exit; 505 goto unmap_exit;
464 506
465 if (next) { 507 *dma_chan = chan;
466 next->dma_chan = chan; 508 *dma_desc = desc;
467 next->dma_desc = desc;
468 } else {
469 host->dma_current = chan;
470 host->dma_desc_current = desc;
471 }
472 509
473 return 0; 510 return 0;
474 511
475 unmap_exit: 512 unmap_exit:
476 if (!next)
477 dmaengine_terminate_all(chan);
478 dma_unmap_sg(device->dev, data->sg, data->sg_len, buffer_dirn); 513 dma_unmap_sg(device->dev, data->sg, data->sg_len, buffer_dirn);
479 return -ENOMEM; 514 return -ENOMEM;
480} 515}
481 516
517static inline int mmci_dma_prep_data(struct mmci_host *host,
518 struct mmc_data *data)
519{
520 /* Check if next job is already prepared. */
521 if (host->dma_current && host->dma_desc_current)
522 return 0;
523
524 /* No job were prepared thus do it now. */
525 return __mmci_dma_prep_data(host, data, &host->dma_current,
526 &host->dma_desc_current);
527}
528
529static inline int mmci_dma_prep_next(struct mmci_host *host,
530 struct mmc_data *data)
531{
532 struct mmci_host_next *nd = &host->next_data;
533 return __mmci_dma_prep_data(host, data, &nd->dma_chan, &nd->dma_desc);
534}
535
482static int mmci_dma_start_data(struct mmci_host *host, unsigned int datactrl) 536static int mmci_dma_start_data(struct mmci_host *host, unsigned int datactrl)
483{ 537{
484 int ret; 538 int ret;
485 struct mmc_data *data = host->data; 539 struct mmc_data *data = host->data;
486 540
487 ret = mmci_dma_prep_data(host, host->data, NULL); 541 ret = mmci_dma_prep_data(host, host->data);
488 if (ret) 542 if (ret)
489 return ret; 543 return ret;
490 544
@@ -514,19 +568,11 @@ static void mmci_get_next_data(struct mmci_host *host, struct mmc_data *data)
514{ 568{
515 struct mmci_host_next *next = &host->next_data; 569 struct mmci_host_next *next = &host->next_data;
516 570
517 if (data->host_cookie && data->host_cookie != next->cookie) { 571 WARN_ON(data->host_cookie && data->host_cookie != next->cookie);
518 pr_warning("[%s] invalid cookie: data->host_cookie %d" 572 WARN_ON(!data->host_cookie && (next->dma_desc || next->dma_chan));
519 " host->next_data.cookie %d\n",
520 __func__, data->host_cookie, host->next_data.cookie);
521 data->host_cookie = 0;
522 }
523
524 if (!data->host_cookie)
525 return;
526 573
527 host->dma_desc_current = next->dma_desc; 574 host->dma_desc_current = next->dma_desc;
528 host->dma_current = next->dma_chan; 575 host->dma_current = next->dma_chan;
529
530 next->dma_desc = NULL; 576 next->dma_desc = NULL;
531 next->dma_chan = NULL; 577 next->dma_chan = NULL;
532} 578}
@@ -541,19 +587,13 @@ static void mmci_pre_request(struct mmc_host *mmc, struct mmc_request *mrq,
541 if (!data) 587 if (!data)
542 return; 588 return;
543 589
544 if (data->host_cookie) { 590 BUG_ON(data->host_cookie);
545 data->host_cookie = 0; 591
592 if (mmci_validate_data(host, data))
546 return; 593 return;
547 }
548 594
549 /* if config for dma */ 595 if (!mmci_dma_prep_next(host, data))
550 if (((data->flags & MMC_DATA_WRITE) && host->dma_tx_channel) || 596 data->host_cookie = ++nd->cookie < 0 ? 1 : nd->cookie;
551 ((data->flags & MMC_DATA_READ) && host->dma_rx_channel)) {
552 if (mmci_dma_prep_data(host, data, nd))
553 data->host_cookie = 0;
554 else
555 data->host_cookie = ++nd->cookie < 0 ? 1 : nd->cookie;
556 }
557} 597}
558 598
559static void mmci_post_request(struct mmc_host *mmc, struct mmc_request *mrq, 599static void mmci_post_request(struct mmc_host *mmc, struct mmc_request *mrq,
@@ -561,29 +601,23 @@ static void mmci_post_request(struct mmc_host *mmc, struct mmc_request *mrq,
561{ 601{
562 struct mmci_host *host = mmc_priv(mmc); 602 struct mmci_host *host = mmc_priv(mmc);
563 struct mmc_data *data = mrq->data; 603 struct mmc_data *data = mrq->data;
564 struct dma_chan *chan;
565 enum dma_data_direction dir;
566 604
567 if (!data) 605 if (!data || !data->host_cookie)
568 return; 606 return;
569 607
570 if (data->flags & MMC_DATA_READ) { 608 mmci_dma_unmap(host, data);
571 dir = DMA_FROM_DEVICE;
572 chan = host->dma_rx_channel;
573 } else {
574 dir = DMA_TO_DEVICE;
575 chan = host->dma_tx_channel;
576 }
577 609
610 if (err) {
611 struct mmci_host_next *next = &host->next_data;
612 struct dma_chan *chan;
613 if (data->flags & MMC_DATA_READ)
614 chan = host->dma_rx_channel;
615 else
616 chan = host->dma_tx_channel;
617 dmaengine_terminate_all(chan);
578 618
579 /* if config for dma */ 619 next->dma_desc = NULL;
580 if (chan) { 620 next->dma_chan = NULL;
581 if (err)
582 dmaengine_terminate_all(chan);
583 if (data->host_cookie)
584 dma_unmap_sg(mmc_dev(host->mmc), data->sg,
585 data->sg_len, dir);
586 mrq->data->host_cookie = 0;
587 } 621 }
588} 622}
589 623
@@ -604,6 +638,11 @@ static inline void mmci_dma_unmap(struct mmci_host *host, struct mmc_data *data)
604{ 638{
605} 639}
606 640
641static inline void mmci_dma_finalize(struct mmci_host *host,
642 struct mmc_data *data)
643{
644}
645
607static inline void mmci_dma_data_error(struct mmci_host *host) 646static inline void mmci_dma_data_error(struct mmci_host *host)
608{ 647{
609} 648}
@@ -680,6 +719,9 @@ static void mmci_start_data(struct mmci_host *host, struct mmc_data *data)
680 mmci_write_clkreg(host, clk); 719 mmci_write_clkreg(host, clk);
681 } 720 }
682 721
722 if (host->mmc->ios.timing == MMC_TIMING_UHS_DDR50)
723 datactrl |= MCI_ST_DPSM_DDRMODE;
724
683 /* 725 /*
684 * Attempt to use DMA operation mode, if this 726 * Attempt to use DMA operation mode, if this
685 * should fail, fall back to PIO mode 727 * should fail, fall back to PIO mode
@@ -751,8 +793,10 @@ mmci_data_irq(struct mmci_host *host, struct mmc_data *data,
751 u32 remain, success; 793 u32 remain, success;
752 794
753 /* Terminate the DMA transfer */ 795 /* Terminate the DMA transfer */
754 if (dma_inprogress(host)) 796 if (dma_inprogress(host)) {
755 mmci_dma_data_error(host); 797 mmci_dma_data_error(host);
798 mmci_dma_unmap(host, data);
799 }
756 800
757 /* 801 /*
758 * Calculate how far we are into the transfer. Note that 802 * Calculate how far we are into the transfer. Note that
@@ -791,7 +835,7 @@ mmci_data_irq(struct mmci_host *host, struct mmc_data *data,
791 835
792 if (status & MCI_DATAEND || data->error) { 836 if (status & MCI_DATAEND || data->error) {
793 if (dma_inprogress(host)) 837 if (dma_inprogress(host))
794 mmci_dma_unmap(host, data); 838 mmci_dma_finalize(host, data);
795 mmci_stop_data(host); 839 mmci_stop_data(host);
796 840
797 if (!data->error) 841 if (!data->error)
@@ -828,8 +872,10 @@ mmci_cmd_irq(struct mmci_host *host, struct mmc_command *cmd,
828 if (!cmd->data || cmd->error) { 872 if (!cmd->data || cmd->error) {
829 if (host->data) { 873 if (host->data) {
830 /* Terminate the DMA transfer */ 874 /* Terminate the DMA transfer */
831 if (dma_inprogress(host)) 875 if (dma_inprogress(host)) {
832 mmci_dma_data_error(host); 876 mmci_dma_data_error(host);
877 mmci_dma_unmap(host, host->data);
878 }
833 mmci_stop_data(host); 879 mmci_stop_data(host);
834 } 880 }
835 mmci_request_end(host, cmd->mrq); 881 mmci_request_end(host, cmd->mrq);
@@ -1055,10 +1101,8 @@ static void mmci_request(struct mmc_host *mmc, struct mmc_request *mrq)
1055 1101
1056 WARN_ON(host->mrq != NULL); 1102 WARN_ON(host->mrq != NULL);
1057 1103
1058 if (mrq->data && !is_power_of_2(mrq->data->blksz)) { 1104 mrq->cmd->error = mmci_validate_data(host, mrq->data);
1059 dev_err(mmc_dev(mmc), "unsupported block size (%d bytes)\n", 1105 if (mrq->cmd->error) {
1060 mrq->data->blksz);
1061 mrq->cmd->error = -EINVAL;
1062 mmc_request_done(mmc, mrq); 1106 mmc_request_done(mmc, mrq);
1063 return; 1107 return;
1064 } 1108 }
@@ -1086,7 +1130,6 @@ static void mmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
1086 struct variant_data *variant = host->variant; 1130 struct variant_data *variant = host->variant;
1087 u32 pwr = 0; 1131 u32 pwr = 0;
1088 unsigned long flags; 1132 unsigned long flags;
1089 int ret;
1090 1133
1091 pm_runtime_get_sync(mmc_dev(mmc)); 1134 pm_runtime_get_sync(mmc_dev(mmc));
1092 1135
@@ -1096,23 +1139,13 @@ static void mmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
1096 1139
1097 switch (ios->power_mode) { 1140 switch (ios->power_mode) {
1098 case MMC_POWER_OFF: 1141 case MMC_POWER_OFF:
1099 if (host->vcc) 1142 if (!IS_ERR(mmc->supply.vmmc))
1100 ret = mmc_regulator_set_ocr(mmc, host->vcc, 0); 1143 mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, 0);
1101 break; 1144 break;
1102 case MMC_POWER_UP: 1145 case MMC_POWER_UP:
1103 if (host->vcc) { 1146 if (!IS_ERR(mmc->supply.vmmc))
1104 ret = mmc_regulator_set_ocr(mmc, host->vcc, ios->vdd); 1147 mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, ios->vdd);
1105 if (ret) { 1148
1106 dev_err(mmc_dev(mmc), "unable to set OCR\n");
1107 /*
1108 * The .set_ios() function in the mmc_host_ops
1109 * struct return void, and failing to set the
1110 * power should be rare so we print an error
1111 * and return here.
1112 */
1113 goto out;
1114 }
1115 }
1116 /* 1149 /*
1117 * The ST Micro variant doesn't have the PL180s MCI_PWR_UP 1150 * The ST Micro variant doesn't have the PL180s MCI_PWR_UP
1118 * and instead uses MCI_PWR_ON so apply whatever value is 1151 * and instead uses MCI_PWR_ON so apply whatever value is
@@ -1154,6 +1187,13 @@ static void mmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
1154 } 1187 }
1155 } 1188 }
1156 1189
1190 /*
1191 * If clock = 0 and the variant requires the MMCIPOWER to be used for
1192 * gating the clock, the MCI_PWR_ON bit is cleared.
1193 */
1194 if (!ios->clock && variant->pwrreg_clkgate)
1195 pwr &= ~MCI_PWR_ON;
1196
1157 spin_lock_irqsave(&host->lock, flags); 1197 spin_lock_irqsave(&host->lock, flags);
1158 1198
1159 mmci_set_clkreg(host, ios->clock); 1199 mmci_set_clkreg(host, ios->clock);
@@ -1161,7 +1201,6 @@ static void mmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
1161 1201
1162 spin_unlock_irqrestore(&host->lock, flags); 1202 spin_unlock_irqrestore(&host->lock, flags);
1163 1203
1164 out:
1165 pm_runtime_mark_last_busy(mmc_dev(mmc)); 1204 pm_runtime_mark_last_busy(mmc_dev(mmc));
1166 pm_runtime_put_autosuspend(mmc_dev(mmc)); 1205 pm_runtime_put_autosuspend(mmc_dev(mmc));
1167} 1206}
@@ -1384,32 +1423,19 @@ static int mmci_probe(struct amba_device *dev,
1384 } else 1423 } else
1385 dev_warn(&dev->dev, "could not get default pinstate\n"); 1424 dev_warn(&dev->dev, "could not get default pinstate\n");
1386 1425
1387#ifdef CONFIG_REGULATOR 1426 /* Get regulators and the supported OCR mask */
1388 /* If we're using the regulator framework, try to fetch a regulator */ 1427 mmc_regulator_get_supply(mmc);
1389 host->vcc = regulator_get(&dev->dev, "vmmc"); 1428 if (!mmc->ocr_avail)
1390 if (IS_ERR(host->vcc))
1391 host->vcc = NULL;
1392 else {
1393 int mask = mmc_regulator_get_ocrmask(host->vcc);
1394
1395 if (mask < 0)
1396 dev_err(&dev->dev, "error getting OCR mask (%d)\n",
1397 mask);
1398 else {
1399 host->mmc->ocr_avail = (u32) mask;
1400 if (plat->ocr_mask)
1401 dev_warn(&dev->dev,
1402 "Provided ocr_mask/setpower will not be used "
1403 "(using regulator instead)\n");
1404 }
1405 }
1406#endif
1407 /* Fall back to platform data if no regulator is found */
1408 if (host->vcc == NULL)
1409 mmc->ocr_avail = plat->ocr_mask; 1429 mmc->ocr_avail = plat->ocr_mask;
1430 else if (plat->ocr_mask)
1431 dev_warn(mmc_dev(mmc), "Platform OCR mask is ignored\n");
1432
1410 mmc->caps = plat->capabilities; 1433 mmc->caps = plat->capabilities;
1411 mmc->caps2 = plat->capabilities2; 1434 mmc->caps2 = plat->capabilities2;
1412 1435
1436 /* We support these PM capabilities. */
1437 mmc->pm_caps = MMC_PM_KEEP_POWER;
1438
1413 /* 1439 /*
1414 * We can do SGIO 1440 * We can do SGIO
1415 */ 1441 */
@@ -1585,10 +1611,6 @@ static int mmci_remove(struct amba_device *dev)
1585 clk_disable_unprepare(host->clk); 1611 clk_disable_unprepare(host->clk);
1586 clk_put(host->clk); 1612 clk_put(host->clk);
1587 1613
1588 if (host->vcc)
1589 mmc_regulator_set_ocr(mmc, host->vcc, 0);
1590 regulator_put(host->vcc);
1591
1592 mmc_free_host(mmc); 1614 mmc_free_host(mmc);
1593 1615
1594 amba_release_regions(dev); 1616 amba_release_regions(dev);
@@ -1636,8 +1658,37 @@ static int mmci_resume(struct device *dev)
1636} 1658}
1637#endif 1659#endif
1638 1660
1661#ifdef CONFIG_PM_RUNTIME
1662static int mmci_runtime_suspend(struct device *dev)
1663{
1664 struct amba_device *adev = to_amba_device(dev);
1665 struct mmc_host *mmc = amba_get_drvdata(adev);
1666
1667 if (mmc) {
1668 struct mmci_host *host = mmc_priv(mmc);
1669 clk_disable_unprepare(host->clk);
1670 }
1671
1672 return 0;
1673}
1674
1675static int mmci_runtime_resume(struct device *dev)
1676{
1677 struct amba_device *adev = to_amba_device(dev);
1678 struct mmc_host *mmc = amba_get_drvdata(adev);
1679
1680 if (mmc) {
1681 struct mmci_host *host = mmc_priv(mmc);
1682 clk_prepare_enable(host->clk);
1683 }
1684
1685 return 0;
1686}
1687#endif
1688
1639static const struct dev_pm_ops mmci_dev_pm_ops = { 1689static const struct dev_pm_ops mmci_dev_pm_ops = {
1640 SET_SYSTEM_SLEEP_PM_OPS(mmci_suspend, mmci_resume) 1690 SET_SYSTEM_SLEEP_PM_OPS(mmci_suspend, mmci_resume)
1691 SET_RUNTIME_PM_OPS(mmci_runtime_suspend, mmci_runtime_resume, NULL)
1641}; 1692};
1642 1693
1643static struct amba_id mmci_ids[] = { 1694static struct amba_id mmci_ids[] = {
@@ -1652,6 +1703,11 @@ static struct amba_id mmci_ids[] = {
1652 .data = &variant_arm_extended_fifo, 1703 .data = &variant_arm_extended_fifo,
1653 }, 1704 },
1654 { 1705 {
1706 .id = 0x02041180,
1707 .mask = 0xff0fffff,
1708 .data = &variant_arm_extended_fifo_hwfc,
1709 },
1710 {
1655 .id = 0x00041181, 1711 .id = 0x00041181,
1656 .mask = 0x000fffff, 1712 .mask = 0x000fffff,
1657 .data = &variant_arm, 1713 .data = &variant_arm,
diff --git a/drivers/mmc/host/mmci.h b/drivers/mmc/host/mmci.h
index d34d8c0add8e..1f33ad5333a0 100644
--- a/drivers/mmc/host/mmci.h
+++ b/drivers/mmc/host/mmci.h
@@ -28,6 +28,8 @@
28#define MCI_ST_UX500_NEG_EDGE (1 << 13) 28#define MCI_ST_UX500_NEG_EDGE (1 << 13)
29#define MCI_ST_UX500_HWFCEN (1 << 14) 29#define MCI_ST_UX500_HWFCEN (1 << 14)
30#define MCI_ST_UX500_CLK_INV (1 << 15) 30#define MCI_ST_UX500_CLK_INV (1 << 15)
31/* Modified PL180 on Versatile Express platform */
32#define MCI_ARM_HWFCEN (1 << 12)
31 33
32#define MMCIARGUMENT 0x008 34#define MMCIARGUMENT 0x008
33#define MMCICOMMAND 0x00c 35#define MMCICOMMAND 0x00c
@@ -193,7 +195,6 @@ struct mmci_host {
193 /* pio stuff */ 195 /* pio stuff */
194 struct sg_mapping_iter sg_miter; 196 struct sg_mapping_iter sg_miter;
195 unsigned int size; 197 unsigned int size;
196 struct regulator *vcc;
197 198
198 /* pinctrl handles */ 199 /* pinctrl handles */
199 struct pinctrl *pinctrl; 200 struct pinctrl *pinctrl;