omap_hsmmc.c 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242
  1. /*
  2. * drivers/mmc/host/omap_hsmmc.c
  3. *
  4. * Driver for OMAP2430/3430 MMC controller.
  5. *
  6. * Copyright (C) 2007 Texas Instruments.
  7. *
  8. * Authors:
  9. * Syed Mohammed Khasim <x0khasim@ti.com>
  10. * Madhusudhan <madhu.cr@ti.com>
  11. * Mohit Jalori <mjalori@ti.com>
  12. *
  13. * This file is licensed under the terms of the GNU General Public License
  14. * version 2. This program is licensed "as is" without any warranty of any
  15. * kind, whether express or implied.
  16. */
  17. #include <linux/module.h>
  18. #include <linux/init.h>
  19. #include <linux/interrupt.h>
  20. #include <linux/delay.h>
  21. #include <linux/dma-mapping.h>
  22. #include <linux/platform_device.h>
  23. #include <linux/workqueue.h>
  24. #include <linux/timer.h>
  25. #include <linux/clk.h>
  26. #include <linux/mmc/host.h>
  27. #include <linux/io.h>
  28. #include <linux/semaphore.h>
  29. #include <mach/dma.h>
  30. #include <mach/hardware.h>
  31. #include <mach/board.h>
  32. #include <mach/mmc.h>
  33. #include <mach/cpu.h>
  34. /* OMAP HSMMC Host Controller Registers */
  35. #define OMAP_HSMMC_SYSCONFIG 0x0010
  36. #define OMAP_HSMMC_CON 0x002C
  37. #define OMAP_HSMMC_BLK 0x0104
  38. #define OMAP_HSMMC_ARG 0x0108
  39. #define OMAP_HSMMC_CMD 0x010C
  40. #define OMAP_HSMMC_RSP10 0x0110
  41. #define OMAP_HSMMC_RSP32 0x0114
  42. #define OMAP_HSMMC_RSP54 0x0118
  43. #define OMAP_HSMMC_RSP76 0x011C
  44. #define OMAP_HSMMC_DATA 0x0120
  45. #define OMAP_HSMMC_HCTL 0x0128
  46. #define OMAP_HSMMC_SYSCTL 0x012C
  47. #define OMAP_HSMMC_STAT 0x0130
  48. #define OMAP_HSMMC_IE 0x0134
  49. #define OMAP_HSMMC_ISE 0x0138
  50. #define OMAP_HSMMC_CAPA 0x0140
  51. #define VS18 (1 << 26)
  52. #define VS30 (1 << 25)
  53. #define SDVS18 (0x5 << 9)
  54. #define SDVS30 (0x6 << 9)
  55. #define SDVSCLR 0xFFFFF1FF
  56. #define SDVSDET 0x00000400
  57. #define AUTOIDLE 0x1
  58. #define SDBP (1 << 8)
  59. #define DTO 0xe
  60. #define ICE 0x1
  61. #define ICS 0x2
  62. #define CEN (1 << 2)
  63. #define CLKD_MASK 0x0000FFC0
  64. #define CLKD_SHIFT 6
  65. #define DTO_MASK 0x000F0000
  66. #define DTO_SHIFT 16
  67. #define INT_EN_MASK 0x307F0033
  68. #define INIT_STREAM (1 << 1)
  69. #define DP_SELECT (1 << 21)
  70. #define DDIR (1 << 4)
  71. #define DMA_EN 0x1
  72. #define MSBS (1 << 5)
  73. #define BCE (1 << 1)
  74. #define FOUR_BIT (1 << 1)
  75. #define CC 0x1
  76. #define TC 0x02
  77. #define OD 0x1
  78. #define ERR (1 << 15)
  79. #define CMD_TIMEOUT (1 << 16)
  80. #define DATA_TIMEOUT (1 << 20)
  81. #define CMD_CRC (1 << 17)
  82. #define DATA_CRC (1 << 21)
  83. #define CARD_ERR (1 << 28)
  84. #define STAT_CLEAR 0xFFFFFFFF
  85. #define INIT_STREAM_CMD 0x00000000
  86. #define DUAL_VOLT_OCR_BIT 7
  87. #define SRC (1 << 25)
  88. #define SRD (1 << 26)
  89. /*
  90. * FIXME: Most likely all the data using these _DEVID defines should come
  91. * from the platform_data, or implemented in controller and slot specific
  92. * functions.
  93. */
  94. #define OMAP_MMC1_DEVID 0
  95. #define OMAP_MMC2_DEVID 1
  96. #define OMAP_MMC_DATADIR_NONE 0
  97. #define OMAP_MMC_DATADIR_READ 1
  98. #define OMAP_MMC_DATADIR_WRITE 2
  99. #define MMC_TIMEOUT_MS 20
  100. #define OMAP_MMC_MASTER_CLOCK 96000000
  101. #define DRIVER_NAME "mmci-omap-hs"
  102. /*
  103. * One controller can have multiple slots, like on some omap boards using
  104. * omap.c controller driver. Luckily this is not currently done on any known
  105. * omap_hsmmc.c device.
  106. */
  107. #define mmc_slot(host) (host->pdata->slots[host->slot_id])
  108. /*
  109. * MMC Host controller read/write API's
  110. */
  111. #define OMAP_HSMMC_READ(base, reg) \
  112. __raw_readl((base) + OMAP_HSMMC_##reg)
  113. #define OMAP_HSMMC_WRITE(base, reg, val) \
  114. __raw_writel((val), (base) + OMAP_HSMMC_##reg)
  115. struct mmc_omap_host {
  116. struct device *dev;
  117. struct mmc_host *mmc;
  118. struct mmc_request *mrq;
  119. struct mmc_command *cmd;
  120. struct mmc_data *data;
  121. struct clk *fclk;
  122. struct clk *iclk;
  123. struct clk *dbclk;
  124. struct semaphore sem;
  125. struct work_struct mmc_carddetect_work;
  126. void __iomem *base;
  127. resource_size_t mapbase;
  128. unsigned int id;
  129. unsigned int dma_len;
  130. unsigned int dma_dir;
  131. unsigned char bus_mode;
  132. unsigned char datadir;
  133. u32 *buffer;
  134. u32 bytesleft;
  135. int suspended;
  136. int irq;
  137. int carddetect;
  138. int use_dma, dma_ch;
  139. int initstr;
  140. int slot_id;
  141. int dbclk_enabled;
  142. struct omap_mmc_platform_data *pdata;
  143. };
  144. /*
  145. * Stop clock to the card
  146. */
  147. static void omap_mmc_stop_clock(struct mmc_omap_host *host)
  148. {
  149. OMAP_HSMMC_WRITE(host->base, SYSCTL,
  150. OMAP_HSMMC_READ(host->base, SYSCTL) & ~CEN);
  151. if ((OMAP_HSMMC_READ(host->base, SYSCTL) & CEN) != 0x0)
  152. dev_dbg(mmc_dev(host->mmc), "MMC Clock is not stoped\n");
  153. }
  154. /*
  155. * Send init stream sequence to card
  156. * before sending IDLE command
  157. */
  158. static void send_init_stream(struct mmc_omap_host *host)
  159. {
  160. int reg = 0;
  161. unsigned long timeout;
  162. disable_irq(host->irq);
  163. OMAP_HSMMC_WRITE(host->base, CON,
  164. OMAP_HSMMC_READ(host->base, CON) | INIT_STREAM);
  165. OMAP_HSMMC_WRITE(host->base, CMD, INIT_STREAM_CMD);
  166. timeout = jiffies + msecs_to_jiffies(MMC_TIMEOUT_MS);
  167. while ((reg != CC) && time_before(jiffies, timeout))
  168. reg = OMAP_HSMMC_READ(host->base, STAT) & CC;
  169. OMAP_HSMMC_WRITE(host->base, CON,
  170. OMAP_HSMMC_READ(host->base, CON) & ~INIT_STREAM);
  171. enable_irq(host->irq);
  172. }
  173. static inline
  174. int mmc_omap_cover_is_closed(struct mmc_omap_host *host)
  175. {
  176. int r = 1;
  177. if (host->pdata->slots[host->slot_id].get_cover_state)
  178. r = host->pdata->slots[host->slot_id].get_cover_state(host->dev,
  179. host->slot_id);
  180. return r;
  181. }
  182. static ssize_t
  183. mmc_omap_show_cover_switch(struct device *dev, struct device_attribute *attr,
  184. char *buf)
  185. {
  186. struct mmc_host *mmc = container_of(dev, struct mmc_host, class_dev);
  187. struct mmc_omap_host *host = mmc_priv(mmc);
  188. return sprintf(buf, "%s\n", mmc_omap_cover_is_closed(host) ? "closed" :
  189. "open");
  190. }
  191. static DEVICE_ATTR(cover_switch, S_IRUGO, mmc_omap_show_cover_switch, NULL);
  192. static ssize_t
  193. mmc_omap_show_slot_name(struct device *dev, struct device_attribute *attr,
  194. char *buf)
  195. {
  196. struct mmc_host *mmc = container_of(dev, struct mmc_host, class_dev);
  197. struct mmc_omap_host *host = mmc_priv(mmc);
  198. struct omap_mmc_slot_data slot = host->pdata->slots[host->slot_id];
  199. return sprintf(buf, "slot:%s\n", slot.name);
  200. }
  201. static DEVICE_ATTR(slot_name, S_IRUGO, mmc_omap_show_slot_name, NULL);
  202. /*
  203. * Configure the response type and send the cmd.
  204. */
  205. static void
  206. mmc_omap_start_command(struct mmc_omap_host *host, struct mmc_command *cmd,
  207. struct mmc_data *data)
  208. {
  209. int cmdreg = 0, resptype = 0, cmdtype = 0;
  210. dev_dbg(mmc_dev(host->mmc), "%s: CMD%d, argument 0x%08x\n",
  211. mmc_hostname(host->mmc), cmd->opcode, cmd->arg);
  212. host->cmd = cmd;
  213. /*
  214. * Clear status bits and enable interrupts
  215. */
  216. OMAP_HSMMC_WRITE(host->base, STAT, STAT_CLEAR);
  217. OMAP_HSMMC_WRITE(host->base, ISE, INT_EN_MASK);
  218. OMAP_HSMMC_WRITE(host->base, IE, INT_EN_MASK);
  219. if (cmd->flags & MMC_RSP_PRESENT) {
  220. if (cmd->flags & MMC_RSP_136)
  221. resptype = 1;
  222. else
  223. resptype = 2;
  224. }
  225. /*
  226. * Unlike OMAP1 controller, the cmdtype does not seem to be based on
  227. * ac, bc, adtc, bcr. Only commands ending an open ended transfer need
  228. * a val of 0x3, rest 0x0.
  229. */
  230. if (cmd == host->mrq->stop)
  231. cmdtype = 0x3;
  232. cmdreg = (cmd->opcode << 24) | (resptype << 16) | (cmdtype << 22);
  233. if (data) {
  234. cmdreg |= DP_SELECT | MSBS | BCE;
  235. if (data->flags & MMC_DATA_READ)
  236. cmdreg |= DDIR;
  237. else
  238. cmdreg &= ~(DDIR);
  239. }
  240. if (host->use_dma)
  241. cmdreg |= DMA_EN;
  242. OMAP_HSMMC_WRITE(host->base, ARG, cmd->arg);
  243. OMAP_HSMMC_WRITE(host->base, CMD, cmdreg);
  244. }
  245. /*
  246. * Notify the transfer complete to MMC core
  247. */
  248. static void
  249. mmc_omap_xfer_done(struct mmc_omap_host *host, struct mmc_data *data)
  250. {
  251. host->data = NULL;
  252. if (host->use_dma && host->dma_ch != -1)
  253. dma_unmap_sg(mmc_dev(host->mmc), data->sg, host->dma_len,
  254. host->dma_dir);
  255. host->datadir = OMAP_MMC_DATADIR_NONE;
  256. if (!data->error)
  257. data->bytes_xfered += data->blocks * (data->blksz);
  258. else
  259. data->bytes_xfered = 0;
  260. if (!data->stop) {
  261. host->mrq = NULL;
  262. mmc_request_done(host->mmc, data->mrq);
  263. return;
  264. }
  265. mmc_omap_start_command(host, data->stop, NULL);
  266. }
  267. /*
  268. * Notify the core about command completion
  269. */
  270. static void
  271. mmc_omap_cmd_done(struct mmc_omap_host *host, struct mmc_command *cmd)
  272. {
  273. host->cmd = NULL;
  274. if (cmd->flags & MMC_RSP_PRESENT) {
  275. if (cmd->flags & MMC_RSP_136) {
  276. /* response type 2 */
  277. cmd->resp[3] = OMAP_HSMMC_READ(host->base, RSP10);
  278. cmd->resp[2] = OMAP_HSMMC_READ(host->base, RSP32);
  279. cmd->resp[1] = OMAP_HSMMC_READ(host->base, RSP54);
  280. cmd->resp[0] = OMAP_HSMMC_READ(host->base, RSP76);
  281. } else {
  282. /* response types 1, 1b, 3, 4, 5, 6 */
  283. cmd->resp[0] = OMAP_HSMMC_READ(host->base, RSP10);
  284. }
  285. }
  286. if (host->data == NULL || cmd->error) {
  287. host->mrq = NULL;
  288. mmc_request_done(host->mmc, cmd->mrq);
  289. }
  290. }
  291. /*
  292. * DMA clean up for command errors
  293. */
  294. static void mmc_dma_cleanup(struct mmc_omap_host *host)
  295. {
  296. host->data->error = -ETIMEDOUT;
  297. if (host->use_dma && host->dma_ch != -1) {
  298. dma_unmap_sg(mmc_dev(host->mmc), host->data->sg, host->dma_len,
  299. host->dma_dir);
  300. omap_free_dma(host->dma_ch);
  301. host->dma_ch = -1;
  302. up(&host->sem);
  303. }
  304. host->data = NULL;
  305. host->datadir = OMAP_MMC_DATADIR_NONE;
  306. }
  307. /*
  308. * Readable error output
  309. */
  310. #ifdef CONFIG_MMC_DEBUG
  311. static void mmc_omap_report_irq(struct mmc_omap_host *host, u32 status)
  312. {
  313. /* --- means reserved bit without definition at documentation */
  314. static const char *mmc_omap_status_bits[] = {
  315. "CC", "TC", "BGE", "---", "BWR", "BRR", "---", "---", "CIRQ",
  316. "OBI", "---", "---", "---", "---", "---", "ERRI", "CTO", "CCRC",
  317. "CEB", "CIE", "DTO", "DCRC", "DEB", "---", "ACE", "---",
  318. "---", "---", "---", "CERR", "CERR", "BADA", "---", "---", "---"
  319. };
  320. char res[256];
  321. char *buf = res;
  322. int len, i;
  323. len = sprintf(buf, "MMC IRQ 0x%x :", status);
  324. buf += len;
  325. for (i = 0; i < ARRAY_SIZE(mmc_omap_status_bits); i++)
  326. if (status & (1 << i)) {
  327. len = sprintf(buf, " %s", mmc_omap_status_bits[i]);
  328. buf += len;
  329. }
  330. dev_dbg(mmc_dev(host->mmc), "%s\n", res);
  331. }
  332. #endif /* CONFIG_MMC_DEBUG */
  333. /*
  334. * MMC controller IRQ handler
  335. */
  336. static irqreturn_t mmc_omap_irq(int irq, void *dev_id)
  337. {
  338. struct mmc_omap_host *host = dev_id;
  339. struct mmc_data *data;
  340. int end_cmd = 0, end_trans = 0, status;
  341. if (host->cmd == NULL && host->data == NULL) {
  342. OMAP_HSMMC_WRITE(host->base, STAT,
  343. OMAP_HSMMC_READ(host->base, STAT));
  344. return IRQ_HANDLED;
  345. }
  346. data = host->data;
  347. status = OMAP_HSMMC_READ(host->base, STAT);
  348. dev_dbg(mmc_dev(host->mmc), "IRQ Status is %x\n", status);
  349. if (status & ERR) {
  350. #ifdef CONFIG_MMC_DEBUG
  351. mmc_omap_report_irq(host, status);
  352. #endif
  353. if ((status & CMD_TIMEOUT) ||
  354. (status & CMD_CRC)) {
  355. if (host->cmd) {
  356. if (status & CMD_TIMEOUT) {
  357. OMAP_HSMMC_WRITE(host->base, SYSCTL,
  358. OMAP_HSMMC_READ(host->base,
  359. SYSCTL) | SRC);
  360. while (OMAP_HSMMC_READ(host->base,
  361. SYSCTL) & SRC)
  362. ;
  363. host->cmd->error = -ETIMEDOUT;
  364. } else {
  365. host->cmd->error = -EILSEQ;
  366. }
  367. end_cmd = 1;
  368. }
  369. if (host->data)
  370. mmc_dma_cleanup(host);
  371. }
  372. if ((status & DATA_TIMEOUT) ||
  373. (status & DATA_CRC)) {
  374. if (host->data) {
  375. if (status & DATA_TIMEOUT)
  376. mmc_dma_cleanup(host);
  377. else
  378. host->data->error = -EILSEQ;
  379. OMAP_HSMMC_WRITE(host->base, SYSCTL,
  380. OMAP_HSMMC_READ(host->base,
  381. SYSCTL) | SRD);
  382. while (OMAP_HSMMC_READ(host->base,
  383. SYSCTL) & SRD)
  384. ;
  385. end_trans = 1;
  386. }
  387. }
  388. if (status & CARD_ERR) {
  389. dev_dbg(mmc_dev(host->mmc),
  390. "Ignoring card err CMD%d\n", host->cmd->opcode);
  391. if (host->cmd)
  392. end_cmd = 1;
  393. if (host->data)
  394. end_trans = 1;
  395. }
  396. }
  397. OMAP_HSMMC_WRITE(host->base, STAT, status);
  398. if (end_cmd || (status & CC))
  399. mmc_omap_cmd_done(host, host->cmd);
  400. if (end_trans || (status & TC))
  401. mmc_omap_xfer_done(host, data);
  402. return IRQ_HANDLED;
  403. }
  404. /*
  405. * Switch MMC operating voltage
  406. */
  407. static int omap_mmc_switch_opcond(struct mmc_omap_host *host, int vdd)
  408. {
  409. u32 reg_val = 0;
  410. int ret;
  411. /* Disable the clocks */
  412. clk_disable(host->fclk);
  413. clk_disable(host->iclk);
  414. clk_disable(host->dbclk);
  415. /* Turn the power off */
  416. ret = mmc_slot(host).set_power(host->dev, host->slot_id, 0, 0);
  417. if (ret != 0)
  418. goto err;
  419. /* Turn the power ON with given VDD 1.8 or 3.0v */
  420. ret = mmc_slot(host).set_power(host->dev, host->slot_id, 1, vdd);
  421. if (ret != 0)
  422. goto err;
  423. clk_enable(host->fclk);
  424. clk_enable(host->iclk);
  425. clk_enable(host->dbclk);
  426. OMAP_HSMMC_WRITE(host->base, HCTL,
  427. OMAP_HSMMC_READ(host->base, HCTL) & SDVSCLR);
  428. reg_val = OMAP_HSMMC_READ(host->base, HCTL);
  429. /*
  430. * If a MMC dual voltage card is detected, the set_ios fn calls
  431. * this fn with VDD bit set for 1.8V. Upon card removal from the
  432. * slot, omap_mmc_set_ios sets the VDD back to 3V on MMC_POWER_OFF.
  433. *
  434. * Only MMC1 supports 3.0V. MMC2 will not function if SDVS30 is
  435. * set in HCTL.
  436. */
  437. if (host->id == OMAP_MMC1_DEVID && (((1 << vdd) == MMC_VDD_32_33) ||
  438. ((1 << vdd) == MMC_VDD_33_34)))
  439. reg_val |= SDVS30;
  440. if ((1 << vdd) == MMC_VDD_165_195)
  441. reg_val |= SDVS18;
  442. OMAP_HSMMC_WRITE(host->base, HCTL, reg_val);
  443. OMAP_HSMMC_WRITE(host->base, HCTL,
  444. OMAP_HSMMC_READ(host->base, HCTL) | SDBP);
  445. return 0;
  446. err:
  447. dev_dbg(mmc_dev(host->mmc), "Unable to switch operating voltage\n");
  448. return ret;
  449. }
  450. /*
  451. * Work Item to notify the core about card insertion/removal
  452. */
  453. static void mmc_omap_detect(struct work_struct *work)
  454. {
  455. struct mmc_omap_host *host = container_of(work, struct mmc_omap_host,
  456. mmc_carddetect_work);
  457. sysfs_notify(&host->mmc->class_dev.kobj, NULL, "cover_switch");
  458. if (host->carddetect) {
  459. mmc_detect_change(host->mmc, (HZ * 200) / 1000);
  460. } else {
  461. OMAP_HSMMC_WRITE(host->base, SYSCTL,
  462. OMAP_HSMMC_READ(host->base, SYSCTL) | SRD);
  463. while (OMAP_HSMMC_READ(host->base, SYSCTL) & SRD)
  464. ;
  465. mmc_detect_change(host->mmc, (HZ * 50) / 1000);
  466. }
  467. }
  468. /*
  469. * ISR for handling card insertion and removal
  470. */
  471. static irqreturn_t omap_mmc_cd_handler(int irq, void *dev_id)
  472. {
  473. struct mmc_omap_host *host = (struct mmc_omap_host *)dev_id;
  474. host->carddetect = mmc_slot(host).card_detect(irq);
  475. schedule_work(&host->mmc_carddetect_work);
  476. return IRQ_HANDLED;
  477. }
  478. /*
  479. * DMA call back function
  480. */
  481. static void mmc_omap_dma_cb(int lch, u16 ch_status, void *data)
  482. {
  483. struct mmc_omap_host *host = data;
  484. if (ch_status & OMAP2_DMA_MISALIGNED_ERR_IRQ)
  485. dev_dbg(mmc_dev(host->mmc), "MISALIGNED_ADRS_ERR\n");
  486. if (host->dma_ch < 0)
  487. return;
  488. omap_free_dma(host->dma_ch);
  489. host->dma_ch = -1;
  490. /*
  491. * DMA Callback: run in interrupt context.
  492. * mutex_unlock will through a kernel warning if used.
  493. */
  494. up(&host->sem);
  495. }
  496. /*
  497. * Configure dma src and destination parameters
  498. */
  499. static int mmc_omap_config_dma_param(int sync_dir, struct mmc_omap_host *host,
  500. struct mmc_data *data)
  501. {
  502. if (sync_dir == 0) {
  503. omap_set_dma_dest_params(host->dma_ch, 0,
  504. OMAP_DMA_AMODE_CONSTANT,
  505. (host->mapbase + OMAP_HSMMC_DATA), 0, 0);
  506. omap_set_dma_src_params(host->dma_ch, 0,
  507. OMAP_DMA_AMODE_POST_INC,
  508. sg_dma_address(&data->sg[0]), 0, 0);
  509. } else {
  510. omap_set_dma_src_params(host->dma_ch, 0,
  511. OMAP_DMA_AMODE_CONSTANT,
  512. (host->mapbase + OMAP_HSMMC_DATA), 0, 0);
  513. omap_set_dma_dest_params(host->dma_ch, 0,
  514. OMAP_DMA_AMODE_POST_INC,
  515. sg_dma_address(&data->sg[0]), 0, 0);
  516. }
  517. return 0;
  518. }
  519. /*
  520. * Routine to configure and start DMA for the MMC card
  521. */
  522. static int
  523. mmc_omap_start_dma_transfer(struct mmc_omap_host *host, struct mmc_request *req)
  524. {
  525. int sync_dev, sync_dir = 0;
  526. int dma_ch = 0, ret = 0, err = 1;
  527. struct mmc_data *data = req->data;
  528. /*
  529. * If for some reason the DMA transfer is still active,
  530. * we wait for timeout period and free the dma
  531. */
  532. if (host->dma_ch != -1) {
  533. set_current_state(TASK_UNINTERRUPTIBLE);
  534. schedule_timeout(100);
  535. if (down_trylock(&host->sem)) {
  536. omap_free_dma(host->dma_ch);
  537. host->dma_ch = -1;
  538. up(&host->sem);
  539. return err;
  540. }
  541. } else {
  542. if (down_trylock(&host->sem))
  543. return err;
  544. }
  545. if (!(data->flags & MMC_DATA_WRITE)) {
  546. host->dma_dir = DMA_FROM_DEVICE;
  547. if (host->id == OMAP_MMC1_DEVID)
  548. sync_dev = OMAP24XX_DMA_MMC1_RX;
  549. else
  550. sync_dev = OMAP24XX_DMA_MMC2_RX;
  551. } else {
  552. host->dma_dir = DMA_TO_DEVICE;
  553. if (host->id == OMAP_MMC1_DEVID)
  554. sync_dev = OMAP24XX_DMA_MMC1_TX;
  555. else
  556. sync_dev = OMAP24XX_DMA_MMC2_TX;
  557. }
  558. ret = omap_request_dma(sync_dev, "MMC/SD", mmc_omap_dma_cb,
  559. host, &dma_ch);
  560. if (ret != 0) {
  561. dev_dbg(mmc_dev(host->mmc),
  562. "%s: omap_request_dma() failed with %d\n",
  563. mmc_hostname(host->mmc), ret);
  564. return ret;
  565. }
  566. host->dma_len = dma_map_sg(mmc_dev(host->mmc), data->sg,
  567. data->sg_len, host->dma_dir);
  568. host->dma_ch = dma_ch;
  569. if (!(data->flags & MMC_DATA_WRITE))
  570. mmc_omap_config_dma_param(1, host, data);
  571. else
  572. mmc_omap_config_dma_param(0, host, data);
  573. if ((data->blksz % 4) == 0)
  574. omap_set_dma_transfer_params(dma_ch, OMAP_DMA_DATA_TYPE_S32,
  575. (data->blksz / 4), data->blocks, OMAP_DMA_SYNC_FRAME,
  576. sync_dev, sync_dir);
  577. else
  578. /* REVISIT: The MMC buffer increments only when MSB is written.
  579. * Return error for blksz which is non multiple of four.
  580. */
  581. return -EINVAL;
  582. omap_start_dma(dma_ch);
  583. return 0;
  584. }
  585. static void set_data_timeout(struct mmc_omap_host *host,
  586. struct mmc_request *req)
  587. {
  588. unsigned int timeout, cycle_ns;
  589. uint32_t reg, clkd, dto = 0;
  590. reg = OMAP_HSMMC_READ(host->base, SYSCTL);
  591. clkd = (reg & CLKD_MASK) >> CLKD_SHIFT;
  592. if (clkd == 0)
  593. clkd = 1;
  594. cycle_ns = 1000000000 / (clk_get_rate(host->fclk) / clkd);
  595. timeout = req->data->timeout_ns / cycle_ns;
  596. timeout += req->data->timeout_clks;
  597. if (timeout) {
  598. while ((timeout & 0x80000000) == 0) {
  599. dto += 1;
  600. timeout <<= 1;
  601. }
  602. dto = 31 - dto;
  603. timeout <<= 1;
  604. if (timeout && dto)
  605. dto += 1;
  606. if (dto >= 13)
  607. dto -= 13;
  608. else
  609. dto = 0;
  610. if (dto > 14)
  611. dto = 14;
  612. }
  613. reg &= ~DTO_MASK;
  614. reg |= dto << DTO_SHIFT;
  615. OMAP_HSMMC_WRITE(host->base, SYSCTL, reg);
  616. }
  617. /*
  618. * Configure block length for MMC/SD cards and initiate the transfer.
  619. */
  620. static int
  621. mmc_omap_prepare_data(struct mmc_omap_host *host, struct mmc_request *req)
  622. {
  623. int ret;
  624. host->data = req->data;
  625. if (req->data == NULL) {
  626. host->datadir = OMAP_MMC_DATADIR_NONE;
  627. OMAP_HSMMC_WRITE(host->base, BLK, 0);
  628. return 0;
  629. }
  630. OMAP_HSMMC_WRITE(host->base, BLK, (req->data->blksz)
  631. | (req->data->blocks << 16));
  632. set_data_timeout(host, req);
  633. host->datadir = (req->data->flags & MMC_DATA_WRITE) ?
  634. OMAP_MMC_DATADIR_WRITE : OMAP_MMC_DATADIR_READ;
  635. if (host->use_dma) {
  636. ret = mmc_omap_start_dma_transfer(host, req);
  637. if (ret != 0) {
  638. dev_dbg(mmc_dev(host->mmc), "MMC start dma failure\n");
  639. return ret;
  640. }
  641. }
  642. return 0;
  643. }
  644. /*
  645. * Request function. for read/write operation
  646. */
  647. static void omap_mmc_request(struct mmc_host *mmc, struct mmc_request *req)
  648. {
  649. struct mmc_omap_host *host = mmc_priv(mmc);
  650. WARN_ON(host->mrq != NULL);
  651. host->mrq = req;
  652. mmc_omap_prepare_data(host, req);
  653. mmc_omap_start_command(host, req->cmd, req->data);
  654. }
  655. /* Routine to configure clock values. Exposed API to core */
  656. static void omap_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
  657. {
  658. struct mmc_omap_host *host = mmc_priv(mmc);
  659. u16 dsor = 0;
  660. unsigned long regval;
  661. unsigned long timeout;
  662. switch (ios->power_mode) {
  663. case MMC_POWER_OFF:
  664. mmc_slot(host).set_power(host->dev, host->slot_id, 0, 0);
  665. /*
  666. * Reset bus voltage to 3V if it got set to 1.8V earlier.
  667. * REVISIT: If we are able to detect cards after unplugging
  668. * a 1.8V card, this code should not be needed.
  669. */
  670. if (!(OMAP_HSMMC_READ(host->base, HCTL) & SDVSDET)) {
  671. int vdd = fls(host->mmc->ocr_avail) - 1;
  672. if (omap_mmc_switch_opcond(host, vdd) != 0)
  673. host->mmc->ios.vdd = vdd;
  674. }
  675. break;
  676. case MMC_POWER_UP:
  677. mmc_slot(host).set_power(host->dev, host->slot_id, 1, ios->vdd);
  678. break;
  679. }
  680. switch (mmc->ios.bus_width) {
  681. case MMC_BUS_WIDTH_4:
  682. OMAP_HSMMC_WRITE(host->base, HCTL,
  683. OMAP_HSMMC_READ(host->base, HCTL) | FOUR_BIT);
  684. break;
  685. case MMC_BUS_WIDTH_1:
  686. OMAP_HSMMC_WRITE(host->base, HCTL,
  687. OMAP_HSMMC_READ(host->base, HCTL) & ~FOUR_BIT);
  688. break;
  689. }
  690. if (host->id == OMAP_MMC1_DEVID) {
  691. /* Only MMC1 can operate at 3V/1.8V */
  692. if ((OMAP_HSMMC_READ(host->base, HCTL) & SDVSDET) &&
  693. (ios->vdd == DUAL_VOLT_OCR_BIT)) {
  694. /*
  695. * The mmc_select_voltage fn of the core does
  696. * not seem to set the power_mode to
  697. * MMC_POWER_UP upon recalculating the voltage.
  698. * vdd 1.8v.
  699. */
  700. if (omap_mmc_switch_opcond(host, ios->vdd) != 0)
  701. dev_dbg(mmc_dev(host->mmc),
  702. "Switch operation failed\n");
  703. }
  704. }
  705. if (ios->clock) {
  706. dsor = OMAP_MMC_MASTER_CLOCK / ios->clock;
  707. if (dsor < 1)
  708. dsor = 1;
  709. if (OMAP_MMC_MASTER_CLOCK / dsor > ios->clock)
  710. dsor++;
  711. if (dsor > 250)
  712. dsor = 250;
  713. }
  714. omap_mmc_stop_clock(host);
  715. regval = OMAP_HSMMC_READ(host->base, SYSCTL);
  716. regval = regval & ~(CLKD_MASK);
  717. regval = regval | (dsor << 6) | (DTO << 16);
  718. OMAP_HSMMC_WRITE(host->base, SYSCTL, regval);
  719. OMAP_HSMMC_WRITE(host->base, SYSCTL,
  720. OMAP_HSMMC_READ(host->base, SYSCTL) | ICE);
  721. /* Wait till the ICS bit is set */
  722. timeout = jiffies + msecs_to_jiffies(MMC_TIMEOUT_MS);
  723. while ((OMAP_HSMMC_READ(host->base, SYSCTL) & ICS) != 0x2
  724. && time_before(jiffies, timeout))
  725. msleep(1);
  726. OMAP_HSMMC_WRITE(host->base, SYSCTL,
  727. OMAP_HSMMC_READ(host->base, SYSCTL) | CEN);
  728. if (ios->power_mode == MMC_POWER_ON)
  729. send_init_stream(host);
  730. if (ios->bus_mode == MMC_BUSMODE_OPENDRAIN)
  731. OMAP_HSMMC_WRITE(host->base, CON,
  732. OMAP_HSMMC_READ(host->base, CON) | OD);
  733. }
  734. static int omap_hsmmc_get_cd(struct mmc_host *mmc)
  735. {
  736. struct mmc_omap_host *host = mmc_priv(mmc);
  737. struct omap_mmc_platform_data *pdata = host->pdata;
  738. if (!pdata->slots[0].card_detect)
  739. return -ENOSYS;
  740. return pdata->slots[0].card_detect(pdata->slots[0].card_detect_irq);
  741. }
  742. static int omap_hsmmc_get_ro(struct mmc_host *mmc)
  743. {
  744. struct mmc_omap_host *host = mmc_priv(mmc);
  745. struct omap_mmc_platform_data *pdata = host->pdata;
  746. if (!pdata->slots[0].get_ro)
  747. return -ENOSYS;
  748. return pdata->slots[0].get_ro(host->dev, 0);
  749. }
  750. static struct mmc_host_ops mmc_omap_ops = {
  751. .request = omap_mmc_request,
  752. .set_ios = omap_mmc_set_ios,
  753. .get_cd = omap_hsmmc_get_cd,
  754. .get_ro = omap_hsmmc_get_ro,
  755. /* NYET -- enable_sdio_irq */
  756. };
  757. static int __init omap_mmc_probe(struct platform_device *pdev)
  758. {
  759. struct omap_mmc_platform_data *pdata = pdev->dev.platform_data;
  760. struct mmc_host *mmc;
  761. struct mmc_omap_host *host = NULL;
  762. struct resource *res;
  763. int ret = 0, irq;
  764. u32 hctl, capa;
  765. if (pdata == NULL) {
  766. dev_err(&pdev->dev, "Platform Data is missing\n");
  767. return -ENXIO;
  768. }
  769. if (pdata->nr_slots == 0) {
  770. dev_err(&pdev->dev, "No Slots\n");
  771. return -ENXIO;
  772. }
  773. res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  774. irq = platform_get_irq(pdev, 0);
  775. if (res == NULL || irq < 0)
  776. return -ENXIO;
  777. res = request_mem_region(res->start, res->end - res->start + 1,
  778. pdev->name);
  779. if (res == NULL)
  780. return -EBUSY;
  781. mmc = mmc_alloc_host(sizeof(struct mmc_omap_host), &pdev->dev);
  782. if (!mmc) {
  783. ret = -ENOMEM;
  784. goto err;
  785. }
  786. host = mmc_priv(mmc);
  787. host->mmc = mmc;
  788. host->pdata = pdata;
  789. host->dev = &pdev->dev;
  790. host->use_dma = 1;
  791. host->dev->dma_mask = &pdata->dma_mask;
  792. host->dma_ch = -1;
  793. host->irq = irq;
  794. host->id = pdev->id;
  795. host->slot_id = 0;
  796. host->mapbase = res->start;
  797. host->base = ioremap(host->mapbase, SZ_4K);
  798. platform_set_drvdata(pdev, host);
  799. INIT_WORK(&host->mmc_carddetect_work, mmc_omap_detect);
  800. mmc->ops = &mmc_omap_ops;
  801. mmc->f_min = 400000;
  802. mmc->f_max = 52000000;
  803. sema_init(&host->sem, 1);
  804. host->iclk = clk_get(&pdev->dev, "mmchs_ick");
  805. if (IS_ERR(host->iclk)) {
  806. ret = PTR_ERR(host->iclk);
  807. host->iclk = NULL;
  808. goto err1;
  809. }
  810. host->fclk = clk_get(&pdev->dev, "mmchs_fck");
  811. if (IS_ERR(host->fclk)) {
  812. ret = PTR_ERR(host->fclk);
  813. host->fclk = NULL;
  814. clk_put(host->iclk);
  815. goto err1;
  816. }
  817. if (clk_enable(host->fclk) != 0) {
  818. clk_put(host->iclk);
  819. clk_put(host->fclk);
  820. goto err1;
  821. }
  822. if (clk_enable(host->iclk) != 0) {
  823. clk_disable(host->fclk);
  824. clk_put(host->iclk);
  825. clk_put(host->fclk);
  826. goto err1;
  827. }
  828. host->dbclk = clk_get(&pdev->dev, "mmchsdb_fck");
  829. /*
  830. * MMC can still work without debounce clock.
  831. */
  832. if (IS_ERR(host->dbclk))
  833. dev_warn(mmc_dev(host->mmc), "Failed to get debounce clock\n");
  834. else
  835. if (clk_enable(host->dbclk) != 0)
  836. dev_dbg(mmc_dev(host->mmc), "Enabling debounce"
  837. " clk failed\n");
  838. else
  839. host->dbclk_enabled = 1;
  840. #ifdef CONFIG_MMC_BLOCK_BOUNCE
  841. mmc->max_phys_segs = 1;
  842. mmc->max_hw_segs = 1;
  843. #endif
  844. mmc->max_blk_size = 512; /* Block Length at max can be 1024 */
  845. mmc->max_blk_count = 0xFFFF; /* No. of Blocks is 16 bits */
  846. mmc->max_req_size = mmc->max_blk_size * mmc->max_blk_count;
  847. mmc->max_seg_size = mmc->max_req_size;
  848. mmc->ocr_avail = mmc_slot(host).ocr_mask;
  849. mmc->caps |= MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED;
  850. if (pdata->slots[host->slot_id].wires >= 4)
  851. mmc->caps |= MMC_CAP_4_BIT_DATA;
  852. /* Only MMC1 supports 3.0V */
  853. if (host->id == OMAP_MMC1_DEVID) {
  854. hctl = SDVS30;
  855. capa = VS30 | VS18;
  856. } else {
  857. hctl = SDVS18;
  858. capa = VS18;
  859. }
  860. OMAP_HSMMC_WRITE(host->base, HCTL,
  861. OMAP_HSMMC_READ(host->base, HCTL) | hctl);
  862. OMAP_HSMMC_WRITE(host->base, CAPA,
  863. OMAP_HSMMC_READ(host->base, CAPA) | capa);
  864. /* Set the controller to AUTO IDLE mode */
  865. OMAP_HSMMC_WRITE(host->base, SYSCONFIG,
  866. OMAP_HSMMC_READ(host->base, SYSCONFIG) | AUTOIDLE);
  867. /* Set SD bus power bit */
  868. OMAP_HSMMC_WRITE(host->base, HCTL,
  869. OMAP_HSMMC_READ(host->base, HCTL) | SDBP);
  870. /* Request IRQ for MMC operations */
  871. ret = request_irq(host->irq, mmc_omap_irq, IRQF_DISABLED,
  872. mmc_hostname(mmc), host);
  873. if (ret) {
  874. dev_dbg(mmc_dev(host->mmc), "Unable to grab HSMMC IRQ\n");
  875. goto err_irq;
  876. }
  877. if (pdata->init != NULL) {
  878. if (pdata->init(&pdev->dev) != 0) {
  879. dev_dbg(mmc_dev(host->mmc),
  880. "Unable to configure MMC IRQs\n");
  881. goto err_irq_cd_init;
  882. }
  883. }
  884. /* Request IRQ for card detect */
  885. if ((mmc_slot(host).card_detect_irq) && (mmc_slot(host).card_detect)) {
  886. ret = request_irq(mmc_slot(host).card_detect_irq,
  887. omap_mmc_cd_handler,
  888. IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING
  889. | IRQF_DISABLED,
  890. mmc_hostname(mmc), host);
  891. if (ret) {
  892. dev_dbg(mmc_dev(host->mmc),
  893. "Unable to grab MMC CD IRQ\n");
  894. goto err_irq_cd;
  895. }
  896. }
  897. OMAP_HSMMC_WRITE(host->base, ISE, INT_EN_MASK);
  898. OMAP_HSMMC_WRITE(host->base, IE, INT_EN_MASK);
  899. mmc_add_host(mmc);
  900. if (host->pdata->slots[host->slot_id].name != NULL) {
  901. ret = device_create_file(&mmc->class_dev, &dev_attr_slot_name);
  902. if (ret < 0)
  903. goto err_slot_name;
  904. }
  905. if (mmc_slot(host).card_detect_irq && mmc_slot(host).card_detect &&
  906. host->pdata->slots[host->slot_id].get_cover_state) {
  907. ret = device_create_file(&mmc->class_dev,
  908. &dev_attr_cover_switch);
  909. if (ret < 0)
  910. goto err_cover_switch;
  911. }
  912. return 0;
  913. err_cover_switch:
  914. device_remove_file(&mmc->class_dev, &dev_attr_cover_switch);
  915. err_slot_name:
  916. mmc_remove_host(mmc);
  917. err_irq_cd:
  918. free_irq(mmc_slot(host).card_detect_irq, host);
  919. err_irq_cd_init:
  920. free_irq(host->irq, host);
  921. err_irq:
  922. clk_disable(host->fclk);
  923. clk_disable(host->iclk);
  924. clk_put(host->fclk);
  925. clk_put(host->iclk);
  926. if (host->dbclk_enabled) {
  927. clk_disable(host->dbclk);
  928. clk_put(host->dbclk);
  929. }
  930. err1:
  931. iounmap(host->base);
  932. err:
  933. dev_dbg(mmc_dev(host->mmc), "Probe Failed\n");
  934. release_mem_region(res->start, res->end - res->start + 1);
  935. if (host)
  936. mmc_free_host(mmc);
  937. return ret;
  938. }
  939. static int omap_mmc_remove(struct platform_device *pdev)
  940. {
  941. struct mmc_omap_host *host = platform_get_drvdata(pdev);
  942. struct resource *res;
  943. if (host) {
  944. mmc_remove_host(host->mmc);
  945. if (host->pdata->cleanup)
  946. host->pdata->cleanup(&pdev->dev);
  947. free_irq(host->irq, host);
  948. if (mmc_slot(host).card_detect_irq)
  949. free_irq(mmc_slot(host).card_detect_irq, host);
  950. flush_scheduled_work();
  951. clk_disable(host->fclk);
  952. clk_disable(host->iclk);
  953. clk_put(host->fclk);
  954. clk_put(host->iclk);
  955. if (host->dbclk_enabled) {
  956. clk_disable(host->dbclk);
  957. clk_put(host->dbclk);
  958. }
  959. mmc_free_host(host->mmc);
  960. iounmap(host->base);
  961. }
  962. res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  963. if (res)
  964. release_mem_region(res->start, res->end - res->start + 1);
  965. platform_set_drvdata(pdev, NULL);
  966. return 0;
  967. }
  968. #ifdef CONFIG_PM
  969. static int omap_mmc_suspend(struct platform_device *pdev, pm_message_t state)
  970. {
  971. int ret = 0;
  972. struct mmc_omap_host *host = platform_get_drvdata(pdev);
  973. if (host && host->suspended)
  974. return 0;
  975. if (host) {
  976. ret = mmc_suspend_host(host->mmc, state);
  977. if (ret == 0) {
  978. host->suspended = 1;
  979. OMAP_HSMMC_WRITE(host->base, ISE, 0);
  980. OMAP_HSMMC_WRITE(host->base, IE, 0);
  981. if (host->pdata->suspend) {
  982. ret = host->pdata->suspend(&pdev->dev,
  983. host->slot_id);
  984. if (ret)
  985. dev_dbg(mmc_dev(host->mmc),
  986. "Unable to handle MMC board"
  987. " level suspend\n");
  988. }
  989. if (!(OMAP_HSMMC_READ(host->base, HCTL) & SDVSDET)) {
  990. OMAP_HSMMC_WRITE(host->base, HCTL,
  991. OMAP_HSMMC_READ(host->base, HCTL)
  992. & SDVSCLR);
  993. OMAP_HSMMC_WRITE(host->base, HCTL,
  994. OMAP_HSMMC_READ(host->base, HCTL)
  995. | SDVS30);
  996. OMAP_HSMMC_WRITE(host->base, HCTL,
  997. OMAP_HSMMC_READ(host->base, HCTL)
  998. | SDBP);
  999. }
  1000. clk_disable(host->fclk);
  1001. clk_disable(host->iclk);
  1002. clk_disable(host->dbclk);
  1003. }
  1004. }
  1005. return ret;
  1006. }
  1007. /* Routine to resume the MMC device */
  1008. static int omap_mmc_resume(struct platform_device *pdev)
  1009. {
  1010. int ret = 0;
  1011. struct mmc_omap_host *host = platform_get_drvdata(pdev);
  1012. if (host && !host->suspended)
  1013. return 0;
  1014. if (host) {
  1015. ret = clk_enable(host->fclk);
  1016. if (ret)
  1017. goto clk_en_err;
  1018. ret = clk_enable(host->iclk);
  1019. if (ret) {
  1020. clk_disable(host->fclk);
  1021. clk_put(host->fclk);
  1022. goto clk_en_err;
  1023. }
  1024. if (clk_enable(host->dbclk) != 0)
  1025. dev_dbg(mmc_dev(host->mmc),
  1026. "Enabling debounce clk failed\n");
  1027. if (host->pdata->resume) {
  1028. ret = host->pdata->resume(&pdev->dev, host->slot_id);
  1029. if (ret)
  1030. dev_dbg(mmc_dev(host->mmc),
  1031. "Unmask interrupt failed\n");
  1032. }
  1033. /* Notify the core to resume the host */
  1034. ret = mmc_resume_host(host->mmc);
  1035. if (ret == 0)
  1036. host->suspended = 0;
  1037. }
  1038. return ret;
  1039. clk_en_err:
  1040. dev_dbg(mmc_dev(host->mmc),
  1041. "Failed to enable MMC clocks during resume\n");
  1042. return ret;
  1043. }
  1044. #else
  1045. #define omap_mmc_suspend NULL
  1046. #define omap_mmc_resume NULL
  1047. #endif
  1048. static struct platform_driver omap_mmc_driver = {
  1049. .probe = omap_mmc_probe,
  1050. .remove = omap_mmc_remove,
  1051. .suspend = omap_mmc_suspend,
  1052. .resume = omap_mmc_resume,
  1053. .driver = {
  1054. .name = DRIVER_NAME,
  1055. .owner = THIS_MODULE,
  1056. },
  1057. };
  1058. static int __init omap_mmc_init(void)
  1059. {
  1060. /* Register the MMC driver */
  1061. return platform_driver_register(&omap_mmc_driver);
  1062. }
  1063. static void __exit omap_mmc_cleanup(void)
  1064. {
  1065. /* Unregister MMC driver */
  1066. platform_driver_unregister(&omap_mmc_driver);
  1067. }
  1068. module_init(omap_mmc_init);
  1069. module_exit(omap_mmc_cleanup);
  1070. MODULE_DESCRIPTION("OMAP High Speed Multimedia Card driver");
  1071. MODULE_LICENSE("GPL");
  1072. MODULE_ALIAS("platform:" DRIVER_NAME);
  1073. MODULE_AUTHOR("Texas Instruments Inc");