2 * linux/drivers/mmc/host/mmci.c - ARM PrimeCell MMCI PL180/1 driver
4 * Copyright (C) 2003 Deep Blue Solutions, Ltd, All Rights Reserved.
5 * Copyright (C) 2010 ST-Ericsson SA
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
11 #include <linux/module.h>
12 #include <linux/moduleparam.h>
13 #include <linux/init.h>
14 #include <linux/ioport.h>
15 #include <linux/device.h>
17 #include <linux/interrupt.h>
18 #include <linux/kernel.h>
19 #include <linux/slab.h>
20 #include <linux/delay.h>
21 #include <linux/err.h>
22 #include <linux/highmem.h>
23 #include <linux/log2.h>
24 #include <linux/mmc/pm.h>
25 #include <linux/mmc/host.h>
26 #include <linux/mmc/card.h>
27 #include <linux/mmc/slot-gpio.h>
28 #include <linux/amba/bus.h>
29 #include <linux/clk.h>
30 #include <linux/scatterlist.h>
32 #include <linux/regulator/consumer.h>
33 #include <linux/dmaengine.h>
34 #include <linux/dma-mapping.h>
35 #include <linux/amba/mmci.h>
36 #include <linux/pm_runtime.h>
37 #include <linux/types.h>
38 #include <linux/pinctrl/consumer.h>
39 #include <linux/reset.h>
41 #include <asm/div64.h>
45 #include "mmci_qcom_dml.h"
47 #define DRIVER_NAME "mmci-pl18x"
49 #ifdef CONFIG_DMA_ENGINE
50 void mmci_variant_init(struct mmci_host
*host
);
52 static inline void mmci_variant_init(struct mmci_host
*host
) {}
55 #ifdef CONFIG_MMC_STM32_SDMMC
56 void sdmmc_variant_init(struct mmci_host
*host
);
58 static inline void sdmmc_variant_init(struct mmci_host
*host
) {}
61 static unsigned int fmax
= 515633;
63 static struct variant_data variant_arm
= {
65 .fifohalfsize
= 8 * 4,
66 .cmdreg_cpsm_enable
= MCI_CPSM_ENABLE
,
67 .cmdreg_lrsp_crc
= MCI_CPSM_RESPONSE
| MCI_CPSM_LONGRSP
,
68 .cmdreg_srsp_crc
= MCI_CPSM_RESPONSE
,
69 .cmdreg_srsp
= MCI_CPSM_RESPONSE
,
70 .datalength_bits
= 16,
71 .datactrl_blocksz
= 11,
72 .datactrl_dpsm_enable
= MCI_DPSM_ENABLE
,
73 .pwrreg_powerup
= MCI_PWR_UP
,
75 .reversed_irq_handling
= true,
77 .irq_pio_mask
= MCI_IRQ_PIO_MASK
,
78 .start_err
= MCI_STARTBITERR
,
80 .init
= mmci_variant_init
,
83 static struct variant_data variant_arm_extended_fifo
= {
85 .fifohalfsize
= 64 * 4,
86 .cmdreg_cpsm_enable
= MCI_CPSM_ENABLE
,
87 .cmdreg_lrsp_crc
= MCI_CPSM_RESPONSE
| MCI_CPSM_LONGRSP
,
88 .cmdreg_srsp_crc
= MCI_CPSM_RESPONSE
,
89 .cmdreg_srsp
= MCI_CPSM_RESPONSE
,
90 .datalength_bits
= 16,
91 .datactrl_blocksz
= 11,
92 .datactrl_dpsm_enable
= MCI_DPSM_ENABLE
,
93 .pwrreg_powerup
= MCI_PWR_UP
,
96 .irq_pio_mask
= MCI_IRQ_PIO_MASK
,
97 .start_err
= MCI_STARTBITERR
,
99 .init
= mmci_variant_init
,
102 static struct variant_data variant_arm_extended_fifo_hwfc
= {
104 .fifohalfsize
= 64 * 4,
105 .clkreg_enable
= MCI_ARM_HWFCEN
,
106 .cmdreg_cpsm_enable
= MCI_CPSM_ENABLE
,
107 .cmdreg_lrsp_crc
= MCI_CPSM_RESPONSE
| MCI_CPSM_LONGRSP
,
108 .cmdreg_srsp_crc
= MCI_CPSM_RESPONSE
,
109 .cmdreg_srsp
= MCI_CPSM_RESPONSE
,
110 .datalength_bits
= 16,
111 .datactrl_blocksz
= 11,
112 .datactrl_dpsm_enable
= MCI_DPSM_ENABLE
,
113 .pwrreg_powerup
= MCI_PWR_UP
,
116 .irq_pio_mask
= MCI_IRQ_PIO_MASK
,
117 .start_err
= MCI_STARTBITERR
,
118 .opendrain
= MCI_ROD
,
119 .init
= mmci_variant_init
,
122 static struct variant_data variant_u300
= {
124 .fifohalfsize
= 8 * 4,
125 .clkreg_enable
= MCI_ST_U300_HWFCEN
,
126 .clkreg_8bit_bus_enable
= MCI_ST_8BIT_BUS
,
127 .cmdreg_cpsm_enable
= MCI_CPSM_ENABLE
,
128 .cmdreg_lrsp_crc
= MCI_CPSM_RESPONSE
| MCI_CPSM_LONGRSP
,
129 .cmdreg_srsp_crc
= MCI_CPSM_RESPONSE
,
130 .cmdreg_srsp
= MCI_CPSM_RESPONSE
,
131 .datalength_bits
= 16,
132 .datactrl_blocksz
= 11,
133 .datactrl_dpsm_enable
= MCI_DPSM_ENABLE
,
134 .datactrl_mask_sdio
= MCI_DPSM_ST_SDIOEN
,
136 .pwrreg_powerup
= MCI_PWR_ON
,
138 .signal_direction
= true,
139 .pwrreg_clkgate
= true,
140 .pwrreg_nopower
= true,
142 .irq_pio_mask
= MCI_IRQ_PIO_MASK
,
143 .start_err
= MCI_STARTBITERR
,
145 .init
= mmci_variant_init
,
148 static struct variant_data variant_nomadik
= {
150 .fifohalfsize
= 8 * 4,
151 .clkreg
= MCI_CLK_ENABLE
,
152 .clkreg_8bit_bus_enable
= MCI_ST_8BIT_BUS
,
153 .cmdreg_cpsm_enable
= MCI_CPSM_ENABLE
,
154 .cmdreg_lrsp_crc
= MCI_CPSM_RESPONSE
| MCI_CPSM_LONGRSP
,
155 .cmdreg_srsp_crc
= MCI_CPSM_RESPONSE
,
156 .cmdreg_srsp
= MCI_CPSM_RESPONSE
,
157 .datalength_bits
= 24,
158 .datactrl_blocksz
= 11,
159 .datactrl_dpsm_enable
= MCI_DPSM_ENABLE
,
160 .datactrl_mask_sdio
= MCI_DPSM_ST_SDIOEN
,
163 .pwrreg_powerup
= MCI_PWR_ON
,
165 .signal_direction
= true,
166 .pwrreg_clkgate
= true,
167 .pwrreg_nopower
= true,
169 .irq_pio_mask
= MCI_IRQ_PIO_MASK
,
170 .start_err
= MCI_STARTBITERR
,
172 .init
= mmci_variant_init
,
175 static struct variant_data variant_ux500
= {
177 .fifohalfsize
= 8 * 4,
178 .clkreg
= MCI_CLK_ENABLE
,
179 .clkreg_enable
= MCI_ST_UX500_HWFCEN
,
180 .clkreg_8bit_bus_enable
= MCI_ST_8BIT_BUS
,
181 .clkreg_neg_edge_enable
= MCI_ST_UX500_NEG_EDGE
,
182 .cmdreg_cpsm_enable
= MCI_CPSM_ENABLE
,
183 .cmdreg_lrsp_crc
= MCI_CPSM_RESPONSE
| MCI_CPSM_LONGRSP
,
184 .cmdreg_srsp_crc
= MCI_CPSM_RESPONSE
,
185 .cmdreg_srsp
= MCI_CPSM_RESPONSE
,
186 .datalength_bits
= 24,
187 .datactrl_blocksz
= 11,
188 .datactrl_dpsm_enable
= MCI_DPSM_ENABLE
,
189 .datactrl_mask_sdio
= MCI_DPSM_ST_SDIOEN
,
192 .pwrreg_powerup
= MCI_PWR_ON
,
194 .signal_direction
= true,
195 .pwrreg_clkgate
= true,
197 .busy_dpsm_flag
= MCI_DPSM_ST_BUSYMODE
,
198 .busy_detect_flag
= MCI_ST_CARDBUSY
,
199 .busy_detect_mask
= MCI_ST_BUSYENDMASK
,
200 .pwrreg_nopower
= true,
202 .irq_pio_mask
= MCI_IRQ_PIO_MASK
,
203 .start_err
= MCI_STARTBITERR
,
205 .init
= mmci_variant_init
,
208 static struct variant_data variant_ux500v2
= {
210 .fifohalfsize
= 8 * 4,
211 .clkreg
= MCI_CLK_ENABLE
,
212 .clkreg_enable
= MCI_ST_UX500_HWFCEN
,
213 .clkreg_8bit_bus_enable
= MCI_ST_8BIT_BUS
,
214 .clkreg_neg_edge_enable
= MCI_ST_UX500_NEG_EDGE
,
215 .cmdreg_cpsm_enable
= MCI_CPSM_ENABLE
,
216 .cmdreg_lrsp_crc
= MCI_CPSM_RESPONSE
| MCI_CPSM_LONGRSP
,
217 .cmdreg_srsp_crc
= MCI_CPSM_RESPONSE
,
218 .cmdreg_srsp
= MCI_CPSM_RESPONSE
,
219 .datactrl_mask_ddrmode
= MCI_DPSM_ST_DDRMODE
,
220 .datalength_bits
= 24,
221 .datactrl_blocksz
= 11,
222 .datactrl_dpsm_enable
= MCI_DPSM_ENABLE
,
223 .datactrl_mask_sdio
= MCI_DPSM_ST_SDIOEN
,
226 .blksz_datactrl16
= true,
227 .pwrreg_powerup
= MCI_PWR_ON
,
229 .signal_direction
= true,
230 .pwrreg_clkgate
= true,
232 .busy_dpsm_flag
= MCI_DPSM_ST_BUSYMODE
,
233 .busy_detect_flag
= MCI_ST_CARDBUSY
,
234 .busy_detect_mask
= MCI_ST_BUSYENDMASK
,
235 .pwrreg_nopower
= true,
237 .irq_pio_mask
= MCI_IRQ_PIO_MASK
,
238 .start_err
= MCI_STARTBITERR
,
240 .init
= mmci_variant_init
,
243 static struct variant_data variant_stm32
= {
245 .fifohalfsize
= 8 * 4,
246 .clkreg
= MCI_CLK_ENABLE
,
247 .clkreg_enable
= MCI_ST_UX500_HWFCEN
,
248 .clkreg_8bit_bus_enable
= MCI_ST_8BIT_BUS
,
249 .clkreg_neg_edge_enable
= MCI_ST_UX500_NEG_EDGE
,
250 .cmdreg_cpsm_enable
= MCI_CPSM_ENABLE
,
251 .cmdreg_lrsp_crc
= MCI_CPSM_RESPONSE
| MCI_CPSM_LONGRSP
,
252 .cmdreg_srsp_crc
= MCI_CPSM_RESPONSE
,
253 .cmdreg_srsp
= MCI_CPSM_RESPONSE
,
254 .irq_pio_mask
= MCI_IRQ_PIO_MASK
,
255 .datalength_bits
= 24,
256 .datactrl_blocksz
= 11,
257 .datactrl_dpsm_enable
= MCI_DPSM_ENABLE
,
258 .datactrl_mask_sdio
= MCI_DPSM_ST_SDIOEN
,
261 .pwrreg_powerup
= MCI_PWR_ON
,
263 .pwrreg_clkgate
= true,
264 .pwrreg_nopower
= true,
265 .init
= mmci_variant_init
,
268 static struct variant_data variant_stm32_sdmmc
= {
270 .fifohalfsize
= 8 * 4,
272 .stm32_clkdiv
= true,
273 .cmdreg_cpsm_enable
= MCI_CPSM_STM32_ENABLE
,
274 .cmdreg_lrsp_crc
= MCI_CPSM_STM32_LRSP_CRC
,
275 .cmdreg_srsp_crc
= MCI_CPSM_STM32_SRSP_CRC
,
276 .cmdreg_srsp
= MCI_CPSM_STM32_SRSP
,
277 .data_cmd_enable
= MCI_CPSM_STM32_CMDTRANS
,
278 .irq_pio_mask
= MCI_IRQ_PIO_STM32_MASK
,
279 .datactrl_first
= true,
280 .datacnt_useless
= true,
281 .datalength_bits
= 25,
282 .datactrl_blocksz
= 14,
283 .stm32_idmabsize_mask
= GENMASK(12, 5),
284 .init
= sdmmc_variant_init
,
287 static struct variant_data variant_qcom
= {
289 .fifohalfsize
= 8 * 4,
290 .clkreg
= MCI_CLK_ENABLE
,
291 .clkreg_enable
= MCI_QCOM_CLK_FLOWENA
|
292 MCI_QCOM_CLK_SELECT_IN_FBCLK
,
293 .clkreg_8bit_bus_enable
= MCI_QCOM_CLK_WIDEBUS_8
,
294 .datactrl_mask_ddrmode
= MCI_QCOM_CLK_SELECT_IN_DDR_MODE
,
295 .cmdreg_cpsm_enable
= MCI_CPSM_ENABLE
,
296 .cmdreg_lrsp_crc
= MCI_CPSM_RESPONSE
| MCI_CPSM_LONGRSP
,
297 .cmdreg_srsp_crc
= MCI_CPSM_RESPONSE
,
298 .cmdreg_srsp
= MCI_CPSM_RESPONSE
,
299 .data_cmd_enable
= MCI_CPSM_QCOM_DATCMD
,
300 .blksz_datactrl4
= true,
301 .datalength_bits
= 24,
302 .datactrl_blocksz
= 11,
303 .datactrl_dpsm_enable
= MCI_DPSM_ENABLE
,
304 .pwrreg_powerup
= MCI_PWR_UP
,
306 .explicit_mclk_control
= true,
310 .irq_pio_mask
= MCI_IRQ_PIO_MASK
,
311 .start_err
= MCI_STARTBITERR
,
312 .opendrain
= MCI_ROD
,
313 .init
= qcom_variant_init
,
316 /* Busy detection for the ST Micro variant */
317 static int mmci_card_busy(struct mmc_host
*mmc
)
319 struct mmci_host
*host
= mmc_priv(mmc
);
323 spin_lock_irqsave(&host
->lock
, flags
);
324 if (readl(host
->base
+ MMCISTATUS
) & host
->variant
->busy_detect_flag
)
326 spin_unlock_irqrestore(&host
->lock
, flags
);
331 static void mmci_reg_delay(struct mmci_host
*host
)
334 * According to the spec, at least three feedback clock cycles
335 * of max 52 MHz must pass between two writes to the MMCICLOCK reg.
336 * Three MCLK clock cycles must pass between two MMCIPOWER reg writes.
337 * Worst delay time during card init is at 100 kHz => 30 us.
338 * Worst delay time when up and running is at 25 MHz => 120 ns.
340 if (host
->cclk
< 25000000)
347 * This must be called with host->lock held
349 void mmci_write_clkreg(struct mmci_host
*host
, u32 clk
)
351 if (host
->clk_reg
!= clk
) {
353 writel(clk
, host
->base
+ MMCICLOCK
);
358 * This must be called with host->lock held
360 void mmci_write_pwrreg(struct mmci_host
*host
, u32 pwr
)
362 if (host
->pwr_reg
!= pwr
) {
364 writel(pwr
, host
->base
+ MMCIPOWER
);
369 * This must be called with host->lock held
371 static void mmci_write_datactrlreg(struct mmci_host
*host
, u32 datactrl
)
373 /* Keep busy mode in DPSM if enabled */
374 datactrl
|= host
->datactrl_reg
& host
->variant
->busy_dpsm_flag
;
376 if (host
->datactrl_reg
!= datactrl
) {
377 host
->datactrl_reg
= datactrl
;
378 writel(datactrl
, host
->base
+ MMCIDATACTRL
);
383 * This must be called with host->lock held
385 static void mmci_set_clkreg(struct mmci_host
*host
, unsigned int desired
)
387 struct variant_data
*variant
= host
->variant
;
388 u32 clk
= variant
->clkreg
;
390 /* Make sure cclk reflects the current calculated clock */
394 if (variant
->explicit_mclk_control
) {
395 host
->cclk
= host
->mclk
;
396 } else if (desired
>= host
->mclk
) {
397 clk
= MCI_CLK_BYPASS
;
398 if (variant
->st_clkdiv
)
399 clk
|= MCI_ST_UX500_NEG_EDGE
;
400 host
->cclk
= host
->mclk
;
401 } else if (variant
->st_clkdiv
) {
403 * DB8500 TRM says f = mclk / (clkdiv + 2)
404 * => clkdiv = (mclk / f) - 2
405 * Round the divider up so we don't exceed the max
408 clk
= DIV_ROUND_UP(host
->mclk
, desired
) - 2;
411 host
->cclk
= host
->mclk
/ (clk
+ 2);
414 * PL180 TRM says f = mclk / (2 * (clkdiv + 1))
415 * => clkdiv = mclk / (2 * f) - 1
417 clk
= host
->mclk
/ (2 * desired
) - 1;
420 host
->cclk
= host
->mclk
/ (2 * (clk
+ 1));
423 clk
|= variant
->clkreg_enable
;
424 clk
|= MCI_CLK_ENABLE
;
425 /* This hasn't proven to be worthwhile */
426 /* clk |= MCI_CLK_PWRSAVE; */
429 /* Set actual clock for debug */
430 host
->mmc
->actual_clock
= host
->cclk
;
432 if (host
->mmc
->ios
.bus_width
== MMC_BUS_WIDTH_4
)
434 if (host
->mmc
->ios
.bus_width
== MMC_BUS_WIDTH_8
)
435 clk
|= variant
->clkreg_8bit_bus_enable
;
437 if (host
->mmc
->ios
.timing
== MMC_TIMING_UHS_DDR50
||
438 host
->mmc
->ios
.timing
== MMC_TIMING_MMC_DDR52
)
439 clk
|= variant
->clkreg_neg_edge_enable
;
441 mmci_write_clkreg(host
, clk
);
444 void mmci_dma_release(struct mmci_host
*host
)
446 if (host
->ops
&& host
->ops
->dma_release
)
447 host
->ops
->dma_release(host
);
449 host
->use_dma
= false;
452 void mmci_dma_setup(struct mmci_host
*host
)
454 if (!host
->ops
|| !host
->ops
->dma_setup
)
457 if (host
->ops
->dma_setup(host
))
460 /* initialize pre request cookie */
461 host
->next_cookie
= 1;
463 host
->use_dma
= true;
467 * Validate mmc prerequisites
469 static int mmci_validate_data(struct mmci_host
*host
,
470 struct mmc_data
*data
)
475 if (!is_power_of_2(data
->blksz
)) {
476 dev_err(mmc_dev(host
->mmc
),
477 "unsupported block size (%d bytes)\n", data
->blksz
);
481 if (host
->ops
&& host
->ops
->validate_data
)
482 return host
->ops
->validate_data(host
, data
);
487 int mmci_prep_data(struct mmci_host
*host
, struct mmc_data
*data
, bool next
)
491 if (!host
->ops
|| !host
->ops
->prep_data
)
494 err
= host
->ops
->prep_data(host
, data
, next
);
497 data
->host_cookie
= ++host
->next_cookie
< 0 ?
498 1 : host
->next_cookie
;
503 void mmci_unprep_data(struct mmci_host
*host
, struct mmc_data
*data
,
506 if (host
->ops
&& host
->ops
->unprep_data
)
507 host
->ops
->unprep_data(host
, data
, err
);
509 data
->host_cookie
= 0;
512 void mmci_get_next_data(struct mmci_host
*host
, struct mmc_data
*data
)
514 WARN_ON(data
->host_cookie
&& data
->host_cookie
!= host
->next_cookie
);
516 if (host
->ops
&& host
->ops
->get_next_data
)
517 host
->ops
->get_next_data(host
, data
);
520 int mmci_dma_start(struct mmci_host
*host
, unsigned int datactrl
)
522 struct mmc_data
*data
= host
->data
;
528 ret
= mmci_prep_data(host
, data
, false);
532 if (!host
->ops
|| !host
->ops
->dma_start
)
535 /* Okay, go for it. */
536 dev_vdbg(mmc_dev(host
->mmc
),
537 "Submit MMCI DMA job, sglen %d blksz %04x blks %04x flags %08x\n",
538 data
->sg_len
, data
->blksz
, data
->blocks
, data
->flags
);
540 host
->ops
->dma_start(host
, &datactrl
);
542 /* Trigger the DMA transfer */
543 mmci_write_datactrlreg(host
, datactrl
);
546 * Let the MMCI say when the data is ended and it's time
547 * to fire next DMA request. When that happens, MMCI will
548 * call mmci_data_end()
550 writel(readl(host
->base
+ MMCIMASK0
) | MCI_DATAENDMASK
,
551 host
->base
+ MMCIMASK0
);
555 void mmci_dma_finalize(struct mmci_host
*host
, struct mmc_data
*data
)
560 if (host
->ops
&& host
->ops
->dma_finalize
)
561 host
->ops
->dma_finalize(host
, data
);
564 void mmci_dma_error(struct mmci_host
*host
)
569 if (host
->ops
&& host
->ops
->dma_error
)
570 host
->ops
->dma_error(host
);
574 mmci_request_end(struct mmci_host
*host
, struct mmc_request
*mrq
)
576 writel(0, host
->base
+ MMCICOMMAND
);
583 mmc_request_done(host
->mmc
, mrq
);
586 static void mmci_set_mask1(struct mmci_host
*host
, unsigned int mask
)
588 void __iomem
*base
= host
->base
;
589 struct variant_data
*variant
= host
->variant
;
591 if (host
->singleirq
) {
592 unsigned int mask0
= readl(base
+ MMCIMASK0
);
594 mask0
&= ~variant
->irq_pio_mask
;
597 writel(mask0
, base
+ MMCIMASK0
);
600 if (variant
->mmcimask1
)
601 writel(mask
, base
+ MMCIMASK1
);
603 host
->mask1_reg
= mask
;
606 static void mmci_stop_data(struct mmci_host
*host
)
608 mmci_write_datactrlreg(host
, 0);
609 mmci_set_mask1(host
, 0);
613 static void mmci_init_sg(struct mmci_host
*host
, struct mmc_data
*data
)
615 unsigned int flags
= SG_MITER_ATOMIC
;
617 if (data
->flags
& MMC_DATA_READ
)
618 flags
|= SG_MITER_TO_SG
;
620 flags
|= SG_MITER_FROM_SG
;
622 sg_miter_start(&host
->sg_miter
, data
->sg
, data
->sg_len
, flags
);
626 * All the DMA operation mode stuff goes inside this ifdef.
627 * This assumes that you have a generic DMA device interface,
628 * no custom DMA interfaces are supported.
630 #ifdef CONFIG_DMA_ENGINE
631 struct mmci_dmae_next
{
632 struct dma_async_tx_descriptor
*desc
;
633 struct dma_chan
*chan
;
636 struct mmci_dmae_priv
{
637 struct dma_chan
*cur
;
638 struct dma_chan
*rx_channel
;
639 struct dma_chan
*tx_channel
;
640 struct dma_async_tx_descriptor
*desc_current
;
641 struct mmci_dmae_next next_data
;
644 int mmci_dmae_setup(struct mmci_host
*host
)
646 const char *rxname
, *txname
;
647 struct mmci_dmae_priv
*dmae
;
649 dmae
= devm_kzalloc(mmc_dev(host
->mmc
), sizeof(*dmae
), GFP_KERNEL
);
653 host
->dma_priv
= dmae
;
655 dmae
->rx_channel
= dma_request_slave_channel(mmc_dev(host
->mmc
),
657 dmae
->tx_channel
= dma_request_slave_channel(mmc_dev(host
->mmc
),
661 * If only an RX channel is specified, the driver will
662 * attempt to use it bidirectionally, however if it is
663 * is specified but cannot be located, DMA will be disabled.
665 if (dmae
->rx_channel
&& !dmae
->tx_channel
)
666 dmae
->tx_channel
= dmae
->rx_channel
;
668 if (dmae
->rx_channel
)
669 rxname
= dma_chan_name(dmae
->rx_channel
);
673 if (dmae
->tx_channel
)
674 txname
= dma_chan_name(dmae
->tx_channel
);
678 dev_info(mmc_dev(host
->mmc
), "DMA channels RX %s, TX %s\n",
682 * Limit the maximum segment size in any SG entry according to
683 * the parameters of the DMA engine device.
685 if (dmae
->tx_channel
) {
686 struct device
*dev
= dmae
->tx_channel
->device
->dev
;
687 unsigned int max_seg_size
= dma_get_max_seg_size(dev
);
689 if (max_seg_size
< host
->mmc
->max_seg_size
)
690 host
->mmc
->max_seg_size
= max_seg_size
;
692 if (dmae
->rx_channel
) {
693 struct device
*dev
= dmae
->rx_channel
->device
->dev
;
694 unsigned int max_seg_size
= dma_get_max_seg_size(dev
);
696 if (max_seg_size
< host
->mmc
->max_seg_size
)
697 host
->mmc
->max_seg_size
= max_seg_size
;
700 if (!dmae
->tx_channel
|| !dmae
->rx_channel
) {
701 mmci_dmae_release(host
);
709 * This is used in or so inline it
710 * so it can be discarded.
712 void mmci_dmae_release(struct mmci_host
*host
)
714 struct mmci_dmae_priv
*dmae
= host
->dma_priv
;
716 if (dmae
->rx_channel
)
717 dma_release_channel(dmae
->rx_channel
);
718 if (dmae
->tx_channel
)
719 dma_release_channel(dmae
->tx_channel
);
720 dmae
->rx_channel
= dmae
->tx_channel
= NULL
;
723 static void mmci_dma_unmap(struct mmci_host
*host
, struct mmc_data
*data
)
725 struct mmci_dmae_priv
*dmae
= host
->dma_priv
;
726 struct dma_chan
*chan
;
728 if (data
->flags
& MMC_DATA_READ
)
729 chan
= dmae
->rx_channel
;
731 chan
= dmae
->tx_channel
;
733 dma_unmap_sg(chan
->device
->dev
, data
->sg
, data
->sg_len
,
734 mmc_get_dma_dir(data
));
737 void mmci_dmae_error(struct mmci_host
*host
)
739 struct mmci_dmae_priv
*dmae
= host
->dma_priv
;
741 if (!dma_inprogress(host
))
744 dev_err(mmc_dev(host
->mmc
), "error during DMA transfer!\n");
745 dmaengine_terminate_all(dmae
->cur
);
746 host
->dma_in_progress
= false;
748 dmae
->desc_current
= NULL
;
749 host
->data
->host_cookie
= 0;
751 mmci_dma_unmap(host
, host
->data
);
754 void mmci_dmae_finalize(struct mmci_host
*host
, struct mmc_data
*data
)
756 struct mmci_dmae_priv
*dmae
= host
->dma_priv
;
760 if (!dma_inprogress(host
))
763 /* Wait up to 1ms for the DMA to complete */
765 status
= readl(host
->base
+ MMCISTATUS
);
766 if (!(status
& MCI_RXDATAAVLBLMASK
) || i
>= 100)
772 * Check to see whether we still have some data left in the FIFO -
773 * this catches DMA controllers which are unable to monitor the
774 * DMALBREQ and DMALSREQ signals while allowing us to DMA to non-
775 * contiguous buffers. On TX, we'll get a FIFO underrun error.
777 if (status
& MCI_RXDATAAVLBLMASK
) {
778 mmci_dma_error(host
);
781 } else if (!data
->host_cookie
) {
782 mmci_dma_unmap(host
, data
);
786 * Use of DMA with scatter-gather is impossible.
787 * Give up with DMA and switch back to PIO mode.
789 if (status
& MCI_RXDATAAVLBLMASK
) {
790 dev_err(mmc_dev(host
->mmc
), "buggy DMA detected. Taking evasive action.\n");
791 mmci_dma_release(host
);
794 host
->dma_in_progress
= false;
796 dmae
->desc_current
= NULL
;
799 /* prepares DMA channel and DMA descriptor, returns non-zero on failure */
800 static int _mmci_dmae_prep_data(struct mmci_host
*host
, struct mmc_data
*data
,
801 struct dma_chan
**dma_chan
,
802 struct dma_async_tx_descriptor
**dma_desc
)
804 struct mmci_dmae_priv
*dmae
= host
->dma_priv
;
805 struct variant_data
*variant
= host
->variant
;
806 struct dma_slave_config conf
= {
807 .src_addr
= host
->phybase
+ MMCIFIFO
,
808 .dst_addr
= host
->phybase
+ MMCIFIFO
,
809 .src_addr_width
= DMA_SLAVE_BUSWIDTH_4_BYTES
,
810 .dst_addr_width
= DMA_SLAVE_BUSWIDTH_4_BYTES
,
811 .src_maxburst
= variant
->fifohalfsize
>> 2, /* # of words */
812 .dst_maxburst
= variant
->fifohalfsize
>> 2, /* # of words */
815 struct dma_chan
*chan
;
816 struct dma_device
*device
;
817 struct dma_async_tx_descriptor
*desc
;
819 unsigned long flags
= DMA_CTRL_ACK
;
821 if (data
->flags
& MMC_DATA_READ
) {
822 conf
.direction
= DMA_DEV_TO_MEM
;
823 chan
= dmae
->rx_channel
;
825 conf
.direction
= DMA_MEM_TO_DEV
;
826 chan
= dmae
->tx_channel
;
829 /* If there's no DMA channel, fall back to PIO */
833 /* If less than or equal to the fifo size, don't bother with DMA */
834 if (data
->blksz
* data
->blocks
<= variant
->fifosize
)
837 device
= chan
->device
;
838 nr_sg
= dma_map_sg(device
->dev
, data
->sg
, data
->sg_len
,
839 mmc_get_dma_dir(data
));
843 if (host
->variant
->qcom_dml
)
844 flags
|= DMA_PREP_INTERRUPT
;
846 dmaengine_slave_config(chan
, &conf
);
847 desc
= dmaengine_prep_slave_sg(chan
, data
->sg
, nr_sg
,
848 conf
.direction
, flags
);
858 dma_unmap_sg(device
->dev
, data
->sg
, data
->sg_len
,
859 mmc_get_dma_dir(data
));
863 int mmci_dmae_prep_data(struct mmci_host
*host
,
864 struct mmc_data
*data
,
867 struct mmci_dmae_priv
*dmae
= host
->dma_priv
;
868 struct mmci_dmae_next
*nd
= &dmae
->next_data
;
874 return _mmci_dmae_prep_data(host
, data
, &nd
->chan
, &nd
->desc
);
875 /* Check if next job is already prepared. */
876 if (dmae
->cur
&& dmae
->desc_current
)
879 /* No job were prepared thus do it now. */
880 return _mmci_dmae_prep_data(host
, data
, &dmae
->cur
,
881 &dmae
->desc_current
);
884 int mmci_dmae_start(struct mmci_host
*host
, unsigned int *datactrl
)
886 struct mmci_dmae_priv
*dmae
= host
->dma_priv
;
887 struct mmc_data
*data
= host
->data
;
889 host
->dma_in_progress
= true;
890 dmaengine_submit(dmae
->desc_current
);
891 dma_async_issue_pending(dmae
->cur
);
893 if (host
->variant
->qcom_dml
)
894 dml_start_xfer(host
, data
);
896 *datactrl
|= MCI_DPSM_DMAENABLE
;
901 void mmci_dmae_get_next_data(struct mmci_host
*host
, struct mmc_data
*data
)
903 struct mmci_dmae_priv
*dmae
= host
->dma_priv
;
904 struct mmci_dmae_next
*next
= &dmae
->next_data
;
909 WARN_ON(!data
->host_cookie
&& (next
->desc
|| next
->chan
));
911 dmae
->desc_current
= next
->desc
;
912 dmae
->cur
= next
->chan
;
917 void mmci_dmae_unprep_data(struct mmci_host
*host
,
918 struct mmc_data
*data
, int err
)
921 struct mmci_dmae_priv
*dmae
= host
->dma_priv
;
926 mmci_dma_unmap(host
, data
);
929 struct mmci_dmae_next
*next
= &dmae
->next_data
;
930 struct dma_chan
*chan
;
931 if (data
->flags
& MMC_DATA_READ
)
932 chan
= dmae
->rx_channel
;
934 chan
= dmae
->tx_channel
;
935 dmaengine_terminate_all(chan
);
937 if (dmae
->desc_current
== next
->desc
)
938 dmae
->desc_current
= NULL
;
940 if (dmae
->cur
== next
->chan
) {
941 host
->dma_in_progress
= false;
950 static struct mmci_host_ops mmci_variant_ops
= {
951 .prep_data
= mmci_dmae_prep_data
,
952 .unprep_data
= mmci_dmae_unprep_data
,
953 .get_next_data
= mmci_dmae_get_next_data
,
954 .dma_setup
= mmci_dmae_setup
,
955 .dma_release
= mmci_dmae_release
,
956 .dma_start
= mmci_dmae_start
,
957 .dma_finalize
= mmci_dmae_finalize
,
958 .dma_error
= mmci_dmae_error
,
961 void mmci_variant_init(struct mmci_host
*host
)
963 host
->ops
= &mmci_variant_ops
;
967 static void mmci_pre_request(struct mmc_host
*mmc
, struct mmc_request
*mrq
)
969 struct mmci_host
*host
= mmc_priv(mmc
);
970 struct mmc_data
*data
= mrq
->data
;
975 WARN_ON(data
->host_cookie
);
977 if (mmci_validate_data(host
, data
))
980 mmci_prep_data(host
, data
, true);
983 static void mmci_post_request(struct mmc_host
*mmc
, struct mmc_request
*mrq
,
986 struct mmci_host
*host
= mmc_priv(mmc
);
987 struct mmc_data
*data
= mrq
->data
;
989 if (!data
|| !data
->host_cookie
)
992 mmci_unprep_data(host
, data
, err
);
995 static void mmci_start_data(struct mmci_host
*host
, struct mmc_data
*data
)
997 struct variant_data
*variant
= host
->variant
;
998 unsigned int datactrl
, timeout
, irqmask
;
999 unsigned long long clks
;
1003 dev_dbg(mmc_dev(host
->mmc
), "blksz %04x blks %04x flags %08x\n",
1004 data
->blksz
, data
->blocks
, data
->flags
);
1007 host
->size
= data
->blksz
* data
->blocks
;
1008 data
->bytes_xfered
= 0;
1010 clks
= (unsigned long long)data
->timeout_ns
* host
->cclk
;
1011 do_div(clks
, NSEC_PER_SEC
);
1013 timeout
= data
->timeout_clks
+ (unsigned int)clks
;
1016 writel(timeout
, base
+ MMCIDATATIMER
);
1017 writel(host
->size
, base
+ MMCIDATALENGTH
);
1019 blksz_bits
= ffs(data
->blksz
) - 1;
1020 BUG_ON(1 << blksz_bits
!= data
->blksz
);
1022 if (variant
->blksz_datactrl16
)
1023 datactrl
= variant
->datactrl_dpsm_enable
| (data
->blksz
<< 16);
1024 else if (variant
->blksz_datactrl4
)
1025 datactrl
= variant
->datactrl_dpsm_enable
| (data
->blksz
<< 4);
1027 datactrl
= variant
->datactrl_dpsm_enable
| blksz_bits
<< 4;
1029 if (data
->flags
& MMC_DATA_READ
)
1030 datactrl
|= MCI_DPSM_DIRECTION
;
1032 if (host
->mmc
->card
&& mmc_card_sdio(host
->mmc
->card
)) {
1035 datactrl
|= variant
->datactrl_mask_sdio
;
1038 * The ST Micro variant for SDIO small write transfers
1039 * needs to have clock H/W flow control disabled,
1040 * otherwise the transfer will not start. The threshold
1041 * depends on the rate of MCLK.
1043 if (variant
->st_sdio
&& data
->flags
& MMC_DATA_WRITE
&&
1045 (host
->size
<= 8 && host
->mclk
> 50000000)))
1046 clk
= host
->clk_reg
& ~variant
->clkreg_enable
;
1048 clk
= host
->clk_reg
| variant
->clkreg_enable
;
1050 mmci_write_clkreg(host
, clk
);
1053 if (host
->mmc
->ios
.timing
== MMC_TIMING_UHS_DDR50
||
1054 host
->mmc
->ios
.timing
== MMC_TIMING_MMC_DDR52
)
1055 datactrl
|= variant
->datactrl_mask_ddrmode
;
1058 * Attempt to use DMA operation mode, if this
1059 * should fail, fall back to PIO mode
1061 if (!mmci_dma_start(host
, datactrl
))
1064 /* IRQ mode, map the SG list for CPU reading/writing */
1065 mmci_init_sg(host
, data
);
1067 if (data
->flags
& MMC_DATA_READ
) {
1068 irqmask
= MCI_RXFIFOHALFFULLMASK
;
1071 * If we have less than the fifo 'half-full' threshold to
1072 * transfer, trigger a PIO interrupt as soon as any data
1075 if (host
->size
< variant
->fifohalfsize
)
1076 irqmask
|= MCI_RXDATAAVLBLMASK
;
1079 * We don't actually need to include "FIFO empty" here
1080 * since its implicit in "FIFO half empty".
1082 irqmask
= MCI_TXFIFOHALFEMPTYMASK
;
1085 mmci_write_datactrlreg(host
, datactrl
);
1086 writel(readl(base
+ MMCIMASK0
) & ~MCI_DATAENDMASK
, base
+ MMCIMASK0
);
1087 mmci_set_mask1(host
, irqmask
);
1091 mmci_start_command(struct mmci_host
*host
, struct mmc_command
*cmd
, u32 c
)
1093 void __iomem
*base
= host
->base
;
1095 dev_dbg(mmc_dev(host
->mmc
), "op %02x arg %08x flags %08x\n",
1096 cmd
->opcode
, cmd
->arg
, cmd
->flags
);
1098 if (readl(base
+ MMCICOMMAND
) & host
->variant
->cmdreg_cpsm_enable
) {
1099 writel(0, base
+ MMCICOMMAND
);
1100 mmci_reg_delay(host
);
1103 c
|= cmd
->opcode
| host
->variant
->cmdreg_cpsm_enable
;
1104 if (cmd
->flags
& MMC_RSP_PRESENT
) {
1105 if (cmd
->flags
& MMC_RSP_136
)
1106 c
|= host
->variant
->cmdreg_lrsp_crc
;
1107 else if (cmd
->flags
& MMC_RSP_CRC
)
1108 c
|= host
->variant
->cmdreg_srsp_crc
;
1110 c
|= host
->variant
->cmdreg_srsp
;
1113 c
|= MCI_CPSM_INTERRUPT
;
1115 if (mmc_cmd_type(cmd
) == MMC_CMD_ADTC
)
1116 c
|= host
->variant
->data_cmd_enable
;
1120 writel(cmd
->arg
, base
+ MMCIARGUMENT
);
1121 writel(c
, base
+ MMCICOMMAND
);
1125 mmci_data_irq(struct mmci_host
*host
, struct mmc_data
*data
,
1126 unsigned int status
)
1128 unsigned int status_err
;
1130 /* Make sure we have data to handle */
1134 /* First check for errors */
1135 status_err
= status
& (host
->variant
->start_err
|
1136 MCI_DATACRCFAIL
| MCI_DATATIMEOUT
|
1137 MCI_TXUNDERRUN
| MCI_RXOVERRUN
);
1140 u32 remain
, success
;
1142 /* Terminate the DMA transfer */
1143 mmci_dma_error(host
);
1146 * Calculate how far we are into the transfer. Note that
1147 * the data counter gives the number of bytes transferred
1148 * on the MMC bus, not on the host side. On reads, this
1149 * can be as much as a FIFO-worth of data ahead. This
1150 * matters for FIFO overruns only.
1152 if (!host
->variant
->datacnt_useless
) {
1153 remain
= readl(host
->base
+ MMCIDATACNT
);
1154 success
= data
->blksz
* data
->blocks
- remain
;
1159 dev_dbg(mmc_dev(host
->mmc
), "MCI ERROR IRQ, status 0x%08x at 0x%08x\n",
1160 status_err
, success
);
1161 if (status_err
& MCI_DATACRCFAIL
) {
1162 /* Last block was not successful */
1164 data
->error
= -EILSEQ
;
1165 } else if (status_err
& MCI_DATATIMEOUT
) {
1166 data
->error
= -ETIMEDOUT
;
1167 } else if (status_err
& MCI_STARTBITERR
) {
1168 data
->error
= -ECOMM
;
1169 } else if (status_err
& MCI_TXUNDERRUN
) {
1171 } else if (status_err
& MCI_RXOVERRUN
) {
1172 if (success
> host
->variant
->fifosize
)
1173 success
-= host
->variant
->fifosize
;
1178 data
->bytes_xfered
= round_down(success
, data
->blksz
);
1181 if (status
& MCI_DATABLOCKEND
)
1182 dev_err(mmc_dev(host
->mmc
), "stray MCI_DATABLOCKEND interrupt\n");
1184 if (status
& MCI_DATAEND
|| data
->error
) {
1185 mmci_dma_finalize(host
, data
);
1187 mmci_stop_data(host
);
1190 /* The error clause is handled above, success! */
1191 data
->bytes_xfered
= data
->blksz
* data
->blocks
;
1193 if (!data
->stop
|| host
->mrq
->sbc
) {
1194 mmci_request_end(host
, data
->mrq
);
1196 mmci_start_command(host
, data
->stop
, 0);
1202 mmci_cmd_irq(struct mmci_host
*host
, struct mmc_command
*cmd
,
1203 unsigned int status
)
1205 void __iomem
*base
= host
->base
;
1211 sbc
= (cmd
== host
->mrq
->sbc
);
1214 * We need to be one of these interrupts to be considered worth
1215 * handling. Note that we tag on any latent IRQs postponed
1216 * due to waiting for busy status.
1218 if (!((status
|host
->busy_status
) &
1219 (MCI_CMDCRCFAIL
|MCI_CMDTIMEOUT
|MCI_CMDSENT
|MCI_CMDRESPEND
)))
1223 * ST Micro variant: handle busy detection.
1225 if (host
->variant
->busy_detect
) {
1226 bool busy_resp
= !!(cmd
->flags
& MMC_RSP_BUSY
);
1228 /* We are busy with a command, return */
1229 if (host
->busy_status
&&
1230 (status
& host
->variant
->busy_detect_flag
))
1234 * We were not busy, but we now got a busy response on
1235 * something that was not an error, and we double-check
1236 * that the special busy status bit is still set before
1239 if (!host
->busy_status
&& busy_resp
&&
1240 !(status
& (MCI_CMDCRCFAIL
|MCI_CMDTIMEOUT
)) &&
1241 (readl(base
+ MMCISTATUS
) & host
->variant
->busy_detect_flag
)) {
1243 /* Clear the busy start IRQ */
1244 writel(host
->variant
->busy_detect_mask
,
1245 host
->base
+ MMCICLEAR
);
1247 /* Unmask the busy end IRQ */
1248 writel(readl(base
+ MMCIMASK0
) |
1249 host
->variant
->busy_detect_mask
,
1252 * Now cache the last response status code (until
1253 * the busy bit goes low), and return.
1256 status
& (MCI_CMDSENT
|MCI_CMDRESPEND
);
1261 * At this point we are not busy with a command, we have
1262 * not received a new busy request, clear and mask the busy
1263 * end IRQ and fall through to process the IRQ.
1265 if (host
->busy_status
) {
1267 writel(host
->variant
->busy_detect_mask
,
1268 host
->base
+ MMCICLEAR
);
1270 writel(readl(base
+ MMCIMASK0
) &
1271 ~host
->variant
->busy_detect_mask
,
1273 host
->busy_status
= 0;
1279 if (status
& MCI_CMDTIMEOUT
) {
1280 cmd
->error
= -ETIMEDOUT
;
1281 } else if (status
& MCI_CMDCRCFAIL
&& cmd
->flags
& MMC_RSP_CRC
) {
1282 cmd
->error
= -EILSEQ
;
1284 cmd
->resp
[0] = readl(base
+ MMCIRESPONSE0
);
1285 cmd
->resp
[1] = readl(base
+ MMCIRESPONSE1
);
1286 cmd
->resp
[2] = readl(base
+ MMCIRESPONSE2
);
1287 cmd
->resp
[3] = readl(base
+ MMCIRESPONSE3
);
1290 if ((!sbc
&& !cmd
->data
) || cmd
->error
) {
1292 /* Terminate the DMA transfer */
1293 mmci_dma_error(host
);
1295 mmci_stop_data(host
);
1297 mmci_request_end(host
, host
->mrq
);
1299 mmci_start_command(host
, host
->mrq
->cmd
, 0);
1300 } else if (!host
->variant
->datactrl_first
&&
1301 !(cmd
->data
->flags
& MMC_DATA_READ
)) {
1302 mmci_start_data(host
, cmd
->data
);
1306 static int mmci_get_rx_fifocnt(struct mmci_host
*host
, u32 status
, int remain
)
1308 return remain
- (readl(host
->base
+ MMCIFIFOCNT
) << 2);
1311 static int mmci_qcom_get_rx_fifocnt(struct mmci_host
*host
, u32 status
, int r
)
1314 * on qcom SDCC4 only 8 words are used in each burst so only 8 addresses
1315 * from the fifo range should be used
1317 if (status
& MCI_RXFIFOHALFFULL
)
1318 return host
->variant
->fifohalfsize
;
1319 else if (status
& MCI_RXDATAAVLBL
)
1325 static int mmci_pio_read(struct mmci_host
*host
, char *buffer
, unsigned int remain
)
1327 void __iomem
*base
= host
->base
;
1329 u32 status
= readl(host
->base
+ MMCISTATUS
);
1330 int host_remain
= host
->size
;
1333 int count
= host
->get_rx_fifocnt(host
, status
, host_remain
);
1342 * SDIO especially may want to send something that is
1343 * not divisible by 4 (as opposed to card sectors
1344 * etc). Therefore make sure to always read the last bytes
1345 * while only doing full 32-bit reads towards the FIFO.
1347 if (unlikely(count
& 0x3)) {
1349 unsigned char buf
[4];
1350 ioread32_rep(base
+ MMCIFIFO
, buf
, 1);
1351 memcpy(ptr
, buf
, count
);
1353 ioread32_rep(base
+ MMCIFIFO
, ptr
, count
>> 2);
1357 ioread32_rep(base
+ MMCIFIFO
, ptr
, count
>> 2);
1362 host_remain
-= count
;
1367 status
= readl(base
+ MMCISTATUS
);
1368 } while (status
& MCI_RXDATAAVLBL
);
1370 return ptr
- buffer
;
1373 static int mmci_pio_write(struct mmci_host
*host
, char *buffer
, unsigned int remain
, u32 status
)
1375 struct variant_data
*variant
= host
->variant
;
1376 void __iomem
*base
= host
->base
;
1380 unsigned int count
, maxcnt
;
1382 maxcnt
= status
& MCI_TXFIFOEMPTY
?
1383 variant
->fifosize
: variant
->fifohalfsize
;
1384 count
= min(remain
, maxcnt
);
1387 * SDIO especially may want to send something that is
1388 * not divisible by 4 (as opposed to card sectors
1389 * etc), and the FIFO only accept full 32-bit writes.
1390 * So compensate by adding +3 on the count, a single
1391 * byte become a 32bit write, 7 bytes will be two
1394 iowrite32_rep(base
+ MMCIFIFO
, ptr
, (count
+ 3) >> 2);
1402 status
= readl(base
+ MMCISTATUS
);
1403 } while (status
& MCI_TXFIFOHALFEMPTY
);
1405 return ptr
- buffer
;
1409 * PIO data transfer IRQ handler.
1411 static irqreturn_t
mmci_pio_irq(int irq
, void *dev_id
)
1413 struct mmci_host
*host
= dev_id
;
1414 struct sg_mapping_iter
*sg_miter
= &host
->sg_miter
;
1415 struct variant_data
*variant
= host
->variant
;
1416 void __iomem
*base
= host
->base
;
1419 status
= readl(base
+ MMCISTATUS
);
1421 dev_dbg(mmc_dev(host
->mmc
), "irq1 (pio) %08x\n", status
);
1424 unsigned int remain
, len
;
1428 * For write, we only need to test the half-empty flag
1429 * here - if the FIFO is completely empty, then by
1430 * definition it is more than half empty.
1432 * For read, check for data available.
1434 if (!(status
& (MCI_TXFIFOHALFEMPTY
|MCI_RXDATAAVLBL
)))
1437 if (!sg_miter_next(sg_miter
))
1440 buffer
= sg_miter
->addr
;
1441 remain
= sg_miter
->length
;
1444 if (status
& MCI_RXACTIVE
)
1445 len
= mmci_pio_read(host
, buffer
, remain
);
1446 if (status
& MCI_TXACTIVE
)
1447 len
= mmci_pio_write(host
, buffer
, remain
, status
);
1449 sg_miter
->consumed
= len
;
1457 status
= readl(base
+ MMCISTATUS
);
1460 sg_miter_stop(sg_miter
);
1463 * If we have less than the fifo 'half-full' threshold to transfer,
1464 * trigger a PIO interrupt as soon as any data is available.
1466 if (status
& MCI_RXACTIVE
&& host
->size
< variant
->fifohalfsize
)
1467 mmci_set_mask1(host
, MCI_RXDATAAVLBLMASK
);
1470 * If we run out of data, disable the data IRQs; this
1471 * prevents a race where the FIFO becomes empty before
1472 * the chip itself has disabled the data path, and
1473 * stops us racing with our data end IRQ.
1475 if (host
->size
== 0) {
1476 mmci_set_mask1(host
, 0);
1477 writel(readl(base
+ MMCIMASK0
) | MCI_DATAENDMASK
, base
+ MMCIMASK0
);
1484 * Handle completion of command and data transfers.
1486 static irqreturn_t
mmci_irq(int irq
, void *dev_id
)
1488 struct mmci_host
*host
= dev_id
;
1492 spin_lock(&host
->lock
);
1495 status
= readl(host
->base
+ MMCISTATUS
);
1497 if (host
->singleirq
) {
1498 if (status
& host
->mask1_reg
)
1499 mmci_pio_irq(irq
, dev_id
);
1501 status
&= ~host
->variant
->irq_pio_mask
;
1505 * We intentionally clear the MCI_ST_CARDBUSY IRQ (if it's
1506 * enabled) in mmci_cmd_irq() function where ST Micro busy
1507 * detection variant is handled. Considering the HW seems to be
1508 * triggering the IRQ on both edges while monitoring DAT0 for
1509 * busy completion and that same status bit is used to monitor
1510 * start and end of busy detection, special care must be taken
1511 * to make sure that both start and end interrupts are always
1512 * cleared one after the other.
1514 status
&= readl(host
->base
+ MMCIMASK0
);
1515 if (host
->variant
->busy_detect
)
1516 writel(status
& ~host
->variant
->busy_detect_mask
,
1517 host
->base
+ MMCICLEAR
);
1519 writel(status
, host
->base
+ MMCICLEAR
);
1521 dev_dbg(mmc_dev(host
->mmc
), "irq0 (data+cmd) %08x\n", status
);
1523 if (host
->variant
->reversed_irq_handling
) {
1524 mmci_data_irq(host
, host
->data
, status
);
1525 mmci_cmd_irq(host
, host
->cmd
, status
);
1527 mmci_cmd_irq(host
, host
->cmd
, status
);
1528 mmci_data_irq(host
, host
->data
, status
);
1532 * Don't poll for busy completion in irq context.
1534 if (host
->variant
->busy_detect
&& host
->busy_status
)
1535 status
&= ~host
->variant
->busy_detect_flag
;
1540 spin_unlock(&host
->lock
);
1542 return IRQ_RETVAL(ret
);
1545 static void mmci_request(struct mmc_host
*mmc
, struct mmc_request
*mrq
)
1547 struct mmci_host
*host
= mmc_priv(mmc
);
1548 unsigned long flags
;
1550 WARN_ON(host
->mrq
!= NULL
);
1552 mrq
->cmd
->error
= mmci_validate_data(host
, mrq
->data
);
1553 if (mrq
->cmd
->error
) {
1554 mmc_request_done(mmc
, mrq
);
1558 spin_lock_irqsave(&host
->lock
, flags
);
1563 mmci_get_next_data(host
, mrq
->data
);
1566 (host
->variant
->datactrl_first
|| mrq
->data
->flags
& MMC_DATA_READ
))
1567 mmci_start_data(host
, mrq
->data
);
1570 mmci_start_command(host
, mrq
->sbc
, 0);
1572 mmci_start_command(host
, mrq
->cmd
, 0);
1574 spin_unlock_irqrestore(&host
->lock
, flags
);
1577 static void mmci_set_ios(struct mmc_host
*mmc
, struct mmc_ios
*ios
)
1579 struct mmci_host
*host
= mmc_priv(mmc
);
1580 struct variant_data
*variant
= host
->variant
;
1582 unsigned long flags
;
1585 if (host
->plat
->ios_handler
&&
1586 host
->plat
->ios_handler(mmc_dev(mmc
), ios
))
1587 dev_err(mmc_dev(mmc
), "platform ios_handler failed\n");
1589 switch (ios
->power_mode
) {
1591 if (!IS_ERR(mmc
->supply
.vmmc
))
1592 mmc_regulator_set_ocr(mmc
, mmc
->supply
.vmmc
, 0);
1594 if (!IS_ERR(mmc
->supply
.vqmmc
) && host
->vqmmc_enabled
) {
1595 regulator_disable(mmc
->supply
.vqmmc
);
1596 host
->vqmmc_enabled
= false;
1601 if (!IS_ERR(mmc
->supply
.vmmc
))
1602 mmc_regulator_set_ocr(mmc
, mmc
->supply
.vmmc
, ios
->vdd
);
1605 * The ST Micro variant doesn't have the PL180s MCI_PWR_UP
1606 * and instead uses MCI_PWR_ON so apply whatever value is
1607 * configured in the variant data.
1609 pwr
|= variant
->pwrreg_powerup
;
1613 if (!IS_ERR(mmc
->supply
.vqmmc
) && !host
->vqmmc_enabled
) {
1614 ret
= regulator_enable(mmc
->supply
.vqmmc
);
1616 dev_err(mmc_dev(mmc
),
1617 "failed to enable vqmmc regulator\n");
1619 host
->vqmmc_enabled
= true;
1626 if (variant
->signal_direction
&& ios
->power_mode
!= MMC_POWER_OFF
) {
1628 * The ST Micro variant has some additional bits
1629 * indicating signal direction for the signals in
1630 * the SD/MMC bus and feedback-clock usage.
1632 pwr
|= host
->pwr_reg_add
;
1634 if (ios
->bus_width
== MMC_BUS_WIDTH_4
)
1635 pwr
&= ~MCI_ST_DATA74DIREN
;
1636 else if (ios
->bus_width
== MMC_BUS_WIDTH_1
)
1637 pwr
&= (~MCI_ST_DATA74DIREN
&
1638 ~MCI_ST_DATA31DIREN
&
1639 ~MCI_ST_DATA2DIREN
);
1642 if (variant
->opendrain
) {
1643 if (ios
->bus_mode
== MMC_BUSMODE_OPENDRAIN
)
1644 pwr
|= variant
->opendrain
;
1647 * If the variant cannot configure the pads by its own, then we
1648 * expect the pinctrl to be able to do that for us
1650 if (ios
->bus_mode
== MMC_BUSMODE_OPENDRAIN
)
1651 pinctrl_select_state(host
->pinctrl
, host
->pins_opendrain
);
1653 pinctrl_select_state(host
->pinctrl
, host
->pins_default
);
1657 * If clock = 0 and the variant requires the MMCIPOWER to be used for
1658 * gating the clock, the MCI_PWR_ON bit is cleared.
1660 if (!ios
->clock
&& variant
->pwrreg_clkgate
)
1663 if (host
->variant
->explicit_mclk_control
&&
1664 ios
->clock
!= host
->clock_cache
) {
1665 ret
= clk_set_rate(host
->clk
, ios
->clock
);
1667 dev_err(mmc_dev(host
->mmc
),
1668 "Error setting clock rate (%d)\n", ret
);
1670 host
->mclk
= clk_get_rate(host
->clk
);
1672 host
->clock_cache
= ios
->clock
;
1674 spin_lock_irqsave(&host
->lock
, flags
);
1676 if (host
->ops
&& host
->ops
->set_clkreg
)
1677 host
->ops
->set_clkreg(host
, ios
->clock
);
1679 mmci_set_clkreg(host
, ios
->clock
);
1681 if (host
->ops
&& host
->ops
->set_pwrreg
)
1682 host
->ops
->set_pwrreg(host
, pwr
);
1684 mmci_write_pwrreg(host
, pwr
);
1686 mmci_reg_delay(host
);
1688 spin_unlock_irqrestore(&host
->lock
, flags
);
1691 static int mmci_get_cd(struct mmc_host
*mmc
)
1693 struct mmci_host
*host
= mmc_priv(mmc
);
1694 struct mmci_platform_data
*plat
= host
->plat
;
1695 unsigned int status
= mmc_gpio_get_cd(mmc
);
1697 if (status
== -ENOSYS
) {
1699 return 1; /* Assume always present */
1701 status
= plat
->status(mmc_dev(host
->mmc
));
1706 static int mmci_sig_volt_switch(struct mmc_host
*mmc
, struct mmc_ios
*ios
)
1710 if (!IS_ERR(mmc
->supply
.vqmmc
)) {
1712 switch (ios
->signal_voltage
) {
1713 case MMC_SIGNAL_VOLTAGE_330
:
1714 ret
= regulator_set_voltage(mmc
->supply
.vqmmc
,
1717 case MMC_SIGNAL_VOLTAGE_180
:
1718 ret
= regulator_set_voltage(mmc
->supply
.vqmmc
,
1721 case MMC_SIGNAL_VOLTAGE_120
:
1722 ret
= regulator_set_voltage(mmc
->supply
.vqmmc
,
1728 dev_warn(mmc_dev(mmc
), "Voltage switch failed\n");
1734 static struct mmc_host_ops mmci_ops
= {
1735 .request
= mmci_request
,
1736 .pre_req
= mmci_pre_request
,
1737 .post_req
= mmci_post_request
,
1738 .set_ios
= mmci_set_ios
,
1739 .get_ro
= mmc_gpio_get_ro
,
1740 .get_cd
= mmci_get_cd
,
1741 .start_signal_voltage_switch
= mmci_sig_volt_switch
,
1744 static int mmci_of_parse(struct device_node
*np
, struct mmc_host
*mmc
)
1746 struct mmci_host
*host
= mmc_priv(mmc
);
1747 int ret
= mmc_of_parse(mmc
);
1752 if (of_get_property(np
, "st,sig-dir-dat0", NULL
))
1753 host
->pwr_reg_add
|= MCI_ST_DATA0DIREN
;
1754 if (of_get_property(np
, "st,sig-dir-dat2", NULL
))
1755 host
->pwr_reg_add
|= MCI_ST_DATA2DIREN
;
1756 if (of_get_property(np
, "st,sig-dir-dat31", NULL
))
1757 host
->pwr_reg_add
|= MCI_ST_DATA31DIREN
;
1758 if (of_get_property(np
, "st,sig-dir-dat74", NULL
))
1759 host
->pwr_reg_add
|= MCI_ST_DATA74DIREN
;
1760 if (of_get_property(np
, "st,sig-dir-cmd", NULL
))
1761 host
->pwr_reg_add
|= MCI_ST_CMDDIREN
;
1762 if (of_get_property(np
, "st,sig-pin-fbclk", NULL
))
1763 host
->pwr_reg_add
|= MCI_ST_FBCLKEN
;
1764 if (of_get_property(np
, "st,sig-dir", NULL
))
1765 host
->pwr_reg_add
|= MCI_STM32_DIRPOL
;
1766 if (of_get_property(np
, "st,neg-edge", NULL
))
1767 host
->clk_reg_add
|= MCI_STM32_CLK_NEGEDGE
;
1768 if (of_get_property(np
, "st,use-ckin", NULL
))
1769 host
->clk_reg_add
|= MCI_STM32_CLK_SELCKIN
;
1771 if (of_get_property(np
, "mmc-cap-mmc-highspeed", NULL
))
1772 mmc
->caps
|= MMC_CAP_MMC_HIGHSPEED
;
1773 if (of_get_property(np
, "mmc-cap-sd-highspeed", NULL
))
1774 mmc
->caps
|= MMC_CAP_SD_HIGHSPEED
;
1779 static int mmci_probe(struct amba_device
*dev
,
1780 const struct amba_id
*id
)
1782 struct mmci_platform_data
*plat
= dev
->dev
.platform_data
;
1783 struct device_node
*np
= dev
->dev
.of_node
;
1784 struct variant_data
*variant
= id
->data
;
1785 struct mmci_host
*host
;
1786 struct mmc_host
*mmc
;
1789 /* Must have platform data or Device Tree. */
1791 dev_err(&dev
->dev
, "No plat data or DT found\n");
1796 plat
= devm_kzalloc(&dev
->dev
, sizeof(*plat
), GFP_KERNEL
);
1801 mmc
= mmc_alloc_host(sizeof(struct mmci_host
), &dev
->dev
);
1805 ret
= mmci_of_parse(np
, mmc
);
1809 host
= mmc_priv(mmc
);
1813 * Some variant (STM32) doesn't have opendrain bit, nevertheless
1814 * pins can be set accordingly using pinctrl
1816 if (!variant
->opendrain
) {
1817 host
->pinctrl
= devm_pinctrl_get(&dev
->dev
);
1818 if (IS_ERR(host
->pinctrl
)) {
1819 dev_err(&dev
->dev
, "failed to get pinctrl");
1820 ret
= PTR_ERR(host
->pinctrl
);
1824 host
->pins_default
= pinctrl_lookup_state(host
->pinctrl
,
1825 PINCTRL_STATE_DEFAULT
);
1826 if (IS_ERR(host
->pins_default
)) {
1827 dev_err(mmc_dev(mmc
), "Can't select default pins\n");
1828 ret
= PTR_ERR(host
->pins_default
);
1832 host
->pins_opendrain
= pinctrl_lookup_state(host
->pinctrl
,
1833 MMCI_PINCTRL_STATE_OPENDRAIN
);
1834 if (IS_ERR(host
->pins_opendrain
)) {
1835 dev_err(mmc_dev(mmc
), "Can't select opendrain pins\n");
1836 ret
= PTR_ERR(host
->pins_opendrain
);
1841 host
->hw_designer
= amba_manf(dev
);
1842 host
->hw_revision
= amba_rev(dev
);
1843 dev_dbg(mmc_dev(mmc
), "designer ID = 0x%02x\n", host
->hw_designer
);
1844 dev_dbg(mmc_dev(mmc
), "revision = 0x%01x\n", host
->hw_revision
);
1846 host
->clk
= devm_clk_get(&dev
->dev
, NULL
);
1847 if (IS_ERR(host
->clk
)) {
1848 ret
= PTR_ERR(host
->clk
);
1852 ret
= clk_prepare_enable(host
->clk
);
1856 if (variant
->qcom_fifo
)
1857 host
->get_rx_fifocnt
= mmci_qcom_get_rx_fifocnt
;
1859 host
->get_rx_fifocnt
= mmci_get_rx_fifocnt
;
1862 host
->variant
= variant
;
1863 host
->mclk
= clk_get_rate(host
->clk
);
1865 * According to the spec, mclk is max 100 MHz,
1866 * so we try to adjust the clock down to this,
1869 if (host
->mclk
> variant
->f_max
) {
1870 ret
= clk_set_rate(host
->clk
, variant
->f_max
);
1873 host
->mclk
= clk_get_rate(host
->clk
);
1874 dev_dbg(mmc_dev(mmc
), "eventual mclk rate: %u Hz\n",
1878 host
->phybase
= dev
->res
.start
;
1879 host
->base
= devm_ioremap_resource(&dev
->dev
, &dev
->res
);
1880 if (IS_ERR(host
->base
)) {
1881 ret
= PTR_ERR(host
->base
);
1886 variant
->init(host
);
1889 * The ARM and ST versions of the block have slightly different
1890 * clock divider equations which means that the minimum divider
1892 * on Qualcomm like controllers get the nearest minimum clock to 100Khz
1894 if (variant
->st_clkdiv
)
1895 mmc
->f_min
= DIV_ROUND_UP(host
->mclk
, 257);
1896 else if (variant
->stm32_clkdiv
)
1897 mmc
->f_min
= DIV_ROUND_UP(host
->mclk
, 2046);
1898 else if (variant
->explicit_mclk_control
)
1899 mmc
->f_min
= clk_round_rate(host
->clk
, 100000);
1901 mmc
->f_min
= DIV_ROUND_UP(host
->mclk
, 512);
1903 * If no maximum operating frequency is supplied, fall back to use
1904 * the module parameter, which has a (low) default value in case it
1905 * is not specified. Either value must not exceed the clock rate into
1906 * the block, of course.
1909 mmc
->f_max
= variant
->explicit_mclk_control
?
1910 min(variant
->f_max
, mmc
->f_max
) :
1911 min(host
->mclk
, mmc
->f_max
);
1913 mmc
->f_max
= variant
->explicit_mclk_control
?
1914 fmax
: min(host
->mclk
, fmax
);
1917 dev_dbg(mmc_dev(mmc
), "clocking block at %u Hz\n", mmc
->f_max
);
1919 host
->rst
= devm_reset_control_get_optional_exclusive(&dev
->dev
, NULL
);
1920 if (IS_ERR(host
->rst
)) {
1921 ret
= PTR_ERR(host
->rst
);
1925 /* Get regulators and the supported OCR mask */
1926 ret
= mmc_regulator_get_supply(mmc
);
1930 if (!mmc
->ocr_avail
)
1931 mmc
->ocr_avail
= plat
->ocr_mask
;
1932 else if (plat
->ocr_mask
)
1933 dev_warn(mmc_dev(mmc
), "Platform OCR mask is ignored\n");
1935 /* We support these capabilities. */
1936 mmc
->caps
|= MMC_CAP_CMD23
;
1939 * Enable busy detection.
1941 if (variant
->busy_detect
) {
1942 mmci_ops
.card_busy
= mmci_card_busy
;
1944 * Not all variants have a flag to enable busy detection
1945 * in the DPSM, but if they do, set it here.
1947 if (variant
->busy_dpsm_flag
)
1948 mmci_write_datactrlreg(host
,
1949 host
->variant
->busy_dpsm_flag
);
1950 mmc
->caps
|= MMC_CAP_WAIT_WHILE_BUSY
;
1951 mmc
->max_busy_timeout
= 0;
1954 mmc
->ops
= &mmci_ops
;
1956 /* We support these PM capabilities. */
1957 mmc
->pm_caps
|= MMC_PM_KEEP_POWER
;
1962 mmc
->max_segs
= NR_SG
;
1965 * Since only a certain number of bits are valid in the data length
1966 * register, we must ensure that we don't exceed 2^num-1 bytes in a
1969 mmc
->max_req_size
= (1 << variant
->datalength_bits
) - 1;
1972 * Set the maximum segment size. Since we aren't doing DMA
1973 * (yet) we are only limited by the data length register.
1975 mmc
->max_seg_size
= mmc
->max_req_size
;
1978 * Block size can be up to 2048 bytes, but must be a power of two.
1980 mmc
->max_blk_size
= 1 << variant
->datactrl_blocksz
;
1983 * Limit the number of blocks transferred so that we don't overflow
1984 * the maximum request size.
1986 mmc
->max_blk_count
= mmc
->max_req_size
>> variant
->datactrl_blocksz
;
1988 spin_lock_init(&host
->lock
);
1990 writel(0, host
->base
+ MMCIMASK0
);
1992 if (variant
->mmcimask1
)
1993 writel(0, host
->base
+ MMCIMASK1
);
1995 writel(0xfff, host
->base
+ MMCICLEAR
);
1999 * - not using DT but using a descriptor table, or
2000 * - using a table of descriptors ALONGSIDE DT, or
2001 * look up these descriptors named "cd" and "wp" right here, fail
2002 * silently of these do not exist
2005 ret
= mmc_gpiod_request_cd(mmc
, "cd", 0, false, 0, NULL
);
2006 if (ret
== -EPROBE_DEFER
)
2009 ret
= mmc_gpiod_request_ro(mmc
, "wp", 0, false, 0, NULL
);
2010 if (ret
== -EPROBE_DEFER
)
2014 ret
= devm_request_irq(&dev
->dev
, dev
->irq
[0], mmci_irq
, IRQF_SHARED
,
2015 DRIVER_NAME
" (cmd)", host
);
2020 host
->singleirq
= true;
2022 ret
= devm_request_irq(&dev
->dev
, dev
->irq
[1], mmci_pio_irq
,
2023 IRQF_SHARED
, DRIVER_NAME
" (pio)", host
);
2028 writel(MCI_IRQENABLE
| variant
->start_err
, host
->base
+ MMCIMASK0
);
2030 amba_set_drvdata(dev
, mmc
);
2032 dev_info(&dev
->dev
, "%s: PL%03x manf %x rev%u at 0x%08llx irq %d,%d (pio)\n",
2033 mmc_hostname(mmc
), amba_part(dev
), amba_manf(dev
),
2034 amba_rev(dev
), (unsigned long long)dev
->res
.start
,
2035 dev
->irq
[0], dev
->irq
[1]);
2037 mmci_dma_setup(host
);
2039 pm_runtime_set_autosuspend_delay(&dev
->dev
, 50);
2040 pm_runtime_use_autosuspend(&dev
->dev
);
2044 pm_runtime_put(&dev
->dev
);
2048 clk_disable_unprepare(host
->clk
);
2054 static int mmci_remove(struct amba_device
*dev
)
2056 struct mmc_host
*mmc
= amba_get_drvdata(dev
);
2059 struct mmci_host
*host
= mmc_priv(mmc
);
2060 struct variant_data
*variant
= host
->variant
;
2063 * Undo pm_runtime_put() in probe. We use the _sync
2064 * version here so that we can access the primecell.
2066 pm_runtime_get_sync(&dev
->dev
);
2068 mmc_remove_host(mmc
);
2070 writel(0, host
->base
+ MMCIMASK0
);
2072 if (variant
->mmcimask1
)
2073 writel(0, host
->base
+ MMCIMASK1
);
2075 writel(0, host
->base
+ MMCICOMMAND
);
2076 writel(0, host
->base
+ MMCIDATACTRL
);
2078 mmci_dma_release(host
);
2079 clk_disable_unprepare(host
->clk
);
2087 static void mmci_save(struct mmci_host
*host
)
2089 unsigned long flags
;
2091 spin_lock_irqsave(&host
->lock
, flags
);
2093 writel(0, host
->base
+ MMCIMASK0
);
2094 if (host
->variant
->pwrreg_nopower
) {
2095 writel(0, host
->base
+ MMCIDATACTRL
);
2096 writel(0, host
->base
+ MMCIPOWER
);
2097 writel(0, host
->base
+ MMCICLOCK
);
2099 mmci_reg_delay(host
);
2101 spin_unlock_irqrestore(&host
->lock
, flags
);
2104 static void mmci_restore(struct mmci_host
*host
)
2106 unsigned long flags
;
2108 spin_lock_irqsave(&host
->lock
, flags
);
2110 if (host
->variant
->pwrreg_nopower
) {
2111 writel(host
->clk_reg
, host
->base
+ MMCICLOCK
);
2112 writel(host
->datactrl_reg
, host
->base
+ MMCIDATACTRL
);
2113 writel(host
->pwr_reg
, host
->base
+ MMCIPOWER
);
2115 writel(MCI_IRQENABLE
| host
->variant
->start_err
,
2116 host
->base
+ MMCIMASK0
);
2117 mmci_reg_delay(host
);
2119 spin_unlock_irqrestore(&host
->lock
, flags
);
2122 static int mmci_runtime_suspend(struct device
*dev
)
2124 struct amba_device
*adev
= to_amba_device(dev
);
2125 struct mmc_host
*mmc
= amba_get_drvdata(adev
);
2128 struct mmci_host
*host
= mmc_priv(mmc
);
2129 pinctrl_pm_select_sleep_state(dev
);
2131 clk_disable_unprepare(host
->clk
);
2137 static int mmci_runtime_resume(struct device
*dev
)
2139 struct amba_device
*adev
= to_amba_device(dev
);
2140 struct mmc_host
*mmc
= amba_get_drvdata(adev
);
2143 struct mmci_host
*host
= mmc_priv(mmc
);
2144 clk_prepare_enable(host
->clk
);
2146 pinctrl_pm_select_default_state(dev
);
2153 static const struct dev_pm_ops mmci_dev_pm_ops
= {
2154 SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend
,
2155 pm_runtime_force_resume
)
2156 SET_RUNTIME_PM_OPS(mmci_runtime_suspend
, mmci_runtime_resume
, NULL
)
2159 static const struct amba_id mmci_ids
[] = {
2163 .data
= &variant_arm
,
2168 .data
= &variant_arm_extended_fifo
,
2173 .data
= &variant_arm_extended_fifo_hwfc
,
2178 .data
= &variant_arm
,
2180 /* ST Micro variants */
2184 .data
= &variant_u300
,
2189 .data
= &variant_nomadik
,
2194 .data
= &variant_nomadik
,
2199 .data
= &variant_ux500
,
2204 .data
= &variant_ux500v2
,
2209 .data
= &variant_stm32
,
2214 .data
= &variant_stm32_sdmmc
,
2216 /* Qualcomm variants */
2220 .data
= &variant_qcom
,
2225 MODULE_DEVICE_TABLE(amba
, mmci_ids
);
2227 static struct amba_driver mmci_driver
= {
2229 .name
= DRIVER_NAME
,
2230 .pm
= &mmci_dev_pm_ops
,
2232 .probe
= mmci_probe
,
2233 .remove
= mmci_remove
,
2234 .id_table
= mmci_ids
,
2237 module_amba_driver(mmci_driver
);
2239 module_param(fmax
, uint
, 0444);
2241 MODULE_DESCRIPTION("ARM PrimeCell PL180/181 Multimedia Card Interface driver");
2242 MODULE_LICENSE("GPL");