1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25#include <linux/module.h>
26#include <linux/moduleparam.h>
27#include <linux/init.h>
28#include <linux/ioport.h>
29#include <linux/platform_device.h>
30#include <linux/interrupt.h>
31#include <linux/dma-mapping.h>
32#include <linux/delay.h>
33#include <linux/pnp.h>
34#include <linux/highmem.h>
35#include <linux/mmc/host.h>
36#include <linux/scatterlist.h>
37#include <linux/slab.h>
38
39#include <asm/io.h>
40#include <asm/dma.h>
41
42#include "wbsd.h"
43
44#define DRIVER_NAME "wbsd"
45
46#define DBG(x...) \
47 pr_debug(DRIVER_NAME ": " x)
48#define DBGF(f, x...) \
49 pr_debug(DRIVER_NAME " [%s()]: " f, __func__ , ##x)
50
51
52
53
54
55#ifdef CONFIG_PNP
56
57static const struct pnp_device_id pnp_dev_table[] = {
58 { "WEC0517", 0 },
59 { "WEC0518", 0 },
60 { "", 0 },
61};
62
63MODULE_DEVICE_TABLE(pnp, pnp_dev_table);
64
65#endif
66
67static const int config_ports[] = { 0x2E, 0x4E };
68static const int unlock_codes[] = { 0x83, 0x87 };
69
70static const int valid_ids[] = {
71 0x7112,
72};
73
74#ifdef CONFIG_PNP
75static unsigned int param_nopnp = 0;
76#else
77static const unsigned int param_nopnp = 1;
78#endif
79static unsigned int param_io = 0x248;
80static unsigned int param_irq = 6;
81static int param_dma = 2;
82
83
84
85
86
87static inline void wbsd_unlock_config(struct wbsd_host *host)
88{
89 BUG_ON(host->config == 0);
90
91 outb(host->unlock_code, host->config);
92 outb(host->unlock_code, host->config);
93}
94
95static inline void wbsd_lock_config(struct wbsd_host *host)
96{
97 BUG_ON(host->config == 0);
98
99 outb(LOCK_CODE, host->config);
100}
101
102static inline void wbsd_write_config(struct wbsd_host *host, u8 reg, u8 value)
103{
104 BUG_ON(host->config == 0);
105
106 outb(reg, host->config);
107 outb(value, host->config + 1);
108}
109
110static inline u8 wbsd_read_config(struct wbsd_host *host, u8 reg)
111{
112 BUG_ON(host->config == 0);
113
114 outb(reg, host->config);
115 return inb(host->config + 1);
116}
117
118static inline void wbsd_write_index(struct wbsd_host *host, u8 index, u8 value)
119{
120 outb(index, host->base + WBSD_IDXR);
121 outb(value, host->base + WBSD_DATAR);
122}
123
124static inline u8 wbsd_read_index(struct wbsd_host *host, u8 index)
125{
126 outb(index, host->base + WBSD_IDXR);
127 return inb(host->base + WBSD_DATAR);
128}
129
130
131
132
133
134static void wbsd_init_device(struct wbsd_host *host)
135{
136 u8 setup, ier;
137
138
139
140
141 setup = wbsd_read_index(host, WBSD_IDX_SETUP);
142 setup |= WBSD_FIFO_RESET | WBSD_SOFT_RESET;
143 wbsd_write_index(host, WBSD_IDX_SETUP, setup);
144
145
146
147
148 setup &= ~WBSD_DAT3_H;
149 wbsd_write_index(host, WBSD_IDX_SETUP, setup);
150 host->flags &= ~WBSD_FIGNORE_DETECT;
151
152
153
154
155 host->clk = wbsd_read_index(host, WBSD_IDX_CLK);
156
157
158
159
160 outb(WBSD_POWER_N, host->base + WBSD_CSR);
161
162
163
164
165 wbsd_write_index(host, WBSD_IDX_TAAC, 0x7F);
166
167
168
169
170 if (inb(host->base + WBSD_CSR) & WBSD_CARDPRESENT)
171 host->flags |= WBSD_FCARD_PRESENT;
172 else
173 host->flags &= ~WBSD_FCARD_PRESENT;
174
175
176
177
178 ier = 0;
179 ier |= WBSD_EINT_CARD;
180 ier |= WBSD_EINT_FIFO_THRE;
181 ier |= WBSD_EINT_CRC;
182 ier |= WBSD_EINT_TIMEOUT;
183 ier |= WBSD_EINT_TC;
184
185 outb(ier, host->base + WBSD_EIR);
186
187
188
189
190 inb(host->base + WBSD_ISR);
191}
192
193static void wbsd_reset(struct wbsd_host *host)
194{
195 u8 setup;
196
197 pr_err("%s: Resetting chip\n", mmc_hostname(host->mmc));
198
199
200
201
202 setup = wbsd_read_index(host, WBSD_IDX_SETUP);
203 setup |= WBSD_SOFT_RESET;
204 wbsd_write_index(host, WBSD_IDX_SETUP, setup);
205}
206
207static void wbsd_request_end(struct wbsd_host *host, struct mmc_request *mrq)
208{
209 unsigned long dmaflags;
210
211 if (host->dma >= 0) {
212
213
214
215 dmaflags = claim_dma_lock();
216 disable_dma(host->dma);
217 clear_dma_ff(host->dma);
218 release_dma_lock(dmaflags);
219
220
221
222
223 wbsd_write_index(host, WBSD_IDX_DMA, 0);
224 }
225
226 host->mrq = NULL;
227
228
229
230
231 spin_unlock(&host->lock);
232 mmc_request_done(host->mmc, mrq);
233 spin_lock(&host->lock);
234}
235
236
237
238
239
240static inline void wbsd_init_sg(struct wbsd_host *host, struct mmc_data *data)
241{
242
243
244
245 host->cur_sg = data->sg;
246 host->num_sg = data->sg_len;
247
248 host->offset = 0;
249 host->remain = host->cur_sg->length;
250}
251
252static inline int wbsd_next_sg(struct wbsd_host *host)
253{
254
255
256
257 host->cur_sg++;
258 host->num_sg--;
259
260
261
262
263 if (host->num_sg > 0) {
264 host->offset = 0;
265 host->remain = host->cur_sg->length;
266 }
267
268 return host->num_sg;
269}
270
271static inline char *wbsd_map_sg(struct wbsd_host *host)
272{
273 return kmap_atomic(sg_page(host->cur_sg)) + host->cur_sg->offset;
274}
275
276static inline void wbsd_sg_to_dma(struct wbsd_host *host, struct mmc_data *data)
277{
278 size_t len = 0;
279 int i;
280
281 for (i = 0; i < data->sg_len; i++)
282 len += data->sg[i].length;
283 sg_copy_to_buffer(data->sg, data->sg_len, host->dma_buffer, len);
284}
285
286static inline void wbsd_dma_to_sg(struct wbsd_host *host, struct mmc_data *data)
287{
288 size_t len = 0;
289 int i;
290
291 for (i = 0; i < data->sg_len; i++)
292 len += data->sg[i].length;
293 sg_copy_from_buffer(data->sg, data->sg_len, host->dma_buffer, len);
294}
295
296
297
298
299
300static inline void wbsd_get_short_reply(struct wbsd_host *host,
301 struct mmc_command *cmd)
302{
303
304
305
306 if (wbsd_read_index(host, WBSD_IDX_RSPLEN) != WBSD_RSP_SHORT) {
307 cmd->error = -EILSEQ;
308 return;
309 }
310
311 cmd->resp[0] = wbsd_read_index(host, WBSD_IDX_RESP12) << 24;
312 cmd->resp[0] |= wbsd_read_index(host, WBSD_IDX_RESP13) << 16;
313 cmd->resp[0] |= wbsd_read_index(host, WBSD_IDX_RESP14) << 8;
314 cmd->resp[0] |= wbsd_read_index(host, WBSD_IDX_RESP15) << 0;
315 cmd->resp[1] = wbsd_read_index(host, WBSD_IDX_RESP16) << 24;
316}
317
318static inline void wbsd_get_long_reply(struct wbsd_host *host,
319 struct mmc_command *cmd)
320{
321 int i;
322
323
324
325
326 if (wbsd_read_index(host, WBSD_IDX_RSPLEN) != WBSD_RSP_LONG) {
327 cmd->error = -EILSEQ;
328 return;
329 }
330
331 for (i = 0; i < 4; i++) {
332 cmd->resp[i] =
333 wbsd_read_index(host, WBSD_IDX_RESP1 + i * 4) << 24;
334 cmd->resp[i] |=
335 wbsd_read_index(host, WBSD_IDX_RESP2 + i * 4) << 16;
336 cmd->resp[i] |=
337 wbsd_read_index(host, WBSD_IDX_RESP3 + i * 4) << 8;
338 cmd->resp[i] |=
339 wbsd_read_index(host, WBSD_IDX_RESP4 + i * 4) << 0;
340 }
341}
342
343static void wbsd_send_command(struct wbsd_host *host, struct mmc_command *cmd)
344{
345 int i;
346 u8 status, isr;
347
348
349
350
351
352
353 host->isr = 0;
354
355
356
357
358 outb(cmd->opcode, host->base + WBSD_CMDR);
359 for (i = 3; i >= 0; i--)
360 outb((cmd->arg >> (i * 8)) & 0xff, host->base + WBSD_CMDR);
361
362 cmd->error = 0;
363
364
365
366
367 do {
368 status = wbsd_read_index(host, WBSD_IDX_STATUS);
369 } while (status & WBSD_CARDTRAFFIC);
370
371
372
373
374 if (cmd->flags & MMC_RSP_PRESENT) {
375
376
377
378 isr = host->isr;
379
380
381 if (isr & WBSD_INT_CARD)
382 cmd->error = -ENOMEDIUM;
383
384 else if (isr & WBSD_INT_TIMEOUT)
385 cmd->error = -ETIMEDOUT;
386
387 else if ((cmd->flags & MMC_RSP_CRC) && (isr & WBSD_INT_CRC))
388 cmd->error = -EILSEQ;
389
390 else {
391 if (cmd->flags & MMC_RSP_136)
392 wbsd_get_long_reply(host, cmd);
393 else
394 wbsd_get_short_reply(host, cmd);
395 }
396 }
397}
398
399
400
401
402
403static void wbsd_empty_fifo(struct wbsd_host *host)
404{
405 struct mmc_data *data = host->mrq->cmd->data;
406 char *buffer;
407 int i, idx, fsr, fifo;
408
409
410
411
412 if (host->num_sg == 0)
413 return;
414
415 buffer = wbsd_map_sg(host) + host->offset;
416 idx = 0;
417
418
419
420
421
422 while (!((fsr = inb(host->base + WBSD_FSR)) & WBSD_FIFO_EMPTY)) {
423
424
425
426
427 if (fsr & WBSD_FIFO_FULL)
428 fifo = 16;
429 else if (fsr & WBSD_FIFO_FUTHRE)
430 fifo = 8;
431 else
432 fifo = 1;
433
434 for (i = 0; i < fifo; i++) {
435 buffer[idx++] = inb(host->base + WBSD_DFR);
436 host->offset++;
437 host->remain--;
438
439 data->bytes_xfered++;
440
441
442
443
444 if (host->remain == 0) {
445 kunmap_atomic(buffer);
446
447
448
449 if (!wbsd_next_sg(host))
450 return;
451
452 buffer = wbsd_map_sg(host);
453 idx = 0;
454 }
455 }
456 }
457 kunmap_atomic(buffer);
458
459
460
461
462
463
464 if ((data->blocks * data->blksz - data->bytes_xfered) < 16)
465 tasklet_schedule(&host->fifo_tasklet);
466}
467
468static void wbsd_fill_fifo(struct wbsd_host *host)
469{
470 struct mmc_data *data = host->mrq->cmd->data;
471 char *buffer;
472 int i, idx, fsr, fifo;
473
474
475
476
477
478 if (host->num_sg == 0)
479 return;
480
481 buffer = wbsd_map_sg(host) + host->offset;
482 idx = 0;
483
484
485
486
487
488 while (!((fsr = inb(host->base + WBSD_FSR)) & WBSD_FIFO_FULL)) {
489
490
491
492
493 if (fsr & WBSD_FIFO_EMPTY)
494 fifo = 0;
495 else if (fsr & WBSD_FIFO_EMTHRE)
496 fifo = 8;
497 else
498 fifo = 15;
499
500 for (i = 16; i > fifo; i--) {
501 outb(buffer[idx], host->base + WBSD_DFR);
502 host->offset++;
503 host->remain--;
504
505 data->bytes_xfered++;
506
507
508
509
510 if (host->remain == 0) {
511 kunmap_atomic(buffer);
512
513
514
515 if (!wbsd_next_sg(host))
516 return;
517
518 buffer = wbsd_map_sg(host);
519 idx = 0;
520 }
521 }
522 }
523 kunmap_atomic(buffer);
524
525
526
527
528
529
530 tasklet_schedule(&host->fifo_tasklet);
531}
532
533static void wbsd_prepare_data(struct wbsd_host *host, struct mmc_data *data)
534{
535 u16 blksize;
536 u8 setup;
537 unsigned long dmaflags;
538 unsigned int size;
539
540
541
542
543 size = data->blocks * data->blksz;
544
545
546
547
548
549 if (data->timeout_ns > 127000000)
550 wbsd_write_index(host, WBSD_IDX_TAAC, 127);
551 else {
552 wbsd_write_index(host, WBSD_IDX_TAAC,
553 data->timeout_ns / 1000000);
554 }
555
556 if (data->timeout_clks > 255)
557 wbsd_write_index(host, WBSD_IDX_NSAC, 255);
558 else
559 wbsd_write_index(host, WBSD_IDX_NSAC, data->timeout_clks);
560
561
562
563
564
565
566
567
568
569 if (host->bus_width == MMC_BUS_WIDTH_1) {
570 blksize = data->blksz + 2;
571
572 wbsd_write_index(host, WBSD_IDX_PBSMSB, (blksize >> 4) & 0xF0);
573 wbsd_write_index(host, WBSD_IDX_PBSLSB, blksize & 0xFF);
574 } else if (host->bus_width == MMC_BUS_WIDTH_4) {
575 blksize = data->blksz + 2 * 4;
576
577 wbsd_write_index(host, WBSD_IDX_PBSMSB,
578 ((blksize >> 4) & 0xF0) | WBSD_DATA_WIDTH);
579 wbsd_write_index(host, WBSD_IDX_PBSLSB, blksize & 0xFF);
580 } else {
581 data->error = -EINVAL;
582 return;
583 }
584
585
586
587
588
589
590 setup = wbsd_read_index(host, WBSD_IDX_SETUP);
591 setup |= WBSD_FIFO_RESET;
592 wbsd_write_index(host, WBSD_IDX_SETUP, setup);
593
594
595
596
597 if (host->dma >= 0) {
598
599
600
601 BUG_ON(size > 0x10000);
602 if (size > 0x10000) {
603 data->error = -EINVAL;
604 return;
605 }
606
607
608
609
610
611 if (data->flags & MMC_DATA_WRITE)
612 wbsd_sg_to_dma(host, data);
613
614
615
616
617 dmaflags = claim_dma_lock();
618 disable_dma(host->dma);
619 clear_dma_ff(host->dma);
620 if (data->flags & MMC_DATA_READ)
621 set_dma_mode(host->dma, DMA_MODE_READ & ~0x40);
622 else
623 set_dma_mode(host->dma, DMA_MODE_WRITE & ~0x40);
624 set_dma_addr(host->dma, host->dma_addr);
625 set_dma_count(host->dma, size);
626
627 enable_dma(host->dma);
628 release_dma_lock(dmaflags);
629
630
631
632
633 wbsd_write_index(host, WBSD_IDX_DMA, WBSD_DMA_ENABLE);
634 } else {
635
636
637
638
639 host->firsterr = 1;
640
641
642
643
644 wbsd_init_sg(host, data);
645
646
647
648
649 wbsd_write_index(host, WBSD_IDX_DMA, 0);
650
651
652
653
654
655 if (data->flags & MMC_DATA_READ) {
656 wbsd_write_index(host, WBSD_IDX_FIFOEN,
657 WBSD_FIFOEN_FULL | 8);
658 } else {
659 wbsd_write_index(host, WBSD_IDX_FIFOEN,
660 WBSD_FIFOEN_EMPTY | 8);
661 wbsd_fill_fifo(host);
662 }
663 }
664
665 data->error = 0;
666}
667
668static void wbsd_finish_data(struct wbsd_host *host, struct mmc_data *data)
669{
670 unsigned long dmaflags;
671 int count;
672 u8 status;
673
674 WARN_ON(host->mrq == NULL);
675
676
677
678
679 if (data->stop)
680 wbsd_send_command(host, data->stop);
681
682
683
684
685
686 do {
687 status = wbsd_read_index(host, WBSD_IDX_STATUS);
688 } while (status & (WBSD_BLOCK_READ | WBSD_BLOCK_WRITE));
689
690
691
692
693 if (host->dma >= 0) {
694
695
696
697 wbsd_write_index(host, WBSD_IDX_DMA, 0);
698
699
700
701
702 dmaflags = claim_dma_lock();
703 disable_dma(host->dma);
704 clear_dma_ff(host->dma);
705 count = get_dma_residue(host->dma);
706 release_dma_lock(dmaflags);
707
708 data->bytes_xfered = host->mrq->data->blocks *
709 host->mrq->data->blksz - count;
710 data->bytes_xfered -= data->bytes_xfered % data->blksz;
711
712
713
714
715 if (count) {
716 pr_err("%s: Incomplete DMA transfer. "
717 "%d bytes left.\n",
718 mmc_hostname(host->mmc), count);
719
720 if (!data->error)
721 data->error = -EIO;
722 } else {
723
724
725
726
727 if (data->flags & MMC_DATA_READ)
728 wbsd_dma_to_sg(host, data);
729 }
730
731 if (data->error) {
732 if (data->bytes_xfered)
733 data->bytes_xfered -= data->blksz;
734 }
735 }
736
737 wbsd_request_end(host, host->mrq);
738}
739
740
741
742
743
744
745
746static void wbsd_request(struct mmc_host *mmc, struct mmc_request *mrq)
747{
748 struct wbsd_host *host = mmc_priv(mmc);
749 struct mmc_command *cmd;
750
751
752
753
754 spin_lock_bh(&host->lock);
755
756 BUG_ON(host->mrq != NULL);
757
758 cmd = mrq->cmd;
759
760 host->mrq = mrq;
761
762
763
764
765 if (!(host->flags & WBSD_FCARD_PRESENT)) {
766 cmd->error = -ENOMEDIUM;
767 goto done;
768 }
769
770 if (cmd->data) {
771
772
773
774
775
776
777 switch (cmd->opcode) {
778 case 11:
779 case 17:
780 case 18:
781 case 20:
782 case 24:
783 case 25:
784 case 26:
785 case 27:
786 case 30:
787 case 42:
788 case 56:
789 break;
790
791
792
793 case 51:
794 break;
795
796 default:
797 pr_warn("%s: Data command %d is not supported by this controller\n",
798 mmc_hostname(host->mmc), cmd->opcode);
799 cmd->error = -EINVAL;
800
801 goto done;
802 }
803 }
804
805
806
807
808 if (cmd->data) {
809 wbsd_prepare_data(host, cmd->data);
810
811 if (cmd->data->error)
812 goto done;
813 }
814
815 wbsd_send_command(host, cmd);
816
817
818
819
820
821
822 if (cmd->data && !cmd->error) {
823
824
825
826 if (host->dma == -1)
827 tasklet_schedule(&host->fifo_tasklet);
828
829 spin_unlock_bh(&host->lock);
830
831 return;
832 }
833
834done:
835 wbsd_request_end(host, mrq);
836
837 spin_unlock_bh(&host->lock);
838}
839
840static void wbsd_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
841{
842 struct wbsd_host *host = mmc_priv(mmc);
843 u8 clk, setup, pwr;
844
845 spin_lock_bh(&host->lock);
846
847
848
849
850
851 if (ios->power_mode == MMC_POWER_OFF)
852 wbsd_init_device(host);
853
854 if (ios->clock >= 24000000)
855 clk = WBSD_CLK_24M;
856 else if (ios->clock >= 16000000)
857 clk = WBSD_CLK_16M;
858 else if (ios->clock >= 12000000)
859 clk = WBSD_CLK_12M;
860 else
861 clk = WBSD_CLK_375K;
862
863
864
865
866
867 if (clk != host->clk) {
868 wbsd_write_index(host, WBSD_IDX_CLK, clk);
869 host->clk = clk;
870 }
871
872
873
874
875 if (ios->power_mode != MMC_POWER_OFF) {
876 pwr = inb(host->base + WBSD_CSR);
877 pwr &= ~WBSD_POWER_N;
878 outb(pwr, host->base + WBSD_CSR);
879 }
880
881
882
883
884
885
886 setup = wbsd_read_index(host, WBSD_IDX_SETUP);
887 if (ios->chip_select == MMC_CS_HIGH) {
888 BUG_ON(ios->bus_width != MMC_BUS_WIDTH_1);
889 setup |= WBSD_DAT3_H;
890 host->flags |= WBSD_FIGNORE_DETECT;
891 } else {
892 if (setup & WBSD_DAT3_H) {
893 setup &= ~WBSD_DAT3_H;
894
895
896
897
898
899 mod_timer(&host->ignore_timer, jiffies + HZ / 100);
900 }
901 }
902 wbsd_write_index(host, WBSD_IDX_SETUP, setup);
903
904
905
906
907
908 host->bus_width = ios->bus_width;
909
910 spin_unlock_bh(&host->lock);
911}
912
913static int wbsd_get_ro(struct mmc_host *mmc)
914{
915 struct wbsd_host *host = mmc_priv(mmc);
916 u8 csr;
917
918 spin_lock_bh(&host->lock);
919
920 csr = inb(host->base + WBSD_CSR);
921 csr |= WBSD_MSLED;
922 outb(csr, host->base + WBSD_CSR);
923
924 mdelay(1);
925
926 csr = inb(host->base + WBSD_CSR);
927 csr &= ~WBSD_MSLED;
928 outb(csr, host->base + WBSD_CSR);
929
930 spin_unlock_bh(&host->lock);
931
932 return !!(csr & WBSD_WRPT);
933}
934
935static const struct mmc_host_ops wbsd_ops = {
936 .request = wbsd_request,
937 .set_ios = wbsd_set_ios,
938 .get_ro = wbsd_get_ro,
939};
940
941
942
943
944
945
946
947
948
949
950
951static void wbsd_reset_ignore(struct timer_list *t)
952{
953 struct wbsd_host *host = from_timer(host, t, ignore_timer);
954
955 BUG_ON(host == NULL);
956
957 DBG("Resetting card detection ignore\n");
958
959 spin_lock_bh(&host->lock);
960
961 host->flags &= ~WBSD_FIGNORE_DETECT;
962
963
964
965
966
967 tasklet_schedule(&host->card_tasklet);
968
969 spin_unlock_bh(&host->lock);
970}
971
972
973
974
975
976static inline struct mmc_data *wbsd_get_data(struct wbsd_host *host)
977{
978 WARN_ON(!host->mrq);
979 if (!host->mrq)
980 return NULL;
981
982 WARN_ON(!host->mrq->cmd);
983 if (!host->mrq->cmd)
984 return NULL;
985
986 WARN_ON(!host->mrq->cmd->data);
987 if (!host->mrq->cmd->data)
988 return NULL;
989
990 return host->mrq->cmd->data;
991}
992
993static void wbsd_tasklet_card(unsigned long param)
994{
995 struct wbsd_host *host = (struct wbsd_host *)param;
996 u8 csr;
997 int delay = -1;
998
999 spin_lock(&host->lock);
1000
1001 if (host->flags & WBSD_FIGNORE_DETECT) {
1002 spin_unlock(&host->lock);
1003 return;
1004 }
1005
1006 csr = inb(host->base + WBSD_CSR);
1007 WARN_ON(csr == 0xff);
1008
1009 if (csr & WBSD_CARDPRESENT) {
1010 if (!(host->flags & WBSD_FCARD_PRESENT)) {
1011 DBG("Card inserted\n");
1012 host->flags |= WBSD_FCARD_PRESENT;
1013
1014 delay = 500;
1015 }
1016 } else if (host->flags & WBSD_FCARD_PRESENT) {
1017 DBG("Card removed\n");
1018 host->flags &= ~WBSD_FCARD_PRESENT;
1019
1020 if (host->mrq) {
1021 pr_err("%s: Card removed during transfer!\n",
1022 mmc_hostname(host->mmc));
1023 wbsd_reset(host);
1024
1025 host->mrq->cmd->error = -ENOMEDIUM;
1026 tasklet_schedule(&host->finish_tasklet);
1027 }
1028
1029 delay = 0;
1030 }
1031
1032
1033
1034
1035
1036 spin_unlock(&host->lock);
1037
1038 if (delay != -1)
1039 mmc_detect_change(host->mmc, msecs_to_jiffies(delay));
1040}
1041
1042static void wbsd_tasklet_fifo(unsigned long param)
1043{
1044 struct wbsd_host *host = (struct wbsd_host *)param;
1045 struct mmc_data *data;
1046
1047 spin_lock(&host->lock);
1048
1049 if (!host->mrq)
1050 goto end;
1051
1052 data = wbsd_get_data(host);
1053 if (!data)
1054 goto end;
1055
1056 if (data->flags & MMC_DATA_WRITE)
1057 wbsd_fill_fifo(host);
1058 else
1059 wbsd_empty_fifo(host);
1060
1061
1062
1063
1064 if (host->num_sg == 0) {
1065 wbsd_write_index(host, WBSD_IDX_FIFOEN, 0);
1066 tasklet_schedule(&host->finish_tasklet);
1067 }
1068
1069end:
1070 spin_unlock(&host->lock);
1071}
1072
1073static void wbsd_tasklet_crc(unsigned long param)
1074{
1075 struct wbsd_host *host = (struct wbsd_host *)param;
1076 struct mmc_data *data;
1077
1078 spin_lock(&host->lock);
1079
1080 if (!host->mrq)
1081 goto end;
1082
1083 data = wbsd_get_data(host);
1084 if (!data)
1085 goto end;
1086
1087 DBGF("CRC error\n");
1088
1089 data->error = -EILSEQ;
1090
1091 tasklet_schedule(&host->finish_tasklet);
1092
1093end:
1094 spin_unlock(&host->lock);
1095}
1096
1097static void wbsd_tasklet_timeout(unsigned long param)
1098{
1099 struct wbsd_host *host = (struct wbsd_host *)param;
1100 struct mmc_data *data;
1101
1102 spin_lock(&host->lock);
1103
1104 if (!host->mrq)
1105 goto end;
1106
1107 data = wbsd_get_data(host);
1108 if (!data)
1109 goto end;
1110
1111 DBGF("Timeout\n");
1112
1113 data->error = -ETIMEDOUT;
1114
1115 tasklet_schedule(&host->finish_tasklet);
1116
1117end:
1118 spin_unlock(&host->lock);
1119}
1120
1121static void wbsd_tasklet_finish(unsigned long param)
1122{
1123 struct wbsd_host *host = (struct wbsd_host *)param;
1124 struct mmc_data *data;
1125
1126 spin_lock(&host->lock);
1127
1128 WARN_ON(!host->mrq);
1129 if (!host->mrq)
1130 goto end;
1131
1132 data = wbsd_get_data(host);
1133 if (!data)
1134 goto end;
1135
1136 wbsd_finish_data(host, data);
1137
1138end:
1139 spin_unlock(&host->lock);
1140}
1141
1142
1143
1144
1145
1146static irqreturn_t wbsd_irq(int irq, void *dev_id)
1147{
1148 struct wbsd_host *host = dev_id;
1149 int isr;
1150
1151 isr = inb(host->base + WBSD_ISR);
1152
1153
1154
1155
1156 if (isr == 0xff || isr == 0x00)
1157 return IRQ_NONE;
1158
1159 host->isr |= isr;
1160
1161
1162
1163
1164 if (isr & WBSD_INT_CARD)
1165 tasklet_schedule(&host->card_tasklet);
1166 if (isr & WBSD_INT_FIFO_THRE)
1167 tasklet_schedule(&host->fifo_tasklet);
1168 if (isr & WBSD_INT_CRC)
1169 tasklet_hi_schedule(&host->crc_tasklet);
1170 if (isr & WBSD_INT_TIMEOUT)
1171 tasklet_hi_schedule(&host->timeout_tasklet);
1172 if (isr & WBSD_INT_TC)
1173 tasklet_schedule(&host->finish_tasklet);
1174
1175 return IRQ_HANDLED;
1176}
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188static int wbsd_alloc_mmc(struct device *dev)
1189{
1190 struct mmc_host *mmc;
1191 struct wbsd_host *host;
1192
1193
1194
1195
1196 mmc = mmc_alloc_host(sizeof(struct wbsd_host), dev);
1197 if (!mmc)
1198 return -ENOMEM;
1199
1200 host = mmc_priv(mmc);
1201 host->mmc = mmc;
1202
1203 host->dma = -1;
1204
1205
1206
1207
1208 mmc->ops = &wbsd_ops;
1209 mmc->f_min = 375000;
1210 mmc->f_max = 24000000;
1211 mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34;
1212 mmc->caps = MMC_CAP_4_BIT_DATA;
1213
1214 spin_lock_init(&host->lock);
1215
1216
1217
1218
1219 timer_setup(&host->ignore_timer, wbsd_reset_ignore, 0);
1220
1221
1222
1223
1224
1225 mmc->max_segs = 128;
1226
1227
1228
1229
1230 mmc->max_req_size = 65536;
1231
1232
1233
1234
1235
1236 mmc->max_seg_size = mmc->max_req_size;
1237
1238
1239
1240
1241
1242 mmc->max_blk_size = 4087;
1243
1244
1245
1246
1247
1248 mmc->max_blk_count = mmc->max_req_size;
1249
1250 dev_set_drvdata(dev, mmc);
1251
1252 return 0;
1253}
1254
1255static void wbsd_free_mmc(struct device *dev)
1256{
1257 struct mmc_host *mmc;
1258 struct wbsd_host *host;
1259
1260 mmc = dev_get_drvdata(dev);
1261 if (!mmc)
1262 return;
1263
1264 host = mmc_priv(mmc);
1265 BUG_ON(host == NULL);
1266
1267 del_timer_sync(&host->ignore_timer);
1268
1269 mmc_free_host(mmc);
1270
1271 dev_set_drvdata(dev, NULL);
1272}
1273
1274
1275
1276
1277
1278static int wbsd_scan(struct wbsd_host *host)
1279{
1280 int i, j, k;
1281 int id;
1282
1283
1284
1285
1286
1287 for (i = 0; i < ARRAY_SIZE(config_ports); i++) {
1288 if (!request_region(config_ports[i], 2, DRIVER_NAME))
1289 continue;
1290
1291 for (j = 0; j < ARRAY_SIZE(unlock_codes); j++) {
1292 id = 0xFFFF;
1293
1294 host->config = config_ports[i];
1295 host->unlock_code = unlock_codes[j];
1296
1297 wbsd_unlock_config(host);
1298
1299 outb(WBSD_CONF_ID_HI, config_ports[i]);
1300 id = inb(config_ports[i] + 1) << 8;
1301
1302 outb(WBSD_CONF_ID_LO, config_ports[i]);
1303 id |= inb(config_ports[i] + 1);
1304
1305 wbsd_lock_config(host);
1306
1307 for (k = 0; k < ARRAY_SIZE(valid_ids); k++) {
1308 if (id == valid_ids[k]) {
1309 host->chip_id = id;
1310
1311 return 0;
1312 }
1313 }
1314
1315 if (id != 0xFFFF) {
1316 DBG("Unknown hardware (id %x) found at %x\n",
1317 id, config_ports[i]);
1318 }
1319 }
1320
1321 release_region(config_ports[i], 2);
1322 }
1323
1324 host->config = 0;
1325 host->unlock_code = 0;
1326
1327 return -ENODEV;
1328}
1329
1330
1331
1332
1333
1334static int wbsd_request_region(struct wbsd_host *host, int base)
1335{
1336 if (base & 0x7)
1337 return -EINVAL;
1338
1339 if (!request_region(base, 8, DRIVER_NAME))
1340 return -EIO;
1341
1342 host->base = base;
1343
1344 return 0;
1345}
1346
1347static void wbsd_release_regions(struct wbsd_host *host)
1348{
1349 if (host->base)
1350 release_region(host->base, 8);
1351
1352 host->base = 0;
1353
1354 if (host->config)
1355 release_region(host->config, 2);
1356
1357 host->config = 0;
1358}
1359
1360
1361
1362
1363
1364static void wbsd_request_dma(struct wbsd_host *host, int dma)
1365{
1366 if (dma < 0)
1367 return;
1368
1369 if (request_dma(dma, DRIVER_NAME))
1370 goto err;
1371
1372
1373
1374
1375
1376 host->dma_buffer = kmalloc(WBSD_DMA_SIZE,
1377 GFP_NOIO | GFP_DMA | __GFP_RETRY_MAYFAIL | __GFP_NOWARN);
1378 if (!host->dma_buffer)
1379 goto free;
1380
1381
1382
1383
1384 host->dma_addr = dma_map_single(mmc_dev(host->mmc), host->dma_buffer,
1385 WBSD_DMA_SIZE, DMA_BIDIRECTIONAL);
1386 if (dma_mapping_error(mmc_dev(host->mmc), host->dma_addr))
1387 goto kfree;
1388
1389
1390
1391
1392 if ((host->dma_addr & 0xffff) != 0)
1393 goto unmap;
1394
1395
1396
1397 else if (host->dma_addr >= 0x1000000)
1398 goto unmap;
1399
1400 host->dma = dma;
1401
1402 return;
1403
1404unmap:
1405
1406
1407
1408 BUG_ON(1);
1409
1410 dma_unmap_single(mmc_dev(host->mmc), host->dma_addr,
1411 WBSD_DMA_SIZE, DMA_BIDIRECTIONAL);
1412 host->dma_addr = 0;
1413
1414kfree:
1415 kfree(host->dma_buffer);
1416 host->dma_buffer = NULL;
1417
1418free:
1419 free_dma(dma);
1420
1421err:
1422 pr_warn(DRIVER_NAME ": Unable to allocate DMA %d - falling back on FIFO\n",
1423 dma);
1424}
1425
1426static void wbsd_release_dma(struct wbsd_host *host)
1427{
1428
1429
1430
1431 if (host->dma_buffer) {
1432 dma_unmap_single(mmc_dev(host->mmc), host->dma_addr,
1433 WBSD_DMA_SIZE, DMA_BIDIRECTIONAL);
1434 kfree(host->dma_buffer);
1435 }
1436 if (host->dma >= 0)
1437 free_dma(host->dma);
1438
1439 host->dma = -1;
1440 host->dma_buffer = NULL;
1441 host->dma_addr = 0;
1442}
1443
1444
1445
1446
1447
1448static int wbsd_request_irq(struct wbsd_host *host, int irq)
1449{
1450 int ret;
1451
1452
1453
1454
1455 tasklet_init(&host->card_tasklet, wbsd_tasklet_card,
1456 (unsigned long)host);
1457 tasklet_init(&host->fifo_tasklet, wbsd_tasklet_fifo,
1458 (unsigned long)host);
1459 tasklet_init(&host->crc_tasklet, wbsd_tasklet_crc,
1460 (unsigned long)host);
1461 tasklet_init(&host->timeout_tasklet, wbsd_tasklet_timeout,
1462 (unsigned long)host);
1463 tasklet_init(&host->finish_tasklet, wbsd_tasklet_finish,
1464 (unsigned long)host);
1465
1466
1467
1468
1469 ret = request_irq(irq, wbsd_irq, IRQF_SHARED, DRIVER_NAME, host);
1470 if (ret)
1471 return ret;
1472
1473 host->irq = irq;
1474
1475 return 0;
1476}
1477
1478static void wbsd_release_irq(struct wbsd_host *host)
1479{
1480 if (!host->irq)
1481 return;
1482
1483 free_irq(host->irq, host);
1484
1485 host->irq = 0;
1486
1487 tasklet_kill(&host->card_tasklet);
1488 tasklet_kill(&host->fifo_tasklet);
1489 tasklet_kill(&host->crc_tasklet);
1490 tasklet_kill(&host->timeout_tasklet);
1491 tasklet_kill(&host->finish_tasklet);
1492}
1493
1494
1495
1496
1497
1498static int wbsd_request_resources(struct wbsd_host *host,
1499 int base, int irq, int dma)
1500{
1501 int ret;
1502
1503
1504
1505
1506 ret = wbsd_request_region(host, base);
1507 if (ret)
1508 return ret;
1509
1510
1511
1512
1513 ret = wbsd_request_irq(host, irq);
1514 if (ret)
1515 return ret;
1516
1517
1518
1519
1520 wbsd_request_dma(host, dma);
1521
1522 return 0;
1523}
1524
1525
1526
1527
1528
1529static void wbsd_release_resources(struct wbsd_host *host)
1530{
1531 wbsd_release_dma(host);
1532 wbsd_release_irq(host);
1533 wbsd_release_regions(host);
1534}
1535
1536
1537
1538
1539
1540static void wbsd_chip_config(struct wbsd_host *host)
1541{
1542 wbsd_unlock_config(host);
1543
1544
1545
1546
1547 wbsd_write_config(host, WBSD_CONF_SWRST, 1);
1548 wbsd_write_config(host, WBSD_CONF_SWRST, 0);
1549
1550
1551
1552
1553 wbsd_write_config(host, WBSD_CONF_DEVICE, DEVICE_SD);
1554
1555
1556
1557
1558 wbsd_write_config(host, WBSD_CONF_PINS, WBSD_PINS_DETECT_GP11);
1559
1560
1561
1562
1563 wbsd_write_config(host, WBSD_CONF_PORT_HI, host->base >> 8);
1564 wbsd_write_config(host, WBSD_CONF_PORT_LO, host->base & 0xff);
1565
1566 wbsd_write_config(host, WBSD_CONF_IRQ, host->irq);
1567
1568 if (host->dma >= 0)
1569 wbsd_write_config(host, WBSD_CONF_DRQ, host->dma);
1570
1571
1572
1573
1574 wbsd_write_config(host, WBSD_CONF_ENABLE, 1);
1575 wbsd_write_config(host, WBSD_CONF_POWER, 0x20);
1576
1577 wbsd_lock_config(host);
1578}
1579
1580
1581
1582
1583
1584static int wbsd_chip_validate(struct wbsd_host *host)
1585{
1586 int base, irq, dma;
1587
1588 wbsd_unlock_config(host);
1589
1590
1591
1592
1593 wbsd_write_config(host, WBSD_CONF_DEVICE, DEVICE_SD);
1594
1595
1596
1597
1598 base = wbsd_read_config(host, WBSD_CONF_PORT_HI) << 8;
1599 base |= wbsd_read_config(host, WBSD_CONF_PORT_LO);
1600
1601 irq = wbsd_read_config(host, WBSD_CONF_IRQ);
1602
1603 dma = wbsd_read_config(host, WBSD_CONF_DRQ);
1604
1605 wbsd_lock_config(host);
1606
1607
1608
1609
1610 if (base != host->base)
1611 return 0;
1612 if (irq != host->irq)
1613 return 0;
1614 if ((dma != host->dma) && (host->dma != -1))
1615 return 0;
1616
1617 return 1;
1618}
1619
1620
1621
1622
1623
1624static void wbsd_chip_poweroff(struct wbsd_host *host)
1625{
1626 wbsd_unlock_config(host);
1627
1628 wbsd_write_config(host, WBSD_CONF_DEVICE, DEVICE_SD);
1629 wbsd_write_config(host, WBSD_CONF_ENABLE, 0);
1630
1631 wbsd_lock_config(host);
1632}
1633
1634
1635
1636
1637
1638
1639
1640static int wbsd_init(struct device *dev, int base, int irq, int dma,
1641 int pnp)
1642{
1643 struct wbsd_host *host = NULL;
1644 struct mmc_host *mmc = NULL;
1645 int ret;
1646
1647 ret = wbsd_alloc_mmc(dev);
1648 if (ret)
1649 return ret;
1650
1651 mmc = dev_get_drvdata(dev);
1652 host = mmc_priv(mmc);
1653
1654
1655
1656
1657 ret = wbsd_scan(host);
1658 if (ret) {
1659 if (pnp && (ret == -ENODEV)) {
1660 pr_warn(DRIVER_NAME ": Unable to confirm device presence - you may experience lock-ups\n");
1661 } else {
1662 wbsd_free_mmc(dev);
1663 return ret;
1664 }
1665 }
1666
1667
1668
1669
1670 ret = wbsd_request_resources(host, base, irq, dma);
1671 if (ret) {
1672 wbsd_release_resources(host);
1673 wbsd_free_mmc(dev);
1674 return ret;
1675 }
1676
1677
1678
1679
1680 if (pnp) {
1681 if ((host->config != 0) && !wbsd_chip_validate(host)) {
1682 pr_warn(DRIVER_NAME ": PnP active but chip not configured! You probably have a buggy BIOS. Configuring chip manually.\n");
1683 wbsd_chip_config(host);
1684 }
1685 } else
1686 wbsd_chip_config(host);
1687
1688
1689
1690
1691
1692#ifdef CONFIG_PM
1693 if (host->config) {
1694 wbsd_unlock_config(host);
1695 wbsd_write_config(host, WBSD_CONF_PME, 0xA0);
1696 wbsd_lock_config(host);
1697 }
1698#endif
1699
1700
1701
1702 mdelay(5);
1703
1704
1705
1706
1707 wbsd_init_device(host);
1708
1709 mmc_add_host(mmc);
1710
1711 pr_info("%s: W83L51xD", mmc_hostname(mmc));
1712 if (host->chip_id != 0)
1713 printk(" id %x", (int)host->chip_id);
1714 printk(" at 0x%x irq %d", (int)host->base, (int)host->irq);
1715 if (host->dma >= 0)
1716 printk(" dma %d", (int)host->dma);
1717 else
1718 printk(" FIFO");
1719 if (pnp)
1720 printk(" PnP");
1721 printk("\n");
1722
1723 return 0;
1724}
1725
1726static void wbsd_shutdown(struct device *dev, int pnp)
1727{
1728 struct mmc_host *mmc = dev_get_drvdata(dev);
1729 struct wbsd_host *host;
1730
1731 if (!mmc)
1732 return;
1733
1734 host = mmc_priv(mmc);
1735
1736 mmc_remove_host(mmc);
1737
1738
1739
1740
1741 if (!pnp)
1742 wbsd_chip_poweroff(host);
1743
1744 wbsd_release_resources(host);
1745
1746 wbsd_free_mmc(dev);
1747}
1748
1749
1750
1751
1752
1753static int wbsd_probe(struct platform_device *dev)
1754{
1755
1756 return wbsd_init(&dev->dev, param_io, param_irq, param_dma, 0);
1757}
1758
1759static int wbsd_remove(struct platform_device *dev)
1760{
1761 wbsd_shutdown(&dev->dev, 0);
1762
1763 return 0;
1764}
1765
1766
1767
1768
1769
1770#ifdef CONFIG_PNP
1771
1772static int
1773wbsd_pnp_probe(struct pnp_dev *pnpdev, const struct pnp_device_id *dev_id)
1774{
1775 int io, irq, dma;
1776
1777
1778
1779
1780 io = pnp_port_start(pnpdev, 0);
1781 irq = pnp_irq(pnpdev, 0);
1782 if (pnp_dma_valid(pnpdev, 0))
1783 dma = pnp_dma(pnpdev, 0);
1784 else
1785 dma = -1;
1786
1787 DBGF("PnP resources: port %3x irq %d dma %d\n", io, irq, dma);
1788
1789 return wbsd_init(&pnpdev->dev, io, irq, dma, 1);
1790}
1791
1792static void wbsd_pnp_remove(struct pnp_dev *dev)
1793{
1794 wbsd_shutdown(&dev->dev, 1);
1795}
1796
1797#endif
1798
1799
1800
1801
1802
1803#ifdef CONFIG_PM
1804
1805static int wbsd_platform_suspend(struct platform_device *dev,
1806 pm_message_t state)
1807{
1808 struct mmc_host *mmc = platform_get_drvdata(dev);
1809 struct wbsd_host *host;
1810
1811 if (mmc == NULL)
1812 return 0;
1813
1814 DBGF("Suspending...\n");
1815
1816 host = mmc_priv(mmc);
1817
1818 wbsd_chip_poweroff(host);
1819 return 0;
1820}
1821
1822static int wbsd_platform_resume(struct platform_device *dev)
1823{
1824 struct mmc_host *mmc = platform_get_drvdata(dev);
1825 struct wbsd_host *host;
1826
1827 if (mmc == NULL)
1828 return 0;
1829
1830 DBGF("Resuming...\n");
1831
1832 host = mmc_priv(mmc);
1833
1834 wbsd_chip_config(host);
1835
1836
1837
1838
1839 mdelay(5);
1840
1841 wbsd_init_device(host);
1842 return 0;
1843}
1844
1845#ifdef CONFIG_PNP
1846
1847static int wbsd_pnp_suspend(struct pnp_dev *pnp_dev, pm_message_t state)
1848{
1849 struct mmc_host *mmc = dev_get_drvdata(&pnp_dev->dev);
1850
1851 if (mmc == NULL)
1852 return 0;
1853
1854 DBGF("Suspending...\n");
1855 return 0;
1856}
1857
1858static int wbsd_pnp_resume(struct pnp_dev *pnp_dev)
1859{
1860 struct mmc_host *mmc = dev_get_drvdata(&pnp_dev->dev);
1861 struct wbsd_host *host;
1862
1863 if (mmc == NULL)
1864 return 0;
1865
1866 DBGF("Resuming...\n");
1867
1868 host = mmc_priv(mmc);
1869
1870
1871
1872
1873 if (host->config != 0) {
1874 if (!wbsd_chip_validate(host)) {
1875 pr_warn(DRIVER_NAME ": PnP active but chip not configured! You probably have a buggy BIOS. Configuring chip manually.\n");
1876 wbsd_chip_config(host);
1877 }
1878 }
1879
1880
1881
1882
1883 mdelay(5);
1884
1885 wbsd_init_device(host);
1886 return 0;
1887}
1888
1889#endif
1890
1891#else
1892
1893#define wbsd_platform_suspend NULL
1894#define wbsd_platform_resume NULL
1895
1896#define wbsd_pnp_suspend NULL
1897#define wbsd_pnp_resume NULL
1898
1899#endif
1900
1901static struct platform_device *wbsd_device;
1902
1903static struct platform_driver wbsd_driver = {
1904 .probe = wbsd_probe,
1905 .remove = wbsd_remove,
1906
1907 .suspend = wbsd_platform_suspend,
1908 .resume = wbsd_platform_resume,
1909 .driver = {
1910 .name = DRIVER_NAME,
1911 },
1912};
1913
1914#ifdef CONFIG_PNP
1915
1916static struct pnp_driver wbsd_pnp_driver = {
1917 .name = DRIVER_NAME,
1918 .id_table = pnp_dev_table,
1919 .probe = wbsd_pnp_probe,
1920 .remove = wbsd_pnp_remove,
1921
1922 .suspend = wbsd_pnp_suspend,
1923 .resume = wbsd_pnp_resume,
1924};
1925
1926#endif
1927
1928
1929
1930
1931
1932static int __init wbsd_drv_init(void)
1933{
1934 int result;
1935
1936 pr_info(DRIVER_NAME
1937 ": Winbond W83L51xD SD/MMC card interface driver\n");
1938 pr_info(DRIVER_NAME ": Copyright(c) Pierre Ossman\n");
1939
1940#ifdef CONFIG_PNP
1941
1942 if (!param_nopnp) {
1943 result = pnp_register_driver(&wbsd_pnp_driver);
1944 if (result < 0)
1945 return result;
1946 }
1947#endif
1948
1949 if (param_nopnp) {
1950 result = platform_driver_register(&wbsd_driver);
1951 if (result < 0)
1952 return result;
1953
1954 wbsd_device = platform_device_alloc(DRIVER_NAME, -1);
1955 if (!wbsd_device) {
1956 platform_driver_unregister(&wbsd_driver);
1957 return -ENOMEM;
1958 }
1959
1960 result = platform_device_add(wbsd_device);
1961 if (result) {
1962 platform_device_put(wbsd_device);
1963 platform_driver_unregister(&wbsd_driver);
1964 return result;
1965 }
1966 }
1967
1968 return 0;
1969}
1970
1971static void __exit wbsd_drv_exit(void)
1972{
1973#ifdef CONFIG_PNP
1974
1975 if (!param_nopnp)
1976 pnp_unregister_driver(&wbsd_pnp_driver);
1977
1978#endif
1979
1980 if (param_nopnp) {
1981 platform_device_unregister(wbsd_device);
1982
1983 platform_driver_unregister(&wbsd_driver);
1984 }
1985
1986 DBG("unloaded\n");
1987}
1988
1989module_init(wbsd_drv_init);
1990module_exit(wbsd_drv_exit);
1991#ifdef CONFIG_PNP
1992module_param_hw_named(nopnp, param_nopnp, uint, other, 0444);
1993#endif
1994module_param_hw_named(io, param_io, uint, ioport, 0444);
1995module_param_hw_named(irq, param_irq, uint, irq, 0444);
1996module_param_hw_named(dma, param_dma, int, dma, 0444);
1997
1998MODULE_LICENSE("GPL");
1999MODULE_AUTHOR("Pierre Ossman <pierre@ossman.eu>");
2000MODULE_DESCRIPTION("Winbond W83L51xD SD/MMC card interface driver");
2001
2002#ifdef CONFIG_PNP
2003MODULE_PARM_DESC(nopnp, "Scan for device instead of relying on PNP. (default 0)");
2004#endif
2005MODULE_PARM_DESC(io, "I/O base to allocate. Must be 8 byte aligned. (default 0x248)");
2006MODULE_PARM_DESC(irq, "IRQ to allocate. (default 6)");
2007MODULE_PARM_DESC(dma, "DMA channel to allocate. -1 for no DMA. (default 2)");
2008