mxcmmc.c 29 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243
  1. /*
  2. * linux/drivers/mmc/host/mxcmmc.c - Freescale i.MX MMCI driver
  3. *
  4. * This is a driver for the SDHC controller found in Freescale MX2/MX3
  5. * SoCs. It is basically the same hardware as found on MX1 (imxmmc.c).
  6. * Unlike the hardware found on MX1, this hardware just works and does
  7. * not need all the quirks found in imxmmc.c, hence the separate driver.
  8. *
  9. * Copyright (C) 2008 Sascha Hauer, Pengutronix <s.hauer@pengutronix.de>
  10. * Copyright (C) 2006 Pavel Pisa, PiKRON <ppisa@pikron.com>
  11. *
  12. * derived from pxamci.c by Russell King
  13. *
  14. * This program is free software; you can redistribute it and/or modify
  15. * it under the terms of the GNU General Public License version 2 as
  16. * published by the Free Software Foundation.
  17. *
  18. */
  19. #include <linux/module.h>
  20. #include <linux/init.h>
  21. #include <linux/ioport.h>
  22. #include <linux/platform_device.h>
  23. #include <linux/interrupt.h>
  24. #include <linux/irq.h>
  25. #include <linux/blkdev.h>
  26. #include <linux/dma-mapping.h>
  27. #include <linux/mmc/host.h>
  28. #include <linux/mmc/card.h>
  29. #include <linux/delay.h>
  30. #include <linux/clk.h>
  31. #include <linux/io.h>
  32. #include <linux/gpio.h>
  33. #include <linux/regulator/consumer.h>
  34. #include <linux/dmaengine.h>
  35. #include <linux/types.h>
  36. #include <linux/of.h>
  37. #include <linux/of_device.h>
  38. #include <linux/of_dma.h>
  39. #include <linux/of_gpio.h>
  40. #include <linux/mmc/slot-gpio.h>
  41. #include <asm/dma.h>
  42. #include <asm/irq.h>
  43. #include <linux/platform_data/mmc-mxcmmc.h>
  44. #include <linux/platform_data/dma-imx.h>
  45. #define DRIVER_NAME "mxc-mmc"
  46. #define MXCMCI_TIMEOUT_MS 10000
  47. #define MMC_REG_STR_STP_CLK 0x00
  48. #define MMC_REG_STATUS 0x04
  49. #define MMC_REG_CLK_RATE 0x08
  50. #define MMC_REG_CMD_DAT_CONT 0x0C
  51. #define MMC_REG_RES_TO 0x10
  52. #define MMC_REG_READ_TO 0x14
  53. #define MMC_REG_BLK_LEN 0x18
  54. #define MMC_REG_NOB 0x1C
  55. #define MMC_REG_REV_NO 0x20
  56. #define MMC_REG_INT_CNTR 0x24
  57. #define MMC_REG_CMD 0x28
  58. #define MMC_REG_ARG 0x2C
  59. #define MMC_REG_RES_FIFO 0x34
  60. #define MMC_REG_BUFFER_ACCESS 0x38
  61. #define STR_STP_CLK_RESET (1 << 3)
  62. #define STR_STP_CLK_START_CLK (1 << 1)
  63. #define STR_STP_CLK_STOP_CLK (1 << 0)
  64. #define STATUS_CARD_INSERTION (1 << 31)
  65. #define STATUS_CARD_REMOVAL (1 << 30)
  66. #define STATUS_YBUF_EMPTY (1 << 29)
  67. #define STATUS_XBUF_EMPTY (1 << 28)
  68. #define STATUS_YBUF_FULL (1 << 27)
  69. #define STATUS_XBUF_FULL (1 << 26)
  70. #define STATUS_BUF_UND_RUN (1 << 25)
  71. #define STATUS_BUF_OVFL (1 << 24)
  72. #define STATUS_SDIO_INT_ACTIVE (1 << 14)
  73. #define STATUS_END_CMD_RESP (1 << 13)
  74. #define STATUS_WRITE_OP_DONE (1 << 12)
  75. #define STATUS_DATA_TRANS_DONE (1 << 11)
  76. #define STATUS_READ_OP_DONE (1 << 11)
  77. #define STATUS_WR_CRC_ERROR_CODE_MASK (3 << 10)
  78. #define STATUS_CARD_BUS_CLK_RUN (1 << 8)
  79. #define STATUS_BUF_READ_RDY (1 << 7)
  80. #define STATUS_BUF_WRITE_RDY (1 << 6)
  81. #define STATUS_RESP_CRC_ERR (1 << 5)
  82. #define STATUS_CRC_READ_ERR (1 << 3)
  83. #define STATUS_CRC_WRITE_ERR (1 << 2)
  84. #define STATUS_TIME_OUT_RESP (1 << 1)
  85. #define STATUS_TIME_OUT_READ (1 << 0)
  86. #define STATUS_ERR_MASK 0x2f
  87. #define CMD_DAT_CONT_CMD_RESP_LONG_OFF (1 << 12)
  88. #define CMD_DAT_CONT_STOP_READWAIT (1 << 11)
  89. #define CMD_DAT_CONT_START_READWAIT (1 << 10)
  90. #define CMD_DAT_CONT_BUS_WIDTH_4 (2 << 8)
  91. #define CMD_DAT_CONT_INIT (1 << 7)
  92. #define CMD_DAT_CONT_WRITE (1 << 4)
  93. #define CMD_DAT_CONT_DATA_ENABLE (1 << 3)
  94. #define CMD_DAT_CONT_RESPONSE_48BIT_CRC (1 << 0)
  95. #define CMD_DAT_CONT_RESPONSE_136BIT (2 << 0)
  96. #define CMD_DAT_CONT_RESPONSE_48BIT (3 << 0)
  97. #define INT_SDIO_INT_WKP_EN (1 << 18)
  98. #define INT_CARD_INSERTION_WKP_EN (1 << 17)
  99. #define INT_CARD_REMOVAL_WKP_EN (1 << 16)
  100. #define INT_CARD_INSERTION_EN (1 << 15)
  101. #define INT_CARD_REMOVAL_EN (1 << 14)
  102. #define INT_SDIO_IRQ_EN (1 << 13)
  103. #define INT_DAT0_EN (1 << 12)
  104. #define INT_BUF_READ_EN (1 << 4)
  105. #define INT_BUF_WRITE_EN (1 << 3)
  106. #define INT_END_CMD_RES_EN (1 << 2)
  107. #define INT_WRITE_OP_DONE_EN (1 << 1)
  108. #define INT_READ_OP_EN (1 << 0)
  109. enum mxcmci_type {
  110. IMX21_MMC,
  111. IMX31_MMC,
  112. MPC512X_MMC,
  113. };
  114. struct mxcmci_host {
  115. struct mmc_host *mmc;
  116. void __iomem *base;
  117. dma_addr_t phys_base;
  118. int detect_irq;
  119. struct dma_chan *dma;
  120. struct dma_async_tx_descriptor *desc;
  121. int do_dma;
  122. int default_irq_mask;
  123. int use_sdio;
  124. unsigned int power_mode;
  125. struct imxmmc_platform_data *pdata;
  126. struct mmc_request *req;
  127. struct mmc_command *cmd;
  128. struct mmc_data *data;
  129. unsigned int datasize;
  130. unsigned int dma_dir;
  131. u16 rev_no;
  132. unsigned int cmdat;
  133. struct clk *clk_ipg;
  134. struct clk *clk_per;
  135. int clock;
  136. struct work_struct datawork;
  137. spinlock_t lock;
  138. int burstlen;
  139. int dmareq;
  140. struct dma_slave_config dma_slave_config;
  141. struct imx_dma_data dma_data;
  142. struct timer_list watchdog;
  143. enum mxcmci_type devtype;
  144. };
  145. static const struct platform_device_id mxcmci_devtype[] = {
  146. {
  147. .name = "imx21-mmc",
  148. .driver_data = IMX21_MMC,
  149. }, {
  150. .name = "imx31-mmc",
  151. .driver_data = IMX31_MMC,
  152. }, {
  153. .name = "mpc512x-sdhc",
  154. .driver_data = MPC512X_MMC,
  155. }, {
  156. /* sentinel */
  157. }
  158. };
  159. MODULE_DEVICE_TABLE(platform, mxcmci_devtype);
  160. static const struct of_device_id mxcmci_of_match[] = {
  161. {
  162. .compatible = "fsl,imx21-mmc",
  163. .data = &mxcmci_devtype[IMX21_MMC],
  164. }, {
  165. .compatible = "fsl,imx31-mmc",
  166. .data = &mxcmci_devtype[IMX31_MMC],
  167. }, {
  168. .compatible = "fsl,mpc5121-sdhc",
  169. .data = &mxcmci_devtype[MPC512X_MMC],
  170. }, {
  171. /* sentinel */
  172. }
  173. };
  174. MODULE_DEVICE_TABLE(of, mxcmci_of_match);
  175. static inline int is_imx31_mmc(struct mxcmci_host *host)
  176. {
  177. return host->devtype == IMX31_MMC;
  178. }
  179. static inline int is_mpc512x_mmc(struct mxcmci_host *host)
  180. {
  181. return host->devtype == MPC512X_MMC;
  182. }
  183. static inline u32 mxcmci_readl(struct mxcmci_host *host, int reg)
  184. {
  185. if (IS_ENABLED(CONFIG_PPC_MPC512x))
  186. return ioread32be(host->base + reg);
  187. else
  188. return readl(host->base + reg);
  189. }
  190. static inline void mxcmci_writel(struct mxcmci_host *host, u32 val, int reg)
  191. {
  192. if (IS_ENABLED(CONFIG_PPC_MPC512x))
  193. iowrite32be(val, host->base + reg);
  194. else
  195. writel(val, host->base + reg);
  196. }
  197. static inline u16 mxcmci_readw(struct mxcmci_host *host, int reg)
  198. {
  199. if (IS_ENABLED(CONFIG_PPC_MPC512x))
  200. return ioread32be(host->base + reg);
  201. else
  202. return readw(host->base + reg);
  203. }
  204. static inline void mxcmci_writew(struct mxcmci_host *host, u16 val, int reg)
  205. {
  206. if (IS_ENABLED(CONFIG_PPC_MPC512x))
  207. iowrite32be(val, host->base + reg);
  208. else
  209. writew(val, host->base + reg);
  210. }
  211. static void mxcmci_set_clk_rate(struct mxcmci_host *host, unsigned int clk_ios);
  212. static void mxcmci_set_power(struct mxcmci_host *host, unsigned int vdd)
  213. {
  214. if (!IS_ERR(host->mmc->supply.vmmc)) {
  215. if (host->power_mode == MMC_POWER_UP)
  216. mmc_regulator_set_ocr(host->mmc,
  217. host->mmc->supply.vmmc, vdd);
  218. else if (host->power_mode == MMC_POWER_OFF)
  219. mmc_regulator_set_ocr(host->mmc,
  220. host->mmc->supply.vmmc, 0);
  221. }
  222. if (host->pdata && host->pdata->setpower)
  223. host->pdata->setpower(mmc_dev(host->mmc), vdd);
  224. }
  225. static inline int mxcmci_use_dma(struct mxcmci_host *host)
  226. {
  227. return host->do_dma;
  228. }
  229. static void mxcmci_softreset(struct mxcmci_host *host)
  230. {
  231. int i;
  232. dev_dbg(mmc_dev(host->mmc), "mxcmci_softreset\n");
  233. /* reset sequence */
  234. mxcmci_writew(host, STR_STP_CLK_RESET, MMC_REG_STR_STP_CLK);
  235. mxcmci_writew(host, STR_STP_CLK_RESET | STR_STP_CLK_START_CLK,
  236. MMC_REG_STR_STP_CLK);
  237. for (i = 0; i < 8; i++)
  238. mxcmci_writew(host, STR_STP_CLK_START_CLK, MMC_REG_STR_STP_CLK);
  239. mxcmci_writew(host, 0xff, MMC_REG_RES_TO);
  240. }
  241. #if IS_ENABLED(CONFIG_PPC_MPC512x)
  242. static inline void buffer_swap32(u32 *buf, int len)
  243. {
  244. int i;
  245. for (i = 0; i < ((len + 3) / 4); i++) {
  246. *buf = swab32(*buf);
  247. buf++;
  248. }
  249. }
  250. static void mxcmci_swap_buffers(struct mmc_data *data)
  251. {
  252. struct scatterlist *sg;
  253. int i;
  254. for_each_sg(data->sg, sg, data->sg_len, i)
  255. buffer_swap32(sg_virt(sg), sg->length);
  256. }
  257. #else
  258. static inline void mxcmci_swap_buffers(struct mmc_data *data) {}
  259. #endif
  260. static int mxcmci_setup_data(struct mxcmci_host *host, struct mmc_data *data)
  261. {
  262. unsigned int nob = data->blocks;
  263. unsigned int blksz = data->blksz;
  264. unsigned int datasize = nob * blksz;
  265. struct scatterlist *sg;
  266. enum dma_transfer_direction slave_dirn;
  267. int i, nents;
  268. if (data->flags & MMC_DATA_STREAM)
  269. nob = 0xffff;
  270. host->data = data;
  271. data->bytes_xfered = 0;
  272. mxcmci_writew(host, nob, MMC_REG_NOB);
  273. mxcmci_writew(host, blksz, MMC_REG_BLK_LEN);
  274. host->datasize = datasize;
  275. if (!mxcmci_use_dma(host))
  276. return 0;
  277. for_each_sg(data->sg, sg, data->sg_len, i) {
  278. if (sg->offset & 3 || sg->length & 3 || sg->length < 512) {
  279. host->do_dma = 0;
  280. return 0;
  281. }
  282. }
  283. if (data->flags & MMC_DATA_READ) {
  284. host->dma_dir = DMA_FROM_DEVICE;
  285. slave_dirn = DMA_DEV_TO_MEM;
  286. } else {
  287. host->dma_dir = DMA_TO_DEVICE;
  288. slave_dirn = DMA_MEM_TO_DEV;
  289. mxcmci_swap_buffers(data);
  290. }
  291. nents = dma_map_sg(host->dma->device->dev, data->sg,
  292. data->sg_len, host->dma_dir);
  293. if (nents != data->sg_len)
  294. return -EINVAL;
  295. host->desc = dmaengine_prep_slave_sg(host->dma,
  296. data->sg, data->sg_len, slave_dirn,
  297. DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
  298. if (!host->desc) {
  299. dma_unmap_sg(host->dma->device->dev, data->sg, data->sg_len,
  300. host->dma_dir);
  301. host->do_dma = 0;
  302. return 0; /* Fall back to PIO */
  303. }
  304. wmb();
  305. dmaengine_submit(host->desc);
  306. dma_async_issue_pending(host->dma);
  307. mod_timer(&host->watchdog, jiffies + msecs_to_jiffies(MXCMCI_TIMEOUT_MS));
  308. return 0;
  309. }
  310. static void mxcmci_cmd_done(struct mxcmci_host *host, unsigned int stat);
  311. static void mxcmci_data_done(struct mxcmci_host *host, unsigned int stat);
  312. static void mxcmci_dma_callback(void *data)
  313. {
  314. struct mxcmci_host *host = data;
  315. u32 stat;
  316. del_timer(&host->watchdog);
  317. stat = mxcmci_readl(host, MMC_REG_STATUS);
  318. dev_dbg(mmc_dev(host->mmc), "%s: 0x%08x\n", __func__, stat);
  319. mxcmci_data_done(host, stat);
  320. }
  321. static int mxcmci_start_cmd(struct mxcmci_host *host, struct mmc_command *cmd,
  322. unsigned int cmdat)
  323. {
  324. u32 int_cntr = host->default_irq_mask;
  325. unsigned long flags;
  326. WARN_ON(host->cmd != NULL);
  327. host->cmd = cmd;
  328. switch (mmc_resp_type(cmd)) {
  329. case MMC_RSP_R1: /* short CRC, OPCODE */
  330. case MMC_RSP_R1B:/* short CRC, OPCODE, BUSY */
  331. cmdat |= CMD_DAT_CONT_RESPONSE_48BIT_CRC;
  332. break;
  333. case MMC_RSP_R2: /* long 136 bit + CRC */
  334. cmdat |= CMD_DAT_CONT_RESPONSE_136BIT;
  335. break;
  336. case MMC_RSP_R3: /* short */
  337. cmdat |= CMD_DAT_CONT_RESPONSE_48BIT;
  338. break;
  339. case MMC_RSP_NONE:
  340. break;
  341. default:
  342. dev_err(mmc_dev(host->mmc), "unhandled response type 0x%x\n",
  343. mmc_resp_type(cmd));
  344. cmd->error = -EINVAL;
  345. return -EINVAL;
  346. }
  347. int_cntr = INT_END_CMD_RES_EN;
  348. if (mxcmci_use_dma(host)) {
  349. if (host->dma_dir == DMA_FROM_DEVICE) {
  350. host->desc->callback = mxcmci_dma_callback;
  351. host->desc->callback_param = host;
  352. } else {
  353. int_cntr |= INT_WRITE_OP_DONE_EN;
  354. }
  355. }
  356. spin_lock_irqsave(&host->lock, flags);
  357. if (host->use_sdio)
  358. int_cntr |= INT_SDIO_IRQ_EN;
  359. mxcmci_writel(host, int_cntr, MMC_REG_INT_CNTR);
  360. spin_unlock_irqrestore(&host->lock, flags);
  361. mxcmci_writew(host, cmd->opcode, MMC_REG_CMD);
  362. mxcmci_writel(host, cmd->arg, MMC_REG_ARG);
  363. mxcmci_writew(host, cmdat, MMC_REG_CMD_DAT_CONT);
  364. return 0;
  365. }
  366. static void mxcmci_finish_request(struct mxcmci_host *host,
  367. struct mmc_request *req)
  368. {
  369. u32 int_cntr = host->default_irq_mask;
  370. unsigned long flags;
  371. spin_lock_irqsave(&host->lock, flags);
  372. if (host->use_sdio)
  373. int_cntr |= INT_SDIO_IRQ_EN;
  374. mxcmci_writel(host, int_cntr, MMC_REG_INT_CNTR);
  375. spin_unlock_irqrestore(&host->lock, flags);
  376. host->req = NULL;
  377. host->cmd = NULL;
  378. host->data = NULL;
  379. mmc_request_done(host->mmc, req);
  380. }
  381. static int mxcmci_finish_data(struct mxcmci_host *host, unsigned int stat)
  382. {
  383. struct mmc_data *data = host->data;
  384. int data_error;
  385. if (mxcmci_use_dma(host)) {
  386. dma_unmap_sg(host->dma->device->dev, data->sg, data->sg_len,
  387. host->dma_dir);
  388. mxcmci_swap_buffers(data);
  389. }
  390. if (stat & STATUS_ERR_MASK) {
  391. dev_dbg(mmc_dev(host->mmc), "request failed. status: 0x%08x\n",
  392. stat);
  393. if (stat & STATUS_CRC_READ_ERR) {
  394. dev_err(mmc_dev(host->mmc), "%s: -EILSEQ\n", __func__);
  395. data->error = -EILSEQ;
  396. } else if (stat & STATUS_CRC_WRITE_ERR) {
  397. u32 err_code = (stat >> 9) & 0x3;
  398. if (err_code == 2) { /* No CRC response */
  399. dev_err(mmc_dev(host->mmc),
  400. "%s: No CRC -ETIMEDOUT\n", __func__);
  401. data->error = -ETIMEDOUT;
  402. } else {
  403. dev_err(mmc_dev(host->mmc),
  404. "%s: -EILSEQ\n", __func__);
  405. data->error = -EILSEQ;
  406. }
  407. } else if (stat & STATUS_TIME_OUT_READ) {
  408. dev_err(mmc_dev(host->mmc),
  409. "%s: read -ETIMEDOUT\n", __func__);
  410. data->error = -ETIMEDOUT;
  411. } else {
  412. dev_err(mmc_dev(host->mmc), "%s: -EIO\n", __func__);
  413. data->error = -EIO;
  414. }
  415. } else {
  416. data->bytes_xfered = host->datasize;
  417. }
  418. data_error = data->error;
  419. host->data = NULL;
  420. return data_error;
  421. }
  422. static void mxcmci_read_response(struct mxcmci_host *host, unsigned int stat)
  423. {
  424. struct mmc_command *cmd = host->cmd;
  425. int i;
  426. u32 a, b, c;
  427. if (!cmd)
  428. return;
  429. if (stat & STATUS_TIME_OUT_RESP) {
  430. dev_dbg(mmc_dev(host->mmc), "CMD TIMEOUT\n");
  431. cmd->error = -ETIMEDOUT;
  432. } else if (stat & STATUS_RESP_CRC_ERR && cmd->flags & MMC_RSP_CRC) {
  433. dev_dbg(mmc_dev(host->mmc), "cmd crc error\n");
  434. cmd->error = -EILSEQ;
  435. }
  436. if (cmd->flags & MMC_RSP_PRESENT) {
  437. if (cmd->flags & MMC_RSP_136) {
  438. for (i = 0; i < 4; i++) {
  439. a = mxcmci_readw(host, MMC_REG_RES_FIFO);
  440. b = mxcmci_readw(host, MMC_REG_RES_FIFO);
  441. cmd->resp[i] = a << 16 | b;
  442. }
  443. } else {
  444. a = mxcmci_readw(host, MMC_REG_RES_FIFO);
  445. b = mxcmci_readw(host, MMC_REG_RES_FIFO);
  446. c = mxcmci_readw(host, MMC_REG_RES_FIFO);
  447. cmd->resp[0] = a << 24 | b << 8 | c >> 8;
  448. }
  449. }
  450. }
  451. static int mxcmci_poll_status(struct mxcmci_host *host, u32 mask)
  452. {
  453. u32 stat;
  454. unsigned long timeout = jiffies + HZ;
  455. do {
  456. stat = mxcmci_readl(host, MMC_REG_STATUS);
  457. if (stat & STATUS_ERR_MASK)
  458. return stat;
  459. if (time_after(jiffies, timeout)) {
  460. mxcmci_softreset(host);
  461. mxcmci_set_clk_rate(host, host->clock);
  462. return STATUS_TIME_OUT_READ;
  463. }
  464. if (stat & mask)
  465. return 0;
  466. cpu_relax();
  467. } while (1);
  468. }
  469. static int mxcmci_pull(struct mxcmci_host *host, void *_buf, int bytes)
  470. {
  471. unsigned int stat;
  472. u32 *buf = _buf;
  473. while (bytes > 3) {
  474. stat = mxcmci_poll_status(host,
  475. STATUS_BUF_READ_RDY | STATUS_READ_OP_DONE);
  476. if (stat)
  477. return stat;
  478. *buf++ = cpu_to_le32(mxcmci_readl(host, MMC_REG_BUFFER_ACCESS));
  479. bytes -= 4;
  480. }
  481. if (bytes) {
  482. u8 *b = (u8 *)buf;
  483. u32 tmp;
  484. stat = mxcmci_poll_status(host,
  485. STATUS_BUF_READ_RDY | STATUS_READ_OP_DONE);
  486. if (stat)
  487. return stat;
  488. tmp = cpu_to_le32(mxcmci_readl(host, MMC_REG_BUFFER_ACCESS));
  489. memcpy(b, &tmp, bytes);
  490. }
  491. return 0;
  492. }
  493. static int mxcmci_push(struct mxcmci_host *host, void *_buf, int bytes)
  494. {
  495. unsigned int stat;
  496. u32 *buf = _buf;
  497. while (bytes > 3) {
  498. stat = mxcmci_poll_status(host, STATUS_BUF_WRITE_RDY);
  499. if (stat)
  500. return stat;
  501. mxcmci_writel(host, cpu_to_le32(*buf++), MMC_REG_BUFFER_ACCESS);
  502. bytes -= 4;
  503. }
  504. if (bytes) {
  505. u8 *b = (u8 *)buf;
  506. u32 tmp;
  507. stat = mxcmci_poll_status(host, STATUS_BUF_WRITE_RDY);
  508. if (stat)
  509. return stat;
  510. memcpy(&tmp, b, bytes);
  511. mxcmci_writel(host, cpu_to_le32(tmp), MMC_REG_BUFFER_ACCESS);
  512. }
  513. return mxcmci_poll_status(host, STATUS_BUF_WRITE_RDY);
  514. }
  515. static int mxcmci_transfer_data(struct mxcmci_host *host)
  516. {
  517. struct mmc_data *data = host->req->data;
  518. struct scatterlist *sg;
  519. int stat, i;
  520. host->data = data;
  521. host->datasize = 0;
  522. if (data->flags & MMC_DATA_READ) {
  523. for_each_sg(data->sg, sg, data->sg_len, i) {
  524. stat = mxcmci_pull(host, sg_virt(sg), sg->length);
  525. if (stat)
  526. return stat;
  527. host->datasize += sg->length;
  528. }
  529. } else {
  530. for_each_sg(data->sg, sg, data->sg_len, i) {
  531. stat = mxcmci_push(host, sg_virt(sg), sg->length);
  532. if (stat)
  533. return stat;
  534. host->datasize += sg->length;
  535. }
  536. stat = mxcmci_poll_status(host, STATUS_WRITE_OP_DONE);
  537. if (stat)
  538. return stat;
  539. }
  540. return 0;
  541. }
  542. static void mxcmci_datawork(struct work_struct *work)
  543. {
  544. struct mxcmci_host *host = container_of(work, struct mxcmci_host,
  545. datawork);
  546. int datastat = mxcmci_transfer_data(host);
  547. mxcmci_writel(host, STATUS_READ_OP_DONE | STATUS_WRITE_OP_DONE,
  548. MMC_REG_STATUS);
  549. mxcmci_finish_data(host, datastat);
  550. if (host->req->stop) {
  551. if (mxcmci_start_cmd(host, host->req->stop, 0)) {
  552. mxcmci_finish_request(host, host->req);
  553. return;
  554. }
  555. } else {
  556. mxcmci_finish_request(host, host->req);
  557. }
  558. }
  559. static void mxcmci_data_done(struct mxcmci_host *host, unsigned int stat)
  560. {
  561. struct mmc_request *req;
  562. int data_error;
  563. unsigned long flags;
  564. spin_lock_irqsave(&host->lock, flags);
  565. if (!host->data) {
  566. spin_unlock_irqrestore(&host->lock, flags);
  567. return;
  568. }
  569. if (!host->req) {
  570. spin_unlock_irqrestore(&host->lock, flags);
  571. return;
  572. }
  573. req = host->req;
  574. if (!req->stop)
  575. host->req = NULL; /* we will handle finish req below */
  576. data_error = mxcmci_finish_data(host, stat);
  577. spin_unlock_irqrestore(&host->lock, flags);
  578. mxcmci_read_response(host, stat);
  579. host->cmd = NULL;
  580. if (req->stop) {
  581. if (mxcmci_start_cmd(host, req->stop, 0)) {
  582. mxcmci_finish_request(host, req);
  583. return;
  584. }
  585. } else {
  586. mxcmci_finish_request(host, req);
  587. }
  588. }
  589. static void mxcmci_cmd_done(struct mxcmci_host *host, unsigned int stat)
  590. {
  591. mxcmci_read_response(host, stat);
  592. host->cmd = NULL;
  593. if (!host->data && host->req) {
  594. mxcmci_finish_request(host, host->req);
  595. return;
  596. }
  597. /* For the DMA case the DMA engine handles the data transfer
  598. * automatically. For non DMA we have to do it ourselves.
  599. * Don't do it in interrupt context though.
  600. */
  601. if (!mxcmci_use_dma(host) && host->data)
  602. schedule_work(&host->datawork);
  603. }
  604. static irqreturn_t mxcmci_irq(int irq, void *devid)
  605. {
  606. struct mxcmci_host *host = devid;
  607. unsigned long flags;
  608. bool sdio_irq;
  609. u32 stat;
  610. stat = mxcmci_readl(host, MMC_REG_STATUS);
  611. mxcmci_writel(host,
  612. stat & ~(STATUS_SDIO_INT_ACTIVE | STATUS_DATA_TRANS_DONE |
  613. STATUS_WRITE_OP_DONE),
  614. MMC_REG_STATUS);
  615. dev_dbg(mmc_dev(host->mmc), "%s: 0x%08x\n", __func__, stat);
  616. spin_lock_irqsave(&host->lock, flags);
  617. sdio_irq = (stat & STATUS_SDIO_INT_ACTIVE) && host->use_sdio;
  618. spin_unlock_irqrestore(&host->lock, flags);
  619. if (mxcmci_use_dma(host) && (stat & (STATUS_WRITE_OP_DONE)))
  620. mxcmci_writel(host, STATUS_WRITE_OP_DONE, MMC_REG_STATUS);
  621. if (sdio_irq) {
  622. mxcmci_writel(host, STATUS_SDIO_INT_ACTIVE, MMC_REG_STATUS);
  623. mmc_signal_sdio_irq(host->mmc);
  624. }
  625. if (stat & STATUS_END_CMD_RESP)
  626. mxcmci_cmd_done(host, stat);
  627. if (mxcmci_use_dma(host) && (stat & STATUS_WRITE_OP_DONE)) {
  628. del_timer(&host->watchdog);
  629. mxcmci_data_done(host, stat);
  630. }
  631. if (host->default_irq_mask &&
  632. (stat & (STATUS_CARD_INSERTION | STATUS_CARD_REMOVAL)))
  633. mmc_detect_change(host->mmc, msecs_to_jiffies(200));
  634. return IRQ_HANDLED;
  635. }
  636. static void mxcmci_request(struct mmc_host *mmc, struct mmc_request *req)
  637. {
  638. struct mxcmci_host *host = mmc_priv(mmc);
  639. unsigned int cmdat = host->cmdat;
  640. int error;
  641. WARN_ON(host->req != NULL);
  642. host->req = req;
  643. host->cmdat &= ~CMD_DAT_CONT_INIT;
  644. if (host->dma)
  645. host->do_dma = 1;
  646. if (req->data) {
  647. error = mxcmci_setup_data(host, req->data);
  648. if (error) {
  649. req->cmd->error = error;
  650. goto out;
  651. }
  652. cmdat |= CMD_DAT_CONT_DATA_ENABLE;
  653. if (req->data->flags & MMC_DATA_WRITE)
  654. cmdat |= CMD_DAT_CONT_WRITE;
  655. }
  656. error = mxcmci_start_cmd(host, req->cmd, cmdat);
  657. out:
  658. if (error)
  659. mxcmci_finish_request(host, req);
  660. }
  661. static void mxcmci_set_clk_rate(struct mxcmci_host *host, unsigned int clk_ios)
  662. {
  663. unsigned int divider;
  664. int prescaler = 0;
  665. unsigned int clk_in = clk_get_rate(host->clk_per);
  666. while (prescaler <= 0x800) {
  667. for (divider = 1; divider <= 0xF; divider++) {
  668. int x;
  669. x = (clk_in / (divider + 1));
  670. if (prescaler)
  671. x /= (prescaler * 2);
  672. if (x <= clk_ios)
  673. break;
  674. }
  675. if (divider < 0x10)
  676. break;
  677. if (prescaler == 0)
  678. prescaler = 1;
  679. else
  680. prescaler <<= 1;
  681. }
  682. mxcmci_writew(host, (prescaler << 4) | divider, MMC_REG_CLK_RATE);
  683. dev_dbg(mmc_dev(host->mmc), "scaler: %d divider: %d in: %d out: %d\n",
  684. prescaler, divider, clk_in, clk_ios);
  685. }
  686. static int mxcmci_setup_dma(struct mmc_host *mmc)
  687. {
  688. struct mxcmci_host *host = mmc_priv(mmc);
  689. struct dma_slave_config *config = &host->dma_slave_config;
  690. config->dst_addr = host->phys_base + MMC_REG_BUFFER_ACCESS;
  691. config->src_addr = host->phys_base + MMC_REG_BUFFER_ACCESS;
  692. config->dst_addr_width = 4;
  693. config->src_addr_width = 4;
  694. config->dst_maxburst = host->burstlen;
  695. config->src_maxburst = host->burstlen;
  696. config->device_fc = false;
  697. return dmaengine_slave_config(host->dma, config);
  698. }
  699. static void mxcmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
  700. {
  701. struct mxcmci_host *host = mmc_priv(mmc);
  702. int burstlen, ret;
  703. /*
  704. * use burstlen of 64 (16 words) in 4 bit mode (--> reg value 0)
  705. * use burstlen of 16 (4 words) in 1 bit mode (--> reg value 16)
  706. */
  707. if (ios->bus_width == MMC_BUS_WIDTH_4)
  708. burstlen = 16;
  709. else
  710. burstlen = 4;
  711. if (mxcmci_use_dma(host) && burstlen != host->burstlen) {
  712. host->burstlen = burstlen;
  713. ret = mxcmci_setup_dma(mmc);
  714. if (ret) {
  715. dev_err(mmc_dev(host->mmc),
  716. "failed to config DMA channel. Falling back to PIO\n");
  717. dma_release_channel(host->dma);
  718. host->do_dma = 0;
  719. host->dma = NULL;
  720. }
  721. }
  722. if (ios->bus_width == MMC_BUS_WIDTH_4)
  723. host->cmdat |= CMD_DAT_CONT_BUS_WIDTH_4;
  724. else
  725. host->cmdat &= ~CMD_DAT_CONT_BUS_WIDTH_4;
  726. if (host->power_mode != ios->power_mode) {
  727. host->power_mode = ios->power_mode;
  728. mxcmci_set_power(host, ios->vdd);
  729. if (ios->power_mode == MMC_POWER_ON)
  730. host->cmdat |= CMD_DAT_CONT_INIT;
  731. }
  732. if (ios->clock) {
  733. mxcmci_set_clk_rate(host, ios->clock);
  734. mxcmci_writew(host, STR_STP_CLK_START_CLK, MMC_REG_STR_STP_CLK);
  735. } else {
  736. mxcmci_writew(host, STR_STP_CLK_STOP_CLK, MMC_REG_STR_STP_CLK);
  737. }
  738. host->clock = ios->clock;
  739. }
  740. static irqreturn_t mxcmci_detect_irq(int irq, void *data)
  741. {
  742. struct mmc_host *mmc = data;
  743. dev_dbg(mmc_dev(mmc), "%s\n", __func__);
  744. mmc_detect_change(mmc, msecs_to_jiffies(250));
  745. return IRQ_HANDLED;
  746. }
  747. static int mxcmci_get_ro(struct mmc_host *mmc)
  748. {
  749. struct mxcmci_host *host = mmc_priv(mmc);
  750. if (host->pdata && host->pdata->get_ro)
  751. return !!host->pdata->get_ro(mmc_dev(mmc));
  752. /*
  753. * If board doesn't support read only detection (no mmc_gpio
  754. * context or gpio is invalid), then let the mmc core decide
  755. * what to do.
  756. */
  757. return mmc_gpio_get_ro(mmc);
  758. }
  759. static void mxcmci_enable_sdio_irq(struct mmc_host *mmc, int enable)
  760. {
  761. struct mxcmci_host *host = mmc_priv(mmc);
  762. unsigned long flags;
  763. u32 int_cntr;
  764. spin_lock_irqsave(&host->lock, flags);
  765. host->use_sdio = enable;
  766. int_cntr = mxcmci_readl(host, MMC_REG_INT_CNTR);
  767. if (enable)
  768. int_cntr |= INT_SDIO_IRQ_EN;
  769. else
  770. int_cntr &= ~INT_SDIO_IRQ_EN;
  771. mxcmci_writel(host, int_cntr, MMC_REG_INT_CNTR);
  772. spin_unlock_irqrestore(&host->lock, flags);
  773. }
  774. static void mxcmci_init_card(struct mmc_host *host, struct mmc_card *card)
  775. {
  776. struct mxcmci_host *mxcmci = mmc_priv(host);
  777. /*
  778. * MX3 SoCs have a silicon bug which corrupts CRC calculation of
  779. * multi-block transfers when connected SDIO peripheral doesn't
  780. * drive the BUSY line as required by the specs.
  781. * One way to prevent this is to only allow 1-bit transfers.
  782. */
  783. if (is_imx31_mmc(mxcmci) && card->type == MMC_TYPE_SDIO)
  784. host->caps &= ~MMC_CAP_4_BIT_DATA;
  785. else
  786. host->caps |= MMC_CAP_4_BIT_DATA;
  787. }
  788. static bool filter(struct dma_chan *chan, void *param)
  789. {
  790. struct mxcmci_host *host = param;
  791. if (!imx_dma_is_general_purpose(chan))
  792. return false;
  793. chan->private = &host->dma_data;
  794. return true;
  795. }
  796. static void mxcmci_watchdog(unsigned long data)
  797. {
  798. struct mmc_host *mmc = (struct mmc_host *)data;
  799. struct mxcmci_host *host = mmc_priv(mmc);
  800. struct mmc_request *req = host->req;
  801. unsigned int stat = mxcmci_readl(host, MMC_REG_STATUS);
  802. if (host->dma_dir == DMA_FROM_DEVICE) {
  803. dmaengine_terminate_all(host->dma);
  804. dev_err(mmc_dev(host->mmc),
  805. "%s: read time out (status = 0x%08x)\n",
  806. __func__, stat);
  807. } else {
  808. dev_err(mmc_dev(host->mmc),
  809. "%s: write time out (status = 0x%08x)\n",
  810. __func__, stat);
  811. mxcmci_softreset(host);
  812. }
  813. /* Mark transfer as erroneus and inform the upper layers */
  814. if (host->data)
  815. host->data->error = -ETIMEDOUT;
  816. host->req = NULL;
  817. host->cmd = NULL;
  818. host->data = NULL;
  819. mmc_request_done(host->mmc, req);
  820. }
  821. static const struct mmc_host_ops mxcmci_ops = {
  822. .request = mxcmci_request,
  823. .set_ios = mxcmci_set_ios,
  824. .get_ro = mxcmci_get_ro,
  825. .enable_sdio_irq = mxcmci_enable_sdio_irq,
  826. .init_card = mxcmci_init_card,
  827. };
  828. static int mxcmci_probe(struct platform_device *pdev)
  829. {
  830. struct mmc_host *mmc;
  831. struct mxcmci_host *host;
  832. struct resource *res;
  833. int ret = 0, irq;
  834. bool dat3_card_detect = false;
  835. dma_cap_mask_t mask;
  836. const struct of_device_id *of_id;
  837. struct imxmmc_platform_data *pdata = pdev->dev.platform_data;
  838. pr_info("i.MX/MPC512x SDHC driver\n");
  839. of_id = of_match_device(mxcmci_of_match, &pdev->dev);
  840. res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  841. irq = platform_get_irq(pdev, 0);
  842. if (irq < 0)
  843. return -EINVAL;
  844. mmc = mmc_alloc_host(sizeof(*host), &pdev->dev);
  845. if (!mmc)
  846. return -ENOMEM;
  847. host = mmc_priv(mmc);
  848. host->base = devm_ioremap_resource(&pdev->dev, res);
  849. if (IS_ERR(host->base)) {
  850. ret = PTR_ERR(host->base);
  851. goto out_free;
  852. }
  853. host->phys_base = res->start;
  854. ret = mmc_of_parse(mmc);
  855. if (ret)
  856. goto out_free;
  857. mmc->ops = &mxcmci_ops;
  858. /* For devicetree parsing, the bus width is read from devicetree */
  859. if (pdata)
  860. mmc->caps = MMC_CAP_4_BIT_DATA | MMC_CAP_SDIO_IRQ;
  861. else
  862. mmc->caps |= MMC_CAP_SDIO_IRQ;
  863. /* MMC core transfer sizes tunable parameters */
  864. mmc->max_blk_size = 2048;
  865. mmc->max_blk_count = 65535;
  866. mmc->max_req_size = mmc->max_blk_size * mmc->max_blk_count;
  867. mmc->max_seg_size = mmc->max_req_size;
  868. if (of_id) {
  869. const struct platform_device_id *id_entry = of_id->data;
  870. host->devtype = id_entry->driver_data;
  871. } else {
  872. host->devtype = pdev->id_entry->driver_data;
  873. }
  874. /* adjust max_segs after devtype detection */
  875. if (!is_mpc512x_mmc(host))
  876. mmc->max_segs = 64;
  877. host->mmc = mmc;
  878. host->pdata = pdata;
  879. spin_lock_init(&host->lock);
  880. if (pdata)
  881. dat3_card_detect = pdata->dat3_card_detect;
  882. else if (!(mmc->caps & MMC_CAP_NONREMOVABLE)
  883. && !of_property_read_bool(pdev->dev.of_node, "cd-gpios"))
  884. dat3_card_detect = true;
  885. ret = mmc_regulator_get_supply(mmc);
  886. if (ret == -EPROBE_DEFER)
  887. goto out_free;
  888. if (!mmc->ocr_avail) {
  889. if (pdata && pdata->ocr_avail)
  890. mmc->ocr_avail = pdata->ocr_avail;
  891. else
  892. mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34;
  893. }
  894. if (dat3_card_detect)
  895. host->default_irq_mask =
  896. INT_CARD_INSERTION_EN | INT_CARD_REMOVAL_EN;
  897. else
  898. host->default_irq_mask = 0;
  899. host->clk_ipg = devm_clk_get(&pdev->dev, "ipg");
  900. if (IS_ERR(host->clk_ipg)) {
  901. ret = PTR_ERR(host->clk_ipg);
  902. goto out_free;
  903. }
  904. host->clk_per = devm_clk_get(&pdev->dev, "per");
  905. if (IS_ERR(host->clk_per)) {
  906. ret = PTR_ERR(host->clk_per);
  907. goto out_free;
  908. }
  909. clk_prepare_enable(host->clk_per);
  910. clk_prepare_enable(host->clk_ipg);
  911. mxcmci_softreset(host);
  912. host->rev_no = mxcmci_readw(host, MMC_REG_REV_NO);
  913. if (host->rev_no != 0x400) {
  914. ret = -ENODEV;
  915. dev_err(mmc_dev(host->mmc), "wrong rev.no. 0x%08x. aborting.\n",
  916. host->rev_no);
  917. goto out_clk_put;
  918. }
  919. mmc->f_min = clk_get_rate(host->clk_per) >> 16;
  920. mmc->f_max = clk_get_rate(host->clk_per) >> 1;
  921. /* recommended in data sheet */
  922. mxcmci_writew(host, 0x2db4, MMC_REG_READ_TO);
  923. mxcmci_writel(host, host->default_irq_mask, MMC_REG_INT_CNTR);
  924. if (!host->pdata) {
  925. host->dma = dma_request_slave_channel(&pdev->dev, "rx-tx");
  926. } else {
  927. res = platform_get_resource(pdev, IORESOURCE_DMA, 0);
  928. if (res) {
  929. host->dmareq = res->start;
  930. host->dma_data.peripheral_type = IMX_DMATYPE_SDHC;
  931. host->dma_data.priority = DMA_PRIO_LOW;
  932. host->dma_data.dma_request = host->dmareq;
  933. dma_cap_zero(mask);
  934. dma_cap_set(DMA_SLAVE, mask);
  935. host->dma = dma_request_channel(mask, filter, host);
  936. }
  937. }
  938. if (host->dma)
  939. mmc->max_seg_size = dma_get_max_seg_size(
  940. host->dma->device->dev);
  941. else
  942. dev_info(mmc_dev(host->mmc), "dma not available. Using PIO\n");
  943. INIT_WORK(&host->datawork, mxcmci_datawork);
  944. ret = devm_request_irq(&pdev->dev, irq, mxcmci_irq, 0,
  945. dev_name(&pdev->dev), host);
  946. if (ret)
  947. goto out_free_dma;
  948. platform_set_drvdata(pdev, mmc);
  949. if (host->pdata && host->pdata->init) {
  950. ret = host->pdata->init(&pdev->dev, mxcmci_detect_irq,
  951. host->mmc);
  952. if (ret)
  953. goto out_free_dma;
  954. }
  955. init_timer(&host->watchdog);
  956. host->watchdog.function = &mxcmci_watchdog;
  957. host->watchdog.data = (unsigned long)mmc;
  958. mmc_add_host(mmc);
  959. return 0;
  960. out_free_dma:
  961. if (host->dma)
  962. dma_release_channel(host->dma);
  963. out_clk_put:
  964. clk_disable_unprepare(host->clk_per);
  965. clk_disable_unprepare(host->clk_ipg);
  966. out_free:
  967. mmc_free_host(mmc);
  968. return ret;
  969. }
  970. static int mxcmci_remove(struct platform_device *pdev)
  971. {
  972. struct mmc_host *mmc = platform_get_drvdata(pdev);
  973. struct mxcmci_host *host = mmc_priv(mmc);
  974. mmc_remove_host(mmc);
  975. if (host->pdata && host->pdata->exit)
  976. host->pdata->exit(&pdev->dev, mmc);
  977. if (host->dma)
  978. dma_release_channel(host->dma);
  979. clk_disable_unprepare(host->clk_per);
  980. clk_disable_unprepare(host->clk_ipg);
  981. mmc_free_host(mmc);
  982. return 0;
  983. }
  984. static int __maybe_unused mxcmci_suspend(struct device *dev)
  985. {
  986. struct mmc_host *mmc = dev_get_drvdata(dev);
  987. struct mxcmci_host *host = mmc_priv(mmc);
  988. clk_disable_unprepare(host->clk_per);
  989. clk_disable_unprepare(host->clk_ipg);
  990. return 0;
  991. }
  992. static int __maybe_unused mxcmci_resume(struct device *dev)
  993. {
  994. struct mmc_host *mmc = dev_get_drvdata(dev);
  995. struct mxcmci_host *host = mmc_priv(mmc);
  996. clk_prepare_enable(host->clk_per);
  997. clk_prepare_enable(host->clk_ipg);
  998. return 0;
  999. }
  1000. static SIMPLE_DEV_PM_OPS(mxcmci_pm_ops, mxcmci_suspend, mxcmci_resume);
  1001. static struct platform_driver mxcmci_driver = {
  1002. .probe = mxcmci_probe,
  1003. .remove = mxcmci_remove,
  1004. .id_table = mxcmci_devtype,
  1005. .driver = {
  1006. .name = DRIVER_NAME,
  1007. .pm = &mxcmci_pm_ops,
  1008. .of_match_table = mxcmci_of_match,
  1009. }
  1010. };
  1011. module_platform_driver(mxcmci_driver);
  1012. MODULE_DESCRIPTION("i.MX Multimedia Card Interface Driver");
  1013. MODULE_AUTHOR("Sascha Hauer, Pengutronix");
  1014. MODULE_LICENSE("GPL");
  1015. MODULE_ALIAS("platform:mxc-mmc");