2 * linux/drivers/mmc/host/sdhci.c - Secure Digital Host Controller Interface driver
4 * Copyright (C) 2005-2008 Pierre Ossman, All Rights Reserved.
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.
11 * Thanks to the following companies for their support:
13 * - JMicron (hardware and technical support)
16 #include <linux/delay.h>
17 #include <linux/highmem.h>
19 #include <linux/dma-mapping.h>
20 #include <linux/scatterlist.h>
22 #include <linux/leds.h>
24 #include <linux/mmc/host.h>
28 #define DRIVER_NAME "sdhci"
30 #define DBG(f, x...) \
31 pr_debug(DRIVER_NAME " [%s()]: " f, __func__,## x)
33 static unsigned int debug_quirks = 0;
35 static void sdhci_prepare_data(struct sdhci_host *, struct mmc_data *);
36 static void sdhci_finish_data(struct sdhci_host *);
38 static void sdhci_send_command(struct sdhci_host *, struct mmc_command *);
39 static void sdhci_finish_command(struct sdhci_host *);
41 static void sdhci_dumpregs(struct sdhci_host *host)
43 printk(KERN_DEBUG DRIVER_NAME ": ============== REGISTER DUMP ==============\n");
45 printk(KERN_DEBUG DRIVER_NAME ": Sys addr: 0x%08x | Version: 0x%08x\n",
46 readl(host->ioaddr + SDHCI_DMA_ADDRESS),
47 readw(host->ioaddr + SDHCI_HOST_VERSION));
48 printk(KERN_DEBUG DRIVER_NAME ": Blk size: 0x%08x | Blk cnt: 0x%08x\n",
49 readw(host->ioaddr + SDHCI_BLOCK_SIZE),
50 readw(host->ioaddr + SDHCI_BLOCK_COUNT));
51 printk(KERN_DEBUG DRIVER_NAME ": Argument: 0x%08x | Trn mode: 0x%08x\n",
52 readl(host->ioaddr + SDHCI_ARGUMENT),
53 readw(host->ioaddr + SDHCI_TRANSFER_MODE));
54 printk(KERN_DEBUG DRIVER_NAME ": Present: 0x%08x | Host ctl: 0x%08x\n",
55 readl(host->ioaddr + SDHCI_PRESENT_STATE),
56 readb(host->ioaddr + SDHCI_HOST_CONTROL));
57 printk(KERN_DEBUG DRIVER_NAME ": Power: 0x%08x | Blk gap: 0x%08x\n",
58 readb(host->ioaddr + SDHCI_POWER_CONTROL),
59 readb(host->ioaddr + SDHCI_BLOCK_GAP_CONTROL));
60 printk(KERN_DEBUG DRIVER_NAME ": Wake-up: 0x%08x | Clock: 0x%08x\n",
61 readb(host->ioaddr + SDHCI_WAKE_UP_CONTROL),
62 readw(host->ioaddr + SDHCI_CLOCK_CONTROL));
63 printk(KERN_DEBUG DRIVER_NAME ": Timeout: 0x%08x | Int stat: 0x%08x\n",
64 readb(host->ioaddr + SDHCI_TIMEOUT_CONTROL),
65 readl(host->ioaddr + SDHCI_INT_STATUS));
66 printk(KERN_DEBUG DRIVER_NAME ": Int enab: 0x%08x | Sig enab: 0x%08x\n",
67 readl(host->ioaddr + SDHCI_INT_ENABLE),
68 readl(host->ioaddr + SDHCI_SIGNAL_ENABLE));
69 printk(KERN_DEBUG DRIVER_NAME ": AC12 err: 0x%08x | Slot int: 0x%08x\n",
70 readw(host->ioaddr + SDHCI_ACMD12_ERR),
71 readw(host->ioaddr + SDHCI_SLOT_INT_STATUS));
72 printk(KERN_DEBUG DRIVER_NAME ": Caps: 0x%08x | Max curr: 0x%08x\n",
73 readl(host->ioaddr + SDHCI_CAPABILITIES),
74 readl(host->ioaddr + SDHCI_MAX_CURRENT));
76 printk(KERN_DEBUG DRIVER_NAME ": ===========================================\n");
79 /*****************************************************************************\
81 * Low level functions *
83 \*****************************************************************************/
85 static void sdhci_reset(struct sdhci_host *host, u8 mask)
87 unsigned long timeout;
89 if (host->quirks & SDHCI_QUIRK_NO_CARD_NO_RESET) {
90 if (!(readl(host->ioaddr + SDHCI_PRESENT_STATE) &
95 writeb(mask, host->ioaddr + SDHCI_SOFTWARE_RESET);
97 if (mask & SDHCI_RESET_ALL)
100 /* Wait max 100 ms */
103 /* hw clears the bit when it's done */
104 while (readb(host->ioaddr + SDHCI_SOFTWARE_RESET) & mask) {
106 printk(KERN_ERR "%s: Reset 0x%x never completed.\n",
107 mmc_hostname(host->mmc), (int)mask);
108 sdhci_dumpregs(host);
116 static void sdhci_init(struct sdhci_host *host)
120 sdhci_reset(host, SDHCI_RESET_ALL);
122 intmask = SDHCI_INT_BUS_POWER | SDHCI_INT_DATA_END_BIT |
123 SDHCI_INT_DATA_CRC | SDHCI_INT_DATA_TIMEOUT | SDHCI_INT_INDEX |
124 SDHCI_INT_END_BIT | SDHCI_INT_CRC | SDHCI_INT_TIMEOUT |
125 SDHCI_INT_CARD_REMOVE | SDHCI_INT_CARD_INSERT |
126 SDHCI_INT_DATA_AVAIL | SDHCI_INT_SPACE_AVAIL |
127 SDHCI_INT_DMA_END | SDHCI_INT_DATA_END | SDHCI_INT_RESPONSE |
128 SDHCI_INT_ADMA_ERROR;
130 writel(intmask, host->ioaddr + SDHCI_INT_ENABLE);
131 writel(intmask, host->ioaddr + SDHCI_SIGNAL_ENABLE);
134 static void sdhci_activate_led(struct sdhci_host *host)
138 ctrl = readb(host->ioaddr + SDHCI_HOST_CONTROL);
139 ctrl |= SDHCI_CTRL_LED;
140 writeb(ctrl, host->ioaddr + SDHCI_HOST_CONTROL);
143 static void sdhci_deactivate_led(struct sdhci_host *host)
147 ctrl = readb(host->ioaddr + SDHCI_HOST_CONTROL);
148 ctrl &= ~SDHCI_CTRL_LED;
149 writeb(ctrl, host->ioaddr + SDHCI_HOST_CONTROL);
152 #ifdef CONFIG_LEDS_CLASS
153 static void sdhci_led_control(struct led_classdev *led,
154 enum led_brightness brightness)
156 struct sdhci_host *host = container_of(led, struct sdhci_host, led);
159 spin_lock_irqsave(&host->lock, flags);
161 if (brightness == LED_OFF)
162 sdhci_deactivate_led(host);
164 sdhci_activate_led(host);
166 spin_unlock_irqrestore(&host->lock, flags);
170 /*****************************************************************************\
174 \*****************************************************************************/
176 static inline char* sdhci_sg_to_buffer(struct sdhci_host* host)
178 return sg_virt(host->cur_sg);
181 static inline int sdhci_next_sg(struct sdhci_host* host)
184 * Skip to next SG entry.
192 if (host->num_sg > 0) {
194 host->remain = host->cur_sg->length;
200 static void sdhci_read_block_pio(struct sdhci_host *host)
202 int blksize, chunk_remain;
207 DBG("PIO reading\n");
209 blksize = host->data->blksz;
213 buffer = sdhci_sg_to_buffer(host) + host->offset;
216 if (chunk_remain == 0) {
217 data = readl(host->ioaddr + SDHCI_BUFFER);
218 chunk_remain = min(blksize, 4);
221 size = min(host->remain, chunk_remain);
223 chunk_remain -= size;
225 host->offset += size;
226 host->remain -= size;
229 *buffer = data & 0xFF;
235 if (host->remain == 0) {
236 if (sdhci_next_sg(host) == 0) {
237 BUG_ON(blksize != 0);
240 buffer = sdhci_sg_to_buffer(host);
245 static void sdhci_write_block_pio(struct sdhci_host *host)
247 int blksize, chunk_remain;
252 DBG("PIO writing\n");
254 blksize = host->data->blksz;
259 buffer = sdhci_sg_to_buffer(host) + host->offset;
262 size = min(host->remain, chunk_remain);
264 chunk_remain -= size;
266 host->offset += size;
267 host->remain -= size;
271 data |= (u32)*buffer << 24;
276 if (chunk_remain == 0) {
277 writel(data, host->ioaddr + SDHCI_BUFFER);
278 chunk_remain = min(blksize, 4);
281 if (host->remain == 0) {
282 if (sdhci_next_sg(host) == 0) {
283 BUG_ON(blksize != 0);
286 buffer = sdhci_sg_to_buffer(host);
291 static void sdhci_transfer_pio(struct sdhci_host *host)
297 if (host->num_sg == 0)
300 if (host->data->flags & MMC_DATA_READ)
301 mask = SDHCI_DATA_AVAILABLE;
303 mask = SDHCI_SPACE_AVAILABLE;
305 while (readl(host->ioaddr + SDHCI_PRESENT_STATE) & mask) {
306 if (host->data->flags & MMC_DATA_READ)
307 sdhci_read_block_pio(host);
309 sdhci_write_block_pio(host);
311 if (host->num_sg == 0)
315 DBG("PIO transfer complete.\n");
318 static char *sdhci_kmap_atomic(struct scatterlist *sg, unsigned long *flags)
320 local_irq_save(*flags);
321 return kmap_atomic(sg_page(sg), KM_BIO_SRC_IRQ) + sg->offset;
324 static void sdhci_kunmap_atomic(void *buffer, unsigned long *flags)
326 kunmap_atomic(buffer, KM_BIO_SRC_IRQ);
327 local_irq_restore(*flags);
330 static void sdhci_adma_table_pre(struct sdhci_host *host,
331 struct mmc_data *data)
338 dma_addr_t align_addr;
341 struct scatterlist *sg;
347 * The spec does not specify endianness of descriptor table.
348 * We currently guess that it is LE.
351 if (data->flags & MMC_DATA_READ)
352 direction = DMA_FROM_DEVICE;
354 direction = DMA_TO_DEVICE;
357 * The ADMA descriptor table is mapped further down as we
358 * need to fill it with data first.
361 host->align_addr = dma_map_single(mmc_dev(host->mmc),
362 host->align_buffer, 128 * 4, direction);
363 BUG_ON(host->align_addr & 0x3);
365 host->sg_count = dma_map_sg(mmc_dev(host->mmc),
366 data->sg, data->sg_len, direction);
368 desc = host->adma_desc;
369 align = host->align_buffer;
371 align_addr = host->align_addr;
373 for_each_sg(data->sg, sg, host->sg_count, i) {
374 addr = sg_dma_address(sg);
375 len = sg_dma_len(sg);
378 * The SDHCI specification states that ADMA
379 * addresses must be 32-bit aligned. If they
380 * aren't, then we use a bounce buffer for
381 * the (up to three) bytes that screw up the
384 offset = (4 - (addr & 0x3)) & 0x3;
386 if (data->flags & MMC_DATA_WRITE) {
387 buffer = sdhci_kmap_atomic(sg, &flags);
388 memcpy(align, buffer, offset);
389 sdhci_kunmap_atomic(buffer, &flags);
392 desc[7] = (align_addr >> 24) & 0xff;
393 desc[6] = (align_addr >> 16) & 0xff;
394 desc[5] = (align_addr >> 8) & 0xff;
395 desc[4] = (align_addr >> 0) & 0xff;
397 BUG_ON(offset > 65536);
399 desc[3] = (offset >> 8) & 0xff;
400 desc[2] = (offset >> 0) & 0xff;
403 desc[0] = 0x21; /* tran, valid */
414 desc[7] = (addr >> 24) & 0xff;
415 desc[6] = (addr >> 16) & 0xff;
416 desc[5] = (addr >> 8) & 0xff;
417 desc[4] = (addr >> 0) & 0xff;
421 desc[3] = (len >> 8) & 0xff;
422 desc[2] = (len >> 0) & 0xff;
425 desc[0] = 0x21; /* tran, valid */
430 * If this triggers then we have a calculation bug
433 WARN_ON((desc - host->adma_desc) > (128 * 2 + 1) * 4);
437 * Add a terminating entry.
448 desc[0] = 0x03; /* nop, end, valid */
451 * Resync align buffer as we might have changed it.
453 if (data->flags & MMC_DATA_WRITE) {
454 dma_sync_single_for_device(mmc_dev(host->mmc),
455 host->align_addr, 128 * 4, direction);
458 host->adma_addr = dma_map_single(mmc_dev(host->mmc),
459 host->adma_desc, (128 * 2 + 1) * 4, DMA_TO_DEVICE);
460 BUG_ON(host->adma_addr & 0x3);
463 static void sdhci_adma_table_post(struct sdhci_host *host,
464 struct mmc_data *data)
468 struct scatterlist *sg;
474 if (data->flags & MMC_DATA_READ)
475 direction = DMA_FROM_DEVICE;
477 direction = DMA_TO_DEVICE;
479 dma_unmap_single(mmc_dev(host->mmc), host->adma_addr,
480 (128 * 2 + 1) * 4, DMA_TO_DEVICE);
482 dma_unmap_single(mmc_dev(host->mmc), host->align_addr,
485 if (data->flags & MMC_DATA_READ) {
486 dma_sync_sg_for_cpu(mmc_dev(host->mmc), data->sg,
487 data->sg_len, direction);
489 align = host->align_buffer;
491 for_each_sg(data->sg, sg, host->sg_count, i) {
492 if (sg_dma_address(sg) & 0x3) {
493 size = 4 - (sg_dma_address(sg) & 0x3);
495 buffer = sdhci_kmap_atomic(sg, &flags);
496 memcpy(buffer, align, size);
497 sdhci_kunmap_atomic(buffer, &flags);
504 dma_unmap_sg(mmc_dev(host->mmc), data->sg,
505 data->sg_len, direction);
508 static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_data *data)
511 unsigned target_timeout, current_timeout;
514 * If the host controller provides us with an incorrect timeout
515 * value, just skip the check and use 0xE. The hardware may take
516 * longer to time out, but that's much better than having a too-short
519 if ((host->quirks & SDHCI_QUIRK_BROKEN_TIMEOUT_VAL))
523 target_timeout = data->timeout_ns / 1000 +
524 data->timeout_clks / host->clock;
527 * Figure out needed cycles.
528 * We do this in steps in order to fit inside a 32 bit int.
529 * The first step is the minimum timeout, which will have a
530 * minimum resolution of 6 bits:
531 * (1) 2^13*1000 > 2^22,
532 * (2) host->timeout_clk < 2^16
537 current_timeout = (1 << 13) * 1000 / host->timeout_clk;
538 while (current_timeout < target_timeout) {
540 current_timeout <<= 1;
546 printk(KERN_WARNING "%s: Too large timeout requested!\n",
547 mmc_hostname(host->mmc));
554 static void sdhci_prepare_data(struct sdhci_host *host, struct mmc_data *data)
565 BUG_ON(data->blksz * data->blocks > 524288);
566 BUG_ON(data->blksz > host->mmc->max_blk_size);
567 BUG_ON(data->blocks > 65535);
570 host->data_early = 0;
572 count = sdhci_calc_timeout(host, data);
573 writeb(count, host->ioaddr + SDHCI_TIMEOUT_CONTROL);
575 if (host->flags & SDHCI_USE_DMA)
576 host->flags |= SDHCI_REQ_USE_DMA;
579 * FIXME: This doesn't account for merging when mapping the
582 if (host->flags & SDHCI_REQ_USE_DMA) {
584 struct scatterlist *sg;
587 if (host->flags & SDHCI_USE_ADMA) {
588 if (host->quirks & SDHCI_QUIRK_32BIT_ADMA_SIZE)
591 if (host->quirks & SDHCI_QUIRK_32BIT_DMA_SIZE)
595 if (unlikely(broken)) {
596 for_each_sg(data->sg, sg, data->sg_len, i) {
597 if (sg->length & 0x3) {
598 DBG("Reverting to PIO because of "
599 "transfer size (%d)\n",
601 host->flags &= ~SDHCI_REQ_USE_DMA;
609 * The assumption here being that alignment is the same after
610 * translation to device address space.
612 if (host->flags & SDHCI_REQ_USE_DMA) {
614 struct scatterlist *sg;
617 if (host->flags & SDHCI_USE_ADMA) {
619 * As we use 3 byte chunks to work around
620 * alignment problems, we need to check this
623 if (host->quirks & SDHCI_QUIRK_32BIT_ADMA_SIZE)
626 if (host->quirks & SDHCI_QUIRK_32BIT_DMA_ADDR)
630 if (unlikely(broken)) {
631 for_each_sg(data->sg, sg, data->sg_len, i) {
632 if (sg->offset & 0x3) {
633 DBG("Reverting to PIO because of "
635 host->flags &= ~SDHCI_REQ_USE_DMA;
643 * Always adjust the DMA selection as some controllers
644 * (e.g. JMicron) can't do PIO properly when the selection
647 if (host->version >= SDHCI_SPEC_200) {
648 ctrl = readb(host->ioaddr + SDHCI_HOST_CONTROL);
649 ctrl &= ~SDHCI_CTRL_DMA_MASK;
650 if ((host->flags & SDHCI_REQ_USE_DMA) &&
651 (host->flags & SDHCI_USE_ADMA))
652 ctrl |= SDHCI_CTRL_ADMA32;
654 ctrl |= SDHCI_CTRL_SDMA;
655 writeb(ctrl, host->ioaddr + SDHCI_HOST_CONTROL);
658 if (host->flags & SDHCI_REQ_USE_DMA) {
659 if (host->flags & SDHCI_USE_ADMA) {
660 sdhci_adma_table_pre(host, data);
661 writel(host->adma_addr,
662 host->ioaddr + SDHCI_ADMA_ADDRESS);
666 count = dma_map_sg(mmc_dev(host->mmc),
667 data->sg, data->sg_len,
668 (data->flags & MMC_DATA_READ) ?
673 writel(sg_dma_address(data->sg),
674 host->ioaddr + SDHCI_DMA_ADDRESS);
677 host->cur_sg = data->sg;
678 host->num_sg = data->sg_len;
681 host->remain = host->cur_sg->length;
684 /* We do not handle DMA boundaries, so set it to max (512 KiB) */
685 writew(SDHCI_MAKE_BLKSZ(7, data->blksz),
686 host->ioaddr + SDHCI_BLOCK_SIZE);
687 writew(data->blocks, host->ioaddr + SDHCI_BLOCK_COUNT);
690 static void sdhci_set_transfer_mode(struct sdhci_host *host,
691 struct mmc_data *data)
698 WARN_ON(!host->data);
700 mode = SDHCI_TRNS_BLK_CNT_EN;
701 if (data->blocks > 1)
702 mode |= SDHCI_TRNS_MULTI;
703 if (data->flags & MMC_DATA_READ)
704 mode |= SDHCI_TRNS_READ;
705 if (host->flags & SDHCI_REQ_USE_DMA)
706 mode |= SDHCI_TRNS_DMA;
708 writew(mode, host->ioaddr + SDHCI_TRANSFER_MODE);
711 static void sdhci_finish_data(struct sdhci_host *host)
713 struct mmc_data *data;
720 if (host->flags & SDHCI_REQ_USE_DMA) {
721 if (host->flags & SDHCI_USE_ADMA)
722 sdhci_adma_table_post(host, data);
724 dma_unmap_sg(mmc_dev(host->mmc), data->sg,
725 data->sg_len, (data->flags & MMC_DATA_READ) ?
726 DMA_FROM_DEVICE : DMA_TO_DEVICE);
731 * The specification states that the block count register must
732 * be updated, but it does not specify at what point in the
733 * data flow. That makes the register entirely useless to read
734 * back so we have to assume that nothing made it to the card
735 * in the event of an error.
738 data->bytes_xfered = 0;
740 data->bytes_xfered = data->blksz * data->blocks;
744 * The controller needs a reset of internal state machines
745 * upon error conditions.
748 sdhci_reset(host, SDHCI_RESET_CMD);
749 sdhci_reset(host, SDHCI_RESET_DATA);
752 sdhci_send_command(host, data->stop);
754 tasklet_schedule(&host->finish_tasklet);
757 static void sdhci_send_command(struct sdhci_host *host, struct mmc_command *cmd)
761 unsigned long timeout;
768 mask = SDHCI_CMD_INHIBIT;
769 if ((cmd->data != NULL) || (cmd->flags & MMC_RSP_BUSY))
770 mask |= SDHCI_DATA_INHIBIT;
772 /* We shouldn't wait for data inihibit for stop commands, even
773 though they might use busy signaling */
774 if (host->mrq->data && (cmd == host->mrq->data->stop))
775 mask &= ~SDHCI_DATA_INHIBIT;
777 while (readl(host->ioaddr + SDHCI_PRESENT_STATE) & mask) {
779 printk(KERN_ERR "%s: Controller never released "
780 "inhibit bit(s).\n", mmc_hostname(host->mmc));
781 sdhci_dumpregs(host);
783 tasklet_schedule(&host->finish_tasklet);
790 mod_timer(&host->timer, jiffies + 10 * HZ);
794 sdhci_prepare_data(host, cmd->data);
796 writel(cmd->arg, host->ioaddr + SDHCI_ARGUMENT);
798 sdhci_set_transfer_mode(host, cmd->data);
800 if ((cmd->flags & MMC_RSP_136) && (cmd->flags & MMC_RSP_BUSY)) {
801 printk(KERN_ERR "%s: Unsupported response type!\n",
802 mmc_hostname(host->mmc));
803 cmd->error = -EINVAL;
804 tasklet_schedule(&host->finish_tasklet);
808 if (!(cmd->flags & MMC_RSP_PRESENT))
809 flags = SDHCI_CMD_RESP_NONE;
810 else if (cmd->flags & MMC_RSP_136)
811 flags = SDHCI_CMD_RESP_LONG;
812 else if (cmd->flags & MMC_RSP_BUSY)
813 flags = SDHCI_CMD_RESP_SHORT_BUSY;
815 flags = SDHCI_CMD_RESP_SHORT;
817 if (cmd->flags & MMC_RSP_CRC)
818 flags |= SDHCI_CMD_CRC;
819 if (cmd->flags & MMC_RSP_OPCODE)
820 flags |= SDHCI_CMD_INDEX;
822 flags |= SDHCI_CMD_DATA;
824 writew(SDHCI_MAKE_CMD(cmd->opcode, flags),
825 host->ioaddr + SDHCI_COMMAND);
828 static void sdhci_finish_command(struct sdhci_host *host)
832 BUG_ON(host->cmd == NULL);
834 if (host->cmd->flags & MMC_RSP_PRESENT) {
835 if (host->cmd->flags & MMC_RSP_136) {
836 /* CRC is stripped so we need to do some shifting. */
837 for (i = 0;i < 4;i++) {
838 host->cmd->resp[i] = readl(host->ioaddr +
839 SDHCI_RESPONSE + (3-i)*4) << 8;
841 host->cmd->resp[i] |=
843 SDHCI_RESPONSE + (3-i)*4-1);
846 host->cmd->resp[0] = readl(host->ioaddr + SDHCI_RESPONSE);
850 host->cmd->error = 0;
852 if (host->data && host->data_early)
853 sdhci_finish_data(host);
855 if (!host->cmd->data)
856 tasklet_schedule(&host->finish_tasklet);
861 static void sdhci_set_clock(struct sdhci_host *host, unsigned int clock)
865 unsigned long timeout;
867 if (clock == host->clock)
870 writew(0, host->ioaddr + SDHCI_CLOCK_CONTROL);
875 for (div = 1;div < 256;div *= 2) {
876 if ((host->max_clk / div) <= clock)
881 clk = div << SDHCI_DIVIDER_SHIFT;
882 clk |= SDHCI_CLOCK_INT_EN;
883 writew(clk, host->ioaddr + SDHCI_CLOCK_CONTROL);
887 while (!((clk = readw(host->ioaddr + SDHCI_CLOCK_CONTROL))
888 & SDHCI_CLOCK_INT_STABLE)) {
890 printk(KERN_ERR "%s: Internal clock never "
891 "stabilised.\n", mmc_hostname(host->mmc));
892 sdhci_dumpregs(host);
899 clk |= SDHCI_CLOCK_CARD_EN;
900 writew(clk, host->ioaddr + SDHCI_CLOCK_CONTROL);
906 static void sdhci_set_power(struct sdhci_host *host, unsigned short power)
910 if (host->power == power)
913 if (power == (unsigned short)-1) {
914 writeb(0, host->ioaddr + SDHCI_POWER_CONTROL);
919 * Spec says that we should clear the power reg before setting
920 * a new value. Some controllers don't seem to like this though.
922 if (!(host->quirks & SDHCI_QUIRK_SINGLE_POWER_WRITE))
923 writeb(0, host->ioaddr + SDHCI_POWER_CONTROL);
925 pwr = SDHCI_POWER_ON;
927 switch (1 << power) {
928 case MMC_VDD_165_195:
929 pwr |= SDHCI_POWER_180;
933 pwr |= SDHCI_POWER_300;
937 pwr |= SDHCI_POWER_330;
944 * At least the CaFe chip gets confused if we set the voltage
945 * and set turn on power at the same time, so set the voltage first.
947 if ((host->quirks & SDHCI_QUIRK_NO_SIMULT_VDD_AND_POWER))
948 writeb(pwr & ~SDHCI_POWER_ON,
949 host->ioaddr + SDHCI_POWER_CONTROL);
951 writeb(pwr, host->ioaddr + SDHCI_POWER_CONTROL);
957 /*****************************************************************************\
961 \*****************************************************************************/
963 static void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq)
965 struct sdhci_host *host;
968 host = mmc_priv(mmc);
970 spin_lock_irqsave(&host->lock, flags);
972 WARN_ON(host->mrq != NULL);
974 #ifndef CONFIG_LEDS_CLASS
975 sdhci_activate_led(host);
980 if (!(readl(host->ioaddr + SDHCI_PRESENT_STATE) & SDHCI_CARD_PRESENT)
981 || (host->flags & SDHCI_DEVICE_DEAD)) {
982 host->mrq->cmd->error = -ENOMEDIUM;
983 tasklet_schedule(&host->finish_tasklet);
985 sdhci_send_command(host, mrq->cmd);
988 spin_unlock_irqrestore(&host->lock, flags);
991 static void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
993 struct sdhci_host *host;
997 host = mmc_priv(mmc);
999 spin_lock_irqsave(&host->lock, flags);
1001 if (host->flags & SDHCI_DEVICE_DEAD)
1005 * Reset the chip on each power off.
1006 * Should clear out any weird states.
1008 if (ios->power_mode == MMC_POWER_OFF) {
1009 writel(0, host->ioaddr + SDHCI_SIGNAL_ENABLE);
1013 sdhci_set_clock(host, ios->clock);
1015 if (ios->power_mode == MMC_POWER_OFF)
1016 sdhci_set_power(host, -1);
1018 sdhci_set_power(host, ios->vdd);
1020 ctrl = readb(host->ioaddr + SDHCI_HOST_CONTROL);
1022 if (ios->bus_width == MMC_BUS_WIDTH_4)
1023 ctrl |= SDHCI_CTRL_4BITBUS;
1025 ctrl &= ~SDHCI_CTRL_4BITBUS;
1027 if (ios->timing == MMC_TIMING_SD_HS)
1028 ctrl |= SDHCI_CTRL_HISPD;
1030 ctrl &= ~SDHCI_CTRL_HISPD;
1032 writeb(ctrl, host->ioaddr + SDHCI_HOST_CONTROL);
1035 * Some (ENE) controllers go apeshit on some ios operation,
1036 * signalling timeout and CRC errors even on CMD0. Resetting
1037 * it on each ios seems to solve the problem.
1039 if(host->quirks & SDHCI_QUIRK_RESET_CMD_DATA_ON_IOS)
1040 sdhci_reset(host, SDHCI_RESET_CMD | SDHCI_RESET_DATA);
1044 spin_unlock_irqrestore(&host->lock, flags);
1047 static int sdhci_get_ro(struct mmc_host *mmc)
1049 struct sdhci_host *host;
1050 unsigned long flags;
1053 host = mmc_priv(mmc);
1055 spin_lock_irqsave(&host->lock, flags);
1057 if (host->flags & SDHCI_DEVICE_DEAD)
1060 present = readl(host->ioaddr + SDHCI_PRESENT_STATE);
1062 spin_unlock_irqrestore(&host->lock, flags);
1064 return !(present & SDHCI_WRITE_PROTECT);
1067 static void sdhci_enable_sdio_irq(struct mmc_host *mmc, int enable)
1069 struct sdhci_host *host;
1070 unsigned long flags;
1073 host = mmc_priv(mmc);
1075 spin_lock_irqsave(&host->lock, flags);
1077 if (host->flags & SDHCI_DEVICE_DEAD)
1080 ier = readl(host->ioaddr + SDHCI_INT_ENABLE);
1082 ier &= ~SDHCI_INT_CARD_INT;
1084 ier |= SDHCI_INT_CARD_INT;
1086 writel(ier, host->ioaddr + SDHCI_INT_ENABLE);
1087 writel(ier, host->ioaddr + SDHCI_SIGNAL_ENABLE);
1092 spin_unlock_irqrestore(&host->lock, flags);
1095 static const struct mmc_host_ops sdhci_ops = {
1096 .request = sdhci_request,
1097 .set_ios = sdhci_set_ios,
1098 .get_ro = sdhci_get_ro,
1099 .enable_sdio_irq = sdhci_enable_sdio_irq,
1102 /*****************************************************************************\
1106 \*****************************************************************************/
1108 static void sdhci_tasklet_card(unsigned long param)
1110 struct sdhci_host *host;
1111 unsigned long flags;
1113 host = (struct sdhci_host*)param;
1115 spin_lock_irqsave(&host->lock, flags);
1117 if (!(readl(host->ioaddr + SDHCI_PRESENT_STATE) & SDHCI_CARD_PRESENT)) {
1119 printk(KERN_ERR "%s: Card removed during transfer!\n",
1120 mmc_hostname(host->mmc));
1121 printk(KERN_ERR "%s: Resetting controller.\n",
1122 mmc_hostname(host->mmc));
1124 sdhci_reset(host, SDHCI_RESET_CMD);
1125 sdhci_reset(host, SDHCI_RESET_DATA);
1127 host->mrq->cmd->error = -ENOMEDIUM;
1128 tasklet_schedule(&host->finish_tasklet);
1132 spin_unlock_irqrestore(&host->lock, flags);
1134 mmc_detect_change(host->mmc, msecs_to_jiffies(500));
1137 static void sdhci_tasklet_finish(unsigned long param)
1139 struct sdhci_host *host;
1140 unsigned long flags;
1141 struct mmc_request *mrq;
1143 host = (struct sdhci_host*)param;
1145 spin_lock_irqsave(&host->lock, flags);
1147 del_timer(&host->timer);
1152 * The controller needs a reset of internal state machines
1153 * upon error conditions.
1155 if (!(host->flags & SDHCI_DEVICE_DEAD) &&
1157 (mrq->data && (mrq->data->error ||
1158 (mrq->data->stop && mrq->data->stop->error))) ||
1159 (host->quirks & SDHCI_QUIRK_RESET_AFTER_REQUEST))) {
1161 /* Some controllers need this kick or reset won't work here */
1162 if (host->quirks & SDHCI_QUIRK_CLOCK_BEFORE_RESET) {
1165 /* This is to force an update */
1166 clock = host->clock;
1168 sdhci_set_clock(host, clock);
1171 /* Spec says we should do both at the same time, but Ricoh
1172 controllers do not like that. */
1173 sdhci_reset(host, SDHCI_RESET_CMD);
1174 sdhci_reset(host, SDHCI_RESET_DATA);
1181 #ifndef CONFIG_LEDS_CLASS
1182 sdhci_deactivate_led(host);
1186 spin_unlock_irqrestore(&host->lock, flags);
1188 mmc_request_done(host->mmc, mrq);
1191 static void sdhci_timeout_timer(unsigned long data)
1193 struct sdhci_host *host;
1194 unsigned long flags;
1196 host = (struct sdhci_host*)data;
1198 spin_lock_irqsave(&host->lock, flags);
1201 printk(KERN_ERR "%s: Timeout waiting for hardware "
1202 "interrupt.\n", mmc_hostname(host->mmc));
1203 sdhci_dumpregs(host);
1206 host->data->error = -ETIMEDOUT;
1207 sdhci_finish_data(host);
1210 host->cmd->error = -ETIMEDOUT;
1212 host->mrq->cmd->error = -ETIMEDOUT;
1214 tasklet_schedule(&host->finish_tasklet);
1219 spin_unlock_irqrestore(&host->lock, flags);
1222 /*****************************************************************************\
1224 * Interrupt handling *
1226 \*****************************************************************************/
1228 static void sdhci_cmd_irq(struct sdhci_host *host, u32 intmask)
1230 BUG_ON(intmask == 0);
1233 printk(KERN_ERR "%s: Got command interrupt 0x%08x even "
1234 "though no command operation was in progress.\n",
1235 mmc_hostname(host->mmc), (unsigned)intmask);
1236 sdhci_dumpregs(host);
1240 if (intmask & SDHCI_INT_TIMEOUT)
1241 host->cmd->error = -ETIMEDOUT;
1242 else if (intmask & (SDHCI_INT_CRC | SDHCI_INT_END_BIT |
1244 host->cmd->error = -EILSEQ;
1246 if (host->cmd->error)
1247 tasklet_schedule(&host->finish_tasklet);
1248 else if (intmask & SDHCI_INT_RESPONSE)
1249 sdhci_finish_command(host);
1252 static void sdhci_data_irq(struct sdhci_host *host, u32 intmask)
1254 BUG_ON(intmask == 0);
1258 * A data end interrupt is sent together with the response
1259 * for the stop command.
1261 if (intmask & SDHCI_INT_DATA_END)
1264 printk(KERN_ERR "%s: Got data interrupt 0x%08x even "
1265 "though no data operation was in progress.\n",
1266 mmc_hostname(host->mmc), (unsigned)intmask);
1267 sdhci_dumpregs(host);
1272 if (intmask & SDHCI_INT_DATA_TIMEOUT)
1273 host->data->error = -ETIMEDOUT;
1274 else if (intmask & (SDHCI_INT_DATA_CRC | SDHCI_INT_DATA_END_BIT))
1275 host->data->error = -EILSEQ;
1276 else if (intmask & SDHCI_INT_ADMA_ERROR)
1277 host->data->error = -EIO;
1279 if (host->data->error)
1280 sdhci_finish_data(host);
1282 if (intmask & (SDHCI_INT_DATA_AVAIL | SDHCI_INT_SPACE_AVAIL))
1283 sdhci_transfer_pio(host);
1286 * We currently don't do anything fancy with DMA
1287 * boundaries, but as we can't disable the feature
1288 * we need to at least restart the transfer.
1290 if (intmask & SDHCI_INT_DMA_END)
1291 writel(readl(host->ioaddr + SDHCI_DMA_ADDRESS),
1292 host->ioaddr + SDHCI_DMA_ADDRESS);
1294 if (intmask & SDHCI_INT_DATA_END) {
1297 * Data managed to finish before the
1298 * command completed. Make sure we do
1299 * things in the proper order.
1301 host->data_early = 1;
1303 sdhci_finish_data(host);
1309 static irqreturn_t sdhci_irq(int irq, void *dev_id)
1312 struct sdhci_host* host = dev_id;
1316 spin_lock(&host->lock);
1318 intmask = readl(host->ioaddr + SDHCI_INT_STATUS);
1320 if (!intmask || intmask == 0xffffffff) {
1325 DBG("*** %s got interrupt: 0x%08x\n",
1326 mmc_hostname(host->mmc), intmask);
1328 if (intmask & (SDHCI_INT_CARD_INSERT | SDHCI_INT_CARD_REMOVE)) {
1329 writel(intmask & (SDHCI_INT_CARD_INSERT | SDHCI_INT_CARD_REMOVE),
1330 host->ioaddr + SDHCI_INT_STATUS);
1331 tasklet_schedule(&host->card_tasklet);
1334 intmask &= ~(SDHCI_INT_CARD_INSERT | SDHCI_INT_CARD_REMOVE);
1336 if (intmask & SDHCI_INT_CMD_MASK) {
1337 writel(intmask & SDHCI_INT_CMD_MASK,
1338 host->ioaddr + SDHCI_INT_STATUS);
1339 sdhci_cmd_irq(host, intmask & SDHCI_INT_CMD_MASK);
1342 if (intmask & SDHCI_INT_DATA_MASK) {
1343 writel(intmask & SDHCI_INT_DATA_MASK,
1344 host->ioaddr + SDHCI_INT_STATUS);
1345 sdhci_data_irq(host, intmask & SDHCI_INT_DATA_MASK);
1348 intmask &= ~(SDHCI_INT_CMD_MASK | SDHCI_INT_DATA_MASK);
1350 intmask &= ~SDHCI_INT_ERROR;
1352 if (intmask & SDHCI_INT_BUS_POWER) {
1353 printk(KERN_ERR "%s: Card is consuming too much power!\n",
1354 mmc_hostname(host->mmc));
1355 writel(SDHCI_INT_BUS_POWER, host->ioaddr + SDHCI_INT_STATUS);
1358 intmask &= ~SDHCI_INT_BUS_POWER;
1360 if (intmask & SDHCI_INT_CARD_INT)
1363 intmask &= ~SDHCI_INT_CARD_INT;
1366 printk(KERN_ERR "%s: Unexpected interrupt 0x%08x.\n",
1367 mmc_hostname(host->mmc), intmask);
1368 sdhci_dumpregs(host);
1370 writel(intmask, host->ioaddr + SDHCI_INT_STATUS);
1373 result = IRQ_HANDLED;
1377 spin_unlock(&host->lock);
1380 * We have to delay this as it calls back into the driver.
1383 mmc_signal_sdio_irq(host->mmc);
1388 /*****************************************************************************\
1392 \*****************************************************************************/
1396 int sdhci_suspend_host(struct sdhci_host *host, pm_message_t state)
1400 ret = mmc_suspend_host(host->mmc, state);
1404 free_irq(host->irq, host);
1409 EXPORT_SYMBOL_GPL(sdhci_suspend_host);
1411 int sdhci_resume_host(struct sdhci_host *host)
1415 if (host->flags & SDHCI_USE_DMA) {
1416 if (host->ops->enable_dma)
1417 host->ops->enable_dma(host);
1420 ret = request_irq(host->irq, sdhci_irq, IRQF_SHARED,
1421 mmc_hostname(host->mmc), host);
1428 ret = mmc_resume_host(host->mmc);
1435 EXPORT_SYMBOL_GPL(sdhci_resume_host);
1437 #endif /* CONFIG_PM */
1439 /*****************************************************************************\
1441 * Device allocation/registration *
1443 \*****************************************************************************/
1445 struct sdhci_host *sdhci_alloc_host(struct device *dev,
1448 struct mmc_host *mmc;
1449 struct sdhci_host *host;
1451 WARN_ON(dev == NULL);
1453 mmc = mmc_alloc_host(sizeof(struct sdhci_host) + priv_size, dev);
1455 return ERR_PTR(-ENOMEM);
1457 host = mmc_priv(mmc);
1463 EXPORT_SYMBOL_GPL(sdhci_alloc_host);
1465 int sdhci_add_host(struct sdhci_host *host)
1467 struct mmc_host *mmc;
1471 WARN_ON(host == NULL);
1478 host->quirks = debug_quirks;
1480 sdhci_reset(host, SDHCI_RESET_ALL);
1482 host->version = readw(host->ioaddr + SDHCI_HOST_VERSION);
1483 host->version = (host->version & SDHCI_SPEC_VER_MASK)
1484 >> SDHCI_SPEC_VER_SHIFT;
1485 if (host->version > SDHCI_SPEC_200) {
1486 printk(KERN_ERR "%s: Unknown controller version (%d). "
1487 "You may experience problems.\n", mmc_hostname(mmc),
1491 caps = readl(host->ioaddr + SDHCI_CAPABILITIES);
1493 if (host->quirks & SDHCI_QUIRK_FORCE_DMA)
1494 host->flags |= SDHCI_USE_DMA;
1495 else if (!(caps & SDHCI_CAN_DO_DMA))
1496 DBG("Controller doesn't have DMA capability\n");
1498 host->flags |= SDHCI_USE_DMA;
1500 if ((host->quirks & SDHCI_QUIRK_BROKEN_DMA) &&
1501 (host->flags & SDHCI_USE_DMA)) {
1502 DBG("Disabling DMA as it is marked broken\n");
1503 host->flags &= ~SDHCI_USE_DMA;
1506 if (host->flags & SDHCI_USE_DMA) {
1507 if ((host->version >= SDHCI_SPEC_200) &&
1508 (caps & SDHCI_CAN_DO_ADMA2))
1509 host->flags |= SDHCI_USE_ADMA;
1512 if ((host->quirks & SDHCI_QUIRK_BROKEN_ADMA) &&
1513 (host->flags & SDHCI_USE_ADMA)) {
1514 DBG("Disabling ADMA as it is marked broken\n");
1515 host->flags &= ~SDHCI_USE_ADMA;
1518 if (host->flags & SDHCI_USE_DMA) {
1519 if (host->ops->enable_dma) {
1520 if (host->ops->enable_dma(host)) {
1521 printk(KERN_WARNING "%s: No suitable DMA "
1522 "available. Falling back to PIO.\n",
1524 host->flags &= ~(SDHCI_USE_DMA | SDHCI_USE_ADMA);
1529 if (host->flags & SDHCI_USE_ADMA) {
1531 * We need to allocate descriptors for all sg entries
1532 * (128) and potentially one alignment transfer for
1533 * each of those entries.
1535 host->adma_desc = kmalloc((128 * 2 + 1) * 4, GFP_KERNEL);
1536 host->align_buffer = kmalloc(128 * 4, GFP_KERNEL);
1537 if (!host->adma_desc || !host->align_buffer) {
1538 kfree(host->adma_desc);
1539 kfree(host->align_buffer);
1540 printk(KERN_WARNING "%s: Unable to allocate ADMA "
1541 "buffers. Falling back to standard DMA.\n",
1543 host->flags &= ~SDHCI_USE_ADMA;
1547 /* XXX: Hack to get MMC layer to avoid highmem */
1548 if (!(host->flags & SDHCI_USE_DMA))
1549 mmc_dev(host->mmc)->dma_mask = 0;
1552 (caps & SDHCI_CLOCK_BASE_MASK) >> SDHCI_CLOCK_BASE_SHIFT;
1553 if (host->max_clk == 0) {
1554 printk(KERN_ERR "%s: Hardware doesn't specify base clock "
1555 "frequency.\n", mmc_hostname(mmc));
1558 host->max_clk *= 1000000;
1561 (caps & SDHCI_TIMEOUT_CLK_MASK) >> SDHCI_TIMEOUT_CLK_SHIFT;
1562 if (host->timeout_clk == 0) {
1563 printk(KERN_ERR "%s: Hardware doesn't specify timeout clock "
1564 "frequency.\n", mmc_hostname(mmc));
1567 if (caps & SDHCI_TIMEOUT_CLK_UNIT)
1568 host->timeout_clk *= 1000;
1571 * Set host parameters.
1573 mmc->ops = &sdhci_ops;
1574 mmc->f_min = host->max_clk / 256;
1575 mmc->f_max = host->max_clk;
1576 mmc->caps = MMC_CAP_4_BIT_DATA | MMC_CAP_SDIO_IRQ;
1578 if (caps & SDHCI_CAN_DO_HISPD)
1579 mmc->caps |= MMC_CAP_SD_HIGHSPEED;
1582 if (caps & SDHCI_CAN_VDD_330)
1583 mmc->ocr_avail |= MMC_VDD_32_33|MMC_VDD_33_34;
1584 if (caps & SDHCI_CAN_VDD_300)
1585 mmc->ocr_avail |= MMC_VDD_29_30|MMC_VDD_30_31;
1586 if (caps & SDHCI_CAN_VDD_180)
1587 mmc->ocr_avail |= MMC_VDD_165_195;
1589 if (mmc->ocr_avail == 0) {
1590 printk(KERN_ERR "%s: Hardware doesn't report any "
1591 "support voltages.\n", mmc_hostname(mmc));
1595 spin_lock_init(&host->lock);
1598 * Maximum number of segments. Depends on if the hardware
1599 * can do scatter/gather or not.
1601 if (host->flags & SDHCI_USE_ADMA)
1602 mmc->max_hw_segs = 128;
1603 else if (host->flags & SDHCI_USE_DMA)
1604 mmc->max_hw_segs = 1;
1606 mmc->max_hw_segs = 128;
1607 mmc->max_phys_segs = 128;
1610 * Maximum number of sectors in one transfer. Limited by DMA boundary
1613 mmc->max_req_size = 524288;
1616 * Maximum segment size. Could be one segment with the maximum number
1617 * of bytes. When doing hardware scatter/gather, each entry cannot
1618 * be larger than 64 KiB though.
1620 if (host->flags & SDHCI_USE_ADMA)
1621 mmc->max_seg_size = 65536;
1623 mmc->max_seg_size = mmc->max_req_size;
1626 * Maximum block size. This varies from controller to controller and
1627 * is specified in the capabilities register.
1629 mmc->max_blk_size = (caps & SDHCI_MAX_BLOCK_MASK) >> SDHCI_MAX_BLOCK_SHIFT;
1630 if (mmc->max_blk_size >= 3) {
1631 printk(KERN_WARNING "%s: Invalid maximum block size, "
1632 "assuming 512 bytes\n", mmc_hostname(mmc));
1633 mmc->max_blk_size = 512;
1635 mmc->max_blk_size = 512 << mmc->max_blk_size;
1638 * Maximum block count.
1640 mmc->max_blk_count = 65535;
1645 tasklet_init(&host->card_tasklet,
1646 sdhci_tasklet_card, (unsigned long)host);
1647 tasklet_init(&host->finish_tasklet,
1648 sdhci_tasklet_finish, (unsigned long)host);
1650 setup_timer(&host->timer, sdhci_timeout_timer, (unsigned long)host);
1652 ret = request_irq(host->irq, sdhci_irq, IRQF_SHARED,
1653 mmc_hostname(mmc), host);
1659 #ifdef CONFIG_MMC_DEBUG
1660 sdhci_dumpregs(host);
1663 #ifdef CONFIG_LEDS_CLASS
1664 host->led.name = mmc_hostname(mmc);
1665 host->led.brightness = LED_OFF;
1666 host->led.default_trigger = mmc_hostname(mmc);
1667 host->led.brightness_set = sdhci_led_control;
1669 ret = led_classdev_register(mmc_dev(mmc), &host->led);
1678 printk(KERN_INFO "%s: SDHCI controller on %s [%s] using %s%s\n",
1679 mmc_hostname(mmc), host->hw_name, mmc_dev(mmc)->bus_id,
1680 (host->flags & SDHCI_USE_ADMA)?"A":"",
1681 (host->flags & SDHCI_USE_DMA)?"DMA":"PIO");
1685 #ifdef CONFIG_LEDS_CLASS
1687 sdhci_reset(host, SDHCI_RESET_ALL);
1688 free_irq(host->irq, host);
1691 tasklet_kill(&host->card_tasklet);
1692 tasklet_kill(&host->finish_tasklet);
1697 EXPORT_SYMBOL_GPL(sdhci_add_host);
1699 void sdhci_remove_host(struct sdhci_host *host, int dead)
1701 unsigned long flags;
1704 spin_lock_irqsave(&host->lock, flags);
1706 host->flags |= SDHCI_DEVICE_DEAD;
1709 printk(KERN_ERR "%s: Controller removed during "
1710 " transfer!\n", mmc_hostname(host->mmc));
1712 host->mrq->cmd->error = -ENOMEDIUM;
1713 tasklet_schedule(&host->finish_tasklet);
1716 spin_unlock_irqrestore(&host->lock, flags);
1719 mmc_remove_host(host->mmc);
1721 #ifdef CONFIG_LEDS_CLASS
1722 led_classdev_unregister(&host->led);
1726 sdhci_reset(host, SDHCI_RESET_ALL);
1728 free_irq(host->irq, host);
1730 del_timer_sync(&host->timer);
1732 tasklet_kill(&host->card_tasklet);
1733 tasklet_kill(&host->finish_tasklet);
1735 kfree(host->adma_desc);
1736 kfree(host->align_buffer);
1738 host->adma_desc = NULL;
1739 host->align_buffer = NULL;
1742 EXPORT_SYMBOL_GPL(sdhci_remove_host);
1744 void sdhci_free_host(struct sdhci_host *host)
1746 mmc_free_host(host->mmc);
1749 EXPORT_SYMBOL_GPL(sdhci_free_host);
1751 /*****************************************************************************\
1753 * Driver init/exit *
1755 \*****************************************************************************/
1757 static int __init sdhci_drv_init(void)
1759 printk(KERN_INFO DRIVER_NAME
1760 ": Secure Digital Host Controller Interface driver\n");
1761 printk(KERN_INFO DRIVER_NAME ": Copyright(c) Pierre Ossman\n");
1766 static void __exit sdhci_drv_exit(void)
1770 module_init(sdhci_drv_init);
1771 module_exit(sdhci_drv_exit);
1773 module_param(debug_quirks, uint, 0444);
1775 MODULE_AUTHOR("Pierre Ossman <drzeus@drzeus.cx>");
1776 MODULE_DESCRIPTION("Secure Digital Host Controller Interface core driver");
1777 MODULE_LICENSE("GPL");
1779 MODULE_PARM_DESC(debug_quirks, "Force certain quirks.");