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>
18 #include <linux/pci.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;
36 * Different quirks to handle when the hardware deviates from a strict
37 * interpretation of the SDHCI specification.
40 /* Controller doesn't honor resets unless we touch the clock register */
41 #define SDHCI_QUIRK_CLOCK_BEFORE_RESET (1<<0)
42 /* Controller has bad caps bits, but really supports DMA */
43 #define SDHCI_QUIRK_FORCE_DMA (1<<1)
44 /* Controller doesn't like to be reset when there is no card inserted. */
45 #define SDHCI_QUIRK_NO_CARD_NO_RESET (1<<2)
46 /* Controller doesn't like clearing the power reg before a change */
47 #define SDHCI_QUIRK_SINGLE_POWER_WRITE (1<<3)
48 /* Controller has flaky internal state so reset it on each ios change */
49 #define SDHCI_QUIRK_RESET_CMD_DATA_ON_IOS (1<<4)
50 /* Controller has an unusable DMA engine */
51 #define SDHCI_QUIRK_BROKEN_DMA (1<<5)
52 /* Controller can only DMA from 32-bit aligned addresses */
53 #define SDHCI_QUIRK_32BIT_DMA_ADDR (1<<6)
54 /* Controller can only DMA chunk sizes that are a multiple of 32 bits */
55 #define SDHCI_QUIRK_32BIT_DMA_SIZE (1<<7)
56 /* Controller needs to be reset after each request to stay stable */
57 #define SDHCI_QUIRK_RESET_AFTER_REQUEST (1<<8)
59 static const struct pci_device_id pci_ids[] __devinitdata = {
61 .vendor = PCI_VENDOR_ID_RICOH,
62 .device = PCI_DEVICE_ID_RICOH_R5C822,
63 .subvendor = PCI_VENDOR_ID_IBM,
64 .subdevice = PCI_ANY_ID,
65 .driver_data = SDHCI_QUIRK_CLOCK_BEFORE_RESET |
66 SDHCI_QUIRK_FORCE_DMA,
70 .vendor = PCI_VENDOR_ID_RICOH,
71 .device = PCI_DEVICE_ID_RICOH_R5C822,
72 .subvendor = PCI_VENDOR_ID_SAMSUNG,
73 .subdevice = PCI_ANY_ID,
74 .driver_data = SDHCI_QUIRK_FORCE_DMA |
75 SDHCI_QUIRK_NO_CARD_NO_RESET,
79 .vendor = PCI_VENDOR_ID_RICOH,
80 .device = PCI_DEVICE_ID_RICOH_R5C822,
81 .subvendor = PCI_ANY_ID,
82 .subdevice = PCI_ANY_ID,
83 .driver_data = SDHCI_QUIRK_FORCE_DMA,
87 .vendor = PCI_VENDOR_ID_TI,
88 .device = PCI_DEVICE_ID_TI_XX21_XX11_SD,
89 .subvendor = PCI_ANY_ID,
90 .subdevice = PCI_ANY_ID,
91 .driver_data = SDHCI_QUIRK_FORCE_DMA,
95 .vendor = PCI_VENDOR_ID_ENE,
96 .device = PCI_DEVICE_ID_ENE_CB712_SD,
97 .subvendor = PCI_ANY_ID,
98 .subdevice = PCI_ANY_ID,
99 .driver_data = SDHCI_QUIRK_SINGLE_POWER_WRITE |
100 SDHCI_QUIRK_BROKEN_DMA,
104 .vendor = PCI_VENDOR_ID_ENE,
105 .device = PCI_DEVICE_ID_ENE_CB712_SD_2,
106 .subvendor = PCI_ANY_ID,
107 .subdevice = PCI_ANY_ID,
108 .driver_data = SDHCI_QUIRK_SINGLE_POWER_WRITE |
109 SDHCI_QUIRK_BROKEN_DMA,
113 .vendor = PCI_VENDOR_ID_ENE,
114 .device = PCI_DEVICE_ID_ENE_CB714_SD,
115 .subvendor = PCI_ANY_ID,
116 .subdevice = PCI_ANY_ID,
117 .driver_data = SDHCI_QUIRK_SINGLE_POWER_WRITE |
118 SDHCI_QUIRK_RESET_CMD_DATA_ON_IOS,
122 .vendor = PCI_VENDOR_ID_ENE,
123 .device = PCI_DEVICE_ID_ENE_CB714_SD_2,
124 .subvendor = PCI_ANY_ID,
125 .subdevice = PCI_ANY_ID,
126 .driver_data = SDHCI_QUIRK_SINGLE_POWER_WRITE |
127 SDHCI_QUIRK_RESET_CMD_DATA_ON_IOS,
131 .vendor = PCI_VENDOR_ID_JMICRON,
132 .device = PCI_DEVICE_ID_JMICRON_JMB38X_SD,
133 .subvendor = PCI_ANY_ID,
134 .subdevice = PCI_ANY_ID,
135 .driver_data = SDHCI_QUIRK_32BIT_DMA_ADDR |
136 SDHCI_QUIRK_32BIT_DMA_SIZE |
137 SDHCI_QUIRK_RESET_AFTER_REQUEST,
140 { /* Generic SD host controller */
141 PCI_DEVICE_CLASS((PCI_CLASS_SYSTEM_SDHCI << 8), 0xFFFF00)
144 { /* end: all zeroes */ },
147 MODULE_DEVICE_TABLE(pci, pci_ids);
149 static void sdhci_prepare_data(struct sdhci_host *, struct mmc_data *);
150 static void sdhci_finish_data(struct sdhci_host *);
152 static void sdhci_send_command(struct sdhci_host *, struct mmc_command *);
153 static void sdhci_finish_command(struct sdhci_host *);
155 static void sdhci_dumpregs(struct sdhci_host *host)
157 printk(KERN_DEBUG DRIVER_NAME ": ============== REGISTER DUMP ==============\n");
159 printk(KERN_DEBUG DRIVER_NAME ": Sys addr: 0x%08x | Version: 0x%08x\n",
160 readl(host->ioaddr + SDHCI_DMA_ADDRESS),
161 readw(host->ioaddr + SDHCI_HOST_VERSION));
162 printk(KERN_DEBUG DRIVER_NAME ": Blk size: 0x%08x | Blk cnt: 0x%08x\n",
163 readw(host->ioaddr + SDHCI_BLOCK_SIZE),
164 readw(host->ioaddr + SDHCI_BLOCK_COUNT));
165 printk(KERN_DEBUG DRIVER_NAME ": Argument: 0x%08x | Trn mode: 0x%08x\n",
166 readl(host->ioaddr + SDHCI_ARGUMENT),
167 readw(host->ioaddr + SDHCI_TRANSFER_MODE));
168 printk(KERN_DEBUG DRIVER_NAME ": Present: 0x%08x | Host ctl: 0x%08x\n",
169 readl(host->ioaddr + SDHCI_PRESENT_STATE),
170 readb(host->ioaddr + SDHCI_HOST_CONTROL));
171 printk(KERN_DEBUG DRIVER_NAME ": Power: 0x%08x | Blk gap: 0x%08x\n",
172 readb(host->ioaddr + SDHCI_POWER_CONTROL),
173 readb(host->ioaddr + SDHCI_BLOCK_GAP_CONTROL));
174 printk(KERN_DEBUG DRIVER_NAME ": Wake-up: 0x%08x | Clock: 0x%08x\n",
175 readb(host->ioaddr + SDHCI_WAKE_UP_CONTROL),
176 readw(host->ioaddr + SDHCI_CLOCK_CONTROL));
177 printk(KERN_DEBUG DRIVER_NAME ": Timeout: 0x%08x | Int stat: 0x%08x\n",
178 readb(host->ioaddr + SDHCI_TIMEOUT_CONTROL),
179 readl(host->ioaddr + SDHCI_INT_STATUS));
180 printk(KERN_DEBUG DRIVER_NAME ": Int enab: 0x%08x | Sig enab: 0x%08x\n",
181 readl(host->ioaddr + SDHCI_INT_ENABLE),
182 readl(host->ioaddr + SDHCI_SIGNAL_ENABLE));
183 printk(KERN_DEBUG DRIVER_NAME ": AC12 err: 0x%08x | Slot int: 0x%08x\n",
184 readw(host->ioaddr + SDHCI_ACMD12_ERR),
185 readw(host->ioaddr + SDHCI_SLOT_INT_STATUS));
186 printk(KERN_DEBUG DRIVER_NAME ": Caps: 0x%08x | Max curr: 0x%08x\n",
187 readl(host->ioaddr + SDHCI_CAPABILITIES),
188 readl(host->ioaddr + SDHCI_MAX_CURRENT));
190 printk(KERN_DEBUG DRIVER_NAME ": ===========================================\n");
193 /*****************************************************************************\
195 * Low level functions *
197 \*****************************************************************************/
199 static void sdhci_reset(struct sdhci_host *host, u8 mask)
201 unsigned long timeout;
203 if (host->chip->quirks & SDHCI_QUIRK_NO_CARD_NO_RESET) {
204 if (!(readl(host->ioaddr + SDHCI_PRESENT_STATE) &
209 writeb(mask, host->ioaddr + SDHCI_SOFTWARE_RESET);
211 if (mask & SDHCI_RESET_ALL)
214 /* Wait max 100 ms */
217 /* hw clears the bit when it's done */
218 while (readb(host->ioaddr + SDHCI_SOFTWARE_RESET) & mask) {
220 printk(KERN_ERR "%s: Reset 0x%x never completed.\n",
221 mmc_hostname(host->mmc), (int)mask);
222 sdhci_dumpregs(host);
230 static void sdhci_init(struct sdhci_host *host)
234 sdhci_reset(host, SDHCI_RESET_ALL);
236 intmask = SDHCI_INT_BUS_POWER | SDHCI_INT_DATA_END_BIT |
237 SDHCI_INT_DATA_CRC | SDHCI_INT_DATA_TIMEOUT | SDHCI_INT_INDEX |
238 SDHCI_INT_END_BIT | SDHCI_INT_CRC | SDHCI_INT_TIMEOUT |
239 SDHCI_INT_CARD_REMOVE | SDHCI_INT_CARD_INSERT |
240 SDHCI_INT_DATA_AVAIL | SDHCI_INT_SPACE_AVAIL |
241 SDHCI_INT_DMA_END | SDHCI_INT_DATA_END | SDHCI_INT_RESPONSE;
243 writel(intmask, host->ioaddr + SDHCI_INT_ENABLE);
244 writel(intmask, host->ioaddr + SDHCI_SIGNAL_ENABLE);
247 static void sdhci_activate_led(struct sdhci_host *host)
251 ctrl = readb(host->ioaddr + SDHCI_HOST_CONTROL);
252 ctrl |= SDHCI_CTRL_LED;
253 writeb(ctrl, host->ioaddr + SDHCI_HOST_CONTROL);
256 static void sdhci_deactivate_led(struct sdhci_host *host)
260 ctrl = readb(host->ioaddr + SDHCI_HOST_CONTROL);
261 ctrl &= ~SDHCI_CTRL_LED;
262 writeb(ctrl, host->ioaddr + SDHCI_HOST_CONTROL);
265 #ifdef CONFIG_LEDS_CLASS
266 static void sdhci_led_control(struct led_classdev *led,
267 enum led_brightness brightness)
269 struct sdhci_host *host = container_of(led, struct sdhci_host, led);
272 spin_lock_irqsave(&host->lock, flags);
274 if (brightness == LED_OFF)
275 sdhci_deactivate_led(host);
277 sdhci_activate_led(host);
279 spin_unlock_irqrestore(&host->lock, flags);
283 /*****************************************************************************\
287 \*****************************************************************************/
289 static inline char* sdhci_sg_to_buffer(struct sdhci_host* host)
291 return sg_virt(host->cur_sg);
294 static inline int sdhci_next_sg(struct sdhci_host* host)
297 * Skip to next SG entry.
305 if (host->num_sg > 0) {
307 host->remain = host->cur_sg->length;
313 static void sdhci_read_block_pio(struct sdhci_host *host)
315 int blksize, chunk_remain;
320 DBG("PIO reading\n");
322 blksize = host->data->blksz;
326 buffer = sdhci_sg_to_buffer(host) + host->offset;
329 if (chunk_remain == 0) {
330 data = readl(host->ioaddr + SDHCI_BUFFER);
331 chunk_remain = min(blksize, 4);
334 size = min(host->remain, chunk_remain);
336 chunk_remain -= size;
338 host->offset += size;
339 host->remain -= size;
342 *buffer = data & 0xFF;
348 if (host->remain == 0) {
349 if (sdhci_next_sg(host) == 0) {
350 BUG_ON(blksize != 0);
353 buffer = sdhci_sg_to_buffer(host);
358 static void sdhci_write_block_pio(struct sdhci_host *host)
360 int blksize, chunk_remain;
365 DBG("PIO writing\n");
367 blksize = host->data->blksz;
372 buffer = sdhci_sg_to_buffer(host) + host->offset;
375 size = min(host->remain, chunk_remain);
377 chunk_remain -= size;
379 host->offset += size;
380 host->remain -= size;
384 data |= (u32)*buffer << 24;
389 if (chunk_remain == 0) {
390 writel(data, host->ioaddr + SDHCI_BUFFER);
391 chunk_remain = min(blksize, 4);
394 if (host->remain == 0) {
395 if (sdhci_next_sg(host) == 0) {
396 BUG_ON(blksize != 0);
399 buffer = sdhci_sg_to_buffer(host);
404 static void sdhci_transfer_pio(struct sdhci_host *host)
410 if (host->num_sg == 0)
413 if (host->data->flags & MMC_DATA_READ)
414 mask = SDHCI_DATA_AVAILABLE;
416 mask = SDHCI_SPACE_AVAILABLE;
418 while (readl(host->ioaddr + SDHCI_PRESENT_STATE) & mask) {
419 if (host->data->flags & MMC_DATA_READ)
420 sdhci_read_block_pio(host);
422 sdhci_write_block_pio(host);
424 if (host->num_sg == 0)
428 DBG("PIO transfer complete.\n");
431 static void sdhci_prepare_data(struct sdhci_host *host, struct mmc_data *data)
434 unsigned target_timeout, current_timeout;
442 BUG_ON(data->blksz * data->blocks > 524288);
443 BUG_ON(data->blksz > host->mmc->max_blk_size);
444 BUG_ON(data->blocks > 65535);
447 host->data_early = 0;
450 target_timeout = data->timeout_ns / 1000 +
451 data->timeout_clks / host->clock;
454 * Figure out needed cycles.
455 * We do this in steps in order to fit inside a 32 bit int.
456 * The first step is the minimum timeout, which will have a
457 * minimum resolution of 6 bits:
458 * (1) 2^13*1000 > 2^22,
459 * (2) host->timeout_clk < 2^16
464 current_timeout = (1 << 13) * 1000 / host->timeout_clk;
465 while (current_timeout < target_timeout) {
467 current_timeout <<= 1;
473 printk(KERN_WARNING "%s: Too large timeout requested!\n",
474 mmc_hostname(host->mmc));
478 writeb(count, host->ioaddr + SDHCI_TIMEOUT_CONTROL);
480 if (host->flags & SDHCI_USE_DMA)
481 host->flags |= SDHCI_REQ_USE_DMA;
483 if (unlikely((host->flags & SDHCI_REQ_USE_DMA) &&
484 (host->chip->quirks & SDHCI_QUIRK_32BIT_DMA_SIZE) &&
485 ((data->blksz * data->blocks) & 0x3))) {
486 DBG("Reverting to PIO because of transfer size (%d)\n",
487 data->blksz * data->blocks);
488 host->flags &= ~SDHCI_REQ_USE_DMA;
492 * The assumption here being that alignment is the same after
493 * translation to device address space.
495 if (unlikely((host->flags & SDHCI_REQ_USE_DMA) &&
496 (host->chip->quirks & SDHCI_QUIRK_32BIT_DMA_ADDR) &&
497 (data->sg->offset & 0x3))) {
498 DBG("Reverting to PIO because of bad alignment\n");
499 host->flags &= ~SDHCI_REQ_USE_DMA;
502 if (host->flags & SDHCI_REQ_USE_DMA) {
505 count = pci_map_sg(host->chip->pdev, data->sg, data->sg_len,
506 (data->flags & MMC_DATA_READ)?PCI_DMA_FROMDEVICE:PCI_DMA_TODEVICE);
509 writel(sg_dma_address(data->sg), host->ioaddr + SDHCI_DMA_ADDRESS);
511 host->cur_sg = data->sg;
512 host->num_sg = data->sg_len;
515 host->remain = host->cur_sg->length;
518 /* We do not handle DMA boundaries, so set it to max (512 KiB) */
519 writew(SDHCI_MAKE_BLKSZ(7, data->blksz),
520 host->ioaddr + SDHCI_BLOCK_SIZE);
521 writew(data->blocks, host->ioaddr + SDHCI_BLOCK_COUNT);
524 static void sdhci_set_transfer_mode(struct sdhci_host *host,
525 struct mmc_data *data)
532 WARN_ON(!host->data);
534 mode = SDHCI_TRNS_BLK_CNT_EN;
535 if (data->blocks > 1)
536 mode |= SDHCI_TRNS_MULTI;
537 if (data->flags & MMC_DATA_READ)
538 mode |= SDHCI_TRNS_READ;
539 if (host->flags & SDHCI_REQ_USE_DMA)
540 mode |= SDHCI_TRNS_DMA;
542 writew(mode, host->ioaddr + SDHCI_TRANSFER_MODE);
545 static void sdhci_finish_data(struct sdhci_host *host)
547 struct mmc_data *data;
555 if (host->flags & SDHCI_REQ_USE_DMA) {
556 pci_unmap_sg(host->chip->pdev, data->sg, data->sg_len,
557 (data->flags & MMC_DATA_READ)?PCI_DMA_FROMDEVICE:PCI_DMA_TODEVICE);
561 * Controller doesn't count down when in single block mode.
563 if (data->blocks == 1)
564 blocks = (data->error == 0) ? 0 : 1;
566 blocks = readw(host->ioaddr + SDHCI_BLOCK_COUNT);
567 data->bytes_xfered = data->blksz * (data->blocks - blocks);
569 if (!data->error && blocks) {
570 printk(KERN_ERR "%s: Controller signalled completion even "
571 "though there were blocks left.\n",
572 mmc_hostname(host->mmc));
578 * The controller needs a reset of internal state machines
579 * upon error conditions.
582 sdhci_reset(host, SDHCI_RESET_CMD);
583 sdhci_reset(host, SDHCI_RESET_DATA);
586 sdhci_send_command(host, data->stop);
588 tasklet_schedule(&host->finish_tasklet);
591 static void sdhci_send_command(struct sdhci_host *host, struct mmc_command *cmd)
595 unsigned long timeout;
602 mask = SDHCI_CMD_INHIBIT;
603 if ((cmd->data != NULL) || (cmd->flags & MMC_RSP_BUSY))
604 mask |= SDHCI_DATA_INHIBIT;
606 /* We shouldn't wait for data inihibit for stop commands, even
607 though they might use busy signaling */
608 if (host->mrq->data && (cmd == host->mrq->data->stop))
609 mask &= ~SDHCI_DATA_INHIBIT;
611 while (readl(host->ioaddr + SDHCI_PRESENT_STATE) & mask) {
613 printk(KERN_ERR "%s: Controller never released "
614 "inhibit bit(s).\n", mmc_hostname(host->mmc));
615 sdhci_dumpregs(host);
617 tasklet_schedule(&host->finish_tasklet);
624 mod_timer(&host->timer, jiffies + 10 * HZ);
628 sdhci_prepare_data(host, cmd->data);
630 writel(cmd->arg, host->ioaddr + SDHCI_ARGUMENT);
632 sdhci_set_transfer_mode(host, cmd->data);
634 if ((cmd->flags & MMC_RSP_136) && (cmd->flags & MMC_RSP_BUSY)) {
635 printk(KERN_ERR "%s: Unsupported response type!\n",
636 mmc_hostname(host->mmc));
637 cmd->error = -EINVAL;
638 tasklet_schedule(&host->finish_tasklet);
642 if (!(cmd->flags & MMC_RSP_PRESENT))
643 flags = SDHCI_CMD_RESP_NONE;
644 else if (cmd->flags & MMC_RSP_136)
645 flags = SDHCI_CMD_RESP_LONG;
646 else if (cmd->flags & MMC_RSP_BUSY)
647 flags = SDHCI_CMD_RESP_SHORT_BUSY;
649 flags = SDHCI_CMD_RESP_SHORT;
651 if (cmd->flags & MMC_RSP_CRC)
652 flags |= SDHCI_CMD_CRC;
653 if (cmd->flags & MMC_RSP_OPCODE)
654 flags |= SDHCI_CMD_INDEX;
656 flags |= SDHCI_CMD_DATA;
658 writew(SDHCI_MAKE_CMD(cmd->opcode, flags),
659 host->ioaddr + SDHCI_COMMAND);
662 static void sdhci_finish_command(struct sdhci_host *host)
666 BUG_ON(host->cmd == NULL);
668 if (host->cmd->flags & MMC_RSP_PRESENT) {
669 if (host->cmd->flags & MMC_RSP_136) {
670 /* CRC is stripped so we need to do some shifting. */
671 for (i = 0;i < 4;i++) {
672 host->cmd->resp[i] = readl(host->ioaddr +
673 SDHCI_RESPONSE + (3-i)*4) << 8;
675 host->cmd->resp[i] |=
677 SDHCI_RESPONSE + (3-i)*4-1);
680 host->cmd->resp[0] = readl(host->ioaddr + SDHCI_RESPONSE);
684 host->cmd->error = 0;
686 if (host->data && host->data_early)
687 sdhci_finish_data(host);
689 if (!host->cmd->data)
690 tasklet_schedule(&host->finish_tasklet);
695 static void sdhci_set_clock(struct sdhci_host *host, unsigned int clock)
699 unsigned long timeout;
701 if (clock == host->clock)
704 writew(0, host->ioaddr + SDHCI_CLOCK_CONTROL);
709 for (div = 1;div < 256;div *= 2) {
710 if ((host->max_clk / div) <= clock)
715 clk = div << SDHCI_DIVIDER_SHIFT;
716 clk |= SDHCI_CLOCK_INT_EN;
717 writew(clk, host->ioaddr + SDHCI_CLOCK_CONTROL);
721 while (!((clk = readw(host->ioaddr + SDHCI_CLOCK_CONTROL))
722 & SDHCI_CLOCK_INT_STABLE)) {
724 printk(KERN_ERR "%s: Internal clock never "
725 "stabilised.\n", mmc_hostname(host->mmc));
726 sdhci_dumpregs(host);
733 clk |= SDHCI_CLOCK_CARD_EN;
734 writew(clk, host->ioaddr + SDHCI_CLOCK_CONTROL);
740 static void sdhci_set_power(struct sdhci_host *host, unsigned short power)
744 if (host->power == power)
747 if (power == (unsigned short)-1) {
748 writeb(0, host->ioaddr + SDHCI_POWER_CONTROL);
753 * Spec says that we should clear the power reg before setting
754 * a new value. Some controllers don't seem to like this though.
756 if (!(host->chip->quirks & SDHCI_QUIRK_SINGLE_POWER_WRITE))
757 writeb(0, host->ioaddr + SDHCI_POWER_CONTROL);
759 pwr = SDHCI_POWER_ON;
761 switch (1 << power) {
762 case MMC_VDD_165_195:
763 pwr |= SDHCI_POWER_180;
767 pwr |= SDHCI_POWER_300;
771 pwr |= SDHCI_POWER_330;
777 writeb(pwr, host->ioaddr + SDHCI_POWER_CONTROL);
783 /*****************************************************************************\
787 \*****************************************************************************/
789 static void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq)
791 struct sdhci_host *host;
794 host = mmc_priv(mmc);
796 spin_lock_irqsave(&host->lock, flags);
798 WARN_ON(host->mrq != NULL);
800 #ifndef CONFIG_LEDS_CLASS
801 sdhci_activate_led(host);
806 if (!(readl(host->ioaddr + SDHCI_PRESENT_STATE) & SDHCI_CARD_PRESENT)) {
807 host->mrq->cmd->error = -ENOMEDIUM;
808 tasklet_schedule(&host->finish_tasklet);
810 sdhci_send_command(host, mrq->cmd);
813 spin_unlock_irqrestore(&host->lock, flags);
816 static void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
818 struct sdhci_host *host;
822 host = mmc_priv(mmc);
824 spin_lock_irqsave(&host->lock, flags);
827 * Reset the chip on each power off.
828 * Should clear out any weird states.
830 if (ios->power_mode == MMC_POWER_OFF) {
831 writel(0, host->ioaddr + SDHCI_SIGNAL_ENABLE);
835 sdhci_set_clock(host, ios->clock);
837 if (ios->power_mode == MMC_POWER_OFF)
838 sdhci_set_power(host, -1);
840 sdhci_set_power(host, ios->vdd);
842 ctrl = readb(host->ioaddr + SDHCI_HOST_CONTROL);
844 if (ios->bus_width == MMC_BUS_WIDTH_4)
845 ctrl |= SDHCI_CTRL_4BITBUS;
847 ctrl &= ~SDHCI_CTRL_4BITBUS;
849 if (ios->timing == MMC_TIMING_SD_HS)
850 ctrl |= SDHCI_CTRL_HISPD;
852 ctrl &= ~SDHCI_CTRL_HISPD;
854 writeb(ctrl, host->ioaddr + SDHCI_HOST_CONTROL);
857 * Some (ENE) controllers go apeshit on some ios operation,
858 * signalling timeout and CRC errors even on CMD0. Resetting
859 * it on each ios seems to solve the problem.
861 if(host->chip->quirks & SDHCI_QUIRK_RESET_CMD_DATA_ON_IOS)
862 sdhci_reset(host, SDHCI_RESET_CMD | SDHCI_RESET_DATA);
865 spin_unlock_irqrestore(&host->lock, flags);
868 static int sdhci_get_ro(struct mmc_host *mmc)
870 struct sdhci_host *host;
874 host = mmc_priv(mmc);
876 spin_lock_irqsave(&host->lock, flags);
878 present = readl(host->ioaddr + SDHCI_PRESENT_STATE);
880 spin_unlock_irqrestore(&host->lock, flags);
882 return !(present & SDHCI_WRITE_PROTECT);
885 static void sdhci_enable_sdio_irq(struct mmc_host *mmc, int enable)
887 struct sdhci_host *host;
891 host = mmc_priv(mmc);
893 spin_lock_irqsave(&host->lock, flags);
895 ier = readl(host->ioaddr + SDHCI_INT_ENABLE);
897 ier &= ~SDHCI_INT_CARD_INT;
899 ier |= SDHCI_INT_CARD_INT;
901 writel(ier, host->ioaddr + SDHCI_INT_ENABLE);
902 writel(ier, host->ioaddr + SDHCI_SIGNAL_ENABLE);
906 spin_unlock_irqrestore(&host->lock, flags);
909 static const struct mmc_host_ops sdhci_ops = {
910 .request = sdhci_request,
911 .set_ios = sdhci_set_ios,
912 .get_ro = sdhci_get_ro,
913 .enable_sdio_irq = sdhci_enable_sdio_irq,
916 /*****************************************************************************\
920 \*****************************************************************************/
922 static void sdhci_tasklet_card(unsigned long param)
924 struct sdhci_host *host;
927 host = (struct sdhci_host*)param;
929 spin_lock_irqsave(&host->lock, flags);
931 if (!(readl(host->ioaddr + SDHCI_PRESENT_STATE) & SDHCI_CARD_PRESENT)) {
933 printk(KERN_ERR "%s: Card removed during transfer!\n",
934 mmc_hostname(host->mmc));
935 printk(KERN_ERR "%s: Resetting controller.\n",
936 mmc_hostname(host->mmc));
938 sdhci_reset(host, SDHCI_RESET_CMD);
939 sdhci_reset(host, SDHCI_RESET_DATA);
941 host->mrq->cmd->error = -ENOMEDIUM;
942 tasklet_schedule(&host->finish_tasklet);
946 spin_unlock_irqrestore(&host->lock, flags);
948 mmc_detect_change(host->mmc, msecs_to_jiffies(500));
951 static void sdhci_tasklet_finish(unsigned long param)
953 struct sdhci_host *host;
955 struct mmc_request *mrq;
957 host = (struct sdhci_host*)param;
959 spin_lock_irqsave(&host->lock, flags);
961 del_timer(&host->timer);
966 * The controller needs a reset of internal state machines
967 * upon error conditions.
969 if (mrq->cmd->error ||
970 (mrq->data && (mrq->data->error ||
971 (mrq->data->stop && mrq->data->stop->error))) ||
972 (host->chip->quirks & SDHCI_QUIRK_RESET_AFTER_REQUEST)) {
974 /* Some controllers need this kick or reset won't work here */
975 if (host->chip->quirks & SDHCI_QUIRK_CLOCK_BEFORE_RESET) {
978 /* This is to force an update */
981 sdhci_set_clock(host, clock);
984 /* Spec says we should do both at the same time, but Ricoh
985 controllers do not like that. */
986 sdhci_reset(host, SDHCI_RESET_CMD);
987 sdhci_reset(host, SDHCI_RESET_DATA);
994 #ifndef CONFIG_LEDS_CLASS
995 sdhci_deactivate_led(host);
999 spin_unlock_irqrestore(&host->lock, flags);
1001 mmc_request_done(host->mmc, mrq);
1004 static void sdhci_timeout_timer(unsigned long data)
1006 struct sdhci_host *host;
1007 unsigned long flags;
1009 host = (struct sdhci_host*)data;
1011 spin_lock_irqsave(&host->lock, flags);
1014 printk(KERN_ERR "%s: Timeout waiting for hardware "
1015 "interrupt.\n", mmc_hostname(host->mmc));
1016 sdhci_dumpregs(host);
1019 host->data->error = -ETIMEDOUT;
1020 sdhci_finish_data(host);
1023 host->cmd->error = -ETIMEDOUT;
1025 host->mrq->cmd->error = -ETIMEDOUT;
1027 tasklet_schedule(&host->finish_tasklet);
1032 spin_unlock_irqrestore(&host->lock, flags);
1035 /*****************************************************************************\
1037 * Interrupt handling *
1039 \*****************************************************************************/
1041 static void sdhci_cmd_irq(struct sdhci_host *host, u32 intmask)
1043 BUG_ON(intmask == 0);
1046 printk(KERN_ERR "%s: Got command interrupt 0x%08x even "
1047 "though no command operation was in progress.\n",
1048 mmc_hostname(host->mmc), (unsigned)intmask);
1049 sdhci_dumpregs(host);
1053 if (intmask & SDHCI_INT_TIMEOUT)
1054 host->cmd->error = -ETIMEDOUT;
1055 else if (intmask & (SDHCI_INT_CRC | SDHCI_INT_END_BIT |
1057 host->cmd->error = -EILSEQ;
1059 if (host->cmd->error)
1060 tasklet_schedule(&host->finish_tasklet);
1061 else if (intmask & SDHCI_INT_RESPONSE)
1062 sdhci_finish_command(host);
1065 static void sdhci_data_irq(struct sdhci_host *host, u32 intmask)
1067 BUG_ON(intmask == 0);
1071 * A data end interrupt is sent together with the response
1072 * for the stop command.
1074 if (intmask & SDHCI_INT_DATA_END)
1077 printk(KERN_ERR "%s: Got data interrupt 0x%08x even "
1078 "though no data operation was in progress.\n",
1079 mmc_hostname(host->mmc), (unsigned)intmask);
1080 sdhci_dumpregs(host);
1085 if (intmask & SDHCI_INT_DATA_TIMEOUT)
1086 host->data->error = -ETIMEDOUT;
1087 else if (intmask & (SDHCI_INT_DATA_CRC | SDHCI_INT_DATA_END_BIT))
1088 host->data->error = -EILSEQ;
1090 if (host->data->error)
1091 sdhci_finish_data(host);
1093 if (intmask & (SDHCI_INT_DATA_AVAIL | SDHCI_INT_SPACE_AVAIL))
1094 sdhci_transfer_pio(host);
1097 * We currently don't do anything fancy with DMA
1098 * boundaries, but as we can't disable the feature
1099 * we need to at least restart the transfer.
1101 if (intmask & SDHCI_INT_DMA_END)
1102 writel(readl(host->ioaddr + SDHCI_DMA_ADDRESS),
1103 host->ioaddr + SDHCI_DMA_ADDRESS);
1105 if (intmask & SDHCI_INT_DATA_END) {
1108 * Data managed to finish before the
1109 * command completed. Make sure we do
1110 * things in the proper order.
1112 host->data_early = 1;
1114 sdhci_finish_data(host);
1120 static irqreturn_t sdhci_irq(int irq, void *dev_id)
1123 struct sdhci_host* host = dev_id;
1127 spin_lock(&host->lock);
1129 intmask = readl(host->ioaddr + SDHCI_INT_STATUS);
1131 if (!intmask || intmask == 0xffffffff) {
1136 DBG("*** %s got interrupt: 0x%08x\n",
1137 mmc_hostname(host->mmc), intmask);
1139 if (intmask & (SDHCI_INT_CARD_INSERT | SDHCI_INT_CARD_REMOVE)) {
1140 writel(intmask & (SDHCI_INT_CARD_INSERT | SDHCI_INT_CARD_REMOVE),
1141 host->ioaddr + SDHCI_INT_STATUS);
1142 tasklet_schedule(&host->card_tasklet);
1145 intmask &= ~(SDHCI_INT_CARD_INSERT | SDHCI_INT_CARD_REMOVE);
1147 if (intmask & SDHCI_INT_CMD_MASK) {
1148 writel(intmask & SDHCI_INT_CMD_MASK,
1149 host->ioaddr + SDHCI_INT_STATUS);
1150 sdhci_cmd_irq(host, intmask & SDHCI_INT_CMD_MASK);
1153 if (intmask & SDHCI_INT_DATA_MASK) {
1154 writel(intmask & SDHCI_INT_DATA_MASK,
1155 host->ioaddr + SDHCI_INT_STATUS);
1156 sdhci_data_irq(host, intmask & SDHCI_INT_DATA_MASK);
1159 intmask &= ~(SDHCI_INT_CMD_MASK | SDHCI_INT_DATA_MASK);
1161 intmask &= ~SDHCI_INT_ERROR;
1163 if (intmask & SDHCI_INT_BUS_POWER) {
1164 printk(KERN_ERR "%s: Card is consuming too much power!\n",
1165 mmc_hostname(host->mmc));
1166 writel(SDHCI_INT_BUS_POWER, host->ioaddr + SDHCI_INT_STATUS);
1169 intmask &= ~SDHCI_INT_BUS_POWER;
1171 if (intmask & SDHCI_INT_CARD_INT)
1174 intmask &= ~SDHCI_INT_CARD_INT;
1177 printk(KERN_ERR "%s: Unexpected interrupt 0x%08x.\n",
1178 mmc_hostname(host->mmc), intmask);
1179 sdhci_dumpregs(host);
1181 writel(intmask, host->ioaddr + SDHCI_INT_STATUS);
1184 result = IRQ_HANDLED;
1188 spin_unlock(&host->lock);
1191 * We have to delay this as it calls back into the driver.
1194 mmc_signal_sdio_irq(host->mmc);
1199 /*****************************************************************************\
1203 \*****************************************************************************/
1207 static int sdhci_suspend (struct pci_dev *pdev, pm_message_t state)
1209 struct sdhci_chip *chip;
1212 chip = pci_get_drvdata(pdev);
1216 DBG("Suspending...\n");
1218 for (i = 0;i < chip->num_slots;i++) {
1219 if (!chip->hosts[i])
1221 ret = mmc_suspend_host(chip->hosts[i]->mmc, state);
1223 for (i--;i >= 0;i--)
1224 mmc_resume_host(chip->hosts[i]->mmc);
1229 pci_save_state(pdev);
1230 pci_enable_wake(pdev, pci_choose_state(pdev, state), 0);
1232 for (i = 0;i < chip->num_slots;i++) {
1233 if (!chip->hosts[i])
1235 free_irq(chip->hosts[i]->irq, chip->hosts[i]);
1238 pci_disable_device(pdev);
1239 pci_set_power_state(pdev, pci_choose_state(pdev, state));
1244 static int sdhci_resume (struct pci_dev *pdev)
1246 struct sdhci_chip *chip;
1249 chip = pci_get_drvdata(pdev);
1253 DBG("Resuming...\n");
1255 pci_set_power_state(pdev, PCI_D0);
1256 pci_restore_state(pdev);
1257 ret = pci_enable_device(pdev);
1261 for (i = 0;i < chip->num_slots;i++) {
1262 if (!chip->hosts[i])
1264 if (chip->hosts[i]->flags & SDHCI_USE_DMA)
1265 pci_set_master(pdev);
1266 ret = request_irq(chip->hosts[i]->irq, sdhci_irq,
1267 IRQF_SHARED, mmc_hostname(chip->hosts[i]->mmc),
1271 sdhci_init(chip->hosts[i]);
1273 ret = mmc_resume_host(chip->hosts[i]->mmc);
1281 #else /* CONFIG_PM */
1283 #define sdhci_suspend NULL
1284 #define sdhci_resume NULL
1286 #endif /* CONFIG_PM */
1288 /*****************************************************************************\
1290 * Device probing/removal *
1292 \*****************************************************************************/
1294 static int __devinit sdhci_probe_slot(struct pci_dev *pdev, int slot)
1297 unsigned int version;
1298 struct sdhci_chip *chip;
1299 struct mmc_host *mmc;
1300 struct sdhci_host *host;
1305 chip = pci_get_drvdata(pdev);
1308 ret = pci_read_config_byte(pdev, PCI_SLOT_INFO, &first_bar);
1312 first_bar &= PCI_SLOT_INFO_FIRST_BAR_MASK;
1314 if (first_bar > 5) {
1315 printk(KERN_ERR DRIVER_NAME ": Invalid first BAR. Aborting.\n");
1319 if (!(pci_resource_flags(pdev, first_bar + slot) & IORESOURCE_MEM)) {
1320 printk(KERN_ERR DRIVER_NAME ": BAR is not iomem. Aborting.\n");
1324 if (pci_resource_len(pdev, first_bar + slot) != 0x100) {
1325 printk(KERN_ERR DRIVER_NAME ": Invalid iomem size. "
1326 "You may experience problems.\n");
1329 if ((pdev->class & 0x0000FF) == PCI_SDHCI_IFVENDOR) {
1330 printk(KERN_ERR DRIVER_NAME ": Vendor specific interface. Aborting.\n");
1334 if ((pdev->class & 0x0000FF) > PCI_SDHCI_IFVENDOR) {
1335 printk(KERN_ERR DRIVER_NAME ": Unknown interface. Aborting.\n");
1339 mmc = mmc_alloc_host(sizeof(struct sdhci_host), &pdev->dev);
1343 host = mmc_priv(mmc);
1347 chip->hosts[slot] = host;
1349 host->bar = first_bar + slot;
1351 host->addr = pci_resource_start(pdev, host->bar);
1352 host->irq = pdev->irq;
1354 DBG("slot %d at 0x%08lx, irq %d\n", slot, host->addr, host->irq);
1356 ret = pci_request_region(pdev, host->bar, mmc_hostname(mmc));
1360 host->ioaddr = ioremap_nocache(host->addr,
1361 pci_resource_len(pdev, host->bar));
1362 if (!host->ioaddr) {
1367 sdhci_reset(host, SDHCI_RESET_ALL);
1369 version = readw(host->ioaddr + SDHCI_HOST_VERSION);
1370 version = (version & SDHCI_SPEC_VER_MASK) >> SDHCI_SPEC_VER_SHIFT;
1372 printk(KERN_ERR "%s: Unknown controller version (%d). "
1373 "You may experience problems.\n", mmc_hostname(mmc),
1377 caps = readl(host->ioaddr + SDHCI_CAPABILITIES);
1379 if (chip->quirks & SDHCI_QUIRK_FORCE_DMA)
1380 host->flags |= SDHCI_USE_DMA;
1381 else if (!(caps & SDHCI_CAN_DO_DMA))
1382 DBG("Controller doesn't have DMA capability\n");
1384 host->flags |= SDHCI_USE_DMA;
1386 if ((chip->quirks & SDHCI_QUIRK_BROKEN_DMA) &&
1387 (host->flags & SDHCI_USE_DMA)) {
1388 DBG("Disabling DMA as it is marked broken\n");
1389 host->flags &= ~SDHCI_USE_DMA;
1392 if (((pdev->class & 0x0000FF) != PCI_SDHCI_IFDMA) &&
1393 (host->flags & SDHCI_USE_DMA)) {
1394 printk(KERN_WARNING "%s: Will use DMA "
1395 "mode even though HW doesn't fully "
1396 "claim to support it.\n", mmc_hostname(mmc));
1399 if (host->flags & SDHCI_USE_DMA) {
1400 if (pci_set_dma_mask(pdev, DMA_32BIT_MASK)) {
1401 printk(KERN_WARNING "%s: No suitable DMA available. "
1402 "Falling back to PIO.\n", mmc_hostname(mmc));
1403 host->flags &= ~SDHCI_USE_DMA;
1407 if (host->flags & SDHCI_USE_DMA)
1408 pci_set_master(pdev);
1409 else /* XXX: Hack to get MMC layer to avoid highmem */
1413 (caps & SDHCI_CLOCK_BASE_MASK) >> SDHCI_CLOCK_BASE_SHIFT;
1414 if (host->max_clk == 0) {
1415 printk(KERN_ERR "%s: Hardware doesn't specify base clock "
1416 "frequency.\n", mmc_hostname(mmc));
1420 host->max_clk *= 1000000;
1423 (caps & SDHCI_TIMEOUT_CLK_MASK) >> SDHCI_TIMEOUT_CLK_SHIFT;
1424 if (host->timeout_clk == 0) {
1425 printk(KERN_ERR "%s: Hardware doesn't specify timeout clock "
1426 "frequency.\n", mmc_hostname(mmc));
1430 if (caps & SDHCI_TIMEOUT_CLK_UNIT)
1431 host->timeout_clk *= 1000;
1434 * Set host parameters.
1436 mmc->ops = &sdhci_ops;
1437 mmc->f_min = host->max_clk / 256;
1438 mmc->f_max = host->max_clk;
1439 mmc->caps = MMC_CAP_4_BIT_DATA | MMC_CAP_MULTIWRITE | MMC_CAP_SDIO_IRQ;
1441 if (caps & SDHCI_CAN_DO_HISPD)
1442 mmc->caps |= MMC_CAP_SD_HIGHSPEED;
1445 if (caps & SDHCI_CAN_VDD_330)
1446 mmc->ocr_avail |= MMC_VDD_32_33|MMC_VDD_33_34;
1447 if (caps & SDHCI_CAN_VDD_300)
1448 mmc->ocr_avail |= MMC_VDD_29_30|MMC_VDD_30_31;
1449 if (caps & SDHCI_CAN_VDD_180)
1450 mmc->ocr_avail |= MMC_VDD_165_195;
1452 if (mmc->ocr_avail == 0) {
1453 printk(KERN_ERR "%s: Hardware doesn't report any "
1454 "support voltages.\n", mmc_hostname(mmc));
1459 spin_lock_init(&host->lock);
1462 * Maximum number of segments. Hardware cannot do scatter lists.
1464 if (host->flags & SDHCI_USE_DMA)
1465 mmc->max_hw_segs = 1;
1467 mmc->max_hw_segs = 16;
1468 mmc->max_phys_segs = 16;
1471 * Maximum number of sectors in one transfer. Limited by DMA boundary
1474 mmc->max_req_size = 524288;
1477 * Maximum segment size. Could be one segment with the maximum number
1480 mmc->max_seg_size = mmc->max_req_size;
1483 * Maximum block size. This varies from controller to controller and
1484 * is specified in the capabilities register.
1486 mmc->max_blk_size = (caps & SDHCI_MAX_BLOCK_MASK) >> SDHCI_MAX_BLOCK_SHIFT;
1487 if (mmc->max_blk_size >= 3) {
1488 printk(KERN_WARNING "%s: Invalid maximum block size, "
1489 "assuming 512 bytes\n", mmc_hostname(mmc));
1490 mmc->max_blk_size = 512;
1492 mmc->max_blk_size = 512 << mmc->max_blk_size;
1495 * Maximum block count.
1497 mmc->max_blk_count = 65535;
1502 tasklet_init(&host->card_tasklet,
1503 sdhci_tasklet_card, (unsigned long)host);
1504 tasklet_init(&host->finish_tasklet,
1505 sdhci_tasklet_finish, (unsigned long)host);
1507 setup_timer(&host->timer, sdhci_timeout_timer, (unsigned long)host);
1509 ret = request_irq(host->irq, sdhci_irq, IRQF_SHARED,
1510 mmc_hostname(mmc), host);
1516 #ifdef CONFIG_MMC_DEBUG
1517 sdhci_dumpregs(host);
1520 #ifdef CONFIG_LEDS_CLASS
1521 host->led.name = mmc_hostname(mmc);
1522 host->led.brightness = LED_OFF;
1523 host->led.default_trigger = mmc_hostname(mmc);
1524 host->led.brightness_set = sdhci_led_control;
1526 ret = led_classdev_register(&pdev->dev, &host->led);
1535 printk(KERN_INFO "%s: SDHCI at 0x%08lx irq %d %s\n",
1536 mmc_hostname(mmc), host->addr, host->irq,
1537 (host->flags & SDHCI_USE_DMA)?"DMA":"PIO");
1541 #ifdef CONFIG_LEDS_CLASS
1543 sdhci_reset(host, SDHCI_RESET_ALL);
1544 free_irq(host->irq, host);
1547 tasklet_kill(&host->card_tasklet);
1548 tasklet_kill(&host->finish_tasklet);
1550 iounmap(host->ioaddr);
1552 pci_release_region(pdev, host->bar);
1559 static void sdhci_remove_slot(struct pci_dev *pdev, int slot)
1561 struct sdhci_chip *chip;
1562 struct mmc_host *mmc;
1563 struct sdhci_host *host;
1565 chip = pci_get_drvdata(pdev);
1566 host = chip->hosts[slot];
1569 chip->hosts[slot] = NULL;
1571 mmc_remove_host(mmc);
1573 #ifdef CONFIG_LEDS_CLASS
1574 led_classdev_unregister(&host->led);
1577 sdhci_reset(host, SDHCI_RESET_ALL);
1579 free_irq(host->irq, host);
1581 del_timer_sync(&host->timer);
1583 tasklet_kill(&host->card_tasklet);
1584 tasklet_kill(&host->finish_tasklet);
1586 iounmap(host->ioaddr);
1588 pci_release_region(pdev, host->bar);
1593 static int __devinit sdhci_probe(struct pci_dev *pdev,
1594 const struct pci_device_id *ent)
1598 struct sdhci_chip *chip;
1600 BUG_ON(pdev == NULL);
1601 BUG_ON(ent == NULL);
1603 pci_read_config_byte(pdev, PCI_CLASS_REVISION, &rev);
1605 printk(KERN_INFO DRIVER_NAME
1606 ": SDHCI controller found at %s [%04x:%04x] (rev %x)\n",
1607 pci_name(pdev), (int)pdev->vendor, (int)pdev->device,
1610 ret = pci_read_config_byte(pdev, PCI_SLOT_INFO, &slots);
1614 slots = PCI_SLOT_INFO_SLOTS(slots) + 1;
1615 DBG("found %d slot(s)\n", slots);
1619 ret = pci_enable_device(pdev);
1623 chip = kzalloc(sizeof(struct sdhci_chip) +
1624 sizeof(struct sdhci_host*) * slots, GFP_KERNEL);
1631 chip->quirks = ent->driver_data;
1634 chip->quirks = debug_quirks;
1636 chip->num_slots = slots;
1637 pci_set_drvdata(pdev, chip);
1639 for (i = 0;i < slots;i++) {
1640 ret = sdhci_probe_slot(pdev, i);
1642 for (i--;i >= 0;i--)
1643 sdhci_remove_slot(pdev, i);
1651 pci_set_drvdata(pdev, NULL);
1655 pci_disable_device(pdev);
1659 static void __devexit sdhci_remove(struct pci_dev *pdev)
1662 struct sdhci_chip *chip;
1664 chip = pci_get_drvdata(pdev);
1667 for (i = 0;i < chip->num_slots;i++)
1668 sdhci_remove_slot(pdev, i);
1670 pci_set_drvdata(pdev, NULL);
1675 pci_disable_device(pdev);
1678 static struct pci_driver sdhci_driver = {
1679 .name = DRIVER_NAME,
1680 .id_table = pci_ids,
1681 .probe = sdhci_probe,
1682 .remove = __devexit_p(sdhci_remove),
1683 .suspend = sdhci_suspend,
1684 .resume = sdhci_resume,
1687 /*****************************************************************************\
1689 * Driver init/exit *
1691 \*****************************************************************************/
1693 static int __init sdhci_drv_init(void)
1695 printk(KERN_INFO DRIVER_NAME
1696 ": Secure Digital Host Controller Interface driver\n");
1697 printk(KERN_INFO DRIVER_NAME ": Copyright(c) Pierre Ossman\n");
1699 return pci_register_driver(&sdhci_driver);
1702 static void __exit sdhci_drv_exit(void)
1706 pci_unregister_driver(&sdhci_driver);
1709 module_init(sdhci_drv_init);
1710 module_exit(sdhci_drv_exit);
1712 module_param(debug_quirks, uint, 0444);
1714 MODULE_AUTHOR("Pierre Ossman <drzeus@drzeus.cx>");
1715 MODULE_DESCRIPTION("Secure Digital Host Controller Interface driver");
1716 MODULE_LICENSE("GPL");
1718 MODULE_PARM_DESC(debug_quirks, "Force certain quirks.");