mxcmmc.c 30 KB

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