msm_sdcc.c 30 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283
  1. /*
  2. * linux/drivers/mmc/host/msm_sdcc.c - Qualcomm MSM 7X00A SDCC Driver
  3. *
  4. * Copyright (C) 2007 Google Inc,
  5. * Copyright (C) 2003 Deep Blue Solutions, Ltd, All Rights Reserved.
  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. * Based on mmci.c
  12. *
  13. * Author: San Mehat (san@android.com)
  14. *
  15. */
  16. #include <linux/module.h>
  17. #include <linux/moduleparam.h>
  18. #include <linux/init.h>
  19. #include <linux/ioport.h>
  20. #include <linux/device.h>
  21. #include <linux/interrupt.h>
  22. #include <linux/delay.h>
  23. #include <linux/err.h>
  24. #include <linux/highmem.h>
  25. #include <linux/log2.h>
  26. #include <linux/mmc/host.h>
  27. #include <linux/mmc/card.h>
  28. #include <linux/clk.h>
  29. #include <linux/scatterlist.h>
  30. #include <linux/platform_device.h>
  31. #include <linux/dma-mapping.h>
  32. #include <linux/debugfs.h>
  33. #include <linux/io.h>
  34. #include <linux/memory.h>
  35. #include <linux/gfp.h>
  36. #include <asm/cacheflush.h>
  37. #include <asm/div64.h>
  38. #include <asm/sizes.h>
  39. #include <mach/mmc.h>
  40. #include <mach/msm_iomap.h>
  41. #include <mach/dma.h>
  42. #include "msm_sdcc.h"
  43. #define DRIVER_NAME "msm-sdcc"
  44. static unsigned int msmsdcc_fmin = 144000;
  45. static unsigned int msmsdcc_fmax = 50000000;
  46. static unsigned int msmsdcc_4bit = 1;
  47. static unsigned int msmsdcc_pwrsave = 1;
  48. static unsigned int msmsdcc_piopoll = 1;
  49. static unsigned int msmsdcc_sdioirq;
  50. #define PIO_SPINMAX 30
  51. #define CMD_SPINMAX 20
  52. static void
  53. msmsdcc_start_command(struct msmsdcc_host *host, struct mmc_command *cmd,
  54. u32 c);
  55. static void
  56. msmsdcc_request_end(struct msmsdcc_host *host, struct mmc_request *mrq)
  57. {
  58. writel(0, host->base + MMCICOMMAND);
  59. BUG_ON(host->curr.data);
  60. host->curr.mrq = NULL;
  61. host->curr.cmd = NULL;
  62. if (mrq->data)
  63. mrq->data->bytes_xfered = host->curr.data_xfered;
  64. if (mrq->cmd->error == -ETIMEDOUT)
  65. mdelay(5);
  66. /*
  67. * Need to drop the host lock here; mmc_request_done may call
  68. * back into the driver...
  69. */
  70. spin_unlock(&host->lock);
  71. mmc_request_done(host->mmc, mrq);
  72. spin_lock(&host->lock);
  73. }
  74. static void
  75. msmsdcc_stop_data(struct msmsdcc_host *host)
  76. {
  77. writel(0, host->base + MMCIDATACTRL);
  78. host->curr.data = NULL;
  79. host->curr.got_dataend = host->curr.got_datablkend = 0;
  80. }
  81. uint32_t msmsdcc_fifo_addr(struct msmsdcc_host *host)
  82. {
  83. switch (host->pdev_id) {
  84. case 1:
  85. return MSM_SDC1_PHYS + MMCIFIFO;
  86. case 2:
  87. return MSM_SDC2_PHYS + MMCIFIFO;
  88. case 3:
  89. return MSM_SDC3_PHYS + MMCIFIFO;
  90. case 4:
  91. return MSM_SDC4_PHYS + MMCIFIFO;
  92. }
  93. BUG();
  94. return 0;
  95. }
  96. static void
  97. msmsdcc_dma_complete_func(struct msm_dmov_cmd *cmd,
  98. unsigned int result,
  99. struct msm_dmov_errdata *err)
  100. {
  101. struct msmsdcc_dma_data *dma_data =
  102. container_of(cmd, struct msmsdcc_dma_data, hdr);
  103. struct msmsdcc_host *host = dma_data->host;
  104. unsigned long flags;
  105. struct mmc_request *mrq;
  106. spin_lock_irqsave(&host->lock, flags);
  107. mrq = host->curr.mrq;
  108. BUG_ON(!mrq);
  109. if (!(result & DMOV_RSLT_VALID)) {
  110. pr_err("msmsdcc: Invalid DataMover result\n");
  111. goto out;
  112. }
  113. if (result & DMOV_RSLT_DONE) {
  114. host->curr.data_xfered = host->curr.xfer_size;
  115. } else {
  116. /* Error or flush */
  117. if (result & DMOV_RSLT_ERROR)
  118. pr_err("%s: DMA error (0x%.8x)\n",
  119. mmc_hostname(host->mmc), result);
  120. if (result & DMOV_RSLT_FLUSH)
  121. pr_err("%s: DMA channel flushed (0x%.8x)\n",
  122. mmc_hostname(host->mmc), result);
  123. if (err)
  124. pr_err("Flush data: %.8x %.8x %.8x %.8x %.8x %.8x\n",
  125. err->flush[0], err->flush[1], err->flush[2],
  126. err->flush[3], err->flush[4], err->flush[5]);
  127. if (!mrq->data->error)
  128. mrq->data->error = -EIO;
  129. }
  130. host->dma.busy = 0;
  131. dma_unmap_sg(mmc_dev(host->mmc), host->dma.sg, host->dma.num_ents,
  132. host->dma.dir);
  133. if (host->curr.user_pages) {
  134. struct scatterlist *sg = host->dma.sg;
  135. int i;
  136. for (i = 0; i < host->dma.num_ents; i++)
  137. flush_dcache_page(sg_page(sg++));
  138. }
  139. host->dma.sg = NULL;
  140. if ((host->curr.got_dataend && host->curr.got_datablkend)
  141. || mrq->data->error) {
  142. /*
  143. * If we've already gotten our DATAEND / DATABLKEND
  144. * for this request, then complete it through here.
  145. */
  146. msmsdcc_stop_data(host);
  147. if (!mrq->data->error)
  148. host->curr.data_xfered = host->curr.xfer_size;
  149. if (!mrq->data->stop || mrq->cmd->error) {
  150. writel(0, host->base + MMCICOMMAND);
  151. host->curr.mrq = NULL;
  152. host->curr.cmd = NULL;
  153. mrq->data->bytes_xfered = host->curr.data_xfered;
  154. spin_unlock_irqrestore(&host->lock, flags);
  155. mmc_request_done(host->mmc, mrq);
  156. return;
  157. } else
  158. msmsdcc_start_command(host, mrq->data->stop, 0);
  159. }
  160. out:
  161. spin_unlock_irqrestore(&host->lock, flags);
  162. return;
  163. }
  164. static int validate_dma(struct msmsdcc_host *host, struct mmc_data *data)
  165. {
  166. if (host->dma.channel == -1)
  167. return -ENOENT;
  168. if ((data->blksz * data->blocks) < MCI_FIFOSIZE)
  169. return -EINVAL;
  170. if ((data->blksz * data->blocks) % MCI_FIFOSIZE)
  171. return -EINVAL;
  172. return 0;
  173. }
  174. static int msmsdcc_config_dma(struct msmsdcc_host *host, struct mmc_data *data)
  175. {
  176. struct msmsdcc_nc_dmadata *nc;
  177. dmov_box *box;
  178. uint32_t rows;
  179. uint32_t crci;
  180. unsigned int n;
  181. int i, rc;
  182. struct scatterlist *sg = data->sg;
  183. rc = validate_dma(host, data);
  184. if (rc)
  185. return rc;
  186. host->dma.sg = data->sg;
  187. host->dma.num_ents = data->sg_len;
  188. nc = host->dma.nc;
  189. switch (host->pdev_id) {
  190. case 1:
  191. crci = MSMSDCC_CRCI_SDC1;
  192. break;
  193. case 2:
  194. crci = MSMSDCC_CRCI_SDC2;
  195. break;
  196. case 3:
  197. crci = MSMSDCC_CRCI_SDC3;
  198. break;
  199. case 4:
  200. crci = MSMSDCC_CRCI_SDC4;
  201. break;
  202. default:
  203. host->dma.sg = NULL;
  204. host->dma.num_ents = 0;
  205. return -ENOENT;
  206. }
  207. if (data->flags & MMC_DATA_READ)
  208. host->dma.dir = DMA_FROM_DEVICE;
  209. else
  210. host->dma.dir = DMA_TO_DEVICE;
  211. host->curr.user_pages = 0;
  212. n = dma_map_sg(mmc_dev(host->mmc), host->dma.sg,
  213. host->dma.num_ents, host->dma.dir);
  214. if (n != host->dma.num_ents) {
  215. pr_err("%s: Unable to map in all sg elements\n",
  216. mmc_hostname(host->mmc));
  217. host->dma.sg = NULL;
  218. host->dma.num_ents = 0;
  219. return -ENOMEM;
  220. }
  221. box = &nc->cmd[0];
  222. for (i = 0; i < host->dma.num_ents; i++) {
  223. box->cmd = CMD_MODE_BOX;
  224. if (i == (host->dma.num_ents - 1))
  225. box->cmd |= CMD_LC;
  226. rows = (sg_dma_len(sg) % MCI_FIFOSIZE) ?
  227. (sg_dma_len(sg) / MCI_FIFOSIZE) + 1 :
  228. (sg_dma_len(sg) / MCI_FIFOSIZE) ;
  229. if (data->flags & MMC_DATA_READ) {
  230. box->src_row_addr = msmsdcc_fifo_addr(host);
  231. box->dst_row_addr = sg_dma_address(sg);
  232. box->src_dst_len = (MCI_FIFOSIZE << 16) |
  233. (MCI_FIFOSIZE);
  234. box->row_offset = MCI_FIFOSIZE;
  235. box->num_rows = rows * ((1 << 16) + 1);
  236. box->cmd |= CMD_SRC_CRCI(crci);
  237. } else {
  238. box->src_row_addr = sg_dma_address(sg);
  239. box->dst_row_addr = msmsdcc_fifo_addr(host);
  240. box->src_dst_len = (MCI_FIFOSIZE << 16) |
  241. (MCI_FIFOSIZE);
  242. box->row_offset = (MCI_FIFOSIZE << 16);
  243. box->num_rows = rows * ((1 << 16) + 1);
  244. box->cmd |= CMD_DST_CRCI(crci);
  245. }
  246. box++;
  247. sg++;
  248. }
  249. /* location of command block must be 64 bit aligned */
  250. BUG_ON(host->dma.cmd_busaddr & 0x07);
  251. nc->cmdptr = (host->dma.cmd_busaddr >> 3) | CMD_PTR_LP;
  252. host->dma.hdr.cmdptr = DMOV_CMD_PTR_LIST |
  253. DMOV_CMD_ADDR(host->dma.cmdptr_busaddr);
  254. host->dma.hdr.complete_func = msmsdcc_dma_complete_func;
  255. return 0;
  256. }
  257. static void
  258. msmsdcc_start_data(struct msmsdcc_host *host, struct mmc_data *data)
  259. {
  260. unsigned int datactrl, timeout;
  261. unsigned long long clks;
  262. void __iomem *base = host->base;
  263. unsigned int pio_irqmask = 0;
  264. host->curr.data = data;
  265. host->curr.xfer_size = data->blksz * data->blocks;
  266. host->curr.xfer_remain = host->curr.xfer_size;
  267. host->curr.data_xfered = 0;
  268. host->curr.got_dataend = 0;
  269. host->curr.got_datablkend = 0;
  270. memset(&host->pio, 0, sizeof(host->pio));
  271. clks = (unsigned long long)data->timeout_ns * host->clk_rate;
  272. do_div(clks, NSEC_PER_SEC);
  273. timeout = data->timeout_clks + (unsigned int)clks;
  274. writel(timeout, base + MMCIDATATIMER);
  275. writel(host->curr.xfer_size, base + MMCIDATALENGTH);
  276. datactrl = MCI_DPSM_ENABLE | (data->blksz << 4);
  277. if (!msmsdcc_config_dma(host, data))
  278. datactrl |= MCI_DPSM_DMAENABLE;
  279. else {
  280. host->pio.sg = data->sg;
  281. host->pio.sg_len = data->sg_len;
  282. host->pio.sg_off = 0;
  283. if (data->flags & MMC_DATA_READ) {
  284. pio_irqmask = MCI_RXFIFOHALFFULLMASK;
  285. if (host->curr.xfer_remain < MCI_FIFOSIZE)
  286. pio_irqmask |= MCI_RXDATAAVLBLMASK;
  287. } else
  288. pio_irqmask = MCI_TXFIFOHALFEMPTYMASK;
  289. }
  290. if (data->flags & MMC_DATA_READ)
  291. datactrl |= MCI_DPSM_DIRECTION;
  292. writel(pio_irqmask, base + MMCIMASK1);
  293. writel(datactrl, base + MMCIDATACTRL);
  294. if (datactrl & MCI_DPSM_DMAENABLE) {
  295. host->dma.busy = 1;
  296. msm_dmov_enqueue_cmd(host->dma.channel, &host->dma.hdr);
  297. }
  298. }
  299. static void
  300. msmsdcc_start_command(struct msmsdcc_host *host, struct mmc_command *cmd, u32 c)
  301. {
  302. void __iomem *base = host->base;
  303. if (readl(base + MMCICOMMAND) & MCI_CPSM_ENABLE) {
  304. writel(0, base + MMCICOMMAND);
  305. udelay(2 + ((5 * 1000000) / host->clk_rate));
  306. }
  307. c |= cmd->opcode | MCI_CPSM_ENABLE;
  308. if (cmd->flags & MMC_RSP_PRESENT) {
  309. if (cmd->flags & MMC_RSP_136)
  310. c |= MCI_CPSM_LONGRSP;
  311. c |= MCI_CPSM_RESPONSE;
  312. }
  313. if (cmd->opcode == 17 || cmd->opcode == 18 ||
  314. cmd->opcode == 24 || cmd->opcode == 25 ||
  315. cmd->opcode == 53)
  316. c |= MCI_CSPM_DATCMD;
  317. if (cmd == cmd->mrq->stop)
  318. c |= MCI_CSPM_MCIABORT;
  319. host->curr.cmd = cmd;
  320. host->stats.cmds++;
  321. writel(cmd->arg, base + MMCIARGUMENT);
  322. writel(c, base + MMCICOMMAND);
  323. }
  324. static void
  325. msmsdcc_data_err(struct msmsdcc_host *host, struct mmc_data *data,
  326. unsigned int status)
  327. {
  328. if (status & MCI_DATACRCFAIL) {
  329. pr_err("%s: Data CRC error\n", mmc_hostname(host->mmc));
  330. pr_err("%s: opcode 0x%.8x\n", __func__,
  331. data->mrq->cmd->opcode);
  332. pr_err("%s: blksz %d, blocks %d\n", __func__,
  333. data->blksz, data->blocks);
  334. data->error = -EILSEQ;
  335. } else if (status & MCI_DATATIMEOUT) {
  336. pr_err("%s: Data timeout\n", mmc_hostname(host->mmc));
  337. data->error = -ETIMEDOUT;
  338. } else if (status & MCI_RXOVERRUN) {
  339. pr_err("%s: RX overrun\n", mmc_hostname(host->mmc));
  340. data->error = -EIO;
  341. } else if (status & MCI_TXUNDERRUN) {
  342. pr_err("%s: TX underrun\n", mmc_hostname(host->mmc));
  343. data->error = -EIO;
  344. } else {
  345. pr_err("%s: Unknown error (0x%.8x)\n",
  346. mmc_hostname(host->mmc), status);
  347. data->error = -EIO;
  348. }
  349. }
  350. static int
  351. msmsdcc_pio_read(struct msmsdcc_host *host, char *buffer, unsigned int remain)
  352. {
  353. void __iomem *base = host->base;
  354. uint32_t *ptr = (uint32_t *) buffer;
  355. int count = 0;
  356. while (readl(base + MMCISTATUS) & MCI_RXDATAAVLBL) {
  357. *ptr = readl(base + MMCIFIFO + (count % MCI_FIFOSIZE));
  358. ptr++;
  359. count += sizeof(uint32_t);
  360. remain -= sizeof(uint32_t);
  361. if (remain == 0)
  362. break;
  363. }
  364. return count;
  365. }
  366. static int
  367. msmsdcc_pio_write(struct msmsdcc_host *host, char *buffer,
  368. unsigned int remain, u32 status)
  369. {
  370. void __iomem *base = host->base;
  371. char *ptr = buffer;
  372. do {
  373. unsigned int count, maxcnt;
  374. maxcnt = status & MCI_TXFIFOEMPTY ? MCI_FIFOSIZE :
  375. MCI_FIFOHALFSIZE;
  376. count = min(remain, maxcnt);
  377. writesl(base + MMCIFIFO, ptr, count >> 2);
  378. ptr += count;
  379. remain -= count;
  380. if (remain == 0)
  381. break;
  382. status = readl(base + MMCISTATUS);
  383. } while (status & MCI_TXFIFOHALFEMPTY);
  384. return ptr - buffer;
  385. }
  386. static int
  387. msmsdcc_spin_on_status(struct msmsdcc_host *host, uint32_t mask, int maxspin)
  388. {
  389. while (maxspin) {
  390. if ((readl(host->base + MMCISTATUS) & mask))
  391. return 0;
  392. udelay(1);
  393. --maxspin;
  394. }
  395. return -ETIMEDOUT;
  396. }
  397. static int
  398. msmsdcc_pio_irq(int irq, void *dev_id)
  399. {
  400. struct msmsdcc_host *host = dev_id;
  401. void __iomem *base = host->base;
  402. uint32_t status;
  403. status = readl(base + MMCISTATUS);
  404. do {
  405. unsigned long flags;
  406. unsigned int remain, len;
  407. char *buffer;
  408. if (!(status & (MCI_TXFIFOHALFEMPTY | MCI_RXDATAAVLBL))) {
  409. if (host->curr.xfer_remain == 0 || !msmsdcc_piopoll)
  410. break;
  411. if (msmsdcc_spin_on_status(host,
  412. (MCI_TXFIFOHALFEMPTY |
  413. MCI_RXDATAAVLBL),
  414. PIO_SPINMAX)) {
  415. break;
  416. }
  417. }
  418. /* Map the current scatter buffer */
  419. local_irq_save(flags);
  420. buffer = kmap_atomic(sg_page(host->pio.sg),
  421. KM_BIO_SRC_IRQ) + host->pio.sg->offset;
  422. buffer += host->pio.sg_off;
  423. remain = host->pio.sg->length - host->pio.sg_off;
  424. len = 0;
  425. if (status & MCI_RXACTIVE)
  426. len = msmsdcc_pio_read(host, buffer, remain);
  427. if (status & MCI_TXACTIVE)
  428. len = msmsdcc_pio_write(host, buffer, remain, status);
  429. /* Unmap the buffer */
  430. kunmap_atomic(buffer, KM_BIO_SRC_IRQ);
  431. local_irq_restore(flags);
  432. host->pio.sg_off += len;
  433. host->curr.xfer_remain -= len;
  434. host->curr.data_xfered += len;
  435. remain -= len;
  436. if (remain == 0) {
  437. /* This sg page is full - do some housekeeping */
  438. if (status & MCI_RXACTIVE && host->curr.user_pages)
  439. flush_dcache_page(sg_page(host->pio.sg));
  440. if (!--host->pio.sg_len) {
  441. memset(&host->pio, 0, sizeof(host->pio));
  442. break;
  443. }
  444. /* Advance to next sg */
  445. host->pio.sg++;
  446. host->pio.sg_off = 0;
  447. }
  448. status = readl(base + MMCISTATUS);
  449. } while (1);
  450. if (status & MCI_RXACTIVE && host->curr.xfer_remain < MCI_FIFOSIZE)
  451. writel(MCI_RXDATAAVLBLMASK, base + MMCIMASK1);
  452. if (!host->curr.xfer_remain)
  453. writel(0, base + MMCIMASK1);
  454. return IRQ_HANDLED;
  455. }
  456. static void msmsdcc_do_cmdirq(struct msmsdcc_host *host, uint32_t status)
  457. {
  458. struct mmc_command *cmd = host->curr.cmd;
  459. void __iomem *base = host->base;
  460. host->curr.cmd = NULL;
  461. cmd->resp[0] = readl(base + MMCIRESPONSE0);
  462. cmd->resp[1] = readl(base + MMCIRESPONSE1);
  463. cmd->resp[2] = readl(base + MMCIRESPONSE2);
  464. cmd->resp[3] = readl(base + MMCIRESPONSE3);
  465. del_timer(&host->command_timer);
  466. if (status & MCI_CMDTIMEOUT) {
  467. cmd->error = -ETIMEDOUT;
  468. } else if (status & MCI_CMDCRCFAIL &&
  469. cmd->flags & MMC_RSP_CRC) {
  470. pr_err("%s: Command CRC error\n", mmc_hostname(host->mmc));
  471. cmd->error = -EILSEQ;
  472. }
  473. if (!cmd->data || cmd->error) {
  474. if (host->curr.data && host->dma.sg)
  475. msm_dmov_stop_cmd(host->dma.channel,
  476. &host->dma.hdr, 0);
  477. else if (host->curr.data) { /* Non DMA */
  478. msmsdcc_stop_data(host);
  479. msmsdcc_request_end(host, cmd->mrq);
  480. } else /* host->data == NULL */
  481. msmsdcc_request_end(host, cmd->mrq);
  482. } else if (!(cmd->data->flags & MMC_DATA_READ))
  483. msmsdcc_start_data(host, cmd->data);
  484. }
  485. static void
  486. msmsdcc_handle_irq_data(struct msmsdcc_host *host, u32 status,
  487. void __iomem *base)
  488. {
  489. struct mmc_data *data = host->curr.data;
  490. if (!data)
  491. return;
  492. /* Check for data errors */
  493. if (status & (MCI_DATACRCFAIL | MCI_DATATIMEOUT |
  494. MCI_TXUNDERRUN | MCI_RXOVERRUN)) {
  495. msmsdcc_data_err(host, data, status);
  496. host->curr.data_xfered = 0;
  497. if (host->dma.sg)
  498. msm_dmov_stop_cmd(host->dma.channel,
  499. &host->dma.hdr, 0);
  500. else {
  501. msmsdcc_stop_data(host);
  502. if (!data->stop)
  503. msmsdcc_request_end(host, data->mrq);
  504. else
  505. msmsdcc_start_command(host, data->stop, 0);
  506. }
  507. }
  508. /* Check for data done */
  509. if (!host->curr.got_dataend && (status & MCI_DATAEND))
  510. host->curr.got_dataend = 1;
  511. if (!host->curr.got_datablkend && (status & MCI_DATABLOCKEND))
  512. host->curr.got_datablkend = 1;
  513. /*
  514. * If DMA is still in progress, we complete via the completion handler
  515. */
  516. if (host->curr.got_dataend && host->curr.got_datablkend &&
  517. !host->dma.busy) {
  518. /*
  519. * There appears to be an issue in the controller where
  520. * if you request a small block transfer (< fifo size),
  521. * you may get your DATAEND/DATABLKEND irq without the
  522. * PIO data irq.
  523. *
  524. * Check to see if there is still data to be read,
  525. * and simulate a PIO irq.
  526. */
  527. if (readl(base + MMCISTATUS) & MCI_RXDATAAVLBL)
  528. msmsdcc_pio_irq(1, host);
  529. msmsdcc_stop_data(host);
  530. if (!data->error)
  531. host->curr.data_xfered = host->curr.xfer_size;
  532. if (!data->stop)
  533. msmsdcc_request_end(host, data->mrq);
  534. else
  535. msmsdcc_start_command(host, data->stop, 0);
  536. }
  537. }
  538. static irqreturn_t
  539. msmsdcc_irq(int irq, void *dev_id)
  540. {
  541. struct msmsdcc_host *host = dev_id;
  542. void __iomem *base = host->base;
  543. u32 status;
  544. int ret = 0;
  545. int cardint = 0;
  546. spin_lock(&host->lock);
  547. do {
  548. status = readl(base + MMCISTATUS);
  549. status &= (readl(base + MMCIMASK0) | MCI_DATABLOCKENDMASK);
  550. writel(status, base + MMCICLEAR);
  551. msmsdcc_handle_irq_data(host, status, base);
  552. if (status & (MCI_CMDSENT | MCI_CMDRESPEND | MCI_CMDCRCFAIL |
  553. MCI_CMDTIMEOUT) && host->curr.cmd) {
  554. msmsdcc_do_cmdirq(host, status);
  555. }
  556. if (status & MCI_SDIOINTOPER) {
  557. cardint = 1;
  558. status &= ~MCI_SDIOINTOPER;
  559. }
  560. ret = 1;
  561. } while (status);
  562. spin_unlock(&host->lock);
  563. /*
  564. * We have to delay handling the card interrupt as it calls
  565. * back into the driver.
  566. */
  567. if (cardint)
  568. mmc_signal_sdio_irq(host->mmc);
  569. return IRQ_RETVAL(ret);
  570. }
  571. static void
  572. msmsdcc_request(struct mmc_host *mmc, struct mmc_request *mrq)
  573. {
  574. struct msmsdcc_host *host = mmc_priv(mmc);
  575. unsigned long flags;
  576. WARN_ON(host->curr.mrq != NULL);
  577. WARN_ON(host->pwr == 0);
  578. spin_lock_irqsave(&host->lock, flags);
  579. host->stats.reqs++;
  580. if (host->eject) {
  581. if (mrq->data && !(mrq->data->flags & MMC_DATA_READ)) {
  582. mrq->cmd->error = 0;
  583. mrq->data->bytes_xfered = mrq->data->blksz *
  584. mrq->data->blocks;
  585. } else
  586. mrq->cmd->error = -ENOMEDIUM;
  587. spin_unlock_irqrestore(&host->lock, flags);
  588. mmc_request_done(mmc, mrq);
  589. return;
  590. }
  591. host->curr.mrq = mrq;
  592. if (mrq->data && mrq->data->flags & MMC_DATA_READ)
  593. msmsdcc_start_data(host, mrq->data);
  594. msmsdcc_start_command(host, mrq->cmd, 0);
  595. if (host->cmdpoll && !msmsdcc_spin_on_status(host,
  596. MCI_CMDRESPEND|MCI_CMDCRCFAIL|MCI_CMDTIMEOUT,
  597. CMD_SPINMAX)) {
  598. uint32_t status = readl(host->base + MMCISTATUS);
  599. msmsdcc_do_cmdirq(host, status);
  600. writel(MCI_CMDRESPEND | MCI_CMDCRCFAIL | MCI_CMDTIMEOUT,
  601. host->base + MMCICLEAR);
  602. host->stats.cmdpoll_hits++;
  603. } else {
  604. host->stats.cmdpoll_misses++;
  605. mod_timer(&host->command_timer, jiffies + HZ);
  606. }
  607. spin_unlock_irqrestore(&host->lock, flags);
  608. }
  609. static void
  610. msmsdcc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
  611. {
  612. struct msmsdcc_host *host = mmc_priv(mmc);
  613. u32 clk = 0, pwr = 0;
  614. int rc;
  615. if (ios->clock) {
  616. if (!host->clks_on) {
  617. clk_enable(host->pclk);
  618. clk_enable(host->clk);
  619. host->clks_on = 1;
  620. }
  621. if (ios->clock != host->clk_rate) {
  622. rc = clk_set_rate(host->clk, ios->clock);
  623. if (rc < 0)
  624. pr_err("%s: Error setting clock rate (%d)\n",
  625. mmc_hostname(host->mmc), rc);
  626. else
  627. host->clk_rate = ios->clock;
  628. }
  629. clk |= MCI_CLK_ENABLE;
  630. }
  631. if (ios->bus_width == MMC_BUS_WIDTH_4)
  632. clk |= (2 << 10); /* Set WIDEBUS */
  633. if (ios->clock > 400000 && msmsdcc_pwrsave)
  634. clk |= (1 << 9); /* PWRSAVE */
  635. clk |= (1 << 12); /* FLOW_ENA */
  636. clk |= (1 << 15); /* feedback clock */
  637. if (host->plat->translate_vdd)
  638. pwr |= host->plat->translate_vdd(mmc_dev(mmc), ios->vdd);
  639. switch (ios->power_mode) {
  640. case MMC_POWER_OFF:
  641. break;
  642. case MMC_POWER_UP:
  643. pwr |= MCI_PWR_UP;
  644. break;
  645. case MMC_POWER_ON:
  646. pwr |= MCI_PWR_ON;
  647. break;
  648. }
  649. if (ios->bus_mode == MMC_BUSMODE_OPENDRAIN)
  650. pwr |= MCI_OD;
  651. writel(clk, host->base + MMCICLOCK);
  652. if (host->pwr != pwr) {
  653. host->pwr = pwr;
  654. writel(pwr, host->base + MMCIPOWER);
  655. }
  656. if (!(clk & MCI_CLK_ENABLE) && host->clks_on) {
  657. clk_disable(host->clk);
  658. clk_disable(host->pclk);
  659. host->clks_on = 0;
  660. }
  661. }
  662. static void msmsdcc_enable_sdio_irq(struct mmc_host *mmc, int enable)
  663. {
  664. struct msmsdcc_host *host = mmc_priv(mmc);
  665. unsigned long flags;
  666. u32 status;
  667. spin_lock_irqsave(&host->lock, flags);
  668. if (msmsdcc_sdioirq == 1) {
  669. status = readl(host->base + MMCIMASK0);
  670. if (enable)
  671. status |= MCI_SDIOINTOPERMASK;
  672. else
  673. status &= ~MCI_SDIOINTOPERMASK;
  674. host->saved_irq0mask = status;
  675. writel(status, host->base + MMCIMASK0);
  676. }
  677. spin_unlock_irqrestore(&host->lock, flags);
  678. }
  679. static const struct mmc_host_ops msmsdcc_ops = {
  680. .request = msmsdcc_request,
  681. .set_ios = msmsdcc_set_ios,
  682. .enable_sdio_irq = msmsdcc_enable_sdio_irq,
  683. };
  684. static void
  685. msmsdcc_check_status(unsigned long data)
  686. {
  687. struct msmsdcc_host *host = (struct msmsdcc_host *)data;
  688. unsigned int status;
  689. if (!host->plat->status) {
  690. mmc_detect_change(host->mmc, 0);
  691. goto out;
  692. }
  693. status = host->plat->status(mmc_dev(host->mmc));
  694. host->eject = !status;
  695. if (status ^ host->oldstat) {
  696. pr_info("%s: Slot status change detected (%d -> %d)\n",
  697. mmc_hostname(host->mmc), host->oldstat, status);
  698. if (status)
  699. mmc_detect_change(host->mmc, (5 * HZ) / 2);
  700. else
  701. mmc_detect_change(host->mmc, 0);
  702. }
  703. host->oldstat = status;
  704. out:
  705. if (host->timer.function)
  706. mod_timer(&host->timer, jiffies + HZ);
  707. }
  708. static irqreturn_t
  709. msmsdcc_platform_status_irq(int irq, void *dev_id)
  710. {
  711. struct msmsdcc_host *host = dev_id;
  712. printk(KERN_DEBUG "%s: %d\n", __func__, irq);
  713. msmsdcc_check_status((unsigned long) host);
  714. return IRQ_HANDLED;
  715. }
  716. static void
  717. msmsdcc_status_notify_cb(int card_present, void *dev_id)
  718. {
  719. struct msmsdcc_host *host = dev_id;
  720. printk(KERN_DEBUG "%s: card_present %d\n", mmc_hostname(host->mmc),
  721. card_present);
  722. msmsdcc_check_status((unsigned long) host);
  723. }
  724. /*
  725. * called when a command expires.
  726. * Dump some debugging, and then error
  727. * out the transaction.
  728. */
  729. static void
  730. msmsdcc_command_expired(unsigned long _data)
  731. {
  732. struct msmsdcc_host *host = (struct msmsdcc_host *) _data;
  733. struct mmc_request *mrq;
  734. unsigned long flags;
  735. spin_lock_irqsave(&host->lock, flags);
  736. mrq = host->curr.mrq;
  737. if (!mrq) {
  738. pr_info("%s: Command expiry misfire\n",
  739. mmc_hostname(host->mmc));
  740. spin_unlock_irqrestore(&host->lock, flags);
  741. return;
  742. }
  743. pr_err("%s: Command timeout (%p %p %p %p)\n",
  744. mmc_hostname(host->mmc), mrq, mrq->cmd,
  745. mrq->data, host->dma.sg);
  746. mrq->cmd->error = -ETIMEDOUT;
  747. msmsdcc_stop_data(host);
  748. writel(0, host->base + MMCICOMMAND);
  749. host->curr.mrq = NULL;
  750. host->curr.cmd = NULL;
  751. spin_unlock_irqrestore(&host->lock, flags);
  752. mmc_request_done(host->mmc, mrq);
  753. }
  754. static int
  755. msmsdcc_init_dma(struct msmsdcc_host *host)
  756. {
  757. memset(&host->dma, 0, sizeof(struct msmsdcc_dma_data));
  758. host->dma.host = host;
  759. host->dma.channel = -1;
  760. if (!host->dmares)
  761. return -ENODEV;
  762. host->dma.nc = dma_alloc_coherent(NULL,
  763. sizeof(struct msmsdcc_nc_dmadata),
  764. &host->dma.nc_busaddr,
  765. GFP_KERNEL);
  766. if (host->dma.nc == NULL) {
  767. pr_err("Unable to allocate DMA buffer\n");
  768. return -ENOMEM;
  769. }
  770. memset(host->dma.nc, 0x00, sizeof(struct msmsdcc_nc_dmadata));
  771. host->dma.cmd_busaddr = host->dma.nc_busaddr;
  772. host->dma.cmdptr_busaddr = host->dma.nc_busaddr +
  773. offsetof(struct msmsdcc_nc_dmadata, cmdptr);
  774. host->dma.channel = host->dmares->start;
  775. return 0;
  776. }
  777. #ifdef CONFIG_MMC_MSM7X00A_RESUME_IN_WQ
  778. static void
  779. do_resume_work(struct work_struct *work)
  780. {
  781. struct msmsdcc_host *host =
  782. container_of(work, struct msmsdcc_host, resume_task);
  783. struct mmc_host *mmc = host->mmc;
  784. if (mmc) {
  785. mmc_resume_host(mmc);
  786. if (host->stat_irq)
  787. enable_irq(host->stat_irq);
  788. }
  789. }
  790. #endif
  791. static int
  792. msmsdcc_probe(struct platform_device *pdev)
  793. {
  794. struct mmc_platform_data *plat = pdev->dev.platform_data;
  795. struct msmsdcc_host *host;
  796. struct mmc_host *mmc;
  797. struct resource *cmd_irqres = NULL;
  798. struct resource *pio_irqres = NULL;
  799. struct resource *stat_irqres = NULL;
  800. struct resource *memres = NULL;
  801. struct resource *dmares = NULL;
  802. int ret;
  803. /* must have platform data */
  804. if (!plat) {
  805. pr_err("%s: Platform data not available\n", __func__);
  806. ret = -EINVAL;
  807. goto out;
  808. }
  809. if (pdev->id < 1 || pdev->id > 4)
  810. return -EINVAL;
  811. if (pdev->resource == NULL || pdev->num_resources < 2) {
  812. pr_err("%s: Invalid resource\n", __func__);
  813. return -ENXIO;
  814. }
  815. memres = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  816. dmares = platform_get_resource(pdev, IORESOURCE_DMA, 0);
  817. cmd_irqres = platform_get_resource_byname(pdev, IORESOURCE_IRQ,
  818. "cmd_irq");
  819. pio_irqres = platform_get_resource_byname(pdev, IORESOURCE_IRQ,
  820. "pio_irq");
  821. stat_irqres = platform_get_resource_byname(pdev, IORESOURCE_IRQ,
  822. "status_irq");
  823. if (!cmd_irqres || !pio_irqres || !memres) {
  824. pr_err("%s: Invalid resource\n", __func__);
  825. return -ENXIO;
  826. }
  827. /*
  828. * Setup our host structure
  829. */
  830. mmc = mmc_alloc_host(sizeof(struct msmsdcc_host), &pdev->dev);
  831. if (!mmc) {
  832. ret = -ENOMEM;
  833. goto out;
  834. }
  835. host = mmc_priv(mmc);
  836. host->pdev_id = pdev->id;
  837. host->plat = plat;
  838. host->mmc = mmc;
  839. host->cmdpoll = 1;
  840. host->base = ioremap(memres->start, PAGE_SIZE);
  841. if (!host->base) {
  842. ret = -ENOMEM;
  843. goto out;
  844. }
  845. host->cmd_irqres = cmd_irqres;
  846. host->pio_irqres = pio_irqres;
  847. host->memres = memres;
  848. host->dmares = dmares;
  849. spin_lock_init(&host->lock);
  850. /*
  851. * Setup DMA
  852. */
  853. msmsdcc_init_dma(host);
  854. /*
  855. * Setup main peripheral bus clock
  856. */
  857. host->pclk = clk_get(&pdev->dev, "sdc_pclk");
  858. if (IS_ERR(host->pclk)) {
  859. ret = PTR_ERR(host->pclk);
  860. goto host_free;
  861. }
  862. ret = clk_enable(host->pclk);
  863. if (ret)
  864. goto pclk_put;
  865. host->pclk_rate = clk_get_rate(host->pclk);
  866. /*
  867. * Setup SDC MMC clock
  868. */
  869. host->clk = clk_get(&pdev->dev, "sdc_clk");
  870. if (IS_ERR(host->clk)) {
  871. ret = PTR_ERR(host->clk);
  872. goto pclk_disable;
  873. }
  874. ret = clk_enable(host->clk);
  875. if (ret)
  876. goto clk_put;
  877. ret = clk_set_rate(host->clk, msmsdcc_fmin);
  878. if (ret) {
  879. pr_err("%s: Clock rate set failed (%d)\n", __func__, ret);
  880. goto clk_disable;
  881. }
  882. host->clk_rate = clk_get_rate(host->clk);
  883. host->clks_on = 1;
  884. /*
  885. * Setup MMC host structure
  886. */
  887. mmc->ops = &msmsdcc_ops;
  888. mmc->f_min = msmsdcc_fmin;
  889. mmc->f_max = msmsdcc_fmax;
  890. mmc->ocr_avail = plat->ocr_mask;
  891. if (msmsdcc_4bit)
  892. mmc->caps |= MMC_CAP_4_BIT_DATA;
  893. if (msmsdcc_sdioirq)
  894. mmc->caps |= MMC_CAP_SDIO_IRQ;
  895. mmc->caps |= MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED;
  896. mmc->max_phys_segs = NR_SG;
  897. mmc->max_hw_segs = NR_SG;
  898. mmc->max_blk_size = 4096; /* MCI_DATA_CTL BLOCKSIZE up to 4096 */
  899. mmc->max_blk_count = 65536;
  900. mmc->max_req_size = 33554432; /* MCI_DATA_LENGTH is 25 bits */
  901. mmc->max_seg_size = mmc->max_req_size;
  902. writel(0, host->base + MMCIMASK0);
  903. writel(0x5e007ff, host->base + MMCICLEAR); /* Add: 1 << 25 */
  904. writel(MCI_IRQENABLE, host->base + MMCIMASK0);
  905. host->saved_irq0mask = MCI_IRQENABLE;
  906. /*
  907. * Setup card detect change
  908. */
  909. memset(&host->timer, 0, sizeof(host->timer));
  910. if (stat_irqres && !(stat_irqres->flags & IORESOURCE_DISABLED)) {
  911. unsigned long irqflags = IRQF_SHARED |
  912. (stat_irqres->flags & IRQF_TRIGGER_MASK);
  913. host->stat_irq = stat_irqres->start;
  914. ret = request_irq(host->stat_irq,
  915. msmsdcc_platform_status_irq,
  916. irqflags,
  917. DRIVER_NAME " (slot)",
  918. host);
  919. if (ret) {
  920. pr_err("%s: Unable to get slot IRQ %d (%d)\n",
  921. mmc_hostname(mmc), host->stat_irq, ret);
  922. goto clk_disable;
  923. }
  924. } else if (plat->register_status_notify) {
  925. plat->register_status_notify(msmsdcc_status_notify_cb, host);
  926. } else if (!plat->status)
  927. pr_err("%s: No card detect facilities available\n",
  928. mmc_hostname(mmc));
  929. else {
  930. init_timer(&host->timer);
  931. host->timer.data = (unsigned long)host;
  932. host->timer.function = msmsdcc_check_status;
  933. host->timer.expires = jiffies + HZ;
  934. add_timer(&host->timer);
  935. }
  936. if (plat->status) {
  937. host->oldstat = host->plat->status(mmc_dev(host->mmc));
  938. host->eject = !host->oldstat;
  939. }
  940. /*
  941. * Setup a command timer. We currently need this due to
  942. * some 'strange' timeout / error handling situations.
  943. */
  944. init_timer(&host->command_timer);
  945. host->command_timer.data = (unsigned long) host;
  946. host->command_timer.function = msmsdcc_command_expired;
  947. ret = request_irq(cmd_irqres->start, msmsdcc_irq, IRQF_SHARED,
  948. DRIVER_NAME " (cmd)", host);
  949. if (ret)
  950. goto stat_irq_free;
  951. ret = request_irq(pio_irqres->start, msmsdcc_pio_irq, IRQF_SHARED,
  952. DRIVER_NAME " (pio)", host);
  953. if (ret)
  954. goto cmd_irq_free;
  955. mmc_set_drvdata(pdev, mmc);
  956. mmc_add_host(mmc);
  957. pr_info("%s: Qualcomm MSM SDCC at 0x%016llx irq %d,%d dma %d\n",
  958. mmc_hostname(mmc), (unsigned long long)memres->start,
  959. (unsigned int) cmd_irqres->start,
  960. (unsigned int) host->stat_irq, host->dma.channel);
  961. pr_info("%s: 4 bit data mode %s\n", mmc_hostname(mmc),
  962. (mmc->caps & MMC_CAP_4_BIT_DATA ? "enabled" : "disabled"));
  963. pr_info("%s: MMC clock %u -> %u Hz, PCLK %u Hz\n",
  964. mmc_hostname(mmc), msmsdcc_fmin, msmsdcc_fmax, host->pclk_rate);
  965. pr_info("%s: Slot eject status = %d\n", mmc_hostname(mmc), host->eject);
  966. pr_info("%s: Power save feature enable = %d\n",
  967. mmc_hostname(mmc), msmsdcc_pwrsave);
  968. if (host->dma.channel != -1) {
  969. pr_info("%s: DM non-cached buffer at %p, dma_addr 0x%.8x\n",
  970. mmc_hostname(mmc), host->dma.nc, host->dma.nc_busaddr);
  971. pr_info("%s: DM cmd busaddr 0x%.8x, cmdptr busaddr 0x%.8x\n",
  972. mmc_hostname(mmc), host->dma.cmd_busaddr,
  973. host->dma.cmdptr_busaddr);
  974. } else
  975. pr_info("%s: PIO transfer enabled\n", mmc_hostname(mmc));
  976. if (host->timer.function)
  977. pr_info("%s: Polling status mode enabled\n", mmc_hostname(mmc));
  978. return 0;
  979. cmd_irq_free:
  980. free_irq(cmd_irqres->start, host);
  981. stat_irq_free:
  982. if (host->stat_irq)
  983. free_irq(host->stat_irq, host);
  984. clk_disable:
  985. clk_disable(host->clk);
  986. clk_put:
  987. clk_put(host->clk);
  988. pclk_disable:
  989. clk_disable(host->pclk);
  990. pclk_put:
  991. clk_put(host->pclk);
  992. host_free:
  993. mmc_free_host(mmc);
  994. out:
  995. return ret;
  996. }
  997. static int
  998. msmsdcc_suspend(struct platform_device *dev, pm_message_t state)
  999. {
  1000. struct mmc_host *mmc = mmc_get_drvdata(dev);
  1001. int rc = 0;
  1002. if (mmc) {
  1003. struct msmsdcc_host *host = mmc_priv(mmc);
  1004. if (host->stat_irq)
  1005. disable_irq(host->stat_irq);
  1006. if (mmc->card && mmc->card->type != MMC_TYPE_SDIO)
  1007. rc = mmc_suspend_host(mmc, state);
  1008. if (!rc) {
  1009. writel(0, host->base + MMCIMASK0);
  1010. if (host->clks_on) {
  1011. clk_disable(host->clk);
  1012. clk_disable(host->pclk);
  1013. host->clks_on = 0;
  1014. }
  1015. }
  1016. }
  1017. return rc;
  1018. }
  1019. static int
  1020. msmsdcc_resume(struct platform_device *dev)
  1021. {
  1022. struct mmc_host *mmc = mmc_get_drvdata(dev);
  1023. unsigned long flags;
  1024. if (mmc) {
  1025. struct msmsdcc_host *host = mmc_priv(mmc);
  1026. spin_lock_irqsave(&host->lock, flags);
  1027. if (!host->clks_on) {
  1028. clk_enable(host->pclk);
  1029. clk_enable(host->clk);
  1030. host->clks_on = 1;
  1031. }
  1032. writel(host->saved_irq0mask, host->base + MMCIMASK0);
  1033. spin_unlock_irqrestore(&host->lock, flags);
  1034. if (mmc->card && mmc->card->type != MMC_TYPE_SDIO)
  1035. mmc_resume_host(mmc);
  1036. if (host->stat_irq)
  1037. enable_irq(host->stat_irq);
  1038. }
  1039. return 0;
  1040. }
  1041. static struct platform_driver msmsdcc_driver = {
  1042. .probe = msmsdcc_probe,
  1043. .suspend = msmsdcc_suspend,
  1044. .resume = msmsdcc_resume,
  1045. .driver = {
  1046. .name = "msm_sdcc",
  1047. },
  1048. };
  1049. static int __init msmsdcc_init(void)
  1050. {
  1051. return platform_driver_register(&msmsdcc_driver);
  1052. }
  1053. static void __exit msmsdcc_exit(void)
  1054. {
  1055. platform_driver_unregister(&msmsdcc_driver);
  1056. }
  1057. module_init(msmsdcc_init);
  1058. module_exit(msmsdcc_exit);
  1059. MODULE_DESCRIPTION("Qualcomm MSM 7X00A Multimedia Card Interface driver");
  1060. MODULE_LICENSE("GPL");