diff options
Diffstat (limited to 'drivers/mmc')
-rw-r--r-- | drivers/mmc/card/mmc_test.c | 9 | ||||
-rw-r--r-- | drivers/mmc/card/queue.c | 10 | ||||
-rw-r--r-- | drivers/mmc/card/sdio_uart.c | 93 | ||||
-rw-r--r-- | drivers/mmc/core/core.c | 12 | ||||
-rw-r--r-- | drivers/mmc/core/sdio.c | 64 | ||||
-rw-r--r-- | drivers/mmc/core/sdio_io.c | 56 | ||||
-rw-r--r-- | drivers/mmc/host/Kconfig | 15 | ||||
-rw-r--r-- | drivers/mmc/host/Makefile | 1 | ||||
-rw-r--r-- | drivers/mmc/host/at91_mci.c | 224 | ||||
-rw-r--r-- | drivers/mmc/host/au1xmmc.c | 12 | ||||
-rw-r--r-- | drivers/mmc/host/bfin_sdh.c | 10 | ||||
-rw-r--r-- | drivers/mmc/host/davinci_mmc.c | 45 | ||||
-rw-r--r-- | drivers/mmc/host/mmci.c | 41 | ||||
-rw-r--r-- | drivers/mmc/host/omap_hsmmc.c | 400 | ||||
-rw-r--r-- | drivers/mmc/host/ricoh_mmc.c | 262 | ||||
-rw-r--r-- | drivers/mmc/host/s3cmci.c | 4 | ||||
-rw-r--r-- | drivers/mmc/host/sdhci-pci.c | 24 | ||||
-rw-r--r-- | drivers/mmc/host/sdhci.c | 76 | ||||
-rw-r--r-- | drivers/mmc/host/tmio_mmc.c | 13 | ||||
-rw-r--r-- | drivers/mmc/host/tmio_mmc.h | 6 |
20 files changed, 788 insertions, 589 deletions
diff --git a/drivers/mmc/card/mmc_test.c b/drivers/mmc/card/mmc_test.c index b9f1e84897cc..e7f8027165e6 100644 --- a/drivers/mmc/card/mmc_test.c +++ b/drivers/mmc/card/mmc_test.c | |||
@@ -74,6 +74,9 @@ static void mmc_test_prepare_mrq(struct mmc_test_card *test, | |||
74 | } | 74 | } |
75 | 75 | ||
76 | mrq->cmd->arg = dev_addr; | 76 | mrq->cmd->arg = dev_addr; |
77 | if (!mmc_card_blockaddr(test->card)) | ||
78 | mrq->cmd->arg <<= 9; | ||
79 | |||
77 | mrq->cmd->flags = MMC_RSP_R1 | MMC_CMD_ADTC; | 80 | mrq->cmd->flags = MMC_RSP_R1 | MMC_CMD_ADTC; |
78 | 81 | ||
79 | if (blocks == 1) | 82 | if (blocks == 1) |
@@ -190,7 +193,7 @@ static int __mmc_test_prepare(struct mmc_test_card *test, int write) | |||
190 | } | 193 | } |
191 | 194 | ||
192 | for (i = 0;i < BUFFER_SIZE / 512;i++) { | 195 | for (i = 0;i < BUFFER_SIZE / 512;i++) { |
193 | ret = mmc_test_buffer_transfer(test, test->buffer, i * 512, 512, 1); | 196 | ret = mmc_test_buffer_transfer(test, test->buffer, i, 512, 1); |
194 | if (ret) | 197 | if (ret) |
195 | return ret; | 198 | return ret; |
196 | } | 199 | } |
@@ -219,7 +222,7 @@ static int mmc_test_cleanup(struct mmc_test_card *test) | |||
219 | memset(test->buffer, 0, 512); | 222 | memset(test->buffer, 0, 512); |
220 | 223 | ||
221 | for (i = 0;i < BUFFER_SIZE / 512;i++) { | 224 | for (i = 0;i < BUFFER_SIZE / 512;i++) { |
222 | ret = mmc_test_buffer_transfer(test, test->buffer, i * 512, 512, 1); | 225 | ret = mmc_test_buffer_transfer(test, test->buffer, i, 512, 1); |
223 | if (ret) | 226 | if (ret) |
224 | return ret; | 227 | return ret; |
225 | } | 228 | } |
@@ -426,7 +429,7 @@ static int mmc_test_transfer(struct mmc_test_card *test, | |||
426 | for (i = 0;i < sectors;i++) { | 429 | for (i = 0;i < sectors;i++) { |
427 | ret = mmc_test_buffer_transfer(test, | 430 | ret = mmc_test_buffer_transfer(test, |
428 | test->buffer + i * 512, | 431 | test->buffer + i * 512, |
429 | dev_addr + i * 512, 512, 0); | 432 | dev_addr + i, 512, 0); |
430 | if (ret) | 433 | if (ret) |
431 | return ret; | 434 | return ret; |
432 | } | 435 | } |
diff --git a/drivers/mmc/card/queue.c b/drivers/mmc/card/queue.c index c5a7a855f4b1..381fe032caa1 100644 --- a/drivers/mmc/card/queue.c +++ b/drivers/mmc/card/queue.c | |||
@@ -154,9 +154,8 @@ int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card, spinlock_t *lock | |||
154 | 154 | ||
155 | if (mq->bounce_buf) { | 155 | if (mq->bounce_buf) { |
156 | blk_queue_bounce_limit(mq->queue, BLK_BOUNCE_ANY); | 156 | blk_queue_bounce_limit(mq->queue, BLK_BOUNCE_ANY); |
157 | blk_queue_max_sectors(mq->queue, bouncesz / 512); | 157 | blk_queue_max_hw_sectors(mq->queue, bouncesz / 512); |
158 | blk_queue_max_phys_segments(mq->queue, bouncesz / 512); | 158 | blk_queue_max_segments(mq->queue, bouncesz / 512); |
159 | blk_queue_max_hw_segments(mq->queue, bouncesz / 512); | ||
160 | blk_queue_max_segment_size(mq->queue, bouncesz); | 159 | blk_queue_max_segment_size(mq->queue, bouncesz); |
161 | 160 | ||
162 | mq->sg = kmalloc(sizeof(struct scatterlist), | 161 | mq->sg = kmalloc(sizeof(struct scatterlist), |
@@ -180,10 +179,9 @@ int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card, spinlock_t *lock | |||
180 | 179 | ||
181 | if (!mq->bounce_buf) { | 180 | if (!mq->bounce_buf) { |
182 | blk_queue_bounce_limit(mq->queue, limit); | 181 | blk_queue_bounce_limit(mq->queue, limit); |
183 | blk_queue_max_sectors(mq->queue, | 182 | blk_queue_max_hw_sectors(mq->queue, |
184 | min(host->max_blk_count, host->max_req_size / 512)); | 183 | min(host->max_blk_count, host->max_req_size / 512)); |
185 | blk_queue_max_phys_segments(mq->queue, host->max_phys_segs); | 184 | blk_queue_max_segments(mq->queue, host->max_hw_segs); |
186 | blk_queue_max_hw_segments(mq->queue, host->max_hw_segs); | ||
187 | blk_queue_max_segment_size(mq->queue, host->max_seg_size); | 185 | blk_queue_max_segment_size(mq->queue, host->max_seg_size); |
188 | 186 | ||
189 | mq->sg = kmalloc(sizeof(struct scatterlist) * | 187 | mq->sg = kmalloc(sizeof(struct scatterlist) * |
diff --git a/drivers/mmc/card/sdio_uart.c b/drivers/mmc/card/sdio_uart.c index a4e37758be41..723e50894db9 100644 --- a/drivers/mmc/card/sdio_uart.c +++ b/drivers/mmc/card/sdio_uart.c | |||
@@ -37,6 +37,7 @@ | |||
37 | #include <linux/gfp.h> | 37 | #include <linux/gfp.h> |
38 | #include <linux/tty.h> | 38 | #include <linux/tty.h> |
39 | #include <linux/tty_flip.h> | 39 | #include <linux/tty_flip.h> |
40 | #include <linux/kfifo.h> | ||
40 | 41 | ||
41 | #include <linux/mmc/core.h> | 42 | #include <linux/mmc/core.h> |
42 | #include <linux/mmc/card.h> | 43 | #include <linux/mmc/card.h> |
@@ -47,19 +48,9 @@ | |||
47 | #define UART_NR 8 /* Number of UARTs this driver can handle */ | 48 | #define UART_NR 8 /* Number of UARTs this driver can handle */ |
48 | 49 | ||
49 | 50 | ||
50 | #define UART_XMIT_SIZE PAGE_SIZE | 51 | #define FIFO_SIZE PAGE_SIZE |
51 | #define WAKEUP_CHARS 256 | 52 | #define WAKEUP_CHARS 256 |
52 | 53 | ||
53 | #define circ_empty(circ) ((circ)->head == (circ)->tail) | ||
54 | #define circ_clear(circ) ((circ)->head = (circ)->tail = 0) | ||
55 | |||
56 | #define circ_chars_pending(circ) \ | ||
57 | (CIRC_CNT((circ)->head, (circ)->tail, UART_XMIT_SIZE)) | ||
58 | |||
59 | #define circ_chars_free(circ) \ | ||
60 | (CIRC_SPACE((circ)->head, (circ)->tail, UART_XMIT_SIZE)) | ||
61 | |||
62 | |||
63 | struct uart_icount { | 54 | struct uart_icount { |
64 | __u32 cts; | 55 | __u32 cts; |
65 | __u32 dsr; | 56 | __u32 dsr; |
@@ -82,7 +73,7 @@ struct sdio_uart_port { | |||
82 | struct mutex func_lock; | 73 | struct mutex func_lock; |
83 | struct task_struct *in_sdio_uart_irq; | 74 | struct task_struct *in_sdio_uart_irq; |
84 | unsigned int regs_offset; | 75 | unsigned int regs_offset; |
85 | struct circ_buf xmit; | 76 | struct kfifo xmit_fifo; |
86 | spinlock_t write_lock; | 77 | spinlock_t write_lock; |
87 | struct uart_icount icount; | 78 | struct uart_icount icount; |
88 | unsigned int uartclk; | 79 | unsigned int uartclk; |
@@ -105,6 +96,8 @@ static int sdio_uart_add_port(struct sdio_uart_port *port) | |||
105 | kref_init(&port->kref); | 96 | kref_init(&port->kref); |
106 | mutex_init(&port->func_lock); | 97 | mutex_init(&port->func_lock); |
107 | spin_lock_init(&port->write_lock); | 98 | spin_lock_init(&port->write_lock); |
99 | if (kfifo_alloc(&port->xmit_fifo, FIFO_SIZE, GFP_KERNEL)) | ||
100 | return -ENOMEM; | ||
108 | 101 | ||
109 | spin_lock(&sdio_uart_table_lock); | 102 | spin_lock(&sdio_uart_table_lock); |
110 | for (index = 0; index < UART_NR; index++) { | 103 | for (index = 0; index < UART_NR; index++) { |
@@ -140,6 +133,7 @@ static void sdio_uart_port_destroy(struct kref *kref) | |||
140 | { | 133 | { |
141 | struct sdio_uart_port *port = | 134 | struct sdio_uart_port *port = |
142 | container_of(kref, struct sdio_uart_port, kref); | 135 | container_of(kref, struct sdio_uart_port, kref); |
136 | kfifo_free(&port->xmit_fifo); | ||
143 | kfree(port); | 137 | kfree(port); |
144 | } | 138 | } |
145 | 139 | ||
@@ -456,9 +450,11 @@ static void sdio_uart_receive_chars(struct sdio_uart_port *port, | |||
456 | 450 | ||
457 | static void sdio_uart_transmit_chars(struct sdio_uart_port *port) | 451 | static void sdio_uart_transmit_chars(struct sdio_uart_port *port) |
458 | { | 452 | { |
459 | struct circ_buf *xmit = &port->xmit; | 453 | struct kfifo *xmit = &port->xmit_fifo; |
460 | int count; | 454 | int count; |
461 | struct tty_struct *tty; | 455 | struct tty_struct *tty; |
456 | u8 iobuf[16]; | ||
457 | int len; | ||
462 | 458 | ||
463 | if (port->x_char) { | 459 | if (port->x_char) { |
464 | sdio_out(port, UART_TX, port->x_char); | 460 | sdio_out(port, UART_TX, port->x_char); |
@@ -469,27 +465,25 @@ static void sdio_uart_transmit_chars(struct sdio_uart_port *port) | |||
469 | 465 | ||
470 | tty = tty_port_tty_get(&port->port); | 466 | tty = tty_port_tty_get(&port->port); |
471 | 467 | ||
472 | if (tty == NULL || circ_empty(xmit) || | 468 | if (tty == NULL || !kfifo_len(xmit) || |
473 | tty->stopped || tty->hw_stopped) { | 469 | tty->stopped || tty->hw_stopped) { |
474 | sdio_uart_stop_tx(port); | 470 | sdio_uart_stop_tx(port); |
475 | tty_kref_put(tty); | 471 | tty_kref_put(tty); |
476 | return; | 472 | return; |
477 | } | 473 | } |
478 | 474 | ||
479 | count = 16; | 475 | len = kfifo_out_locked(xmit, iobuf, 16, &port->write_lock); |
480 | do { | 476 | for (count = 0; count < len; count++) { |
481 | sdio_out(port, UART_TX, xmit->buf[xmit->tail]); | 477 | sdio_out(port, UART_TX, iobuf[count]); |
482 | xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1); | ||
483 | port->icount.tx++; | 478 | port->icount.tx++; |
484 | if (circ_empty(xmit)) | 479 | } |
485 | break; | ||
486 | } while (--count > 0); | ||
487 | 480 | ||
488 | if (circ_chars_pending(xmit) < WAKEUP_CHARS) | 481 | len = kfifo_len(xmit); |
482 | if (len < WAKEUP_CHARS) { | ||
489 | tty_wakeup(tty); | 483 | tty_wakeup(tty); |
490 | 484 | if (len == 0) | |
491 | if (circ_empty(xmit)) | 485 | sdio_uart_stop_tx(port); |
492 | sdio_uart_stop_tx(port); | 486 | } |
493 | tty_kref_put(tty); | 487 | tty_kref_put(tty); |
494 | } | 488 | } |
495 | 489 | ||
@@ -632,7 +626,6 @@ static int sdio_uart_activate(struct tty_port *tport, struct tty_struct *tty) | |||
632 | { | 626 | { |
633 | struct sdio_uart_port *port = | 627 | struct sdio_uart_port *port = |
634 | container_of(tport, struct sdio_uart_port, port); | 628 | container_of(tport, struct sdio_uart_port, port); |
635 | unsigned long page; | ||
636 | int ret; | 629 | int ret; |
637 | 630 | ||
638 | /* | 631 | /* |
@@ -641,22 +634,17 @@ static int sdio_uart_activate(struct tty_port *tport, struct tty_struct *tty) | |||
641 | */ | 634 | */ |
642 | set_bit(TTY_IO_ERROR, &tty->flags); | 635 | set_bit(TTY_IO_ERROR, &tty->flags); |
643 | 636 | ||
644 | /* Initialise and allocate the transmit buffer. */ | 637 | kfifo_reset(&port->xmit_fifo); |
645 | page = __get_free_page(GFP_KERNEL); | ||
646 | if (!page) | ||
647 | return -ENOMEM; | ||
648 | port->xmit.buf = (unsigned char *)page; | ||
649 | circ_clear(&port->xmit); | ||
650 | 638 | ||
651 | ret = sdio_uart_claim_func(port); | 639 | ret = sdio_uart_claim_func(port); |
652 | if (ret) | 640 | if (ret) |
653 | goto err1; | 641 | return ret; |
654 | ret = sdio_enable_func(port->func); | 642 | ret = sdio_enable_func(port->func); |
655 | if (ret) | 643 | if (ret) |
656 | goto err2; | 644 | goto err1; |
657 | ret = sdio_claim_irq(port->func, sdio_uart_irq); | 645 | ret = sdio_claim_irq(port->func, sdio_uart_irq); |
658 | if (ret) | 646 | if (ret) |
659 | goto err3; | 647 | goto err2; |
660 | 648 | ||
661 | /* | 649 | /* |
662 | * Clear the FIFO buffers and disable them. | 650 | * Clear the FIFO buffers and disable them. |
@@ -700,12 +688,10 @@ static int sdio_uart_activate(struct tty_port *tport, struct tty_struct *tty) | |||
700 | sdio_uart_release_func(port); | 688 | sdio_uart_release_func(port); |
701 | return 0; | 689 | return 0; |
702 | 690 | ||
703 | err3: | ||
704 | sdio_disable_func(port->func); | ||
705 | err2: | 691 | err2: |
706 | sdio_uart_release_func(port); | 692 | sdio_disable_func(port->func); |
707 | err1: | 693 | err1: |
708 | free_page((unsigned long)port->xmit.buf); | 694 | sdio_uart_release_func(port); |
709 | return ret; | 695 | return ret; |
710 | } | 696 | } |
711 | 697 | ||
@@ -727,7 +713,7 @@ static void sdio_uart_shutdown(struct tty_port *tport) | |||
727 | 713 | ||
728 | ret = sdio_uart_claim_func(port); | 714 | ret = sdio_uart_claim_func(port); |
729 | if (ret) | 715 | if (ret) |
730 | goto skip; | 716 | return; |
731 | 717 | ||
732 | sdio_uart_stop_rx(port); | 718 | sdio_uart_stop_rx(port); |
733 | 719 | ||
@@ -749,10 +735,6 @@ static void sdio_uart_shutdown(struct tty_port *tport) | |||
749 | sdio_disable_func(port->func); | 735 | sdio_disable_func(port->func); |
750 | 736 | ||
751 | sdio_uart_release_func(port); | 737 | sdio_uart_release_func(port); |
752 | |||
753 | skip: | ||
754 | /* Free the transmit buffer page. */ | ||
755 | free_page((unsigned long)port->xmit.buf); | ||
756 | } | 738 | } |
757 | 739 | ||
758 | /** | 740 | /** |
@@ -822,27 +804,12 @@ static int sdio_uart_write(struct tty_struct *tty, const unsigned char *buf, | |||
822 | int count) | 804 | int count) |
823 | { | 805 | { |
824 | struct sdio_uart_port *port = tty->driver_data; | 806 | struct sdio_uart_port *port = tty->driver_data; |
825 | struct circ_buf *circ = &port->xmit; | 807 | int ret; |
826 | int c, ret = 0; | ||
827 | 808 | ||
828 | if (!port->func) | 809 | if (!port->func) |
829 | return -ENODEV; | 810 | return -ENODEV; |
830 | 811 | ||
831 | spin_lock(&port->write_lock); | 812 | ret = kfifo_in_locked(&port->xmit_fifo, buf, count, &port->write_lock); |
832 | while (1) { | ||
833 | c = CIRC_SPACE_TO_END(circ->head, circ->tail, UART_XMIT_SIZE); | ||
834 | if (count < c) | ||
835 | c = count; | ||
836 | if (c <= 0) | ||
837 | break; | ||
838 | memcpy(circ->buf + circ->head, buf, c); | ||
839 | circ->head = (circ->head + c) & (UART_XMIT_SIZE - 1); | ||
840 | buf += c; | ||
841 | count -= c; | ||
842 | ret += c; | ||
843 | } | ||
844 | spin_unlock(&port->write_lock); | ||
845 | |||
846 | if (!(port->ier & UART_IER_THRI)) { | 813 | if (!(port->ier & UART_IER_THRI)) { |
847 | int err = sdio_uart_claim_func(port); | 814 | int err = sdio_uart_claim_func(port); |
848 | if (!err) { | 815 | if (!err) { |
@@ -859,13 +826,13 @@ static int sdio_uart_write(struct tty_struct *tty, const unsigned char *buf, | |||
859 | static int sdio_uart_write_room(struct tty_struct *tty) | 826 | static int sdio_uart_write_room(struct tty_struct *tty) |
860 | { | 827 | { |
861 | struct sdio_uart_port *port = tty->driver_data; | 828 | struct sdio_uart_port *port = tty->driver_data; |
862 | return port ? circ_chars_free(&port->xmit) : 0; | 829 | return FIFO_SIZE - kfifo_len(&port->xmit_fifo); |
863 | } | 830 | } |
864 | 831 | ||
865 | static int sdio_uart_chars_in_buffer(struct tty_struct *tty) | 832 | static int sdio_uart_chars_in_buffer(struct tty_struct *tty) |
866 | { | 833 | { |
867 | struct sdio_uart_port *port = tty->driver_data; | 834 | struct sdio_uart_port *port = tty->driver_data; |
868 | return port ? circ_chars_pending(&port->xmit) : 0; | 835 | return kfifo_len(&port->xmit_fifo); |
869 | } | 836 | } |
870 | 837 | ||
871 | static void sdio_uart_send_xchar(struct tty_struct *tty, char ch) | 838 | static void sdio_uart_send_xchar(struct tty_struct *tty, char ch) |
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 30acd5265821..f4b97d3c3d0f 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c | |||
@@ -1151,6 +1151,9 @@ void mmc_stop_host(struct mmc_host *host) | |||
1151 | cancel_delayed_work(&host->detect); | 1151 | cancel_delayed_work(&host->detect); |
1152 | mmc_flush_scheduled_work(); | 1152 | mmc_flush_scheduled_work(); |
1153 | 1153 | ||
1154 | /* clear pm flags now and let card drivers set them as needed */ | ||
1155 | host->pm_flags = 0; | ||
1156 | |||
1154 | mmc_bus_get(host); | 1157 | mmc_bus_get(host); |
1155 | if (host->bus_ops && !host->bus_dead) { | 1158 | if (host->bus_ops && !host->bus_dead) { |
1156 | if (host->bus_ops->remove) | 1159 | if (host->bus_ops->remove) |
@@ -1273,12 +1276,13 @@ int mmc_suspend_host(struct mmc_host *host, pm_message_t state) | |||
1273 | mmc_claim_host(host); | 1276 | mmc_claim_host(host); |
1274 | mmc_detach_bus(host); | 1277 | mmc_detach_bus(host); |
1275 | mmc_release_host(host); | 1278 | mmc_release_host(host); |
1279 | host->pm_flags = 0; | ||
1276 | err = 0; | 1280 | err = 0; |
1277 | } | 1281 | } |
1278 | } | 1282 | } |
1279 | mmc_bus_put(host); | 1283 | mmc_bus_put(host); |
1280 | 1284 | ||
1281 | if (!err) | 1285 | if (!err && !(host->pm_flags & MMC_PM_KEEP_POWER)) |
1282 | mmc_power_off(host); | 1286 | mmc_power_off(host); |
1283 | 1287 | ||
1284 | return err; | 1288 | return err; |
@@ -1296,8 +1300,10 @@ int mmc_resume_host(struct mmc_host *host) | |||
1296 | 1300 | ||
1297 | mmc_bus_get(host); | 1301 | mmc_bus_get(host); |
1298 | if (host->bus_ops && !host->bus_dead) { | 1302 | if (host->bus_ops && !host->bus_dead) { |
1299 | mmc_power_up(host); | 1303 | if (!(host->pm_flags & MMC_PM_KEEP_POWER)) { |
1300 | mmc_select_voltage(host, host->ocr); | 1304 | mmc_power_up(host); |
1305 | mmc_select_voltage(host, host->ocr); | ||
1306 | } | ||
1301 | BUG_ON(!host->bus_ops->resume); | 1307 | BUG_ON(!host->bus_ops->resume); |
1302 | err = host->bus_ops->resume(host); | 1308 | err = host->bus_ops->resume(host); |
1303 | if (err) { | 1309 | if (err) { |
diff --git a/drivers/mmc/core/sdio.c b/drivers/mmc/core/sdio.c index 06b64085a355..2dd4cfe7ca17 100644 --- a/drivers/mmc/core/sdio.c +++ b/drivers/mmc/core/sdio.c | |||
@@ -188,6 +188,40 @@ static int sdio_disable_cd(struct mmc_card *card) | |||
188 | } | 188 | } |
189 | 189 | ||
190 | /* | 190 | /* |
191 | * Devices that remain active during a system suspend are | ||
192 | * put back into 1-bit mode. | ||
193 | */ | ||
194 | static int sdio_disable_wide(struct mmc_card *card) | ||
195 | { | ||
196 | int ret; | ||
197 | u8 ctrl; | ||
198 | |||
199 | if (!(card->host->caps & MMC_CAP_4_BIT_DATA)) | ||
200 | return 0; | ||
201 | |||
202 | if (card->cccr.low_speed && !card->cccr.wide_bus) | ||
203 | return 0; | ||
204 | |||
205 | ret = mmc_io_rw_direct(card, 0, 0, SDIO_CCCR_IF, 0, &ctrl); | ||
206 | if (ret) | ||
207 | return ret; | ||
208 | |||
209 | if (!(ctrl & SDIO_BUS_WIDTH_4BIT)) | ||
210 | return 0; | ||
211 | |||
212 | ctrl &= ~SDIO_BUS_WIDTH_4BIT; | ||
213 | ctrl |= SDIO_BUS_ASYNC_INT; | ||
214 | |||
215 | ret = mmc_io_rw_direct(card, 1, 0, SDIO_CCCR_IF, ctrl, NULL); | ||
216 | if (ret) | ||
217 | return ret; | ||
218 | |||
219 | mmc_set_bus_width(card->host, MMC_BUS_WIDTH_1); | ||
220 | |||
221 | return 0; | ||
222 | } | ||
223 | |||
224 | /* | ||
191 | * Test if the card supports high-speed mode and, if so, switch to it. | 225 | * Test if the card supports high-speed mode and, if so, switch to it. |
192 | */ | 226 | */ |
193 | static int sdio_enable_hs(struct mmc_card *card) | 227 | static int sdio_enable_hs(struct mmc_card *card) |
@@ -224,7 +258,7 @@ static int sdio_enable_hs(struct mmc_card *card) | |||
224 | * we're trying to reinitialise. | 258 | * we're trying to reinitialise. |
225 | */ | 259 | */ |
226 | static int mmc_sdio_init_card(struct mmc_host *host, u32 ocr, | 260 | static int mmc_sdio_init_card(struct mmc_host *host, u32 ocr, |
227 | struct mmc_card *oldcard) | 261 | struct mmc_card *oldcard, int powered_resume) |
228 | { | 262 | { |
229 | struct mmc_card *card; | 263 | struct mmc_card *card; |
230 | int err; | 264 | int err; |
@@ -235,9 +269,11 @@ static int mmc_sdio_init_card(struct mmc_host *host, u32 ocr, | |||
235 | /* | 269 | /* |
236 | * Inform the card of the voltage | 270 | * Inform the card of the voltage |
237 | */ | 271 | */ |
238 | err = mmc_send_io_op_cond(host, host->ocr, &ocr); | 272 | if (!powered_resume) { |
239 | if (err) | 273 | err = mmc_send_io_op_cond(host, host->ocr, &ocr); |
240 | goto err; | 274 | if (err) |
275 | goto err; | ||
276 | } | ||
241 | 277 | ||
242 | /* | 278 | /* |
243 | * For SPI, enable CRC as appropriate. | 279 | * For SPI, enable CRC as appropriate. |
@@ -262,7 +298,7 @@ static int mmc_sdio_init_card(struct mmc_host *host, u32 ocr, | |||
262 | /* | 298 | /* |
263 | * For native busses: set card RCA and quit open drain mode. | 299 | * For native busses: set card RCA and quit open drain mode. |
264 | */ | 300 | */ |
265 | if (!mmc_host_is_spi(host)) { | 301 | if (!powered_resume && !mmc_host_is_spi(host)) { |
266 | err = mmc_send_relative_addr(host, &card->rca); | 302 | err = mmc_send_relative_addr(host, &card->rca); |
267 | if (err) | 303 | if (err) |
268 | goto remove; | 304 | goto remove; |
@@ -273,7 +309,7 @@ static int mmc_sdio_init_card(struct mmc_host *host, u32 ocr, | |||
273 | /* | 309 | /* |
274 | * Select card, as all following commands rely on that. | 310 | * Select card, as all following commands rely on that. |
275 | */ | 311 | */ |
276 | if (!mmc_host_is_spi(host)) { | 312 | if (!powered_resume && !mmc_host_is_spi(host)) { |
277 | err = mmc_select_card(card); | 313 | err = mmc_select_card(card); |
278 | if (err) | 314 | if (err) |
279 | goto remove; | 315 | goto remove; |
@@ -425,6 +461,12 @@ static int mmc_sdio_suspend(struct mmc_host *host) | |||
425 | } | 461 | } |
426 | } | 462 | } |
427 | 463 | ||
464 | if (!err && host->pm_flags & MMC_PM_KEEP_POWER) { | ||
465 | mmc_claim_host(host); | ||
466 | sdio_disable_wide(host->card); | ||
467 | mmc_release_host(host); | ||
468 | } | ||
469 | |||
428 | return err; | 470 | return err; |
429 | } | 471 | } |
430 | 472 | ||
@@ -437,7 +479,13 @@ static int mmc_sdio_resume(struct mmc_host *host) | |||
437 | 479 | ||
438 | /* Basic card reinitialization. */ | 480 | /* Basic card reinitialization. */ |
439 | mmc_claim_host(host); | 481 | mmc_claim_host(host); |
440 | err = mmc_sdio_init_card(host, host->ocr, host->card); | 482 | err = mmc_sdio_init_card(host, host->ocr, host->card, |
483 | (host->pm_flags & MMC_PM_KEEP_POWER)); | ||
484 | if (!err) | ||
485 | /* We may have switched to 1-bit mode during suspend. */ | ||
486 | err = sdio_enable_wide(host->card); | ||
487 | if (!err && host->sdio_irqs) | ||
488 | mmc_signal_sdio_irq(host); | ||
441 | mmc_release_host(host); | 489 | mmc_release_host(host); |
442 | 490 | ||
443 | /* | 491 | /* |
@@ -507,7 +555,7 @@ int mmc_attach_sdio(struct mmc_host *host, u32 ocr) | |||
507 | /* | 555 | /* |
508 | * Detect and init the card. | 556 | * Detect and init the card. |
509 | */ | 557 | */ |
510 | err = mmc_sdio_init_card(host, host->ocr, NULL); | 558 | err = mmc_sdio_init_card(host, host->ocr, NULL, 0); |
511 | if (err) | 559 | if (err) |
512 | goto err; | 560 | goto err; |
513 | card = host->card; | 561 | card = host->card; |
diff --git a/drivers/mmc/core/sdio_io.c b/drivers/mmc/core/sdio_io.c index f9aa8a7deffa..ff27c8c71355 100644 --- a/drivers/mmc/core/sdio_io.c +++ b/drivers/mmc/core/sdio_io.c | |||
@@ -189,7 +189,12 @@ static inline unsigned int sdio_max_byte_size(struct sdio_func *func) | |||
189 | { | 189 | { |
190 | unsigned mval = min(func->card->host->max_seg_size, | 190 | unsigned mval = min(func->card->host->max_seg_size, |
191 | func->card->host->max_blk_size); | 191 | func->card->host->max_blk_size); |
192 | mval = min(mval, func->max_blksize); | 192 | |
193 | if (mmc_blksz_for_byte_mode(func->card)) | ||
194 | mval = min(mval, func->cur_blksize); | ||
195 | else | ||
196 | mval = min(mval, func->max_blksize); | ||
197 | |||
193 | return min(mval, 512u); /* maximum size for byte mode */ | 198 | return min(mval, 512u); /* maximum size for byte mode */ |
194 | } | 199 | } |
195 | 200 | ||
@@ -635,3 +640,52 @@ void sdio_f0_writeb(struct sdio_func *func, unsigned char b, unsigned int addr, | |||
635 | *err_ret = ret; | 640 | *err_ret = ret; |
636 | } | 641 | } |
637 | EXPORT_SYMBOL_GPL(sdio_f0_writeb); | 642 | EXPORT_SYMBOL_GPL(sdio_f0_writeb); |
643 | |||
644 | /** | ||
645 | * sdio_get_host_pm_caps - get host power management capabilities | ||
646 | * @func: SDIO function attached to host | ||
647 | * | ||
648 | * Returns a capability bitmask corresponding to power management | ||
649 | * features supported by the host controller that the card function | ||
650 | * might rely upon during a system suspend. The host doesn't need | ||
651 | * to be claimed, nor the function active, for this information to be | ||
652 | * obtained. | ||
653 | */ | ||
654 | mmc_pm_flag_t sdio_get_host_pm_caps(struct sdio_func *func) | ||
655 | { | ||
656 | BUG_ON(!func); | ||
657 | BUG_ON(!func->card); | ||
658 | |||
659 | return func->card->host->pm_caps; | ||
660 | } | ||
661 | EXPORT_SYMBOL_GPL(sdio_get_host_pm_caps); | ||
662 | |||
663 | /** | ||
664 | * sdio_set_host_pm_flags - set wanted host power management capabilities | ||
665 | * @func: SDIO function attached to host | ||
666 | * | ||
667 | * Set a capability bitmask corresponding to wanted host controller | ||
668 | * power management features for the upcoming suspend state. | ||
669 | * This must be called, if needed, each time the suspend method of | ||
670 | * the function driver is called, and must contain only bits that | ||
671 | * were returned by sdio_get_host_pm_caps(). | ||
672 | * The host doesn't need to be claimed, nor the function active, | ||
673 | * for this information to be set. | ||
674 | */ | ||
675 | int sdio_set_host_pm_flags(struct sdio_func *func, mmc_pm_flag_t flags) | ||
676 | { | ||
677 | struct mmc_host *host; | ||
678 | |||
679 | BUG_ON(!func); | ||
680 | BUG_ON(!func->card); | ||
681 | |||
682 | host = func->card->host; | ||
683 | |||
684 | if (flags & ~host->pm_caps) | ||
685 | return -EINVAL; | ||
686 | |||
687 | /* function suspend methods are serialized, hence no lock needed */ | ||
688 | host->pm_flags |= flags; | ||
689 | return 0; | ||
690 | } | ||
691 | EXPORT_SYMBOL_GPL(sdio_set_host_pm_flags); | ||
diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig index ce1d28884e29..2e13b94769fd 100644 --- a/drivers/mmc/host/Kconfig +++ b/drivers/mmc/host/Kconfig | |||
@@ -69,20 +69,16 @@ config MMC_SDHCI_PCI | |||
69 | If unsure, say N. | 69 | If unsure, say N. |
70 | 70 | ||
71 | config MMC_RICOH_MMC | 71 | config MMC_RICOH_MMC |
72 | tristate "Ricoh MMC Controller Disabler (EXPERIMENTAL)" | 72 | bool "Ricoh MMC Controller Disabler (EXPERIMENTAL)" |
73 | depends on MMC_SDHCI_PCI | 73 | depends on MMC_SDHCI_PCI |
74 | help | 74 | help |
75 | This selects the disabler for the Ricoh MMC Controller. This | 75 | This adds a pci quirk to disable Ricoh MMC Controller. This |
76 | proprietary controller is unnecessary because the SDHCI driver | 76 | proprietary controller is unnecessary because the SDHCI driver |
77 | supports MMC cards on the SD controller, but if it is not | 77 | supports MMC cards on the SD controller, but if it is not |
78 | disabled, it will steal the MMC cards away - rendering them | 78 | disabled, it will steal the MMC cards away - rendering them |
79 | useless. It is safe to select this driver even if you don't | 79 | useless. It is safe to select this even if you don't |
80 | have a Ricoh based card reader. | 80 | have a Ricoh based card reader. |
81 | 81 | ||
82 | |||
83 | To compile this driver as a module, choose M here: | ||
84 | the module will be called ricoh_mmc. | ||
85 | |||
86 | If unsure, say Y. | 82 | If unsure, say Y. |
87 | 83 | ||
88 | config MMC_SDHCI_OF | 84 | config MMC_SDHCI_OF |
@@ -193,6 +189,7 @@ config MMC_AU1X | |||
193 | 189 | ||
194 | choice | 190 | choice |
195 | prompt "Atmel SD/MMC Driver" | 191 | prompt "Atmel SD/MMC Driver" |
192 | depends on AVR32 || ARCH_AT91 | ||
196 | default MMC_ATMELMCI if AVR32 | 193 | default MMC_ATMELMCI if AVR32 |
197 | help | 194 | help |
198 | Choose which driver to use for the Atmel MCI Silicon | 195 | Choose which driver to use for the Atmel MCI Silicon |
@@ -368,7 +365,7 @@ config MMC_SDRICOH_CS | |||
368 | 365 | ||
369 | config MMC_TMIO | 366 | config MMC_TMIO |
370 | tristate "Toshiba Mobile IO Controller (TMIO) MMC/SD function support" | 367 | tristate "Toshiba Mobile IO Controller (TMIO) MMC/SD function support" |
371 | depends on MFD_TMIO || MFD_ASIC3 || SUPERH | 368 | depends on MFD_TMIO || MFD_ASIC3 || MFD_SH_MOBILE_SDHI |
372 | help | 369 | help |
373 | This provides support for the SD/MMC cell found in TC6393XB, | 370 | This provides support for the SD/MMC cell found in TC6393XB, |
374 | T7L66XB and also HTC ASIC3 | 371 | T7L66XB and also HTC ASIC3 |
@@ -399,7 +396,7 @@ config MMC_VIA_SDMMC | |||
399 | 396 | ||
400 | config SDH_BFIN | 397 | config SDH_BFIN |
401 | tristate "Blackfin Secure Digital Host support" | 398 | tristate "Blackfin Secure Digital Host support" |
402 | depends on MMC && ((BF54x && !BF544) || (BF51x && !BF512)) | 399 | depends on (BF54x && !BF544) || (BF51x && !BF512) |
403 | help | 400 | help |
404 | If you say yes here you will get support for the Blackfin on-chip | 401 | If you say yes here you will get support for the Blackfin on-chip |
405 | Secure Digital Host interface. This includes support for MMC and | 402 | Secure Digital Host interface. This includes support for MMC and |
diff --git a/drivers/mmc/host/Makefile b/drivers/mmc/host/Makefile index 3d253dd4240f..f4803977dfce 100644 --- a/drivers/mmc/host/Makefile +++ b/drivers/mmc/host/Makefile | |||
@@ -12,7 +12,6 @@ obj-$(CONFIG_MMC_IMX) += imxmmc.o | |||
12 | obj-$(CONFIG_MMC_MXC) += mxcmmc.o | 12 | obj-$(CONFIG_MMC_MXC) += mxcmmc.o |
13 | obj-$(CONFIG_MMC_SDHCI) += sdhci.o | 13 | obj-$(CONFIG_MMC_SDHCI) += sdhci.o |
14 | obj-$(CONFIG_MMC_SDHCI_PCI) += sdhci-pci.o | 14 | obj-$(CONFIG_MMC_SDHCI_PCI) += sdhci-pci.o |
15 | obj-$(CONFIG_MMC_RICOH_MMC) += ricoh_mmc.o | ||
16 | obj-$(CONFIG_MMC_SDHCI_PLTFM) += sdhci-pltfm.o | 15 | obj-$(CONFIG_MMC_SDHCI_PLTFM) += sdhci-pltfm.o |
17 | obj-$(CONFIG_MMC_SDHCI_S3C) += sdhci-s3c.o | 16 | obj-$(CONFIG_MMC_SDHCI_S3C) += sdhci-s3c.o |
18 | obj-$(CONFIG_MMC_WBSD) += wbsd.o | 17 | obj-$(CONFIG_MMC_WBSD) += wbsd.o |
diff --git a/drivers/mmc/host/at91_mci.c b/drivers/mmc/host/at91_mci.c index 63924e0c7ea9..91dc60cd032b 100644 --- a/drivers/mmc/host/at91_mci.c +++ b/drivers/mmc/host/at91_mci.c | |||
@@ -78,6 +78,17 @@ | |||
78 | 78 | ||
79 | #define DRIVER_NAME "at91_mci" | 79 | #define DRIVER_NAME "at91_mci" |
80 | 80 | ||
81 | static inline int at91mci_is_mci1rev2xx(void) | ||
82 | { | ||
83 | return ( cpu_is_at91sam9260() | ||
84 | || cpu_is_at91sam9263() | ||
85 | || cpu_is_at91cap9() | ||
86 | || cpu_is_at91sam9rl() | ||
87 | || cpu_is_at91sam9g10() | ||
88 | || cpu_is_at91sam9g20() | ||
89 | ); | ||
90 | } | ||
91 | |||
81 | #define FL_SENT_COMMAND (1 << 0) | 92 | #define FL_SENT_COMMAND (1 << 0) |
82 | #define FL_SENT_STOP (1 << 1) | 93 | #define FL_SENT_STOP (1 << 1) |
83 | 94 | ||
@@ -88,6 +99,10 @@ | |||
88 | #define at91_mci_read(host, reg) __raw_readl((host)->baseaddr + (reg)) | 99 | #define at91_mci_read(host, reg) __raw_readl((host)->baseaddr + (reg)) |
89 | #define at91_mci_write(host, reg, val) __raw_writel((val), (host)->baseaddr + (reg)) | 100 | #define at91_mci_write(host, reg, val) __raw_writel((val), (host)->baseaddr + (reg)) |
90 | 101 | ||
102 | #define MCI_BLKSIZE 512 | ||
103 | #define MCI_MAXBLKSIZE 4095 | ||
104 | #define MCI_BLKATONCE 256 | ||
105 | #define MCI_BUFSIZE (MCI_BLKSIZE * MCI_BLKATONCE) | ||
91 | 106 | ||
92 | /* | 107 | /* |
93 | * Low level type for this driver | 108 | * Low level type for this driver |
@@ -200,8 +215,8 @@ static inline void at91_mci_sg_to_dma(struct at91mci_host *host, struct mmc_data | |||
200 | size = data->blksz * data->blocks; | 215 | size = data->blksz * data->blocks; |
201 | len = data->sg_len; | 216 | len = data->sg_len; |
202 | 217 | ||
203 | /* AT91SAM926[0/3] Data Write Operation and number of bytes erratum */ | 218 | /* MCI1 rev2xx Data Write Operation and number of bytes erratum */ |
204 | if (cpu_is_at91sam9260() || cpu_is_at91sam9263()) | 219 | if (at91mci_is_mci1rev2xx()) |
205 | if (host->total_length == 12) | 220 | if (host->total_length == 12) |
206 | memset(dmabuf, 0, 12); | 221 | memset(dmabuf, 0, 12); |
207 | 222 | ||
@@ -227,8 +242,10 @@ static inline void at91_mci_sg_to_dma(struct at91mci_host *host, struct mmc_data | |||
227 | for (index = 0; index < (amount / 4); index++) | 242 | for (index = 0; index < (amount / 4); index++) |
228 | *dmabuf++ = swab32(sgbuffer[index]); | 243 | *dmabuf++ = swab32(sgbuffer[index]); |
229 | } else { | 244 | } else { |
230 | memcpy(dmabuf, sgbuffer, amount); | 245 | char *tmpv = (char *)dmabuf; |
231 | dmabuf += amount; | 246 | memcpy(tmpv, sgbuffer, amount); |
247 | tmpv += amount; | ||
248 | dmabuf = (unsigned *)tmpv; | ||
232 | } | 249 | } |
233 | 250 | ||
234 | kunmap_atomic(sgbuffer, KM_BIO_SRC_IRQ); | 251 | kunmap_atomic(sgbuffer, KM_BIO_SRC_IRQ); |
@@ -245,80 +262,14 @@ static inline void at91_mci_sg_to_dma(struct at91mci_host *host, struct mmc_data | |||
245 | } | 262 | } |
246 | 263 | ||
247 | /* | 264 | /* |
248 | * Prepare a dma read | ||
249 | */ | ||
250 | static void at91_mci_pre_dma_read(struct at91mci_host *host) | ||
251 | { | ||
252 | int i; | ||
253 | struct scatterlist *sg; | ||
254 | struct mmc_command *cmd; | ||
255 | struct mmc_data *data; | ||
256 | |||
257 | pr_debug("pre dma read\n"); | ||
258 | |||
259 | cmd = host->cmd; | ||
260 | if (!cmd) { | ||
261 | pr_debug("no command\n"); | ||
262 | return; | ||
263 | } | ||
264 | |||
265 | data = cmd->data; | ||
266 | if (!data) { | ||
267 | pr_debug("no data\n"); | ||
268 | return; | ||
269 | } | ||
270 | |||
271 | for (i = 0; i < 2; i++) { | ||
272 | /* nothing left to transfer */ | ||
273 | if (host->transfer_index >= data->sg_len) { | ||
274 | pr_debug("Nothing left to transfer (index = %d)\n", host->transfer_index); | ||
275 | break; | ||
276 | } | ||
277 | |||
278 | /* Check to see if this needs filling */ | ||
279 | if (i == 0) { | ||
280 | if (at91_mci_read(host, ATMEL_PDC_RCR) != 0) { | ||
281 | pr_debug("Transfer active in current\n"); | ||
282 | continue; | ||
283 | } | ||
284 | } | ||
285 | else { | ||
286 | if (at91_mci_read(host, ATMEL_PDC_RNCR) != 0) { | ||
287 | pr_debug("Transfer active in next\n"); | ||
288 | continue; | ||
289 | } | ||
290 | } | ||
291 | |||
292 | /* Setup the next transfer */ | ||
293 | pr_debug("Using transfer index %d\n", host->transfer_index); | ||
294 | |||
295 | sg = &data->sg[host->transfer_index++]; | ||
296 | pr_debug("sg = %p\n", sg); | ||
297 | |||
298 | sg->dma_address = dma_map_page(NULL, sg_page(sg), sg->offset, sg->length, DMA_FROM_DEVICE); | ||
299 | |||
300 | pr_debug("dma address = %08X, length = %d\n", sg->dma_address, sg->length); | ||
301 | |||
302 | if (i == 0) { | ||
303 | at91_mci_write(host, ATMEL_PDC_RPR, sg->dma_address); | ||
304 | at91_mci_write(host, ATMEL_PDC_RCR, (data->blksz & 0x3) ? sg->length : sg->length / 4); | ||
305 | } | ||
306 | else { | ||
307 | at91_mci_write(host, ATMEL_PDC_RNPR, sg->dma_address); | ||
308 | at91_mci_write(host, ATMEL_PDC_RNCR, (data->blksz & 0x3) ? sg->length : sg->length / 4); | ||
309 | } | ||
310 | } | ||
311 | |||
312 | pr_debug("pre dma read done\n"); | ||
313 | } | ||
314 | |||
315 | /* | ||
316 | * Handle after a dma read | 265 | * Handle after a dma read |
317 | */ | 266 | */ |
318 | static void at91_mci_post_dma_read(struct at91mci_host *host) | 267 | static void at91_mci_post_dma_read(struct at91mci_host *host) |
319 | { | 268 | { |
320 | struct mmc_command *cmd; | 269 | struct mmc_command *cmd; |
321 | struct mmc_data *data; | 270 | struct mmc_data *data; |
271 | unsigned int len, i, size; | ||
272 | unsigned *dmabuf = host->buffer; | ||
322 | 273 | ||
323 | pr_debug("post dma read\n"); | 274 | pr_debug("post dma read\n"); |
324 | 275 | ||
@@ -334,42 +285,39 @@ static void at91_mci_post_dma_read(struct at91mci_host *host) | |||
334 | return; | 285 | return; |
335 | } | 286 | } |
336 | 287 | ||
337 | while (host->in_use_index < host->transfer_index) { | 288 | size = data->blksz * data->blocks; |
338 | struct scatterlist *sg; | 289 | len = data->sg_len; |
339 | 290 | ||
340 | pr_debug("finishing index %d\n", host->in_use_index); | 291 | at91_mci_write(host, AT91_MCI_IDR, AT91_MCI_ENDRX); |
292 | at91_mci_write(host, AT91_MCI_IER, AT91_MCI_RXBUFF); | ||
341 | 293 | ||
342 | sg = &data->sg[host->in_use_index++]; | 294 | for (i = 0; i < len; i++) { |
295 | struct scatterlist *sg; | ||
296 | int amount; | ||
297 | unsigned int *sgbuffer; | ||
343 | 298 | ||
344 | pr_debug("Unmapping page %08X\n", sg->dma_address); | 299 | sg = &data->sg[i]; |
345 | 300 | ||
346 | dma_unmap_page(NULL, sg->dma_address, sg->length, DMA_FROM_DEVICE); | 301 | sgbuffer = kmap_atomic(sg_page(sg), KM_BIO_SRC_IRQ) + sg->offset; |
302 | amount = min(size, sg->length); | ||
303 | size -= amount; | ||
347 | 304 | ||
348 | if (cpu_is_at91rm9200()) { /* AT91RM9200 errata */ | 305 | if (cpu_is_at91rm9200()) { /* AT91RM9200 errata */ |
349 | unsigned int *buffer; | ||
350 | int index; | 306 | int index; |
351 | 307 | for (index = 0; index < (amount / 4); index++) | |
352 | /* Swap the contents of the buffer */ | 308 | sgbuffer[index] = swab32(*dmabuf++); |
353 | buffer = kmap_atomic(sg_page(sg), KM_BIO_SRC_IRQ) + sg->offset; | 309 | } else { |
354 | pr_debug("buffer = %p, length = %d\n", buffer, sg->length); | 310 | char *tmpv = (char *)dmabuf; |
355 | 311 | memcpy(sgbuffer, tmpv, amount); | |
356 | for (index = 0; index < (sg->length / 4); index++) | 312 | tmpv += amount; |
357 | buffer[index] = swab32(buffer[index]); | 313 | dmabuf = (unsigned *)tmpv; |
358 | |||
359 | kunmap_atomic(buffer, KM_BIO_SRC_IRQ); | ||
360 | } | 314 | } |
361 | 315 | ||
362 | flush_dcache_page(sg_page(sg)); | 316 | kunmap_atomic(sgbuffer, KM_BIO_SRC_IRQ); |
363 | 317 | dmac_flush_range((void *)sgbuffer, ((void *)sgbuffer) + amount); | |
364 | data->bytes_xfered += sg->length; | 318 | data->bytes_xfered += amount; |
365 | } | 319 | if (size == 0) |
366 | 320 | break; | |
367 | /* Is there another transfer to trigger? */ | ||
368 | if (host->transfer_index < data->sg_len) | ||
369 | at91_mci_pre_dma_read(host); | ||
370 | else { | ||
371 | at91_mci_write(host, AT91_MCI_IDR, AT91_MCI_ENDRX); | ||
372 | at91_mci_write(host, AT91_MCI_IER, AT91_MCI_RXBUFF); | ||
373 | } | 321 | } |
374 | 322 | ||
375 | pr_debug("post dma read done\n"); | 323 | pr_debug("post dma read done\n"); |
@@ -461,7 +409,7 @@ static void at91_mci_enable(struct at91mci_host *host) | |||
461 | at91_mci_write(host, AT91_MCI_DTOR, AT91_MCI_DTOMUL_1M | AT91_MCI_DTOCYC); | 409 | at91_mci_write(host, AT91_MCI_DTOR, AT91_MCI_DTOMUL_1M | AT91_MCI_DTOCYC); |
462 | mr = AT91_MCI_PDCMODE | 0x34a; | 410 | mr = AT91_MCI_PDCMODE | 0x34a; |
463 | 411 | ||
464 | if (cpu_is_at91sam9260() || cpu_is_at91sam9263()) | 412 | if (at91mci_is_mci1rev2xx()) |
465 | mr |= AT91_MCI_RDPROOF | AT91_MCI_WRPROOF; | 413 | mr |= AT91_MCI_RDPROOF | AT91_MCI_WRPROOF; |
466 | 414 | ||
467 | at91_mci_write(host, AT91_MCI_MR, mr); | 415 | at91_mci_write(host, AT91_MCI_MR, mr); |
@@ -602,10 +550,14 @@ static void at91_mci_send_command(struct at91mci_host *host, struct mmc_command | |||
602 | /* | 550 | /* |
603 | * Handle a read | 551 | * Handle a read |
604 | */ | 552 | */ |
605 | host->buffer = NULL; | ||
606 | host->total_length = 0; | 553 | host->total_length = 0; |
607 | 554 | ||
608 | at91_mci_pre_dma_read(host); | 555 | at91_mci_write(host, ATMEL_PDC_RPR, host->physical_address); |
556 | at91_mci_write(host, ATMEL_PDC_RCR, (data->blksz & 0x3) ? | ||
557 | (blocks * block_length) : (blocks * block_length) / 4); | ||
558 | at91_mci_write(host, ATMEL_PDC_RNPR, 0); | ||
559 | at91_mci_write(host, ATMEL_PDC_RNCR, 0); | ||
560 | |||
609 | ier = AT91_MCI_ENDRX /* | AT91_MCI_RXBUFF */; | 561 | ier = AT91_MCI_ENDRX /* | AT91_MCI_RXBUFF */; |
610 | } | 562 | } |
611 | else { | 563 | else { |
@@ -614,27 +566,15 @@ static void at91_mci_send_command(struct at91mci_host *host, struct mmc_command | |||
614 | */ | 566 | */ |
615 | host->total_length = block_length * blocks; | 567 | host->total_length = block_length * blocks; |
616 | /* | 568 | /* |
617 | * AT91SAM926[0/3] Data Write Operation and | 569 | * MCI1 rev2xx Data Write Operation and |
618 | * number of bytes erratum | 570 | * number of bytes erratum |
619 | */ | 571 | */ |
620 | if (cpu_is_at91sam9260 () || cpu_is_at91sam9263()) | 572 | if (at91mci_is_mci1rev2xx()) |
621 | if (host->total_length < 12) | 573 | if (host->total_length < 12) |
622 | host->total_length = 12; | 574 | host->total_length = 12; |
623 | 575 | ||
624 | host->buffer = kmalloc(host->total_length, GFP_KERNEL); | ||
625 | if (!host->buffer) { | ||
626 | pr_debug("Can't alloc tx buffer\n"); | ||
627 | cmd->error = -ENOMEM; | ||
628 | mmc_request_done(host->mmc, host->request); | ||
629 | return; | ||
630 | } | ||
631 | |||
632 | at91_mci_sg_to_dma(host, data); | 576 | at91_mci_sg_to_dma(host, data); |
633 | 577 | ||
634 | host->physical_address = dma_map_single(NULL, | ||
635 | host->buffer, host->total_length, | ||
636 | DMA_TO_DEVICE); | ||
637 | |||
638 | pr_debug("Transmitting %d bytes\n", host->total_length); | 578 | pr_debug("Transmitting %d bytes\n", host->total_length); |
639 | 579 | ||
640 | at91_mci_write(host, ATMEL_PDC_TPR, host->physical_address); | 580 | at91_mci_write(host, ATMEL_PDC_TPR, host->physical_address); |
@@ -701,14 +641,6 @@ static void at91_mci_completed_command(struct at91mci_host *host, unsigned int s | |||
701 | cmd->resp[2] = at91_mci_read(host, AT91_MCI_RSPR(2)); | 641 | cmd->resp[2] = at91_mci_read(host, AT91_MCI_RSPR(2)); |
702 | cmd->resp[3] = at91_mci_read(host, AT91_MCI_RSPR(3)); | 642 | cmd->resp[3] = at91_mci_read(host, AT91_MCI_RSPR(3)); |
703 | 643 | ||
704 | if (host->buffer) { | ||
705 | dma_unmap_single(NULL, | ||
706 | host->physical_address, host->total_length, | ||
707 | DMA_TO_DEVICE); | ||
708 | kfree(host->buffer); | ||
709 | host->buffer = NULL; | ||
710 | } | ||
711 | |||
712 | pr_debug("Status = %08X/%08x [%08X %08X %08X %08X]\n", | 644 | pr_debug("Status = %08X/%08x [%08X %08X %08X %08X]\n", |
713 | status, at91_mci_read(host, AT91_MCI_SR), | 645 | status, at91_mci_read(host, AT91_MCI_SR), |
714 | cmd->resp[0], cmd->resp[1], cmd->resp[2], cmd->resp[3]); | 646 | cmd->resp[0], cmd->resp[1], cmd->resp[2], cmd->resp[3]); |
@@ -754,7 +686,8 @@ static void at91_mci_request(struct mmc_host *mmc, struct mmc_request *mrq) | |||
754 | host->request = mrq; | 686 | host->request = mrq; |
755 | host->flags = 0; | 687 | host->flags = 0; |
756 | 688 | ||
757 | mod_timer(&host->timer, jiffies + HZ); | 689 | /* more than 1s timeout needed with slow SD cards */ |
690 | mod_timer(&host->timer, jiffies + msecs_to_jiffies(2000)); | ||
758 | 691 | ||
759 | at91_mci_process_next(host); | 692 | at91_mci_process_next(host); |
760 | } | 693 | } |
@@ -942,7 +875,8 @@ static irqreturn_t at91_mmc_det_irq(int irq, void *_host) | |||
942 | pr_debug("****** Resetting SD-card bus width ******\n"); | 875 | pr_debug("****** Resetting SD-card bus width ******\n"); |
943 | at91_mci_write(host, AT91_MCI_SDCR, at91_mci_read(host, AT91_MCI_SDCR) & ~AT91_MCI_SDCBUS); | 876 | at91_mci_write(host, AT91_MCI_SDCR, at91_mci_read(host, AT91_MCI_SDCR) & ~AT91_MCI_SDCBUS); |
944 | } | 877 | } |
945 | mmc_detect_change(host->mmc, msecs_to_jiffies(100)); | 878 | /* 0.5s needed because of early card detect switch firing */ |
879 | mmc_detect_change(host->mmc, msecs_to_jiffies(500)); | ||
946 | } | 880 | } |
947 | return IRQ_HANDLED; | 881 | return IRQ_HANDLED; |
948 | } | 882 | } |
@@ -1006,24 +940,42 @@ static int __init at91_mci_probe(struct platform_device *pdev) | |||
1006 | mmc->f_min = 375000; | 940 | mmc->f_min = 375000; |
1007 | mmc->f_max = 25000000; | 941 | mmc->f_max = 25000000; |
1008 | mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34; | 942 | mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34; |
1009 | mmc->caps = MMC_CAP_SDIO_IRQ; | 943 | mmc->caps = 0; |
1010 | 944 | ||
1011 | mmc->max_blk_size = 4095; | 945 | mmc->max_blk_size = MCI_MAXBLKSIZE; |
1012 | mmc->max_blk_count = mmc->max_req_size; | 946 | mmc->max_blk_count = MCI_BLKATONCE; |
947 | mmc->max_req_size = MCI_BUFSIZE; | ||
948 | mmc->max_phys_segs = MCI_BLKATONCE; | ||
949 | mmc->max_hw_segs = MCI_BLKATONCE; | ||
950 | mmc->max_seg_size = MCI_BUFSIZE; | ||
1013 | 951 | ||
1014 | host = mmc_priv(mmc); | 952 | host = mmc_priv(mmc); |
1015 | host->mmc = mmc; | 953 | host->mmc = mmc; |
1016 | host->buffer = NULL; | ||
1017 | host->bus_mode = 0; | 954 | host->bus_mode = 0; |
1018 | host->board = pdev->dev.platform_data; | 955 | host->board = pdev->dev.platform_data; |
1019 | if (host->board->wire4) { | 956 | if (host->board->wire4) { |
1020 | if (cpu_is_at91sam9260() || cpu_is_at91sam9263()) | 957 | if (at91mci_is_mci1rev2xx()) |
1021 | mmc->caps |= MMC_CAP_4_BIT_DATA; | 958 | mmc->caps |= MMC_CAP_4_BIT_DATA; |
1022 | else | 959 | else |
1023 | dev_warn(&pdev->dev, "4 wire bus mode not supported" | 960 | dev_warn(&pdev->dev, "4 wire bus mode not supported" |
1024 | " - using 1 wire\n"); | 961 | " - using 1 wire\n"); |
1025 | } | 962 | } |
1026 | 963 | ||
964 | host->buffer = dma_alloc_coherent(&pdev->dev, MCI_BUFSIZE, | ||
965 | &host->physical_address, GFP_KERNEL); | ||
966 | if (!host->buffer) { | ||
967 | ret = -ENOMEM; | ||
968 | dev_err(&pdev->dev, "Can't allocate transmit buffer\n"); | ||
969 | goto fail5; | ||
970 | } | ||
971 | |||
972 | /* Add SDIO capability when available */ | ||
973 | if (at91mci_is_mci1rev2xx()) { | ||
974 | /* at91mci MCI1 rev2xx sdio interrupt erratum */ | ||
975 | if (host->board->wire4 || !host->board->slot_b) | ||
976 | mmc->caps |= MMC_CAP_SDIO_IRQ; | ||
977 | } | ||
978 | |||
1027 | /* | 979 | /* |
1028 | * Reserve GPIOs ... board init code makes sure these pins are set | 980 | * Reserve GPIOs ... board init code makes sure these pins are set |
1029 | * up as GPIOs with the right direction (input, except for vcc) | 981 | * up as GPIOs with the right direction (input, except for vcc) |
@@ -1032,7 +984,7 @@ static int __init at91_mci_probe(struct platform_device *pdev) | |||
1032 | ret = gpio_request(host->board->det_pin, "mmc_detect"); | 984 | ret = gpio_request(host->board->det_pin, "mmc_detect"); |
1033 | if (ret < 0) { | 985 | if (ret < 0) { |
1034 | dev_dbg(&pdev->dev, "couldn't claim card detect pin\n"); | 986 | dev_dbg(&pdev->dev, "couldn't claim card detect pin\n"); |
1035 | goto fail5; | 987 | goto fail4b; |
1036 | } | 988 | } |
1037 | } | 989 | } |
1038 | if (host->board->wp_pin) { | 990 | if (host->board->wp_pin) { |
@@ -1132,6 +1084,10 @@ fail3: | |||
1132 | fail4: | 1084 | fail4: |
1133 | if (host->board->det_pin) | 1085 | if (host->board->det_pin) |
1134 | gpio_free(host->board->det_pin); | 1086 | gpio_free(host->board->det_pin); |
1087 | fail4b: | ||
1088 | if (host->buffer) | ||
1089 | dma_free_coherent(&pdev->dev, MCI_BUFSIZE, | ||
1090 | host->buffer, host->physical_address); | ||
1135 | fail5: | 1091 | fail5: |
1136 | mmc_free_host(mmc); | 1092 | mmc_free_host(mmc); |
1137 | fail6: | 1093 | fail6: |
@@ -1154,6 +1110,10 @@ static int __exit at91_mci_remove(struct platform_device *pdev) | |||
1154 | 1110 | ||
1155 | host = mmc_priv(mmc); | 1111 | host = mmc_priv(mmc); |
1156 | 1112 | ||
1113 | if (host->buffer) | ||
1114 | dma_free_coherent(&pdev->dev, MCI_BUFSIZE, | ||
1115 | host->buffer, host->physical_address); | ||
1116 | |||
1157 | if (host->board->det_pin) { | 1117 | if (host->board->det_pin) { |
1158 | if (device_can_wakeup(&pdev->dev)) | 1118 | if (device_can_wakeup(&pdev->dev)) |
1159 | free_irq(gpio_to_irq(host->board->det_pin), host); | 1119 | free_irq(gpio_to_irq(host->board->det_pin), host); |
diff --git a/drivers/mmc/host/au1xmmc.c b/drivers/mmc/host/au1xmmc.c index d3f55615c099..57b21198828f 100644 --- a/drivers/mmc/host/au1xmmc.c +++ b/drivers/mmc/host/au1xmmc.c | |||
@@ -650,11 +650,11 @@ static int au1xmmc_prepare_data(struct au1xmmc_host *host, | |||
650 | flags = DDMA_FLAGS_IE; | 650 | flags = DDMA_FLAGS_IE; |
651 | 651 | ||
652 | if (host->flags & HOST_F_XMIT) { | 652 | if (host->flags & HOST_F_XMIT) { |
653 | ret = au1xxx_dbdma_put_source_flags(channel, | 653 | ret = au1xxx_dbdma_put_source(channel, |
654 | (void *)sg_virt(sg), len, flags); | 654 | sg_phys(sg), len, flags); |
655 | } else { | 655 | } else { |
656 | ret = au1xxx_dbdma_put_dest_flags(channel, | 656 | ret = au1xxx_dbdma_put_dest(channel, |
657 | (void *)sg_virt(sg), len, flags); | 657 | sg_phys(sg), len, flags); |
658 | } | 658 | } |
659 | 659 | ||
660 | if (!ret) | 660 | if (!ret) |
@@ -1017,6 +1017,10 @@ static int __devinit au1xmmc_probe(struct platform_device *pdev) | |||
1017 | } else | 1017 | } else |
1018 | mmc->caps |= MMC_CAP_NEEDS_POLL; | 1018 | mmc->caps |= MMC_CAP_NEEDS_POLL; |
1019 | 1019 | ||
1020 | /* platform may not be able to use all advertised caps */ | ||
1021 | if (host->platdata) | ||
1022 | mmc->caps &= ~(host->platdata->mask_host_caps); | ||
1023 | |||
1020 | tasklet_init(&host->data_task, au1xmmc_tasklet_data, | 1024 | tasklet_init(&host->data_task, au1xmmc_tasklet_data, |
1021 | (unsigned long)host); | 1025 | (unsigned long)host); |
1022 | 1026 | ||
diff --git a/drivers/mmc/host/bfin_sdh.c b/drivers/mmc/host/bfin_sdh.c index 3343a57355cc..56f7b448b911 100644 --- a/drivers/mmc/host/bfin_sdh.c +++ b/drivers/mmc/host/bfin_sdh.c | |||
@@ -115,7 +115,7 @@ static int sdh_setup_data(struct sdh_host *host, struct mmc_data *data) | |||
115 | unsigned int length; | 115 | unsigned int length; |
116 | unsigned int data_ctl; | 116 | unsigned int data_ctl; |
117 | unsigned int dma_cfg; | 117 | unsigned int dma_cfg; |
118 | struct scatterlist *sg; | 118 | unsigned int cycle_ns, timeout; |
119 | 119 | ||
120 | dev_dbg(mmc_dev(host->mmc), "%s enter flags: 0x%x\n", __func__, data->flags); | 120 | dev_dbg(mmc_dev(host->mmc), "%s enter flags: 0x%x\n", __func__, data->flags); |
121 | host->data = data; | 121 | host->data = data; |
@@ -136,8 +136,11 @@ static int sdh_setup_data(struct sdh_host *host, struct mmc_data *data) | |||
136 | data_ctl |= ((ffs(data->blksz) - 1) << 4); | 136 | data_ctl |= ((ffs(data->blksz) - 1) << 4); |
137 | 137 | ||
138 | bfin_write_SDH_DATA_CTL(data_ctl); | 138 | bfin_write_SDH_DATA_CTL(data_ctl); |
139 | 139 | /* the time of a host clock period in ns */ | |
140 | bfin_write_SDH_DATA_TIMER(0xFFFF); | 140 | cycle_ns = 1000000000 / (get_sclk() / (2 * (host->clk_div + 1))); |
141 | timeout = data->timeout_ns / cycle_ns; | ||
142 | timeout += data->timeout_clks; | ||
143 | bfin_write_SDH_DATA_TIMER(timeout); | ||
141 | SSYNC(); | 144 | SSYNC(); |
142 | 145 | ||
143 | if (data->flags & MMC_DATA_READ) { | 146 | if (data->flags & MMC_DATA_READ) { |
@@ -151,6 +154,7 @@ static int sdh_setup_data(struct sdh_host *host, struct mmc_data *data) | |||
151 | #if defined(CONFIG_BF54x) | 154 | #if defined(CONFIG_BF54x) |
152 | dma_cfg |= DMAFLOW_ARRAY | NDSIZE_5 | RESTART | WDSIZE_32 | DMAEN; | 155 | dma_cfg |= DMAFLOW_ARRAY | NDSIZE_5 | RESTART | WDSIZE_32 | DMAEN; |
153 | { | 156 | { |
157 | struct scatterlist *sg; | ||
154 | int i; | 158 | int i; |
155 | for_each_sg(data->sg, sg, host->dma_len, i) { | 159 | for_each_sg(data->sg, sg, host->dma_len, i) { |
156 | host->sg_cpu[i].start_addr = sg_dma_address(sg); | 160 | host->sg_cpu[i].start_addr = sg_dma_address(sg); |
diff --git a/drivers/mmc/host/davinci_mmc.c b/drivers/mmc/host/davinci_mmc.c index dd45e7c3517e..3bd0ba294e9d 100644 --- a/drivers/mmc/host/davinci_mmc.c +++ b/drivers/mmc/host/davinci_mmc.c | |||
@@ -73,6 +73,7 @@ | |||
73 | /* DAVINCI_MMCCTL definitions */ | 73 | /* DAVINCI_MMCCTL definitions */ |
74 | #define MMCCTL_DATRST (1 << 0) | 74 | #define MMCCTL_DATRST (1 << 0) |
75 | #define MMCCTL_CMDRST (1 << 1) | 75 | #define MMCCTL_CMDRST (1 << 1) |
76 | #define MMCCTL_WIDTH_8_BIT (1 << 8) | ||
76 | #define MMCCTL_WIDTH_4_BIT (1 << 2) | 77 | #define MMCCTL_WIDTH_4_BIT (1 << 2) |
77 | #define MMCCTL_DATEG_DISABLED (0 << 6) | 78 | #define MMCCTL_DATEG_DISABLED (0 << 6) |
78 | #define MMCCTL_DATEG_RISING (1 << 6) | 79 | #define MMCCTL_DATEG_RISING (1 << 6) |
@@ -791,22 +792,42 @@ static void calculate_clk_divider(struct mmc_host *mmc, struct mmc_ios *ios) | |||
791 | 792 | ||
792 | static void mmc_davinci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) | 793 | static void mmc_davinci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) |
793 | { | 794 | { |
794 | unsigned int mmc_pclk = 0; | ||
795 | struct mmc_davinci_host *host = mmc_priv(mmc); | 795 | struct mmc_davinci_host *host = mmc_priv(mmc); |
796 | 796 | ||
797 | mmc_pclk = host->mmc_input_clk; | ||
798 | dev_dbg(mmc_dev(host->mmc), | 797 | dev_dbg(mmc_dev(host->mmc), |
799 | "clock %dHz busmode %d powermode %d Vdd %04x\n", | 798 | "clock %dHz busmode %d powermode %d Vdd %04x\n", |
800 | ios->clock, ios->bus_mode, ios->power_mode, | 799 | ios->clock, ios->bus_mode, ios->power_mode, |
801 | ios->vdd); | 800 | ios->vdd); |
802 | if (ios->bus_width == MMC_BUS_WIDTH_4) { | 801 | |
803 | dev_dbg(mmc_dev(host->mmc), "Enabling 4 bit mode\n"); | 802 | switch (ios->bus_width) { |
804 | writel(readl(host->base + DAVINCI_MMCCTL) | MMCCTL_WIDTH_4_BIT, | 803 | case MMC_BUS_WIDTH_8: |
805 | host->base + DAVINCI_MMCCTL); | 804 | dev_dbg(mmc_dev(host->mmc), "Enabling 8 bit mode\n"); |
806 | } else { | 805 | writel((readl(host->base + DAVINCI_MMCCTL) & |
807 | dev_dbg(mmc_dev(host->mmc), "Disabling 4 bit mode\n"); | 806 | ~MMCCTL_WIDTH_4_BIT) | MMCCTL_WIDTH_8_BIT, |
808 | writel(readl(host->base + DAVINCI_MMCCTL) & ~MMCCTL_WIDTH_4_BIT, | ||
809 | host->base + DAVINCI_MMCCTL); | 807 | host->base + DAVINCI_MMCCTL); |
808 | break; | ||
809 | case MMC_BUS_WIDTH_4: | ||
810 | dev_dbg(mmc_dev(host->mmc), "Enabling 4 bit mode\n"); | ||
811 | if (host->version == MMC_CTLR_VERSION_2) | ||
812 | writel((readl(host->base + DAVINCI_MMCCTL) & | ||
813 | ~MMCCTL_WIDTH_8_BIT) | MMCCTL_WIDTH_4_BIT, | ||
814 | host->base + DAVINCI_MMCCTL); | ||
815 | else | ||
816 | writel(readl(host->base + DAVINCI_MMCCTL) | | ||
817 | MMCCTL_WIDTH_4_BIT, | ||
818 | host->base + DAVINCI_MMCCTL); | ||
819 | break; | ||
820 | case MMC_BUS_WIDTH_1: | ||
821 | dev_dbg(mmc_dev(host->mmc), "Enabling 1 bit mode\n"); | ||
822 | if (host->version == MMC_CTLR_VERSION_2) | ||
823 | writel(readl(host->base + DAVINCI_MMCCTL) & | ||
824 | ~(MMCCTL_WIDTH_8_BIT | MMCCTL_WIDTH_4_BIT), | ||
825 | host->base + DAVINCI_MMCCTL); | ||
826 | else | ||
827 | writel(readl(host->base + DAVINCI_MMCCTL) & | ||
828 | ~MMCCTL_WIDTH_4_BIT, | ||
829 | host->base + DAVINCI_MMCCTL); | ||
830 | break; | ||
810 | } | 831 | } |
811 | 832 | ||
812 | calculate_clk_divider(mmc, ios); | 833 | calculate_clk_divider(mmc, ios); |
@@ -1189,10 +1210,14 @@ static int __init davinci_mmcsd_probe(struct platform_device *pdev) | |||
1189 | 1210 | ||
1190 | /* REVISIT: someday, support IRQ-driven card detection. */ | 1211 | /* REVISIT: someday, support IRQ-driven card detection. */ |
1191 | mmc->caps |= MMC_CAP_NEEDS_POLL; | 1212 | mmc->caps |= MMC_CAP_NEEDS_POLL; |
1213 | mmc->caps |= MMC_CAP_WAIT_WHILE_BUSY; | ||
1192 | 1214 | ||
1193 | if (!pdata || pdata->wires == 4 || pdata->wires == 0) | 1215 | if (pdata && (pdata->wires == 4 || pdata->wires == 0)) |
1194 | mmc->caps |= MMC_CAP_4_BIT_DATA; | 1216 | mmc->caps |= MMC_CAP_4_BIT_DATA; |
1195 | 1217 | ||
1218 | if (pdata && (pdata->wires == 8)) | ||
1219 | mmc->caps |= (MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA); | ||
1220 | |||
1196 | host->version = pdata->version; | 1221 | host->version = pdata->version; |
1197 | 1222 | ||
1198 | mmc->ops = &mmc_davinci_ops; | 1223 | mmc->ops = &mmc_davinci_ops; |
diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c index 90d168ad03b6..84c103a7ee13 100644 --- a/drivers/mmc/host/mmci.c +++ b/drivers/mmc/host/mmci.c | |||
@@ -2,6 +2,7 @@ | |||
2 | * linux/drivers/mmc/host/mmci.c - ARM PrimeCell MMCI PL180/1 driver | 2 | * linux/drivers/mmc/host/mmci.c - ARM PrimeCell MMCI PL180/1 driver |
3 | * | 3 | * |
4 | * Copyright (C) 2003 Deep Blue Solutions, Ltd, All Rights Reserved. | 4 | * Copyright (C) 2003 Deep Blue Solutions, Ltd, All Rights Reserved. |
5 | * Copyright (C) 2010 ST-Ericsson AB. | ||
5 | * | 6 | * |
6 | * This program is free software; you can redistribute it and/or modify | 7 | * This program is free software; you can redistribute it and/or modify |
7 | * it under the terms of the GNU General Public License version 2 as | 8 | * it under the terms of the GNU General Public License version 2 as |
@@ -34,9 +35,6 @@ | |||
34 | 35 | ||
35 | #define DRIVER_NAME "mmci-pl18x" | 36 | #define DRIVER_NAME "mmci-pl18x" |
36 | 37 | ||
37 | #define DBG(host,fmt,args...) \ | ||
38 | pr_debug("%s: %s: " fmt, mmc_hostname(host->mmc), __func__ , args) | ||
39 | |||
40 | static unsigned int fmax = 515633; | 38 | static unsigned int fmax = 515633; |
41 | 39 | ||
42 | /* | 40 | /* |
@@ -105,8 +103,8 @@ static void mmci_start_data(struct mmci_host *host, struct mmc_data *data) | |||
105 | void __iomem *base; | 103 | void __iomem *base; |
106 | int blksz_bits; | 104 | int blksz_bits; |
107 | 105 | ||
108 | DBG(host, "blksz %04x blks %04x flags %08x\n", | 106 | dev_dbg(mmc_dev(host->mmc), "blksz %04x blks %04x flags %08x\n", |
109 | data->blksz, data->blocks, data->flags); | 107 | data->blksz, data->blocks, data->flags); |
110 | 108 | ||
111 | host->data = data; | 109 | host->data = data; |
112 | host->size = data->blksz; | 110 | host->size = data->blksz; |
@@ -155,7 +153,7 @@ mmci_start_command(struct mmci_host *host, struct mmc_command *cmd, u32 c) | |||
155 | { | 153 | { |
156 | void __iomem *base = host->base; | 154 | void __iomem *base = host->base; |
157 | 155 | ||
158 | DBG(host, "op %02x arg %08x flags %08x\n", | 156 | dev_dbg(mmc_dev(host->mmc), "op %02x arg %08x flags %08x\n", |
159 | cmd->opcode, cmd->arg, cmd->flags); | 157 | cmd->opcode, cmd->arg, cmd->flags); |
160 | 158 | ||
161 | if (readl(base + MMCICOMMAND) & MCI_CPSM_ENABLE) { | 159 | if (readl(base + MMCICOMMAND) & MCI_CPSM_ENABLE) { |
@@ -184,8 +182,20 @@ mmci_data_irq(struct mmci_host *host, struct mmc_data *data, | |||
184 | { | 182 | { |
185 | if (status & MCI_DATABLOCKEND) { | 183 | if (status & MCI_DATABLOCKEND) { |
186 | host->data_xfered += data->blksz; | 184 | host->data_xfered += data->blksz; |
185 | #ifdef CONFIG_ARCH_U300 | ||
186 | /* | ||
187 | * On the U300 some signal or other is | ||
188 | * badly routed so that a data write does | ||
189 | * not properly terminate with a MCI_DATAEND | ||
190 | * status flag. This quirk will make writes | ||
191 | * work again. | ||
192 | */ | ||
193 | if (data->flags & MMC_DATA_WRITE) | ||
194 | status |= MCI_DATAEND; | ||
195 | #endif | ||
187 | } | 196 | } |
188 | if (status & (MCI_DATACRCFAIL|MCI_DATATIMEOUT|MCI_TXUNDERRUN|MCI_RXOVERRUN)) { | 197 | if (status & (MCI_DATACRCFAIL|MCI_DATATIMEOUT|MCI_TXUNDERRUN|MCI_RXOVERRUN)) { |
198 | dev_dbg(mmc_dev(host->mmc), "MCI ERROR IRQ (status %08x)\n", status); | ||
189 | if (status & MCI_DATACRCFAIL) | 199 | if (status & MCI_DATACRCFAIL) |
190 | data->error = -EILSEQ; | 200 | data->error = -EILSEQ; |
191 | else if (status & MCI_DATATIMEOUT) | 201 | else if (status & MCI_DATATIMEOUT) |
@@ -307,7 +317,7 @@ static irqreturn_t mmci_pio_irq(int irq, void *dev_id) | |||
307 | 317 | ||
308 | status = readl(base + MMCISTATUS); | 318 | status = readl(base + MMCISTATUS); |
309 | 319 | ||
310 | DBG(host, "irq1 %08x\n", status); | 320 | dev_dbg(mmc_dev(host->mmc), "irq1 (pio) %08x\n", status); |
311 | 321 | ||
312 | do { | 322 | do { |
313 | unsigned long flags; | 323 | unsigned long flags; |
@@ -401,7 +411,7 @@ static irqreturn_t mmci_irq(int irq, void *dev_id) | |||
401 | status &= readl(host->base + MMCIMASK0); | 411 | status &= readl(host->base + MMCIMASK0); |
402 | writel(status, host->base + MMCICLEAR); | 412 | writel(status, host->base + MMCICLEAR); |
403 | 413 | ||
404 | DBG(host, "irq0 %08x\n", status); | 414 | dev_dbg(mmc_dev(host->mmc), "irq0 (data+cmd) %08x\n", status); |
405 | 415 | ||
406 | data = host->data; | 416 | data = host->data; |
407 | if (status & (MCI_DATACRCFAIL|MCI_DATATIMEOUT|MCI_TXUNDERRUN| | 417 | if (status & (MCI_DATACRCFAIL|MCI_DATATIMEOUT|MCI_TXUNDERRUN| |
@@ -428,8 +438,8 @@ static void mmci_request(struct mmc_host *mmc, struct mmc_request *mrq) | |||
428 | WARN_ON(host->mrq != NULL); | 438 | WARN_ON(host->mrq != NULL); |
429 | 439 | ||
430 | if (mrq->data && !is_power_of_2(mrq->data->blksz)) { | 440 | if (mrq->data && !is_power_of_2(mrq->data->blksz)) { |
431 | printk(KERN_ERR "%s: Unsupported block size (%d bytes)\n", | 441 | dev_err(mmc_dev(mmc), "unsupported block size (%d bytes)\n", |
432 | mmc_hostname(mmc), mrq->data->blksz); | 442 | mrq->data->blksz); |
433 | mrq->cmd->error = -EINVAL; | 443 | mrq->cmd->error = -EINVAL; |
434 | mmc_request_done(mmc, mrq); | 444 | mmc_request_done(mmc, mrq); |
435 | return; | 445 | return; |
@@ -582,8 +592,8 @@ static int __devinit mmci_probe(struct amba_device *dev, struct amba_id *id) | |||
582 | 592 | ||
583 | host->hw_designer = amba_manf(dev); | 593 | host->hw_designer = amba_manf(dev); |
584 | host->hw_revision = amba_rev(dev); | 594 | host->hw_revision = amba_rev(dev); |
585 | DBG(host, "designer ID = 0x%02x\n", host->hw_designer); | 595 | dev_dbg(mmc_dev(mmc), "designer ID = 0x%02x\n", host->hw_designer); |
586 | DBG(host, "revision = 0x%01x\n", host->hw_revision); | 596 | dev_dbg(mmc_dev(mmc), "revision = 0x%01x\n", host->hw_revision); |
587 | 597 | ||
588 | host->clk = clk_get(&dev->dev, NULL); | 598 | host->clk = clk_get(&dev->dev, NULL); |
589 | if (IS_ERR(host->clk)) { | 599 | if (IS_ERR(host->clk)) { |
@@ -608,7 +618,8 @@ static int __devinit mmci_probe(struct amba_device *dev, struct amba_id *id) | |||
608 | if (ret < 0) | 618 | if (ret < 0) |
609 | goto clk_disable; | 619 | goto clk_disable; |
610 | host->mclk = clk_get_rate(host->clk); | 620 | host->mclk = clk_get_rate(host->clk); |
611 | DBG(host, "eventual mclk rate: %u Hz\n", host->mclk); | 621 | dev_dbg(mmc_dev(mmc), "eventual mclk rate: %u Hz\n", |
622 | host->mclk); | ||
612 | } | 623 | } |
613 | host->base = ioremap(dev->res.start, resource_size(&dev->res)); | 624 | host->base = ioremap(dev->res.start, resource_size(&dev->res)); |
614 | if (!host->base) { | 625 | if (!host->base) { |
@@ -619,6 +630,8 @@ static int __devinit mmci_probe(struct amba_device *dev, struct amba_id *id) | |||
619 | mmc->ops = &mmci_ops; | 630 | mmc->ops = &mmci_ops; |
620 | mmc->f_min = (host->mclk + 511) / 512; | 631 | mmc->f_min = (host->mclk + 511) / 512; |
621 | mmc->f_max = min(host->mclk, fmax); | 632 | mmc->f_max = min(host->mclk, fmax); |
633 | dev_dbg(mmc_dev(mmc), "clocking block at %u Hz\n", mmc->f_max); | ||
634 | |||
622 | #ifdef CONFIG_REGULATOR | 635 | #ifdef CONFIG_REGULATOR |
623 | /* If we're using the regulator framework, try to fetch a regulator */ | 636 | /* If we're using the regulator framework, try to fetch a regulator */ |
624 | host->vcc = regulator_get(&dev->dev, "vmmc"); | 637 | host->vcc = regulator_get(&dev->dev, "vmmc"); |
@@ -712,7 +725,7 @@ static int __devinit mmci_probe(struct amba_device *dev, struct amba_id *id) | |||
712 | 725 | ||
713 | mmc_add_host(mmc); | 726 | mmc_add_host(mmc); |
714 | 727 | ||
715 | printk(KERN_INFO "%s: MMCI rev %x cfg %02x at 0x%016llx irq %d,%d\n", | 728 | dev_info(&dev->dev, "%s: MMCI rev %x cfg %02x at 0x%016llx irq %d,%d\n", |
716 | mmc_hostname(mmc), amba_rev(dev), amba_config(dev), | 729 | mmc_hostname(mmc), amba_rev(dev), amba_config(dev), |
717 | (unsigned long long)dev->res.start, dev->irq[0], dev->irq[1]); | 730 | (unsigned long long)dev->res.start, dev->irq[0], dev->irq[1]); |
718 | 731 | ||
diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c index 4b2322518909..83f0affadcae 100644 --- a/drivers/mmc/host/omap_hsmmc.c +++ b/drivers/mmc/host/omap_hsmmc.c | |||
@@ -30,6 +30,8 @@ | |||
30 | #include <linux/mmc/core.h> | 30 | #include <linux/mmc/core.h> |
31 | #include <linux/io.h> | 31 | #include <linux/io.h> |
32 | #include <linux/semaphore.h> | 32 | #include <linux/semaphore.h> |
33 | #include <linux/gpio.h> | ||
34 | #include <linux/regulator/consumer.h> | ||
33 | #include <plat/dma.h> | 35 | #include <plat/dma.h> |
34 | #include <mach/hardware.h> | 36 | #include <mach/hardware.h> |
35 | #include <plat/board.h> | 37 | #include <plat/board.h> |
@@ -146,6 +148,15 @@ struct omap_hsmmc_host { | |||
146 | struct clk *fclk; | 148 | struct clk *fclk; |
147 | struct clk *iclk; | 149 | struct clk *iclk; |
148 | struct clk *dbclk; | 150 | struct clk *dbclk; |
151 | /* | ||
152 | * vcc == configured supply | ||
153 | * vcc_aux == optional | ||
154 | * - MMC1, supply for DAT4..DAT7 | ||
155 | * - MMC2/MMC2, external level shifter voltage supply, for | ||
156 | * chip (SDIO, eMMC, etc) or transceiver (MMC2 only) | ||
157 | */ | ||
158 | struct regulator *vcc; | ||
159 | struct regulator *vcc_aux; | ||
149 | struct semaphore sem; | 160 | struct semaphore sem; |
150 | struct work_struct mmc_carddetect_work; | 161 | struct work_struct mmc_carddetect_work; |
151 | void __iomem *base; | 162 | void __iomem *base; |
@@ -171,10 +182,337 @@ struct omap_hsmmc_host { | |||
171 | int vdd; | 182 | int vdd; |
172 | int protect_card; | 183 | int protect_card; |
173 | int reqs_blocked; | 184 | int reqs_blocked; |
185 | int use_reg; | ||
174 | 186 | ||
175 | struct omap_mmc_platform_data *pdata; | 187 | struct omap_mmc_platform_data *pdata; |
176 | }; | 188 | }; |
177 | 189 | ||
190 | static int omap_hsmmc_card_detect(struct device *dev, int slot) | ||
191 | { | ||
192 | struct omap_mmc_platform_data *mmc = dev->platform_data; | ||
193 | |||
194 | /* NOTE: assumes card detect signal is active-low */ | ||
195 | return !gpio_get_value_cansleep(mmc->slots[0].switch_pin); | ||
196 | } | ||
197 | |||
198 | static int omap_hsmmc_get_wp(struct device *dev, int slot) | ||
199 | { | ||
200 | struct omap_mmc_platform_data *mmc = dev->platform_data; | ||
201 | |||
202 | /* NOTE: assumes write protect signal is active-high */ | ||
203 | return gpio_get_value_cansleep(mmc->slots[0].gpio_wp); | ||
204 | } | ||
205 | |||
206 | static int omap_hsmmc_get_cover_state(struct device *dev, int slot) | ||
207 | { | ||
208 | struct omap_mmc_platform_data *mmc = dev->platform_data; | ||
209 | |||
210 | /* NOTE: assumes card detect signal is active-low */ | ||
211 | return !gpio_get_value_cansleep(mmc->slots[0].switch_pin); | ||
212 | } | ||
213 | |||
214 | #ifdef CONFIG_PM | ||
215 | |||
216 | static int omap_hsmmc_suspend_cdirq(struct device *dev, int slot) | ||
217 | { | ||
218 | struct omap_mmc_platform_data *mmc = dev->platform_data; | ||
219 | |||
220 | disable_irq(mmc->slots[0].card_detect_irq); | ||
221 | return 0; | ||
222 | } | ||
223 | |||
224 | static int omap_hsmmc_resume_cdirq(struct device *dev, int slot) | ||
225 | { | ||
226 | struct omap_mmc_platform_data *mmc = dev->platform_data; | ||
227 | |||
228 | enable_irq(mmc->slots[0].card_detect_irq); | ||
229 | return 0; | ||
230 | } | ||
231 | |||
232 | #else | ||
233 | |||
234 | #define omap_hsmmc_suspend_cdirq NULL | ||
235 | #define omap_hsmmc_resume_cdirq NULL | ||
236 | |||
237 | #endif | ||
238 | |||
239 | #ifdef CONFIG_REGULATOR | ||
240 | |||
241 | static int omap_hsmmc_1_set_power(struct device *dev, int slot, int power_on, | ||
242 | int vdd) | ||
243 | { | ||
244 | struct omap_hsmmc_host *host = | ||
245 | platform_get_drvdata(to_platform_device(dev)); | ||
246 | int ret; | ||
247 | |||
248 | if (mmc_slot(host).before_set_reg) | ||
249 | mmc_slot(host).before_set_reg(dev, slot, power_on, vdd); | ||
250 | |||
251 | if (power_on) | ||
252 | ret = mmc_regulator_set_ocr(host->vcc, vdd); | ||
253 | else | ||
254 | ret = mmc_regulator_set_ocr(host->vcc, 0); | ||
255 | |||
256 | if (mmc_slot(host).after_set_reg) | ||
257 | mmc_slot(host).after_set_reg(dev, slot, power_on, vdd); | ||
258 | |||
259 | return ret; | ||
260 | } | ||
261 | |||
262 | static int omap_hsmmc_23_set_power(struct device *dev, int slot, int power_on, | ||
263 | int vdd) | ||
264 | { | ||
265 | struct omap_hsmmc_host *host = | ||
266 | platform_get_drvdata(to_platform_device(dev)); | ||
267 | int ret = 0; | ||
268 | |||
269 | /* | ||
270 | * If we don't see a Vcc regulator, assume it's a fixed | ||
271 | * voltage always-on regulator. | ||
272 | */ | ||
273 | if (!host->vcc) | ||
274 | return 0; | ||
275 | |||
276 | if (mmc_slot(host).before_set_reg) | ||
277 | mmc_slot(host).before_set_reg(dev, slot, power_on, vdd); | ||
278 | |||
279 | /* | ||
280 | * Assume Vcc regulator is used only to power the card ... OMAP | ||
281 | * VDDS is used to power the pins, optionally with a transceiver to | ||
282 | * support cards using voltages other than VDDS (1.8V nominal). When a | ||
283 | * transceiver is used, DAT3..7 are muxed as transceiver control pins. | ||
284 | * | ||
285 | * In some cases this regulator won't support enable/disable; | ||
286 | * e.g. it's a fixed rail for a WLAN chip. | ||
287 | * | ||
288 | * In other cases vcc_aux switches interface power. Example, for | ||
289 | * eMMC cards it represents VccQ. Sometimes transceivers or SDIO | ||
290 | * chips/cards need an interface voltage rail too. | ||
291 | */ | ||
292 | if (power_on) { | ||
293 | ret = mmc_regulator_set_ocr(host->vcc, vdd); | ||
294 | /* Enable interface voltage rail, if needed */ | ||
295 | if (ret == 0 && host->vcc_aux) { | ||
296 | ret = regulator_enable(host->vcc_aux); | ||
297 | if (ret < 0) | ||
298 | ret = mmc_regulator_set_ocr(host->vcc, 0); | ||
299 | } | ||
300 | } else { | ||
301 | if (host->vcc_aux) | ||
302 | ret = regulator_disable(host->vcc_aux); | ||
303 | if (ret == 0) | ||
304 | ret = mmc_regulator_set_ocr(host->vcc, 0); | ||
305 | } | ||
306 | |||
307 | if (mmc_slot(host).after_set_reg) | ||
308 | mmc_slot(host).after_set_reg(dev, slot, power_on, vdd); | ||
309 | |||
310 | return ret; | ||
311 | } | ||
312 | |||
313 | static int omap_hsmmc_1_set_sleep(struct device *dev, int slot, int sleep, | ||
314 | int vdd, int cardsleep) | ||
315 | { | ||
316 | struct omap_hsmmc_host *host = | ||
317 | platform_get_drvdata(to_platform_device(dev)); | ||
318 | int mode = sleep ? REGULATOR_MODE_STANDBY : REGULATOR_MODE_NORMAL; | ||
319 | |||
320 | return regulator_set_mode(host->vcc, mode); | ||
321 | } | ||
322 | |||
323 | static int omap_hsmmc_23_set_sleep(struct device *dev, int slot, int sleep, | ||
324 | int vdd, int cardsleep) | ||
325 | { | ||
326 | struct omap_hsmmc_host *host = | ||
327 | platform_get_drvdata(to_platform_device(dev)); | ||
328 | int err, mode; | ||
329 | |||
330 | /* | ||
331 | * If we don't see a Vcc regulator, assume it's a fixed | ||
332 | * voltage always-on regulator. | ||
333 | */ | ||
334 | if (!host->vcc) | ||
335 | return 0; | ||
336 | |||
337 | mode = sleep ? REGULATOR_MODE_STANDBY : REGULATOR_MODE_NORMAL; | ||
338 | |||
339 | if (!host->vcc_aux) | ||
340 | return regulator_set_mode(host->vcc, mode); | ||
341 | |||
342 | if (cardsleep) { | ||
343 | /* VCC can be turned off if card is asleep */ | ||
344 | if (sleep) | ||
345 | err = mmc_regulator_set_ocr(host->vcc, 0); | ||
346 | else | ||
347 | err = mmc_regulator_set_ocr(host->vcc, vdd); | ||
348 | } else | ||
349 | err = regulator_set_mode(host->vcc, mode); | ||
350 | if (err) | ||
351 | return err; | ||
352 | |||
353 | if (!mmc_slot(host).vcc_aux_disable_is_sleep) | ||
354 | return regulator_set_mode(host->vcc_aux, mode); | ||
355 | |||
356 | if (sleep) | ||
357 | return regulator_disable(host->vcc_aux); | ||
358 | else | ||
359 | return regulator_enable(host->vcc_aux); | ||
360 | } | ||
361 | |||
362 | static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host) | ||
363 | { | ||
364 | struct regulator *reg; | ||
365 | int ret = 0; | ||
366 | |||
367 | switch (host->id) { | ||
368 | case OMAP_MMC1_DEVID: | ||
369 | /* On-chip level shifting via PBIAS0/PBIAS1 */ | ||
370 | mmc_slot(host).set_power = omap_hsmmc_1_set_power; | ||
371 | mmc_slot(host).set_sleep = omap_hsmmc_1_set_sleep; | ||
372 | break; | ||
373 | case OMAP_MMC2_DEVID: | ||
374 | case OMAP_MMC3_DEVID: | ||
375 | /* Off-chip level shifting, or none */ | ||
376 | mmc_slot(host).set_power = omap_hsmmc_23_set_power; | ||
377 | mmc_slot(host).set_sleep = omap_hsmmc_23_set_sleep; | ||
378 | break; | ||
379 | default: | ||
380 | pr_err("MMC%d configuration not supported!\n", host->id); | ||
381 | return -EINVAL; | ||
382 | } | ||
383 | |||
384 | reg = regulator_get(host->dev, "vmmc"); | ||
385 | if (IS_ERR(reg)) { | ||
386 | dev_dbg(host->dev, "vmmc regulator missing\n"); | ||
387 | /* | ||
388 | * HACK: until fixed.c regulator is usable, | ||
389 | * we don't require a main regulator | ||
390 | * for MMC2 or MMC3 | ||
391 | */ | ||
392 | if (host->id == OMAP_MMC1_DEVID) { | ||
393 | ret = PTR_ERR(reg); | ||
394 | goto err; | ||
395 | } | ||
396 | } else { | ||
397 | host->vcc = reg; | ||
398 | mmc_slot(host).ocr_mask = mmc_regulator_get_ocrmask(reg); | ||
399 | |||
400 | /* Allow an aux regulator */ | ||
401 | reg = regulator_get(host->dev, "vmmc_aux"); | ||
402 | host->vcc_aux = IS_ERR(reg) ? NULL : reg; | ||
403 | |||
404 | /* | ||
405 | * UGLY HACK: workaround regulator framework bugs. | ||
406 | * When the bootloader leaves a supply active, it's | ||
407 | * initialized with zero usecount ... and we can't | ||
408 | * disable it without first enabling it. Until the | ||
409 | * framework is fixed, we need a workaround like this | ||
410 | * (which is safe for MMC, but not in general). | ||
411 | */ | ||
412 | if (regulator_is_enabled(host->vcc) > 0) { | ||
413 | regulator_enable(host->vcc); | ||
414 | regulator_disable(host->vcc); | ||
415 | } | ||
416 | if (host->vcc_aux) { | ||
417 | if (regulator_is_enabled(reg) > 0) { | ||
418 | regulator_enable(reg); | ||
419 | regulator_disable(reg); | ||
420 | } | ||
421 | } | ||
422 | } | ||
423 | |||
424 | return 0; | ||
425 | |||
426 | err: | ||
427 | mmc_slot(host).set_power = NULL; | ||
428 | mmc_slot(host).set_sleep = NULL; | ||
429 | return ret; | ||
430 | } | ||
431 | |||
432 | static void omap_hsmmc_reg_put(struct omap_hsmmc_host *host) | ||
433 | { | ||
434 | regulator_put(host->vcc); | ||
435 | regulator_put(host->vcc_aux); | ||
436 | mmc_slot(host).set_power = NULL; | ||
437 | mmc_slot(host).set_sleep = NULL; | ||
438 | } | ||
439 | |||
440 | static inline int omap_hsmmc_have_reg(void) | ||
441 | { | ||
442 | return 1; | ||
443 | } | ||
444 | |||
445 | #else | ||
446 | |||
447 | static inline int omap_hsmmc_reg_get(struct omap_hsmmc_host *host) | ||
448 | { | ||
449 | return -EINVAL; | ||
450 | } | ||
451 | |||
452 | static inline void omap_hsmmc_reg_put(struct omap_hsmmc_host *host) | ||
453 | { | ||
454 | } | ||
455 | |||
456 | static inline int omap_hsmmc_have_reg(void) | ||
457 | { | ||
458 | return 0; | ||
459 | } | ||
460 | |||
461 | #endif | ||
462 | |||
463 | static int omap_hsmmc_gpio_init(struct omap_mmc_platform_data *pdata) | ||
464 | { | ||
465 | int ret; | ||
466 | |||
467 | if (gpio_is_valid(pdata->slots[0].switch_pin)) { | ||
468 | pdata->suspend = omap_hsmmc_suspend_cdirq; | ||
469 | pdata->resume = omap_hsmmc_resume_cdirq; | ||
470 | if (pdata->slots[0].cover) | ||
471 | pdata->slots[0].get_cover_state = | ||
472 | omap_hsmmc_get_cover_state; | ||
473 | else | ||
474 | pdata->slots[0].card_detect = omap_hsmmc_card_detect; | ||
475 | pdata->slots[0].card_detect_irq = | ||
476 | gpio_to_irq(pdata->slots[0].switch_pin); | ||
477 | ret = gpio_request(pdata->slots[0].switch_pin, "mmc_cd"); | ||
478 | if (ret) | ||
479 | return ret; | ||
480 | ret = gpio_direction_input(pdata->slots[0].switch_pin); | ||
481 | if (ret) | ||
482 | goto err_free_sp; | ||
483 | } else | ||
484 | pdata->slots[0].switch_pin = -EINVAL; | ||
485 | |||
486 | if (gpio_is_valid(pdata->slots[0].gpio_wp)) { | ||
487 | pdata->slots[0].get_ro = omap_hsmmc_get_wp; | ||
488 | ret = gpio_request(pdata->slots[0].gpio_wp, "mmc_wp"); | ||
489 | if (ret) | ||
490 | goto err_free_cd; | ||
491 | ret = gpio_direction_input(pdata->slots[0].gpio_wp); | ||
492 | if (ret) | ||
493 | goto err_free_wp; | ||
494 | } else | ||
495 | pdata->slots[0].gpio_wp = -EINVAL; | ||
496 | |||
497 | return 0; | ||
498 | |||
499 | err_free_wp: | ||
500 | gpio_free(pdata->slots[0].gpio_wp); | ||
501 | err_free_cd: | ||
502 | if (gpio_is_valid(pdata->slots[0].switch_pin)) | ||
503 | err_free_sp: | ||
504 | gpio_free(pdata->slots[0].switch_pin); | ||
505 | return ret; | ||
506 | } | ||
507 | |||
508 | static void omap_hsmmc_gpio_free(struct omap_mmc_platform_data *pdata) | ||
509 | { | ||
510 | if (gpio_is_valid(pdata->slots[0].gpio_wp)) | ||
511 | gpio_free(pdata->slots[0].gpio_wp); | ||
512 | if (gpio_is_valid(pdata->slots[0].switch_pin)) | ||
513 | gpio_free(pdata->slots[0].switch_pin); | ||
514 | } | ||
515 | |||
178 | /* | 516 | /* |
179 | * Stop clock to the card | 517 | * Stop clock to the card |
180 | */ | 518 | */ |
@@ -835,7 +1173,7 @@ static void omap_hsmmc_detect(struct work_struct *work) | |||
835 | sysfs_notify(&host->mmc->class_dev.kobj, NULL, "cover_switch"); | 1173 | sysfs_notify(&host->mmc->class_dev.kobj, NULL, "cover_switch"); |
836 | 1174 | ||
837 | if (slot->card_detect) | 1175 | if (slot->card_detect) |
838 | carddetect = slot->card_detect(slot->card_detect_irq); | 1176 | carddetect = slot->card_detect(host->dev, host->slot_id); |
839 | else { | 1177 | else { |
840 | omap_hsmmc_protect_card(host); | 1178 | omap_hsmmc_protect_card(host); |
841 | carddetect = -ENOSYS; | 1179 | carddetect = -ENOSYS; |
@@ -1242,7 +1580,7 @@ static int omap_hsmmc_get_cd(struct mmc_host *mmc) | |||
1242 | 1580 | ||
1243 | if (!mmc_slot(host).card_detect) | 1581 | if (!mmc_slot(host).card_detect) |
1244 | return -ENOSYS; | 1582 | return -ENOSYS; |
1245 | return mmc_slot(host).card_detect(mmc_slot(host).card_detect_irq); | 1583 | return mmc_slot(host).card_detect(host->dev, host->slot_id); |
1246 | } | 1584 | } |
1247 | 1585 | ||
1248 | static int omap_hsmmc_get_ro(struct mmc_host *mmc) | 1586 | static int omap_hsmmc_get_ro(struct mmc_host *mmc) |
@@ -1311,7 +1649,7 @@ static int omap_hsmmc_enabled_to_disabled(struct omap_hsmmc_host *host) | |||
1311 | if (host->power_mode == MMC_POWER_OFF) | 1649 | if (host->power_mode == MMC_POWER_OFF) |
1312 | return 0; | 1650 | return 0; |
1313 | 1651 | ||
1314 | return msecs_to_jiffies(OMAP_MMC_SLEEP_TIMEOUT); | 1652 | return OMAP_MMC_SLEEP_TIMEOUT; |
1315 | } | 1653 | } |
1316 | 1654 | ||
1317 | /* Handler for [DISABLED -> REGSLEEP / CARDSLEEP] transition */ | 1655 | /* Handler for [DISABLED -> REGSLEEP / CARDSLEEP] transition */ |
@@ -1347,11 +1685,14 @@ static int omap_hsmmc_disabled_to_sleep(struct omap_hsmmc_host *host) | |||
1347 | dev_dbg(mmc_dev(host->mmc), "DISABLED -> %s\n", | 1685 | dev_dbg(mmc_dev(host->mmc), "DISABLED -> %s\n", |
1348 | host->dpm_state == CARDSLEEP ? "CARDSLEEP" : "REGSLEEP"); | 1686 | host->dpm_state == CARDSLEEP ? "CARDSLEEP" : "REGSLEEP"); |
1349 | 1687 | ||
1688 | if (mmc_slot(host).no_off) | ||
1689 | return 0; | ||
1690 | |||
1350 | if ((host->mmc->caps & MMC_CAP_NONREMOVABLE) || | 1691 | if ((host->mmc->caps & MMC_CAP_NONREMOVABLE) || |
1351 | mmc_slot(host).card_detect || | 1692 | mmc_slot(host).card_detect || |
1352 | (mmc_slot(host).get_cover_state && | 1693 | (mmc_slot(host).get_cover_state && |
1353 | mmc_slot(host).get_cover_state(host->dev, host->slot_id))) | 1694 | mmc_slot(host).get_cover_state(host->dev, host->slot_id))) |
1354 | return msecs_to_jiffies(OMAP_MMC_OFF_TIMEOUT); | 1695 | return OMAP_MMC_OFF_TIMEOUT; |
1355 | 1696 | ||
1356 | return 0; | 1697 | return 0; |
1357 | } | 1698 | } |
@@ -1362,6 +1703,9 @@ static int omap_hsmmc_sleep_to_off(struct omap_hsmmc_host *host) | |||
1362 | if (!mmc_try_claim_host(host->mmc)) | 1703 | if (!mmc_try_claim_host(host->mmc)) |
1363 | return 0; | 1704 | return 0; |
1364 | 1705 | ||
1706 | if (mmc_slot(host).no_off) | ||
1707 | return 0; | ||
1708 | |||
1365 | if (!((host->mmc->caps & MMC_CAP_NONREMOVABLE) || | 1709 | if (!((host->mmc->caps & MMC_CAP_NONREMOVABLE) || |
1366 | mmc_slot(host).card_detect || | 1710 | mmc_slot(host).card_detect || |
1367 | (mmc_slot(host).get_cover_state && | 1711 | (mmc_slot(host).get_cover_state && |
@@ -1616,7 +1960,7 @@ static int __init omap_hsmmc_probe(struct platform_device *pdev) | |||
1616 | struct mmc_host *mmc; | 1960 | struct mmc_host *mmc; |
1617 | struct omap_hsmmc_host *host = NULL; | 1961 | struct omap_hsmmc_host *host = NULL; |
1618 | struct resource *res; | 1962 | struct resource *res; |
1619 | int ret = 0, irq; | 1963 | int ret, irq; |
1620 | 1964 | ||
1621 | if (pdata == NULL) { | 1965 | if (pdata == NULL) { |
1622 | dev_err(&pdev->dev, "Platform Data is missing\n"); | 1966 | dev_err(&pdev->dev, "Platform Data is missing\n"); |
@@ -1638,10 +1982,14 @@ static int __init omap_hsmmc_probe(struct platform_device *pdev) | |||
1638 | if (res == NULL) | 1982 | if (res == NULL) |
1639 | return -EBUSY; | 1983 | return -EBUSY; |
1640 | 1984 | ||
1985 | ret = omap_hsmmc_gpio_init(pdata); | ||
1986 | if (ret) | ||
1987 | goto err; | ||
1988 | |||
1641 | mmc = mmc_alloc_host(sizeof(struct omap_hsmmc_host), &pdev->dev); | 1989 | mmc = mmc_alloc_host(sizeof(struct omap_hsmmc_host), &pdev->dev); |
1642 | if (!mmc) { | 1990 | if (!mmc) { |
1643 | ret = -ENOMEM; | 1991 | ret = -ENOMEM; |
1644 | goto err; | 1992 | goto err_alloc; |
1645 | } | 1993 | } |
1646 | 1994 | ||
1647 | host = mmc_priv(mmc); | 1995 | host = mmc_priv(mmc); |
@@ -1656,7 +2004,7 @@ static int __init omap_hsmmc_probe(struct platform_device *pdev) | |||
1656 | host->slot_id = 0; | 2004 | host->slot_id = 0; |
1657 | host->mapbase = res->start; | 2005 | host->mapbase = res->start; |
1658 | host->base = ioremap(host->mapbase, SZ_4K); | 2006 | host->base = ioremap(host->mapbase, SZ_4K); |
1659 | host->power_mode = -1; | 2007 | host->power_mode = MMC_POWER_OFF; |
1660 | 2008 | ||
1661 | platform_set_drvdata(pdev, host); | 2009 | platform_set_drvdata(pdev, host); |
1662 | INIT_WORK(&host->mmc_carddetect_work, omap_hsmmc_detect); | 2010 | INIT_WORK(&host->mmc_carddetect_work, omap_hsmmc_detect); |
@@ -1666,6 +2014,13 @@ static int __init omap_hsmmc_probe(struct platform_device *pdev) | |||
1666 | else | 2014 | else |
1667 | mmc->ops = &omap_hsmmc_ops; | 2015 | mmc->ops = &omap_hsmmc_ops; |
1668 | 2016 | ||
2017 | /* | ||
2018 | * If regulator_disable can only put vcc_aux to sleep then there is | ||
2019 | * no off state. | ||
2020 | */ | ||
2021 | if (mmc_slot(host).vcc_aux_disable_is_sleep) | ||
2022 | mmc_slot(host).no_off = 1; | ||
2023 | |||
1669 | mmc->f_min = 400000; | 2024 | mmc->f_min = 400000; |
1670 | mmc->f_max = 52000000; | 2025 | mmc->f_max = 52000000; |
1671 | 2026 | ||
@@ -1781,7 +2136,6 @@ static int __init omap_hsmmc_probe(struct platform_device *pdev) | |||
1781 | goto err_irq; | 2136 | goto err_irq; |
1782 | } | 2137 | } |
1783 | 2138 | ||
1784 | /* initialize power supplies, gpios, etc */ | ||
1785 | if (pdata->init != NULL) { | 2139 | if (pdata->init != NULL) { |
1786 | if (pdata->init(&pdev->dev) != 0) { | 2140 | if (pdata->init(&pdev->dev) != 0) { |
1787 | dev_dbg(mmc_dev(host->mmc), | 2141 | dev_dbg(mmc_dev(host->mmc), |
@@ -1789,6 +2143,14 @@ static int __init omap_hsmmc_probe(struct platform_device *pdev) | |||
1789 | goto err_irq_cd_init; | 2143 | goto err_irq_cd_init; |
1790 | } | 2144 | } |
1791 | } | 2145 | } |
2146 | |||
2147 | if (omap_hsmmc_have_reg() && !mmc_slot(host).set_power) { | ||
2148 | ret = omap_hsmmc_reg_get(host); | ||
2149 | if (ret) | ||
2150 | goto err_reg; | ||
2151 | host->use_reg = 1; | ||
2152 | } | ||
2153 | |||
1792 | mmc->ocr_avail = mmc_slot(host).ocr_mask; | 2154 | mmc->ocr_avail = mmc_slot(host).ocr_mask; |
1793 | 2155 | ||
1794 | /* Request IRQ for card detect */ | 2156 | /* Request IRQ for card detect */ |
@@ -1823,19 +2185,22 @@ static int __init omap_hsmmc_probe(struct platform_device *pdev) | |||
1823 | ret = device_create_file(&mmc->class_dev, | 2185 | ret = device_create_file(&mmc->class_dev, |
1824 | &dev_attr_cover_switch); | 2186 | &dev_attr_cover_switch); |
1825 | if (ret < 0) | 2187 | if (ret < 0) |
1826 | goto err_cover_switch; | 2188 | goto err_slot_name; |
1827 | } | 2189 | } |
1828 | 2190 | ||
1829 | omap_hsmmc_debugfs(mmc); | 2191 | omap_hsmmc_debugfs(mmc); |
1830 | 2192 | ||
1831 | return 0; | 2193 | return 0; |
1832 | 2194 | ||
1833 | err_cover_switch: | ||
1834 | device_remove_file(&mmc->class_dev, &dev_attr_cover_switch); | ||
1835 | err_slot_name: | 2195 | err_slot_name: |
1836 | mmc_remove_host(mmc); | 2196 | mmc_remove_host(mmc); |
1837 | err_irq_cd: | ||
1838 | free_irq(mmc_slot(host).card_detect_irq, host); | 2197 | free_irq(mmc_slot(host).card_detect_irq, host); |
2198 | err_irq_cd: | ||
2199 | if (host->use_reg) | ||
2200 | omap_hsmmc_reg_put(host); | ||
2201 | err_reg: | ||
2202 | if (host->pdata->cleanup) | ||
2203 | host->pdata->cleanup(&pdev->dev); | ||
1839 | err_irq_cd_init: | 2204 | err_irq_cd_init: |
1840 | free_irq(host->irq, host); | 2205 | free_irq(host->irq, host); |
1841 | err_irq: | 2206 | err_irq: |
@@ -1847,14 +2212,14 @@ err_irq: | |||
1847 | clk_disable(host->dbclk); | 2212 | clk_disable(host->dbclk); |
1848 | clk_put(host->dbclk); | 2213 | clk_put(host->dbclk); |
1849 | } | 2214 | } |
1850 | |||
1851 | err1: | 2215 | err1: |
1852 | iounmap(host->base); | 2216 | iounmap(host->base); |
2217 | platform_set_drvdata(pdev, NULL); | ||
2218 | mmc_free_host(mmc); | ||
2219 | err_alloc: | ||
2220 | omap_hsmmc_gpio_free(pdata); | ||
1853 | err: | 2221 | err: |
1854 | dev_dbg(mmc_dev(host->mmc), "Probe Failed\n"); | ||
1855 | release_mem_region(res->start, res->end - res->start + 1); | 2222 | release_mem_region(res->start, res->end - res->start + 1); |
1856 | if (host) | ||
1857 | mmc_free_host(mmc); | ||
1858 | return ret; | 2223 | return ret; |
1859 | } | 2224 | } |
1860 | 2225 | ||
@@ -1866,6 +2231,8 @@ static int omap_hsmmc_remove(struct platform_device *pdev) | |||
1866 | if (host) { | 2231 | if (host) { |
1867 | mmc_host_enable(host->mmc); | 2232 | mmc_host_enable(host->mmc); |
1868 | mmc_remove_host(host->mmc); | 2233 | mmc_remove_host(host->mmc); |
2234 | if (host->use_reg) | ||
2235 | omap_hsmmc_reg_put(host); | ||
1869 | if (host->pdata->cleanup) | 2236 | if (host->pdata->cleanup) |
1870 | host->pdata->cleanup(&pdev->dev); | 2237 | host->pdata->cleanup(&pdev->dev); |
1871 | free_irq(host->irq, host); | 2238 | free_irq(host->irq, host); |
@@ -1884,6 +2251,7 @@ static int omap_hsmmc_remove(struct platform_device *pdev) | |||
1884 | 2251 | ||
1885 | mmc_free_host(host->mmc); | 2252 | mmc_free_host(host->mmc); |
1886 | iounmap(host->base); | 2253 | iounmap(host->base); |
2254 | omap_hsmmc_gpio_free(pdev->dev.platform_data); | ||
1887 | } | 2255 | } |
1888 | 2256 | ||
1889 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 2257 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
diff --git a/drivers/mmc/host/ricoh_mmc.c b/drivers/mmc/host/ricoh_mmc.c deleted file mode 100644 index f62790513322..000000000000 --- a/drivers/mmc/host/ricoh_mmc.c +++ /dev/null | |||
@@ -1,262 +0,0 @@ | |||
1 | /* | ||
2 | * ricoh_mmc.c - Dummy driver to disable the Rioch MMC controller. | ||
3 | * | ||
4 | * Copyright (C) 2007 Philip Langdale, All Rights Reserved. | ||
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 (at | ||
9 | * your option) any later version. | ||
10 | */ | ||
11 | |||
12 | /* | ||
13 | * This is a conceptually ridiculous driver, but it is required by the way | ||
14 | * the Ricoh multi-function chips (R5CXXX) work. These chips implement | ||
15 | * the four main memory card controllers (SD, MMC, MS, xD) and one or both | ||
16 | * of cardbus or firewire. It happens that they implement SD and MMC | ||
17 | * support as separate controllers (and PCI functions). The linux SDHCI | ||
18 | * driver supports MMC cards but the chip detects MMC cards in hardware | ||
19 | * and directs them to the MMC controller - so the SDHCI driver never sees | ||
20 | * them. To get around this, we must disable the useless MMC controller. | ||
21 | * At that point, the SDHCI controller will start seeing them. As a bonus, | ||
22 | * a detection event occurs immediately, even if the MMC card is already | ||
23 | * in the reader. | ||
24 | * | ||
25 | * It seems to be the case that the relevant PCI registers to deactivate the | ||
26 | * MMC controller live on PCI function 0, which might be the cardbus controller | ||
27 | * or the firewire controller, depending on the particular chip in question. As | ||
28 | * such, it makes what this driver has to do unavoidably ugly. Such is life. | ||
29 | */ | ||
30 | |||
31 | #include <linux/pci.h> | ||
32 | |||
33 | #define DRIVER_NAME "ricoh-mmc" | ||
34 | |||
35 | static const struct pci_device_id pci_ids[] __devinitdata = { | ||
36 | { | ||
37 | .vendor = PCI_VENDOR_ID_RICOH, | ||
38 | .device = PCI_DEVICE_ID_RICOH_R5C843, | ||
39 | .subvendor = PCI_ANY_ID, | ||
40 | .subdevice = PCI_ANY_ID, | ||
41 | }, | ||
42 | { /* end: all zeroes */ }, | ||
43 | }; | ||
44 | |||
45 | MODULE_DEVICE_TABLE(pci, pci_ids); | ||
46 | |||
47 | static int ricoh_mmc_disable(struct pci_dev *fw_dev) | ||
48 | { | ||
49 | u8 write_enable; | ||
50 | u8 write_target; | ||
51 | u8 disable; | ||
52 | |||
53 | if (fw_dev->device == PCI_DEVICE_ID_RICOH_RL5C476) { | ||
54 | /* via RL5C476 */ | ||
55 | |||
56 | pci_read_config_byte(fw_dev, 0xB7, &disable); | ||
57 | if (disable & 0x02) { | ||
58 | printk(KERN_INFO DRIVER_NAME | ||
59 | ": Controller already disabled. " \ | ||
60 | "Nothing to do.\n"); | ||
61 | return -ENODEV; | ||
62 | } | ||
63 | |||
64 | pci_read_config_byte(fw_dev, 0x8E, &write_enable); | ||
65 | pci_write_config_byte(fw_dev, 0x8E, 0xAA); | ||
66 | pci_read_config_byte(fw_dev, 0x8D, &write_target); | ||
67 | pci_write_config_byte(fw_dev, 0x8D, 0xB7); | ||
68 | pci_write_config_byte(fw_dev, 0xB7, disable | 0x02); | ||
69 | pci_write_config_byte(fw_dev, 0x8E, write_enable); | ||
70 | pci_write_config_byte(fw_dev, 0x8D, write_target); | ||
71 | } else { | ||
72 | /* via R5C832 */ | ||
73 | |||
74 | pci_read_config_byte(fw_dev, 0xCB, &disable); | ||
75 | if (disable & 0x02) { | ||
76 | printk(KERN_INFO DRIVER_NAME | ||
77 | ": Controller already disabled. " \ | ||
78 | "Nothing to do.\n"); | ||
79 | return -ENODEV; | ||
80 | } | ||
81 | |||
82 | pci_read_config_byte(fw_dev, 0xCA, &write_enable); | ||
83 | pci_write_config_byte(fw_dev, 0xCA, 0x57); | ||
84 | pci_write_config_byte(fw_dev, 0xCB, disable | 0x02); | ||
85 | pci_write_config_byte(fw_dev, 0xCA, write_enable); | ||
86 | } | ||
87 | |||
88 | printk(KERN_INFO DRIVER_NAME | ||
89 | ": Controller is now disabled.\n"); | ||
90 | |||
91 | return 0; | ||
92 | } | ||
93 | |||
94 | static int ricoh_mmc_enable(struct pci_dev *fw_dev) | ||
95 | { | ||
96 | u8 write_enable; | ||
97 | u8 write_target; | ||
98 | u8 disable; | ||
99 | |||
100 | if (fw_dev->device == PCI_DEVICE_ID_RICOH_RL5C476) { | ||
101 | /* via RL5C476 */ | ||
102 | |||
103 | pci_read_config_byte(fw_dev, 0x8E, &write_enable); | ||
104 | pci_write_config_byte(fw_dev, 0x8E, 0xAA); | ||
105 | pci_read_config_byte(fw_dev, 0x8D, &write_target); | ||
106 | pci_write_config_byte(fw_dev, 0x8D, 0xB7); | ||
107 | pci_read_config_byte(fw_dev, 0xB7, &disable); | ||
108 | pci_write_config_byte(fw_dev, 0xB7, disable & ~0x02); | ||
109 | pci_write_config_byte(fw_dev, 0x8E, write_enable); | ||
110 | pci_write_config_byte(fw_dev, 0x8D, write_target); | ||
111 | } else { | ||
112 | /* via R5C832 */ | ||
113 | |||
114 | pci_read_config_byte(fw_dev, 0xCA, &write_enable); | ||
115 | pci_read_config_byte(fw_dev, 0xCB, &disable); | ||
116 | pci_write_config_byte(fw_dev, 0xCA, 0x57); | ||
117 | pci_write_config_byte(fw_dev, 0xCB, disable & ~0x02); | ||
118 | pci_write_config_byte(fw_dev, 0xCA, write_enable); | ||
119 | } | ||
120 | |||
121 | printk(KERN_INFO DRIVER_NAME | ||
122 | ": Controller is now re-enabled.\n"); | ||
123 | |||
124 | return 0; | ||
125 | } | ||
126 | |||
127 | static int __devinit ricoh_mmc_probe(struct pci_dev *pdev, | ||
128 | const struct pci_device_id *ent) | ||
129 | { | ||
130 | u8 rev; | ||
131 | u8 ctrlfound = 0; | ||
132 | |||
133 | struct pci_dev *fw_dev = NULL; | ||
134 | |||
135 | BUG_ON(pdev == NULL); | ||
136 | BUG_ON(ent == NULL); | ||
137 | |||
138 | pci_read_config_byte(pdev, PCI_CLASS_REVISION, &rev); | ||
139 | |||
140 | printk(KERN_INFO DRIVER_NAME | ||
141 | ": Ricoh MMC controller found at %s [%04x:%04x] (rev %x)\n", | ||
142 | pci_name(pdev), (int)pdev->vendor, (int)pdev->device, | ||
143 | (int)rev); | ||
144 | |||
145 | while ((fw_dev = | ||
146 | pci_get_device(PCI_VENDOR_ID_RICOH, | ||
147 | PCI_DEVICE_ID_RICOH_RL5C476, fw_dev))) { | ||
148 | if (PCI_SLOT(pdev->devfn) == PCI_SLOT(fw_dev->devfn) && | ||
149 | PCI_FUNC(fw_dev->devfn) == 0 && | ||
150 | pdev->bus == fw_dev->bus) { | ||
151 | if (ricoh_mmc_disable(fw_dev) != 0) | ||
152 | return -ENODEV; | ||
153 | |||
154 | pci_set_drvdata(pdev, fw_dev); | ||
155 | |||
156 | ++ctrlfound; | ||
157 | break; | ||
158 | } | ||
159 | } | ||
160 | |||
161 | fw_dev = NULL; | ||
162 | |||
163 | while (!ctrlfound && | ||
164 | (fw_dev = pci_get_device(PCI_VENDOR_ID_RICOH, | ||
165 | PCI_DEVICE_ID_RICOH_R5C832, fw_dev))) { | ||
166 | if (PCI_SLOT(pdev->devfn) == PCI_SLOT(fw_dev->devfn) && | ||
167 | PCI_FUNC(fw_dev->devfn) == 0 && | ||
168 | pdev->bus == fw_dev->bus) { | ||
169 | if (ricoh_mmc_disable(fw_dev) != 0) | ||
170 | return -ENODEV; | ||
171 | |||
172 | pci_set_drvdata(pdev, fw_dev); | ||
173 | |||
174 | ++ctrlfound; | ||
175 | } | ||
176 | } | ||
177 | |||
178 | if (!ctrlfound) { | ||
179 | printk(KERN_WARNING DRIVER_NAME | ||
180 | ": Main Ricoh function not found. Cannot disable controller.\n"); | ||
181 | return -ENODEV; | ||
182 | } | ||
183 | |||
184 | return 0; | ||
185 | } | ||
186 | |||
187 | static void __devexit ricoh_mmc_remove(struct pci_dev *pdev) | ||
188 | { | ||
189 | struct pci_dev *fw_dev = NULL; | ||
190 | |||
191 | fw_dev = pci_get_drvdata(pdev); | ||
192 | BUG_ON(fw_dev == NULL); | ||
193 | |||
194 | ricoh_mmc_enable(fw_dev); | ||
195 | |||
196 | pci_set_drvdata(pdev, NULL); | ||
197 | } | ||
198 | |||
199 | static int ricoh_mmc_suspend_late(struct pci_dev *pdev, pm_message_t state) | ||
200 | { | ||
201 | struct pci_dev *fw_dev = NULL; | ||
202 | |||
203 | fw_dev = pci_get_drvdata(pdev); | ||
204 | BUG_ON(fw_dev == NULL); | ||
205 | |||
206 | printk(KERN_INFO DRIVER_NAME ": Suspending.\n"); | ||
207 | |||
208 | ricoh_mmc_enable(fw_dev); | ||
209 | |||
210 | return 0; | ||
211 | } | ||
212 | |||
213 | static int ricoh_mmc_resume_early(struct pci_dev *pdev) | ||
214 | { | ||
215 | struct pci_dev *fw_dev = NULL; | ||
216 | |||
217 | fw_dev = pci_get_drvdata(pdev); | ||
218 | BUG_ON(fw_dev == NULL); | ||
219 | |||
220 | printk(KERN_INFO DRIVER_NAME ": Resuming.\n"); | ||
221 | |||
222 | ricoh_mmc_disable(fw_dev); | ||
223 | |||
224 | return 0; | ||
225 | } | ||
226 | |||
227 | static struct pci_driver ricoh_mmc_driver = { | ||
228 | .name = DRIVER_NAME, | ||
229 | .id_table = pci_ids, | ||
230 | .probe = ricoh_mmc_probe, | ||
231 | .remove = __devexit_p(ricoh_mmc_remove), | ||
232 | .suspend_late = ricoh_mmc_suspend_late, | ||
233 | .resume_early = ricoh_mmc_resume_early, | ||
234 | }; | ||
235 | |||
236 | /*****************************************************************************\ | ||
237 | * * | ||
238 | * Driver init/exit * | ||
239 | * * | ||
240 | \*****************************************************************************/ | ||
241 | |||
242 | static int __init ricoh_mmc_drv_init(void) | ||
243 | { | ||
244 | printk(KERN_INFO DRIVER_NAME | ||
245 | ": Ricoh MMC Controller disabling driver\n"); | ||
246 | printk(KERN_INFO DRIVER_NAME ": Copyright(c) Philip Langdale\n"); | ||
247 | |||
248 | return pci_register_driver(&ricoh_mmc_driver); | ||
249 | } | ||
250 | |||
251 | static void __exit ricoh_mmc_drv_exit(void) | ||
252 | { | ||
253 | pci_unregister_driver(&ricoh_mmc_driver); | ||
254 | } | ||
255 | |||
256 | module_init(ricoh_mmc_drv_init); | ||
257 | module_exit(ricoh_mmc_drv_exit); | ||
258 | |||
259 | MODULE_AUTHOR("Philip Langdale <philipl@alumni.utexas.net>"); | ||
260 | MODULE_DESCRIPTION("Ricoh MMC Controller disabling driver"); | ||
261 | MODULE_LICENSE("GPL"); | ||
262 | |||
diff --git a/drivers/mmc/host/s3cmci.c b/drivers/mmc/host/s3cmci.c index d96e1abf2d64..2fdf7689ae6c 100644 --- a/drivers/mmc/host/s3cmci.c +++ b/drivers/mmc/host/s3cmci.c | |||
@@ -1179,7 +1179,7 @@ static int s3cmci_card_present(struct mmc_host *mmc) | |||
1179 | struct s3c24xx_mci_pdata *pdata = host->pdata; | 1179 | struct s3c24xx_mci_pdata *pdata = host->pdata; |
1180 | int ret; | 1180 | int ret; |
1181 | 1181 | ||
1182 | if (pdata->gpio_detect == 0) | 1182 | if (pdata->no_detect) |
1183 | return -ENOSYS; | 1183 | return -ENOSYS; |
1184 | 1184 | ||
1185 | ret = gpio_get_value(pdata->gpio_detect) ? 0 : 1; | 1185 | ret = gpio_get_value(pdata->gpio_detect) ? 0 : 1; |
@@ -1360,6 +1360,8 @@ static struct mmc_host_ops s3cmci_ops = { | |||
1360 | static struct s3c24xx_mci_pdata s3cmci_def_pdata = { | 1360 | static struct s3c24xx_mci_pdata s3cmci_def_pdata = { |
1361 | /* This is currently here to avoid a number of if (host->pdata) | 1361 | /* This is currently here to avoid a number of if (host->pdata) |
1362 | * checks. Any zero fields to ensure reasonable defaults are picked. */ | 1362 | * checks. Any zero fields to ensure reasonable defaults are picked. */ |
1363 | .no_wprotect = 1, | ||
1364 | .no_detect = 1, | ||
1363 | }; | 1365 | }; |
1364 | 1366 | ||
1365 | #ifdef CONFIG_CPU_FREQ | 1367 | #ifdef CONFIG_CPU_FREQ |
diff --git a/drivers/mmc/host/sdhci-pci.c b/drivers/mmc/host/sdhci-pci.c index 5c3a1767770a..8e1020cf73f4 100644 --- a/drivers/mmc/host/sdhci-pci.c +++ b/drivers/mmc/host/sdhci-pci.c | |||
@@ -80,9 +80,6 @@ struct sdhci_pci_chip { | |||
80 | 80 | ||
81 | static int ricoh_probe(struct sdhci_pci_chip *chip) | 81 | static int ricoh_probe(struct sdhci_pci_chip *chip) |
82 | { | 82 | { |
83 | if (chip->pdev->subsystem_vendor == PCI_VENDOR_ID_IBM) | ||
84 | chip->quirks |= SDHCI_QUIRK_CLOCK_BEFORE_RESET; | ||
85 | |||
86 | if (chip->pdev->subsystem_vendor == PCI_VENDOR_ID_SAMSUNG || | 83 | if (chip->pdev->subsystem_vendor == PCI_VENDOR_ID_SAMSUNG || |
87 | chip->pdev->subsystem_vendor == PCI_VENDOR_ID_SONY) | 84 | chip->pdev->subsystem_vendor == PCI_VENDOR_ID_SONY) |
88 | chip->quirks |= SDHCI_QUIRK_NO_CARD_NO_RESET; | 85 | chip->quirks |= SDHCI_QUIRK_NO_CARD_NO_RESET; |
@@ -92,7 +89,9 @@ static int ricoh_probe(struct sdhci_pci_chip *chip) | |||
92 | 89 | ||
93 | static const struct sdhci_pci_fixes sdhci_ricoh = { | 90 | static const struct sdhci_pci_fixes sdhci_ricoh = { |
94 | .probe = ricoh_probe, | 91 | .probe = ricoh_probe, |
95 | .quirks = SDHCI_QUIRK_32BIT_DMA_ADDR, | 92 | .quirks = SDHCI_QUIRK_32BIT_DMA_ADDR | |
93 | SDHCI_QUIRK_FORCE_DMA | | ||
94 | SDHCI_QUIRK_CLOCK_BEFORE_RESET, | ||
96 | }; | 95 | }; |
97 | 96 | ||
98 | static const struct sdhci_pci_fixes sdhci_ene_712 = { | 97 | static const struct sdhci_pci_fixes sdhci_ene_712 = { |
@@ -501,6 +500,7 @@ static int sdhci_pci_suspend (struct pci_dev *pdev, pm_message_t state) | |||
501 | { | 500 | { |
502 | struct sdhci_pci_chip *chip; | 501 | struct sdhci_pci_chip *chip; |
503 | struct sdhci_pci_slot *slot; | 502 | struct sdhci_pci_slot *slot; |
503 | mmc_pm_flag_t pm_flags = 0; | ||
504 | int i, ret; | 504 | int i, ret; |
505 | 505 | ||
506 | chip = pci_get_drvdata(pdev); | 506 | chip = pci_get_drvdata(pdev); |
@@ -519,6 +519,8 @@ static int sdhci_pci_suspend (struct pci_dev *pdev, pm_message_t state) | |||
519 | sdhci_resume_host(chip->slots[i]->host); | 519 | sdhci_resume_host(chip->slots[i]->host); |
520 | return ret; | 520 | return ret; |
521 | } | 521 | } |
522 | |||
523 | pm_flags |= slot->host->mmc->pm_flags; | ||
522 | } | 524 | } |
523 | 525 | ||
524 | if (chip->fixes && chip->fixes->suspend) { | 526 | if (chip->fixes && chip->fixes->suspend) { |
@@ -531,9 +533,15 @@ static int sdhci_pci_suspend (struct pci_dev *pdev, pm_message_t state) | |||
531 | } | 533 | } |
532 | 534 | ||
533 | pci_save_state(pdev); | 535 | pci_save_state(pdev); |
534 | pci_enable_wake(pdev, pci_choose_state(pdev, state), 0); | 536 | if (pm_flags & MMC_PM_KEEP_POWER) { |
535 | pci_disable_device(pdev); | 537 | if (pm_flags & MMC_PM_WAKE_SDIO_IRQ) |
536 | pci_set_power_state(pdev, pci_choose_state(pdev, state)); | 538 | pci_enable_wake(pdev, PCI_D3hot, 1); |
539 | pci_set_power_state(pdev, PCI_D3hot); | ||
540 | } else { | ||
541 | pci_enable_wake(pdev, pci_choose_state(pdev, state), 0); | ||
542 | pci_disable_device(pdev); | ||
543 | pci_set_power_state(pdev, pci_choose_state(pdev, state)); | ||
544 | } | ||
537 | 545 | ||
538 | return 0; | 546 | return 0; |
539 | } | 547 | } |
@@ -653,6 +661,8 @@ static struct sdhci_pci_slot * __devinit sdhci_pci_probe_slot( | |||
653 | goto unmap; | 661 | goto unmap; |
654 | } | 662 | } |
655 | 663 | ||
664 | host->mmc->pm_caps = MMC_PM_KEEP_POWER | MMC_PM_WAKE_SDIO_IRQ; | ||
665 | |||
656 | ret = sdhci_add_host(host); | 666 | ret = sdhci_add_host(host); |
657 | if (ret) | 667 | if (ret) |
658 | goto remove; | 668 | goto remove; |
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index c279fbc4c2e5..d6ab62d539fb 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c | |||
@@ -174,20 +174,31 @@ static void sdhci_reset(struct sdhci_host *host, u8 mask) | |||
174 | sdhci_clear_set_irqs(host, SDHCI_INT_ALL_MASK, ier); | 174 | sdhci_clear_set_irqs(host, SDHCI_INT_ALL_MASK, ier); |
175 | } | 175 | } |
176 | 176 | ||
177 | static void sdhci_init(struct sdhci_host *host) | 177 | static void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios); |
178 | |||
179 | static void sdhci_init(struct sdhci_host *host, int soft) | ||
178 | { | 180 | { |
179 | sdhci_reset(host, SDHCI_RESET_ALL); | 181 | if (soft) |
182 | sdhci_reset(host, SDHCI_RESET_CMD|SDHCI_RESET_DATA); | ||
183 | else | ||
184 | sdhci_reset(host, SDHCI_RESET_ALL); | ||
180 | 185 | ||
181 | sdhci_clear_set_irqs(host, SDHCI_INT_ALL_MASK, | 186 | sdhci_clear_set_irqs(host, SDHCI_INT_ALL_MASK, |
182 | SDHCI_INT_BUS_POWER | SDHCI_INT_DATA_END_BIT | | 187 | SDHCI_INT_BUS_POWER | SDHCI_INT_DATA_END_BIT | |
183 | SDHCI_INT_DATA_CRC | SDHCI_INT_DATA_TIMEOUT | SDHCI_INT_INDEX | | 188 | SDHCI_INT_DATA_CRC | SDHCI_INT_DATA_TIMEOUT | SDHCI_INT_INDEX | |
184 | SDHCI_INT_END_BIT | SDHCI_INT_CRC | SDHCI_INT_TIMEOUT | | 189 | SDHCI_INT_END_BIT | SDHCI_INT_CRC | SDHCI_INT_TIMEOUT | |
185 | SDHCI_INT_DATA_END | SDHCI_INT_RESPONSE); | 190 | SDHCI_INT_DATA_END | SDHCI_INT_RESPONSE); |
191 | |||
192 | if (soft) { | ||
193 | /* force clock reconfiguration */ | ||
194 | host->clock = 0; | ||
195 | sdhci_set_ios(host->mmc, &host->mmc->ios); | ||
196 | } | ||
186 | } | 197 | } |
187 | 198 | ||
188 | static void sdhci_reinit(struct sdhci_host *host) | 199 | static void sdhci_reinit(struct sdhci_host *host) |
189 | { | 200 | { |
190 | sdhci_init(host); | 201 | sdhci_init(host, 0); |
191 | sdhci_enable_card_detection(host); | 202 | sdhci_enable_card_detection(host); |
192 | } | 203 | } |
193 | 204 | ||
@@ -376,6 +387,20 @@ static void sdhci_kunmap_atomic(void *buffer, unsigned long *flags) | |||
376 | local_irq_restore(*flags); | 387 | local_irq_restore(*flags); |
377 | } | 388 | } |
378 | 389 | ||
390 | static void sdhci_set_adma_desc(u8 *desc, u32 addr, int len, unsigned cmd) | ||
391 | { | ||
392 | __le32 *dataddr = (__le32 __force *)(desc + 4); | ||
393 | __le16 *cmdlen = (__le16 __force *)desc; | ||
394 | |||
395 | /* SDHCI specification says ADMA descriptors should be 4 byte | ||
396 | * aligned, so using 16 or 32bit operations should be safe. */ | ||
397 | |||
398 | cmdlen[0] = cpu_to_le16(cmd); | ||
399 | cmdlen[1] = cpu_to_le16(len); | ||
400 | |||
401 | dataddr[0] = cpu_to_le32(addr); | ||
402 | } | ||
403 | |||
379 | static int sdhci_adma_table_pre(struct sdhci_host *host, | 404 | static int sdhci_adma_table_pre(struct sdhci_host *host, |
380 | struct mmc_data *data) | 405 | struct mmc_data *data) |
381 | { | 406 | { |
@@ -443,19 +468,11 @@ static int sdhci_adma_table_pre(struct sdhci_host *host, | |||
443 | sdhci_kunmap_atomic(buffer, &flags); | 468 | sdhci_kunmap_atomic(buffer, &flags); |
444 | } | 469 | } |
445 | 470 | ||
446 | desc[7] = (align_addr >> 24) & 0xff; | 471 | /* tran, valid */ |
447 | desc[6] = (align_addr >> 16) & 0xff; | 472 | sdhci_set_adma_desc(desc, align_addr, offset, 0x21); |
448 | desc[5] = (align_addr >> 8) & 0xff; | ||
449 | desc[4] = (align_addr >> 0) & 0xff; | ||
450 | 473 | ||
451 | BUG_ON(offset > 65536); | 474 | BUG_ON(offset > 65536); |
452 | 475 | ||
453 | desc[3] = (offset >> 8) & 0xff; | ||
454 | desc[2] = (offset >> 0) & 0xff; | ||
455 | |||
456 | desc[1] = 0x00; | ||
457 | desc[0] = 0x21; /* tran, valid */ | ||
458 | |||
459 | align += 4; | 476 | align += 4; |
460 | align_addr += 4; | 477 | align_addr += 4; |
461 | 478 | ||
@@ -465,19 +482,10 @@ static int sdhci_adma_table_pre(struct sdhci_host *host, | |||
465 | len -= offset; | 482 | len -= offset; |
466 | } | 483 | } |
467 | 484 | ||
468 | desc[7] = (addr >> 24) & 0xff; | ||
469 | desc[6] = (addr >> 16) & 0xff; | ||
470 | desc[5] = (addr >> 8) & 0xff; | ||
471 | desc[4] = (addr >> 0) & 0xff; | ||
472 | |||
473 | BUG_ON(len > 65536); | 485 | BUG_ON(len > 65536); |
474 | 486 | ||
475 | desc[3] = (len >> 8) & 0xff; | 487 | /* tran, valid */ |
476 | desc[2] = (len >> 0) & 0xff; | 488 | sdhci_set_adma_desc(desc, addr, len, 0x21); |
477 | |||
478 | desc[1] = 0x00; | ||
479 | desc[0] = 0x21; /* tran, valid */ | ||
480 | |||
481 | desc += 8; | 489 | desc += 8; |
482 | 490 | ||
483 | /* | 491 | /* |
@@ -490,16 +498,9 @@ static int sdhci_adma_table_pre(struct sdhci_host *host, | |||
490 | /* | 498 | /* |
491 | * Add a terminating entry. | 499 | * Add a terminating entry. |
492 | */ | 500 | */ |
493 | desc[7] = 0; | ||
494 | desc[6] = 0; | ||
495 | desc[5] = 0; | ||
496 | desc[4] = 0; | ||
497 | 501 | ||
498 | desc[3] = 0; | 502 | /* nop, end, valid */ |
499 | desc[2] = 0; | 503 | sdhci_set_adma_desc(desc, 0, 0, 0x3); |
500 | |||
501 | desc[1] = 0x00; | ||
502 | desc[0] = 0x03; /* nop, end, valid */ | ||
503 | 504 | ||
504 | /* | 505 | /* |
505 | * Resync align buffer as we might have changed it. | 506 | * Resync align buffer as we might have changed it. |
@@ -1610,16 +1611,13 @@ int sdhci_resume_host(struct sdhci_host *host) | |||
1610 | if (ret) | 1611 | if (ret) |
1611 | return ret; | 1612 | return ret; |
1612 | 1613 | ||
1613 | sdhci_init(host); | 1614 | sdhci_init(host, (host->mmc->pm_flags & MMC_PM_KEEP_POWER)); |
1614 | mmiowb(); | 1615 | mmiowb(); |
1615 | 1616 | ||
1616 | ret = mmc_resume_host(host->mmc); | 1617 | ret = mmc_resume_host(host->mmc); |
1617 | if (ret) | ||
1618 | return ret; | ||
1619 | |||
1620 | sdhci_enable_card_detection(host); | 1618 | sdhci_enable_card_detection(host); |
1621 | 1619 | ||
1622 | return 0; | 1620 | return ret; |
1623 | } | 1621 | } |
1624 | 1622 | ||
1625 | EXPORT_SYMBOL_GPL(sdhci_resume_host); | 1623 | EXPORT_SYMBOL_GPL(sdhci_resume_host); |
@@ -1874,7 +1872,7 @@ int sdhci_add_host(struct sdhci_host *host) | |||
1874 | if (ret) | 1872 | if (ret) |
1875 | goto untasklet; | 1873 | goto untasklet; |
1876 | 1874 | ||
1877 | sdhci_init(host); | 1875 | sdhci_init(host, 0); |
1878 | 1876 | ||
1879 | #ifdef CONFIG_MMC_DEBUG | 1877 | #ifdef CONFIG_MMC_DEBUG |
1880 | sdhci_dumpregs(host); | 1878 | sdhci_dumpregs(host); |
diff --git a/drivers/mmc/host/tmio_mmc.c b/drivers/mmc/host/tmio_mmc.c index e22c3fa3516a..b2b577f6afd4 100644 --- a/drivers/mmc/host/tmio_mmc.c +++ b/drivers/mmc/host/tmio_mmc.c | |||
@@ -323,7 +323,7 @@ static irqreturn_t tmio_mmc_irq(int irq, void *devid) | |||
323 | if (ireg & (TMIO_STAT_CARD_INSERT | TMIO_STAT_CARD_REMOVE)) { | 323 | if (ireg & (TMIO_STAT_CARD_INSERT | TMIO_STAT_CARD_REMOVE)) { |
324 | ack_mmc_irqs(host, TMIO_STAT_CARD_INSERT | | 324 | ack_mmc_irqs(host, TMIO_STAT_CARD_INSERT | |
325 | TMIO_STAT_CARD_REMOVE); | 325 | TMIO_STAT_CARD_REMOVE); |
326 | mmc_detect_change(host->mmc, 0); | 326 | mmc_detect_change(host->mmc, msecs_to_jiffies(100)); |
327 | } | 327 | } |
328 | 328 | ||
329 | /* CRC and other errors */ | 329 | /* CRC and other errors */ |
@@ -550,6 +550,7 @@ static int __devinit tmio_mmc_probe(struct platform_device *dev) | |||
550 | 550 | ||
551 | mmc->ops = &tmio_mmc_ops; | 551 | mmc->ops = &tmio_mmc_ops; |
552 | mmc->caps = MMC_CAP_4_BIT_DATA; | 552 | mmc->caps = MMC_CAP_4_BIT_DATA; |
553 | mmc->caps |= pdata->capabilities; | ||
553 | mmc->f_max = pdata->hclk; | 554 | mmc->f_max = pdata->hclk; |
554 | mmc->f_min = mmc->f_max / 512; | 555 | mmc->f_min = mmc->f_max / 512; |
555 | mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34; | 556 | mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34; |
@@ -568,14 +569,14 @@ static int __devinit tmio_mmc_probe(struct platform_device *dev) | |||
568 | if (ret >= 0) | 569 | if (ret >= 0) |
569 | host->irq = ret; | 570 | host->irq = ret; |
570 | else | 571 | else |
571 | goto unmap_ctl; | 572 | goto cell_disable; |
572 | 573 | ||
573 | disable_mmc_irqs(host, TMIO_MASK_ALL); | 574 | disable_mmc_irqs(host, TMIO_MASK_ALL); |
574 | 575 | ||
575 | ret = request_irq(host->irq, tmio_mmc_irq, IRQF_DISABLED | | 576 | ret = request_irq(host->irq, tmio_mmc_irq, IRQF_DISABLED | |
576 | IRQF_TRIGGER_FALLING, dev_name(&dev->dev), host); | 577 | IRQF_TRIGGER_FALLING, dev_name(&dev->dev), host); |
577 | if (ret) | 578 | if (ret) |
578 | goto unmap_ctl; | 579 | goto cell_disable; |
579 | 580 | ||
580 | mmc_add_host(mmc); | 581 | mmc_add_host(mmc); |
581 | 582 | ||
@@ -587,6 +588,9 @@ static int __devinit tmio_mmc_probe(struct platform_device *dev) | |||
587 | 588 | ||
588 | return 0; | 589 | return 0; |
589 | 590 | ||
591 | cell_disable: | ||
592 | if (cell->disable) | ||
593 | cell->disable(dev); | ||
590 | unmap_ctl: | 594 | unmap_ctl: |
591 | iounmap(host->ctl); | 595 | iounmap(host->ctl); |
592 | host_free: | 596 | host_free: |
@@ -597,6 +601,7 @@ out: | |||
597 | 601 | ||
598 | static int __devexit tmio_mmc_remove(struct platform_device *dev) | 602 | static int __devexit tmio_mmc_remove(struct platform_device *dev) |
599 | { | 603 | { |
604 | struct mfd_cell *cell = (struct mfd_cell *)dev->dev.platform_data; | ||
600 | struct mmc_host *mmc = platform_get_drvdata(dev); | 605 | struct mmc_host *mmc = platform_get_drvdata(dev); |
601 | 606 | ||
602 | platform_set_drvdata(dev, NULL); | 607 | platform_set_drvdata(dev, NULL); |
@@ -605,6 +610,8 @@ static int __devexit tmio_mmc_remove(struct platform_device *dev) | |||
605 | struct tmio_mmc_host *host = mmc_priv(mmc); | 610 | struct tmio_mmc_host *host = mmc_priv(mmc); |
606 | mmc_remove_host(mmc); | 611 | mmc_remove_host(mmc); |
607 | free_irq(host->irq, host); | 612 | free_irq(host->irq, host); |
613 | if (cell->disable) | ||
614 | cell->disable(dev); | ||
608 | iounmap(host->ctl); | 615 | iounmap(host->ctl); |
609 | mmc_free_host(mmc); | 616 | mmc_free_host(mmc); |
610 | } | 617 | } |
diff --git a/drivers/mmc/host/tmio_mmc.h b/drivers/mmc/host/tmio_mmc.h index 692dc23363b9..dafecfbcd91a 100644 --- a/drivers/mmc/host/tmio_mmc.h +++ b/drivers/mmc/host/tmio_mmc.h | |||
@@ -55,10 +55,8 @@ | |||
55 | /* Define some IRQ masks */ | 55 | /* Define some IRQ masks */ |
56 | /* This is the mask used at reset by the chip */ | 56 | /* This is the mask used at reset by the chip */ |
57 | #define TMIO_MASK_ALL 0x837f031d | 57 | #define TMIO_MASK_ALL 0x837f031d |
58 | #define TMIO_MASK_READOP (TMIO_STAT_RXRDY | TMIO_STAT_DATAEND | \ | 58 | #define TMIO_MASK_READOP (TMIO_STAT_RXRDY | TMIO_STAT_DATAEND) |
59 | TMIO_STAT_CARD_REMOVE | TMIO_STAT_CARD_INSERT) | 59 | #define TMIO_MASK_WRITEOP (TMIO_STAT_TXRQ | TMIO_STAT_DATAEND) |
60 | #define TMIO_MASK_WRITEOP (TMIO_STAT_TXRQ | TMIO_STAT_DATAEND | \ | ||
61 | TMIO_STAT_CARD_REMOVE | TMIO_STAT_CARD_INSERT) | ||
62 | #define TMIO_MASK_CMD (TMIO_STAT_CMDRESPEND | TMIO_STAT_CMDTIMEOUT | \ | 60 | #define TMIO_MASK_CMD (TMIO_STAT_CMDRESPEND | TMIO_STAT_CMDTIMEOUT | \ |
63 | TMIO_STAT_CARD_REMOVE | TMIO_STAT_CARD_INSERT) | 61 | TMIO_STAT_CARD_REMOVE | TMIO_STAT_CARD_INSERT) |
64 | #define TMIO_MASK_IRQ (TMIO_MASK_READOP | TMIO_MASK_WRITEOP | TMIO_MASK_CMD) | 62 | #define TMIO_MASK_IRQ (TMIO_MASK_READOP | TMIO_MASK_WRITEOP | TMIO_MASK_CMD) |