mmci.c 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333
  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. * Copyright (C) 2010 ST-Ericsson SA
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. */
  11. #include <linux/module.h>
  12. #include <linux/moduleparam.h>
  13. #include <linux/init.h>
  14. #include <linux/ioport.h>
  15. #include <linux/device.h>
  16. #include <linux/interrupt.h>
  17. #include <linux/kernel.h>
  18. #include <linux/delay.h>
  19. #include <linux/err.h>
  20. #include <linux/highmem.h>
  21. #include <linux/log2.h>
  22. #include <linux/mmc/host.h>
  23. #include <linux/mmc/card.h>
  24. #include <linux/amba/bus.h>
  25. #include <linux/clk.h>
  26. #include <linux/scatterlist.h>
  27. #include <linux/gpio.h>
  28. #include <linux/regulator/consumer.h>
  29. #include <linux/dmaengine.h>
  30. #include <linux/dma-mapping.h>
  31. #include <linux/amba/mmci.h>
  32. #include <asm/div64.h>
  33. #include <asm/io.h>
  34. #include <asm/sizes.h>
  35. #include "mmci.h"
  36. #define DRIVER_NAME "mmci-pl18x"
  37. static unsigned int fmax = 515633;
  38. /**
  39. * struct variant_data - MMCI variant-specific quirks
  40. * @clkreg: default value for MCICLOCK register
  41. * @clkreg_enable: enable value for MMCICLOCK register
  42. * @datalength_bits: number of bits in the MMCIDATALENGTH register
  43. * @fifosize: number of bytes that can be written when MMCI_TXFIFOEMPTY
  44. * is asserted (likewise for RX)
  45. * @fifohalfsize: number of bytes that can be written when MCI_TXFIFOHALFEMPTY
  46. * is asserted (likewise for RX)
  47. * @sdio: variant supports SDIO
  48. * @st_clkdiv: true if using a ST-specific clock divider algorithm
  49. */
  50. struct variant_data {
  51. unsigned int clkreg;
  52. unsigned int clkreg_enable;
  53. unsigned int datalength_bits;
  54. unsigned int fifosize;
  55. unsigned int fifohalfsize;
  56. bool sdio;
  57. bool st_clkdiv;
  58. };
  59. static struct variant_data variant_arm = {
  60. .fifosize = 16 * 4,
  61. .fifohalfsize = 8 * 4,
  62. .datalength_bits = 16,
  63. };
  64. static struct variant_data variant_u300 = {
  65. .fifosize = 16 * 4,
  66. .fifohalfsize = 8 * 4,
  67. .clkreg_enable = 1 << 13, /* HWFCEN */
  68. .datalength_bits = 16,
  69. .sdio = true,
  70. };
  71. static struct variant_data variant_ux500 = {
  72. .fifosize = 30 * 4,
  73. .fifohalfsize = 8 * 4,
  74. .clkreg = MCI_CLK_ENABLE,
  75. .clkreg_enable = 1 << 14, /* HWFCEN */
  76. .datalength_bits = 24,
  77. .sdio = true,
  78. .st_clkdiv = true,
  79. };
  80. /*
  81. * This must be called with host->lock held
  82. */
  83. static void mmci_set_clkreg(struct mmci_host *host, unsigned int desired)
  84. {
  85. struct variant_data *variant = host->variant;
  86. u32 clk = variant->clkreg;
  87. if (desired) {
  88. if (desired >= host->mclk) {
  89. clk = MCI_CLK_BYPASS;
  90. host->cclk = host->mclk;
  91. } else if (variant->st_clkdiv) {
  92. /*
  93. * DB8500 TRM says f = mclk / (clkdiv + 2)
  94. * => clkdiv = (mclk / f) - 2
  95. * Round the divider up so we don't exceed the max
  96. * frequency
  97. */
  98. clk = DIV_ROUND_UP(host->mclk, desired) - 2;
  99. if (clk >= 256)
  100. clk = 255;
  101. host->cclk = host->mclk / (clk + 2);
  102. } else {
  103. /*
  104. * PL180 TRM says f = mclk / (2 * (clkdiv + 1))
  105. * => clkdiv = mclk / (2 * f) - 1
  106. */
  107. clk = host->mclk / (2 * desired) - 1;
  108. if (clk >= 256)
  109. clk = 255;
  110. host->cclk = host->mclk / (2 * (clk + 1));
  111. }
  112. clk |= variant->clkreg_enable;
  113. clk |= MCI_CLK_ENABLE;
  114. /* This hasn't proven to be worthwhile */
  115. /* clk |= MCI_CLK_PWRSAVE; */
  116. }
  117. if (host->mmc->ios.bus_width == MMC_BUS_WIDTH_4)
  118. clk |= MCI_4BIT_BUS;
  119. if (host->mmc->ios.bus_width == MMC_BUS_WIDTH_8)
  120. clk |= MCI_ST_8BIT_BUS;
  121. writel(clk, host->base + MMCICLOCK);
  122. }
  123. static void
  124. mmci_request_end(struct mmci_host *host, struct mmc_request *mrq)
  125. {
  126. writel(0, host->base + MMCICOMMAND);
  127. BUG_ON(host->data);
  128. host->mrq = NULL;
  129. host->cmd = NULL;
  130. /*
  131. * Need to drop the host lock here; mmc_request_done may call
  132. * back into the driver...
  133. */
  134. spin_unlock(&host->lock);
  135. mmc_request_done(host->mmc, mrq);
  136. spin_lock(&host->lock);
  137. }
  138. static void mmci_set_mask1(struct mmci_host *host, unsigned int mask)
  139. {
  140. void __iomem *base = host->base;
  141. if (host->singleirq) {
  142. unsigned int mask0 = readl(base + MMCIMASK0);
  143. mask0 &= ~MCI_IRQ1MASK;
  144. mask0 |= mask;
  145. writel(mask0, base + MMCIMASK0);
  146. }
  147. writel(mask, base + MMCIMASK1);
  148. }
  149. static void mmci_stop_data(struct mmci_host *host)
  150. {
  151. writel(0, host->base + MMCIDATACTRL);
  152. mmci_set_mask1(host, 0);
  153. host->data = NULL;
  154. }
  155. static void mmci_init_sg(struct mmci_host *host, struct mmc_data *data)
  156. {
  157. unsigned int flags = SG_MITER_ATOMIC;
  158. if (data->flags & MMC_DATA_READ)
  159. flags |= SG_MITER_TO_SG;
  160. else
  161. flags |= SG_MITER_FROM_SG;
  162. sg_miter_start(&host->sg_miter, data->sg, data->sg_len, flags);
  163. }
  164. /*
  165. * All the DMA operation mode stuff goes inside this ifdef.
  166. * This assumes that you have a generic DMA device interface,
  167. * no custom DMA interfaces are supported.
  168. */
  169. #ifdef CONFIG_DMA_ENGINE
  170. static void __devinit mmci_dma_setup(struct mmci_host *host)
  171. {
  172. struct mmci_platform_data *plat = host->plat;
  173. const char *rxname, *txname;
  174. dma_cap_mask_t mask;
  175. if (!plat || !plat->dma_filter) {
  176. dev_info(mmc_dev(host->mmc), "no DMA platform data\n");
  177. return;
  178. }
  179. /* Try to acquire a generic DMA engine slave channel */
  180. dma_cap_zero(mask);
  181. dma_cap_set(DMA_SLAVE, mask);
  182. /*
  183. * If only an RX channel is specified, the driver will
  184. * attempt to use it bidirectionally, however if it is
  185. * is specified but cannot be located, DMA will be disabled.
  186. */
  187. if (plat->dma_rx_param) {
  188. host->dma_rx_channel = dma_request_channel(mask,
  189. plat->dma_filter,
  190. plat->dma_rx_param);
  191. /* E.g if no DMA hardware is present */
  192. if (!host->dma_rx_channel)
  193. dev_err(mmc_dev(host->mmc), "no RX DMA channel\n");
  194. }
  195. if (plat->dma_tx_param) {
  196. host->dma_tx_channel = dma_request_channel(mask,
  197. plat->dma_filter,
  198. plat->dma_tx_param);
  199. if (!host->dma_tx_channel)
  200. dev_warn(mmc_dev(host->mmc), "no TX DMA channel\n");
  201. } else {
  202. host->dma_tx_channel = host->dma_rx_channel;
  203. }
  204. if (host->dma_rx_channel)
  205. rxname = dma_chan_name(host->dma_rx_channel);
  206. else
  207. rxname = "none";
  208. if (host->dma_tx_channel)
  209. txname = dma_chan_name(host->dma_tx_channel);
  210. else
  211. txname = "none";
  212. dev_info(mmc_dev(host->mmc), "DMA channels RX %s, TX %s\n",
  213. rxname, txname);
  214. /*
  215. * Limit the maximum segment size in any SG entry according to
  216. * the parameters of the DMA engine device.
  217. */
  218. if (host->dma_tx_channel) {
  219. struct device *dev = host->dma_tx_channel->device->dev;
  220. unsigned int max_seg_size = dma_get_max_seg_size(dev);
  221. if (max_seg_size < host->mmc->max_seg_size)
  222. host->mmc->max_seg_size = max_seg_size;
  223. }
  224. if (host->dma_rx_channel) {
  225. struct device *dev = host->dma_rx_channel->device->dev;
  226. unsigned int max_seg_size = dma_get_max_seg_size(dev);
  227. if (max_seg_size < host->mmc->max_seg_size)
  228. host->mmc->max_seg_size = max_seg_size;
  229. }
  230. }
  231. /*
  232. * This is used in __devinit or __devexit so inline it
  233. * so it can be discarded.
  234. */
  235. static inline void mmci_dma_release(struct mmci_host *host)
  236. {
  237. struct mmci_platform_data *plat = host->plat;
  238. if (host->dma_rx_channel)
  239. dma_release_channel(host->dma_rx_channel);
  240. if (host->dma_tx_channel && plat->dma_tx_param)
  241. dma_release_channel(host->dma_tx_channel);
  242. host->dma_rx_channel = host->dma_tx_channel = NULL;
  243. }
  244. static void mmci_dma_unmap(struct mmci_host *host, struct mmc_data *data)
  245. {
  246. struct dma_chan *chan = host->dma_current;
  247. enum dma_data_direction dir;
  248. u32 status;
  249. int i;
  250. /* Wait up to 1ms for the DMA to complete */
  251. for (i = 0; ; i++) {
  252. status = readl(host->base + MMCISTATUS);
  253. if (!(status & MCI_RXDATAAVLBLMASK) || i >= 100)
  254. break;
  255. udelay(10);
  256. }
  257. /*
  258. * Check to see whether we still have some data left in the FIFO -
  259. * this catches DMA controllers which are unable to monitor the
  260. * DMALBREQ and DMALSREQ signals while allowing us to DMA to non-
  261. * contiguous buffers. On TX, we'll get a FIFO underrun error.
  262. */
  263. if (status & MCI_RXDATAAVLBLMASK) {
  264. dmaengine_terminate_all(chan);
  265. if (!data->error)
  266. data->error = -EIO;
  267. }
  268. if (data->flags & MMC_DATA_WRITE) {
  269. dir = DMA_TO_DEVICE;
  270. } else {
  271. dir = DMA_FROM_DEVICE;
  272. }
  273. dma_unmap_sg(chan->device->dev, data->sg, data->sg_len, dir);
  274. /*
  275. * Use of DMA with scatter-gather is impossible.
  276. * Give up with DMA and switch back to PIO mode.
  277. */
  278. if (status & MCI_RXDATAAVLBLMASK) {
  279. dev_err(mmc_dev(host->mmc), "buggy DMA detected. Taking evasive action.\n");
  280. mmci_dma_release(host);
  281. }
  282. }
  283. static void mmci_dma_data_error(struct mmci_host *host)
  284. {
  285. dev_err(mmc_dev(host->mmc), "error during DMA transfer!\n");
  286. dmaengine_terminate_all(host->dma_current);
  287. }
  288. static int mmci_dma_start_data(struct mmci_host *host, unsigned int datactrl)
  289. {
  290. struct variant_data *variant = host->variant;
  291. struct dma_slave_config conf = {
  292. .src_addr = host->phybase + MMCIFIFO,
  293. .dst_addr = host->phybase + MMCIFIFO,
  294. .src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES,
  295. .dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES,
  296. .src_maxburst = variant->fifohalfsize >> 2, /* # of words */
  297. .dst_maxburst = variant->fifohalfsize >> 2, /* # of words */
  298. };
  299. struct mmc_data *data = host->data;
  300. struct dma_chan *chan;
  301. struct dma_device *device;
  302. struct dma_async_tx_descriptor *desc;
  303. int nr_sg;
  304. host->dma_current = NULL;
  305. if (data->flags & MMC_DATA_READ) {
  306. conf.direction = DMA_FROM_DEVICE;
  307. chan = host->dma_rx_channel;
  308. } else {
  309. conf.direction = DMA_TO_DEVICE;
  310. chan = host->dma_tx_channel;
  311. }
  312. /* If there's no DMA channel, fall back to PIO */
  313. if (!chan)
  314. return -EINVAL;
  315. /* If less than or equal to the fifo size, don't bother with DMA */
  316. if (host->size <= variant->fifosize)
  317. return -EINVAL;
  318. device = chan->device;
  319. nr_sg = dma_map_sg(device->dev, data->sg, data->sg_len, conf.direction);
  320. if (nr_sg == 0)
  321. return -EINVAL;
  322. dmaengine_slave_config(chan, &conf);
  323. desc = device->device_prep_slave_sg(chan, data->sg, nr_sg,
  324. conf.direction, DMA_CTRL_ACK);
  325. if (!desc)
  326. goto unmap_exit;
  327. /* Okay, go for it. */
  328. host->dma_current = chan;
  329. dev_vdbg(mmc_dev(host->mmc),
  330. "Submit MMCI DMA job, sglen %d blksz %04x blks %04x flags %08x\n",
  331. data->sg_len, data->blksz, data->blocks, data->flags);
  332. dmaengine_submit(desc);
  333. dma_async_issue_pending(chan);
  334. datactrl |= MCI_DPSM_DMAENABLE;
  335. /* Trigger the DMA transfer */
  336. writel(datactrl, host->base + MMCIDATACTRL);
  337. /*
  338. * Let the MMCI say when the data is ended and it's time
  339. * to fire next DMA request. When that happens, MMCI will
  340. * call mmci_data_end()
  341. */
  342. writel(readl(host->base + MMCIMASK0) | MCI_DATAENDMASK,
  343. host->base + MMCIMASK0);
  344. return 0;
  345. unmap_exit:
  346. dmaengine_terminate_all(chan);
  347. dma_unmap_sg(device->dev, data->sg, data->sg_len, conf.direction);
  348. return -ENOMEM;
  349. }
  350. #else
  351. /* Blank functions if the DMA engine is not available */
  352. static inline void mmci_dma_setup(struct mmci_host *host)
  353. {
  354. }
  355. static inline void mmci_dma_release(struct mmci_host *host)
  356. {
  357. }
  358. static inline void mmci_dma_unmap(struct mmci_host *host, struct mmc_data *data)
  359. {
  360. }
  361. static inline void mmci_dma_data_error(struct mmci_host *host)
  362. {
  363. }
  364. static inline int mmci_dma_start_data(struct mmci_host *host, unsigned int datactrl)
  365. {
  366. return -ENOSYS;
  367. }
  368. #endif
  369. static void mmci_start_data(struct mmci_host *host, struct mmc_data *data)
  370. {
  371. struct variant_data *variant = host->variant;
  372. unsigned int datactrl, timeout, irqmask;
  373. unsigned long long clks;
  374. void __iomem *base;
  375. int blksz_bits;
  376. dev_dbg(mmc_dev(host->mmc), "blksz %04x blks %04x flags %08x\n",
  377. data->blksz, data->blocks, data->flags);
  378. host->data = data;
  379. host->size = data->blksz * data->blocks;
  380. data->bytes_xfered = 0;
  381. clks = (unsigned long long)data->timeout_ns * host->cclk;
  382. do_div(clks, 1000000000UL);
  383. timeout = data->timeout_clks + (unsigned int)clks;
  384. base = host->base;
  385. writel(timeout, base + MMCIDATATIMER);
  386. writel(host->size, base + MMCIDATALENGTH);
  387. blksz_bits = ffs(data->blksz) - 1;
  388. BUG_ON(1 << blksz_bits != data->blksz);
  389. datactrl = MCI_DPSM_ENABLE | blksz_bits << 4;
  390. if (data->flags & MMC_DATA_READ)
  391. datactrl |= MCI_DPSM_DIRECTION;
  392. /*
  393. * Attempt to use DMA operation mode, if this
  394. * should fail, fall back to PIO mode
  395. */
  396. if (!mmci_dma_start_data(host, datactrl))
  397. return;
  398. /* IRQ mode, map the SG list for CPU reading/writing */
  399. mmci_init_sg(host, data);
  400. if (data->flags & MMC_DATA_READ) {
  401. irqmask = MCI_RXFIFOHALFFULLMASK;
  402. /*
  403. * If we have less than the fifo 'half-full' threshold to
  404. * transfer, trigger a PIO interrupt as soon as any data
  405. * is available.
  406. */
  407. if (host->size < variant->fifohalfsize)
  408. irqmask |= MCI_RXDATAAVLBLMASK;
  409. } else {
  410. /*
  411. * We don't actually need to include "FIFO empty" here
  412. * since its implicit in "FIFO half empty".
  413. */
  414. irqmask = MCI_TXFIFOHALFEMPTYMASK;
  415. }
  416. /* The ST Micro variants has a special bit to enable SDIO */
  417. if (variant->sdio && host->mmc->card)
  418. if (mmc_card_sdio(host->mmc->card))
  419. datactrl |= MCI_ST_DPSM_SDIOEN;
  420. writel(datactrl, base + MMCIDATACTRL);
  421. writel(readl(base + MMCIMASK0) & ~MCI_DATAENDMASK, base + MMCIMASK0);
  422. mmci_set_mask1(host, irqmask);
  423. }
  424. static void
  425. mmci_start_command(struct mmci_host *host, struct mmc_command *cmd, u32 c)
  426. {
  427. void __iomem *base = host->base;
  428. dev_dbg(mmc_dev(host->mmc), "op %02x arg %08x flags %08x\n",
  429. cmd->opcode, cmd->arg, cmd->flags);
  430. if (readl(base + MMCICOMMAND) & MCI_CPSM_ENABLE) {
  431. writel(0, base + MMCICOMMAND);
  432. udelay(1);
  433. }
  434. c |= cmd->opcode | MCI_CPSM_ENABLE;
  435. if (cmd->flags & MMC_RSP_PRESENT) {
  436. if (cmd->flags & MMC_RSP_136)
  437. c |= MCI_CPSM_LONGRSP;
  438. c |= MCI_CPSM_RESPONSE;
  439. }
  440. if (/*interrupt*/0)
  441. c |= MCI_CPSM_INTERRUPT;
  442. host->cmd = cmd;
  443. writel(cmd->arg, base + MMCIARGUMENT);
  444. writel(c, base + MMCICOMMAND);
  445. }
  446. static void
  447. mmci_data_irq(struct mmci_host *host, struct mmc_data *data,
  448. unsigned int status)
  449. {
  450. /* First check for errors */
  451. if (status & (MCI_DATACRCFAIL|MCI_DATATIMEOUT|MCI_TXUNDERRUN|MCI_RXOVERRUN)) {
  452. u32 remain, success;
  453. /* Terminate the DMA transfer */
  454. if (dma_inprogress(host))
  455. mmci_dma_data_error(host);
  456. /*
  457. * Calculate how far we are into the transfer. Note that
  458. * the data counter gives the number of bytes transferred
  459. * on the MMC bus, not on the host side. On reads, this
  460. * can be as much as a FIFO-worth of data ahead. This
  461. * matters for FIFO overruns only.
  462. */
  463. remain = readl(host->base + MMCIDATACNT);
  464. success = data->blksz * data->blocks - remain;
  465. dev_dbg(mmc_dev(host->mmc), "MCI ERROR IRQ, status 0x%08x at 0x%08x\n",
  466. status, success);
  467. if (status & MCI_DATACRCFAIL) {
  468. /* Last block was not successful */
  469. success -= 1;
  470. data->error = -EILSEQ;
  471. } else if (status & MCI_DATATIMEOUT) {
  472. data->error = -ETIMEDOUT;
  473. } else if (status & MCI_TXUNDERRUN) {
  474. data->error = -EIO;
  475. } else if (status & MCI_RXOVERRUN) {
  476. if (success > host->variant->fifosize)
  477. success -= host->variant->fifosize;
  478. else
  479. success = 0;
  480. data->error = -EIO;
  481. }
  482. data->bytes_xfered = round_down(success, data->blksz);
  483. }
  484. if (status & MCI_DATABLOCKEND)
  485. dev_err(mmc_dev(host->mmc), "stray MCI_DATABLOCKEND interrupt\n");
  486. if (status & MCI_DATAEND || data->error) {
  487. if (dma_inprogress(host))
  488. mmci_dma_unmap(host, data);
  489. mmci_stop_data(host);
  490. if (!data->error)
  491. /* The error clause is handled above, success! */
  492. data->bytes_xfered = data->blksz * data->blocks;
  493. if (!data->stop) {
  494. mmci_request_end(host, data->mrq);
  495. } else {
  496. mmci_start_command(host, data->stop, 0);
  497. }
  498. }
  499. }
  500. static void
  501. mmci_cmd_irq(struct mmci_host *host, struct mmc_command *cmd,
  502. unsigned int status)
  503. {
  504. void __iomem *base = host->base;
  505. host->cmd = NULL;
  506. if (status & MCI_CMDTIMEOUT) {
  507. cmd->error = -ETIMEDOUT;
  508. } else if (status & MCI_CMDCRCFAIL && cmd->flags & MMC_RSP_CRC) {
  509. cmd->error = -EILSEQ;
  510. } else {
  511. cmd->resp[0] = readl(base + MMCIRESPONSE0);
  512. cmd->resp[1] = readl(base + MMCIRESPONSE1);
  513. cmd->resp[2] = readl(base + MMCIRESPONSE2);
  514. cmd->resp[3] = readl(base + MMCIRESPONSE3);
  515. }
  516. if (!cmd->data || cmd->error) {
  517. if (host->data)
  518. mmci_stop_data(host);
  519. mmci_request_end(host, cmd->mrq);
  520. } else if (!(cmd->data->flags & MMC_DATA_READ)) {
  521. mmci_start_data(host, cmd->data);
  522. }
  523. }
  524. static int mmci_pio_read(struct mmci_host *host, char *buffer, unsigned int remain)
  525. {
  526. void __iomem *base = host->base;
  527. char *ptr = buffer;
  528. u32 status;
  529. int host_remain = host->size;
  530. do {
  531. int count = host_remain - (readl(base + MMCIFIFOCNT) << 2);
  532. if (count > remain)
  533. count = remain;
  534. if (count <= 0)
  535. break;
  536. readsl(base + MMCIFIFO, ptr, count >> 2);
  537. ptr += count;
  538. remain -= count;
  539. host_remain -= count;
  540. if (remain == 0)
  541. break;
  542. status = readl(base + MMCISTATUS);
  543. } while (status & MCI_RXDATAAVLBL);
  544. return ptr - buffer;
  545. }
  546. static int mmci_pio_write(struct mmci_host *host, char *buffer, unsigned int remain, u32 status)
  547. {
  548. struct variant_data *variant = host->variant;
  549. void __iomem *base = host->base;
  550. char *ptr = buffer;
  551. do {
  552. unsigned int count, maxcnt;
  553. maxcnt = status & MCI_TXFIFOEMPTY ?
  554. variant->fifosize : variant->fifohalfsize;
  555. count = min(remain, maxcnt);
  556. /*
  557. * The ST Micro variant for SDIO transfer sizes
  558. * less then 8 bytes should have clock H/W flow
  559. * control disabled.
  560. */
  561. if (variant->sdio &&
  562. mmc_card_sdio(host->mmc->card)) {
  563. if (count < 8)
  564. writel(readl(host->base + MMCICLOCK) &
  565. ~variant->clkreg_enable,
  566. host->base + MMCICLOCK);
  567. else
  568. writel(readl(host->base + MMCICLOCK) |
  569. variant->clkreg_enable,
  570. host->base + MMCICLOCK);
  571. }
  572. /*
  573. * SDIO especially may want to send something that is
  574. * not divisible by 4 (as opposed to card sectors
  575. * etc), and the FIFO only accept full 32-bit writes.
  576. * So compensate by adding +3 on the count, a single
  577. * byte become a 32bit write, 7 bytes will be two
  578. * 32bit writes etc.
  579. */
  580. writesl(base + MMCIFIFO, ptr, (count + 3) >> 2);
  581. ptr += count;
  582. remain -= count;
  583. if (remain == 0)
  584. break;
  585. status = readl(base + MMCISTATUS);
  586. } while (status & MCI_TXFIFOHALFEMPTY);
  587. return ptr - buffer;
  588. }
  589. /*
  590. * PIO data transfer IRQ handler.
  591. */
  592. static irqreturn_t mmci_pio_irq(int irq, void *dev_id)
  593. {
  594. struct mmci_host *host = dev_id;
  595. struct sg_mapping_iter *sg_miter = &host->sg_miter;
  596. struct variant_data *variant = host->variant;
  597. void __iomem *base = host->base;
  598. unsigned long flags;
  599. u32 status;
  600. status = readl(base + MMCISTATUS);
  601. dev_dbg(mmc_dev(host->mmc), "irq1 (pio) %08x\n", status);
  602. local_irq_save(flags);
  603. do {
  604. unsigned int remain, len;
  605. char *buffer;
  606. /*
  607. * For write, we only need to test the half-empty flag
  608. * here - if the FIFO is completely empty, then by
  609. * definition it is more than half empty.
  610. *
  611. * For read, check for data available.
  612. */
  613. if (!(status & (MCI_TXFIFOHALFEMPTY|MCI_RXDATAAVLBL)))
  614. break;
  615. if (!sg_miter_next(sg_miter))
  616. break;
  617. buffer = sg_miter->addr;
  618. remain = sg_miter->length;
  619. len = 0;
  620. if (status & MCI_RXACTIVE)
  621. len = mmci_pio_read(host, buffer, remain);
  622. if (status & MCI_TXACTIVE)
  623. len = mmci_pio_write(host, buffer, remain, status);
  624. sg_miter->consumed = len;
  625. host->size -= len;
  626. remain -= len;
  627. if (remain)
  628. break;
  629. status = readl(base + MMCISTATUS);
  630. } while (1);
  631. sg_miter_stop(sg_miter);
  632. local_irq_restore(flags);
  633. /*
  634. * If we have less than the fifo 'half-full' threshold to transfer,
  635. * trigger a PIO interrupt as soon as any data is available.
  636. */
  637. if (status & MCI_RXACTIVE && host->size < variant->fifohalfsize)
  638. mmci_set_mask1(host, MCI_RXDATAAVLBLMASK);
  639. /*
  640. * If we run out of data, disable the data IRQs; this
  641. * prevents a race where the FIFO becomes empty before
  642. * the chip itself has disabled the data path, and
  643. * stops us racing with our data end IRQ.
  644. */
  645. if (host->size == 0) {
  646. mmci_set_mask1(host, 0);
  647. writel(readl(base + MMCIMASK0) | MCI_DATAENDMASK, base + MMCIMASK0);
  648. }
  649. return IRQ_HANDLED;
  650. }
  651. /*
  652. * Handle completion of command and data transfers.
  653. */
  654. static irqreturn_t mmci_irq(int irq, void *dev_id)
  655. {
  656. struct mmci_host *host = dev_id;
  657. u32 status;
  658. int ret = 0;
  659. spin_lock(&host->lock);
  660. do {
  661. struct mmc_command *cmd;
  662. struct mmc_data *data;
  663. status = readl(host->base + MMCISTATUS);
  664. if (host->singleirq) {
  665. if (status & readl(host->base + MMCIMASK1))
  666. mmci_pio_irq(irq, dev_id);
  667. status &= ~MCI_IRQ1MASK;
  668. }
  669. status &= readl(host->base + MMCIMASK0);
  670. writel(status, host->base + MMCICLEAR);
  671. dev_dbg(mmc_dev(host->mmc), "irq0 (data+cmd) %08x\n", status);
  672. data = host->data;
  673. if (status & (MCI_DATACRCFAIL|MCI_DATATIMEOUT|MCI_TXUNDERRUN|
  674. MCI_RXOVERRUN|MCI_DATAEND|MCI_DATABLOCKEND) && data)
  675. mmci_data_irq(host, data, status);
  676. cmd = host->cmd;
  677. if (status & (MCI_CMDCRCFAIL|MCI_CMDTIMEOUT|MCI_CMDSENT|MCI_CMDRESPEND) && cmd)
  678. mmci_cmd_irq(host, cmd, status);
  679. ret = 1;
  680. } while (status);
  681. spin_unlock(&host->lock);
  682. return IRQ_RETVAL(ret);
  683. }
  684. static void mmci_request(struct mmc_host *mmc, struct mmc_request *mrq)
  685. {
  686. struct mmci_host *host = mmc_priv(mmc);
  687. unsigned long flags;
  688. WARN_ON(host->mrq != NULL);
  689. if (mrq->data && !is_power_of_2(mrq->data->blksz)) {
  690. dev_err(mmc_dev(mmc), "unsupported block size (%d bytes)\n",
  691. mrq->data->blksz);
  692. mrq->cmd->error = -EINVAL;
  693. mmc_request_done(mmc, mrq);
  694. return;
  695. }
  696. spin_lock_irqsave(&host->lock, flags);
  697. host->mrq = mrq;
  698. if (mrq->data && mrq->data->flags & MMC_DATA_READ)
  699. mmci_start_data(host, mrq->data);
  700. mmci_start_command(host, mrq->cmd, 0);
  701. spin_unlock_irqrestore(&host->lock, flags);
  702. }
  703. static void mmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
  704. {
  705. struct mmci_host *host = mmc_priv(mmc);
  706. u32 pwr = 0;
  707. unsigned long flags;
  708. int ret;
  709. switch (ios->power_mode) {
  710. case MMC_POWER_OFF:
  711. if (host->vcc)
  712. ret = mmc_regulator_set_ocr(mmc, host->vcc, 0);
  713. break;
  714. case MMC_POWER_UP:
  715. if (host->vcc) {
  716. ret = mmc_regulator_set_ocr(mmc, host->vcc, ios->vdd);
  717. if (ret) {
  718. dev_err(mmc_dev(mmc), "unable to set OCR\n");
  719. /*
  720. * The .set_ios() function in the mmc_host_ops
  721. * struct return void, and failing to set the
  722. * power should be rare so we print an error
  723. * and return here.
  724. */
  725. return;
  726. }
  727. }
  728. if (host->plat->vdd_handler)
  729. pwr |= host->plat->vdd_handler(mmc_dev(mmc), ios->vdd,
  730. ios->power_mode);
  731. /* The ST version does not have this, fall through to POWER_ON */
  732. if (host->hw_designer != AMBA_VENDOR_ST) {
  733. pwr |= MCI_PWR_UP;
  734. break;
  735. }
  736. case MMC_POWER_ON:
  737. pwr |= MCI_PWR_ON;
  738. break;
  739. }
  740. if (ios->bus_mode == MMC_BUSMODE_OPENDRAIN) {
  741. if (host->hw_designer != AMBA_VENDOR_ST)
  742. pwr |= MCI_ROD;
  743. else {
  744. /*
  745. * The ST Micro variant use the ROD bit for something
  746. * else and only has OD (Open Drain).
  747. */
  748. pwr |= MCI_OD;
  749. }
  750. }
  751. spin_lock_irqsave(&host->lock, flags);
  752. mmci_set_clkreg(host, ios->clock);
  753. if (host->pwr != pwr) {
  754. host->pwr = pwr;
  755. writel(pwr, host->base + MMCIPOWER);
  756. }
  757. spin_unlock_irqrestore(&host->lock, flags);
  758. }
  759. static int mmci_get_ro(struct mmc_host *mmc)
  760. {
  761. struct mmci_host *host = mmc_priv(mmc);
  762. if (host->gpio_wp == -ENOSYS)
  763. return -ENOSYS;
  764. return gpio_get_value_cansleep(host->gpio_wp);
  765. }
  766. static int mmci_get_cd(struct mmc_host *mmc)
  767. {
  768. struct mmci_host *host = mmc_priv(mmc);
  769. struct mmci_platform_data *plat = host->plat;
  770. unsigned int status;
  771. if (host->gpio_cd == -ENOSYS) {
  772. if (!plat->status)
  773. return 1; /* Assume always present */
  774. status = plat->status(mmc_dev(host->mmc));
  775. } else
  776. status = !!gpio_get_value_cansleep(host->gpio_cd)
  777. ^ plat->cd_invert;
  778. /*
  779. * Use positive logic throughout - status is zero for no card,
  780. * non-zero for card inserted.
  781. */
  782. return status;
  783. }
  784. static irqreturn_t mmci_cd_irq(int irq, void *dev_id)
  785. {
  786. struct mmci_host *host = dev_id;
  787. mmc_detect_change(host->mmc, msecs_to_jiffies(500));
  788. return IRQ_HANDLED;
  789. }
  790. static const struct mmc_host_ops mmci_ops = {
  791. .request = mmci_request,
  792. .set_ios = mmci_set_ios,
  793. .get_ro = mmci_get_ro,
  794. .get_cd = mmci_get_cd,
  795. };
  796. static int __devinit mmci_probe(struct amba_device *dev,
  797. const struct amba_id *id)
  798. {
  799. struct mmci_platform_data *plat = dev->dev.platform_data;
  800. struct variant_data *variant = id->data;
  801. struct mmci_host *host;
  802. struct mmc_host *mmc;
  803. int ret;
  804. /* must have platform data */
  805. if (!plat) {
  806. ret = -EINVAL;
  807. goto out;
  808. }
  809. ret = amba_request_regions(dev, DRIVER_NAME);
  810. if (ret)
  811. goto out;
  812. mmc = mmc_alloc_host(sizeof(struct mmci_host), &dev->dev);
  813. if (!mmc) {
  814. ret = -ENOMEM;
  815. goto rel_regions;
  816. }
  817. host = mmc_priv(mmc);
  818. host->mmc = mmc;
  819. host->gpio_wp = -ENOSYS;
  820. host->gpio_cd = -ENOSYS;
  821. host->gpio_cd_irq = -1;
  822. host->hw_designer = amba_manf(dev);
  823. host->hw_revision = amba_rev(dev);
  824. dev_dbg(mmc_dev(mmc), "designer ID = 0x%02x\n", host->hw_designer);
  825. dev_dbg(mmc_dev(mmc), "revision = 0x%01x\n", host->hw_revision);
  826. host->clk = clk_get(&dev->dev, NULL);
  827. if (IS_ERR(host->clk)) {
  828. ret = PTR_ERR(host->clk);
  829. host->clk = NULL;
  830. goto host_free;
  831. }
  832. ret = clk_enable(host->clk);
  833. if (ret)
  834. goto clk_free;
  835. host->plat = plat;
  836. host->variant = variant;
  837. host->mclk = clk_get_rate(host->clk);
  838. /*
  839. * According to the spec, mclk is max 100 MHz,
  840. * so we try to adjust the clock down to this,
  841. * (if possible).
  842. */
  843. if (host->mclk > 100000000) {
  844. ret = clk_set_rate(host->clk, 100000000);
  845. if (ret < 0)
  846. goto clk_disable;
  847. host->mclk = clk_get_rate(host->clk);
  848. dev_dbg(mmc_dev(mmc), "eventual mclk rate: %u Hz\n",
  849. host->mclk);
  850. }
  851. host->phybase = dev->res.start;
  852. host->base = ioremap(dev->res.start, resource_size(&dev->res));
  853. if (!host->base) {
  854. ret = -ENOMEM;
  855. goto clk_disable;
  856. }
  857. mmc->ops = &mmci_ops;
  858. mmc->f_min = (host->mclk + 511) / 512;
  859. /*
  860. * If the platform data supplies a maximum operating
  861. * frequency, this takes precedence. Else, we fall back
  862. * to using the module parameter, which has a (low)
  863. * default value in case it is not specified. Either
  864. * value must not exceed the clock rate into the block,
  865. * of course.
  866. */
  867. if (plat->f_max)
  868. mmc->f_max = min(host->mclk, plat->f_max);
  869. else
  870. mmc->f_max = min(host->mclk, fmax);
  871. dev_dbg(mmc_dev(mmc), "clocking block at %u Hz\n", mmc->f_max);
  872. #ifdef CONFIG_REGULATOR
  873. /* If we're using the regulator framework, try to fetch a regulator */
  874. host->vcc = regulator_get(&dev->dev, "vmmc");
  875. if (IS_ERR(host->vcc))
  876. host->vcc = NULL;
  877. else {
  878. int mask = mmc_regulator_get_ocrmask(host->vcc);
  879. if (mask < 0)
  880. dev_err(&dev->dev, "error getting OCR mask (%d)\n",
  881. mask);
  882. else {
  883. host->mmc->ocr_avail = (u32) mask;
  884. if (plat->ocr_mask)
  885. dev_warn(&dev->dev,
  886. "Provided ocr_mask/setpower will not be used "
  887. "(using regulator instead)\n");
  888. }
  889. }
  890. #endif
  891. /* Fall back to platform data if no regulator is found */
  892. if (host->vcc == NULL)
  893. mmc->ocr_avail = plat->ocr_mask;
  894. mmc->caps = plat->capabilities;
  895. /*
  896. * We can do SGIO
  897. */
  898. mmc->max_segs = NR_SG;
  899. /*
  900. * Since only a certain number of bits are valid in the data length
  901. * register, we must ensure that we don't exceed 2^num-1 bytes in a
  902. * single request.
  903. */
  904. mmc->max_req_size = (1 << variant->datalength_bits) - 1;
  905. /*
  906. * Set the maximum segment size. Since we aren't doing DMA
  907. * (yet) we are only limited by the data length register.
  908. */
  909. mmc->max_seg_size = mmc->max_req_size;
  910. /*
  911. * Block size can be up to 2048 bytes, but must be a power of two.
  912. */
  913. mmc->max_blk_size = 2048;
  914. /*
  915. * No limit on the number of blocks transferred.
  916. */
  917. mmc->max_blk_count = mmc->max_req_size;
  918. spin_lock_init(&host->lock);
  919. writel(0, host->base + MMCIMASK0);
  920. writel(0, host->base + MMCIMASK1);
  921. writel(0xfff, host->base + MMCICLEAR);
  922. if (gpio_is_valid(plat->gpio_cd)) {
  923. ret = gpio_request(plat->gpio_cd, DRIVER_NAME " (cd)");
  924. if (ret == 0)
  925. ret = gpio_direction_input(plat->gpio_cd);
  926. if (ret == 0)
  927. host->gpio_cd = plat->gpio_cd;
  928. else if (ret != -ENOSYS)
  929. goto err_gpio_cd;
  930. ret = request_any_context_irq(gpio_to_irq(plat->gpio_cd),
  931. mmci_cd_irq, 0,
  932. DRIVER_NAME " (cd)", host);
  933. if (ret >= 0)
  934. host->gpio_cd_irq = gpio_to_irq(plat->gpio_cd);
  935. }
  936. if (gpio_is_valid(plat->gpio_wp)) {
  937. ret = gpio_request(plat->gpio_wp, DRIVER_NAME " (wp)");
  938. if (ret == 0)
  939. ret = gpio_direction_input(plat->gpio_wp);
  940. if (ret == 0)
  941. host->gpio_wp = plat->gpio_wp;
  942. else if (ret != -ENOSYS)
  943. goto err_gpio_wp;
  944. }
  945. if ((host->plat->status || host->gpio_cd != -ENOSYS)
  946. && host->gpio_cd_irq < 0)
  947. mmc->caps |= MMC_CAP_NEEDS_POLL;
  948. ret = request_irq(dev->irq[0], mmci_irq, IRQF_SHARED, DRIVER_NAME " (cmd)", host);
  949. if (ret)
  950. goto unmap;
  951. if (dev->irq[1] == NO_IRQ)
  952. host->singleirq = true;
  953. else {
  954. ret = request_irq(dev->irq[1], mmci_pio_irq, IRQF_SHARED,
  955. DRIVER_NAME " (pio)", host);
  956. if (ret)
  957. goto irq0_free;
  958. }
  959. writel(MCI_IRQENABLE, host->base + MMCIMASK0);
  960. amba_set_drvdata(dev, mmc);
  961. dev_info(&dev->dev, "%s: PL%03x manf %x rev%u at 0x%08llx irq %d,%d (pio)\n",
  962. mmc_hostname(mmc), amba_part(dev), amba_manf(dev),
  963. amba_rev(dev), (unsigned long long)dev->res.start,
  964. dev->irq[0], dev->irq[1]);
  965. mmci_dma_setup(host);
  966. mmc_add_host(mmc);
  967. return 0;
  968. irq0_free:
  969. free_irq(dev->irq[0], host);
  970. unmap:
  971. if (host->gpio_wp != -ENOSYS)
  972. gpio_free(host->gpio_wp);
  973. err_gpio_wp:
  974. if (host->gpio_cd_irq >= 0)
  975. free_irq(host->gpio_cd_irq, host);
  976. if (host->gpio_cd != -ENOSYS)
  977. gpio_free(host->gpio_cd);
  978. err_gpio_cd:
  979. iounmap(host->base);
  980. clk_disable:
  981. clk_disable(host->clk);
  982. clk_free:
  983. clk_put(host->clk);
  984. host_free:
  985. mmc_free_host(mmc);
  986. rel_regions:
  987. amba_release_regions(dev);
  988. out:
  989. return ret;
  990. }
  991. static int __devexit mmci_remove(struct amba_device *dev)
  992. {
  993. struct mmc_host *mmc = amba_get_drvdata(dev);
  994. amba_set_drvdata(dev, NULL);
  995. if (mmc) {
  996. struct mmci_host *host = mmc_priv(mmc);
  997. mmc_remove_host(mmc);
  998. writel(0, host->base + MMCIMASK0);
  999. writel(0, host->base + MMCIMASK1);
  1000. writel(0, host->base + MMCICOMMAND);
  1001. writel(0, host->base + MMCIDATACTRL);
  1002. mmci_dma_release(host);
  1003. free_irq(dev->irq[0], host);
  1004. if (!host->singleirq)
  1005. free_irq(dev->irq[1], host);
  1006. if (host->gpio_wp != -ENOSYS)
  1007. gpio_free(host->gpio_wp);
  1008. if (host->gpio_cd_irq >= 0)
  1009. free_irq(host->gpio_cd_irq, host);
  1010. if (host->gpio_cd != -ENOSYS)
  1011. gpio_free(host->gpio_cd);
  1012. iounmap(host->base);
  1013. clk_disable(host->clk);
  1014. clk_put(host->clk);
  1015. if (host->vcc)
  1016. mmc_regulator_set_ocr(mmc, host->vcc, 0);
  1017. regulator_put(host->vcc);
  1018. mmc_free_host(mmc);
  1019. amba_release_regions(dev);
  1020. }
  1021. return 0;
  1022. }
  1023. #ifdef CONFIG_PM
  1024. static int mmci_suspend(struct amba_device *dev, pm_message_t state)
  1025. {
  1026. struct mmc_host *mmc = amba_get_drvdata(dev);
  1027. int ret = 0;
  1028. if (mmc) {
  1029. struct mmci_host *host = mmc_priv(mmc);
  1030. ret = mmc_suspend_host(mmc);
  1031. if (ret == 0)
  1032. writel(0, host->base + MMCIMASK0);
  1033. }
  1034. return ret;
  1035. }
  1036. static int mmci_resume(struct amba_device *dev)
  1037. {
  1038. struct mmc_host *mmc = amba_get_drvdata(dev);
  1039. int ret = 0;
  1040. if (mmc) {
  1041. struct mmci_host *host = mmc_priv(mmc);
  1042. writel(MCI_IRQENABLE, host->base + MMCIMASK0);
  1043. ret = mmc_resume_host(mmc);
  1044. }
  1045. return ret;
  1046. }
  1047. #else
  1048. #define mmci_suspend NULL
  1049. #define mmci_resume NULL
  1050. #endif
  1051. static struct amba_id mmci_ids[] = {
  1052. {
  1053. .id = 0x00041180,
  1054. .mask = 0x000fffff,
  1055. .data = &variant_arm,
  1056. },
  1057. {
  1058. .id = 0x00041181,
  1059. .mask = 0x000fffff,
  1060. .data = &variant_arm,
  1061. },
  1062. /* ST Micro variants */
  1063. {
  1064. .id = 0x00180180,
  1065. .mask = 0x00ffffff,
  1066. .data = &variant_u300,
  1067. },
  1068. {
  1069. .id = 0x00280180,
  1070. .mask = 0x00ffffff,
  1071. .data = &variant_u300,
  1072. },
  1073. {
  1074. .id = 0x00480180,
  1075. .mask = 0x00ffffff,
  1076. .data = &variant_ux500,
  1077. },
  1078. { 0, 0 },
  1079. };
  1080. static struct amba_driver mmci_driver = {
  1081. .drv = {
  1082. .name = DRIVER_NAME,
  1083. },
  1084. .probe = mmci_probe,
  1085. .remove = __devexit_p(mmci_remove),
  1086. .suspend = mmci_suspend,
  1087. .resume = mmci_resume,
  1088. .id_table = mmci_ids,
  1089. };
  1090. static int __init mmci_init(void)
  1091. {
  1092. return amba_driver_register(&mmci_driver);
  1093. }
  1094. static void __exit mmci_exit(void)
  1095. {
  1096. amba_driver_unregister(&mmci_driver);
  1097. }
  1098. module_init(mmci_init);
  1099. module_exit(mmci_exit);
  1100. module_param(fmax, uint, 0444);
  1101. MODULE_DESCRIPTION("ARM PrimeCell PL180/181 Multimedia Card Interface driver");
  1102. MODULE_LICENSE("GPL");