dw_mmc-rockchip.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * Copyright (c) 2014, Fuzhou Rockchip Electronics Co., Ltd
  4. */
  5. #include <linux/module.h>
  6. #include <linux/platform_device.h>
  7. #include <linux/clk.h>
  8. #include <linux/hw_bitfield.h>
  9. #include <linux/mmc/host.h>
  10. #include <linux/of_address.h>
  11. #include <linux/mmc/slot-gpio.h>
  12. #include <linux/pm_runtime.h>
  13. #include <linux/slab.h>
  14. #include "dw_mmc.h"
  15. #include "dw_mmc-pltfm.h"
  16. #define RK3288_CLKGEN_DIV 2
  17. #define SDMMC_TIMING_CON0 0x130
  18. #define SDMMC_TIMING_CON1 0x134
  19. #define SDMMC_MISC_CON 0x138
  20. #define MEM_CLK_AUTOGATE_ENABLE BIT(5)
  21. #define ROCKCHIP_MMC_DELAY_SEL BIT(10)
  22. #define ROCKCHIP_MMC_DEGREE_MASK 0x3
  23. #define ROCKCHIP_MMC_DEGREE_OFFSET 1
  24. #define ROCKCHIP_MMC_DELAYNUM_OFFSET 2
  25. #define ROCKCHIP_MMC_DELAYNUM_MASK (0xff << ROCKCHIP_MMC_DELAYNUM_OFFSET)
  26. #define ROCKCHIP_MMC_DELAY_ELEMENT_PSEC 60
  27. static const unsigned int freqs[] = { 100000, 200000, 300000, 400000 };
  28. struct dw_mci_rockchip_priv_data {
  29. struct clk *drv_clk;
  30. struct clk *sample_clk;
  31. int default_sample_phase;
  32. int num_phases;
  33. bool internal_phase;
  34. int sample_phase;
  35. int drv_phase;
  36. };
  37. /*
  38. * Each fine delay is between 44ps-77ps. Assume each fine delay is 60ps to
  39. * simplify calculations. So 45degs could be anywhere between 33deg and 57.8deg.
  40. */
  41. static int rockchip_mmc_get_internal_phase(struct dw_mci *host, bool sample)
  42. {
  43. unsigned long rate = clk_get_rate(host->ciu_clk) / RK3288_CLKGEN_DIV;
  44. u32 raw_value;
  45. u16 degrees;
  46. u32 delay_num = 0;
  47. /* Constant signal, no measurable phase shift */
  48. if (!rate)
  49. return 0;
  50. if (sample)
  51. raw_value = mci_readl(host, TIMING_CON1);
  52. else
  53. raw_value = mci_readl(host, TIMING_CON0);
  54. raw_value >>= ROCKCHIP_MMC_DEGREE_OFFSET;
  55. degrees = (raw_value & ROCKCHIP_MMC_DEGREE_MASK) * 90;
  56. if (raw_value & ROCKCHIP_MMC_DELAY_SEL) {
  57. /* degrees/delaynum * 1000000 */
  58. unsigned long factor = (ROCKCHIP_MMC_DELAY_ELEMENT_PSEC / 10) *
  59. 36 * (rate / 10000);
  60. delay_num = (raw_value & ROCKCHIP_MMC_DELAYNUM_MASK);
  61. delay_num >>= ROCKCHIP_MMC_DELAYNUM_OFFSET;
  62. degrees += DIV_ROUND_CLOSEST(delay_num * factor, 1000000);
  63. }
  64. return degrees % 360;
  65. }
  66. static int rockchip_mmc_get_phase(struct dw_mci *host, bool sample)
  67. {
  68. struct dw_mci_rockchip_priv_data *priv = host->priv;
  69. struct clk *clock = sample ? priv->sample_clk : priv->drv_clk;
  70. if (priv->internal_phase)
  71. return rockchip_mmc_get_internal_phase(host, sample);
  72. else
  73. return clk_get_phase(clock);
  74. }
  75. static int rockchip_mmc_set_internal_phase(struct dw_mci *host, bool sample, int degrees)
  76. {
  77. unsigned long rate = clk_get_rate(host->ciu_clk) / RK3288_CLKGEN_DIV;
  78. u8 nineties, remainder;
  79. u8 delay_num;
  80. u32 raw_value;
  81. u32 delay;
  82. /*
  83. * The below calculation is based on the output clock from
  84. * MMC host to the card, which expects the phase clock inherits
  85. * the clock rate from its parent, namely the output clock
  86. * provider of MMC host. However, things may go wrong if
  87. * (1) It is orphan.
  88. * (2) It is assigned to the wrong parent.
  89. *
  90. * This check help debug the case (1), which seems to be the
  91. * most likely problem we often face and which makes it difficult
  92. * for people to debug unstable mmc tuning results.
  93. */
  94. if (!rate) {
  95. dev_err(host->dev, "%s: invalid clk rate\n", __func__);
  96. return -EINVAL;
  97. }
  98. nineties = degrees / 90;
  99. remainder = (degrees % 90);
  100. /*
  101. * Due to the inexact nature of the "fine" delay, we might
  102. * actually go non-monotonic. We don't go _too_ monotonic
  103. * though, so we should be OK. Here are options of how we may
  104. * work:
  105. *
  106. * Ideally we end up with:
  107. * 1.0, 2.0, ..., 69.0, 70.0, ..., 89.0, 90.0
  108. *
  109. * On one extreme (if delay is actually 44ps):
  110. * .73, 1.5, ..., 50.6, 51.3, ..., 65.3, 90.0
  111. * The other (if delay is actually 77ps):
  112. * 1.3, 2.6, ..., 88.6. 89.8, ..., 114.0, 90
  113. *
  114. * It's possible we might make a delay that is up to 25
  115. * degrees off from what we think we're making. That's OK
  116. * though because we should be REALLY far from any bad range.
  117. */
  118. /*
  119. * Convert to delay; do a little extra work to make sure we
  120. * don't overflow 32-bit / 64-bit numbers.
  121. */
  122. delay = 10000000; /* PSECS_PER_SEC / 10000 / 10 */
  123. delay *= remainder;
  124. delay = DIV_ROUND_CLOSEST(delay,
  125. (rate / 1000) * 36 *
  126. (ROCKCHIP_MMC_DELAY_ELEMENT_PSEC / 10));
  127. delay_num = (u8) min_t(u32, delay, 255);
  128. raw_value = delay_num ? ROCKCHIP_MMC_DELAY_SEL : 0;
  129. raw_value |= delay_num << ROCKCHIP_MMC_DELAYNUM_OFFSET;
  130. raw_value |= nineties;
  131. if (sample)
  132. mci_writel(host, TIMING_CON1,
  133. FIELD_PREP_WM16(GENMASK(11, 1), raw_value));
  134. else
  135. mci_writel(host, TIMING_CON0,
  136. FIELD_PREP_WM16(GENMASK(11, 1), raw_value));
  137. dev_dbg(host->dev, "set %s_phase(%d) delay_nums=%u actual_degrees=%d\n",
  138. sample ? "sample" : "drv", degrees, delay_num,
  139. rockchip_mmc_get_phase(host, sample)
  140. );
  141. return 0;
  142. }
  143. static int rockchip_mmc_set_phase(struct dw_mci *host, bool sample, int degrees)
  144. {
  145. struct dw_mci_rockchip_priv_data *priv = host->priv;
  146. struct clk *clock = sample ? priv->sample_clk : priv->drv_clk;
  147. if (priv->internal_phase)
  148. return rockchip_mmc_set_internal_phase(host, sample, degrees);
  149. else
  150. return clk_set_phase(clock, degrees);
  151. }
  152. static void dw_mci_rk3288_set_ios(struct dw_mci *host, struct mmc_ios *ios)
  153. {
  154. struct dw_mci_rockchip_priv_data *priv = host->priv;
  155. int ret;
  156. unsigned int cclkin;
  157. u32 bus_hz;
  158. if (ios->clock == 0)
  159. return;
  160. /*
  161. * cclkin: source clock of mmc controller
  162. * bus_hz: card interface clock generated by CLKGEN
  163. * bus_hz = cclkin / RK3288_CLKGEN_DIV
  164. * ios->clock = (div == 0) ? bus_hz : (bus_hz / (2 * div))
  165. *
  166. * Note: div can only be 0 or 1, but div must be set to 1 for eMMC
  167. * DDR52 8-bit mode.
  168. */
  169. if (ios->bus_width == MMC_BUS_WIDTH_8 &&
  170. ios->timing == MMC_TIMING_MMC_DDR52)
  171. cclkin = 2 * ios->clock * RK3288_CLKGEN_DIV;
  172. else
  173. cclkin = ios->clock * RK3288_CLKGEN_DIV;
  174. ret = clk_set_rate(host->ciu_clk, cclkin);
  175. if (ret)
  176. dev_warn(host->dev, "failed to set rate %uHz err: %d\n", cclkin, ret);
  177. bus_hz = clk_get_rate(host->ciu_clk) / RK3288_CLKGEN_DIV;
  178. if (bus_hz != host->bus_hz) {
  179. host->bus_hz = bus_hz;
  180. /* force dw_mci_setup_bus() */
  181. host->current_speed = 0;
  182. }
  183. /* Make sure we use phases which we can enumerate with */
  184. if (!IS_ERR(priv->sample_clk) && ios->timing <= MMC_TIMING_SD_HS)
  185. rockchip_mmc_set_phase(host, true, priv->default_sample_phase);
  186. /*
  187. * Set the drive phase offset based on speed mode to achieve hold times.
  188. *
  189. * NOTE: this is _not_ a value that is dynamically tuned and is also
  190. * _not_ a value that will vary from board to board. It is a value
  191. * that could vary between different SoC models if they had massively
  192. * different output clock delays inside their dw_mmc IP block (delay_o),
  193. * but since it's OK to overshoot a little we don't need to do complex
  194. * calculations and can pick values that will just work for everyone.
  195. *
  196. * When picking values we'll stick with picking 0/90/180/270 since
  197. * those can be made very accurately on all known Rockchip SoCs.
  198. *
  199. * Note that these values match values from the DesignWare Databook
  200. * tables for the most part except for SDR12 and "ID mode". For those
  201. * two modes the databook calculations assume a clock in of 50MHz. As
  202. * seen above, we always use a clock in rate that is exactly the
  203. * card's input clock (times RK3288_CLKGEN_DIV, but that gets divided
  204. * back out before the controller sees it).
  205. *
  206. * From measurement of a single device, it appears that delay_o is
  207. * about .5 ns. Since we try to leave a bit of margin, it's expected
  208. * that numbers here will be fine even with much larger delay_o
  209. * (the 1.4 ns assumed by the DesignWare Databook would result in the
  210. * same results, for instance).
  211. */
  212. if (!IS_ERR(priv->drv_clk)) {
  213. int phase;
  214. /*
  215. * In almost all cases a 90 degree phase offset will provide
  216. * sufficient hold times across all valid input clock rates
  217. * assuming delay_o is not absurd for a given SoC. We'll use
  218. * that as a default.
  219. */
  220. phase = 90;
  221. switch (ios->timing) {
  222. case MMC_TIMING_MMC_DDR52:
  223. /*
  224. * Since clock in rate with MMC_DDR52 is doubled when
  225. * bus width is 8 we need to double the phase offset
  226. * to get the same timings.
  227. */
  228. if (ios->bus_width == MMC_BUS_WIDTH_8)
  229. phase = 180;
  230. break;
  231. case MMC_TIMING_UHS_SDR104:
  232. case MMC_TIMING_MMC_HS200:
  233. /*
  234. * In the case of 150 MHz clock (typical max for
  235. * Rockchip SoCs), 90 degree offset will add a delay
  236. * of 1.67 ns. That will meet min hold time of .8 ns
  237. * as long as clock output delay is < .87 ns. On
  238. * SoCs measured this seems to be OK, but it doesn't
  239. * hurt to give margin here, so we use 180.
  240. */
  241. phase = 180;
  242. break;
  243. }
  244. rockchip_mmc_set_phase(host, false, phase);
  245. }
  246. }
  247. #define TUNING_ITERATION_TO_PHASE(i, num_phases) \
  248. (DIV_ROUND_UP((i) * 360, num_phases))
  249. static int dw_mci_rk3288_execute_tuning(struct dw_mci_slot *slot, u32 opcode)
  250. {
  251. struct dw_mci *host = slot->host;
  252. struct dw_mci_rockchip_priv_data *priv = host->priv;
  253. struct mmc_host *mmc = slot->mmc;
  254. int ret = 0;
  255. int i;
  256. bool v, prev_v = 0, first_v;
  257. struct range_t {
  258. int start;
  259. int end; /* inclusive */
  260. };
  261. struct range_t *ranges;
  262. unsigned int range_count = 0;
  263. int longest_range_len = -1;
  264. int longest_range = -1;
  265. int middle_phase;
  266. int phase;
  267. if (IS_ERR(priv->sample_clk)) {
  268. dev_err(host->dev, "Tuning clock (sample_clk) not defined.\n");
  269. return -EIO;
  270. }
  271. ranges = kmalloc_objs(*ranges, priv->num_phases / 2 + 1);
  272. if (!ranges)
  273. return -ENOMEM;
  274. /* Try each phase and extract good ranges */
  275. for (i = 0; i < priv->num_phases; ) {
  276. rockchip_mmc_set_phase(host, true,
  277. TUNING_ITERATION_TO_PHASE(
  278. i,
  279. priv->num_phases));
  280. v = !mmc_send_tuning(mmc, opcode, NULL);
  281. if (i == 0)
  282. first_v = v;
  283. if ((!prev_v) && v) {
  284. range_count++;
  285. ranges[range_count-1].start = i;
  286. }
  287. if (v) {
  288. ranges[range_count-1].end = i;
  289. i++;
  290. } else if (i == priv->num_phases - 1) {
  291. /* No extra skipping rules if we're at the end */
  292. i++;
  293. } else {
  294. /*
  295. * No need to check too close to an invalid
  296. * one since testing bad phases is slow. Skip
  297. * 20 degrees.
  298. */
  299. i += DIV_ROUND_UP(20 * priv->num_phases, 360);
  300. /* Always test the last one */
  301. if (i >= priv->num_phases)
  302. i = priv->num_phases - 1;
  303. }
  304. prev_v = v;
  305. }
  306. if (range_count == 0) {
  307. dev_warn(host->dev, "All phases bad!");
  308. ret = -EIO;
  309. goto free;
  310. }
  311. /* wrap around case, merge the end points */
  312. if ((range_count > 1) && first_v && v) {
  313. ranges[0].start = ranges[range_count-1].start;
  314. range_count--;
  315. }
  316. if (ranges[0].start == 0 && ranges[0].end == priv->num_phases - 1) {
  317. rockchip_mmc_set_phase(host, true, priv->default_sample_phase);
  318. dev_info(host->dev, "All phases work, using default phase %d.",
  319. priv->default_sample_phase);
  320. goto free;
  321. }
  322. /* Find the longest range */
  323. for (i = 0; i < range_count; i++) {
  324. int len = (ranges[i].end - ranges[i].start + 1);
  325. if (len < 0)
  326. len += priv->num_phases;
  327. if (longest_range_len < len) {
  328. longest_range_len = len;
  329. longest_range = i;
  330. }
  331. dev_dbg(host->dev, "Good phase range %d-%d (%d len)\n",
  332. TUNING_ITERATION_TO_PHASE(ranges[i].start,
  333. priv->num_phases),
  334. TUNING_ITERATION_TO_PHASE(ranges[i].end,
  335. priv->num_phases),
  336. len
  337. );
  338. }
  339. dev_dbg(host->dev, "Best phase range %d-%d (%d len)\n",
  340. TUNING_ITERATION_TO_PHASE(ranges[longest_range].start,
  341. priv->num_phases),
  342. TUNING_ITERATION_TO_PHASE(ranges[longest_range].end,
  343. priv->num_phases),
  344. longest_range_len
  345. );
  346. middle_phase = ranges[longest_range].start + longest_range_len / 2;
  347. middle_phase %= priv->num_phases;
  348. phase = TUNING_ITERATION_TO_PHASE(middle_phase, priv->num_phases);
  349. dev_info(host->dev, "Successfully tuned phase to %d\n", phase);
  350. rockchip_mmc_set_phase(host, true, phase);
  351. free:
  352. kfree(ranges);
  353. return ret;
  354. }
  355. static int dw_mci_common_parse_dt(struct dw_mci *host)
  356. {
  357. struct device_node *np = host->dev->of_node;
  358. struct dw_mci_rockchip_priv_data *priv;
  359. priv = devm_kzalloc(host->dev, sizeof(*priv), GFP_KERNEL);
  360. if (!priv)
  361. return -ENOMEM;
  362. if (of_property_read_u32(np, "rockchip,desired-num-phases",
  363. &priv->num_phases))
  364. priv->num_phases = 360;
  365. if (of_property_read_u32(np, "rockchip,default-sample-phase",
  366. &priv->default_sample_phase))
  367. priv->default_sample_phase = 0;
  368. host->priv = priv;
  369. return 0;
  370. }
  371. static int dw_mci_rk3288_parse_dt(struct dw_mci *host)
  372. {
  373. struct dw_mci_rockchip_priv_data *priv;
  374. int err;
  375. err = dw_mci_common_parse_dt(host);
  376. if (err)
  377. return err;
  378. priv = host->priv;
  379. priv->drv_clk = devm_clk_get(host->dev, "ciu-drive");
  380. if (IS_ERR(priv->drv_clk))
  381. dev_dbg(host->dev, "ciu-drive not available\n");
  382. priv->sample_clk = devm_clk_get(host->dev, "ciu-sample");
  383. if (IS_ERR(priv->sample_clk))
  384. dev_dbg(host->dev, "ciu-sample not available\n");
  385. priv->internal_phase = false;
  386. return 0;
  387. }
  388. static int dw_mci_rk3576_parse_dt(struct dw_mci *host)
  389. {
  390. struct dw_mci_rockchip_priv_data *priv;
  391. int err = dw_mci_common_parse_dt(host);
  392. if (err)
  393. return err;
  394. priv = host->priv;
  395. priv->internal_phase = true;
  396. return 0;
  397. }
  398. static int dw_mci_rockchip_init(struct dw_mci *host)
  399. {
  400. struct dw_mci_rockchip_priv_data *priv = host->priv;
  401. int ret, i;
  402. /* It is slot 8 on Rockchip SoCs */
  403. host->sdio_id0 = 8;
  404. if (of_device_is_compatible(host->dev->of_node, "rockchip,rk3288-dw-mshc")) {
  405. host->bus_hz /= RK3288_CLKGEN_DIV;
  406. /* clock driver will fail if the clock is less than the lowest source clock
  407. * divided by the internal clock divider. Test for the lowest available
  408. * clock and set the minimum freq to clock / clock divider.
  409. */
  410. for (i = 0; i < ARRAY_SIZE(freqs); i++) {
  411. ret = clk_round_rate(host->ciu_clk, freqs[i] * RK3288_CLKGEN_DIV);
  412. if (ret > 0) {
  413. host->minimum_speed = ret / RK3288_CLKGEN_DIV;
  414. break;
  415. }
  416. }
  417. if (ret < 0)
  418. dev_warn(host->dev, "no valid minimum freq: %d\n", ret);
  419. }
  420. if (priv->internal_phase)
  421. mci_writel(host, MISC_CON, MEM_CLK_AUTOGATE_ENABLE);
  422. return 0;
  423. }
  424. static const struct dw_mci_drv_data rk2928_drv_data = {
  425. .init = dw_mci_rockchip_init,
  426. };
  427. static const struct dw_mci_drv_data rk3288_drv_data = {
  428. .common_caps = MMC_CAP_CMD23,
  429. .set_ios = dw_mci_rk3288_set_ios,
  430. .execute_tuning = dw_mci_rk3288_execute_tuning,
  431. .parse_dt = dw_mci_rk3288_parse_dt,
  432. .init = dw_mci_rockchip_init,
  433. };
  434. static const struct dw_mci_drv_data rk3576_drv_data = {
  435. .common_caps = MMC_CAP_CMD23,
  436. .set_ios = dw_mci_rk3288_set_ios,
  437. .execute_tuning = dw_mci_rk3288_execute_tuning,
  438. .parse_dt = dw_mci_rk3576_parse_dt,
  439. .init = dw_mci_rockchip_init,
  440. };
  441. static const struct of_device_id dw_mci_rockchip_match[] = {
  442. { .compatible = "rockchip,rk2928-dw-mshc",
  443. .data = &rk2928_drv_data },
  444. { .compatible = "rockchip,rk3288-dw-mshc",
  445. .data = &rk3288_drv_data },
  446. { .compatible = "rockchip,rk3576-dw-mshc",
  447. .data = &rk3576_drv_data },
  448. {},
  449. };
  450. MODULE_DEVICE_TABLE(of, dw_mci_rockchip_match);
  451. static int dw_mci_rockchip_probe(struct platform_device *pdev)
  452. {
  453. const struct dw_mci_drv_data *drv_data;
  454. const struct of_device_id *match;
  455. int ret;
  456. if (!pdev->dev.of_node)
  457. return -ENODEV;
  458. match = of_match_node(dw_mci_rockchip_match, pdev->dev.of_node);
  459. drv_data = match->data;
  460. pm_runtime_get_noresume(&pdev->dev);
  461. pm_runtime_set_active(&pdev->dev);
  462. pm_runtime_enable(&pdev->dev);
  463. pm_runtime_set_autosuspend_delay(&pdev->dev, 50);
  464. pm_runtime_use_autosuspend(&pdev->dev);
  465. ret = dw_mci_pltfm_register(pdev, drv_data);
  466. if (ret) {
  467. pm_runtime_disable(&pdev->dev);
  468. pm_runtime_set_suspended(&pdev->dev);
  469. pm_runtime_put_noidle(&pdev->dev);
  470. return ret;
  471. }
  472. pm_runtime_put_autosuspend(&pdev->dev);
  473. return 0;
  474. }
  475. static void dw_mci_rockchip_remove(struct platform_device *pdev)
  476. {
  477. pm_runtime_get_sync(&pdev->dev);
  478. pm_runtime_disable(&pdev->dev);
  479. pm_runtime_put_noidle(&pdev->dev);
  480. dw_mci_pltfm_remove(pdev);
  481. }
  482. static int dw_mci_rockchip_runtime_suspend(struct device *dev)
  483. {
  484. struct platform_device *pdev = to_platform_device(dev);
  485. struct dw_mci *host = platform_get_drvdata(pdev);
  486. struct dw_mci_rockchip_priv_data *priv = host->priv;
  487. if (priv->internal_phase) {
  488. priv->sample_phase = rockchip_mmc_get_phase(host, true);
  489. priv->drv_phase = rockchip_mmc_get_phase(host, false);
  490. }
  491. return dw_mci_runtime_suspend(dev);
  492. }
  493. static int dw_mci_rockchip_runtime_resume(struct device *dev)
  494. {
  495. struct platform_device *pdev = to_platform_device(dev);
  496. struct dw_mci *host = platform_get_drvdata(pdev);
  497. struct dw_mci_rockchip_priv_data *priv = host->priv;
  498. int ret;
  499. ret = dw_mci_runtime_resume(dev);
  500. if (ret)
  501. return ret;
  502. if (priv->internal_phase) {
  503. rockchip_mmc_set_phase(host, true, priv->sample_phase);
  504. rockchip_mmc_set_phase(host, false, priv->drv_phase);
  505. mci_writel(host, MISC_CON, MEM_CLK_AUTOGATE_ENABLE);
  506. }
  507. return ret;
  508. }
  509. static const struct dev_pm_ops dw_mci_rockchip_dev_pm_ops = {
  510. SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, pm_runtime_force_resume)
  511. RUNTIME_PM_OPS(dw_mci_rockchip_runtime_suspend, dw_mci_rockchip_runtime_resume, NULL)
  512. };
  513. static struct platform_driver dw_mci_rockchip_pltfm_driver = {
  514. .probe = dw_mci_rockchip_probe,
  515. .remove = dw_mci_rockchip_remove,
  516. .driver = {
  517. .name = "dwmmc_rockchip",
  518. .probe_type = PROBE_PREFER_ASYNCHRONOUS,
  519. .of_match_table = dw_mci_rockchip_match,
  520. .pm = pm_ptr(&dw_mci_rockchip_dev_pm_ops),
  521. },
  522. };
  523. module_platform_driver(dw_mci_rockchip_pltfm_driver);
  524. MODULE_AUTHOR("Addy Ke <addy.ke@rock-chips.com>");
  525. MODULE_DESCRIPTION("Rockchip Specific DW-MSHC Driver Extension");
  526. MODULE_ALIAS("platform:dwmmc_rockchip");
  527. MODULE_LICENSE("GPL v2");