sdhci.c 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929
  1. /*
  2. * linux/drivers/mmc/host/sdhci.c - Secure Digital Host Controller Interface driver
  3. *
  4. * Copyright (C) 2005-2008 Pierre Ossman, All Rights Reserved.
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or (at
  9. * your option) any later version.
  10. *
  11. * Thanks to the following companies for their support:
  12. *
  13. * - JMicron (hardware and technical support)
  14. */
  15. #include <linux/delay.h>
  16. #include <linux/highmem.h>
  17. #include <linux/io.h>
  18. #include <linux/dma-mapping.h>
  19. #include <linux/scatterlist.h>
  20. #include <linux/leds.h>
  21. #include <linux/mmc/host.h>
  22. #include "sdhci.h"
  23. #define DRIVER_NAME "sdhci"
  24. #define DBG(f, x...) \
  25. pr_debug(DRIVER_NAME " [%s()]: " f, __func__,## x)
  26. #if defined(CONFIG_LEDS_CLASS) || (defined(CONFIG_LEDS_CLASS_MODULE) && \
  27. defined(CONFIG_MMC_SDHCI_MODULE))
  28. #define SDHCI_USE_LEDS_CLASS
  29. #endif
  30. static unsigned int debug_quirks = 0;
  31. static void sdhci_prepare_data(struct sdhci_host *, struct mmc_data *);
  32. static void sdhci_finish_data(struct sdhci_host *);
  33. static void sdhci_send_command(struct sdhci_host *, struct mmc_command *);
  34. static void sdhci_finish_command(struct sdhci_host *);
  35. static void sdhci_dumpregs(struct sdhci_host *host)
  36. {
  37. printk(KERN_DEBUG DRIVER_NAME ": ============== REGISTER DUMP ==============\n");
  38. printk(KERN_DEBUG DRIVER_NAME ": Sys addr: 0x%08x | Version: 0x%08x\n",
  39. sdhci_readl(host, SDHCI_DMA_ADDRESS),
  40. sdhci_readw(host, SDHCI_HOST_VERSION));
  41. printk(KERN_DEBUG DRIVER_NAME ": Blk size: 0x%08x | Blk cnt: 0x%08x\n",
  42. sdhci_readw(host, SDHCI_BLOCK_SIZE),
  43. sdhci_readw(host, SDHCI_BLOCK_COUNT));
  44. printk(KERN_DEBUG DRIVER_NAME ": Argument: 0x%08x | Trn mode: 0x%08x\n",
  45. sdhci_readl(host, SDHCI_ARGUMENT),
  46. sdhci_readw(host, SDHCI_TRANSFER_MODE));
  47. printk(KERN_DEBUG DRIVER_NAME ": Present: 0x%08x | Host ctl: 0x%08x\n",
  48. sdhci_readl(host, SDHCI_PRESENT_STATE),
  49. sdhci_readb(host, SDHCI_HOST_CONTROL));
  50. printk(KERN_DEBUG DRIVER_NAME ": Power: 0x%08x | Blk gap: 0x%08x\n",
  51. sdhci_readb(host, SDHCI_POWER_CONTROL),
  52. sdhci_readb(host, SDHCI_BLOCK_GAP_CONTROL));
  53. printk(KERN_DEBUG DRIVER_NAME ": Wake-up: 0x%08x | Clock: 0x%08x\n",
  54. sdhci_readb(host, SDHCI_WAKE_UP_CONTROL),
  55. sdhci_readw(host, SDHCI_CLOCK_CONTROL));
  56. printk(KERN_DEBUG DRIVER_NAME ": Timeout: 0x%08x | Int stat: 0x%08x\n",
  57. sdhci_readb(host, SDHCI_TIMEOUT_CONTROL),
  58. sdhci_readl(host, SDHCI_INT_STATUS));
  59. printk(KERN_DEBUG DRIVER_NAME ": Int enab: 0x%08x | Sig enab: 0x%08x\n",
  60. sdhci_readl(host, SDHCI_INT_ENABLE),
  61. sdhci_readl(host, SDHCI_SIGNAL_ENABLE));
  62. printk(KERN_DEBUG DRIVER_NAME ": AC12 err: 0x%08x | Slot int: 0x%08x\n",
  63. sdhci_readw(host, SDHCI_ACMD12_ERR),
  64. sdhci_readw(host, SDHCI_SLOT_INT_STATUS));
  65. printk(KERN_DEBUG DRIVER_NAME ": Caps: 0x%08x | Max curr: 0x%08x\n",
  66. sdhci_readl(host, SDHCI_CAPABILITIES),
  67. sdhci_readl(host, SDHCI_MAX_CURRENT));
  68. printk(KERN_DEBUG DRIVER_NAME ": ===========================================\n");
  69. }
  70. /*****************************************************************************\
  71. * *
  72. * Low level functions *
  73. * *
  74. \*****************************************************************************/
  75. static void sdhci_clear_set_irqs(struct sdhci_host *host, u32 clear, u32 set)
  76. {
  77. u32 ier;
  78. ier = sdhci_readl(host, SDHCI_INT_ENABLE);
  79. ier &= ~clear;
  80. ier |= set;
  81. sdhci_writel(host, ier, SDHCI_INT_ENABLE);
  82. sdhci_writel(host, ier, SDHCI_SIGNAL_ENABLE);
  83. }
  84. static void sdhci_unmask_irqs(struct sdhci_host *host, u32 irqs)
  85. {
  86. sdhci_clear_set_irqs(host, 0, irqs);
  87. }
  88. static void sdhci_mask_irqs(struct sdhci_host *host, u32 irqs)
  89. {
  90. sdhci_clear_set_irqs(host, irqs, 0);
  91. }
  92. static void sdhci_set_card_detection(struct sdhci_host *host, bool enable)
  93. {
  94. u32 irqs = SDHCI_INT_CARD_REMOVE | SDHCI_INT_CARD_INSERT;
  95. if (host->quirks & SDHCI_QUIRK_BROKEN_CARD_DETECTION)
  96. return;
  97. if (enable)
  98. sdhci_unmask_irqs(host, irqs);
  99. else
  100. sdhci_mask_irqs(host, irqs);
  101. }
  102. static void sdhci_enable_card_detection(struct sdhci_host *host)
  103. {
  104. sdhci_set_card_detection(host, true);
  105. }
  106. static void sdhci_disable_card_detection(struct sdhci_host *host)
  107. {
  108. sdhci_set_card_detection(host, false);
  109. }
  110. static void sdhci_reset(struct sdhci_host *host, u8 mask)
  111. {
  112. unsigned long timeout;
  113. if (host->quirks & SDHCI_QUIRK_NO_CARD_NO_RESET) {
  114. if (!(sdhci_readl(host, SDHCI_PRESENT_STATE) &
  115. SDHCI_CARD_PRESENT))
  116. return;
  117. }
  118. sdhci_writeb(host, mask, SDHCI_SOFTWARE_RESET);
  119. if (mask & SDHCI_RESET_ALL)
  120. host->clock = 0;
  121. /* Wait max 100 ms */
  122. timeout = 100;
  123. /* hw clears the bit when it's done */
  124. while (sdhci_readb(host, SDHCI_SOFTWARE_RESET) & mask) {
  125. if (timeout == 0) {
  126. printk(KERN_ERR "%s: Reset 0x%x never completed.\n",
  127. mmc_hostname(host->mmc), (int)mask);
  128. sdhci_dumpregs(host);
  129. return;
  130. }
  131. timeout--;
  132. mdelay(1);
  133. }
  134. }
  135. static void sdhci_init(struct sdhci_host *host)
  136. {
  137. sdhci_reset(host, SDHCI_RESET_ALL);
  138. sdhci_clear_set_irqs(host, SDHCI_INT_ALL_MASK,
  139. SDHCI_INT_BUS_POWER | SDHCI_INT_DATA_END_BIT |
  140. SDHCI_INT_DATA_CRC | SDHCI_INT_DATA_TIMEOUT | SDHCI_INT_INDEX |
  141. SDHCI_INT_END_BIT | SDHCI_INT_CRC | SDHCI_INT_TIMEOUT |
  142. SDHCI_INT_DATA_END | SDHCI_INT_RESPONSE);
  143. }
  144. static void sdhci_reinit(struct sdhci_host *host)
  145. {
  146. sdhci_init(host);
  147. sdhci_enable_card_detection(host);
  148. }
  149. static void sdhci_activate_led(struct sdhci_host *host)
  150. {
  151. u8 ctrl;
  152. ctrl = sdhci_readb(host, SDHCI_HOST_CONTROL);
  153. ctrl |= SDHCI_CTRL_LED;
  154. sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL);
  155. }
  156. static void sdhci_deactivate_led(struct sdhci_host *host)
  157. {
  158. u8 ctrl;
  159. ctrl = sdhci_readb(host, SDHCI_HOST_CONTROL);
  160. ctrl &= ~SDHCI_CTRL_LED;
  161. sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL);
  162. }
  163. #ifdef SDHCI_USE_LEDS_CLASS
  164. static void sdhci_led_control(struct led_classdev *led,
  165. enum led_brightness brightness)
  166. {
  167. struct sdhci_host *host = container_of(led, struct sdhci_host, led);
  168. unsigned long flags;
  169. spin_lock_irqsave(&host->lock, flags);
  170. if (brightness == LED_OFF)
  171. sdhci_deactivate_led(host);
  172. else
  173. sdhci_activate_led(host);
  174. spin_unlock_irqrestore(&host->lock, flags);
  175. }
  176. #endif
  177. /*****************************************************************************\
  178. * *
  179. * Core functions *
  180. * *
  181. \*****************************************************************************/
  182. static void sdhci_read_block_pio(struct sdhci_host *host)
  183. {
  184. unsigned long flags;
  185. size_t blksize, len, chunk;
  186. u32 uninitialized_var(scratch);
  187. u8 *buf;
  188. DBG("PIO reading\n");
  189. blksize = host->data->blksz;
  190. chunk = 0;
  191. local_irq_save(flags);
  192. while (blksize) {
  193. if (!sg_miter_next(&host->sg_miter))
  194. BUG();
  195. len = min(host->sg_miter.length, blksize);
  196. blksize -= len;
  197. host->sg_miter.consumed = len;
  198. buf = host->sg_miter.addr;
  199. while (len) {
  200. if (chunk == 0) {
  201. scratch = sdhci_readl(host, SDHCI_BUFFER);
  202. chunk = 4;
  203. }
  204. *buf = scratch & 0xFF;
  205. buf++;
  206. scratch >>= 8;
  207. chunk--;
  208. len--;
  209. }
  210. }
  211. sg_miter_stop(&host->sg_miter);
  212. local_irq_restore(flags);
  213. }
  214. static void sdhci_write_block_pio(struct sdhci_host *host)
  215. {
  216. unsigned long flags;
  217. size_t blksize, len, chunk;
  218. u32 scratch;
  219. u8 *buf;
  220. DBG("PIO writing\n");
  221. blksize = host->data->blksz;
  222. chunk = 0;
  223. scratch = 0;
  224. local_irq_save(flags);
  225. while (blksize) {
  226. if (!sg_miter_next(&host->sg_miter))
  227. BUG();
  228. len = min(host->sg_miter.length, blksize);
  229. blksize -= len;
  230. host->sg_miter.consumed = len;
  231. buf = host->sg_miter.addr;
  232. while (len) {
  233. scratch |= (u32)*buf << (chunk * 8);
  234. buf++;
  235. chunk++;
  236. len--;
  237. if ((chunk == 4) || ((len == 0) && (blksize == 0))) {
  238. sdhci_writel(host, scratch, SDHCI_BUFFER);
  239. chunk = 0;
  240. scratch = 0;
  241. }
  242. }
  243. }
  244. sg_miter_stop(&host->sg_miter);
  245. local_irq_restore(flags);
  246. }
  247. static void sdhci_transfer_pio(struct sdhci_host *host)
  248. {
  249. u32 mask;
  250. BUG_ON(!host->data);
  251. if (host->blocks == 0)
  252. return;
  253. if (host->data->flags & MMC_DATA_READ)
  254. mask = SDHCI_DATA_AVAILABLE;
  255. else
  256. mask = SDHCI_SPACE_AVAILABLE;
  257. /*
  258. * Some controllers (JMicron JMB38x) mess up the buffer bits
  259. * for transfers < 4 bytes. As long as it is just one block,
  260. * we can ignore the bits.
  261. */
  262. if ((host->quirks & SDHCI_QUIRK_BROKEN_SMALL_PIO) &&
  263. (host->data->blocks == 1))
  264. mask = ~0;
  265. while (sdhci_readl(host, SDHCI_PRESENT_STATE) & mask) {
  266. if (host->quirks & SDHCI_QUIRK_PIO_NEEDS_DELAY)
  267. udelay(100);
  268. if (host->data->flags & MMC_DATA_READ)
  269. sdhci_read_block_pio(host);
  270. else
  271. sdhci_write_block_pio(host);
  272. host->blocks--;
  273. if (host->blocks == 0)
  274. break;
  275. }
  276. DBG("PIO transfer complete.\n");
  277. }
  278. static char *sdhci_kmap_atomic(struct scatterlist *sg, unsigned long *flags)
  279. {
  280. local_irq_save(*flags);
  281. return kmap_atomic(sg_page(sg), KM_BIO_SRC_IRQ) + sg->offset;
  282. }
  283. static void sdhci_kunmap_atomic(void *buffer, unsigned long *flags)
  284. {
  285. kunmap_atomic(buffer, KM_BIO_SRC_IRQ);
  286. local_irq_restore(*flags);
  287. }
  288. static int sdhci_adma_table_pre(struct sdhci_host *host,
  289. struct mmc_data *data)
  290. {
  291. int direction;
  292. u8 *desc;
  293. u8 *align;
  294. dma_addr_t addr;
  295. dma_addr_t align_addr;
  296. int len, offset;
  297. struct scatterlist *sg;
  298. int i;
  299. char *buffer;
  300. unsigned long flags;
  301. /*
  302. * The spec does not specify endianness of descriptor table.
  303. * We currently guess that it is LE.
  304. */
  305. if (data->flags & MMC_DATA_READ)
  306. direction = DMA_FROM_DEVICE;
  307. else
  308. direction = DMA_TO_DEVICE;
  309. /*
  310. * The ADMA descriptor table is mapped further down as we
  311. * need to fill it with data first.
  312. */
  313. host->align_addr = dma_map_single(mmc_dev(host->mmc),
  314. host->align_buffer, 128 * 4, direction);
  315. if (dma_mapping_error(mmc_dev(host->mmc), host->align_addr))
  316. goto fail;
  317. BUG_ON(host->align_addr & 0x3);
  318. host->sg_count = dma_map_sg(mmc_dev(host->mmc),
  319. data->sg, data->sg_len, direction);
  320. if (host->sg_count == 0)
  321. goto unmap_align;
  322. desc = host->adma_desc;
  323. align = host->align_buffer;
  324. align_addr = host->align_addr;
  325. for_each_sg(data->sg, sg, host->sg_count, i) {
  326. addr = sg_dma_address(sg);
  327. len = sg_dma_len(sg);
  328. /*
  329. * The SDHCI specification states that ADMA
  330. * addresses must be 32-bit aligned. If they
  331. * aren't, then we use a bounce buffer for
  332. * the (up to three) bytes that screw up the
  333. * alignment.
  334. */
  335. offset = (4 - (addr & 0x3)) & 0x3;
  336. if (offset) {
  337. if (data->flags & MMC_DATA_WRITE) {
  338. buffer = sdhci_kmap_atomic(sg, &flags);
  339. WARN_ON(((long)buffer & PAGE_MASK) > (PAGE_SIZE - 3));
  340. memcpy(align, buffer, offset);
  341. sdhci_kunmap_atomic(buffer, &flags);
  342. }
  343. desc[7] = (align_addr >> 24) & 0xff;
  344. desc[6] = (align_addr >> 16) & 0xff;
  345. desc[5] = (align_addr >> 8) & 0xff;
  346. desc[4] = (align_addr >> 0) & 0xff;
  347. BUG_ON(offset > 65536);
  348. desc[3] = (offset >> 8) & 0xff;
  349. desc[2] = (offset >> 0) & 0xff;
  350. desc[1] = 0x00;
  351. desc[0] = 0x21; /* tran, valid */
  352. align += 4;
  353. align_addr += 4;
  354. desc += 8;
  355. addr += offset;
  356. len -= offset;
  357. }
  358. desc[7] = (addr >> 24) & 0xff;
  359. desc[6] = (addr >> 16) & 0xff;
  360. desc[5] = (addr >> 8) & 0xff;
  361. desc[4] = (addr >> 0) & 0xff;
  362. BUG_ON(len > 65536);
  363. desc[3] = (len >> 8) & 0xff;
  364. desc[2] = (len >> 0) & 0xff;
  365. desc[1] = 0x00;
  366. desc[0] = 0x21; /* tran, valid */
  367. desc += 8;
  368. /*
  369. * If this triggers then we have a calculation bug
  370. * somewhere. :/
  371. */
  372. WARN_ON((desc - host->adma_desc) > (128 * 2 + 1) * 4);
  373. }
  374. /*
  375. * Add a terminating entry.
  376. */
  377. desc[7] = 0;
  378. desc[6] = 0;
  379. desc[5] = 0;
  380. desc[4] = 0;
  381. desc[3] = 0;
  382. desc[2] = 0;
  383. desc[1] = 0x00;
  384. desc[0] = 0x03; /* nop, end, valid */
  385. /*
  386. * Resync align buffer as we might have changed it.
  387. */
  388. if (data->flags & MMC_DATA_WRITE) {
  389. dma_sync_single_for_device(mmc_dev(host->mmc),
  390. host->align_addr, 128 * 4, direction);
  391. }
  392. host->adma_addr = dma_map_single(mmc_dev(host->mmc),
  393. host->adma_desc, (128 * 2 + 1) * 4, DMA_TO_DEVICE);
  394. if (dma_mapping_error(mmc_dev(host->mmc), host->adma_addr))
  395. goto unmap_entries;
  396. BUG_ON(host->adma_addr & 0x3);
  397. return 0;
  398. unmap_entries:
  399. dma_unmap_sg(mmc_dev(host->mmc), data->sg,
  400. data->sg_len, direction);
  401. unmap_align:
  402. dma_unmap_single(mmc_dev(host->mmc), host->align_addr,
  403. 128 * 4, direction);
  404. fail:
  405. return -EINVAL;
  406. }
  407. static void sdhci_adma_table_post(struct sdhci_host *host,
  408. struct mmc_data *data)
  409. {
  410. int direction;
  411. struct scatterlist *sg;
  412. int i, size;
  413. u8 *align;
  414. char *buffer;
  415. unsigned long flags;
  416. if (data->flags & MMC_DATA_READ)
  417. direction = DMA_FROM_DEVICE;
  418. else
  419. direction = DMA_TO_DEVICE;
  420. dma_unmap_single(mmc_dev(host->mmc), host->adma_addr,
  421. (128 * 2 + 1) * 4, DMA_TO_DEVICE);
  422. dma_unmap_single(mmc_dev(host->mmc), host->align_addr,
  423. 128 * 4, direction);
  424. if (data->flags & MMC_DATA_READ) {
  425. dma_sync_sg_for_cpu(mmc_dev(host->mmc), data->sg,
  426. data->sg_len, direction);
  427. align = host->align_buffer;
  428. for_each_sg(data->sg, sg, host->sg_count, i) {
  429. if (sg_dma_address(sg) & 0x3) {
  430. size = 4 - (sg_dma_address(sg) & 0x3);
  431. buffer = sdhci_kmap_atomic(sg, &flags);
  432. WARN_ON(((long)buffer & PAGE_MASK) > (PAGE_SIZE - 3));
  433. memcpy(buffer, align, size);
  434. sdhci_kunmap_atomic(buffer, &flags);
  435. align += 4;
  436. }
  437. }
  438. }
  439. dma_unmap_sg(mmc_dev(host->mmc), data->sg,
  440. data->sg_len, direction);
  441. }
  442. static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_data *data)
  443. {
  444. u8 count;
  445. unsigned target_timeout, current_timeout;
  446. /*
  447. * If the host controller provides us with an incorrect timeout
  448. * value, just skip the check and use 0xE. The hardware may take
  449. * longer to time out, but that's much better than having a too-short
  450. * timeout value.
  451. */
  452. if ((host->quirks & SDHCI_QUIRK_BROKEN_TIMEOUT_VAL))
  453. return 0xE;
  454. /* timeout in us */
  455. target_timeout = data->timeout_ns / 1000 +
  456. data->timeout_clks / host->clock;
  457. /*
  458. * Figure out needed cycles.
  459. * We do this in steps in order to fit inside a 32 bit int.
  460. * The first step is the minimum timeout, which will have a
  461. * minimum resolution of 6 bits:
  462. * (1) 2^13*1000 > 2^22,
  463. * (2) host->timeout_clk < 2^16
  464. * =>
  465. * (1) / (2) > 2^6
  466. */
  467. count = 0;
  468. current_timeout = (1 << 13) * 1000 / host->timeout_clk;
  469. while (current_timeout < target_timeout) {
  470. count++;
  471. current_timeout <<= 1;
  472. if (count >= 0xF)
  473. break;
  474. }
  475. if (count >= 0xF) {
  476. printk(KERN_WARNING "%s: Too large timeout requested!\n",
  477. mmc_hostname(host->mmc));
  478. count = 0xE;
  479. }
  480. return count;
  481. }
  482. static void sdhci_set_transfer_irqs(struct sdhci_host *host)
  483. {
  484. u32 pio_irqs = SDHCI_INT_DATA_AVAIL | SDHCI_INT_SPACE_AVAIL;
  485. u32 dma_irqs = SDHCI_INT_DMA_END | SDHCI_INT_ADMA_ERROR;
  486. if (host->flags & SDHCI_REQ_USE_DMA)
  487. sdhci_clear_set_irqs(host, pio_irqs, dma_irqs);
  488. else
  489. sdhci_clear_set_irqs(host, dma_irqs, pio_irqs);
  490. }
  491. static void sdhci_prepare_data(struct sdhci_host *host, struct mmc_data *data)
  492. {
  493. u8 count;
  494. u8 ctrl;
  495. int ret;
  496. WARN_ON(host->data);
  497. if (data == NULL)
  498. return;
  499. /* Sanity checks */
  500. BUG_ON(data->blksz * data->blocks > 524288);
  501. BUG_ON(data->blksz > host->mmc->max_blk_size);
  502. BUG_ON(data->blocks > 65535);
  503. host->data = data;
  504. host->data_early = 0;
  505. count = sdhci_calc_timeout(host, data);
  506. sdhci_writeb(host, count, SDHCI_TIMEOUT_CONTROL);
  507. if (host->flags & SDHCI_USE_DMA)
  508. host->flags |= SDHCI_REQ_USE_DMA;
  509. /*
  510. * FIXME: This doesn't account for merging when mapping the
  511. * scatterlist.
  512. */
  513. if (host->flags & SDHCI_REQ_USE_DMA) {
  514. int broken, i;
  515. struct scatterlist *sg;
  516. broken = 0;
  517. if (host->flags & SDHCI_USE_ADMA) {
  518. if (host->quirks & SDHCI_QUIRK_32BIT_ADMA_SIZE)
  519. broken = 1;
  520. } else {
  521. if (host->quirks & SDHCI_QUIRK_32BIT_DMA_SIZE)
  522. broken = 1;
  523. }
  524. if (unlikely(broken)) {
  525. for_each_sg(data->sg, sg, data->sg_len, i) {
  526. if (sg->length & 0x3) {
  527. DBG("Reverting to PIO because of "
  528. "transfer size (%d)\n",
  529. sg->length);
  530. host->flags &= ~SDHCI_REQ_USE_DMA;
  531. break;
  532. }
  533. }
  534. }
  535. }
  536. /*
  537. * The assumption here being that alignment is the same after
  538. * translation to device address space.
  539. */
  540. if (host->flags & SDHCI_REQ_USE_DMA) {
  541. int broken, i;
  542. struct scatterlist *sg;
  543. broken = 0;
  544. if (host->flags & SDHCI_USE_ADMA) {
  545. /*
  546. * As we use 3 byte chunks to work around
  547. * alignment problems, we need to check this
  548. * quirk.
  549. */
  550. if (host->quirks & SDHCI_QUIRK_32BIT_ADMA_SIZE)
  551. broken = 1;
  552. } else {
  553. if (host->quirks & SDHCI_QUIRK_32BIT_DMA_ADDR)
  554. broken = 1;
  555. }
  556. if (unlikely(broken)) {
  557. for_each_sg(data->sg, sg, data->sg_len, i) {
  558. if (sg->offset & 0x3) {
  559. DBG("Reverting to PIO because of "
  560. "bad alignment\n");
  561. host->flags &= ~SDHCI_REQ_USE_DMA;
  562. break;
  563. }
  564. }
  565. }
  566. }
  567. if (host->flags & SDHCI_REQ_USE_DMA) {
  568. if (host->flags & SDHCI_USE_ADMA) {
  569. ret = sdhci_adma_table_pre(host, data);
  570. if (ret) {
  571. /*
  572. * This only happens when someone fed
  573. * us an invalid request.
  574. */
  575. WARN_ON(1);
  576. host->flags &= ~SDHCI_REQ_USE_DMA;
  577. } else {
  578. sdhci_writel(host, host->adma_addr,
  579. SDHCI_ADMA_ADDRESS);
  580. }
  581. } else {
  582. int sg_cnt;
  583. sg_cnt = dma_map_sg(mmc_dev(host->mmc),
  584. data->sg, data->sg_len,
  585. (data->flags & MMC_DATA_READ) ?
  586. DMA_FROM_DEVICE :
  587. DMA_TO_DEVICE);
  588. if (sg_cnt == 0) {
  589. /*
  590. * This only happens when someone fed
  591. * us an invalid request.
  592. */
  593. WARN_ON(1);
  594. host->flags &= ~SDHCI_REQ_USE_DMA;
  595. } else {
  596. WARN_ON(sg_cnt != 1);
  597. sdhci_writel(host, sg_dma_address(data->sg),
  598. SDHCI_DMA_ADDRESS);
  599. }
  600. }
  601. }
  602. /*
  603. * Always adjust the DMA selection as some controllers
  604. * (e.g. JMicron) can't do PIO properly when the selection
  605. * is ADMA.
  606. */
  607. if (host->version >= SDHCI_SPEC_200) {
  608. ctrl = sdhci_readb(host, SDHCI_HOST_CONTROL);
  609. ctrl &= ~SDHCI_CTRL_DMA_MASK;
  610. if ((host->flags & SDHCI_REQ_USE_DMA) &&
  611. (host->flags & SDHCI_USE_ADMA))
  612. ctrl |= SDHCI_CTRL_ADMA32;
  613. else
  614. ctrl |= SDHCI_CTRL_SDMA;
  615. sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL);
  616. }
  617. if (!(host->flags & SDHCI_REQ_USE_DMA)) {
  618. sg_miter_start(&host->sg_miter,
  619. data->sg, data->sg_len, SG_MITER_ATOMIC);
  620. host->blocks = data->blocks;
  621. }
  622. sdhci_set_transfer_irqs(host);
  623. /* We do not handle DMA boundaries, so set it to max (512 KiB) */
  624. sdhci_writew(host, SDHCI_MAKE_BLKSZ(7, data->blksz), SDHCI_BLOCK_SIZE);
  625. sdhci_writew(host, data->blocks, SDHCI_BLOCK_COUNT);
  626. }
  627. static void sdhci_set_transfer_mode(struct sdhci_host *host,
  628. struct mmc_data *data)
  629. {
  630. u16 mode;
  631. if (data == NULL)
  632. return;
  633. WARN_ON(!host->data);
  634. mode = SDHCI_TRNS_BLK_CNT_EN;
  635. if (data->blocks > 1)
  636. mode |= SDHCI_TRNS_MULTI;
  637. if (data->flags & MMC_DATA_READ)
  638. mode |= SDHCI_TRNS_READ;
  639. if (host->flags & SDHCI_REQ_USE_DMA)
  640. mode |= SDHCI_TRNS_DMA;
  641. sdhci_writew(host, mode, SDHCI_TRANSFER_MODE);
  642. }
  643. static void sdhci_finish_data(struct sdhci_host *host)
  644. {
  645. struct mmc_data *data;
  646. BUG_ON(!host->data);
  647. data = host->data;
  648. host->data = NULL;
  649. if (host->flags & SDHCI_REQ_USE_DMA) {
  650. if (host->flags & SDHCI_USE_ADMA)
  651. sdhci_adma_table_post(host, data);
  652. else {
  653. dma_unmap_sg(mmc_dev(host->mmc), data->sg,
  654. data->sg_len, (data->flags & MMC_DATA_READ) ?
  655. DMA_FROM_DEVICE : DMA_TO_DEVICE);
  656. }
  657. }
  658. /*
  659. * The specification states that the block count register must
  660. * be updated, but it does not specify at what point in the
  661. * data flow. That makes the register entirely useless to read
  662. * back so we have to assume that nothing made it to the card
  663. * in the event of an error.
  664. */
  665. if (data->error)
  666. data->bytes_xfered = 0;
  667. else
  668. data->bytes_xfered = data->blksz * data->blocks;
  669. if (data->stop) {
  670. /*
  671. * The controller needs a reset of internal state machines
  672. * upon error conditions.
  673. */
  674. if (data->error) {
  675. sdhci_reset(host, SDHCI_RESET_CMD);
  676. sdhci_reset(host, SDHCI_RESET_DATA);
  677. }
  678. sdhci_send_command(host, data->stop);
  679. } else
  680. tasklet_schedule(&host->finish_tasklet);
  681. }
  682. static void sdhci_send_command(struct sdhci_host *host, struct mmc_command *cmd)
  683. {
  684. int flags;
  685. u32 mask;
  686. unsigned long timeout;
  687. WARN_ON(host->cmd);
  688. /* Wait max 10 ms */
  689. timeout = 10;
  690. mask = SDHCI_CMD_INHIBIT;
  691. if ((cmd->data != NULL) || (cmd->flags & MMC_RSP_BUSY))
  692. mask |= SDHCI_DATA_INHIBIT;
  693. /* We shouldn't wait for data inihibit for stop commands, even
  694. though they might use busy signaling */
  695. if (host->mrq->data && (cmd == host->mrq->data->stop))
  696. mask &= ~SDHCI_DATA_INHIBIT;
  697. while (sdhci_readl(host, SDHCI_PRESENT_STATE) & mask) {
  698. if (timeout == 0) {
  699. printk(KERN_ERR "%s: Controller never released "
  700. "inhibit bit(s).\n", mmc_hostname(host->mmc));
  701. sdhci_dumpregs(host);
  702. cmd->error = -EIO;
  703. tasklet_schedule(&host->finish_tasklet);
  704. return;
  705. }
  706. timeout--;
  707. mdelay(1);
  708. }
  709. mod_timer(&host->timer, jiffies + 10 * HZ);
  710. host->cmd = cmd;
  711. sdhci_prepare_data(host, cmd->data);
  712. sdhci_writel(host, cmd->arg, SDHCI_ARGUMENT);
  713. sdhci_set_transfer_mode(host, cmd->data);
  714. if ((cmd->flags & MMC_RSP_136) && (cmd->flags & MMC_RSP_BUSY)) {
  715. printk(KERN_ERR "%s: Unsupported response type!\n",
  716. mmc_hostname(host->mmc));
  717. cmd->error = -EINVAL;
  718. tasklet_schedule(&host->finish_tasklet);
  719. return;
  720. }
  721. if (!(cmd->flags & MMC_RSP_PRESENT))
  722. flags = SDHCI_CMD_RESP_NONE;
  723. else if (cmd->flags & MMC_RSP_136)
  724. flags = SDHCI_CMD_RESP_LONG;
  725. else if (cmd->flags & MMC_RSP_BUSY)
  726. flags = SDHCI_CMD_RESP_SHORT_BUSY;
  727. else
  728. flags = SDHCI_CMD_RESP_SHORT;
  729. if (cmd->flags & MMC_RSP_CRC)
  730. flags |= SDHCI_CMD_CRC;
  731. if (cmd->flags & MMC_RSP_OPCODE)
  732. flags |= SDHCI_CMD_INDEX;
  733. if (cmd->data)
  734. flags |= SDHCI_CMD_DATA;
  735. sdhci_writew(host, SDHCI_MAKE_CMD(cmd->opcode, flags), SDHCI_COMMAND);
  736. }
  737. static void sdhci_finish_command(struct sdhci_host *host)
  738. {
  739. int i;
  740. BUG_ON(host->cmd == NULL);
  741. if (host->cmd->flags & MMC_RSP_PRESENT) {
  742. if (host->cmd->flags & MMC_RSP_136) {
  743. /* CRC is stripped so we need to do some shifting. */
  744. for (i = 0;i < 4;i++) {
  745. host->cmd->resp[i] = sdhci_readl(host,
  746. SDHCI_RESPONSE + (3-i)*4) << 8;
  747. if (i != 3)
  748. host->cmd->resp[i] |=
  749. sdhci_readb(host,
  750. SDHCI_RESPONSE + (3-i)*4-1);
  751. }
  752. } else {
  753. host->cmd->resp[0] = sdhci_readl(host, SDHCI_RESPONSE);
  754. }
  755. }
  756. host->cmd->error = 0;
  757. if (host->data && host->data_early)
  758. sdhci_finish_data(host);
  759. if (!host->cmd->data)
  760. tasklet_schedule(&host->finish_tasklet);
  761. host->cmd = NULL;
  762. }
  763. static void sdhci_set_clock(struct sdhci_host *host, unsigned int clock)
  764. {
  765. int div;
  766. u16 clk;
  767. unsigned long timeout;
  768. if (clock == host->clock)
  769. return;
  770. if (host->ops->set_clock) {
  771. host->ops->set_clock(host, clock);
  772. if (host->quirks & SDHCI_QUIRK_NONSTANDARD_CLOCK)
  773. return;
  774. }
  775. sdhci_writew(host, 0, SDHCI_CLOCK_CONTROL);
  776. if (clock == 0)
  777. goto out;
  778. for (div = 1;div < 256;div *= 2) {
  779. if ((host->max_clk / div) <= clock)
  780. break;
  781. }
  782. div >>= 1;
  783. clk = div << SDHCI_DIVIDER_SHIFT;
  784. clk |= SDHCI_CLOCK_INT_EN;
  785. sdhci_writew(host, clk, SDHCI_CLOCK_CONTROL);
  786. /* Wait max 10 ms */
  787. timeout = 10;
  788. while (!((clk = sdhci_readw(host, SDHCI_CLOCK_CONTROL))
  789. & SDHCI_CLOCK_INT_STABLE)) {
  790. if (timeout == 0) {
  791. printk(KERN_ERR "%s: Internal clock never "
  792. "stabilised.\n", mmc_hostname(host->mmc));
  793. sdhci_dumpregs(host);
  794. return;
  795. }
  796. timeout--;
  797. mdelay(1);
  798. }
  799. clk |= SDHCI_CLOCK_CARD_EN;
  800. sdhci_writew(host, clk, SDHCI_CLOCK_CONTROL);
  801. out:
  802. host->clock = clock;
  803. }
  804. static void sdhci_set_power(struct sdhci_host *host, unsigned short power)
  805. {
  806. u8 pwr;
  807. if (host->power == power)
  808. return;
  809. if (power == (unsigned short)-1) {
  810. sdhci_writeb(host, 0, SDHCI_POWER_CONTROL);
  811. goto out;
  812. }
  813. /*
  814. * Spec says that we should clear the power reg before setting
  815. * a new value. Some controllers don't seem to like this though.
  816. */
  817. if (!(host->quirks & SDHCI_QUIRK_SINGLE_POWER_WRITE))
  818. sdhci_writeb(host, 0, SDHCI_POWER_CONTROL);
  819. pwr = SDHCI_POWER_ON;
  820. switch (1 << power) {
  821. case MMC_VDD_165_195:
  822. pwr |= SDHCI_POWER_180;
  823. break;
  824. case MMC_VDD_29_30:
  825. case MMC_VDD_30_31:
  826. pwr |= SDHCI_POWER_300;
  827. break;
  828. case MMC_VDD_32_33:
  829. case MMC_VDD_33_34:
  830. pwr |= SDHCI_POWER_330;
  831. break;
  832. default:
  833. BUG();
  834. }
  835. /*
  836. * At least the Marvell CaFe chip gets confused if we set the voltage
  837. * and set turn on power at the same time, so set the voltage first.
  838. */
  839. if ((host->quirks & SDHCI_QUIRK_NO_SIMULT_VDD_AND_POWER))
  840. sdhci_writeb(host, pwr & ~SDHCI_POWER_ON, SDHCI_POWER_CONTROL);
  841. sdhci_writeb(host, pwr, SDHCI_POWER_CONTROL);
  842. out:
  843. host->power = power;
  844. }
  845. /*****************************************************************************\
  846. * *
  847. * MMC callbacks *
  848. * *
  849. \*****************************************************************************/
  850. static void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq)
  851. {
  852. struct sdhci_host *host;
  853. bool present;
  854. unsigned long flags;
  855. host = mmc_priv(mmc);
  856. spin_lock_irqsave(&host->lock, flags);
  857. WARN_ON(host->mrq != NULL);
  858. #ifndef SDHCI_USE_LEDS_CLASS
  859. sdhci_activate_led(host);
  860. #endif
  861. host->mrq = mrq;
  862. /* If polling, assume that the card is always present. */
  863. if (host->quirks & SDHCI_QUIRK_BROKEN_CARD_DETECTION)
  864. present = true;
  865. else
  866. present = sdhci_readl(host, SDHCI_PRESENT_STATE) &
  867. SDHCI_CARD_PRESENT;
  868. if (!present || host->flags & SDHCI_DEVICE_DEAD) {
  869. host->mrq->cmd->error = -ENOMEDIUM;
  870. tasklet_schedule(&host->finish_tasklet);
  871. } else
  872. sdhci_send_command(host, mrq->cmd);
  873. mmiowb();
  874. spin_unlock_irqrestore(&host->lock, flags);
  875. }
  876. static void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
  877. {
  878. struct sdhci_host *host;
  879. unsigned long flags;
  880. u8 ctrl;
  881. host = mmc_priv(mmc);
  882. spin_lock_irqsave(&host->lock, flags);
  883. if (host->flags & SDHCI_DEVICE_DEAD)
  884. goto out;
  885. /*
  886. * Reset the chip on each power off.
  887. * Should clear out any weird states.
  888. */
  889. if (ios->power_mode == MMC_POWER_OFF) {
  890. sdhci_writel(host, 0, SDHCI_SIGNAL_ENABLE);
  891. sdhci_reinit(host);
  892. }
  893. sdhci_set_clock(host, ios->clock);
  894. if (ios->power_mode == MMC_POWER_OFF)
  895. sdhci_set_power(host, -1);
  896. else
  897. sdhci_set_power(host, ios->vdd);
  898. ctrl = sdhci_readb(host, SDHCI_HOST_CONTROL);
  899. if (ios->bus_width == MMC_BUS_WIDTH_4)
  900. ctrl |= SDHCI_CTRL_4BITBUS;
  901. else
  902. ctrl &= ~SDHCI_CTRL_4BITBUS;
  903. if (ios->timing == MMC_TIMING_SD_HS)
  904. ctrl |= SDHCI_CTRL_HISPD;
  905. else
  906. ctrl &= ~SDHCI_CTRL_HISPD;
  907. sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL);
  908. /*
  909. * Some (ENE) controllers go apeshit on some ios operation,
  910. * signalling timeout and CRC errors even on CMD0. Resetting
  911. * it on each ios seems to solve the problem.
  912. */
  913. if(host->quirks & SDHCI_QUIRK_RESET_CMD_DATA_ON_IOS)
  914. sdhci_reset(host, SDHCI_RESET_CMD | SDHCI_RESET_DATA);
  915. out:
  916. mmiowb();
  917. spin_unlock_irqrestore(&host->lock, flags);
  918. }
  919. static int sdhci_get_ro(struct mmc_host *mmc)
  920. {
  921. struct sdhci_host *host;
  922. unsigned long flags;
  923. int present;
  924. host = mmc_priv(mmc);
  925. spin_lock_irqsave(&host->lock, flags);
  926. if (host->flags & SDHCI_DEVICE_DEAD)
  927. present = 0;
  928. else
  929. present = sdhci_readl(host, SDHCI_PRESENT_STATE);
  930. spin_unlock_irqrestore(&host->lock, flags);
  931. if (host->quirks & SDHCI_QUIRK_INVERTED_WRITE_PROTECT)
  932. return !!(present & SDHCI_WRITE_PROTECT);
  933. return !(present & SDHCI_WRITE_PROTECT);
  934. }
  935. static void sdhci_enable_sdio_irq(struct mmc_host *mmc, int enable)
  936. {
  937. struct sdhci_host *host;
  938. unsigned long flags;
  939. host = mmc_priv(mmc);
  940. spin_lock_irqsave(&host->lock, flags);
  941. if (host->flags & SDHCI_DEVICE_DEAD)
  942. goto out;
  943. if (enable)
  944. sdhci_unmask_irqs(host, SDHCI_INT_CARD_INT);
  945. else
  946. sdhci_mask_irqs(host, SDHCI_INT_CARD_INT);
  947. out:
  948. mmiowb();
  949. spin_unlock_irqrestore(&host->lock, flags);
  950. }
  951. static const struct mmc_host_ops sdhci_ops = {
  952. .request = sdhci_request,
  953. .set_ios = sdhci_set_ios,
  954. .get_ro = sdhci_get_ro,
  955. .enable_sdio_irq = sdhci_enable_sdio_irq,
  956. };
  957. /*****************************************************************************\
  958. * *
  959. * Tasklets *
  960. * *
  961. \*****************************************************************************/
  962. static void sdhci_tasklet_card(unsigned long param)
  963. {
  964. struct sdhci_host *host;
  965. unsigned long flags;
  966. host = (struct sdhci_host*)param;
  967. spin_lock_irqsave(&host->lock, flags);
  968. if (!(sdhci_readl(host, SDHCI_PRESENT_STATE) & SDHCI_CARD_PRESENT)) {
  969. if (host->mrq) {
  970. printk(KERN_ERR "%s: Card removed during transfer!\n",
  971. mmc_hostname(host->mmc));
  972. printk(KERN_ERR "%s: Resetting controller.\n",
  973. mmc_hostname(host->mmc));
  974. sdhci_reset(host, SDHCI_RESET_CMD);
  975. sdhci_reset(host, SDHCI_RESET_DATA);
  976. host->mrq->cmd->error = -ENOMEDIUM;
  977. tasklet_schedule(&host->finish_tasklet);
  978. }
  979. }
  980. spin_unlock_irqrestore(&host->lock, flags);
  981. mmc_detect_change(host->mmc, msecs_to_jiffies(200));
  982. }
  983. static void sdhci_tasklet_finish(unsigned long param)
  984. {
  985. struct sdhci_host *host;
  986. unsigned long flags;
  987. struct mmc_request *mrq;
  988. host = (struct sdhci_host*)param;
  989. spin_lock_irqsave(&host->lock, flags);
  990. del_timer(&host->timer);
  991. mrq = host->mrq;
  992. /*
  993. * The controller needs a reset of internal state machines
  994. * upon error conditions.
  995. */
  996. if (!(host->flags & SDHCI_DEVICE_DEAD) &&
  997. (mrq->cmd->error ||
  998. (mrq->data && (mrq->data->error ||
  999. (mrq->data->stop && mrq->data->stop->error))) ||
  1000. (host->quirks & SDHCI_QUIRK_RESET_AFTER_REQUEST))) {
  1001. /* Some controllers need this kick or reset won't work here */
  1002. if (host->quirks & SDHCI_QUIRK_CLOCK_BEFORE_RESET) {
  1003. unsigned int clock;
  1004. /* This is to force an update */
  1005. clock = host->clock;
  1006. host->clock = 0;
  1007. sdhci_set_clock(host, clock);
  1008. }
  1009. /* Spec says we should do both at the same time, but Ricoh
  1010. controllers do not like that. */
  1011. sdhci_reset(host, SDHCI_RESET_CMD);
  1012. sdhci_reset(host, SDHCI_RESET_DATA);
  1013. }
  1014. host->mrq = NULL;
  1015. host->cmd = NULL;
  1016. host->data = NULL;
  1017. #ifndef SDHCI_USE_LEDS_CLASS
  1018. sdhci_deactivate_led(host);
  1019. #endif
  1020. mmiowb();
  1021. spin_unlock_irqrestore(&host->lock, flags);
  1022. mmc_request_done(host->mmc, mrq);
  1023. }
  1024. static void sdhci_timeout_timer(unsigned long data)
  1025. {
  1026. struct sdhci_host *host;
  1027. unsigned long flags;
  1028. host = (struct sdhci_host*)data;
  1029. spin_lock_irqsave(&host->lock, flags);
  1030. if (host->mrq) {
  1031. printk(KERN_ERR "%s: Timeout waiting for hardware "
  1032. "interrupt.\n", mmc_hostname(host->mmc));
  1033. sdhci_dumpregs(host);
  1034. if (host->data) {
  1035. host->data->error = -ETIMEDOUT;
  1036. sdhci_finish_data(host);
  1037. } else {
  1038. if (host->cmd)
  1039. host->cmd->error = -ETIMEDOUT;
  1040. else
  1041. host->mrq->cmd->error = -ETIMEDOUT;
  1042. tasklet_schedule(&host->finish_tasklet);
  1043. }
  1044. }
  1045. mmiowb();
  1046. spin_unlock_irqrestore(&host->lock, flags);
  1047. }
  1048. /*****************************************************************************\
  1049. * *
  1050. * Interrupt handling *
  1051. * *
  1052. \*****************************************************************************/
  1053. static void sdhci_cmd_irq(struct sdhci_host *host, u32 intmask)
  1054. {
  1055. BUG_ON(intmask == 0);
  1056. if (!host->cmd) {
  1057. printk(KERN_ERR "%s: Got command interrupt 0x%08x even "
  1058. "though no command operation was in progress.\n",
  1059. mmc_hostname(host->mmc), (unsigned)intmask);
  1060. sdhci_dumpregs(host);
  1061. return;
  1062. }
  1063. if (intmask & SDHCI_INT_TIMEOUT)
  1064. host->cmd->error = -ETIMEDOUT;
  1065. else if (intmask & (SDHCI_INT_CRC | SDHCI_INT_END_BIT |
  1066. SDHCI_INT_INDEX))
  1067. host->cmd->error = -EILSEQ;
  1068. if (host->cmd->error) {
  1069. tasklet_schedule(&host->finish_tasklet);
  1070. return;
  1071. }
  1072. /*
  1073. * The host can send and interrupt when the busy state has
  1074. * ended, allowing us to wait without wasting CPU cycles.
  1075. * Unfortunately this is overloaded on the "data complete"
  1076. * interrupt, so we need to take some care when handling
  1077. * it.
  1078. *
  1079. * Note: The 1.0 specification is a bit ambiguous about this
  1080. * feature so there might be some problems with older
  1081. * controllers.
  1082. */
  1083. if (host->cmd->flags & MMC_RSP_BUSY) {
  1084. if (host->cmd->data)
  1085. DBG("Cannot wait for busy signal when also "
  1086. "doing a data transfer");
  1087. else if (!(host->quirks & SDHCI_QUIRK_NO_BUSY_IRQ))
  1088. return;
  1089. /* The controller does not support the end-of-busy IRQ,
  1090. * fall through and take the SDHCI_INT_RESPONSE */
  1091. }
  1092. if (intmask & SDHCI_INT_RESPONSE)
  1093. sdhci_finish_command(host);
  1094. }
  1095. static void sdhci_data_irq(struct sdhci_host *host, u32 intmask)
  1096. {
  1097. BUG_ON(intmask == 0);
  1098. if (!host->data) {
  1099. /*
  1100. * The "data complete" interrupt is also used to
  1101. * indicate that a busy state has ended. See comment
  1102. * above in sdhci_cmd_irq().
  1103. */
  1104. if (host->cmd && (host->cmd->flags & MMC_RSP_BUSY)) {
  1105. if (intmask & SDHCI_INT_DATA_END) {
  1106. sdhci_finish_command(host);
  1107. return;
  1108. }
  1109. }
  1110. printk(KERN_ERR "%s: Got data interrupt 0x%08x even "
  1111. "though no data operation was in progress.\n",
  1112. mmc_hostname(host->mmc), (unsigned)intmask);
  1113. sdhci_dumpregs(host);
  1114. return;
  1115. }
  1116. if (intmask & SDHCI_INT_DATA_TIMEOUT)
  1117. host->data->error = -ETIMEDOUT;
  1118. else if (intmask & (SDHCI_INT_DATA_CRC | SDHCI_INT_DATA_END_BIT))
  1119. host->data->error = -EILSEQ;
  1120. else if (intmask & SDHCI_INT_ADMA_ERROR)
  1121. host->data->error = -EIO;
  1122. if (host->data->error)
  1123. sdhci_finish_data(host);
  1124. else {
  1125. if (intmask & (SDHCI_INT_DATA_AVAIL | SDHCI_INT_SPACE_AVAIL))
  1126. sdhci_transfer_pio(host);
  1127. /*
  1128. * We currently don't do anything fancy with DMA
  1129. * boundaries, but as we can't disable the feature
  1130. * we need to at least restart the transfer.
  1131. */
  1132. if (intmask & SDHCI_INT_DMA_END)
  1133. sdhci_writel(host, sdhci_readl(host, SDHCI_DMA_ADDRESS),
  1134. SDHCI_DMA_ADDRESS);
  1135. if (intmask & SDHCI_INT_DATA_END) {
  1136. if (host->cmd) {
  1137. /*
  1138. * Data managed to finish before the
  1139. * command completed. Make sure we do
  1140. * things in the proper order.
  1141. */
  1142. host->data_early = 1;
  1143. } else {
  1144. sdhci_finish_data(host);
  1145. }
  1146. }
  1147. }
  1148. }
  1149. static irqreturn_t sdhci_irq(int irq, void *dev_id)
  1150. {
  1151. irqreturn_t result;
  1152. struct sdhci_host* host = dev_id;
  1153. u32 intmask;
  1154. int cardint = 0;
  1155. spin_lock(&host->lock);
  1156. intmask = sdhci_readl(host, SDHCI_INT_STATUS);
  1157. if (!intmask || intmask == 0xffffffff) {
  1158. result = IRQ_NONE;
  1159. goto out;
  1160. }
  1161. DBG("*** %s got interrupt: 0x%08x\n",
  1162. mmc_hostname(host->mmc), intmask);
  1163. if (intmask & (SDHCI_INT_CARD_INSERT | SDHCI_INT_CARD_REMOVE)) {
  1164. sdhci_writel(host, intmask & (SDHCI_INT_CARD_INSERT |
  1165. SDHCI_INT_CARD_REMOVE), SDHCI_INT_STATUS);
  1166. tasklet_schedule(&host->card_tasklet);
  1167. }
  1168. intmask &= ~(SDHCI_INT_CARD_INSERT | SDHCI_INT_CARD_REMOVE);
  1169. if (intmask & SDHCI_INT_CMD_MASK) {
  1170. sdhci_writel(host, intmask & SDHCI_INT_CMD_MASK,
  1171. SDHCI_INT_STATUS);
  1172. sdhci_cmd_irq(host, intmask & SDHCI_INT_CMD_MASK);
  1173. }
  1174. if (intmask & SDHCI_INT_DATA_MASK) {
  1175. sdhci_writel(host, intmask & SDHCI_INT_DATA_MASK,
  1176. SDHCI_INT_STATUS);
  1177. sdhci_data_irq(host, intmask & SDHCI_INT_DATA_MASK);
  1178. }
  1179. intmask &= ~(SDHCI_INT_CMD_MASK | SDHCI_INT_DATA_MASK);
  1180. intmask &= ~SDHCI_INT_ERROR;
  1181. if (intmask & SDHCI_INT_BUS_POWER) {
  1182. printk(KERN_ERR "%s: Card is consuming too much power!\n",
  1183. mmc_hostname(host->mmc));
  1184. sdhci_writel(host, SDHCI_INT_BUS_POWER, SDHCI_INT_STATUS);
  1185. }
  1186. intmask &= ~SDHCI_INT_BUS_POWER;
  1187. if (intmask & SDHCI_INT_CARD_INT)
  1188. cardint = 1;
  1189. intmask &= ~SDHCI_INT_CARD_INT;
  1190. if (intmask) {
  1191. printk(KERN_ERR "%s: Unexpected interrupt 0x%08x.\n",
  1192. mmc_hostname(host->mmc), intmask);
  1193. sdhci_dumpregs(host);
  1194. sdhci_writel(host, intmask, SDHCI_INT_STATUS);
  1195. }
  1196. result = IRQ_HANDLED;
  1197. mmiowb();
  1198. out:
  1199. spin_unlock(&host->lock);
  1200. /*
  1201. * We have to delay this as it calls back into the driver.
  1202. */
  1203. if (cardint)
  1204. mmc_signal_sdio_irq(host->mmc);
  1205. return result;
  1206. }
  1207. /*****************************************************************************\
  1208. * *
  1209. * Suspend/resume *
  1210. * *
  1211. \*****************************************************************************/
  1212. #ifdef CONFIG_PM
  1213. int sdhci_suspend_host(struct sdhci_host *host, pm_message_t state)
  1214. {
  1215. int ret;
  1216. sdhci_disable_card_detection(host);
  1217. ret = mmc_suspend_host(host->mmc, state);
  1218. if (ret)
  1219. return ret;
  1220. free_irq(host->irq, host);
  1221. return 0;
  1222. }
  1223. EXPORT_SYMBOL_GPL(sdhci_suspend_host);
  1224. int sdhci_resume_host(struct sdhci_host *host)
  1225. {
  1226. int ret;
  1227. if (host->flags & SDHCI_USE_DMA) {
  1228. if (host->ops->enable_dma)
  1229. host->ops->enable_dma(host);
  1230. }
  1231. ret = request_irq(host->irq, sdhci_irq, IRQF_SHARED,
  1232. mmc_hostname(host->mmc), host);
  1233. if (ret)
  1234. return ret;
  1235. sdhci_init(host);
  1236. mmiowb();
  1237. ret = mmc_resume_host(host->mmc);
  1238. if (ret)
  1239. return ret;
  1240. sdhci_enable_card_detection(host);
  1241. return 0;
  1242. }
  1243. EXPORT_SYMBOL_GPL(sdhci_resume_host);
  1244. #endif /* CONFIG_PM */
  1245. /*****************************************************************************\
  1246. * *
  1247. * Device allocation/registration *
  1248. * *
  1249. \*****************************************************************************/
  1250. struct sdhci_host *sdhci_alloc_host(struct device *dev,
  1251. size_t priv_size)
  1252. {
  1253. struct mmc_host *mmc;
  1254. struct sdhci_host *host;
  1255. WARN_ON(dev == NULL);
  1256. mmc = mmc_alloc_host(sizeof(struct sdhci_host) + priv_size, dev);
  1257. if (!mmc)
  1258. return ERR_PTR(-ENOMEM);
  1259. host = mmc_priv(mmc);
  1260. host->mmc = mmc;
  1261. return host;
  1262. }
  1263. EXPORT_SYMBOL_GPL(sdhci_alloc_host);
  1264. int sdhci_add_host(struct sdhci_host *host)
  1265. {
  1266. struct mmc_host *mmc;
  1267. unsigned int caps;
  1268. int ret;
  1269. WARN_ON(host == NULL);
  1270. if (host == NULL)
  1271. return -EINVAL;
  1272. mmc = host->mmc;
  1273. if (debug_quirks)
  1274. host->quirks = debug_quirks;
  1275. sdhci_reset(host, SDHCI_RESET_ALL);
  1276. host->version = sdhci_readw(host, SDHCI_HOST_VERSION);
  1277. host->version = (host->version & SDHCI_SPEC_VER_MASK)
  1278. >> SDHCI_SPEC_VER_SHIFT;
  1279. if (host->version > SDHCI_SPEC_200) {
  1280. printk(KERN_ERR "%s: Unknown controller version (%d). "
  1281. "You may experience problems.\n", mmc_hostname(mmc),
  1282. host->version);
  1283. }
  1284. caps = sdhci_readl(host, SDHCI_CAPABILITIES);
  1285. if (host->quirks & SDHCI_QUIRK_FORCE_DMA)
  1286. host->flags |= SDHCI_USE_DMA;
  1287. else if (!(caps & SDHCI_CAN_DO_DMA))
  1288. DBG("Controller doesn't have DMA capability\n");
  1289. else
  1290. host->flags |= SDHCI_USE_DMA;
  1291. if ((host->quirks & SDHCI_QUIRK_BROKEN_DMA) &&
  1292. (host->flags & SDHCI_USE_DMA)) {
  1293. DBG("Disabling DMA as it is marked broken\n");
  1294. host->flags &= ~SDHCI_USE_DMA;
  1295. }
  1296. if (host->flags & SDHCI_USE_DMA) {
  1297. if ((host->version >= SDHCI_SPEC_200) &&
  1298. (caps & SDHCI_CAN_DO_ADMA2))
  1299. host->flags |= SDHCI_USE_ADMA;
  1300. }
  1301. if ((host->quirks & SDHCI_QUIRK_BROKEN_ADMA) &&
  1302. (host->flags & SDHCI_USE_ADMA)) {
  1303. DBG("Disabling ADMA as it is marked broken\n");
  1304. host->flags &= ~SDHCI_USE_ADMA;
  1305. }
  1306. if (host->flags & SDHCI_USE_DMA) {
  1307. if (host->ops->enable_dma) {
  1308. if (host->ops->enable_dma(host)) {
  1309. printk(KERN_WARNING "%s: No suitable DMA "
  1310. "available. Falling back to PIO.\n",
  1311. mmc_hostname(mmc));
  1312. host->flags &= ~(SDHCI_USE_DMA | SDHCI_USE_ADMA);
  1313. }
  1314. }
  1315. }
  1316. if (host->flags & SDHCI_USE_ADMA) {
  1317. /*
  1318. * We need to allocate descriptors for all sg entries
  1319. * (128) and potentially one alignment transfer for
  1320. * each of those entries.
  1321. */
  1322. host->adma_desc = kmalloc((128 * 2 + 1) * 4, GFP_KERNEL);
  1323. host->align_buffer = kmalloc(128 * 4, GFP_KERNEL);
  1324. if (!host->adma_desc || !host->align_buffer) {
  1325. kfree(host->adma_desc);
  1326. kfree(host->align_buffer);
  1327. printk(KERN_WARNING "%s: Unable to allocate ADMA "
  1328. "buffers. Falling back to standard DMA.\n",
  1329. mmc_hostname(mmc));
  1330. host->flags &= ~SDHCI_USE_ADMA;
  1331. }
  1332. }
  1333. /*
  1334. * If we use DMA, then it's up to the caller to set the DMA
  1335. * mask, but PIO does not need the hw shim so we set a new
  1336. * mask here in that case.
  1337. */
  1338. if (!(host->flags & SDHCI_USE_DMA)) {
  1339. host->dma_mask = DMA_BIT_MASK(64);
  1340. mmc_dev(host->mmc)->dma_mask = &host->dma_mask;
  1341. }
  1342. host->max_clk =
  1343. (caps & SDHCI_CLOCK_BASE_MASK) >> SDHCI_CLOCK_BASE_SHIFT;
  1344. host->max_clk *= 1000000;
  1345. if (host->max_clk == 0) {
  1346. if (!host->ops->get_max_clock) {
  1347. printk(KERN_ERR
  1348. "%s: Hardware doesn't specify base clock "
  1349. "frequency.\n", mmc_hostname(mmc));
  1350. return -ENODEV;
  1351. }
  1352. host->max_clk = host->ops->get_max_clock(host);
  1353. }
  1354. host->timeout_clk =
  1355. (caps & SDHCI_TIMEOUT_CLK_MASK) >> SDHCI_TIMEOUT_CLK_SHIFT;
  1356. if (host->timeout_clk == 0) {
  1357. if (!host->ops->get_timeout_clock) {
  1358. printk(KERN_ERR
  1359. "%s: Hardware doesn't specify timeout clock "
  1360. "frequency.\n", mmc_hostname(mmc));
  1361. return -ENODEV;
  1362. }
  1363. host->timeout_clk = host->ops->get_timeout_clock(host);
  1364. }
  1365. if (caps & SDHCI_TIMEOUT_CLK_UNIT)
  1366. host->timeout_clk *= 1000;
  1367. /*
  1368. * Set host parameters.
  1369. */
  1370. mmc->ops = &sdhci_ops;
  1371. mmc->f_min = host->max_clk / 256;
  1372. mmc->f_max = host->max_clk;
  1373. mmc->caps = MMC_CAP_4_BIT_DATA | MMC_CAP_SDIO_IRQ;
  1374. if (caps & SDHCI_CAN_DO_HISPD)
  1375. mmc->caps |= MMC_CAP_SD_HIGHSPEED;
  1376. if (host->quirks & SDHCI_QUIRK_BROKEN_CARD_DETECTION)
  1377. mmc->caps |= MMC_CAP_NEEDS_POLL;
  1378. mmc->ocr_avail = 0;
  1379. if (caps & SDHCI_CAN_VDD_330)
  1380. mmc->ocr_avail |= MMC_VDD_32_33|MMC_VDD_33_34;
  1381. if (caps & SDHCI_CAN_VDD_300)
  1382. mmc->ocr_avail |= MMC_VDD_29_30|MMC_VDD_30_31;
  1383. if (caps & SDHCI_CAN_VDD_180)
  1384. mmc->ocr_avail |= MMC_VDD_165_195;
  1385. if (mmc->ocr_avail == 0) {
  1386. printk(KERN_ERR "%s: Hardware doesn't report any "
  1387. "support voltages.\n", mmc_hostname(mmc));
  1388. return -ENODEV;
  1389. }
  1390. spin_lock_init(&host->lock);
  1391. /*
  1392. * Maximum number of segments. Depends on if the hardware
  1393. * can do scatter/gather or not.
  1394. */
  1395. if (host->flags & SDHCI_USE_ADMA)
  1396. mmc->max_hw_segs = 128;
  1397. else if (host->flags & SDHCI_USE_DMA)
  1398. mmc->max_hw_segs = 1;
  1399. else /* PIO */
  1400. mmc->max_hw_segs = 128;
  1401. mmc->max_phys_segs = 128;
  1402. /*
  1403. * Maximum number of sectors in one transfer. Limited by DMA boundary
  1404. * size (512KiB).
  1405. */
  1406. mmc->max_req_size = 524288;
  1407. /*
  1408. * Maximum segment size. Could be one segment with the maximum number
  1409. * of bytes. When doing hardware scatter/gather, each entry cannot
  1410. * be larger than 64 KiB though.
  1411. */
  1412. if (host->flags & SDHCI_USE_ADMA)
  1413. mmc->max_seg_size = 65536;
  1414. else
  1415. mmc->max_seg_size = mmc->max_req_size;
  1416. /*
  1417. * Maximum block size. This varies from controller to controller and
  1418. * is specified in the capabilities register.
  1419. */
  1420. mmc->max_blk_size = (caps & SDHCI_MAX_BLOCK_MASK) >> SDHCI_MAX_BLOCK_SHIFT;
  1421. if (mmc->max_blk_size >= 3) {
  1422. printk(KERN_WARNING "%s: Invalid maximum block size, "
  1423. "assuming 512 bytes\n", mmc_hostname(mmc));
  1424. mmc->max_blk_size = 512;
  1425. } else
  1426. mmc->max_blk_size = 512 << mmc->max_blk_size;
  1427. /*
  1428. * Maximum block count.
  1429. */
  1430. mmc->max_blk_count = 65535;
  1431. /*
  1432. * Init tasklets.
  1433. */
  1434. tasklet_init(&host->card_tasklet,
  1435. sdhci_tasklet_card, (unsigned long)host);
  1436. tasklet_init(&host->finish_tasklet,
  1437. sdhci_tasklet_finish, (unsigned long)host);
  1438. setup_timer(&host->timer, sdhci_timeout_timer, (unsigned long)host);
  1439. ret = request_irq(host->irq, sdhci_irq, IRQF_SHARED,
  1440. mmc_hostname(mmc), host);
  1441. if (ret)
  1442. goto untasklet;
  1443. sdhci_init(host);
  1444. #ifdef CONFIG_MMC_DEBUG
  1445. sdhci_dumpregs(host);
  1446. #endif
  1447. #ifdef SDHCI_USE_LEDS_CLASS
  1448. snprintf(host->led_name, sizeof(host->led_name),
  1449. "%s::", mmc_hostname(mmc));
  1450. host->led.name = host->led_name;
  1451. host->led.brightness = LED_OFF;
  1452. host->led.default_trigger = mmc_hostname(mmc);
  1453. host->led.brightness_set = sdhci_led_control;
  1454. ret = led_classdev_register(mmc_dev(mmc), &host->led);
  1455. if (ret)
  1456. goto reset;
  1457. #endif
  1458. mmiowb();
  1459. mmc_add_host(mmc);
  1460. printk(KERN_INFO "%s: SDHCI controller on %s [%s] using %s%s\n",
  1461. mmc_hostname(mmc), host->hw_name, dev_name(mmc_dev(mmc)),
  1462. (host->flags & SDHCI_USE_ADMA)?"A":"",
  1463. (host->flags & SDHCI_USE_DMA)?"DMA":"PIO");
  1464. sdhci_enable_card_detection(host);
  1465. return 0;
  1466. #ifdef SDHCI_USE_LEDS_CLASS
  1467. reset:
  1468. sdhci_reset(host, SDHCI_RESET_ALL);
  1469. free_irq(host->irq, host);
  1470. #endif
  1471. untasklet:
  1472. tasklet_kill(&host->card_tasklet);
  1473. tasklet_kill(&host->finish_tasklet);
  1474. return ret;
  1475. }
  1476. EXPORT_SYMBOL_GPL(sdhci_add_host);
  1477. void sdhci_remove_host(struct sdhci_host *host, int dead)
  1478. {
  1479. unsigned long flags;
  1480. if (dead) {
  1481. spin_lock_irqsave(&host->lock, flags);
  1482. host->flags |= SDHCI_DEVICE_DEAD;
  1483. if (host->mrq) {
  1484. printk(KERN_ERR "%s: Controller removed during "
  1485. " transfer!\n", mmc_hostname(host->mmc));
  1486. host->mrq->cmd->error = -ENOMEDIUM;
  1487. tasklet_schedule(&host->finish_tasklet);
  1488. }
  1489. spin_unlock_irqrestore(&host->lock, flags);
  1490. }
  1491. sdhci_disable_card_detection(host);
  1492. mmc_remove_host(host->mmc);
  1493. #ifdef SDHCI_USE_LEDS_CLASS
  1494. led_classdev_unregister(&host->led);
  1495. #endif
  1496. if (!dead)
  1497. sdhci_reset(host, SDHCI_RESET_ALL);
  1498. free_irq(host->irq, host);
  1499. del_timer_sync(&host->timer);
  1500. tasklet_kill(&host->card_tasklet);
  1501. tasklet_kill(&host->finish_tasklet);
  1502. kfree(host->adma_desc);
  1503. kfree(host->align_buffer);
  1504. host->adma_desc = NULL;
  1505. host->align_buffer = NULL;
  1506. }
  1507. EXPORT_SYMBOL_GPL(sdhci_remove_host);
  1508. void sdhci_free_host(struct sdhci_host *host)
  1509. {
  1510. mmc_free_host(host->mmc);
  1511. }
  1512. EXPORT_SYMBOL_GPL(sdhci_free_host);
  1513. /*****************************************************************************\
  1514. * *
  1515. * Driver init/exit *
  1516. * *
  1517. \*****************************************************************************/
  1518. static int __init sdhci_drv_init(void)
  1519. {
  1520. printk(KERN_INFO DRIVER_NAME
  1521. ": Secure Digital Host Controller Interface driver\n");
  1522. printk(KERN_INFO DRIVER_NAME ": Copyright(c) Pierre Ossman\n");
  1523. return 0;
  1524. }
  1525. static void __exit sdhci_drv_exit(void)
  1526. {
  1527. }
  1528. module_init(sdhci_drv_init);
  1529. module_exit(sdhci_drv_exit);
  1530. module_param(debug_quirks, uint, 0444);
  1531. MODULE_AUTHOR("Pierre Ossman <drzeus@drzeus.cx>");
  1532. MODULE_DESCRIPTION("Secure Digital Host Controller Interface core driver");
  1533. MODULE_LICENSE("GPL");
  1534. MODULE_PARM_DESC(debug_quirks, "Force certain quirks.");