tmio_mmc_pio.c 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189
  1. /*
  2. * linux/drivers/mmc/host/tmio_mmc_pio.c
  3. *
  4. * Copyright (C) 2011 Guennadi Liakhovetski
  5. * Copyright (C) 2007 Ian Molton
  6. * Copyright (C) 2004 Ian Molton
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. *
  12. * Driver for the MMC / SD / SDIO IP found in:
  13. *
  14. * TC6393XB, TC6391XB, TC6387XB, T7L66XB, ASIC3, SH-Mobile SoCs
  15. *
  16. * This driver draws mainly on scattered spec sheets, Reverse engineering
  17. * of the toshiba e800 SD driver and some parts of the 2.4 ASIC3 driver (4 bit
  18. * support). (Further 4 bit support from a later datasheet).
  19. *
  20. * TODO:
  21. * Investigate using a workqueue for PIO transfers
  22. * Eliminate FIXMEs
  23. * SDIO support
  24. * Better Power management
  25. * Handle MMC errors better
  26. * double buffer support
  27. *
  28. */
  29. #include <linux/delay.h>
  30. #include <linux/device.h>
  31. #include <linux/highmem.h>
  32. #include <linux/interrupt.h>
  33. #include <linux/io.h>
  34. #include <linux/irq.h>
  35. #include <linux/mfd/tmio.h>
  36. #include <linux/mmc/host.h>
  37. #include <linux/mmc/mmc.h>
  38. #include <linux/mmc/slot-gpio.h>
  39. #include <linux/mmc/tmio.h>
  40. #include <linux/module.h>
  41. #include <linux/pagemap.h>
  42. #include <linux/platform_device.h>
  43. #include <linux/pm_qos.h>
  44. #include <linux/pm_runtime.h>
  45. #include <linux/regulator/consumer.h>
  46. #include <linux/scatterlist.h>
  47. #include <linux/spinlock.h>
  48. #include <linux/workqueue.h>
  49. #include "tmio_mmc.h"
  50. void tmio_mmc_enable_mmc_irqs(struct tmio_mmc_host *host, u32 i)
  51. {
  52. host->sdcard_irq_mask &= ~(i & TMIO_MASK_IRQ);
  53. sd_ctrl_write32(host, CTL_IRQ_MASK, host->sdcard_irq_mask);
  54. }
  55. void tmio_mmc_disable_mmc_irqs(struct tmio_mmc_host *host, u32 i)
  56. {
  57. host->sdcard_irq_mask |= (i & TMIO_MASK_IRQ);
  58. sd_ctrl_write32(host, CTL_IRQ_MASK, host->sdcard_irq_mask);
  59. }
  60. static void tmio_mmc_ack_mmc_irqs(struct tmio_mmc_host *host, u32 i)
  61. {
  62. sd_ctrl_write32(host, CTL_STATUS, ~i);
  63. }
  64. static void tmio_mmc_init_sg(struct tmio_mmc_host *host, struct mmc_data *data)
  65. {
  66. host->sg_len = data->sg_len;
  67. host->sg_ptr = data->sg;
  68. host->sg_orig = data->sg;
  69. host->sg_off = 0;
  70. }
  71. static int tmio_mmc_next_sg(struct tmio_mmc_host *host)
  72. {
  73. host->sg_ptr = sg_next(host->sg_ptr);
  74. host->sg_off = 0;
  75. return --host->sg_len;
  76. }
  77. #ifdef CONFIG_MMC_DEBUG
  78. #define STATUS_TO_TEXT(a, status, i) \
  79. do { \
  80. if (status & TMIO_STAT_##a) { \
  81. if (i++) \
  82. printk(" | "); \
  83. printk(#a); \
  84. } \
  85. } while (0)
  86. static void pr_debug_status(u32 status)
  87. {
  88. int i = 0;
  89. pr_debug("status: %08x = ", status);
  90. STATUS_TO_TEXT(CARD_REMOVE, status, i);
  91. STATUS_TO_TEXT(CARD_INSERT, status, i);
  92. STATUS_TO_TEXT(SIGSTATE, status, i);
  93. STATUS_TO_TEXT(WRPROTECT, status, i);
  94. STATUS_TO_TEXT(CARD_REMOVE_A, status, i);
  95. STATUS_TO_TEXT(CARD_INSERT_A, status, i);
  96. STATUS_TO_TEXT(SIGSTATE_A, status, i);
  97. STATUS_TO_TEXT(CMD_IDX_ERR, status, i);
  98. STATUS_TO_TEXT(STOPBIT_ERR, status, i);
  99. STATUS_TO_TEXT(ILL_FUNC, status, i);
  100. STATUS_TO_TEXT(CMD_BUSY, status, i);
  101. STATUS_TO_TEXT(CMDRESPEND, status, i);
  102. STATUS_TO_TEXT(DATAEND, status, i);
  103. STATUS_TO_TEXT(CRCFAIL, status, i);
  104. STATUS_TO_TEXT(DATATIMEOUT, status, i);
  105. STATUS_TO_TEXT(CMDTIMEOUT, status, i);
  106. STATUS_TO_TEXT(RXOVERFLOW, status, i);
  107. STATUS_TO_TEXT(TXUNDERRUN, status, i);
  108. STATUS_TO_TEXT(RXRDY, status, i);
  109. STATUS_TO_TEXT(TXRQ, status, i);
  110. STATUS_TO_TEXT(ILL_ACCESS, status, i);
  111. printk("\n");
  112. }
  113. #else
  114. #define pr_debug_status(s) do { } while (0)
  115. #endif
  116. static void tmio_mmc_enable_sdio_irq(struct mmc_host *mmc, int enable)
  117. {
  118. struct tmio_mmc_host *host = mmc_priv(mmc);
  119. if (enable) {
  120. host->sdio_irq_mask = TMIO_SDIO_MASK_ALL &
  121. ~TMIO_SDIO_STAT_IOIRQ;
  122. sd_ctrl_write16(host, CTL_TRANSACTION_CTL, 0x0001);
  123. sd_ctrl_write16(host, CTL_SDIO_IRQ_MASK, host->sdio_irq_mask);
  124. } else {
  125. host->sdio_irq_mask = TMIO_SDIO_MASK_ALL;
  126. sd_ctrl_write16(host, CTL_SDIO_IRQ_MASK, host->sdio_irq_mask);
  127. sd_ctrl_write16(host, CTL_TRANSACTION_CTL, 0x0000);
  128. }
  129. }
  130. static void tmio_mmc_set_clock(struct tmio_mmc_host *host, int new_clock)
  131. {
  132. u32 clk = 0, clock;
  133. if (new_clock) {
  134. for (clock = host->mmc->f_min, clk = 0x80000080;
  135. new_clock >= (clock<<1); clk >>= 1)
  136. clock <<= 1;
  137. clk |= 0x100;
  138. }
  139. if (host->set_clk_div)
  140. host->set_clk_div(host->pdev, (clk>>22) & 1);
  141. sd_ctrl_write16(host, CTL_SD_CARD_CLK_CTL, clk & 0x1ff);
  142. msleep(10);
  143. }
  144. static void tmio_mmc_clk_stop(struct tmio_mmc_host *host)
  145. {
  146. /* implicit BUG_ON(!res) */
  147. if (host->pdata->flags & TMIO_MMC_HAVE_HIGH_REG) {
  148. sd_ctrl_write16(host, CTL_CLK_AND_WAIT_CTL, 0x0000);
  149. msleep(10);
  150. }
  151. sd_ctrl_write16(host, CTL_SD_CARD_CLK_CTL, ~0x0100 &
  152. sd_ctrl_read16(host, CTL_SD_CARD_CLK_CTL));
  153. msleep(10);
  154. }
  155. static void tmio_mmc_clk_start(struct tmio_mmc_host *host)
  156. {
  157. sd_ctrl_write16(host, CTL_SD_CARD_CLK_CTL, 0x0100 |
  158. sd_ctrl_read16(host, CTL_SD_CARD_CLK_CTL));
  159. msleep(10);
  160. /* implicit BUG_ON(!res) */
  161. if (host->pdata->flags & TMIO_MMC_HAVE_HIGH_REG) {
  162. sd_ctrl_write16(host, CTL_CLK_AND_WAIT_CTL, 0x0100);
  163. msleep(10);
  164. }
  165. }
  166. static void tmio_mmc_reset(struct tmio_mmc_host *host)
  167. {
  168. /* FIXME - should we set stop clock reg here */
  169. sd_ctrl_write16(host, CTL_RESET_SD, 0x0000);
  170. /* implicit BUG_ON(!res) */
  171. if (host->pdata->flags & TMIO_MMC_HAVE_HIGH_REG)
  172. sd_ctrl_write16(host, CTL_RESET_SDIO, 0x0000);
  173. msleep(10);
  174. sd_ctrl_write16(host, CTL_RESET_SD, 0x0001);
  175. if (host->pdata->flags & TMIO_MMC_HAVE_HIGH_REG)
  176. sd_ctrl_write16(host, CTL_RESET_SDIO, 0x0001);
  177. msleep(10);
  178. }
  179. static void tmio_mmc_reset_work(struct work_struct *work)
  180. {
  181. struct tmio_mmc_host *host = container_of(work, struct tmio_mmc_host,
  182. delayed_reset_work.work);
  183. struct mmc_request *mrq;
  184. unsigned long flags;
  185. spin_lock_irqsave(&host->lock, flags);
  186. mrq = host->mrq;
  187. /*
  188. * is request already finished? Since we use a non-blocking
  189. * cancel_delayed_work(), it can happen, that a .set_ios() call preempts
  190. * us, so, have to check for IS_ERR(host->mrq)
  191. */
  192. if (IS_ERR_OR_NULL(mrq)
  193. || time_is_after_jiffies(host->last_req_ts +
  194. msecs_to_jiffies(2000))) {
  195. spin_unlock_irqrestore(&host->lock, flags);
  196. return;
  197. }
  198. dev_warn(&host->pdev->dev,
  199. "timeout waiting for hardware interrupt (CMD%u)\n",
  200. mrq->cmd->opcode);
  201. if (host->data)
  202. host->data->error = -ETIMEDOUT;
  203. else if (host->cmd)
  204. host->cmd->error = -ETIMEDOUT;
  205. else
  206. mrq->cmd->error = -ETIMEDOUT;
  207. host->cmd = NULL;
  208. host->data = NULL;
  209. host->force_pio = false;
  210. spin_unlock_irqrestore(&host->lock, flags);
  211. tmio_mmc_reset(host);
  212. /* Ready for new calls */
  213. host->mrq = NULL;
  214. tmio_mmc_abort_dma(host);
  215. mmc_request_done(host->mmc, mrq);
  216. }
  217. /* called with host->lock held, interrupts disabled */
  218. static void tmio_mmc_finish_request(struct tmio_mmc_host *host)
  219. {
  220. struct mmc_request *mrq;
  221. unsigned long flags;
  222. spin_lock_irqsave(&host->lock, flags);
  223. mrq = host->mrq;
  224. if (IS_ERR_OR_NULL(mrq)) {
  225. spin_unlock_irqrestore(&host->lock, flags);
  226. return;
  227. }
  228. host->cmd = NULL;
  229. host->data = NULL;
  230. host->force_pio = false;
  231. cancel_delayed_work(&host->delayed_reset_work);
  232. host->mrq = NULL;
  233. spin_unlock_irqrestore(&host->lock, flags);
  234. if (mrq->cmd->error || (mrq->data && mrq->data->error))
  235. tmio_mmc_abort_dma(host);
  236. mmc_request_done(host->mmc, mrq);
  237. }
  238. static void tmio_mmc_done_work(struct work_struct *work)
  239. {
  240. struct tmio_mmc_host *host = container_of(work, struct tmio_mmc_host,
  241. done);
  242. tmio_mmc_finish_request(host);
  243. }
  244. /* These are the bitmasks the tmio chip requires to implement the MMC response
  245. * types. Note that R1 and R6 are the same in this scheme. */
  246. #define APP_CMD 0x0040
  247. #define RESP_NONE 0x0300
  248. #define RESP_R1 0x0400
  249. #define RESP_R1B 0x0500
  250. #define RESP_R2 0x0600
  251. #define RESP_R3 0x0700
  252. #define DATA_PRESENT 0x0800
  253. #define TRANSFER_READ 0x1000
  254. #define TRANSFER_MULTI 0x2000
  255. #define SECURITY_CMD 0x4000
  256. static int tmio_mmc_start_command(struct tmio_mmc_host *host, struct mmc_command *cmd)
  257. {
  258. struct mmc_data *data = host->data;
  259. int c = cmd->opcode;
  260. u32 irq_mask = TMIO_MASK_CMD;
  261. /* CMD12 is handled by hardware */
  262. if (cmd->opcode == MMC_STOP_TRANSMISSION && !cmd->arg) {
  263. sd_ctrl_write16(host, CTL_STOP_INTERNAL_ACTION, 0x001);
  264. return 0;
  265. }
  266. switch (mmc_resp_type(cmd)) {
  267. case MMC_RSP_NONE: c |= RESP_NONE; break;
  268. case MMC_RSP_R1: c |= RESP_R1; break;
  269. case MMC_RSP_R1B: c |= RESP_R1B; break;
  270. case MMC_RSP_R2: c |= RESP_R2; break;
  271. case MMC_RSP_R3: c |= RESP_R3; break;
  272. default:
  273. pr_debug("Unknown response type %d\n", mmc_resp_type(cmd));
  274. return -EINVAL;
  275. }
  276. host->cmd = cmd;
  277. /* FIXME - this seems to be ok commented out but the spec suggest this bit
  278. * should be set when issuing app commands.
  279. * if(cmd->flags & MMC_FLAG_ACMD)
  280. * c |= APP_CMD;
  281. */
  282. if (data) {
  283. c |= DATA_PRESENT;
  284. if (data->blocks > 1) {
  285. sd_ctrl_write16(host, CTL_STOP_INTERNAL_ACTION, 0x100);
  286. c |= TRANSFER_MULTI;
  287. }
  288. if (data->flags & MMC_DATA_READ)
  289. c |= TRANSFER_READ;
  290. }
  291. if (!host->native_hotplug)
  292. irq_mask &= ~(TMIO_STAT_CARD_REMOVE | TMIO_STAT_CARD_INSERT);
  293. tmio_mmc_enable_mmc_irqs(host, irq_mask);
  294. /* Fire off the command */
  295. sd_ctrl_write32(host, CTL_ARG_REG, cmd->arg);
  296. sd_ctrl_write16(host, CTL_SD_CMD, c);
  297. return 0;
  298. }
  299. /*
  300. * This chip always returns (at least?) as much data as you ask for.
  301. * I'm unsure what happens if you ask for less than a block. This should be
  302. * looked into to ensure that a funny length read doesn't hose the controller.
  303. */
  304. static void tmio_mmc_pio_irq(struct tmio_mmc_host *host)
  305. {
  306. struct mmc_data *data = host->data;
  307. void *sg_virt;
  308. unsigned short *buf;
  309. unsigned int count;
  310. unsigned long flags;
  311. if ((host->chan_tx || host->chan_rx) && !host->force_pio) {
  312. pr_err("PIO IRQ in DMA mode!\n");
  313. return;
  314. } else if (!data) {
  315. pr_debug("Spurious PIO IRQ\n");
  316. return;
  317. }
  318. sg_virt = tmio_mmc_kmap_atomic(host->sg_ptr, &flags);
  319. buf = (unsigned short *)(sg_virt + host->sg_off);
  320. count = host->sg_ptr->length - host->sg_off;
  321. if (count > data->blksz)
  322. count = data->blksz;
  323. pr_debug("count: %08x offset: %08x flags %08x\n",
  324. count, host->sg_off, data->flags);
  325. /* Transfer the data */
  326. if (data->flags & MMC_DATA_READ)
  327. sd_ctrl_read16_rep(host, CTL_SD_DATA_PORT, buf, count >> 1);
  328. else
  329. sd_ctrl_write16_rep(host, CTL_SD_DATA_PORT, buf, count >> 1);
  330. host->sg_off += count;
  331. tmio_mmc_kunmap_atomic(host->sg_ptr, &flags, sg_virt);
  332. if (host->sg_off == host->sg_ptr->length)
  333. tmio_mmc_next_sg(host);
  334. return;
  335. }
  336. static void tmio_mmc_check_bounce_buffer(struct tmio_mmc_host *host)
  337. {
  338. if (host->sg_ptr == &host->bounce_sg) {
  339. unsigned long flags;
  340. void *sg_vaddr = tmio_mmc_kmap_atomic(host->sg_orig, &flags);
  341. memcpy(sg_vaddr, host->bounce_buf, host->bounce_sg.length);
  342. tmio_mmc_kunmap_atomic(host->sg_orig, &flags, sg_vaddr);
  343. }
  344. }
  345. /* needs to be called with host->lock held */
  346. void tmio_mmc_do_data_irq(struct tmio_mmc_host *host)
  347. {
  348. struct mmc_data *data = host->data;
  349. struct mmc_command *stop;
  350. host->data = NULL;
  351. if (!data) {
  352. dev_warn(&host->pdev->dev, "Spurious data end IRQ\n");
  353. return;
  354. }
  355. stop = data->stop;
  356. /* FIXME - return correct transfer count on errors */
  357. if (!data->error)
  358. data->bytes_xfered = data->blocks * data->blksz;
  359. else
  360. data->bytes_xfered = 0;
  361. pr_debug("Completed data request\n");
  362. /*
  363. * FIXME: other drivers allow an optional stop command of any given type
  364. * which we dont do, as the chip can auto generate them.
  365. * Perhaps we can be smarter about when to use auto CMD12 and
  366. * only issue the auto request when we know this is the desired
  367. * stop command, allowing fallback to the stop command the
  368. * upper layers expect. For now, we do what works.
  369. */
  370. if (data->flags & MMC_DATA_READ) {
  371. if (host->chan_rx && !host->force_pio)
  372. tmio_mmc_check_bounce_buffer(host);
  373. dev_dbg(&host->pdev->dev, "Complete Rx request %p\n",
  374. host->mrq);
  375. } else {
  376. dev_dbg(&host->pdev->dev, "Complete Tx request %p\n",
  377. host->mrq);
  378. }
  379. if (stop) {
  380. if (stop->opcode == MMC_STOP_TRANSMISSION && !stop->arg)
  381. sd_ctrl_write16(host, CTL_STOP_INTERNAL_ACTION, 0x000);
  382. else
  383. BUG();
  384. }
  385. schedule_work(&host->done);
  386. }
  387. static void tmio_mmc_data_irq(struct tmio_mmc_host *host)
  388. {
  389. struct mmc_data *data;
  390. spin_lock(&host->lock);
  391. data = host->data;
  392. if (!data)
  393. goto out;
  394. if (host->chan_tx && (data->flags & MMC_DATA_WRITE) && !host->force_pio) {
  395. /*
  396. * Has all data been written out yet? Testing on SuperH showed,
  397. * that in most cases the first interrupt comes already with the
  398. * BUSY status bit clear, but on some operations, like mount or
  399. * in the beginning of a write / sync / umount, there is one
  400. * DATAEND interrupt with the BUSY bit set, in this cases
  401. * waiting for one more interrupt fixes the problem.
  402. */
  403. if (!(sd_ctrl_read32(host, CTL_STATUS) & TMIO_STAT_CMD_BUSY)) {
  404. tmio_mmc_disable_mmc_irqs(host, TMIO_STAT_DATAEND);
  405. tasklet_schedule(&host->dma_complete);
  406. }
  407. } else if (host->chan_rx && (data->flags & MMC_DATA_READ) && !host->force_pio) {
  408. tmio_mmc_disable_mmc_irqs(host, TMIO_STAT_DATAEND);
  409. tasklet_schedule(&host->dma_complete);
  410. } else {
  411. tmio_mmc_do_data_irq(host);
  412. tmio_mmc_disable_mmc_irqs(host, TMIO_MASK_READOP | TMIO_MASK_WRITEOP);
  413. }
  414. out:
  415. spin_unlock(&host->lock);
  416. }
  417. static void tmio_mmc_cmd_irq(struct tmio_mmc_host *host,
  418. unsigned int stat)
  419. {
  420. struct mmc_command *cmd = host->cmd;
  421. int i, addr;
  422. spin_lock(&host->lock);
  423. if (!host->cmd) {
  424. pr_debug("Spurious CMD irq\n");
  425. goto out;
  426. }
  427. host->cmd = NULL;
  428. /* This controller is sicker than the PXA one. Not only do we need to
  429. * drop the top 8 bits of the first response word, we also need to
  430. * modify the order of the response for short response command types.
  431. */
  432. for (i = 3, addr = CTL_RESPONSE ; i >= 0 ; i--, addr += 4)
  433. cmd->resp[i] = sd_ctrl_read32(host, addr);
  434. if (cmd->flags & MMC_RSP_136) {
  435. cmd->resp[0] = (cmd->resp[0] << 8) | (cmd->resp[1] >> 24);
  436. cmd->resp[1] = (cmd->resp[1] << 8) | (cmd->resp[2] >> 24);
  437. cmd->resp[2] = (cmd->resp[2] << 8) | (cmd->resp[3] >> 24);
  438. cmd->resp[3] <<= 8;
  439. } else if (cmd->flags & MMC_RSP_R3) {
  440. cmd->resp[0] = cmd->resp[3];
  441. }
  442. if (stat & TMIO_STAT_CMDTIMEOUT)
  443. cmd->error = -ETIMEDOUT;
  444. else if (stat & TMIO_STAT_CRCFAIL && cmd->flags & MMC_RSP_CRC)
  445. cmd->error = -EILSEQ;
  446. /* If there is data to handle we enable data IRQs here, and
  447. * we will ultimatley finish the request in the data_end handler.
  448. * If theres no data or we encountered an error, finish now.
  449. */
  450. if (host->data && !cmd->error) {
  451. if (host->data->flags & MMC_DATA_READ) {
  452. if (host->force_pio || !host->chan_rx)
  453. tmio_mmc_enable_mmc_irqs(host, TMIO_MASK_READOP);
  454. else
  455. tasklet_schedule(&host->dma_issue);
  456. } else {
  457. if (host->force_pio || !host->chan_tx)
  458. tmio_mmc_enable_mmc_irqs(host, TMIO_MASK_WRITEOP);
  459. else
  460. tasklet_schedule(&host->dma_issue);
  461. }
  462. } else {
  463. schedule_work(&host->done);
  464. }
  465. out:
  466. spin_unlock(&host->lock);
  467. }
  468. static void tmio_mmc_card_irq_status(struct tmio_mmc_host *host,
  469. int *ireg, int *status)
  470. {
  471. *status = sd_ctrl_read32(host, CTL_STATUS);
  472. *ireg = *status & TMIO_MASK_IRQ & ~host->sdcard_irq_mask;
  473. pr_debug_status(*status);
  474. pr_debug_status(*ireg);
  475. }
  476. static bool __tmio_mmc_card_detect_irq(struct tmio_mmc_host *host,
  477. int ireg, int status)
  478. {
  479. struct mmc_host *mmc = host->mmc;
  480. /* Card insert / remove attempts */
  481. if (ireg & (TMIO_STAT_CARD_INSERT | TMIO_STAT_CARD_REMOVE)) {
  482. tmio_mmc_ack_mmc_irqs(host, TMIO_STAT_CARD_INSERT |
  483. TMIO_STAT_CARD_REMOVE);
  484. if ((((ireg & TMIO_STAT_CARD_REMOVE) && mmc->card) ||
  485. ((ireg & TMIO_STAT_CARD_INSERT) && !mmc->card)) &&
  486. !work_pending(&mmc->detect.work))
  487. mmc_detect_change(host->mmc, msecs_to_jiffies(100));
  488. return true;
  489. }
  490. return false;
  491. }
  492. irqreturn_t tmio_mmc_card_detect_irq(int irq, void *devid)
  493. {
  494. unsigned int ireg, status;
  495. struct tmio_mmc_host *host = devid;
  496. tmio_mmc_card_irq_status(host, &ireg, &status);
  497. __tmio_mmc_card_detect_irq(host, ireg, status);
  498. return IRQ_HANDLED;
  499. }
  500. EXPORT_SYMBOL(tmio_mmc_card_detect_irq);
  501. static bool __tmio_mmc_sdcard_irq(struct tmio_mmc_host *host,
  502. int ireg, int status)
  503. {
  504. /* Command completion */
  505. if (ireg & (TMIO_STAT_CMDRESPEND | TMIO_STAT_CMDTIMEOUT)) {
  506. tmio_mmc_ack_mmc_irqs(host,
  507. TMIO_STAT_CMDRESPEND |
  508. TMIO_STAT_CMDTIMEOUT);
  509. tmio_mmc_cmd_irq(host, status);
  510. return true;
  511. }
  512. /* Data transfer */
  513. if (ireg & (TMIO_STAT_RXRDY | TMIO_STAT_TXRQ)) {
  514. tmio_mmc_ack_mmc_irqs(host, TMIO_STAT_RXRDY | TMIO_STAT_TXRQ);
  515. tmio_mmc_pio_irq(host);
  516. return true;
  517. }
  518. /* Data transfer completion */
  519. if (ireg & TMIO_STAT_DATAEND) {
  520. tmio_mmc_ack_mmc_irqs(host, TMIO_STAT_DATAEND);
  521. tmio_mmc_data_irq(host);
  522. return true;
  523. }
  524. return false;
  525. }
  526. irqreturn_t tmio_mmc_sdcard_irq(int irq, void *devid)
  527. {
  528. unsigned int ireg, status;
  529. struct tmio_mmc_host *host = devid;
  530. tmio_mmc_card_irq_status(host, &ireg, &status);
  531. __tmio_mmc_sdcard_irq(host, ireg, status);
  532. return IRQ_HANDLED;
  533. }
  534. EXPORT_SYMBOL(tmio_mmc_sdcard_irq);
  535. irqreturn_t tmio_mmc_sdio_irq(int irq, void *devid)
  536. {
  537. struct tmio_mmc_host *host = devid;
  538. struct mmc_host *mmc = host->mmc;
  539. struct tmio_mmc_data *pdata = host->pdata;
  540. unsigned int ireg, status;
  541. if (!(pdata->flags & TMIO_MMC_SDIO_IRQ))
  542. return IRQ_HANDLED;
  543. status = sd_ctrl_read16(host, CTL_SDIO_STATUS);
  544. ireg = status & TMIO_SDIO_MASK_ALL & ~host->sdcard_irq_mask;
  545. sd_ctrl_write16(host, CTL_SDIO_STATUS, status & ~TMIO_SDIO_MASK_ALL);
  546. if (mmc->caps & MMC_CAP_SDIO_IRQ && ireg & TMIO_SDIO_STAT_IOIRQ)
  547. mmc_signal_sdio_irq(mmc);
  548. return IRQ_HANDLED;
  549. }
  550. EXPORT_SYMBOL(tmio_mmc_sdio_irq);
  551. irqreturn_t tmio_mmc_irq(int irq, void *devid)
  552. {
  553. struct tmio_mmc_host *host = devid;
  554. unsigned int ireg, status;
  555. pr_debug("MMC IRQ begin\n");
  556. tmio_mmc_card_irq_status(host, &ireg, &status);
  557. if (__tmio_mmc_card_detect_irq(host, ireg, status))
  558. return IRQ_HANDLED;
  559. if (__tmio_mmc_sdcard_irq(host, ireg, status))
  560. return IRQ_HANDLED;
  561. tmio_mmc_sdio_irq(irq, devid);
  562. return IRQ_HANDLED;
  563. }
  564. EXPORT_SYMBOL(tmio_mmc_irq);
  565. static int tmio_mmc_start_data(struct tmio_mmc_host *host,
  566. struct mmc_data *data)
  567. {
  568. struct tmio_mmc_data *pdata = host->pdata;
  569. pr_debug("setup data transfer: blocksize %08x nr_blocks %d\n",
  570. data->blksz, data->blocks);
  571. /* Some hardware cannot perform 2 byte requests in 4 bit mode */
  572. if (host->mmc->ios.bus_width == MMC_BUS_WIDTH_4) {
  573. int blksz_2bytes = pdata->flags & TMIO_MMC_BLKSZ_2BYTES;
  574. if (data->blksz < 2 || (data->blksz < 4 && !blksz_2bytes)) {
  575. pr_err("%s: %d byte block unsupported in 4 bit mode\n",
  576. mmc_hostname(host->mmc), data->blksz);
  577. return -EINVAL;
  578. }
  579. }
  580. tmio_mmc_init_sg(host, data);
  581. host->data = data;
  582. /* Set transfer length / blocksize */
  583. sd_ctrl_write16(host, CTL_SD_XFER_LEN, data->blksz);
  584. sd_ctrl_write16(host, CTL_XFER_BLK_COUNT, data->blocks);
  585. tmio_mmc_start_dma(host, data);
  586. return 0;
  587. }
  588. /* Process requests from the MMC layer */
  589. static void tmio_mmc_request(struct mmc_host *mmc, struct mmc_request *mrq)
  590. {
  591. struct tmio_mmc_host *host = mmc_priv(mmc);
  592. unsigned long flags;
  593. int ret;
  594. spin_lock_irqsave(&host->lock, flags);
  595. if (host->mrq) {
  596. pr_debug("request not null\n");
  597. if (IS_ERR(host->mrq)) {
  598. spin_unlock_irqrestore(&host->lock, flags);
  599. mrq->cmd->error = -EAGAIN;
  600. mmc_request_done(mmc, mrq);
  601. return;
  602. }
  603. }
  604. host->last_req_ts = jiffies;
  605. wmb();
  606. host->mrq = mrq;
  607. spin_unlock_irqrestore(&host->lock, flags);
  608. if (mrq->data) {
  609. ret = tmio_mmc_start_data(host, mrq->data);
  610. if (ret)
  611. goto fail;
  612. }
  613. ret = tmio_mmc_start_command(host, mrq->cmd);
  614. if (!ret) {
  615. schedule_delayed_work(&host->delayed_reset_work,
  616. msecs_to_jiffies(2000));
  617. return;
  618. }
  619. fail:
  620. host->force_pio = false;
  621. host->mrq = NULL;
  622. mrq->cmd->error = ret;
  623. mmc_request_done(mmc, mrq);
  624. }
  625. static int tmio_mmc_clk_update(struct mmc_host *mmc)
  626. {
  627. struct tmio_mmc_host *host = mmc_priv(mmc);
  628. struct tmio_mmc_data *pdata = host->pdata;
  629. int ret;
  630. if (!pdata->clk_enable)
  631. return -ENOTSUPP;
  632. ret = pdata->clk_enable(host->pdev, &mmc->f_max);
  633. if (!ret)
  634. mmc->f_min = mmc->f_max / 512;
  635. return ret;
  636. }
  637. static void tmio_mmc_power_on(struct tmio_mmc_host *host, unsigned short vdd)
  638. {
  639. struct mmc_host *mmc = host->mmc;
  640. int ret = 0;
  641. /* .set_ios() is returning void, so, no chance to report an error */
  642. if (host->set_pwr)
  643. host->set_pwr(host->pdev, 1);
  644. if (!IS_ERR(mmc->supply.vmmc)) {
  645. ret = mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, vdd);
  646. /*
  647. * Attention: empiric value. With a b43 WiFi SDIO card this
  648. * delay proved necessary for reliable card-insertion probing.
  649. * 100us were not enough. Is this the same 140us delay, as in
  650. * tmio_mmc_set_ios()?
  651. */
  652. udelay(200);
  653. }
  654. /*
  655. * It seems, VccQ should be switched on after Vcc, this is also what the
  656. * omap_hsmmc.c driver does.
  657. */
  658. if (!IS_ERR(mmc->supply.vqmmc) && !ret) {
  659. ret = regulator_enable(mmc->supply.vqmmc);
  660. udelay(200);
  661. }
  662. if (ret < 0)
  663. dev_dbg(&host->pdev->dev, "Regulators failed to power up: %d\n",
  664. ret);
  665. }
  666. static void tmio_mmc_power_off(struct tmio_mmc_host *host)
  667. {
  668. struct mmc_host *mmc = host->mmc;
  669. if (!IS_ERR(mmc->supply.vqmmc))
  670. regulator_disable(mmc->supply.vqmmc);
  671. if (!IS_ERR(mmc->supply.vmmc))
  672. mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, 0);
  673. if (host->set_pwr)
  674. host->set_pwr(host->pdev, 0);
  675. }
  676. /* Set MMC clock / power.
  677. * Note: This controller uses a simple divider scheme therefore it cannot
  678. * run a MMC card at full speed (20MHz). The max clock is 24MHz on SD, but as
  679. * MMC wont run that fast, it has to be clocked at 12MHz which is the next
  680. * slowest setting.
  681. */
  682. static void tmio_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
  683. {
  684. struct tmio_mmc_host *host = mmc_priv(mmc);
  685. struct device *dev = &host->pdev->dev;
  686. unsigned long flags;
  687. mutex_lock(&host->ios_lock);
  688. spin_lock_irqsave(&host->lock, flags);
  689. if (host->mrq) {
  690. if (IS_ERR(host->mrq)) {
  691. dev_dbg(dev,
  692. "%s.%d: concurrent .set_ios(), clk %u, mode %u\n",
  693. current->comm, task_pid_nr(current),
  694. ios->clock, ios->power_mode);
  695. host->mrq = ERR_PTR(-EINTR);
  696. } else {
  697. dev_dbg(dev,
  698. "%s.%d: CMD%u active since %lu, now %lu!\n",
  699. current->comm, task_pid_nr(current),
  700. host->mrq->cmd->opcode, host->last_req_ts, jiffies);
  701. }
  702. spin_unlock_irqrestore(&host->lock, flags);
  703. mutex_unlock(&host->ios_lock);
  704. return;
  705. }
  706. host->mrq = ERR_PTR(-EBUSY);
  707. spin_unlock_irqrestore(&host->lock, flags);
  708. /*
  709. * host->power toggles between false and true in both cases - either
  710. * or not the controller can be runtime-suspended during inactivity.
  711. * But if the controller has to be kept on, the runtime-pm usage_count
  712. * is kept positive, so no suspending actually takes place.
  713. */
  714. if (ios->power_mode == MMC_POWER_ON && ios->clock) {
  715. if (host->power != TMIO_MMC_ON_RUN) {
  716. tmio_mmc_clk_update(mmc);
  717. pm_runtime_get_sync(dev);
  718. if (host->resuming) {
  719. tmio_mmc_reset(host);
  720. host->resuming = false;
  721. }
  722. }
  723. if (host->power == TMIO_MMC_OFF_STOP)
  724. tmio_mmc_reset(host);
  725. tmio_mmc_set_clock(host, ios->clock);
  726. if (host->power == TMIO_MMC_OFF_STOP)
  727. /* power up SD card and the bus */
  728. tmio_mmc_power_on(host, ios->vdd);
  729. host->power = TMIO_MMC_ON_RUN;
  730. /* start bus clock */
  731. tmio_mmc_clk_start(host);
  732. } else if (ios->power_mode != MMC_POWER_UP) {
  733. struct tmio_mmc_data *pdata = host->pdata;
  734. unsigned int old_power = host->power;
  735. if (old_power != TMIO_MMC_OFF_STOP) {
  736. if (ios->power_mode == MMC_POWER_OFF) {
  737. tmio_mmc_power_off(host);
  738. host->power = TMIO_MMC_OFF_STOP;
  739. } else {
  740. host->power = TMIO_MMC_ON_STOP;
  741. }
  742. }
  743. if (old_power == TMIO_MMC_ON_RUN) {
  744. tmio_mmc_clk_stop(host);
  745. pm_runtime_put(dev);
  746. if (pdata->clk_disable)
  747. pdata->clk_disable(host->pdev);
  748. }
  749. }
  750. if (host->power != TMIO_MMC_OFF_STOP) {
  751. switch (ios->bus_width) {
  752. case MMC_BUS_WIDTH_1:
  753. sd_ctrl_write16(host, CTL_SD_MEM_CARD_OPT, 0x80e0);
  754. break;
  755. case MMC_BUS_WIDTH_4:
  756. sd_ctrl_write16(host, CTL_SD_MEM_CARD_OPT, 0x00e0);
  757. break;
  758. }
  759. }
  760. /* Let things settle. delay taken from winCE driver */
  761. udelay(140);
  762. if (PTR_ERR(host->mrq) == -EINTR)
  763. dev_dbg(&host->pdev->dev,
  764. "%s.%d: IOS interrupted: clk %u, mode %u",
  765. current->comm, task_pid_nr(current),
  766. ios->clock, ios->power_mode);
  767. host->mrq = NULL;
  768. mutex_unlock(&host->ios_lock);
  769. }
  770. static int tmio_mmc_get_ro(struct mmc_host *mmc)
  771. {
  772. struct tmio_mmc_host *host = mmc_priv(mmc);
  773. struct tmio_mmc_data *pdata = host->pdata;
  774. int ret = mmc_gpio_get_ro(mmc);
  775. if (ret >= 0)
  776. return ret;
  777. return !((pdata->flags & TMIO_MMC_WRPROTECT_DISABLE) ||
  778. (sd_ctrl_read32(host, CTL_STATUS) & TMIO_STAT_WRPROTECT));
  779. }
  780. static const struct mmc_host_ops tmio_mmc_ops = {
  781. .request = tmio_mmc_request,
  782. .set_ios = tmio_mmc_set_ios,
  783. .get_ro = tmio_mmc_get_ro,
  784. .get_cd = mmc_gpio_get_cd,
  785. .enable_sdio_irq = tmio_mmc_enable_sdio_irq,
  786. };
  787. static int tmio_mmc_init_ocr(struct tmio_mmc_host *host)
  788. {
  789. struct tmio_mmc_data *pdata = host->pdata;
  790. struct mmc_host *mmc = host->mmc;
  791. mmc_regulator_get_supply(mmc);
  792. /* use ocr_mask if no regulator */
  793. if (!mmc->ocr_avail)
  794. mmc->ocr_avail = pdata->ocr_mask;
  795. /*
  796. * try again.
  797. * There is possibility that regulator has not been probed
  798. */
  799. if (!mmc->ocr_avail)
  800. return -EPROBE_DEFER;
  801. return 0;
  802. }
  803. static void tmio_mmc_of_parse(struct platform_device *pdev,
  804. struct tmio_mmc_data *pdata)
  805. {
  806. const struct device_node *np = pdev->dev.of_node;
  807. if (!np)
  808. return;
  809. if (of_get_property(np, "toshiba,mmc-wrprotect-disable", NULL))
  810. pdata->flags |= TMIO_MMC_WRPROTECT_DISABLE;
  811. }
  812. int tmio_mmc_host_probe(struct tmio_mmc_host **host,
  813. struct platform_device *pdev,
  814. struct tmio_mmc_data *pdata)
  815. {
  816. struct tmio_mmc_host *_host;
  817. struct mmc_host *mmc;
  818. struct resource *res_ctl;
  819. int ret;
  820. u32 irq_mask = TMIO_MASK_CMD;
  821. tmio_mmc_of_parse(pdev, pdata);
  822. if (!(pdata->flags & TMIO_MMC_HAS_IDLE_WAIT))
  823. pdata->write16_hook = NULL;
  824. res_ctl = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  825. if (!res_ctl)
  826. return -EINVAL;
  827. mmc = mmc_alloc_host(sizeof(struct tmio_mmc_host), &pdev->dev);
  828. if (!mmc)
  829. return -ENOMEM;
  830. ret = mmc_of_parse(mmc);
  831. if (ret < 0)
  832. goto host_free;
  833. pdata->dev = &pdev->dev;
  834. _host = mmc_priv(mmc);
  835. _host->pdata = pdata;
  836. _host->mmc = mmc;
  837. _host->pdev = pdev;
  838. platform_set_drvdata(pdev, mmc);
  839. _host->set_pwr = pdata->set_pwr;
  840. _host->set_clk_div = pdata->set_clk_div;
  841. ret = tmio_mmc_init_ocr(_host);
  842. if (ret < 0)
  843. goto host_free;
  844. _host->ctl = ioremap(res_ctl->start, resource_size(res_ctl));
  845. if (!_host->ctl) {
  846. ret = -ENOMEM;
  847. goto host_free;
  848. }
  849. mmc->ops = &tmio_mmc_ops;
  850. mmc->caps |= MMC_CAP_4_BIT_DATA | pdata->capabilities;
  851. mmc->caps2 |= pdata->capabilities2;
  852. mmc->max_segs = 32;
  853. mmc->max_blk_size = 512;
  854. mmc->max_blk_count = (PAGE_CACHE_SIZE / mmc->max_blk_size) *
  855. mmc->max_segs;
  856. mmc->max_req_size = mmc->max_blk_size * mmc->max_blk_count;
  857. mmc->max_seg_size = mmc->max_req_size;
  858. _host->native_hotplug = !(pdata->flags & TMIO_MMC_USE_GPIO_CD ||
  859. mmc->caps & MMC_CAP_NEEDS_POLL ||
  860. mmc->caps & MMC_CAP_NONREMOVABLE ||
  861. mmc->slot.cd_irq >= 0);
  862. _host->power = TMIO_MMC_OFF_STOP;
  863. pm_runtime_enable(&pdev->dev);
  864. ret = pm_runtime_resume(&pdev->dev);
  865. if (ret < 0)
  866. goto pm_disable;
  867. if (tmio_mmc_clk_update(mmc) < 0) {
  868. mmc->f_max = pdata->hclk;
  869. mmc->f_min = mmc->f_max / 512;
  870. }
  871. /*
  872. * There are 4 different scenarios for the card detection:
  873. * 1) an external gpio irq handles the cd (best for power savings)
  874. * 2) internal sdhi irq handles the cd
  875. * 3) a worker thread polls the sdhi - indicated by MMC_CAP_NEEDS_POLL
  876. * 4) the medium is non-removable - indicated by MMC_CAP_NONREMOVABLE
  877. *
  878. * While we increment the runtime PM counter for all scenarios when
  879. * the mmc core activates us by calling an appropriate set_ios(), we
  880. * must additionally ensure that in case 2) the tmio mmc hardware stays
  881. * powered on during runtime for the card detection to work.
  882. */
  883. if (_host->native_hotplug)
  884. pm_runtime_get_noresume(&pdev->dev);
  885. tmio_mmc_clk_stop(_host);
  886. tmio_mmc_reset(_host);
  887. _host->sdcard_irq_mask = sd_ctrl_read32(_host, CTL_IRQ_MASK);
  888. tmio_mmc_disable_mmc_irqs(_host, TMIO_MASK_ALL);
  889. /* Unmask the IRQs we want to know about */
  890. if (!_host->chan_rx)
  891. irq_mask |= TMIO_MASK_READOP;
  892. if (!_host->chan_tx)
  893. irq_mask |= TMIO_MASK_WRITEOP;
  894. if (!_host->native_hotplug)
  895. irq_mask &= ~(TMIO_STAT_CARD_REMOVE | TMIO_STAT_CARD_INSERT);
  896. _host->sdcard_irq_mask &= ~irq_mask;
  897. if (pdata->flags & TMIO_MMC_SDIO_IRQ)
  898. tmio_mmc_enable_sdio_irq(mmc, 0);
  899. spin_lock_init(&_host->lock);
  900. mutex_init(&_host->ios_lock);
  901. /* Init delayed work for request timeouts */
  902. INIT_DELAYED_WORK(&_host->delayed_reset_work, tmio_mmc_reset_work);
  903. INIT_WORK(&_host->done, tmio_mmc_done_work);
  904. /* See if we also get DMA */
  905. tmio_mmc_request_dma(_host, pdata);
  906. ret = mmc_add_host(mmc);
  907. if (pdata->clk_disable)
  908. pdata->clk_disable(pdev);
  909. if (ret < 0) {
  910. tmio_mmc_host_remove(_host);
  911. return ret;
  912. }
  913. dev_pm_qos_expose_latency_limit(&pdev->dev, 100);
  914. if (pdata->flags & TMIO_MMC_USE_GPIO_CD) {
  915. ret = mmc_gpio_request_cd(mmc, pdata->cd_gpio, 0);
  916. if (ret < 0) {
  917. tmio_mmc_host_remove(_host);
  918. return ret;
  919. }
  920. }
  921. *host = _host;
  922. return 0;
  923. pm_disable:
  924. pm_runtime_disable(&pdev->dev);
  925. iounmap(_host->ctl);
  926. host_free:
  927. mmc_free_host(mmc);
  928. return ret;
  929. }
  930. EXPORT_SYMBOL(tmio_mmc_host_probe);
  931. void tmio_mmc_host_remove(struct tmio_mmc_host *host)
  932. {
  933. struct platform_device *pdev = host->pdev;
  934. struct mmc_host *mmc = host->mmc;
  935. if (!host->native_hotplug)
  936. pm_runtime_get_sync(&pdev->dev);
  937. dev_pm_qos_hide_latency_limit(&pdev->dev);
  938. mmc_remove_host(mmc);
  939. cancel_work_sync(&host->done);
  940. cancel_delayed_work_sync(&host->delayed_reset_work);
  941. tmio_mmc_release_dma(host);
  942. pm_runtime_put_sync(&pdev->dev);
  943. pm_runtime_disable(&pdev->dev);
  944. iounmap(host->ctl);
  945. mmc_free_host(mmc);
  946. }
  947. EXPORT_SYMBOL(tmio_mmc_host_remove);
  948. #ifdef CONFIG_PM_SLEEP
  949. int tmio_mmc_host_suspend(struct device *dev)
  950. {
  951. struct mmc_host *mmc = dev_get_drvdata(dev);
  952. struct tmio_mmc_host *host = mmc_priv(mmc);
  953. tmio_mmc_disable_mmc_irqs(host, TMIO_MASK_ALL);
  954. return 0;
  955. }
  956. EXPORT_SYMBOL(tmio_mmc_host_suspend);
  957. int tmio_mmc_host_resume(struct device *dev)
  958. {
  959. struct mmc_host *mmc = dev_get_drvdata(dev);
  960. struct tmio_mmc_host *host = mmc_priv(mmc);
  961. tmio_mmc_enable_dma(host, true);
  962. /* The MMC core will perform the complete set up */
  963. host->resuming = true;
  964. return 0;
  965. }
  966. EXPORT_SYMBOL(tmio_mmc_host_resume);
  967. #endif
  968. #ifdef CONFIG_PM_RUNTIME
  969. int tmio_mmc_host_runtime_suspend(struct device *dev)
  970. {
  971. return 0;
  972. }
  973. EXPORT_SYMBOL(tmio_mmc_host_runtime_suspend);
  974. int tmio_mmc_host_runtime_resume(struct device *dev)
  975. {
  976. struct mmc_host *mmc = dev_get_drvdata(dev);
  977. struct tmio_mmc_host *host = mmc_priv(mmc);
  978. tmio_mmc_enable_dma(host, true);
  979. return 0;
  980. }
  981. EXPORT_SYMBOL(tmio_mmc_host_runtime_resume);
  982. #endif
  983. MODULE_LICENSE("GPL v2");