sdhci-esdhc-imx.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590
  1. /*
  2. * Freescale eSDHC i.MX controller driver for the platform bus.
  3. *
  4. * derived from the OF-version.
  5. *
  6. * Copyright (c) 2010 Pengutronix e.K.
  7. * Author: Wolfram Sang <w.sang@pengutronix.de>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License.
  12. */
  13. #include <linux/io.h>
  14. #include <linux/delay.h>
  15. #include <linux/err.h>
  16. #include <linux/clk.h>
  17. #include <linux/gpio.h>
  18. #include <linux/module.h>
  19. #include <linux/slab.h>
  20. #include <linux/mmc/host.h>
  21. #include <linux/mmc/mmc.h>
  22. #include <linux/mmc/sdio.h>
  23. #include <linux/of.h>
  24. #include <linux/of_device.h>
  25. #include <linux/of_gpio.h>
  26. #include <mach/esdhc.h>
  27. #include "sdhci-pltfm.h"
  28. #include "sdhci-esdhc.h"
  29. #define SDHCI_CTRL_D3CD 0x08
  30. /* VENDOR SPEC register */
  31. #define SDHCI_VENDOR_SPEC 0xC0
  32. #define SDHCI_VENDOR_SPEC_SDIO_QUIRK 0x00000002
  33. /*
  34. * There is an INT DMA ERR mis-match between eSDHC and STD SDHC SPEC:
  35. * Bit25 is used in STD SPEC, and is reserved in fsl eSDHC design,
  36. * but bit28 is used as the INT DMA ERR in fsl eSDHC design.
  37. * Define this macro DMA error INT for fsl eSDHC
  38. */
  39. #define SDHCI_INT_VENDOR_SPEC_DMA_ERR 0x10000000
  40. /*
  41. * The CMDTYPE of the CMD register (offset 0xE) should be set to
  42. * "11" when the STOP CMD12 is issued on imx53 to abort one
  43. * open ended multi-blk IO. Otherwise the TC INT wouldn't
  44. * be generated.
  45. * In exact block transfer, the controller doesn't complete the
  46. * operations automatically as required at the end of the
  47. * transfer and remains on hold if the abort command is not sent.
  48. * As a result, the TC flag is not asserted and SW received timeout
  49. * exeception. Bit1 of Vendor Spec registor is used to fix it.
  50. */
  51. #define ESDHC_FLAG_MULTIBLK_NO_INT (1 << 1)
  52. enum imx_esdhc_type {
  53. IMX25_ESDHC,
  54. IMX35_ESDHC,
  55. IMX51_ESDHC,
  56. IMX53_ESDHC,
  57. };
  58. struct pltfm_imx_data {
  59. int flags;
  60. u32 scratchpad;
  61. enum imx_esdhc_type devtype;
  62. struct esdhc_platform_data boarddata;
  63. };
  64. static struct platform_device_id imx_esdhc_devtype[] = {
  65. {
  66. .name = "sdhci-esdhc-imx25",
  67. .driver_data = IMX25_ESDHC,
  68. }, {
  69. .name = "sdhci-esdhc-imx35",
  70. .driver_data = IMX35_ESDHC,
  71. }, {
  72. .name = "sdhci-esdhc-imx51",
  73. .driver_data = IMX51_ESDHC,
  74. }, {
  75. .name = "sdhci-esdhc-imx53",
  76. .driver_data = IMX53_ESDHC,
  77. }, {
  78. /* sentinel */
  79. }
  80. };
  81. MODULE_DEVICE_TABLE(platform, imx_esdhc_devtype);
  82. static const struct of_device_id imx_esdhc_dt_ids[] = {
  83. { .compatible = "fsl,imx25-esdhc", .data = &imx_esdhc_devtype[IMX25_ESDHC], },
  84. { .compatible = "fsl,imx35-esdhc", .data = &imx_esdhc_devtype[IMX35_ESDHC], },
  85. { .compatible = "fsl,imx51-esdhc", .data = &imx_esdhc_devtype[IMX51_ESDHC], },
  86. { .compatible = "fsl,imx53-esdhc", .data = &imx_esdhc_devtype[IMX53_ESDHC], },
  87. { /* sentinel */ }
  88. };
  89. MODULE_DEVICE_TABLE(of, imx_esdhc_dt_ids);
  90. static inline int is_imx25_esdhc(struct pltfm_imx_data *data)
  91. {
  92. return data->devtype == IMX25_ESDHC;
  93. }
  94. static inline int is_imx35_esdhc(struct pltfm_imx_data *data)
  95. {
  96. return data->devtype == IMX35_ESDHC;
  97. }
  98. static inline int is_imx51_esdhc(struct pltfm_imx_data *data)
  99. {
  100. return data->devtype == IMX51_ESDHC;
  101. }
  102. static inline int is_imx53_esdhc(struct pltfm_imx_data *data)
  103. {
  104. return data->devtype == IMX53_ESDHC;
  105. }
  106. static inline void esdhc_clrset_le(struct sdhci_host *host, u32 mask, u32 val, int reg)
  107. {
  108. void __iomem *base = host->ioaddr + (reg & ~0x3);
  109. u32 shift = (reg & 0x3) * 8;
  110. writel(((readl(base) & ~(mask << shift)) | (val << shift)), base);
  111. }
  112. static u32 esdhc_readl_le(struct sdhci_host *host, int reg)
  113. {
  114. struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
  115. struct pltfm_imx_data *imx_data = pltfm_host->priv;
  116. struct esdhc_platform_data *boarddata = &imx_data->boarddata;
  117. /* fake CARD_PRESENT flag */
  118. u32 val = readl(host->ioaddr + reg);
  119. if (unlikely((reg == SDHCI_PRESENT_STATE)
  120. && gpio_is_valid(boarddata->cd_gpio))) {
  121. if (gpio_get_value(boarddata->cd_gpio))
  122. /* no card, if a valid gpio says so... */
  123. val &= ~SDHCI_CARD_PRESENT;
  124. else
  125. /* ... in all other cases assume card is present */
  126. val |= SDHCI_CARD_PRESENT;
  127. }
  128. if (unlikely(reg == SDHCI_CAPABILITIES)) {
  129. /* In FSL esdhc IC module, only bit20 is used to indicate the
  130. * ADMA2 capability of esdhc, but this bit is messed up on
  131. * some SOCs (e.g. on MX25, MX35 this bit is set, but they
  132. * don't actually support ADMA2). So set the BROKEN_ADMA
  133. * uirk on MX25/35 platforms.
  134. */
  135. if (val & SDHCI_CAN_DO_ADMA1) {
  136. val &= ~SDHCI_CAN_DO_ADMA1;
  137. val |= SDHCI_CAN_DO_ADMA2;
  138. }
  139. }
  140. if (unlikely(reg == SDHCI_INT_STATUS)) {
  141. if (val & SDHCI_INT_VENDOR_SPEC_DMA_ERR) {
  142. val &= ~SDHCI_INT_VENDOR_SPEC_DMA_ERR;
  143. val |= SDHCI_INT_ADMA_ERROR;
  144. }
  145. }
  146. return val;
  147. }
  148. static void esdhc_writel_le(struct sdhci_host *host, u32 val, int reg)
  149. {
  150. struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
  151. struct pltfm_imx_data *imx_data = pltfm_host->priv;
  152. struct esdhc_platform_data *boarddata = &imx_data->boarddata;
  153. u32 data;
  154. if (unlikely(reg == SDHCI_INT_ENABLE || reg == SDHCI_SIGNAL_ENABLE)) {
  155. if (boarddata->cd_type == ESDHC_CD_GPIO)
  156. /*
  157. * These interrupts won't work with a custom
  158. * card_detect gpio (only applied to mx25/35)
  159. */
  160. val &= ~(SDHCI_INT_CARD_REMOVE | SDHCI_INT_CARD_INSERT);
  161. if (val & SDHCI_INT_CARD_INT) {
  162. /*
  163. * Clear and then set D3CD bit to avoid missing the
  164. * card interrupt. This is a eSDHC controller problem
  165. * so we need to apply the following workaround: clear
  166. * and set D3CD bit will make eSDHC re-sample the card
  167. * interrupt. In case a card interrupt was lost,
  168. * re-sample it by the following steps.
  169. */
  170. data = readl(host->ioaddr + SDHCI_HOST_CONTROL);
  171. data &= ~SDHCI_CTRL_D3CD;
  172. writel(data, host->ioaddr + SDHCI_HOST_CONTROL);
  173. data |= SDHCI_CTRL_D3CD;
  174. writel(data, host->ioaddr + SDHCI_HOST_CONTROL);
  175. }
  176. }
  177. if (unlikely((imx_data->flags & ESDHC_FLAG_MULTIBLK_NO_INT)
  178. && (reg == SDHCI_INT_STATUS)
  179. && (val & SDHCI_INT_DATA_END))) {
  180. u32 v;
  181. v = readl(host->ioaddr + SDHCI_VENDOR_SPEC);
  182. v &= ~SDHCI_VENDOR_SPEC_SDIO_QUIRK;
  183. writel(v, host->ioaddr + SDHCI_VENDOR_SPEC);
  184. }
  185. if (unlikely(reg == SDHCI_INT_ENABLE || reg == SDHCI_SIGNAL_ENABLE)) {
  186. if (val & SDHCI_INT_ADMA_ERROR) {
  187. val &= ~SDHCI_INT_ADMA_ERROR;
  188. val |= SDHCI_INT_VENDOR_SPEC_DMA_ERR;
  189. }
  190. }
  191. writel(val, host->ioaddr + reg);
  192. }
  193. static u16 esdhc_readw_le(struct sdhci_host *host, int reg)
  194. {
  195. if (unlikely(reg == SDHCI_HOST_VERSION))
  196. reg ^= 2;
  197. return readw(host->ioaddr + reg);
  198. }
  199. static void esdhc_writew_le(struct sdhci_host *host, u16 val, int reg)
  200. {
  201. struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
  202. struct pltfm_imx_data *imx_data = pltfm_host->priv;
  203. switch (reg) {
  204. case SDHCI_TRANSFER_MODE:
  205. /*
  206. * Postpone this write, we must do it together with a
  207. * command write that is down below.
  208. */
  209. if ((imx_data->flags & ESDHC_FLAG_MULTIBLK_NO_INT)
  210. && (host->cmd->opcode == SD_IO_RW_EXTENDED)
  211. && (host->cmd->data->blocks > 1)
  212. && (host->cmd->data->flags & MMC_DATA_READ)) {
  213. u32 v;
  214. v = readl(host->ioaddr + SDHCI_VENDOR_SPEC);
  215. v |= SDHCI_VENDOR_SPEC_SDIO_QUIRK;
  216. writel(v, host->ioaddr + SDHCI_VENDOR_SPEC);
  217. }
  218. imx_data->scratchpad = val;
  219. return;
  220. case SDHCI_COMMAND:
  221. if ((host->cmd->opcode == MMC_STOP_TRANSMISSION)
  222. && (imx_data->flags & ESDHC_FLAG_MULTIBLK_NO_INT))
  223. val |= SDHCI_CMD_ABORTCMD;
  224. writel(val << 16 | imx_data->scratchpad,
  225. host->ioaddr + SDHCI_TRANSFER_MODE);
  226. return;
  227. case SDHCI_BLOCK_SIZE:
  228. val &= ~SDHCI_MAKE_BLKSZ(0x7, 0);
  229. break;
  230. }
  231. esdhc_clrset_le(host, 0xffff, val, reg);
  232. }
  233. static void esdhc_writeb_le(struct sdhci_host *host, u8 val, int reg)
  234. {
  235. u32 new_val;
  236. switch (reg) {
  237. case SDHCI_POWER_CONTROL:
  238. /*
  239. * FSL put some DMA bits here
  240. * If your board has a regulator, code should be here
  241. */
  242. return;
  243. case SDHCI_HOST_CONTROL:
  244. /* FSL messed up here, so we can just keep those three */
  245. new_val = val & (SDHCI_CTRL_LED | \
  246. SDHCI_CTRL_4BITBUS | \
  247. SDHCI_CTRL_D3CD);
  248. /* ensure the endianess */
  249. new_val |= ESDHC_HOST_CONTROL_LE;
  250. /* DMA mode bits are shifted */
  251. new_val |= (val & SDHCI_CTRL_DMA_MASK) << 5;
  252. esdhc_clrset_le(host, 0xffff, new_val, reg);
  253. return;
  254. }
  255. esdhc_clrset_le(host, 0xff, val, reg);
  256. /*
  257. * The esdhc has a design violation to SDHC spec which tells
  258. * that software reset should not affect card detection circuit.
  259. * But esdhc clears its SYSCTL register bits [0..2] during the
  260. * software reset. This will stop those clocks that card detection
  261. * circuit relies on. To work around it, we turn the clocks on back
  262. * to keep card detection circuit functional.
  263. */
  264. if ((reg == SDHCI_SOFTWARE_RESET) && (val & 1))
  265. esdhc_clrset_le(host, 0x7, 0x7, ESDHC_SYSTEM_CONTROL);
  266. }
  267. static unsigned int esdhc_pltfm_get_max_clock(struct sdhci_host *host)
  268. {
  269. struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
  270. return clk_get_rate(pltfm_host->clk);
  271. }
  272. static unsigned int esdhc_pltfm_get_min_clock(struct sdhci_host *host)
  273. {
  274. struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
  275. return clk_get_rate(pltfm_host->clk) / 256 / 16;
  276. }
  277. static unsigned int esdhc_pltfm_get_ro(struct sdhci_host *host)
  278. {
  279. struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
  280. struct pltfm_imx_data *imx_data = pltfm_host->priv;
  281. struct esdhc_platform_data *boarddata = &imx_data->boarddata;
  282. switch (boarddata->wp_type) {
  283. case ESDHC_WP_GPIO:
  284. if (gpio_is_valid(boarddata->wp_gpio))
  285. return gpio_get_value(boarddata->wp_gpio);
  286. case ESDHC_WP_CONTROLLER:
  287. return !(readl(host->ioaddr + SDHCI_PRESENT_STATE) &
  288. SDHCI_WRITE_PROTECT);
  289. case ESDHC_WP_NONE:
  290. break;
  291. }
  292. return -ENOSYS;
  293. }
  294. static struct sdhci_ops sdhci_esdhc_ops = {
  295. .read_l = esdhc_readl_le,
  296. .read_w = esdhc_readw_le,
  297. .write_l = esdhc_writel_le,
  298. .write_w = esdhc_writew_le,
  299. .write_b = esdhc_writeb_le,
  300. .set_clock = esdhc_set_clock,
  301. .get_max_clock = esdhc_pltfm_get_max_clock,
  302. .get_min_clock = esdhc_pltfm_get_min_clock,
  303. .get_ro = esdhc_pltfm_get_ro,
  304. };
  305. static struct sdhci_pltfm_data sdhci_esdhc_imx_pdata = {
  306. .quirks = ESDHC_DEFAULT_QUIRKS | SDHCI_QUIRK_NO_HISPD_BIT
  307. | SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC
  308. | SDHCI_QUIRK_BROKEN_ADMA_ZEROLEN_DESC
  309. | SDHCI_QUIRK_BROKEN_CARD_DETECTION,
  310. .ops = &sdhci_esdhc_ops,
  311. };
  312. static irqreturn_t cd_irq(int irq, void *data)
  313. {
  314. struct sdhci_host *sdhost = (struct sdhci_host *)data;
  315. tasklet_schedule(&sdhost->card_tasklet);
  316. return IRQ_HANDLED;
  317. };
  318. #ifdef CONFIG_OF
  319. static int __devinit
  320. sdhci_esdhc_imx_probe_dt(struct platform_device *pdev,
  321. struct esdhc_platform_data *boarddata)
  322. {
  323. struct device_node *np = pdev->dev.of_node;
  324. if (!np)
  325. return -ENODEV;
  326. if (of_get_property(np, "fsl,card-wired", NULL))
  327. boarddata->cd_type = ESDHC_CD_PERMANENT;
  328. if (of_get_property(np, "fsl,cd-controller", NULL))
  329. boarddata->cd_type = ESDHC_CD_CONTROLLER;
  330. if (of_get_property(np, "fsl,wp-controller", NULL))
  331. boarddata->wp_type = ESDHC_WP_CONTROLLER;
  332. boarddata->cd_gpio = of_get_named_gpio(np, "cd-gpios", 0);
  333. if (gpio_is_valid(boarddata->cd_gpio))
  334. boarddata->cd_type = ESDHC_CD_GPIO;
  335. boarddata->wp_gpio = of_get_named_gpio(np, "wp-gpios", 0);
  336. if (gpio_is_valid(boarddata->wp_gpio))
  337. boarddata->wp_type = ESDHC_WP_GPIO;
  338. return 0;
  339. }
  340. #else
  341. static inline int
  342. sdhci_esdhc_imx_probe_dt(struct platform_device *pdev,
  343. struct esdhc_platform_data *boarddata)
  344. {
  345. return -ENODEV;
  346. }
  347. #endif
  348. static int __devinit sdhci_esdhc_imx_probe(struct platform_device *pdev)
  349. {
  350. const struct of_device_id *of_id =
  351. of_match_device(imx_esdhc_dt_ids, &pdev->dev);
  352. struct sdhci_pltfm_host *pltfm_host;
  353. struct sdhci_host *host;
  354. struct esdhc_platform_data *boarddata;
  355. struct clk *clk;
  356. int err;
  357. struct pltfm_imx_data *imx_data;
  358. host = sdhci_pltfm_init(pdev, &sdhci_esdhc_imx_pdata);
  359. if (IS_ERR(host))
  360. return PTR_ERR(host);
  361. pltfm_host = sdhci_priv(host);
  362. imx_data = kzalloc(sizeof(struct pltfm_imx_data), GFP_KERNEL);
  363. if (!imx_data) {
  364. err = -ENOMEM;
  365. goto err_imx_data;
  366. }
  367. if (of_id)
  368. pdev->id_entry = of_id->data;
  369. imx_data->devtype = pdev->id_entry->driver_data;
  370. pltfm_host->priv = imx_data;
  371. clk = clk_get(mmc_dev(host->mmc), NULL);
  372. if (IS_ERR(clk)) {
  373. dev_err(mmc_dev(host->mmc), "clk err\n");
  374. err = PTR_ERR(clk);
  375. goto err_clk_get;
  376. }
  377. clk_enable(clk);
  378. pltfm_host->clk = clk;
  379. if (!is_imx25_esdhc(imx_data))
  380. host->quirks |= SDHCI_QUIRK_BROKEN_TIMEOUT_VAL;
  381. if (is_imx25_esdhc(imx_data) || is_imx35_esdhc(imx_data))
  382. /* Fix errata ENGcm07207 present on i.MX25 and i.MX35 */
  383. host->quirks |= SDHCI_QUIRK_NO_MULTIBLOCK
  384. | SDHCI_QUIRK_BROKEN_ADMA;
  385. if (is_imx53_esdhc(imx_data))
  386. imx_data->flags |= ESDHC_FLAG_MULTIBLK_NO_INT;
  387. boarddata = &imx_data->boarddata;
  388. if (sdhci_esdhc_imx_probe_dt(pdev, boarddata) < 0) {
  389. if (!host->mmc->parent->platform_data) {
  390. dev_err(mmc_dev(host->mmc), "no board data!\n");
  391. err = -EINVAL;
  392. goto no_board_data;
  393. }
  394. imx_data->boarddata = *((struct esdhc_platform_data *)
  395. host->mmc->parent->platform_data);
  396. }
  397. /* write_protect */
  398. if (boarddata->wp_type == ESDHC_WP_GPIO) {
  399. err = gpio_request_one(boarddata->wp_gpio, GPIOF_IN, "ESDHC_WP");
  400. if (err) {
  401. dev_warn(mmc_dev(host->mmc),
  402. "no write-protect pin available!\n");
  403. boarddata->wp_gpio = -EINVAL;
  404. }
  405. } else {
  406. boarddata->wp_gpio = -EINVAL;
  407. }
  408. /* card_detect */
  409. if (boarddata->cd_type != ESDHC_CD_GPIO)
  410. boarddata->cd_gpio = -EINVAL;
  411. switch (boarddata->cd_type) {
  412. case ESDHC_CD_GPIO:
  413. err = gpio_request_one(boarddata->cd_gpio, GPIOF_IN, "ESDHC_CD");
  414. if (err) {
  415. dev_err(mmc_dev(host->mmc),
  416. "no card-detect pin available!\n");
  417. goto no_card_detect_pin;
  418. }
  419. err = request_irq(gpio_to_irq(boarddata->cd_gpio), cd_irq,
  420. IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING,
  421. mmc_hostname(host->mmc), host);
  422. if (err) {
  423. dev_err(mmc_dev(host->mmc), "request irq error\n");
  424. goto no_card_detect_irq;
  425. }
  426. /* fall through */
  427. case ESDHC_CD_CONTROLLER:
  428. /* we have a working card_detect back */
  429. host->quirks &= ~SDHCI_QUIRK_BROKEN_CARD_DETECTION;
  430. break;
  431. case ESDHC_CD_PERMANENT:
  432. host->mmc->caps = MMC_CAP_NONREMOVABLE;
  433. break;
  434. case ESDHC_CD_NONE:
  435. break;
  436. }
  437. err = sdhci_add_host(host);
  438. if (err)
  439. goto err_add_host;
  440. return 0;
  441. err_add_host:
  442. if (gpio_is_valid(boarddata->cd_gpio))
  443. free_irq(gpio_to_irq(boarddata->cd_gpio), host);
  444. no_card_detect_irq:
  445. if (gpio_is_valid(boarddata->cd_gpio))
  446. gpio_free(boarddata->cd_gpio);
  447. if (gpio_is_valid(boarddata->wp_gpio))
  448. gpio_free(boarddata->wp_gpio);
  449. no_card_detect_pin:
  450. no_board_data:
  451. clk_disable(pltfm_host->clk);
  452. clk_put(pltfm_host->clk);
  453. err_clk_get:
  454. kfree(imx_data);
  455. err_imx_data:
  456. sdhci_pltfm_free(pdev);
  457. return err;
  458. }
  459. static int __devexit sdhci_esdhc_imx_remove(struct platform_device *pdev)
  460. {
  461. struct sdhci_host *host = platform_get_drvdata(pdev);
  462. struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
  463. struct pltfm_imx_data *imx_data = pltfm_host->priv;
  464. struct esdhc_platform_data *boarddata = &imx_data->boarddata;
  465. int dead = (readl(host->ioaddr + SDHCI_INT_STATUS) == 0xffffffff);
  466. sdhci_remove_host(host, dead);
  467. if (gpio_is_valid(boarddata->wp_gpio))
  468. gpio_free(boarddata->wp_gpio);
  469. if (gpio_is_valid(boarddata->cd_gpio)) {
  470. free_irq(gpio_to_irq(boarddata->cd_gpio), host);
  471. gpio_free(boarddata->cd_gpio);
  472. }
  473. clk_disable(pltfm_host->clk);
  474. clk_put(pltfm_host->clk);
  475. kfree(imx_data);
  476. sdhci_pltfm_free(pdev);
  477. return 0;
  478. }
  479. static struct platform_driver sdhci_esdhc_imx_driver = {
  480. .driver = {
  481. .name = "sdhci-esdhc-imx",
  482. .owner = THIS_MODULE,
  483. .of_match_table = imx_esdhc_dt_ids,
  484. },
  485. .id_table = imx_esdhc_devtype,
  486. .probe = sdhci_esdhc_imx_probe,
  487. .remove = __devexit_p(sdhci_esdhc_imx_remove),
  488. #ifdef CONFIG_PM
  489. .suspend = sdhci_pltfm_suspend,
  490. .resume = sdhci_pltfm_resume,
  491. #endif
  492. };
  493. static int __init sdhci_esdhc_imx_init(void)
  494. {
  495. return platform_driver_register(&sdhci_esdhc_imx_driver);
  496. }
  497. module_init(sdhci_esdhc_imx_init);
  498. static void __exit sdhci_esdhc_imx_exit(void)
  499. {
  500. platform_driver_unregister(&sdhci_esdhc_imx_driver);
  501. }
  502. module_exit(sdhci_esdhc_imx_exit);
  503. MODULE_DESCRIPTION("SDHCI driver for Freescale i.MX eSDHC");
  504. MODULE_AUTHOR("Wolfram Sang <w.sang@pengutronix.de>");
  505. MODULE_LICENSE("GPL v2");