mxcmmc.c 29 KB

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