sdhci-esdhc-imx.c 16 KB

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