mmci.c 32 KB

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