2 * drivers/mmc/host/omap_hsmmc.c
4 * Driver for OMAP2430/3430 MMC controller.
6 * Copyright (C) 2007 Texas Instruments.
9 * Syed Mohammed Khasim <x0khasim@ti.com>
10 * Madhusudhan <madhu.cr@ti.com>
11 * Mohit Jalori <mjalori@ti.com>
13 * This file is licensed under the terms of the GNU General Public License
14 * version 2. This program is licensed "as is" without any warranty of any
15 * kind, whether express or implied.
18 #include <linux/module.h>
19 #include <linux/init.h>
20 #include <linux/debugfs.h>
21 #include <linux/seq_file.h>
22 #include <linux/interrupt.h>
23 #include <linux/delay.h>
24 #include <linux/dma-mapping.h>
25 #include <linux/platform_device.h>
26 #include <linux/workqueue.h>
27 #include <linux/timer.h>
28 #include <linux/clk.h>
29 #include <linux/mmc/host.h>
31 #include <linux/semaphore.h>
33 #include <mach/hardware.h>
34 #include <mach/board.h>
38 /* OMAP HSMMC Host Controller Registers */
39 #define OMAP_HSMMC_SYSCONFIG 0x0010
40 #define OMAP_HSMMC_SYSSTATUS 0x0014
41 #define OMAP_HSMMC_CON 0x002C
42 #define OMAP_HSMMC_BLK 0x0104
43 #define OMAP_HSMMC_ARG 0x0108
44 #define OMAP_HSMMC_CMD 0x010C
45 #define OMAP_HSMMC_RSP10 0x0110
46 #define OMAP_HSMMC_RSP32 0x0114
47 #define OMAP_HSMMC_RSP54 0x0118
48 #define OMAP_HSMMC_RSP76 0x011C
49 #define OMAP_HSMMC_DATA 0x0120
50 #define OMAP_HSMMC_HCTL 0x0128
51 #define OMAP_HSMMC_SYSCTL 0x012C
52 #define OMAP_HSMMC_STAT 0x0130
53 #define OMAP_HSMMC_IE 0x0134
54 #define OMAP_HSMMC_ISE 0x0138
55 #define OMAP_HSMMC_CAPA 0x0140
57 #define VS18 (1 << 26)
58 #define VS30 (1 << 25)
59 #define SDVS18 (0x5 << 9)
60 #define SDVS30 (0x6 << 9)
61 #define SDVS33 (0x7 << 9)
62 #define SDVS_MASK 0x00000E00
63 #define SDVSCLR 0xFFFFF1FF
64 #define SDVSDET 0x00000400
71 #define CLKD_MASK 0x0000FFC0
73 #define DTO_MASK 0x000F0000
75 #define INT_EN_MASK 0x307F0033
76 #define BWR_ENABLE (1 << 4)
77 #define BRR_ENABLE (1 << 5)
78 #define INIT_STREAM (1 << 1)
79 #define DP_SELECT (1 << 21)
84 #define FOUR_BIT (1 << 1)
90 #define CMD_TIMEOUT (1 << 16)
91 #define DATA_TIMEOUT (1 << 20)
92 #define CMD_CRC (1 << 17)
93 #define DATA_CRC (1 << 21)
94 #define CARD_ERR (1 << 28)
95 #define STAT_CLEAR 0xFFFFFFFF
96 #define INIT_STREAM_CMD 0x00000000
97 #define DUAL_VOLT_OCR_BIT 7
100 #define SOFTRESET (1 << 1)
101 #define RESETDONE (1 << 0)
104 * FIXME: Most likely all the data using these _DEVID defines should come
105 * from the platform_data, or implemented in controller and slot specific
108 #define OMAP_MMC1_DEVID 0
109 #define OMAP_MMC2_DEVID 1
110 #define OMAP_MMC3_DEVID 2
112 #define MMC_TIMEOUT_MS 20
113 #define OMAP_MMC_MASTER_CLOCK 96000000
114 #define DRIVER_NAME "mmci-omap-hs"
117 * One controller can have multiple slots, like on some omap boards using
118 * omap.c controller driver. Luckily this is not currently done on any known
119 * omap_hsmmc.c device.
121 #define mmc_slot(host) (host->pdata->slots[host->slot_id])
124 * MMC Host controller read/write API's
126 #define OMAP_HSMMC_READ(base, reg) \
127 __raw_readl((base) + OMAP_HSMMC_##reg)
129 #define OMAP_HSMMC_WRITE(base, reg, val) \
130 __raw_writel((val), (base) + OMAP_HSMMC_##reg)
132 struct mmc_omap_host {
134 struct mmc_host *mmc;
135 struct mmc_request *mrq;
136 struct mmc_command *cmd;
137 struct mmc_data *data;
141 struct semaphore sem;
142 struct work_struct mmc_carddetect_work;
144 resource_size_t mapbase;
146 unsigned int dma_len;
147 unsigned int dma_sg_idx;
148 unsigned char bus_mode;
149 unsigned char power_mode;
155 int dma_line_tx, dma_line_rx;
161 struct omap_mmc_platform_data *pdata;
165 * Stop clock to the card
167 static void omap_mmc_stop_clock(struct mmc_omap_host *host)
169 OMAP_HSMMC_WRITE(host->base, SYSCTL,
170 OMAP_HSMMC_READ(host->base, SYSCTL) & ~CEN);
171 if ((OMAP_HSMMC_READ(host->base, SYSCTL) & CEN) != 0x0)
172 dev_dbg(mmc_dev(host->mmc), "MMC Clock is not stoped\n");
178 * Restore the MMC host context, if it was lost as result of a
179 * power state change.
181 static int omap_mmc_restore_ctx(struct mmc_omap_host *host)
183 struct mmc_ios *ios = &host->mmc->ios;
184 struct omap_mmc_platform_data *pdata = host->pdata;
185 int context_loss = 0;
188 unsigned long timeout;
190 if (pdata->get_context_loss_count) {
191 context_loss = pdata->get_context_loss_count(host->dev);
192 if (context_loss < 0)
196 dev_dbg(mmc_dev(host->mmc), "context was %slost\n",
197 context_loss == host->context_loss ? "not " : "");
198 if (host->context_loss == context_loss)
201 /* Wait for hardware reset */
202 timeout = jiffies + msecs_to_jiffies(MMC_TIMEOUT_MS);
203 while ((OMAP_HSMMC_READ(host->base, SYSSTATUS) & RESETDONE) != RESETDONE
204 && time_before(jiffies, timeout))
207 /* Do software reset */
208 OMAP_HSMMC_WRITE(host->base, SYSCONFIG, SOFTRESET);
209 timeout = jiffies + msecs_to_jiffies(MMC_TIMEOUT_MS);
210 while ((OMAP_HSMMC_READ(host->base, SYSSTATUS) & RESETDONE) != RESETDONE
211 && time_before(jiffies, timeout))
214 OMAP_HSMMC_WRITE(host->base, SYSCONFIG,
215 OMAP_HSMMC_READ(host->base, SYSCONFIG) | AUTOIDLE);
217 if (host->id == OMAP_MMC1_DEVID) {
218 if (host->power_mode != MMC_POWER_OFF &&
219 (1 << ios->vdd) <= MMC_VDD_23_24)
229 OMAP_HSMMC_WRITE(host->base, HCTL,
230 OMAP_HSMMC_READ(host->base, HCTL) | hctl);
232 OMAP_HSMMC_WRITE(host->base, CAPA,
233 OMAP_HSMMC_READ(host->base, CAPA) | capa);
235 OMAP_HSMMC_WRITE(host->base, HCTL,
236 OMAP_HSMMC_READ(host->base, HCTL) | SDBP);
238 timeout = jiffies + msecs_to_jiffies(MMC_TIMEOUT_MS);
239 while ((OMAP_HSMMC_READ(host->base, HCTL) & SDBP) != SDBP
240 && time_before(jiffies, timeout))
243 OMAP_HSMMC_WRITE(host->base, STAT, STAT_CLEAR);
244 OMAP_HSMMC_WRITE(host->base, ISE, INT_EN_MASK);
245 OMAP_HSMMC_WRITE(host->base, IE, INT_EN_MASK);
247 /* Do not initialize card-specific things if the power is off */
248 if (host->power_mode == MMC_POWER_OFF)
251 con = OMAP_HSMMC_READ(host->base, CON);
252 switch (ios->bus_width) {
253 case MMC_BUS_WIDTH_8:
254 OMAP_HSMMC_WRITE(host->base, CON, con | DW8);
256 case MMC_BUS_WIDTH_4:
257 OMAP_HSMMC_WRITE(host->base, CON, con & ~DW8);
258 OMAP_HSMMC_WRITE(host->base, HCTL,
259 OMAP_HSMMC_READ(host->base, HCTL) | FOUR_BIT);
261 case MMC_BUS_WIDTH_1:
262 OMAP_HSMMC_WRITE(host->base, CON, con & ~DW8);
263 OMAP_HSMMC_WRITE(host->base, HCTL,
264 OMAP_HSMMC_READ(host->base, HCTL) & ~FOUR_BIT);
269 dsor = OMAP_MMC_MASTER_CLOCK / ios->clock;
273 if (OMAP_MMC_MASTER_CLOCK / dsor > ios->clock)
280 OMAP_HSMMC_WRITE(host->base, SYSCTL,
281 OMAP_HSMMC_READ(host->base, SYSCTL) & ~CEN);
282 OMAP_HSMMC_WRITE(host->base, SYSCTL, (dsor << 6) | (DTO << 16));
283 OMAP_HSMMC_WRITE(host->base, SYSCTL,
284 OMAP_HSMMC_READ(host->base, SYSCTL) | ICE);
286 timeout = jiffies + msecs_to_jiffies(MMC_TIMEOUT_MS);
287 while ((OMAP_HSMMC_READ(host->base, SYSCTL) & ICS) != ICS
288 && time_before(jiffies, timeout))
291 OMAP_HSMMC_WRITE(host->base, SYSCTL,
292 OMAP_HSMMC_READ(host->base, SYSCTL) | CEN);
294 con = OMAP_HSMMC_READ(host->base, CON);
295 if (ios->bus_mode == MMC_BUSMODE_OPENDRAIN)
296 OMAP_HSMMC_WRITE(host->base, CON, con | OD);
298 OMAP_HSMMC_WRITE(host->base, CON, con & ~OD);
300 host->context_loss = context_loss;
302 dev_dbg(mmc_dev(host->mmc), "context is restored\n");
307 * Save the MMC host context (store the number of power state changes so far).
309 static void omap_mmc_save_ctx(struct mmc_omap_host *host)
311 struct omap_mmc_platform_data *pdata = host->pdata;
314 if (pdata->get_context_loss_count) {
315 context_loss = pdata->get_context_loss_count(host->dev);
316 if (context_loss < 0)
318 host->context_loss = context_loss;
324 static int omap_mmc_restore_ctx(struct mmc_omap_host *host)
329 static void omap_mmc_save_ctx(struct mmc_omap_host *host)
336 * Send init stream sequence to card
337 * before sending IDLE command
339 static void send_init_stream(struct mmc_omap_host *host)
342 unsigned long timeout;
344 disable_irq(host->irq);
345 OMAP_HSMMC_WRITE(host->base, CON,
346 OMAP_HSMMC_READ(host->base, CON) | INIT_STREAM);
347 OMAP_HSMMC_WRITE(host->base, CMD, INIT_STREAM_CMD);
349 timeout = jiffies + msecs_to_jiffies(MMC_TIMEOUT_MS);
350 while ((reg != CC) && time_before(jiffies, timeout))
351 reg = OMAP_HSMMC_READ(host->base, STAT) & CC;
353 OMAP_HSMMC_WRITE(host->base, CON,
354 OMAP_HSMMC_READ(host->base, CON) & ~INIT_STREAM);
355 enable_irq(host->irq);
359 int mmc_omap_cover_is_closed(struct mmc_omap_host *host)
363 if (host->pdata->slots[host->slot_id].get_cover_state)
364 r = host->pdata->slots[host->slot_id].get_cover_state(host->dev,
370 mmc_omap_show_cover_switch(struct device *dev, struct device_attribute *attr,
373 struct mmc_host *mmc = container_of(dev, struct mmc_host, class_dev);
374 struct mmc_omap_host *host = mmc_priv(mmc);
376 return sprintf(buf, "%s\n", mmc_omap_cover_is_closed(host) ? "closed" :
380 static DEVICE_ATTR(cover_switch, S_IRUGO, mmc_omap_show_cover_switch, NULL);
383 mmc_omap_show_slot_name(struct device *dev, struct device_attribute *attr,
386 struct mmc_host *mmc = container_of(dev, struct mmc_host, class_dev);
387 struct mmc_omap_host *host = mmc_priv(mmc);
388 struct omap_mmc_slot_data slot = host->pdata->slots[host->slot_id];
390 return sprintf(buf, "%s\n", slot.name);
393 static DEVICE_ATTR(slot_name, S_IRUGO, mmc_omap_show_slot_name, NULL);
396 * Configure the response type and send the cmd.
399 mmc_omap_start_command(struct mmc_omap_host *host, struct mmc_command *cmd,
400 struct mmc_data *data)
402 int cmdreg = 0, resptype = 0, cmdtype = 0;
404 dev_dbg(mmc_dev(host->mmc), "%s: CMD%d, argument 0x%08x\n",
405 mmc_hostname(host->mmc), cmd->opcode, cmd->arg);
409 * Clear status bits and enable interrupts
411 OMAP_HSMMC_WRITE(host->base, STAT, STAT_CLEAR);
412 OMAP_HSMMC_WRITE(host->base, ISE, INT_EN_MASK);
415 OMAP_HSMMC_WRITE(host->base, IE,
416 INT_EN_MASK & ~(BRR_ENABLE | BWR_ENABLE));
418 OMAP_HSMMC_WRITE(host->base, IE, INT_EN_MASK);
420 host->response_busy = 0;
421 if (cmd->flags & MMC_RSP_PRESENT) {
422 if (cmd->flags & MMC_RSP_136)
424 else if (cmd->flags & MMC_RSP_BUSY) {
426 host->response_busy = 1;
432 * Unlike OMAP1 controller, the cmdtype does not seem to be based on
433 * ac, bc, adtc, bcr. Only commands ending an open ended transfer need
434 * a val of 0x3, rest 0x0.
436 if (cmd == host->mrq->stop)
439 cmdreg = (cmd->opcode << 24) | (resptype << 16) | (cmdtype << 22);
442 cmdreg |= DP_SELECT | MSBS | BCE;
443 if (data->flags & MMC_DATA_READ)
452 OMAP_HSMMC_WRITE(host->base, ARG, cmd->arg);
453 OMAP_HSMMC_WRITE(host->base, CMD, cmdreg);
457 mmc_omap_get_dma_dir(struct mmc_omap_host *host, struct mmc_data *data)
459 if (data->flags & MMC_DATA_WRITE)
460 return DMA_TO_DEVICE;
462 return DMA_FROM_DEVICE;
466 * Notify the transfer complete to MMC core
469 mmc_omap_xfer_done(struct mmc_omap_host *host, struct mmc_data *data)
472 struct mmc_request *mrq = host->mrq;
475 mmc_request_done(host->mmc, mrq);
481 if (host->use_dma && host->dma_ch != -1)
482 dma_unmap_sg(mmc_dev(host->mmc), data->sg, host->dma_len,
483 mmc_omap_get_dma_dir(host, data));
486 data->bytes_xfered += data->blocks * (data->blksz);
488 data->bytes_xfered = 0;
492 mmc_request_done(host->mmc, data->mrq);
495 mmc_omap_start_command(host, data->stop, NULL);
499 * Notify the core about command completion
502 mmc_omap_cmd_done(struct mmc_omap_host *host, struct mmc_command *cmd)
506 if (cmd->flags & MMC_RSP_PRESENT) {
507 if (cmd->flags & MMC_RSP_136) {
508 /* response type 2 */
509 cmd->resp[3] = OMAP_HSMMC_READ(host->base, RSP10);
510 cmd->resp[2] = OMAP_HSMMC_READ(host->base, RSP32);
511 cmd->resp[1] = OMAP_HSMMC_READ(host->base, RSP54);
512 cmd->resp[0] = OMAP_HSMMC_READ(host->base, RSP76);
514 /* response types 1, 1b, 3, 4, 5, 6 */
515 cmd->resp[0] = OMAP_HSMMC_READ(host->base, RSP10);
518 if ((host->data == NULL && !host->response_busy) || cmd->error) {
520 mmc_request_done(host->mmc, cmd->mrq);
525 * DMA clean up for command errors
527 static void mmc_dma_cleanup(struct mmc_omap_host *host, int errno)
529 host->data->error = errno;
531 if (host->use_dma && host->dma_ch != -1) {
532 dma_unmap_sg(mmc_dev(host->mmc), host->data->sg, host->dma_len,
533 mmc_omap_get_dma_dir(host, host->data));
534 omap_free_dma(host->dma_ch);
542 * Readable error output
544 #ifdef CONFIG_MMC_DEBUG
545 static void mmc_omap_report_irq(struct mmc_omap_host *host, u32 status)
547 /* --- means reserved bit without definition at documentation */
548 static const char *mmc_omap_status_bits[] = {
549 "CC", "TC", "BGE", "---", "BWR", "BRR", "---", "---", "CIRQ",
550 "OBI", "---", "---", "---", "---", "---", "ERRI", "CTO", "CCRC",
551 "CEB", "CIE", "DTO", "DCRC", "DEB", "---", "ACE", "---",
552 "---", "---", "---", "CERR", "CERR", "BADA", "---", "---", "---"
558 len = sprintf(buf, "MMC IRQ 0x%x :", status);
561 for (i = 0; i < ARRAY_SIZE(mmc_omap_status_bits); i++)
562 if (status & (1 << i)) {
563 len = sprintf(buf, " %s", mmc_omap_status_bits[i]);
567 dev_dbg(mmc_dev(host->mmc), "%s\n", res);
569 #endif /* CONFIG_MMC_DEBUG */
572 * MMC controller internal state machines reset
574 * Used to reset command or data internal state machines, using respectively
575 * SRC or SRD bit of SYSCTL register
576 * Can be called from interrupt context
578 static inline void mmc_omap_reset_controller_fsm(struct mmc_omap_host *host,
582 unsigned long limit = (loops_per_jiffy *
583 msecs_to_jiffies(MMC_TIMEOUT_MS));
585 OMAP_HSMMC_WRITE(host->base, SYSCTL,
586 OMAP_HSMMC_READ(host->base, SYSCTL) | bit);
588 while ((OMAP_HSMMC_READ(host->base, SYSCTL) & bit) &&
592 if (OMAP_HSMMC_READ(host->base, SYSCTL) & bit)
593 dev_err(mmc_dev(host->mmc),
594 "Timeout waiting on controller reset in %s\n",
599 * MMC controller IRQ handler
601 static irqreturn_t mmc_omap_irq(int irq, void *dev_id)
603 struct mmc_omap_host *host = dev_id;
604 struct mmc_data *data;
605 int end_cmd = 0, end_trans = 0, status;
607 if (host->mrq == NULL) {
608 OMAP_HSMMC_WRITE(host->base, STAT,
609 OMAP_HSMMC_READ(host->base, STAT));
610 /* Flush posted write */
611 OMAP_HSMMC_READ(host->base, STAT);
616 status = OMAP_HSMMC_READ(host->base, STAT);
617 dev_dbg(mmc_dev(host->mmc), "IRQ Status is %x\n", status);
620 #ifdef CONFIG_MMC_DEBUG
621 mmc_omap_report_irq(host, status);
623 if ((status & CMD_TIMEOUT) ||
624 (status & CMD_CRC)) {
626 if (status & CMD_TIMEOUT) {
627 mmc_omap_reset_controller_fsm(host, SRC);
628 host->cmd->error = -ETIMEDOUT;
630 host->cmd->error = -EILSEQ;
634 if (host->data || host->response_busy) {
636 mmc_dma_cleanup(host, -ETIMEDOUT);
637 host->response_busy = 0;
638 mmc_omap_reset_controller_fsm(host, SRD);
641 if ((status & DATA_TIMEOUT) ||
642 (status & DATA_CRC)) {
643 if (host->data || host->response_busy) {
644 int err = (status & DATA_TIMEOUT) ?
645 -ETIMEDOUT : -EILSEQ;
648 mmc_dma_cleanup(host, err);
650 host->mrq->cmd->error = err;
651 host->response_busy = 0;
652 mmc_omap_reset_controller_fsm(host, SRD);
656 if (status & CARD_ERR) {
657 dev_dbg(mmc_dev(host->mmc),
658 "Ignoring card err CMD%d\n", host->cmd->opcode);
666 OMAP_HSMMC_WRITE(host->base, STAT, status);
667 /* Flush posted write */
668 OMAP_HSMMC_READ(host->base, STAT);
670 if (end_cmd || ((status & CC) && host->cmd))
671 mmc_omap_cmd_done(host, host->cmd);
672 if (end_trans || (status & TC))
673 mmc_omap_xfer_done(host, data);
678 static void set_sd_bus_power(struct mmc_omap_host *host)
682 OMAP_HSMMC_WRITE(host->base, HCTL,
683 OMAP_HSMMC_READ(host->base, HCTL) | SDBP);
684 for (i = 0; i < loops_per_jiffy; i++) {
685 if (OMAP_HSMMC_READ(host->base, HCTL) & SDBP)
692 * Switch MMC interface voltage ... only relevant for MMC1.
694 * MMC2 and MMC3 use fixed 1.8V levels, and maybe a transceiver.
695 * The MMC2 transceiver controls are used instead of DAT4..DAT7.
696 * Some chips, like eMMC ones, use internal transceivers.
698 static int omap_mmc_switch_opcond(struct mmc_omap_host *host, int vdd)
703 /* Disable the clocks */
704 clk_disable(host->fclk);
705 clk_disable(host->iclk);
706 clk_disable(host->dbclk);
708 /* Turn the power off */
709 ret = mmc_slot(host).set_power(host->dev, host->slot_id, 0, 0);
713 /* Turn the power ON with given VDD 1.8 or 3.0v */
714 ret = mmc_slot(host).set_power(host->dev, host->slot_id, 1, vdd);
718 clk_enable(host->fclk);
719 clk_enable(host->iclk);
720 clk_enable(host->dbclk);
722 OMAP_HSMMC_WRITE(host->base, HCTL,
723 OMAP_HSMMC_READ(host->base, HCTL) & SDVSCLR);
724 reg_val = OMAP_HSMMC_READ(host->base, HCTL);
727 * If a MMC dual voltage card is detected, the set_ios fn calls
728 * this fn with VDD bit set for 1.8V. Upon card removal from the
729 * slot, omap_mmc_set_ios sets the VDD back to 3V on MMC_POWER_OFF.
731 * Cope with a bit of slop in the range ... per data sheets:
732 * - "1.8V" for vdds_mmc1/vdds_mmc1a can be up to 2.45V max,
733 * but recommended values are 1.71V to 1.89V
734 * - "3.0V" for vdds_mmc1/vdds_mmc1a can be up to 3.5V max,
735 * but recommended values are 2.7V to 3.3V
737 * Board setup code shouldn't permit anything very out-of-range.
738 * TWL4030-family VMMC1 and VSIM regulators are fine (avoiding the
739 * middle range) but VSIM can't power DAT4..DAT7 at more than 3V.
741 if ((1 << vdd) <= MMC_VDD_23_24)
746 OMAP_HSMMC_WRITE(host->base, HCTL, reg_val);
747 set_sd_bus_power(host);
751 dev_dbg(mmc_dev(host->mmc), "Unable to switch operating voltage\n");
756 * Work Item to notify the core about card insertion/removal
758 static void mmc_omap_detect(struct work_struct *work)
760 struct mmc_omap_host *host = container_of(work, struct mmc_omap_host,
761 mmc_carddetect_work);
762 struct omap_mmc_slot_data *slot = &mmc_slot(host);
768 sysfs_notify(&host->mmc->class_dev.kobj, NULL, "cover_switch");
770 if (mmc_slot(host).card_detect)
771 carddetect = slot->card_detect(slot->card_detect_irq);
773 carddetect = -ENOSYS;
776 mmc_detect_change(host->mmc, (HZ * 200) / 1000);
778 mmc_host_enable(host->mmc);
779 mmc_omap_reset_controller_fsm(host, SRD);
780 mmc_host_lazy_disable(host->mmc);
781 mmc_detect_change(host->mmc, (HZ * 50) / 1000);
786 * ISR for handling card insertion and removal
788 static irqreturn_t omap_mmc_cd_handler(int irq, void *dev_id)
790 struct mmc_omap_host *host = (struct mmc_omap_host *)dev_id;
794 schedule_work(&host->mmc_carddetect_work);
799 static int mmc_omap_get_dma_sync_dev(struct mmc_omap_host *host,
800 struct mmc_data *data)
804 if (data->flags & MMC_DATA_WRITE)
805 sync_dev = host->dma_line_tx;
807 sync_dev = host->dma_line_rx;
811 static void mmc_omap_config_dma_params(struct mmc_omap_host *host,
812 struct mmc_data *data,
813 struct scatterlist *sgl)
815 int blksz, nblk, dma_ch;
817 dma_ch = host->dma_ch;
818 if (data->flags & MMC_DATA_WRITE) {
819 omap_set_dma_dest_params(dma_ch, 0, OMAP_DMA_AMODE_CONSTANT,
820 (host->mapbase + OMAP_HSMMC_DATA), 0, 0);
821 omap_set_dma_src_params(dma_ch, 0, OMAP_DMA_AMODE_POST_INC,
822 sg_dma_address(sgl), 0, 0);
824 omap_set_dma_src_params(dma_ch, 0, OMAP_DMA_AMODE_CONSTANT,
825 (host->mapbase + OMAP_HSMMC_DATA), 0, 0);
826 omap_set_dma_dest_params(dma_ch, 0, OMAP_DMA_AMODE_POST_INC,
827 sg_dma_address(sgl), 0, 0);
830 blksz = host->data->blksz;
831 nblk = sg_dma_len(sgl) / blksz;
833 omap_set_dma_transfer_params(dma_ch, OMAP_DMA_DATA_TYPE_S32,
834 blksz / 4, nblk, OMAP_DMA_SYNC_FRAME,
835 mmc_omap_get_dma_sync_dev(host, data),
836 !(data->flags & MMC_DATA_WRITE));
838 omap_start_dma(dma_ch);
842 * DMA call back function
844 static void mmc_omap_dma_cb(int lch, u16 ch_status, void *data)
846 struct mmc_omap_host *host = data;
848 if (ch_status & OMAP2_DMA_MISALIGNED_ERR_IRQ)
849 dev_dbg(mmc_dev(host->mmc), "MISALIGNED_ADRS_ERR\n");
851 if (host->dma_ch < 0)
855 if (host->dma_sg_idx < host->dma_len) {
856 /* Fire up the next transfer. */
857 mmc_omap_config_dma_params(host, host->data,
858 host->data->sg + host->dma_sg_idx);
862 omap_free_dma(host->dma_ch);
865 * DMA Callback: run in interrupt context.
866 * mutex_unlock will throw a kernel warning if used.
872 * Routine to configure and start DMA for the MMC card
875 mmc_omap_start_dma_transfer(struct mmc_omap_host *host, struct mmc_request *req)
877 int dma_ch = 0, ret = 0, err = 1, i;
878 struct mmc_data *data = req->data;
880 /* Sanity check: all the SG entries must be aligned by block size. */
881 for (i = 0; i < data->sg_len; i++) {
882 struct scatterlist *sgl;
885 if (sgl->length % data->blksz)
888 if ((data->blksz % 4) != 0)
889 /* REVISIT: The MMC buffer increments only when MSB is written.
890 * Return error for blksz which is non multiple of four.
895 * If for some reason the DMA transfer is still active,
896 * we wait for timeout period and free the dma
898 if (host->dma_ch != -1) {
899 set_current_state(TASK_UNINTERRUPTIBLE);
900 schedule_timeout(100);
901 if (down_trylock(&host->sem)) {
902 omap_free_dma(host->dma_ch);
908 if (down_trylock(&host->sem))
912 ret = omap_request_dma(mmc_omap_get_dma_sync_dev(host, data), "MMC/SD",
913 mmc_omap_dma_cb,host, &dma_ch);
915 dev_err(mmc_dev(host->mmc),
916 "%s: omap_request_dma() failed with %d\n",
917 mmc_hostname(host->mmc), ret);
921 host->dma_len = dma_map_sg(mmc_dev(host->mmc), data->sg,
922 data->sg_len, mmc_omap_get_dma_dir(host, data));
923 host->dma_ch = dma_ch;
924 host->dma_sg_idx = 0;
926 mmc_omap_config_dma_params(host, data, data->sg);
931 static void set_data_timeout(struct mmc_omap_host *host,
932 struct mmc_request *req)
934 unsigned int timeout, cycle_ns;
935 uint32_t reg, clkd, dto = 0;
937 reg = OMAP_HSMMC_READ(host->base, SYSCTL);
938 clkd = (reg & CLKD_MASK) >> CLKD_SHIFT;
942 cycle_ns = 1000000000 / (clk_get_rate(host->fclk) / clkd);
943 timeout = req->data->timeout_ns / cycle_ns;
944 timeout += req->data->timeout_clks;
946 while ((timeout & 0x80000000) == 0) {
963 reg |= dto << DTO_SHIFT;
964 OMAP_HSMMC_WRITE(host->base, SYSCTL, reg);
968 * Configure block length for MMC/SD cards and initiate the transfer.
971 mmc_omap_prepare_data(struct mmc_omap_host *host, struct mmc_request *req)
974 host->data = req->data;
976 if (req->data == NULL) {
977 OMAP_HSMMC_WRITE(host->base, BLK, 0);
981 OMAP_HSMMC_WRITE(host->base, BLK, (req->data->blksz)
982 | (req->data->blocks << 16));
983 set_data_timeout(host, req);
986 ret = mmc_omap_start_dma_transfer(host, req);
988 dev_dbg(mmc_dev(host->mmc), "MMC start dma failure\n");
995 static int omap_mmc_enable(struct mmc_host *mmc)
997 struct mmc_omap_host *host = mmc_priv(mmc);
1000 err = clk_enable(host->fclk);
1003 dev_dbg(mmc_dev(host->mmc), "mmc_fclk: enabled\n");
1004 omap_mmc_restore_ctx(host);
1008 static int omap_mmc_disable(struct mmc_host *mmc, int lazy)
1010 struct mmc_omap_host *host = mmc_priv(mmc);
1012 omap_mmc_save_ctx(host);
1013 clk_disable(host->fclk);
1014 dev_dbg(mmc_dev(host->mmc), "mmc_fclk: disabled\n");
1019 * Request function. for read/write operation
1021 static void omap_mmc_request(struct mmc_host *mmc, struct mmc_request *req)
1023 struct mmc_omap_host *host = mmc_priv(mmc);
1026 WARN_ON(host->mrq != NULL);
1028 err = mmc_omap_prepare_data(host, req);
1030 req->cmd->error = err;
1032 req->data->error = err;
1034 mmc_request_done(mmc, req);
1038 mmc_omap_start_command(host, req->cmd, req->data);
1042 /* Routine to configure clock values. Exposed API to core */
1043 static void omap_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
1045 struct mmc_omap_host *host = mmc_priv(mmc);
1047 unsigned long regval;
1048 unsigned long timeout;
1050 int do_send_init_stream = 0;
1052 mmc_host_enable(host->mmc);
1054 if (ios->power_mode != host->power_mode) {
1055 switch (ios->power_mode) {
1057 mmc_slot(host).set_power(host->dev, host->slot_id,
1061 mmc_slot(host).set_power(host->dev, host->slot_id,
1065 do_send_init_stream = 1;
1068 host->power_mode = ios->power_mode;
1071 con = OMAP_HSMMC_READ(host->base, CON);
1072 switch (mmc->ios.bus_width) {
1073 case MMC_BUS_WIDTH_8:
1074 OMAP_HSMMC_WRITE(host->base, CON, con | DW8);
1076 case MMC_BUS_WIDTH_4:
1077 OMAP_HSMMC_WRITE(host->base, CON, con & ~DW8);
1078 OMAP_HSMMC_WRITE(host->base, HCTL,
1079 OMAP_HSMMC_READ(host->base, HCTL) | FOUR_BIT);
1081 case MMC_BUS_WIDTH_1:
1082 OMAP_HSMMC_WRITE(host->base, CON, con & ~DW8);
1083 OMAP_HSMMC_WRITE(host->base, HCTL,
1084 OMAP_HSMMC_READ(host->base, HCTL) & ~FOUR_BIT);
1088 if (host->id == OMAP_MMC1_DEVID) {
1089 /* Only MMC1 can interface at 3V without some flavor
1090 * of external transceiver; but they all handle 1.8V.
1092 if ((OMAP_HSMMC_READ(host->base, HCTL) & SDVSDET) &&
1093 (ios->vdd == DUAL_VOLT_OCR_BIT)) {
1095 * The mmc_select_voltage fn of the core does
1096 * not seem to set the power_mode to
1097 * MMC_POWER_UP upon recalculating the voltage.
1100 if (omap_mmc_switch_opcond(host, ios->vdd) != 0)
1101 dev_dbg(mmc_dev(host->mmc),
1102 "Switch operation failed\n");
1107 dsor = OMAP_MMC_MASTER_CLOCK / ios->clock;
1111 if (OMAP_MMC_MASTER_CLOCK / dsor > ios->clock)
1117 omap_mmc_stop_clock(host);
1118 regval = OMAP_HSMMC_READ(host->base, SYSCTL);
1119 regval = regval & ~(CLKD_MASK);
1120 regval = regval | (dsor << 6) | (DTO << 16);
1121 OMAP_HSMMC_WRITE(host->base, SYSCTL, regval);
1122 OMAP_HSMMC_WRITE(host->base, SYSCTL,
1123 OMAP_HSMMC_READ(host->base, SYSCTL) | ICE);
1125 /* Wait till the ICS bit is set */
1126 timeout = jiffies + msecs_to_jiffies(MMC_TIMEOUT_MS);
1127 while ((OMAP_HSMMC_READ(host->base, SYSCTL) & ICS) != ICS
1128 && time_before(jiffies, timeout))
1131 OMAP_HSMMC_WRITE(host->base, SYSCTL,
1132 OMAP_HSMMC_READ(host->base, SYSCTL) | CEN);
1134 if (do_send_init_stream)
1135 send_init_stream(host);
1137 con = OMAP_HSMMC_READ(host->base, CON);
1138 if (ios->bus_mode == MMC_BUSMODE_OPENDRAIN)
1139 OMAP_HSMMC_WRITE(host->base, CON, con | OD);
1141 OMAP_HSMMC_WRITE(host->base, CON, con & ~OD);
1143 mmc_host_lazy_disable(host->mmc);
1146 static int omap_hsmmc_get_cd(struct mmc_host *mmc)
1148 struct mmc_omap_host *host = mmc_priv(mmc);
1149 struct omap_mmc_platform_data *pdata = host->pdata;
1151 if (!pdata->slots[0].card_detect)
1153 return pdata->slots[0].card_detect(pdata->slots[0].card_detect_irq);
1156 static int omap_hsmmc_get_ro(struct mmc_host *mmc)
1158 struct mmc_omap_host *host = mmc_priv(mmc);
1159 struct omap_mmc_platform_data *pdata = host->pdata;
1161 if (!pdata->slots[0].get_ro)
1163 return pdata->slots[0].get_ro(host->dev, 0);
1166 static void omap_hsmmc_init(struct mmc_omap_host *host)
1168 u32 hctl, capa, value;
1170 /* Only MMC1 supports 3.0V */
1171 if (host->id == OMAP_MMC1_DEVID) {
1179 value = OMAP_HSMMC_READ(host->base, HCTL) & ~SDVS_MASK;
1180 OMAP_HSMMC_WRITE(host->base, HCTL, value | hctl);
1182 value = OMAP_HSMMC_READ(host->base, CAPA);
1183 OMAP_HSMMC_WRITE(host->base, CAPA, value | capa);
1185 /* Set the controller to AUTO IDLE mode */
1186 value = OMAP_HSMMC_READ(host->base, SYSCONFIG);
1187 OMAP_HSMMC_WRITE(host->base, SYSCONFIG, value | AUTOIDLE);
1189 /* Set SD bus power bit */
1190 set_sd_bus_power(host);
1193 static struct mmc_host_ops mmc_omap_ops = {
1194 .enable = omap_mmc_enable,
1195 .disable = omap_mmc_disable,
1196 .request = omap_mmc_request,
1197 .set_ios = omap_mmc_set_ios,
1198 .get_cd = omap_hsmmc_get_cd,
1199 .get_ro = omap_hsmmc_get_ro,
1200 /* NYET -- enable_sdio_irq */
1203 #ifdef CONFIG_DEBUG_FS
1205 static int mmc_regs_show(struct seq_file *s, void *data)
1207 struct mmc_host *mmc = s->private;
1208 struct mmc_omap_host *host = mmc_priv(mmc);
1209 struct omap_mmc_platform_data *pdata = host->pdata;
1210 int context_loss = 0;
1212 if (pdata->get_context_loss_count)
1213 context_loss = pdata->get_context_loss_count(host->dev);
1215 seq_printf(s, "mmc%d:\n"
1217 " nesting_cnt:\t%d\n"
1218 " ctx_loss:\t%d:%d\n"
1220 mmc->index, mmc->enabled ? 1 : 0, mmc->nesting_cnt,
1221 host->context_loss, context_loss);
1223 if (clk_enable(host->fclk) != 0) {
1224 seq_printf(s, "can't read the regs\n");
1228 seq_printf(s, "SYSCONFIG:\t0x%08x\n",
1229 OMAP_HSMMC_READ(host->base, SYSCONFIG));
1230 seq_printf(s, "CON:\t\t0x%08x\n",
1231 OMAP_HSMMC_READ(host->base, CON));
1232 seq_printf(s, "HCTL:\t\t0x%08x\n",
1233 OMAP_HSMMC_READ(host->base, HCTL));
1234 seq_printf(s, "SYSCTL:\t\t0x%08x\n",
1235 OMAP_HSMMC_READ(host->base, SYSCTL));
1236 seq_printf(s, "IE:\t\t0x%08x\n",
1237 OMAP_HSMMC_READ(host->base, IE));
1238 seq_printf(s, "ISE:\t\t0x%08x\n",
1239 OMAP_HSMMC_READ(host->base, ISE));
1240 seq_printf(s, "CAPA:\t\t0x%08x\n",
1241 OMAP_HSMMC_READ(host->base, CAPA));
1243 clk_disable(host->fclk);
1248 static int mmc_regs_open(struct inode *inode, struct file *file)
1250 return single_open(file, mmc_regs_show, inode->i_private);
1253 static const struct file_operations mmc_regs_fops = {
1254 .open = mmc_regs_open,
1256 .llseek = seq_lseek,
1257 .release = single_release,
1260 static void omap_mmc_debugfs(struct mmc_host *mmc)
1262 if (mmc->debugfs_root)
1263 debugfs_create_file("regs", S_IRUSR, mmc->debugfs_root,
1264 mmc, &mmc_regs_fops);
1269 static void omap_mmc_debugfs(struct mmc_host *mmc)
1275 static int __init omap_mmc_probe(struct platform_device *pdev)
1277 struct omap_mmc_platform_data *pdata = pdev->dev.platform_data;
1278 struct mmc_host *mmc;
1279 struct mmc_omap_host *host = NULL;
1280 struct resource *res;
1283 if (pdata == NULL) {
1284 dev_err(&pdev->dev, "Platform Data is missing\n");
1288 if (pdata->nr_slots == 0) {
1289 dev_err(&pdev->dev, "No Slots\n");
1293 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1294 irq = platform_get_irq(pdev, 0);
1295 if (res == NULL || irq < 0)
1298 res = request_mem_region(res->start, res->end - res->start + 1,
1303 mmc = mmc_alloc_host(sizeof(struct mmc_omap_host), &pdev->dev);
1309 host = mmc_priv(mmc);
1311 host->pdata = pdata;
1312 host->dev = &pdev->dev;
1314 host->dev->dma_mask = &pdata->dma_mask;
1317 host->id = pdev->id;
1319 host->mapbase = res->start;
1320 host->base = ioremap(host->mapbase, SZ_4K);
1321 host->power_mode = -1;
1323 platform_set_drvdata(pdev, host);
1324 INIT_WORK(&host->mmc_carddetect_work, mmc_omap_detect);
1326 mmc->ops = &mmc_omap_ops;
1327 mmc->f_min = 400000;
1328 mmc->f_max = 52000000;
1330 sema_init(&host->sem, 1);
1332 host->iclk = clk_get(&pdev->dev, "ick");
1333 if (IS_ERR(host->iclk)) {
1334 ret = PTR_ERR(host->iclk);
1338 host->fclk = clk_get(&pdev->dev, "fck");
1339 if (IS_ERR(host->fclk)) {
1340 ret = PTR_ERR(host->fclk);
1342 clk_put(host->iclk);
1346 omap_mmc_save_ctx(host);
1348 mmc->caps |= MMC_CAP_DISABLE;
1349 mmc_set_disable_delay(mmc, 100);
1350 if (mmc_host_enable(host->mmc) != 0) {
1351 clk_put(host->iclk);
1352 clk_put(host->fclk);
1356 if (clk_enable(host->iclk) != 0) {
1357 mmc_host_disable(host->mmc);
1358 clk_put(host->iclk);
1359 clk_put(host->fclk);
1363 host->dbclk = clk_get(&pdev->dev, "mmchsdb_fck");
1365 * MMC can still work without debounce clock.
1367 if (IS_ERR(host->dbclk))
1368 dev_warn(mmc_dev(host->mmc), "Failed to get debounce clock\n");
1370 if (clk_enable(host->dbclk) != 0)
1371 dev_dbg(mmc_dev(host->mmc), "Enabling debounce"
1374 host->dbclk_enabled = 1;
1376 /* Since we do only SG emulation, we can have as many segs
1378 mmc->max_phys_segs = 1024;
1379 mmc->max_hw_segs = 1024;
1381 mmc->max_blk_size = 512; /* Block Length at max can be 1024 */
1382 mmc->max_blk_count = 0xFFFF; /* No. of Blocks is 16 bits */
1383 mmc->max_req_size = mmc->max_blk_size * mmc->max_blk_count;
1384 mmc->max_seg_size = mmc->max_req_size;
1386 mmc->caps |= MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED;
1388 if (pdata->slots[host->slot_id].wires >= 8)
1389 mmc->caps |= MMC_CAP_8_BIT_DATA;
1390 else if (pdata->slots[host->slot_id].wires >= 4)
1391 mmc->caps |= MMC_CAP_4_BIT_DATA;
1393 omap_hsmmc_init(host);
1395 /* Select DMA lines */
1397 case OMAP_MMC1_DEVID:
1398 host->dma_line_tx = OMAP24XX_DMA_MMC1_TX;
1399 host->dma_line_rx = OMAP24XX_DMA_MMC1_RX;
1401 case OMAP_MMC2_DEVID:
1402 host->dma_line_tx = OMAP24XX_DMA_MMC2_TX;
1403 host->dma_line_rx = OMAP24XX_DMA_MMC2_RX;
1405 case OMAP_MMC3_DEVID:
1406 host->dma_line_tx = OMAP34XX_DMA_MMC3_TX;
1407 host->dma_line_rx = OMAP34XX_DMA_MMC3_RX;
1410 dev_err(mmc_dev(host->mmc), "Invalid MMC id\n");
1414 /* Request IRQ for MMC operations */
1415 ret = request_irq(host->irq, mmc_omap_irq, IRQF_DISABLED,
1416 mmc_hostname(mmc), host);
1418 dev_dbg(mmc_dev(host->mmc), "Unable to grab HSMMC IRQ\n");
1422 /* initialize power supplies, gpios, etc */
1423 if (pdata->init != NULL) {
1424 if (pdata->init(&pdev->dev) != 0) {
1425 dev_dbg(mmc_dev(host->mmc), "late init error\n");
1426 goto err_irq_cd_init;
1429 mmc->ocr_avail = mmc_slot(host).ocr_mask;
1431 /* Request IRQ for card detect */
1432 if ((mmc_slot(host).card_detect_irq)) {
1433 ret = request_irq(mmc_slot(host).card_detect_irq,
1434 omap_mmc_cd_handler,
1435 IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING
1437 mmc_hostname(mmc), host);
1439 dev_dbg(mmc_dev(host->mmc),
1440 "Unable to grab MMC CD IRQ\n");
1445 OMAP_HSMMC_WRITE(host->base, ISE, INT_EN_MASK);
1446 OMAP_HSMMC_WRITE(host->base, IE, INT_EN_MASK);
1448 mmc_host_lazy_disable(host->mmc);
1452 if (host->pdata->slots[host->slot_id].name != NULL) {
1453 ret = device_create_file(&mmc->class_dev, &dev_attr_slot_name);
1457 if (mmc_slot(host).card_detect_irq &&
1458 host->pdata->slots[host->slot_id].get_cover_state) {
1459 ret = device_create_file(&mmc->class_dev,
1460 &dev_attr_cover_switch);
1462 goto err_cover_switch;
1465 omap_mmc_debugfs(mmc);
1470 device_remove_file(&mmc->class_dev, &dev_attr_cover_switch);
1472 mmc_remove_host(mmc);
1474 free_irq(mmc_slot(host).card_detect_irq, host);
1476 free_irq(host->irq, host);
1478 mmc_host_disable(host->mmc);
1479 clk_disable(host->iclk);
1480 clk_put(host->fclk);
1481 clk_put(host->iclk);
1482 if (host->dbclk_enabled) {
1483 clk_disable(host->dbclk);
1484 clk_put(host->dbclk);
1488 iounmap(host->base);
1490 dev_dbg(mmc_dev(host->mmc), "Probe Failed\n");
1491 release_mem_region(res->start, res->end - res->start + 1);
1497 static int omap_mmc_remove(struct platform_device *pdev)
1499 struct mmc_omap_host *host = platform_get_drvdata(pdev);
1500 struct resource *res;
1503 mmc_host_enable(host->mmc);
1504 mmc_remove_host(host->mmc);
1505 if (host->pdata->cleanup)
1506 host->pdata->cleanup(&pdev->dev);
1507 free_irq(host->irq, host);
1508 if (mmc_slot(host).card_detect_irq)
1509 free_irq(mmc_slot(host).card_detect_irq, host);
1510 flush_scheduled_work();
1512 mmc_host_disable(host->mmc);
1513 clk_disable(host->iclk);
1514 clk_put(host->fclk);
1515 clk_put(host->iclk);
1516 if (host->dbclk_enabled) {
1517 clk_disable(host->dbclk);
1518 clk_put(host->dbclk);
1521 mmc_free_host(host->mmc);
1522 iounmap(host->base);
1525 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1527 release_mem_region(res->start, res->end - res->start + 1);
1528 platform_set_drvdata(pdev, NULL);
1534 static int omap_mmc_suspend(struct platform_device *pdev, pm_message_t state)
1537 struct mmc_omap_host *host = platform_get_drvdata(pdev);
1539 if (host && host->suspended)
1543 host->suspended = 1;
1544 if (host->pdata->suspend) {
1545 ret = host->pdata->suspend(&pdev->dev,
1548 dev_dbg(mmc_dev(host->mmc),
1549 "Unable to handle MMC board"
1550 " level suspend\n");
1551 host->suspended = 0;
1555 cancel_work_sync(&host->mmc_carddetect_work);
1556 mmc_host_enable(host->mmc);
1557 ret = mmc_suspend_host(host->mmc, state);
1559 OMAP_HSMMC_WRITE(host->base, ISE, 0);
1560 OMAP_HSMMC_WRITE(host->base, IE, 0);
1563 OMAP_HSMMC_WRITE(host->base, HCTL,
1564 OMAP_HSMMC_READ(host->base, HCTL) & ~SDBP);
1565 mmc_host_disable(host->mmc);
1566 clk_disable(host->iclk);
1567 clk_disable(host->dbclk);
1569 host->suspended = 0;
1570 if (host->pdata->resume) {
1571 ret = host->pdata->resume(&pdev->dev,
1574 dev_dbg(mmc_dev(host->mmc),
1575 "Unmask interrupt failed\n");
1577 mmc_host_disable(host->mmc);
1584 /* Routine to resume the MMC device */
1585 static int omap_mmc_resume(struct platform_device *pdev)
1588 struct mmc_omap_host *host = platform_get_drvdata(pdev);
1590 if (host && !host->suspended)
1594 ret = clk_enable(host->iclk);
1598 if (clk_enable(host->dbclk) != 0)
1599 dev_dbg(mmc_dev(host->mmc),
1600 "Enabling debounce clk failed\n");
1602 if (mmc_host_enable(host->mmc) != 0) {
1603 clk_disable(host->iclk);
1607 omap_hsmmc_init(host);
1609 if (host->pdata->resume) {
1610 ret = host->pdata->resume(&pdev->dev, host->slot_id);
1612 dev_dbg(mmc_dev(host->mmc),
1613 "Unmask interrupt failed\n");
1616 /* Notify the core to resume the host */
1617 ret = mmc_resume_host(host->mmc);
1619 host->suspended = 0;
1620 mmc_host_lazy_disable(host->mmc);
1626 dev_dbg(mmc_dev(host->mmc),
1627 "Failed to enable MMC clocks during resume\n");
1632 #define omap_mmc_suspend NULL
1633 #define omap_mmc_resume NULL
1636 static struct platform_driver omap_mmc_driver = {
1637 .remove = omap_mmc_remove,
1638 .suspend = omap_mmc_suspend,
1639 .resume = omap_mmc_resume,
1641 .name = DRIVER_NAME,
1642 .owner = THIS_MODULE,
1646 static int __init omap_mmc_init(void)
1648 /* Register the MMC driver */
1649 return platform_driver_probe(&omap_mmc_driver, omap_mmc_probe);
1652 static void __exit omap_mmc_cleanup(void)
1654 /* Unregister MMC driver */
1655 platform_driver_unregister(&omap_mmc_driver);
1658 module_init(omap_mmc_init);
1659 module_exit(omap_mmc_cleanup);
1661 MODULE_DESCRIPTION("OMAP High Speed Multimedia Card driver");
1662 MODULE_LICENSE("GPL");
1663 MODULE_ALIAS("platform:" DRIVER_NAME);
1664 MODULE_AUTHOR("Texas Instruments Inc");