sdhci-pxav3.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608
  1. /*
  2. * Copyright (C) 2010 Marvell International Ltd.
  3. * Zhangfei Gao <zhangfei.gao@marvell.com>
  4. * Kevin Wang <dwang4@marvell.com>
  5. * Mingwei Wang <mwwang@marvell.com>
  6. * Philip Rakity <prakity@marvell.com>
  7. * Mark Brown <markb@marvell.com>
  8. *
  9. * This software is licensed under the terms of the GNU General Public
  10. * License version 2, as published by the Free Software Foundation, and
  11. * may be copied, distributed, and modified under those terms.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. */
  19. #include <linux/err.h>
  20. #include <linux/init.h>
  21. #include <linux/platform_device.h>
  22. #include <linux/clk.h>
  23. #include <linux/io.h>
  24. #include <linux/gpio.h>
  25. #include <linux/mmc/card.h>
  26. #include <linux/mmc/host.h>
  27. #include <linux/mmc/slot-gpio.h>
  28. #include <linux/platform_data/pxa_sdhci.h>
  29. #include <linux/slab.h>
  30. #include <linux/delay.h>
  31. #include <linux/module.h>
  32. #include <linux/of.h>
  33. #include <linux/of_device.h>
  34. #include <linux/of_gpio.h>
  35. #include <linux/pm.h>
  36. #include <linux/pm_runtime.h>
  37. #include <linux/mbus.h>
  38. #include "sdhci.h"
  39. #include "sdhci-pltfm.h"
  40. #define PXAV3_RPM_DELAY_MS 50
  41. #define SD_CLOCK_BURST_SIZE_SETUP 0x10A
  42. #define SDCLK_SEL 0x100
  43. #define SDCLK_DELAY_SHIFT 9
  44. #define SDCLK_DELAY_MASK 0x1f
  45. #define SD_CFG_FIFO_PARAM 0x100
  46. #define SDCFG_GEN_PAD_CLK_ON (1<<6)
  47. #define SDCFG_GEN_PAD_CLK_CNT_MASK 0xFF
  48. #define SDCFG_GEN_PAD_CLK_CNT_SHIFT 24
  49. #define SD_SPI_MODE 0x108
  50. #define SD_CE_ATA_1 0x10C
  51. #define SD_CE_ATA_2 0x10E
  52. #define SDCE_MISC_INT (1<<2)
  53. #define SDCE_MISC_INT_EN (1<<1)
  54. struct sdhci_pxa {
  55. struct clk *clk_core;
  56. struct clk *clk_io;
  57. u8 power_mode;
  58. void __iomem *sdio3_conf_reg;
  59. };
  60. /*
  61. * These registers are relative to the second register region, for the
  62. * MBus bridge.
  63. */
  64. #define SDHCI_WINDOW_CTRL(i) (0x80 + ((i) << 3))
  65. #define SDHCI_WINDOW_BASE(i) (0x84 + ((i) << 3))
  66. #define SDHCI_MAX_WIN_NUM 8
  67. /*
  68. * Fields below belong to SDIO3 Configuration Register (third register
  69. * region for the Armada 38x flavor)
  70. */
  71. #define SDIO3_CONF_CLK_INV BIT(0)
  72. #define SDIO3_CONF_SD_FB_CLK BIT(2)
  73. static int mv_conf_mbus_windows(struct platform_device *pdev,
  74. const struct mbus_dram_target_info *dram)
  75. {
  76. int i;
  77. void __iomem *regs;
  78. struct resource *res;
  79. if (!dram) {
  80. dev_err(&pdev->dev, "no mbus dram info\n");
  81. return -EINVAL;
  82. }
  83. res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
  84. if (!res) {
  85. dev_err(&pdev->dev, "cannot get mbus registers\n");
  86. return -EINVAL;
  87. }
  88. regs = ioremap(res->start, resource_size(res));
  89. if (!regs) {
  90. dev_err(&pdev->dev, "cannot map mbus registers\n");
  91. return -ENOMEM;
  92. }
  93. for (i = 0; i < SDHCI_MAX_WIN_NUM; i++) {
  94. writel(0, regs + SDHCI_WINDOW_CTRL(i));
  95. writel(0, regs + SDHCI_WINDOW_BASE(i));
  96. }
  97. for (i = 0; i < dram->num_cs; i++) {
  98. const struct mbus_dram_window *cs = dram->cs + i;
  99. /* Write size, attributes and target id to control register */
  100. writel(((cs->size - 1) & 0xffff0000) |
  101. (cs->mbus_attr << 8) |
  102. (dram->mbus_dram_target_id << 4) | 1,
  103. regs + SDHCI_WINDOW_CTRL(i));
  104. /* Write base address to base register */
  105. writel(cs->base, regs + SDHCI_WINDOW_BASE(i));
  106. }
  107. iounmap(regs);
  108. return 0;
  109. }
  110. static int armada_38x_quirks(struct platform_device *pdev,
  111. struct sdhci_host *host)
  112. {
  113. struct device_node *np = pdev->dev.of_node;
  114. struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
  115. struct sdhci_pxa *pxa = sdhci_pltfm_priv(pltfm_host);
  116. struct resource *res;
  117. host->quirks &= ~SDHCI_QUIRK_CAP_CLOCK_BASE_BROKEN;
  118. host->quirks |= SDHCI_QUIRK_MISSING_CAPS;
  119. host->caps = sdhci_readl(host, SDHCI_CAPABILITIES);
  120. host->caps1 = sdhci_readl(host, SDHCI_CAPABILITIES_1);
  121. res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
  122. "conf-sdio3");
  123. if (res) {
  124. pxa->sdio3_conf_reg = devm_ioremap_resource(&pdev->dev, res);
  125. if (IS_ERR(pxa->sdio3_conf_reg))
  126. return PTR_ERR(pxa->sdio3_conf_reg);
  127. } else {
  128. /*
  129. * According to erratum 'FE-2946959' both SDR50 and DDR50
  130. * modes require specific clock adjustments in SDIO3
  131. * Configuration register, if the adjustment is not done,
  132. * remove them from the capabilities.
  133. */
  134. host->caps1 &= ~(SDHCI_SUPPORT_SDR50 | SDHCI_SUPPORT_DDR50);
  135. dev_warn(&pdev->dev, "conf-sdio3 register not found: disabling SDR50 and DDR50 modes.\nConsider updating your dtb\n");
  136. }
  137. /*
  138. * According to erratum 'ERR-7878951' Armada 38x SDHCI
  139. * controller has different capabilities than the ones shown
  140. * in its registers
  141. */
  142. if (of_property_read_bool(np, "no-1-8-v")) {
  143. host->caps &= ~SDHCI_CAN_VDD_180;
  144. host->mmc->caps &= ~MMC_CAP_1_8V_DDR;
  145. } else {
  146. host->caps &= ~SDHCI_CAN_VDD_330;
  147. }
  148. host->caps1 &= ~(SDHCI_SUPPORT_SDR104 | SDHCI_USE_SDR50_TUNING);
  149. return 0;
  150. }
  151. static void pxav3_reset(struct sdhci_host *host, u8 mask)
  152. {
  153. struct platform_device *pdev = to_platform_device(mmc_dev(host->mmc));
  154. struct sdhci_pxa_platdata *pdata = pdev->dev.platform_data;
  155. sdhci_reset(host, mask);
  156. if (mask == SDHCI_RESET_ALL) {
  157. /*
  158. * tune timing of read data/command when crc error happen
  159. * no performance impact
  160. */
  161. if (pdata && 0 != pdata->clk_delay_cycles) {
  162. u16 tmp;
  163. tmp = readw(host->ioaddr + SD_CLOCK_BURST_SIZE_SETUP);
  164. tmp |= (pdata->clk_delay_cycles & SDCLK_DELAY_MASK)
  165. << SDCLK_DELAY_SHIFT;
  166. tmp |= SDCLK_SEL;
  167. writew(tmp, host->ioaddr + SD_CLOCK_BURST_SIZE_SETUP);
  168. }
  169. }
  170. }
  171. #define MAX_WAIT_COUNT 5
  172. static void pxav3_gen_init_74_clocks(struct sdhci_host *host, u8 power_mode)
  173. {
  174. struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
  175. struct sdhci_pxa *pxa = sdhci_pltfm_priv(pltfm_host);
  176. u16 tmp;
  177. int count;
  178. if (pxa->power_mode == MMC_POWER_UP
  179. && power_mode == MMC_POWER_ON) {
  180. dev_dbg(mmc_dev(host->mmc),
  181. "%s: slot->power_mode = %d,"
  182. "ios->power_mode = %d\n",
  183. __func__,
  184. pxa->power_mode,
  185. power_mode);
  186. /* set we want notice of when 74 clocks are sent */
  187. tmp = readw(host->ioaddr + SD_CE_ATA_2);
  188. tmp |= SDCE_MISC_INT_EN;
  189. writew(tmp, host->ioaddr + SD_CE_ATA_2);
  190. /* start sending the 74 clocks */
  191. tmp = readw(host->ioaddr + SD_CFG_FIFO_PARAM);
  192. tmp |= SDCFG_GEN_PAD_CLK_ON;
  193. writew(tmp, host->ioaddr + SD_CFG_FIFO_PARAM);
  194. /* slowest speed is about 100KHz or 10usec per clock */
  195. udelay(740);
  196. count = 0;
  197. while (count++ < MAX_WAIT_COUNT) {
  198. if ((readw(host->ioaddr + SD_CE_ATA_2)
  199. & SDCE_MISC_INT) == 0)
  200. break;
  201. udelay(10);
  202. }
  203. if (count == MAX_WAIT_COUNT)
  204. dev_warn(mmc_dev(host->mmc), "74 clock interrupt not cleared\n");
  205. /* clear the interrupt bit if posted */
  206. tmp = readw(host->ioaddr + SD_CE_ATA_2);
  207. tmp |= SDCE_MISC_INT;
  208. writew(tmp, host->ioaddr + SD_CE_ATA_2);
  209. }
  210. pxa->power_mode = power_mode;
  211. }
  212. static void pxav3_set_uhs_signaling(struct sdhci_host *host, unsigned int uhs)
  213. {
  214. struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
  215. struct sdhci_pxa *pxa = sdhci_pltfm_priv(pltfm_host);
  216. u16 ctrl_2;
  217. /*
  218. * Set V18_EN -- UHS modes do not work without this.
  219. * does not change signaling voltage
  220. */
  221. ctrl_2 = sdhci_readw(host, SDHCI_HOST_CONTROL2);
  222. /* Select Bus Speed Mode for host */
  223. ctrl_2 &= ~SDHCI_CTRL_UHS_MASK;
  224. switch (uhs) {
  225. case MMC_TIMING_UHS_SDR12:
  226. ctrl_2 |= SDHCI_CTRL_UHS_SDR12;
  227. break;
  228. case MMC_TIMING_UHS_SDR25:
  229. ctrl_2 |= SDHCI_CTRL_UHS_SDR25;
  230. break;
  231. case MMC_TIMING_UHS_SDR50:
  232. ctrl_2 |= SDHCI_CTRL_UHS_SDR50 | SDHCI_CTRL_VDD_180;
  233. break;
  234. case MMC_TIMING_UHS_SDR104:
  235. ctrl_2 |= SDHCI_CTRL_UHS_SDR104 | SDHCI_CTRL_VDD_180;
  236. break;
  237. case MMC_TIMING_MMC_DDR52:
  238. case MMC_TIMING_UHS_DDR50:
  239. ctrl_2 |= SDHCI_CTRL_UHS_DDR50 | SDHCI_CTRL_VDD_180;
  240. break;
  241. }
  242. /*
  243. * Update SDIO3 Configuration register according to erratum
  244. * FE-2946959
  245. */
  246. if (pxa->sdio3_conf_reg) {
  247. u8 reg_val = readb(pxa->sdio3_conf_reg);
  248. if (uhs == MMC_TIMING_UHS_SDR50 ||
  249. uhs == MMC_TIMING_UHS_DDR50) {
  250. reg_val &= ~SDIO3_CONF_CLK_INV;
  251. reg_val |= SDIO3_CONF_SD_FB_CLK;
  252. } else if (uhs == MMC_TIMING_MMC_HS) {
  253. reg_val &= ~SDIO3_CONF_CLK_INV;
  254. reg_val &= ~SDIO3_CONF_SD_FB_CLK;
  255. } else {
  256. reg_val |= SDIO3_CONF_CLK_INV;
  257. reg_val &= ~SDIO3_CONF_SD_FB_CLK;
  258. }
  259. writeb(reg_val, pxa->sdio3_conf_reg);
  260. }
  261. sdhci_writew(host, ctrl_2, SDHCI_HOST_CONTROL2);
  262. dev_dbg(mmc_dev(host->mmc),
  263. "%s uhs = %d, ctrl_2 = %04X\n",
  264. __func__, uhs, ctrl_2);
  265. }
  266. static void pxav3_set_power(struct sdhci_host *host, unsigned char mode,
  267. unsigned short vdd)
  268. {
  269. struct mmc_host *mmc = host->mmc;
  270. u8 pwr = host->pwr;
  271. sdhci_set_power_noreg(host, mode, vdd);
  272. if (host->pwr == pwr)
  273. return;
  274. if (host->pwr == 0)
  275. vdd = 0;
  276. if (!IS_ERR(mmc->supply.vmmc)) {
  277. spin_unlock_irq(&host->lock);
  278. mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, vdd);
  279. spin_lock_irq(&host->lock);
  280. }
  281. }
  282. static const struct sdhci_ops pxav3_sdhci_ops = {
  283. .set_clock = sdhci_set_clock,
  284. .set_power = pxav3_set_power,
  285. .platform_send_init_74_clocks = pxav3_gen_init_74_clocks,
  286. .get_max_clock = sdhci_pltfm_clk_get_max_clock,
  287. .set_bus_width = sdhci_set_bus_width,
  288. .reset = pxav3_reset,
  289. .set_uhs_signaling = pxav3_set_uhs_signaling,
  290. };
  291. static struct sdhci_pltfm_data sdhci_pxav3_pdata = {
  292. .quirks = SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK
  293. | SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC
  294. | SDHCI_QUIRK_32BIT_ADMA_SIZE
  295. | SDHCI_QUIRK_CAP_CLOCK_BASE_BROKEN,
  296. .ops = &pxav3_sdhci_ops,
  297. };
  298. #ifdef CONFIG_OF
  299. static const struct of_device_id sdhci_pxav3_of_match[] = {
  300. {
  301. .compatible = "mrvl,pxav3-mmc",
  302. },
  303. {
  304. .compatible = "marvell,armada-380-sdhci",
  305. },
  306. {},
  307. };
  308. MODULE_DEVICE_TABLE(of, sdhci_pxav3_of_match);
  309. static struct sdhci_pxa_platdata *pxav3_get_mmc_pdata(struct device *dev)
  310. {
  311. struct sdhci_pxa_platdata *pdata;
  312. struct device_node *np = dev->of_node;
  313. u32 clk_delay_cycles;
  314. pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
  315. if (!pdata)
  316. return NULL;
  317. if (!of_property_read_u32(np, "mrvl,clk-delay-cycles",
  318. &clk_delay_cycles))
  319. pdata->clk_delay_cycles = clk_delay_cycles;
  320. return pdata;
  321. }
  322. #else
  323. static inline struct sdhci_pxa_platdata *pxav3_get_mmc_pdata(struct device *dev)
  324. {
  325. return NULL;
  326. }
  327. #endif
  328. static int sdhci_pxav3_probe(struct platform_device *pdev)
  329. {
  330. struct sdhci_pltfm_host *pltfm_host;
  331. struct sdhci_pxa_platdata *pdata = pdev->dev.platform_data;
  332. struct device *dev = &pdev->dev;
  333. struct device_node *np = pdev->dev.of_node;
  334. struct sdhci_host *host = NULL;
  335. struct sdhci_pxa *pxa = NULL;
  336. const struct of_device_id *match;
  337. int ret;
  338. host = sdhci_pltfm_init(pdev, &sdhci_pxav3_pdata, sizeof(*pxa));
  339. if (IS_ERR(host))
  340. return PTR_ERR(host);
  341. pltfm_host = sdhci_priv(host);
  342. pxa = sdhci_pltfm_priv(pltfm_host);
  343. pxa->clk_io = devm_clk_get(dev, "io");
  344. if (IS_ERR(pxa->clk_io))
  345. pxa->clk_io = devm_clk_get(dev, NULL);
  346. if (IS_ERR(pxa->clk_io)) {
  347. dev_err(dev, "failed to get io clock\n");
  348. ret = PTR_ERR(pxa->clk_io);
  349. goto err_clk_get;
  350. }
  351. pltfm_host->clk = pxa->clk_io;
  352. clk_prepare_enable(pxa->clk_io);
  353. pxa->clk_core = devm_clk_get(dev, "core");
  354. if (!IS_ERR(pxa->clk_core))
  355. clk_prepare_enable(pxa->clk_core);
  356. /* enable 1/8V DDR capable */
  357. host->mmc->caps |= MMC_CAP_1_8V_DDR;
  358. if (of_device_is_compatible(np, "marvell,armada-380-sdhci")) {
  359. ret = armada_38x_quirks(pdev, host);
  360. if (ret < 0)
  361. goto err_mbus_win;
  362. ret = mv_conf_mbus_windows(pdev, mv_mbus_dram_info());
  363. if (ret < 0)
  364. goto err_mbus_win;
  365. }
  366. match = of_match_device(of_match_ptr(sdhci_pxav3_of_match), &pdev->dev);
  367. if (match) {
  368. ret = mmc_of_parse(host->mmc);
  369. if (ret)
  370. goto err_of_parse;
  371. sdhci_get_of_property(pdev);
  372. pdata = pxav3_get_mmc_pdata(dev);
  373. pdev->dev.platform_data = pdata;
  374. } else if (pdata) {
  375. /* on-chip device */
  376. if (pdata->flags & PXA_FLAG_CARD_PERMANENT)
  377. host->mmc->caps |= MMC_CAP_NONREMOVABLE;
  378. /* If slot design supports 8 bit data, indicate this to MMC. */
  379. if (pdata->flags & PXA_FLAG_SD_8_BIT_CAPABLE_SLOT)
  380. host->mmc->caps |= MMC_CAP_8_BIT_DATA;
  381. if (pdata->quirks)
  382. host->quirks |= pdata->quirks;
  383. if (pdata->quirks2)
  384. host->quirks2 |= pdata->quirks2;
  385. if (pdata->host_caps)
  386. host->mmc->caps |= pdata->host_caps;
  387. if (pdata->host_caps2)
  388. host->mmc->caps2 |= pdata->host_caps2;
  389. if (pdata->pm_caps)
  390. host->mmc->pm_caps |= pdata->pm_caps;
  391. if (gpio_is_valid(pdata->ext_cd_gpio)) {
  392. ret = mmc_gpio_request_cd(host->mmc, pdata->ext_cd_gpio,
  393. 0);
  394. if (ret) {
  395. dev_err(mmc_dev(host->mmc),
  396. "failed to allocate card detect gpio\n");
  397. goto err_cd_req;
  398. }
  399. }
  400. }
  401. pm_runtime_get_noresume(&pdev->dev);
  402. pm_runtime_set_active(&pdev->dev);
  403. pm_runtime_set_autosuspend_delay(&pdev->dev, PXAV3_RPM_DELAY_MS);
  404. pm_runtime_use_autosuspend(&pdev->dev);
  405. pm_runtime_enable(&pdev->dev);
  406. pm_suspend_ignore_children(&pdev->dev, 1);
  407. ret = sdhci_add_host(host);
  408. if (ret) {
  409. dev_err(&pdev->dev, "failed to add host\n");
  410. goto err_add_host;
  411. }
  412. platform_set_drvdata(pdev, host);
  413. if (host->mmc->pm_caps & MMC_PM_WAKE_SDIO_IRQ)
  414. device_init_wakeup(&pdev->dev, 1);
  415. pm_runtime_put_autosuspend(&pdev->dev);
  416. return 0;
  417. err_add_host:
  418. pm_runtime_disable(&pdev->dev);
  419. pm_runtime_put_noidle(&pdev->dev);
  420. err_of_parse:
  421. err_cd_req:
  422. err_mbus_win:
  423. clk_disable_unprepare(pxa->clk_io);
  424. clk_disable_unprepare(pxa->clk_core);
  425. err_clk_get:
  426. sdhci_pltfm_free(pdev);
  427. return ret;
  428. }
  429. static int sdhci_pxav3_remove(struct platform_device *pdev)
  430. {
  431. struct sdhci_host *host = platform_get_drvdata(pdev);
  432. struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
  433. struct sdhci_pxa *pxa = sdhci_pltfm_priv(pltfm_host);
  434. pm_runtime_get_sync(&pdev->dev);
  435. pm_runtime_disable(&pdev->dev);
  436. pm_runtime_put_noidle(&pdev->dev);
  437. sdhci_remove_host(host, 1);
  438. clk_disable_unprepare(pxa->clk_io);
  439. clk_disable_unprepare(pxa->clk_core);
  440. sdhci_pltfm_free(pdev);
  441. return 0;
  442. }
  443. #ifdef CONFIG_PM_SLEEP
  444. static int sdhci_pxav3_suspend(struct device *dev)
  445. {
  446. int ret;
  447. struct sdhci_host *host = dev_get_drvdata(dev);
  448. pm_runtime_get_sync(dev);
  449. ret = sdhci_suspend_host(host);
  450. pm_runtime_mark_last_busy(dev);
  451. pm_runtime_put_autosuspend(dev);
  452. return ret;
  453. }
  454. static int sdhci_pxav3_resume(struct device *dev)
  455. {
  456. int ret;
  457. struct sdhci_host *host = dev_get_drvdata(dev);
  458. pm_runtime_get_sync(dev);
  459. ret = sdhci_resume_host(host);
  460. pm_runtime_mark_last_busy(dev);
  461. pm_runtime_put_autosuspend(dev);
  462. return ret;
  463. }
  464. #endif
  465. #ifdef CONFIG_PM
  466. static int sdhci_pxav3_runtime_suspend(struct device *dev)
  467. {
  468. struct sdhci_host *host = dev_get_drvdata(dev);
  469. struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
  470. struct sdhci_pxa *pxa = sdhci_pltfm_priv(pltfm_host);
  471. int ret;
  472. ret = sdhci_runtime_suspend_host(host);
  473. if (ret)
  474. return ret;
  475. clk_disable_unprepare(pxa->clk_io);
  476. if (!IS_ERR(pxa->clk_core))
  477. clk_disable_unprepare(pxa->clk_core);
  478. return 0;
  479. }
  480. static int sdhci_pxav3_runtime_resume(struct device *dev)
  481. {
  482. struct sdhci_host *host = dev_get_drvdata(dev);
  483. struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
  484. struct sdhci_pxa *pxa = sdhci_pltfm_priv(pltfm_host);
  485. clk_prepare_enable(pxa->clk_io);
  486. if (!IS_ERR(pxa->clk_core))
  487. clk_prepare_enable(pxa->clk_core);
  488. return sdhci_runtime_resume_host(host);
  489. }
  490. #endif
  491. static const struct dev_pm_ops sdhci_pxav3_pmops = {
  492. SET_SYSTEM_SLEEP_PM_OPS(sdhci_pxav3_suspend, sdhci_pxav3_resume)
  493. SET_RUNTIME_PM_OPS(sdhci_pxav3_runtime_suspend,
  494. sdhci_pxav3_runtime_resume, NULL)
  495. };
  496. static struct platform_driver sdhci_pxav3_driver = {
  497. .driver = {
  498. .name = "sdhci-pxav3",
  499. .of_match_table = of_match_ptr(sdhci_pxav3_of_match),
  500. .pm = &sdhci_pxav3_pmops,
  501. },
  502. .probe = sdhci_pxav3_probe,
  503. .remove = sdhci_pxav3_remove,
  504. };
  505. module_platform_driver(sdhci_pxav3_driver);
  506. MODULE_DESCRIPTION("SDHCI driver for pxav3");
  507. MODULE_AUTHOR("Marvell International Ltd.");
  508. MODULE_LICENSE("GPL v2");