mxcmmc.c 29 KB

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