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/kernel.h>
21 #include <linux/debugfs.h>
22 #include <linux/dmaengine.h>
23 #include <linux/seq_file.h>
24 #include <linux/sizes.h>
25 #include <linux/interrupt.h>
26 #include <linux/delay.h>
27 #include <linux/dma-mapping.h>
28 #include <linux/platform_device.h>
29 #include <linux/timer.h>
30 #include <linux/clk.h>
32 #include <linux/of_irq.h>
33 #include <linux/of_gpio.h>
34 #include <linux/of_device.h>
35 #include <linux/omap-dmaengine.h>
36 #include <linux/mmc/host.h>
37 #include <linux/mmc/core.h>
38 #include <linux/mmc/mmc.h>
39 #include <linux/mmc/slot-gpio.h>
41 #include <linux/irq.h>
42 #include <linux/gpio.h>
43 #include <linux/regulator/consumer.h>
44 #include <linux/pinctrl/consumer.h>
45 #include <linux/pm_runtime.h>
46 #include <linux/platform_data/hsmmc-omap.h>
48 /* OMAP HSMMC Host Controller Registers */
49 #define OMAP_HSMMC_SYSSTATUS 0x0014
50 #define OMAP_HSMMC_CON 0x002C
51 #define OMAP_HSMMC_SDMASA 0x0100
52 #define OMAP_HSMMC_BLK 0x0104
53 #define OMAP_HSMMC_ARG 0x0108
54 #define OMAP_HSMMC_CMD 0x010C
55 #define OMAP_HSMMC_RSP10 0x0110
56 #define OMAP_HSMMC_RSP32 0x0114
57 #define OMAP_HSMMC_RSP54 0x0118
58 #define OMAP_HSMMC_RSP76 0x011C
59 #define OMAP_HSMMC_DATA 0x0120
60 #define OMAP_HSMMC_PSTATE 0x0124
61 #define OMAP_HSMMC_HCTL 0x0128
62 #define OMAP_HSMMC_SYSCTL 0x012C
63 #define OMAP_HSMMC_STAT 0x0130
64 #define OMAP_HSMMC_IE 0x0134
65 #define OMAP_HSMMC_ISE 0x0138
66 #define OMAP_HSMMC_AC12 0x013C
67 #define OMAP_HSMMC_CAPA 0x0140
69 #define VS18 (1 << 26)
70 #define VS30 (1 << 25)
72 #define SDVS18 (0x5 << 9)
73 #define SDVS30 (0x6 << 9)
74 #define SDVS33 (0x7 << 9)
75 #define SDVS_MASK 0x00000E00
76 #define SDVSCLR 0xFFFFF1FF
77 #define SDVSDET 0x00000400
84 #define CLKD_MAX 0x3FF /* max clock divisor: 1023 */
85 #define CLKD_MASK 0x0000FFC0
87 #define DTO_MASK 0x000F0000
89 #define INIT_STREAM (1 << 1)
90 #define ACEN_ACMD23 (2 << 2)
91 #define DP_SELECT (1 << 21)
96 #define FOUR_BIT (1 << 1)
100 #define CLKEXTFREE (1 << 16)
101 #define CTPL (1 << 11)
104 #define STAT_CLEAR 0xFFFFFFFF
105 #define INIT_STREAM_CMD 0x00000000
106 #define DUAL_VOLT_OCR_BIT 7
107 #define SRC (1 << 25)
108 #define SRD (1 << 26)
109 #define SOFTRESET (1 << 1)
112 #define DLEV_DAT(x) (1 << (20 + (x)))
114 /* Interrupt masks for IE and ISE register */
115 #define CC_EN (1 << 0)
116 #define TC_EN (1 << 1)
117 #define BWR_EN (1 << 4)
118 #define BRR_EN (1 << 5)
119 #define CIRQ_EN (1 << 8)
120 #define ERR_EN (1 << 15)
121 #define CTO_EN (1 << 16)
122 #define CCRC_EN (1 << 17)
123 #define CEB_EN (1 << 18)
124 #define CIE_EN (1 << 19)
125 #define DTO_EN (1 << 20)
126 #define DCRC_EN (1 << 21)
127 #define DEB_EN (1 << 22)
128 #define ACE_EN (1 << 24)
129 #define CERR_EN (1 << 28)
130 #define BADA_EN (1 << 29)
132 #define INT_EN_MASK (BADA_EN | CERR_EN | ACE_EN | DEB_EN | DCRC_EN |\
133 DTO_EN | CIE_EN | CEB_EN | CCRC_EN | CTO_EN | \
134 BRR_EN | BWR_EN | TC_EN | CC_EN)
137 #define ACIE (1 << 4)
138 #define ACEB (1 << 3)
139 #define ACCE (1 << 2)
140 #define ACTO (1 << 1)
141 #define ACNE (1 << 0)
143 #define MMC_AUTOSUSPEND_DELAY 100
144 #define MMC_TIMEOUT_MS 20 /* 20 mSec */
145 #define MMC_TIMEOUT_US 20000 /* 20000 micro Sec */
146 #define OMAP_MMC_MIN_CLOCK 400000
147 #define OMAP_MMC_MAX_CLOCK 52000000
148 #define DRIVER_NAME "omap_hsmmc"
150 #define VDD_1V8 1800000 /* 180000 uV */
151 #define VDD_3V0 3000000 /* 300000 uV */
152 #define VDD_165_195 (ffs(MMC_VDD_165_195) - 1)
155 * One controller can have multiple slots, like on some omap boards using
156 * omap.c controller driver. Luckily this is not currently done on any known
157 * omap_hsmmc.c device.
159 #define mmc_pdata(host) host->pdata
162 * MMC Host controller read/write API's
164 #define OMAP_HSMMC_READ(base, reg) \
165 __raw_readl((base) + OMAP_HSMMC_##reg)
167 #define OMAP_HSMMC_WRITE(base, reg, val) \
168 __raw_writel((val), (base) + OMAP_HSMMC_##reg)
170 struct omap_hsmmc_next {
171 unsigned int dma_len;
175 struct omap_hsmmc_host {
177 struct mmc_host *mmc;
178 struct mmc_request *mrq;
179 struct mmc_command *cmd;
180 struct mmc_data *data;
184 * vcc == configured supply
185 * vcc_aux == optional
186 * - MMC1, supply for DAT4..DAT7
187 * - MMC2/MMC2, external level shifter voltage supply, for
188 * chip (SDIO, eMMC, etc) or transceiver (MMC2 only)
190 struct regulator *vcc;
191 struct regulator *vcc_aux;
192 struct regulator *pbias;
195 resource_size_t mapbase;
196 spinlock_t irq_lock; /* Prevent races with irq handler */
197 unsigned int dma_len;
198 unsigned int dma_sg_idx;
199 unsigned char bus_mode;
200 unsigned char power_mode;
209 struct dma_chan *tx_chan;
210 struct dma_chan *rx_chan;
217 unsigned long clk_rate;
219 #define AUTO_CMD23 (1 << 0) /* Auto CMD23 support */
220 #define HSMMC_SDIO_IRQ_ENABLED (1 << 1) /* SDIO irq enabled */
221 #define HSMMC_WAKE_IRQ_ENABLED (1 << 2)
222 struct omap_hsmmc_next next_data;
223 struct omap_hsmmc_platform_data *pdata;
225 /* return MMC cover switch state, can be NULL if not supported.
227 * possible return values:
231 int (*get_cover_state)(struct device *dev);
233 /* Card detection IRQs */
236 int (*card_detect)(struct device *dev);
239 struct omap_mmc_of_data {
244 static void omap_hsmmc_start_dma_transfer(struct omap_hsmmc_host *host);
246 static int omap_hsmmc_card_detect(struct device *dev)
248 struct omap_hsmmc_host *host = dev_get_drvdata(dev);
250 return mmc_gpio_get_cd(host->mmc);
253 static int omap_hsmmc_get_cover_state(struct device *dev)
255 struct omap_hsmmc_host *host = dev_get_drvdata(dev);
257 return mmc_gpio_get_cd(host->mmc);
260 #ifdef CONFIG_REGULATOR
262 static int omap_hsmmc_set_power(struct device *dev, int power_on, int vdd)
264 struct omap_hsmmc_host *host =
265 platform_get_drvdata(to_platform_device(dev));
269 * If we don't see a Vcc regulator, assume it's a fixed
270 * voltage always-on regulator.
275 if (mmc_pdata(host)->before_set_reg)
276 mmc_pdata(host)->before_set_reg(dev, power_on, vdd);
279 if (host->pbias_enabled == 1) {
280 ret = regulator_disable(host->pbias);
282 host->pbias_enabled = 0;
284 regulator_set_voltage(host->pbias, VDD_3V0, VDD_3V0);
288 * Assume Vcc regulator is used only to power the card ... OMAP
289 * VDDS is used to power the pins, optionally with a transceiver to
290 * support cards using voltages other than VDDS (1.8V nominal). When a
291 * transceiver is used, DAT3..7 are muxed as transceiver control pins.
293 * In some cases this regulator won't support enable/disable;
294 * e.g. it's a fixed rail for a WLAN chip.
296 * In other cases vcc_aux switches interface power. Example, for
297 * eMMC cards it represents VccQ. Sometimes transceivers or SDIO
298 * chips/cards need an interface voltage rail too.
302 ret = mmc_regulator_set_ocr(host->mmc, host->vcc, vdd);
303 /* Enable interface voltage rail, if needed */
304 if (ret == 0 && host->vcc_aux) {
305 ret = regulator_enable(host->vcc_aux);
306 if (ret < 0 && host->vcc)
307 ret = mmc_regulator_set_ocr(host->mmc,
311 /* Shut down the rail */
313 ret = regulator_disable(host->vcc_aux);
315 /* Then proceed to shut down the local regulator */
316 ret = mmc_regulator_set_ocr(host->mmc,
322 if (vdd <= VDD_165_195)
323 ret = regulator_set_voltage(host->pbias, VDD_1V8,
326 ret = regulator_set_voltage(host->pbias, VDD_3V0,
329 goto error_set_power;
331 if (host->pbias_enabled == 0) {
332 ret = regulator_enable(host->pbias);
334 host->pbias_enabled = 1;
338 if (mmc_pdata(host)->after_set_reg)
339 mmc_pdata(host)->after_set_reg(dev, power_on, vdd);
345 static int omap_hsmmc_reg_get(struct omap_hsmmc_host *host)
347 struct regulator *reg;
350 reg = devm_regulator_get(host->dev, "vmmc");
352 dev_err(host->dev, "unable to get vmmc regulator %ld\n",
357 ocr_value = mmc_regulator_get_ocrmask(reg);
358 if (!mmc_pdata(host)->ocr_mask) {
359 mmc_pdata(host)->ocr_mask = ocr_value;
361 if (!(mmc_pdata(host)->ocr_mask & ocr_value)) {
362 dev_err(host->dev, "ocrmask %x is not supported\n",
363 mmc_pdata(host)->ocr_mask);
364 mmc_pdata(host)->ocr_mask = 0;
369 mmc_pdata(host)->set_power = omap_hsmmc_set_power;
371 /* Allow an aux regulator */
372 reg = devm_regulator_get_optional(host->dev, "vmmc_aux");
373 host->vcc_aux = IS_ERR(reg) ? NULL : reg;
375 reg = devm_regulator_get_optional(host->dev, "pbias");
376 host->pbias = IS_ERR(reg) ? NULL : reg;
378 /* For eMMC do not power off when not in sleep state */
379 if (mmc_pdata(host)->no_regulator_off_init)
382 * To disable boot_on regulator, enable regulator
383 * to increase usecount and then disable it.
385 if ((host->vcc && regulator_is_enabled(host->vcc) > 0) ||
386 (host->vcc_aux && regulator_is_enabled(host->vcc_aux))) {
387 int vdd = ffs(mmc_pdata(host)->ocr_mask) - 1;
389 mmc_pdata(host)->set_power(host->dev, 1, vdd);
390 mmc_pdata(host)->set_power(host->dev, 0, 0);
396 static void omap_hsmmc_reg_put(struct omap_hsmmc_host *host)
398 mmc_pdata(host)->set_power = NULL;
401 static inline int omap_hsmmc_have_reg(void)
408 static inline int omap_hsmmc_reg_get(struct omap_hsmmc_host *host)
413 static inline void omap_hsmmc_reg_put(struct omap_hsmmc_host *host)
417 static inline int omap_hsmmc_have_reg(void)
424 static irqreturn_t omap_hsmmc_detect(int irq, void *dev_id);
426 static int omap_hsmmc_gpio_init(struct mmc_host *mmc,
427 struct omap_hsmmc_host *host,
428 struct omap_hsmmc_platform_data *pdata)
432 if (gpio_is_valid(pdata->switch_pin)) {
434 host->get_cover_state =
435 omap_hsmmc_get_cover_state;
437 host->card_detect = omap_hsmmc_card_detect;
438 host->card_detect_irq =
439 gpio_to_irq(pdata->switch_pin);
440 mmc_gpio_set_cd_isr(mmc, omap_hsmmc_detect);
441 ret = mmc_gpio_request_cd(mmc, pdata->switch_pin, 0);
445 pdata->switch_pin = -EINVAL;
448 if (gpio_is_valid(pdata->gpio_wp)) {
449 ret = mmc_gpio_request_ro(mmc, pdata->gpio_wp);
458 * Start clock to the card
460 static void omap_hsmmc_start_clock(struct omap_hsmmc_host *host)
462 OMAP_HSMMC_WRITE(host->base, SYSCTL,
463 OMAP_HSMMC_READ(host->base, SYSCTL) | CEN);
467 * Stop clock to the card
469 static void omap_hsmmc_stop_clock(struct omap_hsmmc_host *host)
471 OMAP_HSMMC_WRITE(host->base, SYSCTL,
472 OMAP_HSMMC_READ(host->base, SYSCTL) & ~CEN);
473 if ((OMAP_HSMMC_READ(host->base, SYSCTL) & CEN) != 0x0)
474 dev_dbg(mmc_dev(host->mmc), "MMC Clock is not stopped\n");
477 static void omap_hsmmc_enable_irq(struct omap_hsmmc_host *host,
478 struct mmc_command *cmd)
480 u32 irq_mask = INT_EN_MASK;
484 irq_mask &= ~(BRR_EN | BWR_EN);
486 /* Disable timeout for erases */
487 if (cmd->opcode == MMC_ERASE)
490 spin_lock_irqsave(&host->irq_lock, flags);
491 OMAP_HSMMC_WRITE(host->base, STAT, STAT_CLEAR);
492 OMAP_HSMMC_WRITE(host->base, ISE, irq_mask);
494 /* latch pending CIRQ, but don't signal MMC core */
495 if (host->flags & HSMMC_SDIO_IRQ_ENABLED)
497 OMAP_HSMMC_WRITE(host->base, IE, irq_mask);
498 spin_unlock_irqrestore(&host->irq_lock, flags);
501 static void omap_hsmmc_disable_irq(struct omap_hsmmc_host *host)
506 spin_lock_irqsave(&host->irq_lock, flags);
507 /* no transfer running but need to keep cirq if enabled */
508 if (host->flags & HSMMC_SDIO_IRQ_ENABLED)
510 OMAP_HSMMC_WRITE(host->base, ISE, irq_mask);
511 OMAP_HSMMC_WRITE(host->base, IE, irq_mask);
512 OMAP_HSMMC_WRITE(host->base, STAT, STAT_CLEAR);
513 spin_unlock_irqrestore(&host->irq_lock, flags);
516 /* Calculate divisor for the given clock frequency */
517 static u16 calc_divisor(struct omap_hsmmc_host *host, struct mmc_ios *ios)
522 dsor = DIV_ROUND_UP(clk_get_rate(host->fclk), ios->clock);
530 static void omap_hsmmc_set_clock(struct omap_hsmmc_host *host)
532 struct mmc_ios *ios = &host->mmc->ios;
533 unsigned long regval;
534 unsigned long timeout;
535 unsigned long clkdiv;
537 dev_vdbg(mmc_dev(host->mmc), "Set clock to %uHz\n", ios->clock);
539 omap_hsmmc_stop_clock(host);
541 regval = OMAP_HSMMC_READ(host->base, SYSCTL);
542 regval = regval & ~(CLKD_MASK | DTO_MASK);
543 clkdiv = calc_divisor(host, ios);
544 regval = regval | (clkdiv << 6) | (DTO << 16);
545 OMAP_HSMMC_WRITE(host->base, SYSCTL, regval);
546 OMAP_HSMMC_WRITE(host->base, SYSCTL,
547 OMAP_HSMMC_READ(host->base, SYSCTL) | ICE);
549 /* Wait till the ICS bit is set */
550 timeout = jiffies + msecs_to_jiffies(MMC_TIMEOUT_MS);
551 while ((OMAP_HSMMC_READ(host->base, SYSCTL) & ICS) != ICS
552 && time_before(jiffies, timeout))
556 * Enable High-Speed Support
558 * - Controller should support High-Speed-Enable Bit
559 * - Controller should not be using DDR Mode
560 * - Controller should advertise that it supports High Speed
561 * in capabilities register
562 * - MMC/SD clock coming out of controller > 25MHz
564 if ((mmc_pdata(host)->features & HSMMC_HAS_HSPE_SUPPORT) &&
565 (ios->timing != MMC_TIMING_MMC_DDR52) &&
566 (ios->timing != MMC_TIMING_UHS_DDR50) &&
567 ((OMAP_HSMMC_READ(host->base, CAPA) & HSS) == HSS)) {
568 regval = OMAP_HSMMC_READ(host->base, HCTL);
569 if (clkdiv && (clk_get_rate(host->fclk)/clkdiv) > 25000000)
574 OMAP_HSMMC_WRITE(host->base, HCTL, regval);
577 omap_hsmmc_start_clock(host);
580 static void omap_hsmmc_set_bus_width(struct omap_hsmmc_host *host)
582 struct mmc_ios *ios = &host->mmc->ios;
585 con = OMAP_HSMMC_READ(host->base, CON);
586 if (ios->timing == MMC_TIMING_MMC_DDR52 ||
587 ios->timing == MMC_TIMING_UHS_DDR50)
588 con |= DDR; /* configure in DDR mode */
591 switch (ios->bus_width) {
592 case MMC_BUS_WIDTH_8:
593 OMAP_HSMMC_WRITE(host->base, CON, con | DW8);
595 case MMC_BUS_WIDTH_4:
596 OMAP_HSMMC_WRITE(host->base, CON, con & ~DW8);
597 OMAP_HSMMC_WRITE(host->base, HCTL,
598 OMAP_HSMMC_READ(host->base, HCTL) | FOUR_BIT);
600 case MMC_BUS_WIDTH_1:
601 OMAP_HSMMC_WRITE(host->base, CON, con & ~DW8);
602 OMAP_HSMMC_WRITE(host->base, HCTL,
603 OMAP_HSMMC_READ(host->base, HCTL) & ~FOUR_BIT);
608 static void omap_hsmmc_set_bus_mode(struct omap_hsmmc_host *host)
610 struct mmc_ios *ios = &host->mmc->ios;
613 con = OMAP_HSMMC_READ(host->base, CON);
614 if (ios->bus_mode == MMC_BUSMODE_OPENDRAIN)
615 OMAP_HSMMC_WRITE(host->base, CON, con | OD);
617 OMAP_HSMMC_WRITE(host->base, CON, con & ~OD);
623 * Restore the MMC host context, if it was lost as result of a
624 * power state change.
626 static int omap_hsmmc_context_restore(struct omap_hsmmc_host *host)
628 struct mmc_ios *ios = &host->mmc->ios;
630 unsigned long timeout;
632 if (host->con == OMAP_HSMMC_READ(host->base, CON) &&
633 host->hctl == OMAP_HSMMC_READ(host->base, HCTL) &&
634 host->sysctl == OMAP_HSMMC_READ(host->base, SYSCTL) &&
635 host->capa == OMAP_HSMMC_READ(host->base, CAPA))
638 host->context_loss++;
640 if (host->pdata->controller_flags & OMAP_HSMMC_SUPPORTS_DUAL_VOLT) {
641 if (host->power_mode != MMC_POWER_OFF &&
642 (1 << ios->vdd) <= MMC_VDD_23_24)
652 if (host->mmc->caps & MMC_CAP_SDIO_IRQ)
655 OMAP_HSMMC_WRITE(host->base, HCTL,
656 OMAP_HSMMC_READ(host->base, HCTL) | hctl);
658 OMAP_HSMMC_WRITE(host->base, CAPA,
659 OMAP_HSMMC_READ(host->base, CAPA) | capa);
661 OMAP_HSMMC_WRITE(host->base, HCTL,
662 OMAP_HSMMC_READ(host->base, HCTL) | SDBP);
664 timeout = jiffies + msecs_to_jiffies(MMC_TIMEOUT_MS);
665 while ((OMAP_HSMMC_READ(host->base, HCTL) & SDBP) != SDBP
666 && time_before(jiffies, timeout))
669 OMAP_HSMMC_WRITE(host->base, ISE, 0);
670 OMAP_HSMMC_WRITE(host->base, IE, 0);
671 OMAP_HSMMC_WRITE(host->base, STAT, STAT_CLEAR);
673 /* Do not initialize card-specific things if the power is off */
674 if (host->power_mode == MMC_POWER_OFF)
677 omap_hsmmc_set_bus_width(host);
679 omap_hsmmc_set_clock(host);
681 omap_hsmmc_set_bus_mode(host);
684 dev_dbg(mmc_dev(host->mmc), "context is restored: restore count %d\n",
690 * Save the MMC host context (store the number of power state changes so far).
692 static void omap_hsmmc_context_save(struct omap_hsmmc_host *host)
694 host->con = OMAP_HSMMC_READ(host->base, CON);
695 host->hctl = OMAP_HSMMC_READ(host->base, HCTL);
696 host->sysctl = OMAP_HSMMC_READ(host->base, SYSCTL);
697 host->capa = OMAP_HSMMC_READ(host->base, CAPA);
702 static int omap_hsmmc_context_restore(struct omap_hsmmc_host *host)
707 static void omap_hsmmc_context_save(struct omap_hsmmc_host *host)
714 * Send init stream sequence to card
715 * before sending IDLE command
717 static void send_init_stream(struct omap_hsmmc_host *host)
720 unsigned long timeout;
722 if (host->protect_card)
725 disable_irq(host->irq);
727 OMAP_HSMMC_WRITE(host->base, IE, INT_EN_MASK);
728 OMAP_HSMMC_WRITE(host->base, CON,
729 OMAP_HSMMC_READ(host->base, CON) | INIT_STREAM);
730 OMAP_HSMMC_WRITE(host->base, CMD, INIT_STREAM_CMD);
732 timeout = jiffies + msecs_to_jiffies(MMC_TIMEOUT_MS);
733 while ((reg != CC_EN) && time_before(jiffies, timeout))
734 reg = OMAP_HSMMC_READ(host->base, STAT) & CC_EN;
736 OMAP_HSMMC_WRITE(host->base, CON,
737 OMAP_HSMMC_READ(host->base, CON) & ~INIT_STREAM);
739 OMAP_HSMMC_WRITE(host->base, STAT, STAT_CLEAR);
740 OMAP_HSMMC_READ(host->base, STAT);
742 enable_irq(host->irq);
746 int omap_hsmmc_cover_is_closed(struct omap_hsmmc_host *host)
750 if (host->get_cover_state)
751 r = host->get_cover_state(host->dev);
756 omap_hsmmc_show_cover_switch(struct device *dev, struct device_attribute *attr,
759 struct mmc_host *mmc = container_of(dev, struct mmc_host, class_dev);
760 struct omap_hsmmc_host *host = mmc_priv(mmc);
762 return sprintf(buf, "%s\n",
763 omap_hsmmc_cover_is_closed(host) ? "closed" : "open");
766 static DEVICE_ATTR(cover_switch, S_IRUGO, omap_hsmmc_show_cover_switch, NULL);
769 omap_hsmmc_show_slot_name(struct device *dev, struct device_attribute *attr,
772 struct mmc_host *mmc = container_of(dev, struct mmc_host, class_dev);
773 struct omap_hsmmc_host *host = mmc_priv(mmc);
775 return sprintf(buf, "%s\n", mmc_pdata(host)->name);
778 static DEVICE_ATTR(slot_name, S_IRUGO, omap_hsmmc_show_slot_name, NULL);
781 * Configure the response type and send the cmd.
784 omap_hsmmc_start_command(struct omap_hsmmc_host *host, struct mmc_command *cmd,
785 struct mmc_data *data)
787 int cmdreg = 0, resptype = 0, cmdtype = 0;
789 dev_vdbg(mmc_dev(host->mmc), "%s: CMD%d, argument 0x%08x\n",
790 mmc_hostname(host->mmc), cmd->opcode, cmd->arg);
793 omap_hsmmc_enable_irq(host, cmd);
795 host->response_busy = 0;
796 if (cmd->flags & MMC_RSP_PRESENT) {
797 if (cmd->flags & MMC_RSP_136)
799 else if (cmd->flags & MMC_RSP_BUSY) {
801 host->response_busy = 1;
807 * Unlike OMAP1 controller, the cmdtype does not seem to be based on
808 * ac, bc, adtc, bcr. Only commands ending an open ended transfer need
809 * a val of 0x3, rest 0x0.
811 if (cmd == host->mrq->stop)
814 cmdreg = (cmd->opcode << 24) | (resptype << 16) | (cmdtype << 22);
816 if ((host->flags & AUTO_CMD23) && mmc_op_multi(cmd->opcode) &&
818 cmdreg |= ACEN_ACMD23;
819 OMAP_HSMMC_WRITE(host->base, SDMASA, host->mrq->sbc->arg);
822 cmdreg |= DP_SELECT | MSBS | BCE;
823 if (data->flags & MMC_DATA_READ)
832 host->req_in_progress = 1;
834 OMAP_HSMMC_WRITE(host->base, ARG, cmd->arg);
835 OMAP_HSMMC_WRITE(host->base, CMD, cmdreg);
839 omap_hsmmc_get_dma_dir(struct omap_hsmmc_host *host, struct mmc_data *data)
841 if (data->flags & MMC_DATA_WRITE)
842 return DMA_TO_DEVICE;
844 return DMA_FROM_DEVICE;
847 static struct dma_chan *omap_hsmmc_get_dma_chan(struct omap_hsmmc_host *host,
848 struct mmc_data *data)
850 return data->flags & MMC_DATA_WRITE ? host->tx_chan : host->rx_chan;
853 static void omap_hsmmc_request_done(struct omap_hsmmc_host *host, struct mmc_request *mrq)
858 spin_lock_irqsave(&host->irq_lock, flags);
859 host->req_in_progress = 0;
860 dma_ch = host->dma_ch;
861 spin_unlock_irqrestore(&host->irq_lock, flags);
863 omap_hsmmc_disable_irq(host);
864 /* Do not complete the request if DMA is still in progress */
865 if (mrq->data && host->use_dma && dma_ch != -1)
868 mmc_request_done(host->mmc, mrq);
872 * Notify the transfer complete to MMC core
875 omap_hsmmc_xfer_done(struct omap_hsmmc_host *host, struct mmc_data *data)
878 struct mmc_request *mrq = host->mrq;
880 /* TC before CC from CMD6 - don't know why, but it happens */
881 if (host->cmd && host->cmd->opcode == 6 &&
882 host->response_busy) {
883 host->response_busy = 0;
887 omap_hsmmc_request_done(host, mrq);
894 data->bytes_xfered += data->blocks * (data->blksz);
896 data->bytes_xfered = 0;
898 if (data->stop && (data->error || !host->mrq->sbc))
899 omap_hsmmc_start_command(host, data->stop, NULL);
901 omap_hsmmc_request_done(host, data->mrq);
905 * Notify the core about command completion
908 omap_hsmmc_cmd_done(struct omap_hsmmc_host *host, struct mmc_command *cmd)
910 if (host->mrq->sbc && (host->cmd == host->mrq->sbc) &&
911 !host->mrq->sbc->error && !(host->flags & AUTO_CMD23)) {
913 omap_hsmmc_start_dma_transfer(host);
914 omap_hsmmc_start_command(host, host->mrq->cmd,
921 if (cmd->flags & MMC_RSP_PRESENT) {
922 if (cmd->flags & MMC_RSP_136) {
923 /* response type 2 */
924 cmd->resp[3] = OMAP_HSMMC_READ(host->base, RSP10);
925 cmd->resp[2] = OMAP_HSMMC_READ(host->base, RSP32);
926 cmd->resp[1] = OMAP_HSMMC_READ(host->base, RSP54);
927 cmd->resp[0] = OMAP_HSMMC_READ(host->base, RSP76);
929 /* response types 1, 1b, 3, 4, 5, 6 */
930 cmd->resp[0] = OMAP_HSMMC_READ(host->base, RSP10);
933 if ((host->data == NULL && !host->response_busy) || cmd->error)
934 omap_hsmmc_request_done(host, host->mrq);
938 * DMA clean up for command errors
940 static void omap_hsmmc_dma_cleanup(struct omap_hsmmc_host *host, int errno)
945 host->data->error = errno;
947 spin_lock_irqsave(&host->irq_lock, flags);
948 dma_ch = host->dma_ch;
950 spin_unlock_irqrestore(&host->irq_lock, flags);
952 if (host->use_dma && dma_ch != -1) {
953 struct dma_chan *chan = omap_hsmmc_get_dma_chan(host, host->data);
955 dmaengine_terminate_all(chan);
956 dma_unmap_sg(chan->device->dev,
957 host->data->sg, host->data->sg_len,
958 omap_hsmmc_get_dma_dir(host, host->data));
960 host->data->host_cookie = 0;
966 * Readable error output
968 #ifdef CONFIG_MMC_DEBUG
969 static void omap_hsmmc_dbg_report_irq(struct omap_hsmmc_host *host, u32 status)
971 /* --- means reserved bit without definition at documentation */
972 static const char *omap_hsmmc_status_bits[] = {
973 "CC" , "TC" , "BGE", "---", "BWR" , "BRR" , "---" , "---" ,
974 "CIRQ", "OBI" , "---", "---", "---" , "---" , "---" , "ERRI",
975 "CTO" , "CCRC", "CEB", "CIE", "DTO" , "DCRC", "DEB" , "---" ,
976 "ACE" , "---" , "---", "---", "CERR", "BADA", "---" , "---"
982 len = sprintf(buf, "MMC IRQ 0x%x :", status);
985 for (i = 0; i < ARRAY_SIZE(omap_hsmmc_status_bits); i++)
986 if (status & (1 << i)) {
987 len = sprintf(buf, " %s", omap_hsmmc_status_bits[i]);
991 dev_vdbg(mmc_dev(host->mmc), "%s\n", res);
994 static inline void omap_hsmmc_dbg_report_irq(struct omap_hsmmc_host *host,
998 #endif /* CONFIG_MMC_DEBUG */
1001 * MMC controller internal state machines reset
1003 * Used to reset command or data internal state machines, using respectively
1004 * SRC or SRD bit of SYSCTL register
1005 * Can be called from interrupt context
1007 static inline void omap_hsmmc_reset_controller_fsm(struct omap_hsmmc_host *host,
1010 unsigned long i = 0;
1011 unsigned long limit = MMC_TIMEOUT_US;
1013 OMAP_HSMMC_WRITE(host->base, SYSCTL,
1014 OMAP_HSMMC_READ(host->base, SYSCTL) | bit);
1017 * OMAP4 ES2 and greater has an updated reset logic.
1018 * Monitor a 0->1 transition first
1020 if (mmc_pdata(host)->features & HSMMC_HAS_UPDATED_RESET) {
1021 while ((!(OMAP_HSMMC_READ(host->base, SYSCTL) & bit))
1027 while ((OMAP_HSMMC_READ(host->base, SYSCTL) & bit) &&
1031 if (OMAP_HSMMC_READ(host->base, SYSCTL) & bit)
1032 dev_err(mmc_dev(host->mmc),
1033 "Timeout waiting on controller reset in %s\n",
1037 static void hsmmc_command_incomplete(struct omap_hsmmc_host *host,
1038 int err, int end_cmd)
1041 omap_hsmmc_reset_controller_fsm(host, SRC);
1043 host->cmd->error = err;
1047 omap_hsmmc_reset_controller_fsm(host, SRD);
1048 omap_hsmmc_dma_cleanup(host, err);
1049 } else if (host->mrq && host->mrq->cmd)
1050 host->mrq->cmd->error = err;
1053 static void omap_hsmmc_do_irq(struct omap_hsmmc_host *host, int status)
1055 struct mmc_data *data;
1056 int end_cmd = 0, end_trans = 0;
1060 dev_vdbg(mmc_dev(host->mmc), "IRQ Status is %x\n", status);
1062 if (status & ERR_EN) {
1063 omap_hsmmc_dbg_report_irq(host, status);
1065 if (status & (CTO_EN | CCRC_EN))
1067 if (status & (CTO_EN | DTO_EN))
1068 hsmmc_command_incomplete(host, -ETIMEDOUT, end_cmd);
1069 else if (status & (CCRC_EN | DCRC_EN))
1070 hsmmc_command_incomplete(host, -EILSEQ, end_cmd);
1072 if (status & ACE_EN) {
1074 ac12 = OMAP_HSMMC_READ(host->base, AC12);
1075 if (!(ac12 & ACNE) && host->mrq->sbc) {
1079 else if (ac12 & (ACCE | ACEB | ACIE))
1081 host->mrq->sbc->error = error;
1082 hsmmc_command_incomplete(host, error, end_cmd);
1084 dev_dbg(mmc_dev(host->mmc), "AC12 err: 0x%x\n", ac12);
1086 if (host->data || host->response_busy) {
1087 end_trans = !end_cmd;
1088 host->response_busy = 0;
1092 OMAP_HSMMC_WRITE(host->base, STAT, status);
1093 if (end_cmd || ((status & CC_EN) && host->cmd))
1094 omap_hsmmc_cmd_done(host, host->cmd);
1095 if ((end_trans || (status & TC_EN)) && host->mrq)
1096 omap_hsmmc_xfer_done(host, data);
1100 * MMC controller IRQ handler
1102 static irqreturn_t omap_hsmmc_irq(int irq, void *dev_id)
1104 struct omap_hsmmc_host *host = dev_id;
1107 status = OMAP_HSMMC_READ(host->base, STAT);
1108 while (status & (INT_EN_MASK | CIRQ_EN)) {
1109 if (host->req_in_progress)
1110 omap_hsmmc_do_irq(host, status);
1112 if (status & CIRQ_EN)
1113 mmc_signal_sdio_irq(host->mmc);
1115 /* Flush posted write */
1116 status = OMAP_HSMMC_READ(host->base, STAT);
1122 static irqreturn_t omap_hsmmc_wake_irq(int irq, void *dev_id)
1124 struct omap_hsmmc_host *host = dev_id;
1126 /* cirq is level triggered, disable to avoid infinite loop */
1127 spin_lock(&host->irq_lock);
1128 if (host->flags & HSMMC_WAKE_IRQ_ENABLED) {
1129 disable_irq_nosync(host->wake_irq);
1130 host->flags &= ~HSMMC_WAKE_IRQ_ENABLED;
1132 spin_unlock(&host->irq_lock);
1133 pm_request_resume(host->dev); /* no use counter */
1138 static void set_sd_bus_power(struct omap_hsmmc_host *host)
1142 OMAP_HSMMC_WRITE(host->base, HCTL,
1143 OMAP_HSMMC_READ(host->base, HCTL) | SDBP);
1144 for (i = 0; i < loops_per_jiffy; i++) {
1145 if (OMAP_HSMMC_READ(host->base, HCTL) & SDBP)
1152 * Switch MMC interface voltage ... only relevant for MMC1.
1154 * MMC2 and MMC3 use fixed 1.8V levels, and maybe a transceiver.
1155 * The MMC2 transceiver controls are used instead of DAT4..DAT7.
1156 * Some chips, like eMMC ones, use internal transceivers.
1158 static int omap_hsmmc_switch_opcond(struct omap_hsmmc_host *host, int vdd)
1163 /* Disable the clocks */
1164 pm_runtime_put_sync(host->dev);
1166 clk_disable_unprepare(host->dbclk);
1168 /* Turn the power off */
1169 ret = mmc_pdata(host)->set_power(host->dev, 0, 0);
1171 /* Turn the power ON with given VDD 1.8 or 3.0v */
1173 ret = mmc_pdata(host)->set_power(host->dev, 1, vdd);
1174 pm_runtime_get_sync(host->dev);
1176 clk_prepare_enable(host->dbclk);
1181 OMAP_HSMMC_WRITE(host->base, HCTL,
1182 OMAP_HSMMC_READ(host->base, HCTL) & SDVSCLR);
1183 reg_val = OMAP_HSMMC_READ(host->base, HCTL);
1186 * If a MMC dual voltage card is detected, the set_ios fn calls
1187 * this fn with VDD bit set for 1.8V. Upon card removal from the
1188 * slot, omap_hsmmc_set_ios sets the VDD back to 3V on MMC_POWER_OFF.
1190 * Cope with a bit of slop in the range ... per data sheets:
1191 * - "1.8V" for vdds_mmc1/vdds_mmc1a can be up to 2.45V max,
1192 * but recommended values are 1.71V to 1.89V
1193 * - "3.0V" for vdds_mmc1/vdds_mmc1a can be up to 3.5V max,
1194 * but recommended values are 2.7V to 3.3V
1196 * Board setup code shouldn't permit anything very out-of-range.
1197 * TWL4030-family VMMC1 and VSIM regulators are fine (avoiding the
1198 * middle range) but VSIM can't power DAT4..DAT7 at more than 3V.
1200 if ((1 << vdd) <= MMC_VDD_23_24)
1205 OMAP_HSMMC_WRITE(host->base, HCTL, reg_val);
1206 set_sd_bus_power(host);
1210 dev_err(mmc_dev(host->mmc), "Unable to switch operating voltage\n");
1214 /* Protect the card while the cover is open */
1215 static void omap_hsmmc_protect_card(struct omap_hsmmc_host *host)
1217 if (!host->get_cover_state)
1220 host->reqs_blocked = 0;
1221 if (host->get_cover_state(host->dev)) {
1222 if (host->protect_card) {
1223 dev_info(host->dev, "%s: cover is closed, "
1224 "card is now accessible\n",
1225 mmc_hostname(host->mmc));
1226 host->protect_card = 0;
1229 if (!host->protect_card) {
1230 dev_info(host->dev, "%s: cover is open, "
1231 "card is now inaccessible\n",
1232 mmc_hostname(host->mmc));
1233 host->protect_card = 1;
1239 * irq handler to notify the core about card insertion/removal
1241 static irqreturn_t omap_hsmmc_detect(int irq, void *dev_id)
1243 struct omap_hsmmc_host *host = dev_id;
1246 sysfs_notify(&host->mmc->class_dev.kobj, NULL, "cover_switch");
1248 if (host->card_detect)
1249 carddetect = host->card_detect(host->dev);
1251 omap_hsmmc_protect_card(host);
1252 carddetect = -ENOSYS;
1256 mmc_detect_change(host->mmc, (HZ * 200) / 1000);
1258 mmc_detect_change(host->mmc, (HZ * 50) / 1000);
1262 static void omap_hsmmc_dma_callback(void *param)
1264 struct omap_hsmmc_host *host = param;
1265 struct dma_chan *chan;
1266 struct mmc_data *data;
1267 int req_in_progress;
1269 spin_lock_irq(&host->irq_lock);
1270 if (host->dma_ch < 0) {
1271 spin_unlock_irq(&host->irq_lock);
1275 data = host->mrq->data;
1276 chan = omap_hsmmc_get_dma_chan(host, data);
1277 if (!data->host_cookie)
1278 dma_unmap_sg(chan->device->dev,
1279 data->sg, data->sg_len,
1280 omap_hsmmc_get_dma_dir(host, data));
1282 req_in_progress = host->req_in_progress;
1284 spin_unlock_irq(&host->irq_lock);
1286 /* If DMA has finished after TC, complete the request */
1287 if (!req_in_progress) {
1288 struct mmc_request *mrq = host->mrq;
1291 mmc_request_done(host->mmc, mrq);
1295 static int omap_hsmmc_pre_dma_transfer(struct omap_hsmmc_host *host,
1296 struct mmc_data *data,
1297 struct omap_hsmmc_next *next,
1298 struct dma_chan *chan)
1302 if (!next && data->host_cookie &&
1303 data->host_cookie != host->next_data.cookie) {
1304 dev_warn(host->dev, "[%s] invalid cookie: data->host_cookie %d"
1305 " host->next_data.cookie %d\n",
1306 __func__, data->host_cookie, host->next_data.cookie);
1307 data->host_cookie = 0;
1310 /* Check if next job is already prepared */
1311 if (next || data->host_cookie != host->next_data.cookie) {
1312 dma_len = dma_map_sg(chan->device->dev, data->sg, data->sg_len,
1313 omap_hsmmc_get_dma_dir(host, data));
1316 dma_len = host->next_data.dma_len;
1317 host->next_data.dma_len = 0;
1325 next->dma_len = dma_len;
1326 data->host_cookie = ++next->cookie < 0 ? 1 : next->cookie;
1328 host->dma_len = dma_len;
1334 * Routine to configure and start DMA for the MMC card
1336 static int omap_hsmmc_setup_dma_transfer(struct omap_hsmmc_host *host,
1337 struct mmc_request *req)
1339 struct dma_slave_config cfg;
1340 struct dma_async_tx_descriptor *tx;
1342 struct mmc_data *data = req->data;
1343 struct dma_chan *chan;
1345 /* Sanity check: all the SG entries must be aligned by block size. */
1346 for (i = 0; i < data->sg_len; i++) {
1347 struct scatterlist *sgl;
1350 if (sgl->length % data->blksz)
1353 if ((data->blksz % 4) != 0)
1354 /* REVISIT: The MMC buffer increments only when MSB is written.
1355 * Return error for blksz which is non multiple of four.
1359 BUG_ON(host->dma_ch != -1);
1361 chan = omap_hsmmc_get_dma_chan(host, data);
1363 cfg.src_addr = host->mapbase + OMAP_HSMMC_DATA;
1364 cfg.dst_addr = host->mapbase + OMAP_HSMMC_DATA;
1365 cfg.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
1366 cfg.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
1367 cfg.src_maxburst = data->blksz / 4;
1368 cfg.dst_maxburst = data->blksz / 4;
1370 ret = dmaengine_slave_config(chan, &cfg);
1374 ret = omap_hsmmc_pre_dma_transfer(host, data, NULL, chan);
1378 tx = dmaengine_prep_slave_sg(chan, data->sg, data->sg_len,
1379 data->flags & MMC_DATA_WRITE ? DMA_MEM_TO_DEV : DMA_DEV_TO_MEM,
1380 DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
1382 dev_err(mmc_dev(host->mmc), "prep_slave_sg() failed\n");
1383 /* FIXME: cleanup */
1387 tx->callback = omap_hsmmc_dma_callback;
1388 tx->callback_param = host;
1391 dmaengine_submit(tx);
1398 static void set_data_timeout(struct omap_hsmmc_host *host,
1399 unsigned int timeout_ns,
1400 unsigned int timeout_clks)
1402 unsigned int timeout, cycle_ns;
1403 uint32_t reg, clkd, dto = 0;
1405 reg = OMAP_HSMMC_READ(host->base, SYSCTL);
1406 clkd = (reg & CLKD_MASK) >> CLKD_SHIFT;
1410 cycle_ns = 1000000000 / (host->clk_rate / clkd);
1411 timeout = timeout_ns / cycle_ns;
1412 timeout += timeout_clks;
1414 while ((timeout & 0x80000000) == 0) {
1431 reg |= dto << DTO_SHIFT;
1432 OMAP_HSMMC_WRITE(host->base, SYSCTL, reg);
1435 static void omap_hsmmc_start_dma_transfer(struct omap_hsmmc_host *host)
1437 struct mmc_request *req = host->mrq;
1438 struct dma_chan *chan;
1442 OMAP_HSMMC_WRITE(host->base, BLK, (req->data->blksz)
1443 | (req->data->blocks << 16));
1444 set_data_timeout(host, req->data->timeout_ns,
1445 req->data->timeout_clks);
1446 chan = omap_hsmmc_get_dma_chan(host, req->data);
1447 dma_async_issue_pending(chan);
1451 * Configure block length for MMC/SD cards and initiate the transfer.
1454 omap_hsmmc_prepare_data(struct omap_hsmmc_host *host, struct mmc_request *req)
1457 host->data = req->data;
1459 if (req->data == NULL) {
1460 OMAP_HSMMC_WRITE(host->base, BLK, 0);
1462 * Set an arbitrary 100ms data timeout for commands with
1465 if (req->cmd->flags & MMC_RSP_BUSY)
1466 set_data_timeout(host, 100000000U, 0);
1470 if (host->use_dma) {
1471 ret = omap_hsmmc_setup_dma_transfer(host, req);
1473 dev_err(mmc_dev(host->mmc), "MMC start dma failure\n");
1480 static void omap_hsmmc_post_req(struct mmc_host *mmc, struct mmc_request *mrq,
1483 struct omap_hsmmc_host *host = mmc_priv(mmc);
1484 struct mmc_data *data = mrq->data;
1486 if (host->use_dma && data->host_cookie) {
1487 struct dma_chan *c = omap_hsmmc_get_dma_chan(host, data);
1489 dma_unmap_sg(c->device->dev, data->sg, data->sg_len,
1490 omap_hsmmc_get_dma_dir(host, data));
1491 data->host_cookie = 0;
1495 static void omap_hsmmc_pre_req(struct mmc_host *mmc, struct mmc_request *mrq,
1498 struct omap_hsmmc_host *host = mmc_priv(mmc);
1500 if (mrq->data->host_cookie) {
1501 mrq->data->host_cookie = 0;
1505 if (host->use_dma) {
1506 struct dma_chan *c = omap_hsmmc_get_dma_chan(host, mrq->data);
1508 if (omap_hsmmc_pre_dma_transfer(host, mrq->data,
1509 &host->next_data, c))
1510 mrq->data->host_cookie = 0;
1515 * Request function. for read/write operation
1517 static void omap_hsmmc_request(struct mmc_host *mmc, struct mmc_request *req)
1519 struct omap_hsmmc_host *host = mmc_priv(mmc);
1522 BUG_ON(host->req_in_progress);
1523 BUG_ON(host->dma_ch != -1);
1524 if (host->protect_card) {
1525 if (host->reqs_blocked < 3) {
1527 * Ensure the controller is left in a consistent
1528 * state by resetting the command and data state
1531 omap_hsmmc_reset_controller_fsm(host, SRD);
1532 omap_hsmmc_reset_controller_fsm(host, SRC);
1533 host->reqs_blocked += 1;
1535 req->cmd->error = -EBADF;
1537 req->data->error = -EBADF;
1538 req->cmd->retries = 0;
1539 mmc_request_done(mmc, req);
1541 } else if (host->reqs_blocked)
1542 host->reqs_blocked = 0;
1543 WARN_ON(host->mrq != NULL);
1545 host->clk_rate = clk_get_rate(host->fclk);
1546 err = omap_hsmmc_prepare_data(host, req);
1548 req->cmd->error = err;
1550 req->data->error = err;
1552 mmc_request_done(mmc, req);
1555 if (req->sbc && !(host->flags & AUTO_CMD23)) {
1556 omap_hsmmc_start_command(host, req->sbc, NULL);
1560 omap_hsmmc_start_dma_transfer(host);
1561 omap_hsmmc_start_command(host, req->cmd, req->data);
1564 /* Routine to configure clock values. Exposed API to core */
1565 static void omap_hsmmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
1567 struct omap_hsmmc_host *host = mmc_priv(mmc);
1568 int do_send_init_stream = 0;
1570 pm_runtime_get_sync(host->dev);
1572 if (ios->power_mode != host->power_mode) {
1573 switch (ios->power_mode) {
1575 mmc_pdata(host)->set_power(host->dev, 0, 0);
1578 mmc_pdata(host)->set_power(host->dev, 1, ios->vdd);
1581 do_send_init_stream = 1;
1584 host->power_mode = ios->power_mode;
1587 /* FIXME: set registers based only on changes to ios */
1589 omap_hsmmc_set_bus_width(host);
1591 if (host->pdata->controller_flags & OMAP_HSMMC_SUPPORTS_DUAL_VOLT) {
1592 /* Only MMC1 can interface at 3V without some flavor
1593 * of external transceiver; but they all handle 1.8V.
1595 if ((OMAP_HSMMC_READ(host->base, HCTL) & SDVSDET) &&
1596 (ios->vdd == DUAL_VOLT_OCR_BIT)) {
1598 * The mmc_select_voltage fn of the core does
1599 * not seem to set the power_mode to
1600 * MMC_POWER_UP upon recalculating the voltage.
1603 if (omap_hsmmc_switch_opcond(host, ios->vdd) != 0)
1604 dev_dbg(mmc_dev(host->mmc),
1605 "Switch operation failed\n");
1609 omap_hsmmc_set_clock(host);
1611 if (do_send_init_stream)
1612 send_init_stream(host);
1614 omap_hsmmc_set_bus_mode(host);
1616 pm_runtime_put_autosuspend(host->dev);
1619 static int omap_hsmmc_get_cd(struct mmc_host *mmc)
1621 struct omap_hsmmc_host *host = mmc_priv(mmc);
1623 if (!host->card_detect)
1625 return host->card_detect(host->dev);
1628 static void omap_hsmmc_init_card(struct mmc_host *mmc, struct mmc_card *card)
1630 struct omap_hsmmc_host *host = mmc_priv(mmc);
1632 if (mmc_pdata(host)->init_card)
1633 mmc_pdata(host)->init_card(card);
1636 static void omap_hsmmc_enable_sdio_irq(struct mmc_host *mmc, int enable)
1638 struct omap_hsmmc_host *host = mmc_priv(mmc);
1640 unsigned long flags;
1642 spin_lock_irqsave(&host->irq_lock, flags);
1644 con = OMAP_HSMMC_READ(host->base, CON);
1645 irq_mask = OMAP_HSMMC_READ(host->base, ISE);
1647 host->flags |= HSMMC_SDIO_IRQ_ENABLED;
1648 irq_mask |= CIRQ_EN;
1649 con |= CTPL | CLKEXTFREE;
1651 host->flags &= ~HSMMC_SDIO_IRQ_ENABLED;
1652 irq_mask &= ~CIRQ_EN;
1653 con &= ~(CTPL | CLKEXTFREE);
1655 OMAP_HSMMC_WRITE(host->base, CON, con);
1656 OMAP_HSMMC_WRITE(host->base, IE, irq_mask);
1659 * if enable, piggy back detection on current request
1660 * but always disable immediately
1662 if (!host->req_in_progress || !enable)
1663 OMAP_HSMMC_WRITE(host->base, ISE, irq_mask);
1665 /* flush posted write */
1666 OMAP_HSMMC_READ(host->base, IE);
1668 spin_unlock_irqrestore(&host->irq_lock, flags);
1671 static int omap_hsmmc_configure_wake_irq(struct omap_hsmmc_host *host)
1673 struct mmc_host *mmc = host->mmc;
1677 * For omaps with wake-up path, wakeirq will be irq from pinctrl and
1678 * for other omaps, wakeirq will be from GPIO (dat line remuxed to
1679 * gpio). wakeirq is needed to detect sdio irq in runtime suspend state
1680 * with functional clock disabled.
1682 if (!host->dev->of_node || !host->wake_irq)
1685 /* Prevent auto-enabling of IRQ */
1686 irq_set_status_flags(host->wake_irq, IRQ_NOAUTOEN);
1687 ret = devm_request_irq(host->dev, host->wake_irq, omap_hsmmc_wake_irq,
1688 IRQF_TRIGGER_LOW | IRQF_ONESHOT,
1689 mmc_hostname(mmc), host);
1691 dev_err(mmc_dev(host->mmc), "Unable to request wake IRQ\n");
1696 * Some omaps don't have wake-up path from deeper idle states
1697 * and need to remux SDIO DAT1 to GPIO for wake-up from idle.
1699 if (host->pdata->controller_flags & OMAP_HSMMC_SWAKEUP_MISSING) {
1700 struct pinctrl *p = devm_pinctrl_get(host->dev);
1705 if (IS_ERR(pinctrl_lookup_state(p, PINCTRL_STATE_DEFAULT))) {
1706 dev_info(host->dev, "missing default pinctrl state\n");
1707 devm_pinctrl_put(p);
1712 if (IS_ERR(pinctrl_lookup_state(p, PINCTRL_STATE_IDLE))) {
1713 dev_info(host->dev, "missing idle pinctrl state\n");
1714 devm_pinctrl_put(p);
1718 devm_pinctrl_put(p);
1721 OMAP_HSMMC_WRITE(host->base, HCTL,
1722 OMAP_HSMMC_READ(host->base, HCTL) | IWE);
1726 devm_free_irq(host->dev, host->wake_irq, host);
1728 dev_warn(host->dev, "no SDIO IRQ support, falling back to polling\n");
1733 static void omap_hsmmc_conf_bus_power(struct omap_hsmmc_host *host)
1735 u32 hctl, capa, value;
1737 /* Only MMC1 supports 3.0V */
1738 if (host->pdata->controller_flags & OMAP_HSMMC_SUPPORTS_DUAL_VOLT) {
1746 value = OMAP_HSMMC_READ(host->base, HCTL) & ~SDVS_MASK;
1747 OMAP_HSMMC_WRITE(host->base, HCTL, value | hctl);
1749 value = OMAP_HSMMC_READ(host->base, CAPA);
1750 OMAP_HSMMC_WRITE(host->base, CAPA, value | capa);
1752 /* Set SD bus power bit */
1753 set_sd_bus_power(host);
1756 static int omap_hsmmc_enable_fclk(struct mmc_host *mmc)
1758 struct omap_hsmmc_host *host = mmc_priv(mmc);
1760 pm_runtime_get_sync(host->dev);
1765 static int omap_hsmmc_disable_fclk(struct mmc_host *mmc)
1767 struct omap_hsmmc_host *host = mmc_priv(mmc);
1769 pm_runtime_mark_last_busy(host->dev);
1770 pm_runtime_put_autosuspend(host->dev);
1775 static int omap_hsmmc_multi_io_quirk(struct mmc_card *card,
1776 unsigned int direction, int blk_size)
1778 /* This controller can't do multiblock reads due to hw bugs */
1779 if (direction == MMC_DATA_READ)
1785 static struct mmc_host_ops omap_hsmmc_ops = {
1786 .enable = omap_hsmmc_enable_fclk,
1787 .disable = omap_hsmmc_disable_fclk,
1788 .post_req = omap_hsmmc_post_req,
1789 .pre_req = omap_hsmmc_pre_req,
1790 .request = omap_hsmmc_request,
1791 .set_ios = omap_hsmmc_set_ios,
1792 .get_cd = omap_hsmmc_get_cd,
1793 .get_ro = mmc_gpio_get_ro,
1794 .init_card = omap_hsmmc_init_card,
1795 .enable_sdio_irq = omap_hsmmc_enable_sdio_irq,
1798 #ifdef CONFIG_DEBUG_FS
1800 static int omap_hsmmc_regs_show(struct seq_file *s, void *data)
1802 struct mmc_host *mmc = s->private;
1803 struct omap_hsmmc_host *host = mmc_priv(mmc);
1805 seq_printf(s, "mmc%d:\n", mmc->index);
1806 seq_printf(s, "sdio irq mode\t%s\n",
1807 (mmc->caps & MMC_CAP_SDIO_IRQ) ? "interrupt" : "polling");
1809 if (mmc->caps & MMC_CAP_SDIO_IRQ) {
1810 seq_printf(s, "sdio irq \t%s\n",
1811 (host->flags & HSMMC_SDIO_IRQ_ENABLED) ? "enabled"
1814 seq_printf(s, "ctx_loss:\t%d\n", host->context_loss);
1816 pm_runtime_get_sync(host->dev);
1817 seq_puts(s, "\nregs:\n");
1818 seq_printf(s, "CON:\t\t0x%08x\n",
1819 OMAP_HSMMC_READ(host->base, CON));
1820 seq_printf(s, "PSTATE:\t\t0x%08x\n",
1821 OMAP_HSMMC_READ(host->base, PSTATE));
1822 seq_printf(s, "HCTL:\t\t0x%08x\n",
1823 OMAP_HSMMC_READ(host->base, HCTL));
1824 seq_printf(s, "SYSCTL:\t\t0x%08x\n",
1825 OMAP_HSMMC_READ(host->base, SYSCTL));
1826 seq_printf(s, "IE:\t\t0x%08x\n",
1827 OMAP_HSMMC_READ(host->base, IE));
1828 seq_printf(s, "ISE:\t\t0x%08x\n",
1829 OMAP_HSMMC_READ(host->base, ISE));
1830 seq_printf(s, "CAPA:\t\t0x%08x\n",
1831 OMAP_HSMMC_READ(host->base, CAPA));
1833 pm_runtime_mark_last_busy(host->dev);
1834 pm_runtime_put_autosuspend(host->dev);
1839 static int omap_hsmmc_regs_open(struct inode *inode, struct file *file)
1841 return single_open(file, omap_hsmmc_regs_show, inode->i_private);
1844 static const struct file_operations mmc_regs_fops = {
1845 .open = omap_hsmmc_regs_open,
1847 .llseek = seq_lseek,
1848 .release = single_release,
1851 static void omap_hsmmc_debugfs(struct mmc_host *mmc)
1853 if (mmc->debugfs_root)
1854 debugfs_create_file("regs", S_IRUSR, mmc->debugfs_root,
1855 mmc, &mmc_regs_fops);
1860 static void omap_hsmmc_debugfs(struct mmc_host *mmc)
1867 static const struct omap_mmc_of_data omap3_pre_es3_mmc_of_data = {
1868 /* See 35xx errata 2.1.1.128 in SPRZ278F */
1869 .controller_flags = OMAP_HSMMC_BROKEN_MULTIBLOCK_READ,
1872 static const struct omap_mmc_of_data omap4_mmc_of_data = {
1873 .reg_offset = 0x100,
1875 static const struct omap_mmc_of_data am33xx_mmc_of_data = {
1876 .reg_offset = 0x100,
1877 .controller_flags = OMAP_HSMMC_SWAKEUP_MISSING,
1880 static const struct of_device_id omap_mmc_of_match[] = {
1882 .compatible = "ti,omap2-hsmmc",
1885 .compatible = "ti,omap3-pre-es3-hsmmc",
1886 .data = &omap3_pre_es3_mmc_of_data,
1889 .compatible = "ti,omap3-hsmmc",
1892 .compatible = "ti,omap4-hsmmc",
1893 .data = &omap4_mmc_of_data,
1896 .compatible = "ti,am33xx-hsmmc",
1897 .data = &am33xx_mmc_of_data,
1901 MODULE_DEVICE_TABLE(of, omap_mmc_of_match);
1903 static struct omap_hsmmc_platform_data *of_get_hsmmc_pdata(struct device *dev)
1905 struct omap_hsmmc_platform_data *pdata;
1906 struct device_node *np = dev->of_node;
1908 pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
1910 return ERR_PTR(-ENOMEM); /* out of memory */
1912 if (of_find_property(np, "ti,dual-volt", NULL))
1913 pdata->controller_flags |= OMAP_HSMMC_SUPPORTS_DUAL_VOLT;
1915 pdata->switch_pin = -EINVAL;
1916 pdata->gpio_wp = -EINVAL;
1918 if (of_find_property(np, "ti,non-removable", NULL)) {
1919 pdata->nonremovable = true;
1920 pdata->no_regulator_off_init = true;
1923 if (of_find_property(np, "ti,needs-special-reset", NULL))
1924 pdata->features |= HSMMC_HAS_UPDATED_RESET;
1926 if (of_find_property(np, "ti,needs-special-hs-handling", NULL))
1927 pdata->features |= HSMMC_HAS_HSPE_SUPPORT;
1932 static inline struct omap_hsmmc_platform_data
1933 *of_get_hsmmc_pdata(struct device *dev)
1935 return ERR_PTR(-EINVAL);
1939 static int omap_hsmmc_probe(struct platform_device *pdev)
1941 struct omap_hsmmc_platform_data *pdata = pdev->dev.platform_data;
1942 struct mmc_host *mmc;
1943 struct omap_hsmmc_host *host = NULL;
1944 struct resource *res;
1946 const struct of_device_id *match;
1947 dma_cap_mask_t mask;
1948 unsigned tx_req, rx_req;
1949 const struct omap_mmc_of_data *data;
1952 match = of_match_device(of_match_ptr(omap_mmc_of_match), &pdev->dev);
1954 pdata = of_get_hsmmc_pdata(&pdev->dev);
1957 return PTR_ERR(pdata);
1961 pdata->reg_offset = data->reg_offset;
1962 pdata->controller_flags |= data->controller_flags;
1966 if (pdata == NULL) {
1967 dev_err(&pdev->dev, "Platform Data is missing\n");
1971 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1972 irq = platform_get_irq(pdev, 0);
1973 if (res == NULL || irq < 0)
1976 base = devm_ioremap_resource(&pdev->dev, res);
1978 return PTR_ERR(base);
1980 mmc = mmc_alloc_host(sizeof(struct omap_hsmmc_host), &pdev->dev);
1986 ret = mmc_of_parse(mmc);
1990 host = mmc_priv(mmc);
1992 host->pdata = pdata;
1993 host->dev = &pdev->dev;
1997 host->mapbase = res->start + pdata->reg_offset;
1998 host->base = base + pdata->reg_offset;
1999 host->power_mode = MMC_POWER_OFF;
2000 host->next_data.cookie = 1;
2001 host->pbias_enabled = 0;
2003 ret = omap_hsmmc_gpio_init(mmc, host, pdata);
2007 platform_set_drvdata(pdev, host);
2009 if (pdev->dev.of_node)
2010 host->wake_irq = irq_of_parse_and_map(pdev->dev.of_node, 1);
2012 mmc->ops = &omap_hsmmc_ops;
2014 mmc->f_min = OMAP_MMC_MIN_CLOCK;
2016 if (pdata->max_freq > 0)
2017 mmc->f_max = pdata->max_freq;
2018 else if (mmc->f_max == 0)
2019 mmc->f_max = OMAP_MMC_MAX_CLOCK;
2021 spin_lock_init(&host->irq_lock);
2023 host->fclk = devm_clk_get(&pdev->dev, "fck");
2024 if (IS_ERR(host->fclk)) {
2025 ret = PTR_ERR(host->fclk);
2030 if (host->pdata->controller_flags & OMAP_HSMMC_BROKEN_MULTIBLOCK_READ) {
2031 dev_info(&pdev->dev, "multiblock reads disabled due to 35xx erratum 2.1.1.128; MMC read performance may suffer\n");
2032 omap_hsmmc_ops.multi_io_quirk = omap_hsmmc_multi_io_quirk;
2035 pm_runtime_enable(host->dev);
2036 pm_runtime_get_sync(host->dev);
2037 pm_runtime_set_autosuspend_delay(host->dev, MMC_AUTOSUSPEND_DELAY);
2038 pm_runtime_use_autosuspend(host->dev);
2040 omap_hsmmc_context_save(host);
2042 host->dbclk = devm_clk_get(&pdev->dev, "mmchsdb_fck");
2044 * MMC can still work without debounce clock.
2046 if (IS_ERR(host->dbclk)) {
2048 } else if (clk_prepare_enable(host->dbclk) != 0) {
2049 dev_warn(mmc_dev(host->mmc), "Failed to enable debounce clk\n");
2053 /* Since we do only SG emulation, we can have as many segs
2055 mmc->max_segs = 1024;
2057 mmc->max_blk_size = 512; /* Block Length at max can be 1024 */
2058 mmc->max_blk_count = 0xFFFF; /* No. of Blocks is 16 bits */
2059 mmc->max_req_size = mmc->max_blk_size * mmc->max_blk_count;
2060 mmc->max_seg_size = mmc->max_req_size;
2062 mmc->caps |= MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED |
2063 MMC_CAP_WAIT_WHILE_BUSY | MMC_CAP_ERASE;
2065 mmc->caps |= mmc_pdata(host)->caps;
2066 if (mmc->caps & MMC_CAP_8_BIT_DATA)
2067 mmc->caps |= MMC_CAP_4_BIT_DATA;
2069 if (mmc_pdata(host)->nonremovable)
2070 mmc->caps |= MMC_CAP_NONREMOVABLE;
2072 mmc->pm_caps |= mmc_pdata(host)->pm_caps;
2074 omap_hsmmc_conf_bus_power(host);
2076 if (!pdev->dev.of_node) {
2077 res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "tx");
2079 dev_err(mmc_dev(host->mmc), "cannot get DMA TX channel\n");
2083 tx_req = res->start;
2085 res = platform_get_resource_byname(pdev, IORESOURCE_DMA, "rx");
2087 dev_err(mmc_dev(host->mmc), "cannot get DMA RX channel\n");
2091 rx_req = res->start;
2095 dma_cap_set(DMA_SLAVE, mask);
2098 dma_request_slave_channel_compat(mask, omap_dma_filter_fn,
2099 &rx_req, &pdev->dev, "rx");
2101 if (!host->rx_chan) {
2102 dev_err(mmc_dev(host->mmc), "unable to obtain RX DMA engine channel %u\n", rx_req);
2108 dma_request_slave_channel_compat(mask, omap_dma_filter_fn,
2109 &tx_req, &pdev->dev, "tx");
2111 if (!host->tx_chan) {
2112 dev_err(mmc_dev(host->mmc), "unable to obtain TX DMA engine channel %u\n", tx_req);
2117 /* Request IRQ for MMC operations */
2118 ret = devm_request_irq(&pdev->dev, host->irq, omap_hsmmc_irq, 0,
2119 mmc_hostname(mmc), host);
2121 dev_err(mmc_dev(host->mmc), "Unable to grab HSMMC IRQ\n");
2125 if (omap_hsmmc_have_reg() && !mmc_pdata(host)->set_power) {
2126 ret = omap_hsmmc_reg_get(host);
2132 mmc->ocr_avail = mmc_pdata(host)->ocr_mask;
2134 omap_hsmmc_disable_irq(host);
2137 * For now, only support SDIO interrupt if we have a separate
2138 * wake-up interrupt configured from device tree. This is because
2139 * the wake-up interrupt is needed for idle state and some
2140 * platforms need special quirks. And we don't want to add new
2141 * legacy mux platform init code callbacks any longer as we
2142 * are moving to DT based booting anyways.
2144 ret = omap_hsmmc_configure_wake_irq(host);
2146 mmc->caps |= MMC_CAP_SDIO_IRQ;
2148 omap_hsmmc_protect_card(host);
2152 if (mmc_pdata(host)->name != NULL) {
2153 ret = device_create_file(&mmc->class_dev, &dev_attr_slot_name);
2157 if (host->card_detect_irq && host->get_cover_state) {
2158 ret = device_create_file(&mmc->class_dev,
2159 &dev_attr_cover_switch);
2164 omap_hsmmc_debugfs(mmc);
2165 pm_runtime_mark_last_busy(host->dev);
2166 pm_runtime_put_autosuspend(host->dev);
2171 mmc_remove_host(mmc);
2173 omap_hsmmc_reg_put(host);
2176 dma_release_channel(host->tx_chan);
2178 dma_release_channel(host->rx_chan);
2179 pm_runtime_put_sync(host->dev);
2180 pm_runtime_disable(host->dev);
2182 clk_disable_unprepare(host->dbclk);
2190 static int omap_hsmmc_remove(struct platform_device *pdev)
2192 struct omap_hsmmc_host *host = platform_get_drvdata(pdev);
2194 pm_runtime_get_sync(host->dev);
2195 mmc_remove_host(host->mmc);
2197 omap_hsmmc_reg_put(host);
2200 dma_release_channel(host->tx_chan);
2202 dma_release_channel(host->rx_chan);
2204 pm_runtime_put_sync(host->dev);
2205 pm_runtime_disable(host->dev);
2207 clk_disable_unprepare(host->dbclk);
2209 mmc_free_host(host->mmc);
2215 static int omap_hsmmc_suspend(struct device *dev)
2217 struct omap_hsmmc_host *host = dev_get_drvdata(dev);
2222 pm_runtime_get_sync(host->dev);
2224 if (!(host->mmc->pm_flags & MMC_PM_KEEP_POWER)) {
2225 OMAP_HSMMC_WRITE(host->base, ISE, 0);
2226 OMAP_HSMMC_WRITE(host->base, IE, 0);
2227 OMAP_HSMMC_WRITE(host->base, STAT, STAT_CLEAR);
2228 OMAP_HSMMC_WRITE(host->base, HCTL,
2229 OMAP_HSMMC_READ(host->base, HCTL) & ~SDBP);
2232 /* do not wake up due to sdio irq */
2233 if ((host->mmc->caps & MMC_CAP_SDIO_IRQ) &&
2234 !(host->mmc->pm_flags & MMC_PM_WAKE_SDIO_IRQ))
2235 disable_irq(host->wake_irq);
2238 clk_disable_unprepare(host->dbclk);
2240 pm_runtime_put_sync(host->dev);
2244 /* Routine to resume the MMC device */
2245 static int omap_hsmmc_resume(struct device *dev)
2247 struct omap_hsmmc_host *host = dev_get_drvdata(dev);
2252 pm_runtime_get_sync(host->dev);
2255 clk_prepare_enable(host->dbclk);
2257 if (!(host->mmc->pm_flags & MMC_PM_KEEP_POWER))
2258 omap_hsmmc_conf_bus_power(host);
2260 omap_hsmmc_protect_card(host);
2262 if ((host->mmc->caps & MMC_CAP_SDIO_IRQ) &&
2263 !(host->mmc->pm_flags & MMC_PM_WAKE_SDIO_IRQ))
2264 enable_irq(host->wake_irq);
2266 pm_runtime_mark_last_busy(host->dev);
2267 pm_runtime_put_autosuspend(host->dev);
2272 #define omap_hsmmc_suspend NULL
2273 #define omap_hsmmc_resume NULL
2276 static int omap_hsmmc_runtime_suspend(struct device *dev)
2278 struct omap_hsmmc_host *host;
2279 unsigned long flags;
2282 host = platform_get_drvdata(to_platform_device(dev));
2283 omap_hsmmc_context_save(host);
2284 dev_dbg(dev, "disabled\n");
2286 spin_lock_irqsave(&host->irq_lock, flags);
2287 if ((host->mmc->caps & MMC_CAP_SDIO_IRQ) &&
2288 (host->flags & HSMMC_SDIO_IRQ_ENABLED)) {
2289 /* disable sdio irq handling to prevent race */
2290 OMAP_HSMMC_WRITE(host->base, ISE, 0);
2291 OMAP_HSMMC_WRITE(host->base, IE, 0);
2293 if (!(OMAP_HSMMC_READ(host->base, PSTATE) & DLEV_DAT(1))) {
2295 * dat1 line low, pending sdio irq
2296 * race condition: possible irq handler running on
2299 dev_dbg(dev, "pending sdio irq, abort suspend\n");
2300 OMAP_HSMMC_WRITE(host->base, STAT, STAT_CLEAR);
2301 OMAP_HSMMC_WRITE(host->base, ISE, CIRQ_EN);
2302 OMAP_HSMMC_WRITE(host->base, IE, CIRQ_EN);
2303 pm_runtime_mark_last_busy(dev);
2308 pinctrl_pm_select_idle_state(dev);
2310 WARN_ON(host->flags & HSMMC_WAKE_IRQ_ENABLED);
2311 enable_irq(host->wake_irq);
2312 host->flags |= HSMMC_WAKE_IRQ_ENABLED;
2314 pinctrl_pm_select_idle_state(dev);
2318 spin_unlock_irqrestore(&host->irq_lock, flags);
2322 static int omap_hsmmc_runtime_resume(struct device *dev)
2324 struct omap_hsmmc_host *host;
2325 unsigned long flags;
2327 host = platform_get_drvdata(to_platform_device(dev));
2328 omap_hsmmc_context_restore(host);
2329 dev_dbg(dev, "enabled\n");
2331 spin_lock_irqsave(&host->irq_lock, flags);
2332 if ((host->mmc->caps & MMC_CAP_SDIO_IRQ) &&
2333 (host->flags & HSMMC_SDIO_IRQ_ENABLED)) {
2334 /* sdio irq flag can't change while in runtime suspend */
2335 if (host->flags & HSMMC_WAKE_IRQ_ENABLED) {
2336 disable_irq_nosync(host->wake_irq);
2337 host->flags &= ~HSMMC_WAKE_IRQ_ENABLED;
2340 pinctrl_pm_select_default_state(host->dev);
2342 /* irq lost, if pinmux incorrect */
2343 OMAP_HSMMC_WRITE(host->base, STAT, STAT_CLEAR);
2344 OMAP_HSMMC_WRITE(host->base, ISE, CIRQ_EN);
2345 OMAP_HSMMC_WRITE(host->base, IE, CIRQ_EN);
2347 pinctrl_pm_select_default_state(host->dev);
2349 spin_unlock_irqrestore(&host->irq_lock, flags);
2353 static struct dev_pm_ops omap_hsmmc_dev_pm_ops = {
2354 .suspend = omap_hsmmc_suspend,
2355 .resume = omap_hsmmc_resume,
2356 .runtime_suspend = omap_hsmmc_runtime_suspend,
2357 .runtime_resume = omap_hsmmc_runtime_resume,
2360 static struct platform_driver omap_hsmmc_driver = {
2361 .probe = omap_hsmmc_probe,
2362 .remove = omap_hsmmc_remove,
2364 .name = DRIVER_NAME,
2365 .pm = &omap_hsmmc_dev_pm_ops,
2366 .of_match_table = of_match_ptr(omap_mmc_of_match),
2370 module_platform_driver(omap_hsmmc_driver);
2371 MODULE_DESCRIPTION("OMAP High Speed Multimedia Card driver");
2372 MODULE_LICENSE("GPL");
2373 MODULE_ALIAS("platform:" DRIVER_NAME);
2374 MODULE_AUTHOR("Texas Instruments Inc");