imxmmc.c 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170
  1. /*
  2. * linux/drivers/mmc/host/imxmmc.c - Motorola i.MX MMCI driver
  3. *
  4. * Copyright (C) 2004 Sascha Hauer, Pengutronix <sascha@saschahauer.de>
  5. * Copyright (C) 2006 Pavel Pisa, PiKRON <ppisa@pikron.com>
  6. *
  7. * derived from pxamci.c by Russell King
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 as
  11. * published by the Free Software Foundation.
  12. *
  13. */
  14. #include <linux/module.h>
  15. #include <linux/init.h>
  16. #include <linux/ioport.h>
  17. #include <linux/platform_device.h>
  18. #include <linux/interrupt.h>
  19. #include <linux/blkdev.h>
  20. #include <linux/dma-mapping.h>
  21. #include <linux/mmc/host.h>
  22. #include <linux/mmc/card.h>
  23. #include <linux/delay.h>
  24. #include <linux/clk.h>
  25. #include <linux/io.h>
  26. #include <asm/dma.h>
  27. #include <asm/irq.h>
  28. #include <asm/sizes.h>
  29. #include <mach/mmc.h>
  30. #include <mach/imx-dma.h>
  31. #include "imxmmc.h"
  32. #define DRIVER_NAME "imx-mmc"
  33. #define IMXMCI_INT_MASK_DEFAULT (INT_MASK_BUF_READY | INT_MASK_DATA_TRAN | \
  34. INT_MASK_WRITE_OP_DONE | INT_MASK_END_CMD_RES | \
  35. INT_MASK_AUTO_CARD_DETECT | INT_MASK_DAT0_EN | INT_MASK_SDIO)
  36. struct imxmci_host {
  37. struct mmc_host *mmc;
  38. spinlock_t lock;
  39. struct resource *res;
  40. void __iomem *base;
  41. int irq;
  42. imx_dmach_t dma;
  43. volatile unsigned int imask;
  44. unsigned int power_mode;
  45. unsigned int present;
  46. struct imxmmc_platform_data *pdata;
  47. struct mmc_request *req;
  48. struct mmc_command *cmd;
  49. struct mmc_data *data;
  50. struct timer_list timer;
  51. struct tasklet_struct tasklet;
  52. unsigned int status_reg;
  53. unsigned long pending_events;
  54. /* Next two fields are there for CPU driven transfers to overcome SDHC deficiencies */
  55. u16 *data_ptr;
  56. unsigned int data_cnt;
  57. atomic_t stuck_timeout;
  58. unsigned int dma_nents;
  59. unsigned int dma_size;
  60. unsigned int dma_dir;
  61. int dma_allocated;
  62. unsigned char actual_bus_width;
  63. int prev_cmd_code;
  64. struct clk *clk;
  65. };
  66. #define IMXMCI_PEND_IRQ_b 0
  67. #define IMXMCI_PEND_DMA_END_b 1
  68. #define IMXMCI_PEND_DMA_ERR_b 2
  69. #define IMXMCI_PEND_WAIT_RESP_b 3
  70. #define IMXMCI_PEND_DMA_DATA_b 4
  71. #define IMXMCI_PEND_CPU_DATA_b 5
  72. #define IMXMCI_PEND_CARD_XCHG_b 6
  73. #define IMXMCI_PEND_SET_INIT_b 7
  74. #define IMXMCI_PEND_STARTED_b 8
  75. #define IMXMCI_PEND_IRQ_m (1 << IMXMCI_PEND_IRQ_b)
  76. #define IMXMCI_PEND_DMA_END_m (1 << IMXMCI_PEND_DMA_END_b)
  77. #define IMXMCI_PEND_DMA_ERR_m (1 << IMXMCI_PEND_DMA_ERR_b)
  78. #define IMXMCI_PEND_WAIT_RESP_m (1 << IMXMCI_PEND_WAIT_RESP_b)
  79. #define IMXMCI_PEND_DMA_DATA_m (1 << IMXMCI_PEND_DMA_DATA_b)
  80. #define IMXMCI_PEND_CPU_DATA_m (1 << IMXMCI_PEND_CPU_DATA_b)
  81. #define IMXMCI_PEND_CARD_XCHG_m (1 << IMXMCI_PEND_CARD_XCHG_b)
  82. #define IMXMCI_PEND_SET_INIT_m (1 << IMXMCI_PEND_SET_INIT_b)
  83. #define IMXMCI_PEND_STARTED_m (1 << IMXMCI_PEND_STARTED_b)
  84. static void imxmci_stop_clock(struct imxmci_host *host)
  85. {
  86. int i = 0;
  87. u16 reg;
  88. reg = readw(host->base + MMC_REG_STR_STP_CLK);
  89. writew(reg & ~STR_STP_CLK_START_CLK, host->base + MMC_REG_STR_STP_CLK);
  90. while (i < 0x1000) {
  91. if (!(i & 0x7f)) {
  92. reg = readw(host->base + MMC_REG_STR_STP_CLK);
  93. writew(reg | STR_STP_CLK_STOP_CLK,
  94. host->base + MMC_REG_STR_STP_CLK);
  95. }
  96. reg = readw(host->base + MMC_REG_STATUS);
  97. if (!(reg & STATUS_CARD_BUS_CLK_RUN)) {
  98. /* Check twice before cut */
  99. reg = readw(host->base + MMC_REG_STATUS);
  100. if (!(reg & STATUS_CARD_BUS_CLK_RUN))
  101. return;
  102. }
  103. i++;
  104. }
  105. dev_dbg(mmc_dev(host->mmc), "imxmci_stop_clock blocked, no luck\n");
  106. }
  107. static int imxmci_start_clock(struct imxmci_host *host)
  108. {
  109. unsigned int trials = 0;
  110. unsigned int delay_limit = 128;
  111. unsigned long flags;
  112. u16 reg;
  113. reg = readw(host->base + MMC_REG_STR_STP_CLK);
  114. writew(reg & ~STR_STP_CLK_STOP_CLK, host->base + MMC_REG_STR_STP_CLK);
  115. clear_bit(IMXMCI_PEND_STARTED_b, &host->pending_events);
  116. /*
  117. * Command start of the clock, this usually succeeds in less
  118. * then 6 delay loops, but during card detection (low clockrate)
  119. * it takes up to 5000 delay loops and sometimes fails for the first time
  120. */
  121. reg = readw(host->base + MMC_REG_STR_STP_CLK);
  122. writew(reg | STR_STP_CLK_START_CLK, host->base + MMC_REG_STR_STP_CLK);
  123. do {
  124. unsigned int delay = delay_limit;
  125. while (delay--) {
  126. reg = readw(host->base + MMC_REG_STATUS);
  127. if (reg & STATUS_CARD_BUS_CLK_RUN) {
  128. /* Check twice before cut */
  129. reg = readw(host->base + MMC_REG_STATUS);
  130. if (reg & STATUS_CARD_BUS_CLK_RUN)
  131. return 0;
  132. }
  133. if (test_bit(IMXMCI_PEND_STARTED_b, &host->pending_events))
  134. return 0;
  135. }
  136. local_irq_save(flags);
  137. /*
  138. * Ensure, that request is not doubled under all possible circumstances.
  139. * It is possible, that cock running state is missed, because some other
  140. * IRQ or schedule delays this function execution and the clocks has
  141. * been already stopped by other means (response processing, SDHC HW)
  142. */
  143. if (!test_bit(IMXMCI_PEND_STARTED_b, &host->pending_events)) {
  144. reg = readw(host->base + MMC_REG_STR_STP_CLK);
  145. writew(reg | STR_STP_CLK_START_CLK,
  146. host->base + MMC_REG_STR_STP_CLK);
  147. }
  148. local_irq_restore(flags);
  149. } while (++trials < 256);
  150. dev_err(mmc_dev(host->mmc), "imxmci_start_clock blocked, no luck\n");
  151. return -1;
  152. }
  153. static void imxmci_softreset(struct imxmci_host *host)
  154. {
  155. int i;
  156. /* reset sequence */
  157. writew(0x08, host->base + MMC_REG_STR_STP_CLK);
  158. writew(0x0D, host->base + MMC_REG_STR_STP_CLK);
  159. for (i = 0; i < 8; i++)
  160. writew(0x05, host->base + MMC_REG_STR_STP_CLK);
  161. writew(0xff, host->base + MMC_REG_RES_TO);
  162. writew(512, host->base + MMC_REG_BLK_LEN);
  163. writew(1, host->base + MMC_REG_NOB);
  164. }
  165. static int imxmci_busy_wait_for_status(struct imxmci_host *host,
  166. unsigned int *pstat, unsigned int stat_mask,
  167. int timeout, const char *where)
  168. {
  169. int loops = 0;
  170. while (!(*pstat & stat_mask)) {
  171. loops += 2;
  172. if (loops >= timeout) {
  173. dev_dbg(mmc_dev(host->mmc), "busy wait timeout in %s, STATUS = 0x%x (0x%x)\n",
  174. where, *pstat, stat_mask);
  175. return -1;
  176. }
  177. udelay(2);
  178. *pstat |= readw(host->base + MMC_REG_STATUS);
  179. }
  180. if (!loops)
  181. return 0;
  182. /* The busy-wait is expected there for clock <8MHz due to SDHC hardware flaws */
  183. if (!(stat_mask & STATUS_END_CMD_RESP) || (host->mmc->ios.clock >= 8000000))
  184. dev_info(mmc_dev(host->mmc), "busy wait for %d usec in %s, STATUS = 0x%x (0x%x)\n",
  185. loops, where, *pstat, stat_mask);
  186. return loops;
  187. }
  188. static void imxmci_setup_data(struct imxmci_host *host, struct mmc_data *data)
  189. {
  190. unsigned int nob = data->blocks;
  191. unsigned int blksz = data->blksz;
  192. unsigned int datasz = nob * blksz;
  193. int i;
  194. if (data->flags & MMC_DATA_STREAM)
  195. nob = 0xffff;
  196. host->data = data;
  197. data->bytes_xfered = 0;
  198. writew(nob, host->base + MMC_REG_NOB);
  199. writew(blksz, host->base + MMC_REG_BLK_LEN);
  200. /*
  201. * DMA cannot be used for small block sizes, we have to use CPU driven transfers otherwise.
  202. * We are in big troubles for non-512 byte transfers according to note in the paragraph
  203. * 20.6.7 of User Manual anyway, but we need to be able to transfer SCR at least.
  204. * The situation is even more complex in reality. The SDHC in not able to handle wll
  205. * partial FIFO fills and reads. The length has to be rounded up to burst size multiple.
  206. * This is required for SCR read at least.
  207. */
  208. if (datasz < 512) {
  209. host->dma_size = datasz;
  210. if (data->flags & MMC_DATA_READ) {
  211. host->dma_dir = DMA_FROM_DEVICE;
  212. /* Hack to enable read SCR */
  213. writew(1, host->base + MMC_REG_NOB);
  214. writew(512, host->base + MMC_REG_BLK_LEN);
  215. } else {
  216. host->dma_dir = DMA_TO_DEVICE;
  217. }
  218. /* Convert back to virtual address */
  219. host->data_ptr = (u16 *)sg_virt(data->sg);
  220. host->data_cnt = 0;
  221. clear_bit(IMXMCI_PEND_DMA_DATA_b, &host->pending_events);
  222. set_bit(IMXMCI_PEND_CPU_DATA_b, &host->pending_events);
  223. return;
  224. }
  225. if (data->flags & MMC_DATA_READ) {
  226. host->dma_dir = DMA_FROM_DEVICE;
  227. host->dma_nents = dma_map_sg(mmc_dev(host->mmc), data->sg,
  228. data->sg_len, host->dma_dir);
  229. imx_dma_setup_sg(host->dma, data->sg, data->sg_len, datasz,
  230. host->res->start + MMC_REG_BUFFER_ACCESS,
  231. DMA_MODE_READ);
  232. /*imx_dma_setup_mem2dev_ccr(host->dma, DMA_MODE_READ, IMX_DMA_WIDTH_16, CCR_REN);*/
  233. CCR(host->dma) = CCR_DMOD_LINEAR | CCR_DSIZ_32 | CCR_SMOD_FIFO | CCR_SSIZ_16 | CCR_REN;
  234. } else {
  235. host->dma_dir = DMA_TO_DEVICE;
  236. host->dma_nents = dma_map_sg(mmc_dev(host->mmc), data->sg,
  237. data->sg_len, host->dma_dir);
  238. imx_dma_setup_sg(host->dma, data->sg, data->sg_len, datasz,
  239. host->res->start + MMC_REG_BUFFER_ACCESS,
  240. DMA_MODE_WRITE);
  241. /*imx_dma_setup_mem2dev_ccr(host->dma, DMA_MODE_WRITE, IMX_DMA_WIDTH_16, CCR_REN);*/
  242. CCR(host->dma) = CCR_SMOD_LINEAR | CCR_SSIZ_32 | CCR_DMOD_FIFO | CCR_DSIZ_16 | CCR_REN;
  243. }
  244. #if 1 /* This code is there only for consistency checking and can be disabled in future */
  245. host->dma_size = 0;
  246. for (i = 0; i < host->dma_nents; i++)
  247. host->dma_size += data->sg[i].length;
  248. if (datasz > host->dma_size) {
  249. dev_err(mmc_dev(host->mmc), "imxmci_setup_data datasz 0x%x > 0x%x dm_size\n",
  250. datasz, host->dma_size);
  251. }
  252. #endif
  253. host->dma_size = datasz;
  254. wmb();
  255. set_bit(IMXMCI_PEND_DMA_DATA_b, &host->pending_events);
  256. clear_bit(IMXMCI_PEND_CPU_DATA_b, &host->pending_events);
  257. /* start DMA engine for read, write is delayed after initial response */
  258. if (host->dma_dir == DMA_FROM_DEVICE)
  259. imx_dma_enable(host->dma);
  260. }
  261. static void imxmci_start_cmd(struct imxmci_host *host, struct mmc_command *cmd, unsigned int cmdat)
  262. {
  263. unsigned long flags;
  264. u32 imask;
  265. WARN_ON(host->cmd != NULL);
  266. host->cmd = cmd;
  267. /* Ensure, that clock are stopped else command programming and start fails */
  268. imxmci_stop_clock(host);
  269. if (cmd->flags & MMC_RSP_BUSY)
  270. cmdat |= CMD_DAT_CONT_BUSY;
  271. switch (mmc_resp_type(cmd)) {
  272. case MMC_RSP_R1: /* short CRC, OPCODE */
  273. case MMC_RSP_R1B:/* short CRC, OPCODE, BUSY */
  274. cmdat |= CMD_DAT_CONT_RESPONSE_FORMAT_R1;
  275. break;
  276. case MMC_RSP_R2: /* long 136 bit + CRC */
  277. cmdat |= CMD_DAT_CONT_RESPONSE_FORMAT_R2;
  278. break;
  279. case MMC_RSP_R3: /* short */
  280. cmdat |= CMD_DAT_CONT_RESPONSE_FORMAT_R3;
  281. break;
  282. default:
  283. break;
  284. }
  285. if (test_and_clear_bit(IMXMCI_PEND_SET_INIT_b, &host->pending_events))
  286. cmdat |= CMD_DAT_CONT_INIT; /* This command needs init */
  287. if (host->actual_bus_width == MMC_BUS_WIDTH_4)
  288. cmdat |= CMD_DAT_CONT_BUS_WIDTH_4;
  289. writew(cmd->opcode, host->base + MMC_REG_CMD);
  290. writew(cmd->arg >> 16, host->base + MMC_REG_ARGH);
  291. writew(cmd->arg & 0xffff, host->base + MMC_REG_ARGL);
  292. writew(cmdat, host->base + MMC_REG_CMD_DAT_CONT);
  293. atomic_set(&host->stuck_timeout, 0);
  294. set_bit(IMXMCI_PEND_WAIT_RESP_b, &host->pending_events);
  295. imask = IMXMCI_INT_MASK_DEFAULT;
  296. imask &= ~INT_MASK_END_CMD_RES;
  297. if (cmdat & CMD_DAT_CONT_DATA_ENABLE) {
  298. /* imask &= ~INT_MASK_BUF_READY; */
  299. imask &= ~INT_MASK_DATA_TRAN;
  300. if (cmdat & CMD_DAT_CONT_WRITE)
  301. imask &= ~INT_MASK_WRITE_OP_DONE;
  302. if (test_bit(IMXMCI_PEND_CPU_DATA_b, &host->pending_events))
  303. imask &= ~INT_MASK_BUF_READY;
  304. }
  305. spin_lock_irqsave(&host->lock, flags);
  306. host->imask = imask;
  307. writew(host->imask, host->base + MMC_REG_INT_MASK);
  308. spin_unlock_irqrestore(&host->lock, flags);
  309. dev_dbg(mmc_dev(host->mmc), "CMD%02d (0x%02x) mask set to 0x%04x\n",
  310. cmd->opcode, cmd->opcode, imask);
  311. imxmci_start_clock(host);
  312. }
  313. static void imxmci_finish_request(struct imxmci_host *host, struct mmc_request *req)
  314. {
  315. unsigned long flags;
  316. spin_lock_irqsave(&host->lock, flags);
  317. host->pending_events &= ~(IMXMCI_PEND_WAIT_RESP_m | IMXMCI_PEND_DMA_END_m |
  318. IMXMCI_PEND_DMA_DATA_m | IMXMCI_PEND_CPU_DATA_m);
  319. host->imask = IMXMCI_INT_MASK_DEFAULT;
  320. writew(host->imask, host->base + MMC_REG_INT_MASK);
  321. spin_unlock_irqrestore(&host->lock, flags);
  322. if (req && req->cmd)
  323. host->prev_cmd_code = req->cmd->opcode;
  324. host->req = NULL;
  325. host->cmd = NULL;
  326. host->data = NULL;
  327. mmc_request_done(host->mmc, req);
  328. }
  329. static int imxmci_finish_data(struct imxmci_host *host, unsigned int stat)
  330. {
  331. struct mmc_data *data = host->data;
  332. int data_error;
  333. if (test_and_clear_bit(IMXMCI_PEND_DMA_DATA_b, &host->pending_events)) {
  334. imx_dma_disable(host->dma);
  335. dma_unmap_sg(mmc_dev(host->mmc), data->sg, host->dma_nents,
  336. host->dma_dir);
  337. }
  338. if (stat & STATUS_ERR_MASK) {
  339. dev_dbg(mmc_dev(host->mmc), "request failed. status: 0x%08x\n", stat);
  340. if (stat & (STATUS_CRC_READ_ERR | STATUS_CRC_WRITE_ERR))
  341. data->error = -EILSEQ;
  342. else if (stat & STATUS_TIME_OUT_READ)
  343. data->error = -ETIMEDOUT;
  344. else
  345. data->error = -EIO;
  346. } else {
  347. data->bytes_xfered = host->dma_size;
  348. }
  349. data_error = data->error;
  350. host->data = NULL;
  351. return data_error;
  352. }
  353. static int imxmci_cmd_done(struct imxmci_host *host, unsigned int stat)
  354. {
  355. struct mmc_command *cmd = host->cmd;
  356. int i;
  357. u32 a, b, c;
  358. struct mmc_data *data = host->data;
  359. if (!cmd)
  360. return 0;
  361. host->cmd = NULL;
  362. if (stat & STATUS_TIME_OUT_RESP) {
  363. dev_dbg(mmc_dev(host->mmc), "CMD TIMEOUT\n");
  364. cmd->error = -ETIMEDOUT;
  365. } else if (stat & STATUS_RESP_CRC_ERR && cmd->flags & MMC_RSP_CRC) {
  366. dev_dbg(mmc_dev(host->mmc), "cmd crc error\n");
  367. cmd->error = -EILSEQ;
  368. }
  369. if (cmd->flags & MMC_RSP_PRESENT) {
  370. if (cmd->flags & MMC_RSP_136) {
  371. for (i = 0; i < 4; i++) {
  372. a = readw(host->base + MMC_REG_RES_FIFO);
  373. b = readw(host->base + MMC_REG_RES_FIFO);
  374. cmd->resp[i] = a << 16 | b;
  375. }
  376. } else {
  377. a = readw(host->base + MMC_REG_RES_FIFO);
  378. b = readw(host->base + MMC_REG_RES_FIFO);
  379. c = readw(host->base + MMC_REG_RES_FIFO);
  380. cmd->resp[0] = a << 24 | b << 8 | c >> 8;
  381. }
  382. }
  383. dev_dbg(mmc_dev(host->mmc), "RESP 0x%08x, 0x%08x, 0x%08x, 0x%08x, error %d\n",
  384. cmd->resp[0], cmd->resp[1], cmd->resp[2], cmd->resp[3], cmd->error);
  385. if (data && !cmd->error && !(stat & STATUS_ERR_MASK)) {
  386. if (host->req->data->flags & MMC_DATA_WRITE) {
  387. /* Wait for FIFO to be empty before starting DMA write */
  388. stat = readw(host->base + MMC_REG_STATUS);
  389. if (imxmci_busy_wait_for_status(host, &stat,
  390. STATUS_APPL_BUFF_FE,
  391. 40, "imxmci_cmd_done DMA WR") < 0) {
  392. cmd->error = -EIO;
  393. imxmci_finish_data(host, stat);
  394. if (host->req)
  395. imxmci_finish_request(host, host->req);
  396. dev_warn(mmc_dev(host->mmc), "STATUS = 0x%04x\n",
  397. stat);
  398. return 0;
  399. }
  400. if (test_bit(IMXMCI_PEND_DMA_DATA_b, &host->pending_events))
  401. imx_dma_enable(host->dma);
  402. }
  403. } else {
  404. struct mmc_request *req;
  405. imxmci_stop_clock(host);
  406. req = host->req;
  407. if (data)
  408. imxmci_finish_data(host, stat);
  409. if (req)
  410. imxmci_finish_request(host, req);
  411. else
  412. dev_warn(mmc_dev(host->mmc), "imxmci_cmd_done: no request to finish\n");
  413. }
  414. return 1;
  415. }
  416. static int imxmci_data_done(struct imxmci_host *host, unsigned int stat)
  417. {
  418. struct mmc_data *data = host->data;
  419. int data_error;
  420. if (!data)
  421. return 0;
  422. data_error = imxmci_finish_data(host, stat);
  423. if (host->req->stop) {
  424. imxmci_stop_clock(host);
  425. imxmci_start_cmd(host, host->req->stop, 0);
  426. } else {
  427. struct mmc_request *req;
  428. req = host->req;
  429. if (req)
  430. imxmci_finish_request(host, req);
  431. else
  432. dev_warn(mmc_dev(host->mmc), "imxmci_data_done: no request to finish\n");
  433. }
  434. return 1;
  435. }
  436. static int imxmci_cpu_driven_data(struct imxmci_host *host, unsigned int *pstat)
  437. {
  438. int i;
  439. int burst_len;
  440. int trans_done = 0;
  441. unsigned int stat = *pstat;
  442. if (host->actual_bus_width != MMC_BUS_WIDTH_4)
  443. burst_len = 16;
  444. else
  445. burst_len = 64;
  446. /* This is unfortunately required */
  447. dev_dbg(mmc_dev(host->mmc), "imxmci_cpu_driven_data running STATUS = 0x%x\n",
  448. stat);
  449. udelay(20); /* required for clocks < 8MHz*/
  450. if (host->dma_dir == DMA_FROM_DEVICE) {
  451. imxmci_busy_wait_for_status(host, &stat,
  452. STATUS_APPL_BUFF_FF | STATUS_DATA_TRANS_DONE |
  453. STATUS_TIME_OUT_READ,
  454. 50, "imxmci_cpu_driven_data read");
  455. while ((stat & (STATUS_APPL_BUFF_FF | STATUS_DATA_TRANS_DONE)) &&
  456. !(stat & STATUS_TIME_OUT_READ) &&
  457. (host->data_cnt < 512)) {
  458. udelay(20); /* required for clocks < 8MHz*/
  459. for (i = burst_len; i >= 2 ; i -= 2) {
  460. u16 data;
  461. data = readw(host->base + MMC_REG_BUFFER_ACCESS);
  462. udelay(10); /* required for clocks < 8MHz*/
  463. if (host->data_cnt+2 <= host->dma_size) {
  464. *(host->data_ptr++) = data;
  465. } else {
  466. if (host->data_cnt < host->dma_size)
  467. *(u8 *)(host->data_ptr) = data;
  468. }
  469. host->data_cnt += 2;
  470. }
  471. stat = readw(host->base + MMC_REG_STATUS);
  472. dev_dbg(mmc_dev(host->mmc), "imxmci_cpu_driven_data read %d burst %d STATUS = 0x%x\n",
  473. host->data_cnt, burst_len, stat);
  474. }
  475. if ((stat & STATUS_DATA_TRANS_DONE) && (host->data_cnt >= 512))
  476. trans_done = 1;
  477. if (host->dma_size & 0x1ff)
  478. stat &= ~STATUS_CRC_READ_ERR;
  479. if (stat & STATUS_TIME_OUT_READ) {
  480. dev_dbg(mmc_dev(host->mmc), "imxmci_cpu_driven_data read timeout STATUS = 0x%x\n",
  481. stat);
  482. trans_done = -1;
  483. }
  484. } else {
  485. imxmci_busy_wait_for_status(host, &stat,
  486. STATUS_APPL_BUFF_FE,
  487. 20, "imxmci_cpu_driven_data write");
  488. while ((stat & STATUS_APPL_BUFF_FE) &&
  489. (host->data_cnt < host->dma_size)) {
  490. if (burst_len >= host->dma_size - host->data_cnt) {
  491. burst_len = host->dma_size - host->data_cnt;
  492. host->data_cnt = host->dma_size;
  493. trans_done = 1;
  494. } else {
  495. host->data_cnt += burst_len;
  496. }
  497. for (i = burst_len; i > 0 ; i -= 2)
  498. writew(*(host->data_ptr++), host->base + MMC_REG_BUFFER_ACCESS);
  499. stat = readw(host->base + MMC_REG_STATUS);
  500. dev_dbg(mmc_dev(host->mmc), "imxmci_cpu_driven_data write burst %d STATUS = 0x%x\n",
  501. burst_len, stat);
  502. }
  503. }
  504. *pstat = stat;
  505. return trans_done;
  506. }
  507. static void imxmci_dma_irq(int dma, void *devid)
  508. {
  509. struct imxmci_host *host = devid;
  510. u32 stat = readw(host->base + MMC_REG_STATUS);
  511. atomic_set(&host->stuck_timeout, 0);
  512. host->status_reg = stat;
  513. set_bit(IMXMCI_PEND_DMA_END_b, &host->pending_events);
  514. tasklet_schedule(&host->tasklet);
  515. }
  516. static irqreturn_t imxmci_irq(int irq, void *devid)
  517. {
  518. struct imxmci_host *host = devid;
  519. u32 stat = readw(host->base + MMC_REG_STATUS);
  520. int handled = 1;
  521. writew(host->imask | INT_MASK_SDIO | INT_MASK_AUTO_CARD_DETECT,
  522. host->base + MMC_REG_INT_MASK);
  523. atomic_set(&host->stuck_timeout, 0);
  524. host->status_reg = stat;
  525. set_bit(IMXMCI_PEND_IRQ_b, &host->pending_events);
  526. set_bit(IMXMCI_PEND_STARTED_b, &host->pending_events);
  527. tasklet_schedule(&host->tasklet);
  528. return IRQ_RETVAL(handled);
  529. }
  530. static void imxmci_tasklet_fnc(unsigned long data)
  531. {
  532. struct imxmci_host *host = (struct imxmci_host *)data;
  533. u32 stat;
  534. unsigned int data_dir_mask = 0; /* STATUS_WR_CRC_ERROR_CODE_MASK */
  535. int timeout = 0;
  536. if (atomic_read(&host->stuck_timeout) > 4) {
  537. char *what;
  538. timeout = 1;
  539. stat = readw(host->base + MMC_REG_STATUS);
  540. host->status_reg = stat;
  541. if (test_bit(IMXMCI_PEND_WAIT_RESP_b, &host->pending_events))
  542. if (test_bit(IMXMCI_PEND_DMA_DATA_b, &host->pending_events))
  543. what = "RESP+DMA";
  544. else
  545. what = "RESP";
  546. else
  547. if (test_bit(IMXMCI_PEND_DMA_DATA_b, &host->pending_events))
  548. if (test_bit(IMXMCI_PEND_DMA_END_b, &host->pending_events))
  549. what = "DATA";
  550. else
  551. what = "DMA";
  552. else
  553. what = "???";
  554. dev_err(mmc_dev(host->mmc),
  555. "%s TIMEOUT, hardware stucked STATUS = 0x%04x IMASK = 0x%04x\n",
  556. what, stat,
  557. readw(host->base + MMC_REG_INT_MASK));
  558. dev_err(mmc_dev(host->mmc),
  559. "CMD_DAT_CONT = 0x%04x, MMC_BLK_LEN = 0x%04x, MMC_NOB = 0x%04x, DMA_CCR = 0x%08x\n",
  560. readw(host->base + MMC_REG_CMD_DAT_CONT),
  561. readw(host->base + MMC_REG_BLK_LEN),
  562. readw(host->base + MMC_REG_NOB),
  563. CCR(host->dma));
  564. dev_err(mmc_dev(host->mmc), "CMD%d, prevCMD%d, bus %d-bit, dma_size = 0x%x\n",
  565. host->cmd ? host->cmd->opcode : 0,
  566. host->prev_cmd_code,
  567. 1 << host->actual_bus_width, host->dma_size);
  568. }
  569. if (!host->present || timeout)
  570. host->status_reg = STATUS_TIME_OUT_RESP | STATUS_TIME_OUT_READ |
  571. STATUS_CRC_READ_ERR | STATUS_CRC_WRITE_ERR;
  572. if (test_bit(IMXMCI_PEND_IRQ_b, &host->pending_events) || timeout) {
  573. clear_bit(IMXMCI_PEND_IRQ_b, &host->pending_events);
  574. stat = readw(host->base + MMC_REG_STATUS);
  575. /*
  576. * This is not required in theory, but there is chance to miss some flag
  577. * which clears automatically by mask write, FreeScale original code keeps
  578. * stat from IRQ time so do I
  579. */
  580. stat |= host->status_reg;
  581. if (test_bit(IMXMCI_PEND_CPU_DATA_b, &host->pending_events))
  582. stat &= ~STATUS_CRC_READ_ERR;
  583. if (test_bit(IMXMCI_PEND_WAIT_RESP_b, &host->pending_events)) {
  584. imxmci_busy_wait_for_status(host, &stat,
  585. STATUS_END_CMD_RESP | STATUS_ERR_MASK,
  586. 20, "imxmci_tasklet_fnc resp (ERRATUM #4)");
  587. }
  588. if (stat & (STATUS_END_CMD_RESP | STATUS_ERR_MASK)) {
  589. if (test_and_clear_bit(IMXMCI_PEND_WAIT_RESP_b, &host->pending_events))
  590. imxmci_cmd_done(host, stat);
  591. if (host->data && (stat & STATUS_ERR_MASK))
  592. imxmci_data_done(host, stat);
  593. }
  594. if (test_bit(IMXMCI_PEND_CPU_DATA_b, &host->pending_events)) {
  595. stat |= readw(host->base + MMC_REG_STATUS);
  596. if (imxmci_cpu_driven_data(host, &stat)) {
  597. if (test_and_clear_bit(IMXMCI_PEND_WAIT_RESP_b, &host->pending_events))
  598. imxmci_cmd_done(host, stat);
  599. atomic_clear_mask(IMXMCI_PEND_IRQ_m|IMXMCI_PEND_CPU_DATA_m,
  600. &host->pending_events);
  601. imxmci_data_done(host, stat);
  602. }
  603. }
  604. }
  605. if (test_bit(IMXMCI_PEND_DMA_END_b, &host->pending_events) &&
  606. !test_bit(IMXMCI_PEND_WAIT_RESP_b, &host->pending_events)) {
  607. stat = readw(host->base + MMC_REG_STATUS);
  608. /* Same as above */
  609. stat |= host->status_reg;
  610. if (host->dma_dir == DMA_TO_DEVICE)
  611. data_dir_mask = STATUS_WRITE_OP_DONE;
  612. else
  613. data_dir_mask = STATUS_DATA_TRANS_DONE;
  614. if (stat & data_dir_mask) {
  615. clear_bit(IMXMCI_PEND_DMA_END_b, &host->pending_events);
  616. imxmci_data_done(host, stat);
  617. }
  618. }
  619. if (test_and_clear_bit(IMXMCI_PEND_CARD_XCHG_b, &host->pending_events)) {
  620. if (host->cmd)
  621. imxmci_cmd_done(host, STATUS_TIME_OUT_RESP);
  622. if (host->data)
  623. imxmci_data_done(host, STATUS_TIME_OUT_READ |
  624. STATUS_CRC_READ_ERR | STATUS_CRC_WRITE_ERR);
  625. if (host->req)
  626. imxmci_finish_request(host, host->req);
  627. mmc_detect_change(host->mmc, msecs_to_jiffies(100));
  628. }
  629. }
  630. static void imxmci_request(struct mmc_host *mmc, struct mmc_request *req)
  631. {
  632. struct imxmci_host *host = mmc_priv(mmc);
  633. unsigned int cmdat;
  634. WARN_ON(host->req != NULL);
  635. host->req = req;
  636. cmdat = 0;
  637. if (req->data) {
  638. imxmci_setup_data(host, req->data);
  639. cmdat |= CMD_DAT_CONT_DATA_ENABLE;
  640. if (req->data->flags & MMC_DATA_WRITE)
  641. cmdat |= CMD_DAT_CONT_WRITE;
  642. if (req->data->flags & MMC_DATA_STREAM)
  643. cmdat |= CMD_DAT_CONT_STREAM_BLOCK;
  644. }
  645. imxmci_start_cmd(host, req->cmd, cmdat);
  646. }
  647. #define CLK_RATE 19200000
  648. static void imxmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
  649. {
  650. struct imxmci_host *host = mmc_priv(mmc);
  651. int prescaler;
  652. if (ios->bus_width == MMC_BUS_WIDTH_4) {
  653. host->actual_bus_width = MMC_BUS_WIDTH_4;
  654. imx_gpio_mode(PB11_PF_SD_DAT3);
  655. BLR(host->dma) = 0; /* burst 64 byte read/write */
  656. } else {
  657. host->actual_bus_width = MMC_BUS_WIDTH_1;
  658. imx_gpio_mode(GPIO_PORTB | GPIO_IN | GPIO_PUEN | 11);
  659. BLR(host->dma) = 16; /* burst 16 byte read/write */
  660. }
  661. if (host->power_mode != ios->power_mode) {
  662. switch (ios->power_mode) {
  663. case MMC_POWER_OFF:
  664. break;
  665. case MMC_POWER_UP:
  666. set_bit(IMXMCI_PEND_SET_INIT_b, &host->pending_events);
  667. break;
  668. case MMC_POWER_ON:
  669. break;
  670. }
  671. host->power_mode = ios->power_mode;
  672. }
  673. if (ios->clock) {
  674. unsigned int clk;
  675. u16 reg;
  676. /* The prescaler is 5 for PERCLK2 equal to 96MHz
  677. * then 96MHz / 5 = 19.2 MHz
  678. */
  679. clk = clk_get_rate(host->clk);
  680. prescaler = (clk + (CLK_RATE * 7) / 8) / CLK_RATE;
  681. switch (prescaler) {
  682. case 0:
  683. case 1: prescaler = 0;
  684. break;
  685. case 2: prescaler = 1;
  686. break;
  687. case 3: prescaler = 2;
  688. break;
  689. case 4: prescaler = 4;
  690. break;
  691. default:
  692. case 5: prescaler = 5;
  693. break;
  694. }
  695. dev_dbg(mmc_dev(host->mmc), "PERCLK2 %d MHz -> prescaler %d\n",
  696. clk, prescaler);
  697. for (clk = 0; clk < 8; clk++) {
  698. int x;
  699. x = CLK_RATE / (1 << clk);
  700. if (x <= ios->clock)
  701. break;
  702. }
  703. /* enable controller */
  704. reg = readw(host->base + MMC_REG_STR_STP_CLK);
  705. writew(reg | STR_STP_CLK_ENABLE,
  706. host->base + MMC_REG_STR_STP_CLK);
  707. imxmci_stop_clock(host);
  708. writew((prescaler << 3) | clk, host->base + MMC_REG_CLK_RATE);
  709. /*
  710. * Under my understanding, clock should not be started there, because it would
  711. * initiate SDHC sequencer and send last or random command into card
  712. */
  713. /* imxmci_start_clock(host); */
  714. dev_dbg(mmc_dev(host->mmc),
  715. "MMC_CLK_RATE: 0x%08x\n",
  716. readw(host->base + MMC_REG_CLK_RATE));
  717. } else {
  718. imxmci_stop_clock(host);
  719. }
  720. }
  721. static int imxmci_get_ro(struct mmc_host *mmc)
  722. {
  723. struct imxmci_host *host = mmc_priv(mmc);
  724. if (host->pdata && host->pdata->get_ro)
  725. return !!host->pdata->get_ro(mmc_dev(mmc));
  726. /*
  727. * Board doesn't support read only detection; let the mmc core
  728. * decide what to do.
  729. */
  730. return -ENOSYS;
  731. }
  732. static const struct mmc_host_ops imxmci_ops = {
  733. .request = imxmci_request,
  734. .set_ios = imxmci_set_ios,
  735. .get_ro = imxmci_get_ro,
  736. };
  737. static void imxmci_check_status(unsigned long data)
  738. {
  739. struct imxmci_host *host = (struct imxmci_host *)data;
  740. if (host->pdata && host->pdata->card_present &&
  741. host->pdata->card_present(mmc_dev(host->mmc)) != host->present) {
  742. host->present ^= 1;
  743. dev_info(mmc_dev(host->mmc), "card %s\n",
  744. host->present ? "inserted" : "removed");
  745. set_bit(IMXMCI_PEND_CARD_XCHG_b, &host->pending_events);
  746. tasklet_schedule(&host->tasklet);
  747. }
  748. if (test_bit(IMXMCI_PEND_WAIT_RESP_b, &host->pending_events) ||
  749. test_bit(IMXMCI_PEND_DMA_DATA_b, &host->pending_events)) {
  750. atomic_inc(&host->stuck_timeout);
  751. if (atomic_read(&host->stuck_timeout) > 4)
  752. tasklet_schedule(&host->tasklet);
  753. } else {
  754. atomic_set(&host->stuck_timeout, 0);
  755. }
  756. mod_timer(&host->timer, jiffies + (HZ>>1));
  757. }
  758. static int __init imxmci_probe(struct platform_device *pdev)
  759. {
  760. struct mmc_host *mmc;
  761. struct imxmci_host *host = NULL;
  762. struct resource *r;
  763. int ret = 0, irq;
  764. u16 rev_no;
  765. pr_info("i.MX mmc driver\n");
  766. r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  767. irq = platform_get_irq(pdev, 0);
  768. if (!r || irq < 0)
  769. return -ENXIO;
  770. r = request_mem_region(r->start, resource_size(r), pdev->name);
  771. if (!r)
  772. return -EBUSY;
  773. mmc = mmc_alloc_host(sizeof(struct imxmci_host), &pdev->dev);
  774. if (!mmc) {
  775. ret = -ENOMEM;
  776. goto out;
  777. }
  778. mmc->ops = &imxmci_ops;
  779. mmc->f_min = 150000;
  780. mmc->f_max = CLK_RATE/2;
  781. mmc->ocr_avail = MMC_VDD_32_33;
  782. mmc->caps = MMC_CAP_4_BIT_DATA;
  783. /* MMC core transfer sizes tunable parameters */
  784. mmc->max_segs = 64;
  785. mmc->max_seg_size = 64*512; /* default PAGE_CACHE_SIZE */
  786. mmc->max_req_size = 64*512; /* default PAGE_CACHE_SIZE */
  787. mmc->max_blk_size = 2048;
  788. mmc->max_blk_count = 65535;
  789. host = mmc_priv(mmc);
  790. host->base = ioremap(r->start, resource_size(r));
  791. if (!host->base) {
  792. ret = -ENOMEM;
  793. goto out;
  794. }
  795. host->mmc = mmc;
  796. host->dma_allocated = 0;
  797. host->pdata = pdev->dev.platform_data;
  798. if (!host->pdata)
  799. dev_warn(&pdev->dev, "No platform data provided!\n");
  800. spin_lock_init(&host->lock);
  801. host->res = r;
  802. host->irq = irq;
  803. host->clk = clk_get(&pdev->dev, "perclk2");
  804. if (IS_ERR(host->clk)) {
  805. ret = PTR_ERR(host->clk);
  806. goto out;
  807. }
  808. clk_enable(host->clk);
  809. imx_gpio_mode(PB8_PF_SD_DAT0);
  810. imx_gpio_mode(PB9_PF_SD_DAT1);
  811. imx_gpio_mode(PB10_PF_SD_DAT2);
  812. /* Configured as GPIO with pull-up to ensure right MCC card mode */
  813. /* Switched to PB11_PF_SD_DAT3 if 4 bit bus is configured */
  814. imx_gpio_mode(GPIO_PORTB | GPIO_IN | GPIO_PUEN | 11);
  815. /* imx_gpio_mode(PB11_PF_SD_DAT3); */
  816. imx_gpio_mode(PB12_PF_SD_CLK);
  817. imx_gpio_mode(PB13_PF_SD_CMD);
  818. imxmci_softreset(host);
  819. rev_no = readw(host->base + MMC_REG_REV_NO);
  820. if (rev_no != 0x390) {
  821. dev_err(mmc_dev(host->mmc), "wrong rev.no. 0x%08x. aborting.\n",
  822. readw(host->base + MMC_REG_REV_NO));
  823. goto out;
  824. }
  825. /* recommended in data sheet */
  826. writew(0x2db4, host->base + MMC_REG_READ_TO);
  827. host->imask = IMXMCI_INT_MASK_DEFAULT;
  828. writew(host->imask, host->base + MMC_REG_INT_MASK);
  829. host->dma = imx_dma_request_by_prio(DRIVER_NAME, DMA_PRIO_LOW);
  830. if(host->dma < 0) {
  831. dev_err(mmc_dev(host->mmc), "imx_dma_request_by_prio failed\n");
  832. ret = -EBUSY;
  833. goto out;
  834. }
  835. host->dma_allocated = 1;
  836. imx_dma_setup_handlers(host->dma, imxmci_dma_irq, NULL, host);
  837. RSSR(host->dma) = DMA_REQ_SDHC;
  838. tasklet_init(&host->tasklet, imxmci_tasklet_fnc, (unsigned long)host);
  839. host->status_reg=0;
  840. host->pending_events=0;
  841. ret = request_irq(host->irq, imxmci_irq, 0, DRIVER_NAME, host);
  842. if (ret)
  843. goto out;
  844. if (host->pdata && host->pdata->card_present)
  845. host->present = host->pdata->card_present(mmc_dev(mmc));
  846. else /* if there is no way to detect assume that card is present */
  847. host->present = 1;
  848. init_timer(&host->timer);
  849. host->timer.data = (unsigned long)host;
  850. host->timer.function = imxmci_check_status;
  851. add_timer(&host->timer);
  852. mod_timer(&host->timer, jiffies + (HZ >> 1));
  853. platform_set_drvdata(pdev, mmc);
  854. mmc_add_host(mmc);
  855. return 0;
  856. out:
  857. if (host) {
  858. if (host->dma_allocated) {
  859. imx_dma_free(host->dma);
  860. host->dma_allocated = 0;
  861. }
  862. if (host->clk) {
  863. clk_disable(host->clk);
  864. clk_put(host->clk);
  865. }
  866. if (host->base)
  867. iounmap(host->base);
  868. }
  869. if (mmc)
  870. mmc_free_host(mmc);
  871. release_mem_region(r->start, resource_size(r));
  872. return ret;
  873. }
  874. static int __exit imxmci_remove(struct platform_device *pdev)
  875. {
  876. struct mmc_host *mmc = platform_get_drvdata(pdev);
  877. platform_set_drvdata(pdev, NULL);
  878. if (mmc) {
  879. struct imxmci_host *host = mmc_priv(mmc);
  880. tasklet_disable(&host->tasklet);
  881. del_timer_sync(&host->timer);
  882. mmc_remove_host(mmc);
  883. free_irq(host->irq, host);
  884. iounmap(host->base);
  885. if (host->dma_allocated) {
  886. imx_dma_free(host->dma);
  887. host->dma_allocated = 0;
  888. }
  889. tasklet_kill(&host->tasklet);
  890. clk_disable(host->clk);
  891. clk_put(host->clk);
  892. release_mem_region(host->res->start, resource_size(host->res));
  893. mmc_free_host(mmc);
  894. }
  895. return 0;
  896. }
  897. #ifdef CONFIG_PM
  898. static int imxmci_suspend(struct platform_device *dev, pm_message_t state)
  899. {
  900. struct mmc_host *mmc = platform_get_drvdata(dev);
  901. int ret = 0;
  902. if (mmc)
  903. ret = mmc_suspend_host(mmc);
  904. return ret;
  905. }
  906. static int imxmci_resume(struct platform_device *dev)
  907. {
  908. struct mmc_host *mmc = platform_get_drvdata(dev);
  909. struct imxmci_host *host;
  910. int ret = 0;
  911. if (mmc) {
  912. host = mmc_priv(mmc);
  913. if (host)
  914. set_bit(IMXMCI_PEND_SET_INIT_b, &host->pending_events);
  915. ret = mmc_resume_host(mmc);
  916. }
  917. return ret;
  918. }
  919. #else
  920. #define imxmci_suspend NULL
  921. #define imxmci_resume NULL
  922. #endif /* CONFIG_PM */
  923. static struct platform_driver imxmci_driver = {
  924. .remove = __exit_p(imxmci_remove),
  925. .suspend = imxmci_suspend,
  926. .resume = imxmci_resume,
  927. .driver = {
  928. .name = DRIVER_NAME,
  929. .owner = THIS_MODULE,
  930. }
  931. };
  932. static int __init imxmci_init(void)
  933. {
  934. return platform_driver_probe(&imxmci_driver, imxmci_probe);
  935. }
  936. static void __exit imxmci_exit(void)
  937. {
  938. platform_driver_unregister(&imxmci_driver);
  939. }
  940. module_init(imxmci_init);
  941. module_exit(imxmci_exit);
  942. MODULE_DESCRIPTION("i.MX Multimedia Card Interface Driver");
  943. MODULE_AUTHOR("Sascha Hauer, Pengutronix");
  944. MODULE_LICENSE("GPL");
  945. MODULE_ALIAS("platform:imx-mmc");