sdhci-s3c.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659
  1. /* linux/drivers/mmc/host/sdhci-s3c.c
  2. *
  3. * Copyright 2008 Openmoko Inc.
  4. * Copyright 2008 Simtec Electronics
  5. * Ben Dooks <ben@simtec.co.uk>
  6. * http://armlinux.simtec.co.uk/
  7. *
  8. * SDHCI (HSMMC) support for Samsung SoC
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License version 2 as
  12. * published by the Free Software Foundation.
  13. */
  14. #include <linux/delay.h>
  15. #include <linux/dma-mapping.h>
  16. #include <linux/platform_device.h>
  17. #include <linux/slab.h>
  18. #include <linux/clk.h>
  19. #include <linux/io.h>
  20. #include <linux/gpio.h>
  21. #include <linux/mmc/host.h>
  22. #include <plat/sdhci.h>
  23. #include <plat/regs-sdhci.h>
  24. #include "sdhci.h"
  25. #define MAX_BUS_CLK (4)
  26. /**
  27. * struct sdhci_s3c - S3C SDHCI instance
  28. * @host: The SDHCI host created
  29. * @pdev: The platform device we where created from.
  30. * @ioarea: The resource created when we claimed the IO area.
  31. * @pdata: The platform data for this controller.
  32. * @cur_clk: The index of the current bus clock.
  33. * @clk_io: The clock for the internal bus interface.
  34. * @clk_bus: The clocks that are available for the SD/MMC bus clock.
  35. */
  36. struct sdhci_s3c {
  37. struct sdhci_host *host;
  38. struct platform_device *pdev;
  39. struct resource *ioarea;
  40. struct s3c_sdhci_platdata *pdata;
  41. unsigned int cur_clk;
  42. int ext_cd_irq;
  43. int ext_cd_gpio;
  44. struct clk *clk_io;
  45. struct clk *clk_bus[MAX_BUS_CLK];
  46. };
  47. static inline struct sdhci_s3c *to_s3c(struct sdhci_host *host)
  48. {
  49. return sdhci_priv(host);
  50. }
  51. /**
  52. * get_curclk - convert ctrl2 register to clock source number
  53. * @ctrl2: Control2 register value.
  54. */
  55. static u32 get_curclk(u32 ctrl2)
  56. {
  57. ctrl2 &= S3C_SDHCI_CTRL2_SELBASECLK_MASK;
  58. ctrl2 >>= S3C_SDHCI_CTRL2_SELBASECLK_SHIFT;
  59. return ctrl2;
  60. }
  61. static void sdhci_s3c_check_sclk(struct sdhci_host *host)
  62. {
  63. struct sdhci_s3c *ourhost = to_s3c(host);
  64. u32 tmp = readl(host->ioaddr + S3C_SDHCI_CONTROL2);
  65. if (get_curclk(tmp) != ourhost->cur_clk) {
  66. dev_dbg(&ourhost->pdev->dev, "restored ctrl2 clock setting\n");
  67. tmp &= ~S3C_SDHCI_CTRL2_SELBASECLK_MASK;
  68. tmp |= ourhost->cur_clk << S3C_SDHCI_CTRL2_SELBASECLK_SHIFT;
  69. writel(tmp, host->ioaddr + 0x80);
  70. }
  71. }
  72. /**
  73. * sdhci_s3c_get_max_clk - callback to get maximum clock frequency.
  74. * @host: The SDHCI host instance.
  75. *
  76. * Callback to return the maximum clock rate acheivable by the controller.
  77. */
  78. static unsigned int sdhci_s3c_get_max_clk(struct sdhci_host *host)
  79. {
  80. struct sdhci_s3c *ourhost = to_s3c(host);
  81. struct clk *busclk;
  82. unsigned int rate, max;
  83. int clk;
  84. /* note, a reset will reset the clock source */
  85. sdhci_s3c_check_sclk(host);
  86. for (max = 0, clk = 0; clk < MAX_BUS_CLK; clk++) {
  87. busclk = ourhost->clk_bus[clk];
  88. if (!busclk)
  89. continue;
  90. rate = clk_get_rate(busclk);
  91. if (rate > max)
  92. max = rate;
  93. }
  94. return max;
  95. }
  96. /**
  97. * sdhci_s3c_consider_clock - consider one the bus clocks for current setting
  98. * @ourhost: Our SDHCI instance.
  99. * @src: The source clock index.
  100. * @wanted: The clock frequency wanted.
  101. */
  102. static unsigned int sdhci_s3c_consider_clock(struct sdhci_s3c *ourhost,
  103. unsigned int src,
  104. unsigned int wanted)
  105. {
  106. unsigned long rate;
  107. struct clk *clksrc = ourhost->clk_bus[src];
  108. int div;
  109. if (!clksrc)
  110. return UINT_MAX;
  111. /*
  112. * Clock divider's step is different as 1 from that of host controller
  113. * when 'clk_type' is S3C_SDHCI_CLK_DIV_EXTERNAL.
  114. */
  115. if (ourhost->pdata->clk_type) {
  116. rate = clk_round_rate(clksrc, wanted);
  117. return wanted - rate;
  118. }
  119. rate = clk_get_rate(clksrc);
  120. for (div = 1; div < 256; div *= 2) {
  121. if ((rate / div) <= wanted)
  122. break;
  123. }
  124. dev_dbg(&ourhost->pdev->dev, "clk %d: rate %ld, want %d, got %ld\n",
  125. src, rate, wanted, rate / div);
  126. return (wanted - (rate / div));
  127. }
  128. /**
  129. * sdhci_s3c_set_clock - callback on clock change
  130. * @host: The SDHCI host being changed
  131. * @clock: The clock rate being requested.
  132. *
  133. * When the card's clock is going to be changed, look at the new frequency
  134. * and find the best clock source to go with it.
  135. */
  136. static void sdhci_s3c_set_clock(struct sdhci_host *host, unsigned int clock)
  137. {
  138. struct sdhci_s3c *ourhost = to_s3c(host);
  139. unsigned int best = UINT_MAX;
  140. unsigned int delta;
  141. int best_src = 0;
  142. int src;
  143. u32 ctrl;
  144. /* don't bother if the clock is going off. */
  145. if (clock == 0)
  146. return;
  147. for (src = 0; src < MAX_BUS_CLK; src++) {
  148. delta = sdhci_s3c_consider_clock(ourhost, src, clock);
  149. if (delta < best) {
  150. best = delta;
  151. best_src = src;
  152. }
  153. }
  154. dev_dbg(&ourhost->pdev->dev,
  155. "selected source %d, clock %d, delta %d\n",
  156. best_src, clock, best);
  157. /* select the new clock source */
  158. if (ourhost->cur_clk != best_src) {
  159. struct clk *clk = ourhost->clk_bus[best_src];
  160. /* turn clock off to card before changing clock source */
  161. writew(0, host->ioaddr + SDHCI_CLOCK_CONTROL);
  162. ourhost->cur_clk = best_src;
  163. host->max_clk = clk_get_rate(clk);
  164. ctrl = readl(host->ioaddr + S3C_SDHCI_CONTROL2);
  165. ctrl &= ~S3C_SDHCI_CTRL2_SELBASECLK_MASK;
  166. ctrl |= best_src << S3C_SDHCI_CTRL2_SELBASECLK_SHIFT;
  167. writel(ctrl, host->ioaddr + S3C_SDHCI_CONTROL2);
  168. }
  169. /* reconfigure the hardware for new clock rate */
  170. {
  171. struct mmc_ios ios;
  172. ios.clock = clock;
  173. if (ourhost->pdata->cfg_card)
  174. (ourhost->pdata->cfg_card)(ourhost->pdev, host->ioaddr,
  175. &ios, NULL);
  176. }
  177. }
  178. /**
  179. * sdhci_s3c_get_min_clock - callback to get minimal supported clock value
  180. * @host: The SDHCI host being queried
  181. *
  182. * To init mmc host properly a minimal clock value is needed. For high system
  183. * bus clock's values the standard formula gives values out of allowed range.
  184. * The clock still can be set to lower values, if clock source other then
  185. * system bus is selected.
  186. */
  187. static unsigned int sdhci_s3c_get_min_clock(struct sdhci_host *host)
  188. {
  189. struct sdhci_s3c *ourhost = to_s3c(host);
  190. unsigned int delta, min = UINT_MAX;
  191. int src;
  192. for (src = 0; src < MAX_BUS_CLK; src++) {
  193. delta = sdhci_s3c_consider_clock(ourhost, src, 0);
  194. if (delta == UINT_MAX)
  195. continue;
  196. /* delta is a negative value in this case */
  197. if (-delta < min)
  198. min = -delta;
  199. }
  200. return min;
  201. }
  202. /* sdhci_cmu_get_max_clk - callback to get maximum clock frequency.*/
  203. static unsigned int sdhci_cmu_get_max_clock(struct sdhci_host *host)
  204. {
  205. struct sdhci_s3c *ourhost = to_s3c(host);
  206. return clk_round_rate(ourhost->clk_bus[ourhost->cur_clk], UINT_MAX);
  207. }
  208. /* sdhci_cmu_get_min_clock - callback to get minimal supported clock value. */
  209. static unsigned int sdhci_cmu_get_min_clock(struct sdhci_host *host)
  210. {
  211. struct sdhci_s3c *ourhost = to_s3c(host);
  212. /*
  213. * initial clock can be in the frequency range of
  214. * 100KHz-400KHz, so we set it as max value.
  215. */
  216. return clk_round_rate(ourhost->clk_bus[ourhost->cur_clk], 400000);
  217. }
  218. /* sdhci_cmu_set_clock - callback on clock change.*/
  219. static void sdhci_cmu_set_clock(struct sdhci_host *host, unsigned int clock)
  220. {
  221. struct sdhci_s3c *ourhost = to_s3c(host);
  222. /* don't bother if the clock is going off */
  223. if (clock == 0)
  224. return;
  225. sdhci_s3c_set_clock(host, clock);
  226. clk_set_rate(ourhost->clk_bus[ourhost->cur_clk], clock);
  227. host->clock = clock;
  228. }
  229. /**
  230. * sdhci_s3c_platform_8bit_width - support 8bit buswidth
  231. * @host: The SDHCI host being queried
  232. * @width: MMC_BUS_WIDTH_ macro for the bus width being requested
  233. *
  234. * We have 8-bit width support but is not a v3 controller.
  235. * So we add platform_8bit_width() and support 8bit width.
  236. */
  237. static int sdhci_s3c_platform_8bit_width(struct sdhci_host *host, int width)
  238. {
  239. u8 ctrl;
  240. ctrl = sdhci_readb(host, SDHCI_HOST_CONTROL);
  241. switch (width) {
  242. case MMC_BUS_WIDTH_8:
  243. ctrl |= SDHCI_CTRL_8BITBUS;
  244. ctrl &= ~SDHCI_CTRL_4BITBUS;
  245. break;
  246. case MMC_BUS_WIDTH_4:
  247. ctrl |= SDHCI_CTRL_4BITBUS;
  248. ctrl &= ~SDHCI_CTRL_8BITBUS;
  249. break;
  250. default:
  251. break;
  252. }
  253. sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL);
  254. return 0;
  255. }
  256. static struct sdhci_ops sdhci_s3c_ops = {
  257. .get_max_clock = sdhci_s3c_get_max_clk,
  258. .set_clock = sdhci_s3c_set_clock,
  259. .get_min_clock = sdhci_s3c_get_min_clock,
  260. .platform_8bit_width = sdhci_s3c_platform_8bit_width,
  261. };
  262. static void sdhci_s3c_notify_change(struct platform_device *dev, int state)
  263. {
  264. struct sdhci_host *host = platform_get_drvdata(dev);
  265. unsigned long flags;
  266. if (host) {
  267. spin_lock_irqsave(&host->lock, flags);
  268. if (state) {
  269. dev_dbg(&dev->dev, "card inserted.\n");
  270. host->flags &= ~SDHCI_DEVICE_DEAD;
  271. host->quirks |= SDHCI_QUIRK_BROKEN_CARD_DETECTION;
  272. } else {
  273. dev_dbg(&dev->dev, "card removed.\n");
  274. host->flags |= SDHCI_DEVICE_DEAD;
  275. host->quirks &= ~SDHCI_QUIRK_BROKEN_CARD_DETECTION;
  276. }
  277. tasklet_schedule(&host->card_tasklet);
  278. spin_unlock_irqrestore(&host->lock, flags);
  279. }
  280. }
  281. static irqreturn_t sdhci_s3c_gpio_card_detect_thread(int irq, void *dev_id)
  282. {
  283. struct sdhci_s3c *sc = dev_id;
  284. int status = gpio_get_value(sc->ext_cd_gpio);
  285. if (sc->pdata->ext_cd_gpio_invert)
  286. status = !status;
  287. sdhci_s3c_notify_change(sc->pdev, status);
  288. return IRQ_HANDLED;
  289. }
  290. static void sdhci_s3c_setup_card_detect_gpio(struct sdhci_s3c *sc)
  291. {
  292. struct s3c_sdhci_platdata *pdata = sc->pdata;
  293. struct device *dev = &sc->pdev->dev;
  294. if (gpio_request(pdata->ext_cd_gpio, "SDHCI EXT CD") == 0) {
  295. sc->ext_cd_gpio = pdata->ext_cd_gpio;
  296. sc->ext_cd_irq = gpio_to_irq(pdata->ext_cd_gpio);
  297. if (sc->ext_cd_irq &&
  298. request_threaded_irq(sc->ext_cd_irq, NULL,
  299. sdhci_s3c_gpio_card_detect_thread,
  300. IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
  301. dev_name(dev), sc) == 0) {
  302. int status = gpio_get_value(sc->ext_cd_gpio);
  303. if (pdata->ext_cd_gpio_invert)
  304. status = !status;
  305. sdhci_s3c_notify_change(sc->pdev, status);
  306. } else {
  307. dev_warn(dev, "cannot request irq for card detect\n");
  308. sc->ext_cd_irq = 0;
  309. }
  310. } else {
  311. dev_err(dev, "cannot request gpio for card detect\n");
  312. }
  313. }
  314. static int __devinit sdhci_s3c_probe(struct platform_device *pdev)
  315. {
  316. struct s3c_sdhci_platdata *pdata = pdev->dev.platform_data;
  317. struct device *dev = &pdev->dev;
  318. struct sdhci_host *host;
  319. struct sdhci_s3c *sc;
  320. struct resource *res;
  321. int ret, irq, ptr, clks;
  322. if (!pdata) {
  323. dev_err(dev, "no device data specified\n");
  324. return -ENOENT;
  325. }
  326. irq = platform_get_irq(pdev, 0);
  327. if (irq < 0) {
  328. dev_err(dev, "no irq specified\n");
  329. return irq;
  330. }
  331. res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  332. if (!res) {
  333. dev_err(dev, "no memory specified\n");
  334. return -ENOENT;
  335. }
  336. host = sdhci_alloc_host(dev, sizeof(struct sdhci_s3c));
  337. if (IS_ERR(host)) {
  338. dev_err(dev, "sdhci_alloc_host() failed\n");
  339. return PTR_ERR(host);
  340. }
  341. sc = sdhci_priv(host);
  342. sc->host = host;
  343. sc->pdev = pdev;
  344. sc->pdata = pdata;
  345. sc->ext_cd_gpio = -1; /* invalid gpio number */
  346. platform_set_drvdata(pdev, host);
  347. sc->clk_io = clk_get(dev, "hsmmc");
  348. if (IS_ERR(sc->clk_io)) {
  349. dev_err(dev, "failed to get io clock\n");
  350. ret = PTR_ERR(sc->clk_io);
  351. goto err_io_clk;
  352. }
  353. /* enable the local io clock and keep it running for the moment. */
  354. clk_enable(sc->clk_io);
  355. for (clks = 0, ptr = 0; ptr < MAX_BUS_CLK; ptr++) {
  356. struct clk *clk;
  357. char *name = pdata->clocks[ptr];
  358. if (name == NULL)
  359. continue;
  360. clk = clk_get(dev, name);
  361. if (IS_ERR(clk)) {
  362. dev_err(dev, "failed to get clock %s\n", name);
  363. continue;
  364. }
  365. clks++;
  366. sc->clk_bus[ptr] = clk;
  367. /*
  368. * save current clock index to know which clock bus
  369. * is used later in overriding functions.
  370. */
  371. sc->cur_clk = ptr;
  372. clk_enable(clk);
  373. dev_info(dev, "clock source %d: %s (%ld Hz)\n",
  374. ptr, name, clk_get_rate(clk));
  375. }
  376. if (clks == 0) {
  377. dev_err(dev, "failed to find any bus clocks\n");
  378. ret = -ENOENT;
  379. goto err_no_busclks;
  380. }
  381. sc->ioarea = request_mem_region(res->start, resource_size(res),
  382. mmc_hostname(host->mmc));
  383. if (!sc->ioarea) {
  384. dev_err(dev, "failed to reserve register area\n");
  385. ret = -ENXIO;
  386. goto err_req_regs;
  387. }
  388. host->ioaddr = ioremap_nocache(res->start, resource_size(res));
  389. if (!host->ioaddr) {
  390. dev_err(dev, "failed to map registers\n");
  391. ret = -ENXIO;
  392. goto err_req_regs;
  393. }
  394. /* Ensure we have minimal gpio selected CMD/CLK/Detect */
  395. if (pdata->cfg_gpio)
  396. pdata->cfg_gpio(pdev, pdata->max_width);
  397. host->hw_name = "samsung-hsmmc";
  398. host->ops = &sdhci_s3c_ops;
  399. host->quirks = 0;
  400. host->irq = irq;
  401. /* Setup quirks for the controller */
  402. host->quirks |= SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC;
  403. host->quirks |= SDHCI_QUIRK_NO_HISPD_BIT;
  404. #ifndef CONFIG_MMC_SDHCI_S3C_DMA
  405. /* we currently see overruns on errors, so disable the SDMA
  406. * support as well. */
  407. host->quirks |= SDHCI_QUIRK_BROKEN_DMA;
  408. #endif /* CONFIG_MMC_SDHCI_S3C_DMA */
  409. /* It seems we do not get an DATA transfer complete on non-busy
  410. * transfers, not sure if this is a problem with this specific
  411. * SDHCI block, or a missing configuration that needs to be set. */
  412. host->quirks |= SDHCI_QUIRK_NO_BUSY_IRQ;
  413. /* This host supports the Auto CMD12 */
  414. host->quirks |= SDHCI_QUIRK_MULTIBLOCK_READ_ACMD12;
  415. if (pdata->cd_type == S3C_SDHCI_CD_NONE ||
  416. pdata->cd_type == S3C_SDHCI_CD_PERMANENT)
  417. host->quirks |= SDHCI_QUIRK_BROKEN_CARD_DETECTION;
  418. if (pdata->cd_type == S3C_SDHCI_CD_PERMANENT)
  419. host->mmc->caps = MMC_CAP_NONREMOVABLE;
  420. if (pdata->host_caps)
  421. host->mmc->caps |= pdata->host_caps;
  422. host->quirks |= (SDHCI_QUIRK_32BIT_DMA_ADDR |
  423. SDHCI_QUIRK_32BIT_DMA_SIZE);
  424. /* HSMMC on Samsung SoCs uses SDCLK as timeout clock */
  425. host->quirks |= SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK;
  426. /*
  427. * If controller does not have internal clock divider,
  428. * we can use overriding functions instead of default.
  429. */
  430. if (pdata->clk_type) {
  431. sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
  432. sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
  433. sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
  434. }
  435. /* It supports additional host capabilities if needed */
  436. if (pdata->host_caps)
  437. host->mmc->caps |= pdata->host_caps;
  438. ret = sdhci_add_host(host);
  439. if (ret) {
  440. dev_err(dev, "sdhci_add_host() failed\n");
  441. goto err_add_host;
  442. }
  443. /* The following two methods of card detection might call
  444. sdhci_s3c_notify_change() immediately, so they can be called
  445. only after sdhci_add_host(). Setup errors are ignored. */
  446. if (pdata->cd_type == S3C_SDHCI_CD_EXTERNAL && pdata->ext_cd_init)
  447. pdata->ext_cd_init(&sdhci_s3c_notify_change);
  448. if (pdata->cd_type == S3C_SDHCI_CD_GPIO &&
  449. gpio_is_valid(pdata->ext_cd_gpio))
  450. sdhci_s3c_setup_card_detect_gpio(sc);
  451. return 0;
  452. err_add_host:
  453. release_resource(sc->ioarea);
  454. kfree(sc->ioarea);
  455. err_req_regs:
  456. for (ptr = 0; ptr < MAX_BUS_CLK; ptr++) {
  457. clk_disable(sc->clk_bus[ptr]);
  458. clk_put(sc->clk_bus[ptr]);
  459. }
  460. err_no_busclks:
  461. clk_disable(sc->clk_io);
  462. clk_put(sc->clk_io);
  463. err_io_clk:
  464. sdhci_free_host(host);
  465. return ret;
  466. }
  467. static int __devexit sdhci_s3c_remove(struct platform_device *pdev)
  468. {
  469. struct s3c_sdhci_platdata *pdata = pdev->dev.platform_data;
  470. struct sdhci_host *host = platform_get_drvdata(pdev);
  471. struct sdhci_s3c *sc = sdhci_priv(host);
  472. int ptr;
  473. if (pdata->cd_type == S3C_SDHCI_CD_EXTERNAL && pdata->ext_cd_cleanup)
  474. pdata->ext_cd_cleanup(&sdhci_s3c_notify_change);
  475. if (sc->ext_cd_irq)
  476. free_irq(sc->ext_cd_irq, sc);
  477. if (gpio_is_valid(sc->ext_cd_gpio))
  478. gpio_free(sc->ext_cd_gpio);
  479. sdhci_remove_host(host, 1);
  480. for (ptr = 0; ptr < 3; ptr++) {
  481. if (sc->clk_bus[ptr]) {
  482. clk_disable(sc->clk_bus[ptr]);
  483. clk_put(sc->clk_bus[ptr]);
  484. }
  485. }
  486. clk_disable(sc->clk_io);
  487. clk_put(sc->clk_io);
  488. iounmap(host->ioaddr);
  489. release_resource(sc->ioarea);
  490. kfree(sc->ioarea);
  491. sdhci_free_host(host);
  492. platform_set_drvdata(pdev, NULL);
  493. return 0;
  494. }
  495. #ifdef CONFIG_PM
  496. static int sdhci_s3c_suspend(struct platform_device *dev, pm_message_t pm)
  497. {
  498. struct sdhci_host *host = platform_get_drvdata(dev);
  499. sdhci_suspend_host(host, pm);
  500. return 0;
  501. }
  502. static int sdhci_s3c_resume(struct platform_device *dev)
  503. {
  504. struct sdhci_host *host = platform_get_drvdata(dev);
  505. sdhci_resume_host(host);
  506. return 0;
  507. }
  508. #else
  509. #define sdhci_s3c_suspend NULL
  510. #define sdhci_s3c_resume NULL
  511. #endif
  512. static struct platform_driver sdhci_s3c_driver = {
  513. .probe = sdhci_s3c_probe,
  514. .remove = __devexit_p(sdhci_s3c_remove),
  515. .suspend = sdhci_s3c_suspend,
  516. .resume = sdhci_s3c_resume,
  517. .driver = {
  518. .owner = THIS_MODULE,
  519. .name = "s3c-sdhci",
  520. },
  521. };
  522. static int __init sdhci_s3c_init(void)
  523. {
  524. return platform_driver_register(&sdhci_s3c_driver);
  525. }
  526. static void __exit sdhci_s3c_exit(void)
  527. {
  528. platform_driver_unregister(&sdhci_s3c_driver);
  529. }
  530. module_init(sdhci_s3c_init);
  531. module_exit(sdhci_s3c_exit);
  532. MODULE_DESCRIPTION("Samsung SDHCI (HSMMC) glue");
  533. MODULE_AUTHOR("Ben Dooks, <ben@simtec.co.uk>");
  534. MODULE_LICENSE("GPL v2");
  535. MODULE_ALIAS("platform:s3c-sdhci");