mxcmmc.c 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252
  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. st_le32(buf, *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. mxcmci_writel(host, stat & ~STATUS_DATA_TRANS_DONE, MMC_REG_STATUS);
  319. dev_dbg(mmc_dev(host->mmc), "%s: 0x%08x\n", __func__, stat);
  320. if (stat & STATUS_READ_OP_DONE)
  321. mxcmci_writel(host, STATUS_READ_OP_DONE, MMC_REG_STATUS);
  322. mxcmci_data_done(host, stat);
  323. }
  324. static int mxcmci_start_cmd(struct mxcmci_host *host, struct mmc_command *cmd,
  325. unsigned int cmdat)
  326. {
  327. u32 int_cntr = host->default_irq_mask;
  328. unsigned long flags;
  329. WARN_ON(host->cmd != NULL);
  330. host->cmd = cmd;
  331. switch (mmc_resp_type(cmd)) {
  332. case MMC_RSP_R1: /* short CRC, OPCODE */
  333. case MMC_RSP_R1B:/* short CRC, OPCODE, BUSY */
  334. cmdat |= CMD_DAT_CONT_RESPONSE_48BIT_CRC;
  335. break;
  336. case MMC_RSP_R2: /* long 136 bit + CRC */
  337. cmdat |= CMD_DAT_CONT_RESPONSE_136BIT;
  338. break;
  339. case MMC_RSP_R3: /* short */
  340. cmdat |= CMD_DAT_CONT_RESPONSE_48BIT;
  341. break;
  342. case MMC_RSP_NONE:
  343. break;
  344. default:
  345. dev_err(mmc_dev(host->mmc), "unhandled response type 0x%x\n",
  346. mmc_resp_type(cmd));
  347. cmd->error = -EINVAL;
  348. return -EINVAL;
  349. }
  350. int_cntr = INT_END_CMD_RES_EN;
  351. if (mxcmci_use_dma(host)) {
  352. if (host->dma_dir == DMA_FROM_DEVICE) {
  353. host->desc->callback = mxcmci_dma_callback;
  354. host->desc->callback_param = host;
  355. } else {
  356. int_cntr |= INT_WRITE_OP_DONE_EN;
  357. }
  358. }
  359. spin_lock_irqsave(&host->lock, flags);
  360. if (host->use_sdio)
  361. int_cntr |= INT_SDIO_IRQ_EN;
  362. mxcmci_writel(host, int_cntr, MMC_REG_INT_CNTR);
  363. spin_unlock_irqrestore(&host->lock, flags);
  364. mxcmci_writew(host, cmd->opcode, MMC_REG_CMD);
  365. mxcmci_writel(host, cmd->arg, MMC_REG_ARG);
  366. mxcmci_writew(host, cmdat, MMC_REG_CMD_DAT_CONT);
  367. return 0;
  368. }
  369. static void mxcmci_finish_request(struct mxcmci_host *host,
  370. struct mmc_request *req)
  371. {
  372. u32 int_cntr = host->default_irq_mask;
  373. unsigned long flags;
  374. spin_lock_irqsave(&host->lock, flags);
  375. if (host->use_sdio)
  376. int_cntr |= INT_SDIO_IRQ_EN;
  377. mxcmci_writel(host, int_cntr, MMC_REG_INT_CNTR);
  378. spin_unlock_irqrestore(&host->lock, flags);
  379. host->req = NULL;
  380. host->cmd = NULL;
  381. host->data = NULL;
  382. mmc_request_done(host->mmc, req);
  383. }
  384. static int mxcmci_finish_data(struct mxcmci_host *host, unsigned int stat)
  385. {
  386. struct mmc_data *data = host->data;
  387. int data_error;
  388. if (mxcmci_use_dma(host)) {
  389. dma_unmap_sg(host->dma->device->dev, data->sg, data->sg_len,
  390. host->dma_dir);
  391. mxcmci_swap_buffers(data);
  392. }
  393. if (stat & STATUS_ERR_MASK) {
  394. dev_dbg(mmc_dev(host->mmc), "request failed. status: 0x%08x\n",
  395. stat);
  396. if (stat & STATUS_CRC_READ_ERR) {
  397. dev_err(mmc_dev(host->mmc), "%s: -EILSEQ\n", __func__);
  398. data->error = -EILSEQ;
  399. } else if (stat & STATUS_CRC_WRITE_ERR) {
  400. u32 err_code = (stat >> 9) & 0x3;
  401. if (err_code == 2) { /* No CRC response */
  402. dev_err(mmc_dev(host->mmc),
  403. "%s: No CRC -ETIMEDOUT\n", __func__);
  404. data->error = -ETIMEDOUT;
  405. } else {
  406. dev_err(mmc_dev(host->mmc),
  407. "%s: -EILSEQ\n", __func__);
  408. data->error = -EILSEQ;
  409. }
  410. } else if (stat & STATUS_TIME_OUT_READ) {
  411. dev_err(mmc_dev(host->mmc),
  412. "%s: read -ETIMEDOUT\n", __func__);
  413. data->error = -ETIMEDOUT;
  414. } else {
  415. dev_err(mmc_dev(host->mmc), "%s: -EIO\n", __func__);
  416. data->error = -EIO;
  417. }
  418. } else {
  419. data->bytes_xfered = host->datasize;
  420. }
  421. data_error = data->error;
  422. host->data = NULL;
  423. return data_error;
  424. }
  425. static void mxcmci_read_response(struct mxcmci_host *host, unsigned int stat)
  426. {
  427. struct mmc_command *cmd = host->cmd;
  428. int i;
  429. u32 a, b, c;
  430. if (!cmd)
  431. return;
  432. if (stat & STATUS_TIME_OUT_RESP) {
  433. dev_dbg(mmc_dev(host->mmc), "CMD TIMEOUT\n");
  434. cmd->error = -ETIMEDOUT;
  435. } else if (stat & STATUS_RESP_CRC_ERR && cmd->flags & MMC_RSP_CRC) {
  436. dev_dbg(mmc_dev(host->mmc), "cmd crc error\n");
  437. cmd->error = -EILSEQ;
  438. }
  439. if (cmd->flags & MMC_RSP_PRESENT) {
  440. if (cmd->flags & MMC_RSP_136) {
  441. for (i = 0; i < 4; i++) {
  442. a = mxcmci_readw(host, MMC_REG_RES_FIFO);
  443. b = mxcmci_readw(host, MMC_REG_RES_FIFO);
  444. cmd->resp[i] = a << 16 | b;
  445. }
  446. } else {
  447. a = mxcmci_readw(host, MMC_REG_RES_FIFO);
  448. b = mxcmci_readw(host, MMC_REG_RES_FIFO);
  449. c = mxcmci_readw(host, MMC_REG_RES_FIFO);
  450. cmd->resp[0] = a << 24 | b << 8 | c >> 8;
  451. }
  452. }
  453. }
  454. static int mxcmci_poll_status(struct mxcmci_host *host, u32 mask)
  455. {
  456. u32 stat;
  457. unsigned long timeout = jiffies + HZ;
  458. do {
  459. stat = mxcmci_readl(host, MMC_REG_STATUS);
  460. if (stat & STATUS_ERR_MASK)
  461. return stat;
  462. if (time_after(jiffies, timeout)) {
  463. mxcmci_softreset(host);
  464. mxcmci_set_clk_rate(host, host->clock);
  465. return STATUS_TIME_OUT_READ;
  466. }
  467. if (stat & mask)
  468. return 0;
  469. cpu_relax();
  470. } while (1);
  471. }
  472. static int mxcmci_pull(struct mxcmci_host *host, void *_buf, int bytes)
  473. {
  474. unsigned int stat;
  475. u32 *buf = _buf;
  476. while (bytes > 3) {
  477. stat = mxcmci_poll_status(host,
  478. STATUS_BUF_READ_RDY | STATUS_READ_OP_DONE);
  479. if (stat)
  480. return stat;
  481. *buf++ = cpu_to_le32(mxcmci_readl(host, MMC_REG_BUFFER_ACCESS));
  482. bytes -= 4;
  483. }
  484. if (bytes) {
  485. u8 *b = (u8 *)buf;
  486. u32 tmp;
  487. stat = mxcmci_poll_status(host,
  488. STATUS_BUF_READ_RDY | STATUS_READ_OP_DONE);
  489. if (stat)
  490. return stat;
  491. tmp = cpu_to_le32(mxcmci_readl(host, MMC_REG_BUFFER_ACCESS));
  492. memcpy(b, &tmp, bytes);
  493. }
  494. return 0;
  495. }
  496. static int mxcmci_push(struct mxcmci_host *host, void *_buf, int bytes)
  497. {
  498. unsigned int stat;
  499. u32 *buf = _buf;
  500. while (bytes > 3) {
  501. stat = mxcmci_poll_status(host, STATUS_BUF_WRITE_RDY);
  502. if (stat)
  503. return stat;
  504. mxcmci_writel(host, cpu_to_le32(*buf++), MMC_REG_BUFFER_ACCESS);
  505. bytes -= 4;
  506. }
  507. if (bytes) {
  508. u8 *b = (u8 *)buf;
  509. u32 tmp;
  510. stat = mxcmci_poll_status(host, STATUS_BUF_WRITE_RDY);
  511. if (stat)
  512. return stat;
  513. memcpy(&tmp, b, bytes);
  514. mxcmci_writel(host, cpu_to_le32(tmp), MMC_REG_BUFFER_ACCESS);
  515. }
  516. stat = mxcmci_poll_status(host, STATUS_BUF_WRITE_RDY);
  517. if (stat)
  518. return stat;
  519. return 0;
  520. }
  521. static int mxcmci_transfer_data(struct mxcmci_host *host)
  522. {
  523. struct mmc_data *data = host->req->data;
  524. struct scatterlist *sg;
  525. int stat, i;
  526. host->data = data;
  527. host->datasize = 0;
  528. if (data->flags & MMC_DATA_READ) {
  529. for_each_sg(data->sg, sg, data->sg_len, i) {
  530. stat = mxcmci_pull(host, sg_virt(sg), sg->length);
  531. if (stat)
  532. return stat;
  533. host->datasize += sg->length;
  534. }
  535. } else {
  536. for_each_sg(data->sg, sg, data->sg_len, i) {
  537. stat = mxcmci_push(host, sg_virt(sg), sg->length);
  538. if (stat)
  539. return stat;
  540. host->datasize += sg->length;
  541. }
  542. stat = mxcmci_poll_status(host, STATUS_WRITE_OP_DONE);
  543. if (stat)
  544. return stat;
  545. }
  546. return 0;
  547. }
  548. static void mxcmci_datawork(struct work_struct *work)
  549. {
  550. struct mxcmci_host *host = container_of(work, struct mxcmci_host,
  551. datawork);
  552. int datastat = mxcmci_transfer_data(host);
  553. mxcmci_writel(host, STATUS_READ_OP_DONE | STATUS_WRITE_OP_DONE,
  554. MMC_REG_STATUS);
  555. mxcmci_finish_data(host, datastat);
  556. if (host->req->stop) {
  557. if (mxcmci_start_cmd(host, host->req->stop, 0)) {
  558. mxcmci_finish_request(host, host->req);
  559. return;
  560. }
  561. } else {
  562. mxcmci_finish_request(host, host->req);
  563. }
  564. }
  565. static void mxcmci_data_done(struct mxcmci_host *host, unsigned int stat)
  566. {
  567. struct mmc_request *req;
  568. int data_error;
  569. unsigned long flags;
  570. spin_lock_irqsave(&host->lock, flags);
  571. if (!host->data) {
  572. spin_unlock_irqrestore(&host->lock, flags);
  573. return;
  574. }
  575. if (!host->req) {
  576. spin_unlock_irqrestore(&host->lock, flags);
  577. return;
  578. }
  579. req = host->req;
  580. if (!req->stop)
  581. host->req = NULL; /* we will handle finish req below */
  582. data_error = mxcmci_finish_data(host, stat);
  583. spin_unlock_irqrestore(&host->lock, flags);
  584. mxcmci_read_response(host, stat);
  585. host->cmd = NULL;
  586. if (req->stop) {
  587. if (mxcmci_start_cmd(host, req->stop, 0)) {
  588. mxcmci_finish_request(host, req);
  589. return;
  590. }
  591. } else {
  592. mxcmci_finish_request(host, req);
  593. }
  594. }
  595. static void mxcmci_cmd_done(struct mxcmci_host *host, unsigned int stat)
  596. {
  597. mxcmci_read_response(host, stat);
  598. host->cmd = NULL;
  599. if (!host->data && host->req) {
  600. mxcmci_finish_request(host, host->req);
  601. return;
  602. }
  603. /* For the DMA case the DMA engine handles the data transfer
  604. * automatically. For non DMA we have to do it ourselves.
  605. * Don't do it in interrupt context though.
  606. */
  607. if (!mxcmci_use_dma(host) && host->data)
  608. schedule_work(&host->datawork);
  609. }
  610. static irqreturn_t mxcmci_irq(int irq, void *devid)
  611. {
  612. struct mxcmci_host *host = devid;
  613. unsigned long flags;
  614. bool sdio_irq;
  615. u32 stat;
  616. stat = mxcmci_readl(host, MMC_REG_STATUS);
  617. mxcmci_writel(host,
  618. stat & ~(STATUS_SDIO_INT_ACTIVE | STATUS_DATA_TRANS_DONE |
  619. STATUS_WRITE_OP_DONE),
  620. MMC_REG_STATUS);
  621. dev_dbg(mmc_dev(host->mmc), "%s: 0x%08x\n", __func__, stat);
  622. spin_lock_irqsave(&host->lock, flags);
  623. sdio_irq = (stat & STATUS_SDIO_INT_ACTIVE) && host->use_sdio;
  624. spin_unlock_irqrestore(&host->lock, flags);
  625. if (mxcmci_use_dma(host) &&
  626. (stat & (STATUS_READ_OP_DONE | STATUS_WRITE_OP_DONE)))
  627. mxcmci_writel(host, STATUS_READ_OP_DONE | STATUS_WRITE_OP_DONE,
  628. MMC_REG_STATUS);
  629. if (sdio_irq) {
  630. mxcmci_writel(host, STATUS_SDIO_INT_ACTIVE, MMC_REG_STATUS);
  631. mmc_signal_sdio_irq(host->mmc);
  632. }
  633. if (stat & STATUS_END_CMD_RESP)
  634. mxcmci_cmd_done(host, stat);
  635. if (mxcmci_use_dma(host) &&
  636. (stat & (STATUS_DATA_TRANS_DONE | STATUS_WRITE_OP_DONE))) {
  637. del_timer(&host->watchdog);
  638. mxcmci_data_done(host, stat);
  639. }
  640. if (host->default_irq_mask &&
  641. (stat & (STATUS_CARD_INSERTION | STATUS_CARD_REMOVAL)))
  642. mmc_detect_change(host->mmc, msecs_to_jiffies(200));
  643. return IRQ_HANDLED;
  644. }
  645. static void mxcmci_request(struct mmc_host *mmc, struct mmc_request *req)
  646. {
  647. struct mxcmci_host *host = mmc_priv(mmc);
  648. unsigned int cmdat = host->cmdat;
  649. int error;
  650. WARN_ON(host->req != NULL);
  651. host->req = req;
  652. host->cmdat &= ~CMD_DAT_CONT_INIT;
  653. if (host->dma)
  654. host->do_dma = 1;
  655. if (req->data) {
  656. error = mxcmci_setup_data(host, req->data);
  657. if (error) {
  658. req->cmd->error = error;
  659. goto out;
  660. }
  661. cmdat |= CMD_DAT_CONT_DATA_ENABLE;
  662. if (req->data->flags & MMC_DATA_WRITE)
  663. cmdat |= CMD_DAT_CONT_WRITE;
  664. }
  665. error = mxcmci_start_cmd(host, req->cmd, cmdat);
  666. out:
  667. if (error)
  668. mxcmci_finish_request(host, req);
  669. }
  670. static void mxcmci_set_clk_rate(struct mxcmci_host *host, unsigned int clk_ios)
  671. {
  672. unsigned int divider;
  673. int prescaler = 0;
  674. unsigned int clk_in = clk_get_rate(host->clk_per);
  675. while (prescaler <= 0x800) {
  676. for (divider = 1; divider <= 0xF; divider++) {
  677. int x;
  678. x = (clk_in / (divider + 1));
  679. if (prescaler)
  680. x /= (prescaler * 2);
  681. if (x <= clk_ios)
  682. break;
  683. }
  684. if (divider < 0x10)
  685. break;
  686. if (prescaler == 0)
  687. prescaler = 1;
  688. else
  689. prescaler <<= 1;
  690. }
  691. mxcmci_writew(host, (prescaler << 4) | divider, MMC_REG_CLK_RATE);
  692. dev_dbg(mmc_dev(host->mmc), "scaler: %d divider: %d in: %d out: %d\n",
  693. prescaler, divider, clk_in, clk_ios);
  694. }
  695. static int mxcmci_setup_dma(struct mmc_host *mmc)
  696. {
  697. struct mxcmci_host *host = mmc_priv(mmc);
  698. struct dma_slave_config *config = &host->dma_slave_config;
  699. config->dst_addr = host->phys_base + MMC_REG_BUFFER_ACCESS;
  700. config->src_addr = host->phys_base + MMC_REG_BUFFER_ACCESS;
  701. config->dst_addr_width = 4;
  702. config->src_addr_width = 4;
  703. config->dst_maxburst = host->burstlen;
  704. config->src_maxburst = host->burstlen;
  705. config->device_fc = false;
  706. return dmaengine_slave_config(host->dma, config);
  707. }
  708. static void mxcmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
  709. {
  710. struct mxcmci_host *host = mmc_priv(mmc);
  711. int burstlen, ret;
  712. /*
  713. * use burstlen of 64 (16 words) in 4 bit mode (--> reg value 0)
  714. * use burstlen of 16 (4 words) in 1 bit mode (--> reg value 16)
  715. */
  716. if (ios->bus_width == MMC_BUS_WIDTH_4)
  717. burstlen = 16;
  718. else
  719. burstlen = 4;
  720. if (mxcmci_use_dma(host) && burstlen != host->burstlen) {
  721. host->burstlen = burstlen;
  722. ret = mxcmci_setup_dma(mmc);
  723. if (ret) {
  724. dev_err(mmc_dev(host->mmc),
  725. "failed to config DMA channel. Falling back to PIO\n");
  726. dma_release_channel(host->dma);
  727. host->do_dma = 0;
  728. host->dma = NULL;
  729. }
  730. }
  731. if (ios->bus_width == MMC_BUS_WIDTH_4)
  732. host->cmdat |= CMD_DAT_CONT_BUS_WIDTH_4;
  733. else
  734. host->cmdat &= ~CMD_DAT_CONT_BUS_WIDTH_4;
  735. if (host->power_mode != ios->power_mode) {
  736. host->power_mode = ios->power_mode;
  737. mxcmci_set_power(host, ios->vdd);
  738. if (ios->power_mode == MMC_POWER_ON)
  739. host->cmdat |= CMD_DAT_CONT_INIT;
  740. }
  741. if (ios->clock) {
  742. mxcmci_set_clk_rate(host, ios->clock);
  743. mxcmci_writew(host, STR_STP_CLK_START_CLK, MMC_REG_STR_STP_CLK);
  744. } else {
  745. mxcmci_writew(host, STR_STP_CLK_STOP_CLK, MMC_REG_STR_STP_CLK);
  746. }
  747. host->clock = ios->clock;
  748. }
  749. static irqreturn_t mxcmci_detect_irq(int irq, void *data)
  750. {
  751. struct mmc_host *mmc = data;
  752. dev_dbg(mmc_dev(mmc), "%s\n", __func__);
  753. mmc_detect_change(mmc, msecs_to_jiffies(250));
  754. return IRQ_HANDLED;
  755. }
  756. static int mxcmci_get_ro(struct mmc_host *mmc)
  757. {
  758. struct mxcmci_host *host = mmc_priv(mmc);
  759. if (host->pdata && host->pdata->get_ro)
  760. return !!host->pdata->get_ro(mmc_dev(mmc));
  761. /*
  762. * If board doesn't support read only detection (no mmc_gpio
  763. * context or gpio is invalid), then let the mmc core decide
  764. * what to do.
  765. */
  766. return mmc_gpio_get_ro(mmc);
  767. }
  768. static void mxcmci_enable_sdio_irq(struct mmc_host *mmc, int enable)
  769. {
  770. struct mxcmci_host *host = mmc_priv(mmc);
  771. unsigned long flags;
  772. u32 int_cntr;
  773. spin_lock_irqsave(&host->lock, flags);
  774. host->use_sdio = enable;
  775. int_cntr = mxcmci_readl(host, MMC_REG_INT_CNTR);
  776. if (enable)
  777. int_cntr |= INT_SDIO_IRQ_EN;
  778. else
  779. int_cntr &= ~INT_SDIO_IRQ_EN;
  780. mxcmci_writel(host, int_cntr, MMC_REG_INT_CNTR);
  781. spin_unlock_irqrestore(&host->lock, flags);
  782. }
  783. static void mxcmci_init_card(struct mmc_host *host, struct mmc_card *card)
  784. {
  785. struct mxcmci_host *mxcmci = mmc_priv(host);
  786. /*
  787. * MX3 SoCs have a silicon bug which corrupts CRC calculation of
  788. * multi-block transfers when connected SDIO peripheral doesn't
  789. * drive the BUSY line as required by the specs.
  790. * One way to prevent this is to only allow 1-bit transfers.
  791. */
  792. if (is_imx31_mmc(mxcmci) && card->type == MMC_TYPE_SDIO)
  793. host->caps &= ~MMC_CAP_4_BIT_DATA;
  794. else
  795. host->caps |= MMC_CAP_4_BIT_DATA;
  796. }
  797. static bool filter(struct dma_chan *chan, void *param)
  798. {
  799. struct mxcmci_host *host = param;
  800. if (!imx_dma_is_general_purpose(chan))
  801. return false;
  802. chan->private = &host->dma_data;
  803. return true;
  804. }
  805. static void mxcmci_watchdog(unsigned long data)
  806. {
  807. struct mmc_host *mmc = (struct mmc_host *)data;
  808. struct mxcmci_host *host = mmc_priv(mmc);
  809. struct mmc_request *req = host->req;
  810. unsigned int stat = mxcmci_readl(host, MMC_REG_STATUS);
  811. if (host->dma_dir == DMA_FROM_DEVICE) {
  812. dmaengine_terminate_all(host->dma);
  813. dev_err(mmc_dev(host->mmc),
  814. "%s: read time out (status = 0x%08x)\n",
  815. __func__, stat);
  816. } else {
  817. dev_err(mmc_dev(host->mmc),
  818. "%s: write time out (status = 0x%08x)\n",
  819. __func__, stat);
  820. mxcmci_softreset(host);
  821. }
  822. /* Mark transfer as erroneus and inform the upper layers */
  823. if (host->data)
  824. host->data->error = -ETIMEDOUT;
  825. host->req = NULL;
  826. host->cmd = NULL;
  827. host->data = NULL;
  828. mmc_request_done(host->mmc, req);
  829. }
  830. static const struct mmc_host_ops mxcmci_ops = {
  831. .request = mxcmci_request,
  832. .set_ios = mxcmci_set_ios,
  833. .get_ro = mxcmci_get_ro,
  834. .enable_sdio_irq = mxcmci_enable_sdio_irq,
  835. .init_card = mxcmci_init_card,
  836. };
  837. static int mxcmci_probe(struct platform_device *pdev)
  838. {
  839. struct mmc_host *mmc;
  840. struct mxcmci_host *host;
  841. struct resource *res;
  842. int ret = 0, irq;
  843. bool dat3_card_detect = false;
  844. dma_cap_mask_t mask;
  845. const struct of_device_id *of_id;
  846. struct imxmmc_platform_data *pdata = pdev->dev.platform_data;
  847. pr_info("i.MX/MPC512x SDHC driver\n");
  848. of_id = of_match_device(mxcmci_of_match, &pdev->dev);
  849. res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  850. irq = platform_get_irq(pdev, 0);
  851. if (irq < 0)
  852. return -EINVAL;
  853. mmc = mmc_alloc_host(sizeof(*host), &pdev->dev);
  854. if (!mmc)
  855. return -ENOMEM;
  856. host = mmc_priv(mmc);
  857. host->base = devm_ioremap_resource(&pdev->dev, res);
  858. if (IS_ERR(host->base)) {
  859. ret = PTR_ERR(host->base);
  860. goto out_free;
  861. }
  862. host->phys_base = res->start;
  863. ret = mmc_of_parse(mmc);
  864. if (ret)
  865. goto out_free;
  866. mmc->ops = &mxcmci_ops;
  867. /* For devicetree parsing, the bus width is read from devicetree */
  868. if (pdata)
  869. mmc->caps = MMC_CAP_4_BIT_DATA | MMC_CAP_SDIO_IRQ;
  870. else
  871. mmc->caps |= MMC_CAP_SDIO_IRQ;
  872. /* MMC core transfer sizes tunable parameters */
  873. mmc->max_blk_size = 2048;
  874. mmc->max_blk_count = 65535;
  875. mmc->max_req_size = mmc->max_blk_size * mmc->max_blk_count;
  876. mmc->max_seg_size = mmc->max_req_size;
  877. if (of_id) {
  878. const struct platform_device_id *id_entry = of_id->data;
  879. host->devtype = id_entry->driver_data;
  880. } else {
  881. host->devtype = pdev->id_entry->driver_data;
  882. }
  883. /* adjust max_segs after devtype detection */
  884. if (!is_mpc512x_mmc(host))
  885. mmc->max_segs = 64;
  886. host->mmc = mmc;
  887. host->pdata = pdata;
  888. spin_lock_init(&host->lock);
  889. if (pdata)
  890. dat3_card_detect = pdata->dat3_card_detect;
  891. else if (!(mmc->caps & MMC_CAP_NONREMOVABLE)
  892. && !of_property_read_bool(pdev->dev.of_node, "cd-gpios"))
  893. dat3_card_detect = true;
  894. ret = mmc_regulator_get_supply(mmc);
  895. if (ret) {
  896. if (pdata && ret != -EPROBE_DEFER)
  897. mmc->ocr_avail = pdata->ocr_avail ? :
  898. MMC_VDD_32_33 | MMC_VDD_33_34;
  899. else
  900. goto out_free;
  901. }
  902. if (dat3_card_detect)
  903. host->default_irq_mask =
  904. INT_CARD_INSERTION_EN | INT_CARD_REMOVAL_EN;
  905. else
  906. host->default_irq_mask = 0;
  907. host->clk_ipg = devm_clk_get(&pdev->dev, "ipg");
  908. if (IS_ERR(host->clk_ipg)) {
  909. ret = PTR_ERR(host->clk_ipg);
  910. goto out_free;
  911. }
  912. host->clk_per = devm_clk_get(&pdev->dev, "per");
  913. if (IS_ERR(host->clk_per)) {
  914. ret = PTR_ERR(host->clk_per);
  915. goto out_free;
  916. }
  917. clk_prepare_enable(host->clk_per);
  918. clk_prepare_enable(host->clk_ipg);
  919. mxcmci_softreset(host);
  920. host->rev_no = mxcmci_readw(host, MMC_REG_REV_NO);
  921. if (host->rev_no != 0x400) {
  922. ret = -ENODEV;
  923. dev_err(mmc_dev(host->mmc), "wrong rev.no. 0x%08x. aborting.\n",
  924. host->rev_no);
  925. goto out_clk_put;
  926. }
  927. mmc->f_min = clk_get_rate(host->clk_per) >> 16;
  928. mmc->f_max = clk_get_rate(host->clk_per) >> 1;
  929. /* recommended in data sheet */
  930. mxcmci_writew(host, 0x2db4, MMC_REG_READ_TO);
  931. mxcmci_writel(host, host->default_irq_mask, MMC_REG_INT_CNTR);
  932. if (!host->pdata) {
  933. host->dma = dma_request_slave_channel(&pdev->dev, "rx-tx");
  934. } else {
  935. res = platform_get_resource(pdev, IORESOURCE_DMA, 0);
  936. if (res) {
  937. host->dmareq = res->start;
  938. host->dma_data.peripheral_type = IMX_DMATYPE_SDHC;
  939. host->dma_data.priority = DMA_PRIO_LOW;
  940. host->dma_data.dma_request = host->dmareq;
  941. dma_cap_zero(mask);
  942. dma_cap_set(DMA_SLAVE, mask);
  943. host->dma = dma_request_channel(mask, filter, host);
  944. }
  945. }
  946. if (host->dma)
  947. mmc->max_seg_size = dma_get_max_seg_size(
  948. host->dma->device->dev);
  949. else
  950. dev_info(mmc_dev(host->mmc), "dma not available. Using PIO\n");
  951. INIT_WORK(&host->datawork, mxcmci_datawork);
  952. ret = devm_request_irq(&pdev->dev, irq, mxcmci_irq, 0,
  953. dev_name(&pdev->dev), host);
  954. if (ret)
  955. goto out_free_dma;
  956. platform_set_drvdata(pdev, mmc);
  957. if (host->pdata && host->pdata->init) {
  958. ret = host->pdata->init(&pdev->dev, mxcmci_detect_irq,
  959. host->mmc);
  960. if (ret)
  961. goto out_free_dma;
  962. }
  963. init_timer(&host->watchdog);
  964. host->watchdog.function = &mxcmci_watchdog;
  965. host->watchdog.data = (unsigned long)mmc;
  966. mmc_add_host(mmc);
  967. return 0;
  968. out_free_dma:
  969. if (host->dma)
  970. dma_release_channel(host->dma);
  971. out_clk_put:
  972. clk_disable_unprepare(host->clk_per);
  973. clk_disable_unprepare(host->clk_ipg);
  974. out_free:
  975. mmc_free_host(mmc);
  976. return ret;
  977. }
  978. static int mxcmci_remove(struct platform_device *pdev)
  979. {
  980. struct mmc_host *mmc = platform_get_drvdata(pdev);
  981. struct mxcmci_host *host = mmc_priv(mmc);
  982. mmc_remove_host(mmc);
  983. if (host->pdata && host->pdata->exit)
  984. host->pdata->exit(&pdev->dev, mmc);
  985. if (host->dma)
  986. dma_release_channel(host->dma);
  987. clk_disable_unprepare(host->clk_per);
  988. clk_disable_unprepare(host->clk_ipg);
  989. mmc_free_host(mmc);
  990. return 0;
  991. }
  992. static int __maybe_unused mxcmci_suspend(struct device *dev)
  993. {
  994. struct mmc_host *mmc = dev_get_drvdata(dev);
  995. struct mxcmci_host *host = mmc_priv(mmc);
  996. clk_disable_unprepare(host->clk_per);
  997. clk_disable_unprepare(host->clk_ipg);
  998. return 0;
  999. }
  1000. static int __maybe_unused mxcmci_resume(struct device *dev)
  1001. {
  1002. struct mmc_host *mmc = dev_get_drvdata(dev);
  1003. struct mxcmci_host *host = mmc_priv(mmc);
  1004. clk_prepare_enable(host->clk_per);
  1005. clk_prepare_enable(host->clk_ipg);
  1006. return 0;
  1007. }
  1008. static SIMPLE_DEV_PM_OPS(mxcmci_pm_ops, mxcmci_suspend, mxcmci_resume);
  1009. static struct platform_driver mxcmci_driver = {
  1010. .probe = mxcmci_probe,
  1011. .remove = mxcmci_remove,
  1012. .id_table = mxcmci_devtype,
  1013. .driver = {
  1014. .name = DRIVER_NAME,
  1015. .owner = THIS_MODULE,
  1016. .pm = &mxcmci_pm_ops,
  1017. .of_match_table = mxcmci_of_match,
  1018. }
  1019. };
  1020. module_platform_driver(mxcmci_driver);
  1021. MODULE_DESCRIPTION("i.MX Multimedia Card Interface Driver");
  1022. MODULE_AUTHOR("Sascha Hauer, Pengutronix");
  1023. MODULE_LICENSE("GPL");
  1024. MODULE_ALIAS("platform:mxc-mmc");