mmci.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754
  1. /*
  2. * linux/drivers/mmc/host/mmci.c - ARM PrimeCell MMCI PL180/1 driver
  3. *
  4. * Copyright (C) 2003 Deep Blue Solutions, Ltd, All Rights Reserved.
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. */
  10. #include <linux/module.h>
  11. #include <linux/moduleparam.h>
  12. #include <linux/init.h>
  13. #include <linux/ioport.h>
  14. #include <linux/device.h>
  15. #include <linux/interrupt.h>
  16. #include <linux/delay.h>
  17. #include <linux/err.h>
  18. #include <linux/highmem.h>
  19. #include <linux/log2.h>
  20. #include <linux/mmc/host.h>
  21. #include <linux/amba/bus.h>
  22. #include <linux/clk.h>
  23. #include <linux/scatterlist.h>
  24. #include <asm/cacheflush.h>
  25. #include <asm/div64.h>
  26. #include <asm/io.h>
  27. #include <asm/sizes.h>
  28. #include <asm/mach/mmc.h>
  29. #include "mmci.h"
  30. #define DRIVER_NAME "mmci-pl18x"
  31. #define DBG(host,fmt,args...) \
  32. pr_debug("%s: %s: " fmt, mmc_hostname(host->mmc), __func__ , args)
  33. static unsigned int fmax = 515633;
  34. static void
  35. mmci_request_end(struct mmci_host *host, struct mmc_request *mrq)
  36. {
  37. writel(0, host->base + MMCICOMMAND);
  38. BUG_ON(host->data);
  39. host->mrq = NULL;
  40. host->cmd = NULL;
  41. if (mrq->data)
  42. mrq->data->bytes_xfered = host->data_xfered;
  43. /*
  44. * Need to drop the host lock here; mmc_request_done may call
  45. * back into the driver...
  46. */
  47. spin_unlock(&host->lock);
  48. mmc_request_done(host->mmc, mrq);
  49. spin_lock(&host->lock);
  50. }
  51. static void mmci_stop_data(struct mmci_host *host)
  52. {
  53. writel(0, host->base + MMCIDATACTRL);
  54. writel(0, host->base + MMCIMASK1);
  55. host->data = NULL;
  56. }
  57. static void mmci_start_data(struct mmci_host *host, struct mmc_data *data)
  58. {
  59. unsigned int datactrl, timeout, irqmask;
  60. unsigned long long clks;
  61. void __iomem *base;
  62. int blksz_bits;
  63. DBG(host, "blksz %04x blks %04x flags %08x\n",
  64. data->blksz, data->blocks, data->flags);
  65. host->data = data;
  66. host->size = data->blksz;
  67. host->data_xfered = 0;
  68. mmci_init_sg(host, data);
  69. clks = (unsigned long long)data->timeout_ns * host->cclk;
  70. do_div(clks, 1000000000UL);
  71. timeout = data->timeout_clks + (unsigned int)clks;
  72. base = host->base;
  73. writel(timeout, base + MMCIDATATIMER);
  74. writel(host->size, base + MMCIDATALENGTH);
  75. blksz_bits = ffs(data->blksz) - 1;
  76. BUG_ON(1 << blksz_bits != data->blksz);
  77. datactrl = MCI_DPSM_ENABLE | blksz_bits << 4;
  78. if (data->flags & MMC_DATA_READ) {
  79. datactrl |= MCI_DPSM_DIRECTION;
  80. irqmask = MCI_RXFIFOHALFFULLMASK;
  81. /*
  82. * If we have less than a FIFOSIZE of bytes to transfer,
  83. * trigger a PIO interrupt as soon as any data is available.
  84. */
  85. if (host->size < MCI_FIFOSIZE)
  86. irqmask |= MCI_RXDATAAVLBLMASK;
  87. } else {
  88. /*
  89. * We don't actually need to include "FIFO empty" here
  90. * since its implicit in "FIFO half empty".
  91. */
  92. irqmask = MCI_TXFIFOHALFEMPTYMASK;
  93. }
  94. writel(datactrl, base + MMCIDATACTRL);
  95. writel(readl(base + MMCIMASK0) & ~MCI_DATAENDMASK, base + MMCIMASK0);
  96. writel(irqmask, base + MMCIMASK1);
  97. }
  98. static void
  99. mmci_start_command(struct mmci_host *host, struct mmc_command *cmd, u32 c)
  100. {
  101. void __iomem *base = host->base;
  102. DBG(host, "op %02x arg %08x flags %08x\n",
  103. cmd->opcode, cmd->arg, cmd->flags);
  104. if (readl(base + MMCICOMMAND) & MCI_CPSM_ENABLE) {
  105. writel(0, base + MMCICOMMAND);
  106. udelay(1);
  107. }
  108. c |= cmd->opcode | MCI_CPSM_ENABLE;
  109. if (cmd->flags & MMC_RSP_PRESENT) {
  110. if (cmd->flags & MMC_RSP_136)
  111. c |= MCI_CPSM_LONGRSP;
  112. c |= MCI_CPSM_RESPONSE;
  113. }
  114. if (/*interrupt*/0)
  115. c |= MCI_CPSM_INTERRUPT;
  116. host->cmd = cmd;
  117. writel(cmd->arg, base + MMCIARGUMENT);
  118. writel(c, base + MMCICOMMAND);
  119. }
  120. static void
  121. mmci_data_irq(struct mmci_host *host, struct mmc_data *data,
  122. unsigned int status)
  123. {
  124. if (status & MCI_DATABLOCKEND) {
  125. host->data_xfered += data->blksz;
  126. }
  127. if (status & (MCI_DATACRCFAIL|MCI_DATATIMEOUT|MCI_TXUNDERRUN|MCI_RXOVERRUN)) {
  128. if (status & MCI_DATACRCFAIL)
  129. data->error = -EILSEQ;
  130. else if (status & MCI_DATATIMEOUT)
  131. data->error = -ETIMEDOUT;
  132. else if (status & (MCI_TXUNDERRUN|MCI_RXOVERRUN))
  133. data->error = -EIO;
  134. status |= MCI_DATAEND;
  135. /*
  136. * We hit an error condition. Ensure that any data
  137. * partially written to a page is properly coherent.
  138. */
  139. if (host->sg_len && data->flags & MMC_DATA_READ)
  140. flush_dcache_page(sg_page(host->sg_ptr));
  141. }
  142. if (status & MCI_DATAEND) {
  143. mmci_stop_data(host);
  144. if (!data->stop) {
  145. mmci_request_end(host, data->mrq);
  146. } else {
  147. mmci_start_command(host, data->stop, 0);
  148. }
  149. }
  150. }
  151. static void
  152. mmci_cmd_irq(struct mmci_host *host, struct mmc_command *cmd,
  153. unsigned int status)
  154. {
  155. void __iomem *base = host->base;
  156. host->cmd = NULL;
  157. cmd->resp[0] = readl(base + MMCIRESPONSE0);
  158. cmd->resp[1] = readl(base + MMCIRESPONSE1);
  159. cmd->resp[2] = readl(base + MMCIRESPONSE2);
  160. cmd->resp[3] = readl(base + MMCIRESPONSE3);
  161. if (status & MCI_CMDTIMEOUT) {
  162. cmd->error = -ETIMEDOUT;
  163. } else if (status & MCI_CMDCRCFAIL && cmd->flags & MMC_RSP_CRC) {
  164. cmd->error = -EILSEQ;
  165. }
  166. if (!cmd->data || cmd->error) {
  167. if (host->data)
  168. mmci_stop_data(host);
  169. mmci_request_end(host, cmd->mrq);
  170. } else if (!(cmd->data->flags & MMC_DATA_READ)) {
  171. mmci_start_data(host, cmd->data);
  172. }
  173. }
  174. static int mmci_pio_read(struct mmci_host *host, char *buffer, unsigned int remain)
  175. {
  176. void __iomem *base = host->base;
  177. char *ptr = buffer;
  178. u32 status;
  179. int host_remain = host->size;
  180. do {
  181. int count = host_remain - (readl(base + MMCIFIFOCNT) << 2);
  182. if (count > remain)
  183. count = remain;
  184. if (count <= 0)
  185. break;
  186. readsl(base + MMCIFIFO, ptr, count >> 2);
  187. ptr += count;
  188. remain -= count;
  189. host_remain -= count;
  190. if (remain == 0)
  191. break;
  192. status = readl(base + MMCISTATUS);
  193. } while (status & MCI_RXDATAAVLBL);
  194. return ptr - buffer;
  195. }
  196. static int mmci_pio_write(struct mmci_host *host, char *buffer, unsigned int remain, u32 status)
  197. {
  198. void __iomem *base = host->base;
  199. char *ptr = buffer;
  200. do {
  201. unsigned int count, maxcnt;
  202. maxcnt = status & MCI_TXFIFOEMPTY ? MCI_FIFOSIZE : MCI_FIFOHALFSIZE;
  203. count = min(remain, maxcnt);
  204. writesl(base + MMCIFIFO, ptr, count >> 2);
  205. ptr += count;
  206. remain -= count;
  207. if (remain == 0)
  208. break;
  209. status = readl(base + MMCISTATUS);
  210. } while (status & MCI_TXFIFOHALFEMPTY);
  211. return ptr - buffer;
  212. }
  213. /*
  214. * PIO data transfer IRQ handler.
  215. */
  216. static irqreturn_t mmci_pio_irq(int irq, void *dev_id)
  217. {
  218. struct mmci_host *host = dev_id;
  219. void __iomem *base = host->base;
  220. u32 status;
  221. status = readl(base + MMCISTATUS);
  222. DBG(host, "irq1 %08x\n", status);
  223. do {
  224. unsigned long flags;
  225. unsigned int remain, len;
  226. char *buffer;
  227. /*
  228. * For write, we only need to test the half-empty flag
  229. * here - if the FIFO is completely empty, then by
  230. * definition it is more than half empty.
  231. *
  232. * For read, check for data available.
  233. */
  234. if (!(status & (MCI_TXFIFOHALFEMPTY|MCI_RXDATAAVLBL)))
  235. break;
  236. /*
  237. * Map the current scatter buffer.
  238. */
  239. buffer = mmci_kmap_atomic(host, &flags) + host->sg_off;
  240. remain = host->sg_ptr->length - host->sg_off;
  241. len = 0;
  242. if (status & MCI_RXACTIVE)
  243. len = mmci_pio_read(host, buffer, remain);
  244. if (status & MCI_TXACTIVE)
  245. len = mmci_pio_write(host, buffer, remain, status);
  246. /*
  247. * Unmap the buffer.
  248. */
  249. mmci_kunmap_atomic(host, buffer, &flags);
  250. host->sg_off += len;
  251. host->size -= len;
  252. remain -= len;
  253. if (remain)
  254. break;
  255. /*
  256. * If we were reading, and we have completed this
  257. * page, ensure that the data cache is coherent.
  258. */
  259. if (status & MCI_RXACTIVE)
  260. flush_dcache_page(sg_page(host->sg_ptr));
  261. if (!mmci_next_sg(host))
  262. break;
  263. status = readl(base + MMCISTATUS);
  264. } while (1);
  265. /*
  266. * If we're nearing the end of the read, switch to
  267. * "any data available" mode.
  268. */
  269. if (status & MCI_RXACTIVE && host->size < MCI_FIFOSIZE)
  270. writel(MCI_RXDATAAVLBLMASK, base + MMCIMASK1);
  271. /*
  272. * If we run out of data, disable the data IRQs; this
  273. * prevents a race where the FIFO becomes empty before
  274. * the chip itself has disabled the data path, and
  275. * stops us racing with our data end IRQ.
  276. */
  277. if (host->size == 0) {
  278. writel(0, base + MMCIMASK1);
  279. writel(readl(base + MMCIMASK0) | MCI_DATAENDMASK, base + MMCIMASK0);
  280. }
  281. return IRQ_HANDLED;
  282. }
  283. /*
  284. * Handle completion of command and data transfers.
  285. */
  286. static irqreturn_t mmci_irq(int irq, void *dev_id)
  287. {
  288. struct mmci_host *host = dev_id;
  289. u32 status;
  290. int ret = 0;
  291. spin_lock(&host->lock);
  292. do {
  293. struct mmc_command *cmd;
  294. struct mmc_data *data;
  295. status = readl(host->base + MMCISTATUS);
  296. status &= readl(host->base + MMCIMASK0);
  297. writel(status, host->base + MMCICLEAR);
  298. DBG(host, "irq0 %08x\n", status);
  299. data = host->data;
  300. if (status & (MCI_DATACRCFAIL|MCI_DATATIMEOUT|MCI_TXUNDERRUN|
  301. MCI_RXOVERRUN|MCI_DATAEND|MCI_DATABLOCKEND) && data)
  302. mmci_data_irq(host, data, status);
  303. cmd = host->cmd;
  304. if (status & (MCI_CMDCRCFAIL|MCI_CMDTIMEOUT|MCI_CMDSENT|MCI_CMDRESPEND) && cmd)
  305. mmci_cmd_irq(host, cmd, status);
  306. ret = 1;
  307. } while (status);
  308. spin_unlock(&host->lock);
  309. return IRQ_RETVAL(ret);
  310. }
  311. static void mmci_request(struct mmc_host *mmc, struct mmc_request *mrq)
  312. {
  313. struct mmci_host *host = mmc_priv(mmc);
  314. unsigned long flags;
  315. WARN_ON(host->mrq != NULL);
  316. if (mrq->data && !is_power_of_2(mrq->data->blksz)) {
  317. printk(KERN_ERR "%s: Unsupported block size (%d bytes)\n",
  318. mmc_hostname(mmc), mrq->data->blksz);
  319. mrq->cmd->error = -EINVAL;
  320. mmc_request_done(mmc, mrq);
  321. return;
  322. }
  323. spin_lock_irqsave(&host->lock, flags);
  324. host->mrq = mrq;
  325. if (mrq->data && mrq->data->flags & MMC_DATA_READ)
  326. mmci_start_data(host, mrq->data);
  327. mmci_start_command(host, mrq->cmd, 0);
  328. spin_unlock_irqrestore(&host->lock, flags);
  329. }
  330. static void mmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
  331. {
  332. struct mmci_host *host = mmc_priv(mmc);
  333. u32 clk = 0, pwr = 0;
  334. if (ios->clock) {
  335. if (ios->clock >= host->mclk) {
  336. clk = MCI_CLK_BYPASS;
  337. host->cclk = host->mclk;
  338. } else {
  339. clk = host->mclk / (2 * ios->clock) - 1;
  340. if (clk >= 256)
  341. clk = 255;
  342. host->cclk = host->mclk / (2 * (clk + 1));
  343. }
  344. if (host->hw_designer == 0x80)
  345. clk |= MCI_FCEN; /* Bug fix in ST IP block */
  346. clk |= MCI_CLK_ENABLE;
  347. }
  348. if (host->plat->translate_vdd)
  349. pwr |= host->plat->translate_vdd(mmc_dev(mmc), ios->vdd);
  350. switch (ios->power_mode) {
  351. case MMC_POWER_OFF:
  352. break;
  353. case MMC_POWER_UP:
  354. /* The ST version does not have this, fall through to POWER_ON */
  355. if (host->hw_designer != 0x80) {
  356. pwr |= MCI_PWR_UP;
  357. break;
  358. }
  359. case MMC_POWER_ON:
  360. pwr |= MCI_PWR_ON;
  361. break;
  362. }
  363. if (ios->bus_mode == MMC_BUSMODE_OPENDRAIN) {
  364. if (host->hw_designer != 0x80)
  365. pwr |= MCI_ROD;
  366. else {
  367. /*
  368. * The ST Micro variant use the ROD bit for something
  369. * else and only has OD (Open Drain).
  370. */
  371. pwr |= MCI_OD;
  372. }
  373. }
  374. writel(clk, host->base + MMCICLOCK);
  375. if (host->pwr != pwr) {
  376. host->pwr = pwr;
  377. writel(pwr, host->base + MMCIPOWER);
  378. }
  379. }
  380. static const struct mmc_host_ops mmci_ops = {
  381. .request = mmci_request,
  382. .set_ios = mmci_set_ios,
  383. };
  384. static void mmci_check_status(unsigned long data)
  385. {
  386. struct mmci_host *host = (struct mmci_host *)data;
  387. unsigned int status;
  388. status = host->plat->status(mmc_dev(host->mmc));
  389. if (status ^ host->oldstat)
  390. mmc_detect_change(host->mmc, 0);
  391. host->oldstat = status;
  392. mod_timer(&host->timer, jiffies + HZ);
  393. }
  394. static int __devinit mmci_probe(struct amba_device *dev, struct amba_id *id)
  395. {
  396. struct mmc_platform_data *plat = dev->dev.platform_data;
  397. struct mmci_host *host;
  398. struct mmc_host *mmc;
  399. int ret;
  400. /* must have platform data */
  401. if (!plat) {
  402. ret = -EINVAL;
  403. goto out;
  404. }
  405. ret = amba_request_regions(dev, DRIVER_NAME);
  406. if (ret)
  407. goto out;
  408. mmc = mmc_alloc_host(sizeof(struct mmci_host), &dev->dev);
  409. if (!mmc) {
  410. ret = -ENOMEM;
  411. goto rel_regions;
  412. }
  413. host = mmc_priv(mmc);
  414. host->mmc = mmc;
  415. /* Bits 12 thru 19 is the designer */
  416. host->hw_designer = (dev->periphid >> 12) & 0xff;
  417. /* Bits 20 thru 23 is the revison */
  418. host->hw_revision = (dev->periphid >> 20) & 0xf;
  419. DBG(host, "designer ID = 0x%02x\n", host->hw_designer);
  420. DBG(host, "revision = 0x%01x\n", host->hw_revision);
  421. host->clk = clk_get(&dev->dev, NULL);
  422. if (IS_ERR(host->clk)) {
  423. ret = PTR_ERR(host->clk);
  424. host->clk = NULL;
  425. goto host_free;
  426. }
  427. ret = clk_enable(host->clk);
  428. if (ret)
  429. goto clk_free;
  430. host->plat = plat;
  431. host->mclk = clk_get_rate(host->clk);
  432. /*
  433. * According to the spec, mclk is max 100 MHz,
  434. * so we try to adjust the clock down to this,
  435. * (if possible).
  436. */
  437. if (host->mclk > 100000000) {
  438. ret = clk_set_rate(host->clk, 100000000);
  439. if (ret < 0)
  440. goto clk_disable;
  441. host->mclk = clk_get_rate(host->clk);
  442. DBG(host, "eventual mclk rate: %u Hz\n", host->mclk);
  443. }
  444. host->base = ioremap(dev->res.start, resource_size(&dev->res));
  445. if (!host->base) {
  446. ret = -ENOMEM;
  447. goto clk_disable;
  448. }
  449. mmc->ops = &mmci_ops;
  450. mmc->f_min = (host->mclk + 511) / 512;
  451. mmc->f_max = min(host->mclk, fmax);
  452. mmc->ocr_avail = plat->ocr_mask;
  453. /*
  454. * We can do SGIO
  455. */
  456. mmc->max_hw_segs = 16;
  457. mmc->max_phys_segs = NR_SG;
  458. /*
  459. * Since we only have a 16-bit data length register, we must
  460. * ensure that we don't exceed 2^16-1 bytes in a single request.
  461. */
  462. mmc->max_req_size = 65535;
  463. /*
  464. * Set the maximum segment size. Since we aren't doing DMA
  465. * (yet) we are only limited by the data length register.
  466. */
  467. mmc->max_seg_size = mmc->max_req_size;
  468. /*
  469. * Block size can be up to 2048 bytes, but must be a power of two.
  470. */
  471. mmc->max_blk_size = 2048;
  472. /*
  473. * No limit on the number of blocks transferred.
  474. */
  475. mmc->max_blk_count = mmc->max_req_size;
  476. spin_lock_init(&host->lock);
  477. writel(0, host->base + MMCIMASK0);
  478. writel(0, host->base + MMCIMASK1);
  479. writel(0xfff, host->base + MMCICLEAR);
  480. ret = request_irq(dev->irq[0], mmci_irq, IRQF_SHARED, DRIVER_NAME " (cmd)", host);
  481. if (ret)
  482. goto unmap;
  483. ret = request_irq(dev->irq[1], mmci_pio_irq, IRQF_SHARED, DRIVER_NAME " (pio)", host);
  484. if (ret)
  485. goto irq0_free;
  486. writel(MCI_IRQENABLE, host->base + MMCIMASK0);
  487. amba_set_drvdata(dev, mmc);
  488. mmc_add_host(mmc);
  489. printk(KERN_INFO "%s: MMCI rev %x cfg %02x at 0x%016llx irq %d,%d\n",
  490. mmc_hostname(mmc), amba_rev(dev), amba_config(dev),
  491. (unsigned long long)dev->res.start, dev->irq[0], dev->irq[1]);
  492. init_timer(&host->timer);
  493. host->timer.data = (unsigned long)host;
  494. host->timer.function = mmci_check_status;
  495. host->timer.expires = jiffies + HZ;
  496. add_timer(&host->timer);
  497. return 0;
  498. irq0_free:
  499. free_irq(dev->irq[0], host);
  500. unmap:
  501. iounmap(host->base);
  502. clk_disable:
  503. clk_disable(host->clk);
  504. clk_free:
  505. clk_put(host->clk);
  506. host_free:
  507. mmc_free_host(mmc);
  508. rel_regions:
  509. amba_release_regions(dev);
  510. out:
  511. return ret;
  512. }
  513. static int __devexit mmci_remove(struct amba_device *dev)
  514. {
  515. struct mmc_host *mmc = amba_get_drvdata(dev);
  516. amba_set_drvdata(dev, NULL);
  517. if (mmc) {
  518. struct mmci_host *host = mmc_priv(mmc);
  519. del_timer_sync(&host->timer);
  520. mmc_remove_host(mmc);
  521. writel(0, host->base + MMCIMASK0);
  522. writel(0, host->base + MMCIMASK1);
  523. writel(0, host->base + MMCICOMMAND);
  524. writel(0, host->base + MMCIDATACTRL);
  525. free_irq(dev->irq[0], host);
  526. free_irq(dev->irq[1], host);
  527. iounmap(host->base);
  528. clk_disable(host->clk);
  529. clk_put(host->clk);
  530. mmc_free_host(mmc);
  531. amba_release_regions(dev);
  532. }
  533. return 0;
  534. }
  535. #ifdef CONFIG_PM
  536. static int mmci_suspend(struct amba_device *dev, pm_message_t state)
  537. {
  538. struct mmc_host *mmc = amba_get_drvdata(dev);
  539. int ret = 0;
  540. if (mmc) {
  541. struct mmci_host *host = mmc_priv(mmc);
  542. ret = mmc_suspend_host(mmc, state);
  543. if (ret == 0)
  544. writel(0, host->base + MMCIMASK0);
  545. }
  546. return ret;
  547. }
  548. static int mmci_resume(struct amba_device *dev)
  549. {
  550. struct mmc_host *mmc = amba_get_drvdata(dev);
  551. int ret = 0;
  552. if (mmc) {
  553. struct mmci_host *host = mmc_priv(mmc);
  554. writel(MCI_IRQENABLE, host->base + MMCIMASK0);
  555. ret = mmc_resume_host(mmc);
  556. }
  557. return ret;
  558. }
  559. #else
  560. #define mmci_suspend NULL
  561. #define mmci_resume NULL
  562. #endif
  563. static struct amba_id mmci_ids[] = {
  564. {
  565. .id = 0x00041180,
  566. .mask = 0x000fffff,
  567. },
  568. {
  569. .id = 0x00041181,
  570. .mask = 0x000fffff,
  571. },
  572. /* ST Micro variants */
  573. {
  574. .id = 0x00180180,
  575. .mask = 0x00ffffff,
  576. },
  577. {
  578. .id = 0x00280180,
  579. .mask = 0x00ffffff,
  580. },
  581. { 0, 0 },
  582. };
  583. static struct amba_driver mmci_driver = {
  584. .drv = {
  585. .name = DRIVER_NAME,
  586. },
  587. .probe = mmci_probe,
  588. .remove = __devexit_p(mmci_remove),
  589. .suspend = mmci_suspend,
  590. .resume = mmci_resume,
  591. .id_table = mmci_ids,
  592. };
  593. static int __init mmci_init(void)
  594. {
  595. return amba_driver_register(&mmci_driver);
  596. }
  597. static void __exit mmci_exit(void)
  598. {
  599. amba_driver_unregister(&mmci_driver);
  600. }
  601. module_init(mmci_init);
  602. module_exit(mmci_exit);
  603. module_param(fmax, uint, 0444);
  604. MODULE_DESCRIPTION("ARM PrimeCell PL180/181 Multimedia Card Interface driver");
  605. MODULE_LICENSE("GPL");