mxcmmc.c 30 KB

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