mmci_stm32_sdmmc.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Copyright (C) STMicroelectronics 2018 - All Rights Reserved
  4. * Author: [email protected] for STMicroelectronics.
  5. */
  6. #include <linux/bitfield.h>
  7. #include <linux/delay.h>
  8. #include <linux/dma-mapping.h>
  9. #include <linux/iopoll.h>
  10. #include <linux/mmc/host.h>
  11. #include <linux/mmc/card.h>
  12. #include <linux/of_address.h>
  13. #include <linux/reset.h>
  14. #include <linux/scatterlist.h>
  15. #include "mmci.h"
  16. #define SDMMC_LLI_BUF_LEN PAGE_SIZE
  17. #define SDMMC_IDMA_BURST BIT(MMCI_STM32_IDMABNDT_SHIFT)
  18. #define DLYB_CR 0x0
  19. #define DLYB_CR_DEN BIT(0)
  20. #define DLYB_CR_SEN BIT(1)
  21. #define DLYB_CFGR 0x4
  22. #define DLYB_CFGR_SEL_MASK GENMASK(3, 0)
  23. #define DLYB_CFGR_UNIT_MASK GENMASK(14, 8)
  24. #define DLYB_CFGR_LNG_MASK GENMASK(27, 16)
  25. #define DLYB_CFGR_LNGF BIT(31)
  26. #define DLYB_NB_DELAY 11
  27. #define DLYB_CFGR_SEL_MAX (DLYB_NB_DELAY + 1)
  28. #define DLYB_CFGR_UNIT_MAX 127
  29. #define DLYB_LNG_TIMEOUT_US 1000
  30. #define SDMMC_VSWEND_TIMEOUT_US 10000
  31. struct sdmmc_lli_desc {
  32. u32 idmalar;
  33. u32 idmabase;
  34. u32 idmasize;
  35. };
  36. struct sdmmc_idma {
  37. dma_addr_t sg_dma;
  38. void *sg_cpu;
  39. dma_addr_t bounce_dma_addr;
  40. void *bounce_buf;
  41. bool use_bounce_buffer;
  42. };
  43. struct sdmmc_dlyb {
  44. void __iomem *base;
  45. u32 unit;
  46. u32 max;
  47. };
  48. static int sdmmc_idma_validate_data(struct mmci_host *host,
  49. struct mmc_data *data)
  50. {
  51. struct sdmmc_idma *idma = host->dma_priv;
  52. struct device *dev = mmc_dev(host->mmc);
  53. struct scatterlist *sg;
  54. int i;
  55. /*
  56. * idma has constraints on idmabase & idmasize for each element
  57. * excepted the last element which has no constraint on idmasize
  58. */
  59. idma->use_bounce_buffer = false;
  60. for_each_sg(data->sg, sg, data->sg_len - 1, i) {
  61. if (!IS_ALIGNED(sg->offset, sizeof(u32)) ||
  62. !IS_ALIGNED(sg->length, SDMMC_IDMA_BURST)) {
  63. dev_dbg(mmc_dev(host->mmc),
  64. "unaligned scatterlist: ofst:%x length:%d\n",
  65. data->sg->offset, data->sg->length);
  66. goto use_bounce_buffer;
  67. }
  68. }
  69. if (!IS_ALIGNED(sg->offset, sizeof(u32))) {
  70. dev_dbg(mmc_dev(host->mmc),
  71. "unaligned last scatterlist: ofst:%x length:%d\n",
  72. data->sg->offset, data->sg->length);
  73. goto use_bounce_buffer;
  74. }
  75. return 0;
  76. use_bounce_buffer:
  77. if (!idma->bounce_buf) {
  78. idma->bounce_buf = dmam_alloc_coherent(dev,
  79. host->mmc->max_req_size,
  80. &idma->bounce_dma_addr,
  81. GFP_KERNEL);
  82. if (!idma->bounce_buf) {
  83. dev_err(dev, "Unable to map allocate DMA bounce buffer.\n");
  84. return -ENOMEM;
  85. }
  86. }
  87. idma->use_bounce_buffer = true;
  88. return 0;
  89. }
  90. static int _sdmmc_idma_prep_data(struct mmci_host *host,
  91. struct mmc_data *data)
  92. {
  93. struct sdmmc_idma *idma = host->dma_priv;
  94. if (idma->use_bounce_buffer) {
  95. if (data->flags & MMC_DATA_WRITE) {
  96. unsigned int xfer_bytes = data->blksz * data->blocks;
  97. sg_copy_to_buffer(data->sg, data->sg_len,
  98. idma->bounce_buf, xfer_bytes);
  99. dma_wmb();
  100. }
  101. } else {
  102. int n_elem;
  103. n_elem = dma_map_sg(mmc_dev(host->mmc),
  104. data->sg,
  105. data->sg_len,
  106. mmc_get_dma_dir(data));
  107. if (!n_elem) {
  108. dev_err(mmc_dev(host->mmc), "dma_map_sg failed\n");
  109. return -EINVAL;
  110. }
  111. }
  112. return 0;
  113. }
  114. static int sdmmc_idma_prep_data(struct mmci_host *host,
  115. struct mmc_data *data, bool next)
  116. {
  117. /* Check if job is already prepared. */
  118. if (!next && data->host_cookie == host->next_cookie)
  119. return 0;
  120. return _sdmmc_idma_prep_data(host, data);
  121. }
  122. static void sdmmc_idma_unprep_data(struct mmci_host *host,
  123. struct mmc_data *data, int err)
  124. {
  125. struct sdmmc_idma *idma = host->dma_priv;
  126. if (idma->use_bounce_buffer) {
  127. if (data->flags & MMC_DATA_READ) {
  128. unsigned int xfer_bytes = data->blksz * data->blocks;
  129. sg_copy_from_buffer(data->sg, data->sg_len,
  130. idma->bounce_buf, xfer_bytes);
  131. }
  132. } else {
  133. dma_unmap_sg(mmc_dev(host->mmc), data->sg, data->sg_len,
  134. mmc_get_dma_dir(data));
  135. }
  136. }
  137. static int sdmmc_idma_setup(struct mmci_host *host)
  138. {
  139. struct sdmmc_idma *idma;
  140. struct device *dev = mmc_dev(host->mmc);
  141. idma = devm_kzalloc(dev, sizeof(*idma), GFP_KERNEL);
  142. if (!idma)
  143. return -ENOMEM;
  144. host->dma_priv = idma;
  145. if (host->variant->dma_lli) {
  146. idma->sg_cpu = dmam_alloc_coherent(dev, SDMMC_LLI_BUF_LEN,
  147. &idma->sg_dma, GFP_KERNEL);
  148. if (!idma->sg_cpu) {
  149. dev_err(dev, "Failed to alloc IDMA descriptor\n");
  150. return -ENOMEM;
  151. }
  152. host->mmc->max_segs = SDMMC_LLI_BUF_LEN /
  153. sizeof(struct sdmmc_lli_desc);
  154. host->mmc->max_seg_size = host->variant->stm32_idmabsize_mask;
  155. host->mmc->max_req_size = SZ_1M;
  156. } else {
  157. host->mmc->max_segs = 1;
  158. host->mmc->max_seg_size = host->mmc->max_req_size;
  159. }
  160. return dma_set_max_seg_size(dev, host->mmc->max_seg_size);
  161. }
  162. static int sdmmc_idma_start(struct mmci_host *host, unsigned int *datactrl)
  163. {
  164. struct sdmmc_idma *idma = host->dma_priv;
  165. struct sdmmc_lli_desc *desc = (struct sdmmc_lli_desc *)idma->sg_cpu;
  166. struct mmc_data *data = host->data;
  167. struct scatterlist *sg;
  168. int i;
  169. if (!host->variant->dma_lli || data->sg_len == 1 ||
  170. idma->use_bounce_buffer) {
  171. u32 dma_addr;
  172. if (idma->use_bounce_buffer)
  173. dma_addr = idma->bounce_dma_addr;
  174. else
  175. dma_addr = sg_dma_address(data->sg);
  176. writel_relaxed(dma_addr,
  177. host->base + MMCI_STM32_IDMABASE0R);
  178. writel_relaxed(MMCI_STM32_IDMAEN,
  179. host->base + MMCI_STM32_IDMACTRLR);
  180. return 0;
  181. }
  182. for_each_sg(data->sg, sg, data->sg_len, i) {
  183. desc[i].idmalar = (i + 1) * sizeof(struct sdmmc_lli_desc);
  184. desc[i].idmalar |= MMCI_STM32_ULA | MMCI_STM32_ULS
  185. | MMCI_STM32_ABR;
  186. desc[i].idmabase = sg_dma_address(sg);
  187. desc[i].idmasize = sg_dma_len(sg);
  188. }
  189. /* notice the end of link list */
  190. desc[data->sg_len - 1].idmalar &= ~MMCI_STM32_ULA;
  191. dma_wmb();
  192. writel_relaxed(idma->sg_dma, host->base + MMCI_STM32_IDMABAR);
  193. writel_relaxed(desc[0].idmalar, host->base + MMCI_STM32_IDMALAR);
  194. writel_relaxed(desc[0].idmabase, host->base + MMCI_STM32_IDMABASE0R);
  195. writel_relaxed(desc[0].idmasize, host->base + MMCI_STM32_IDMABSIZER);
  196. writel_relaxed(MMCI_STM32_IDMAEN | MMCI_STM32_IDMALLIEN,
  197. host->base + MMCI_STM32_IDMACTRLR);
  198. return 0;
  199. }
  200. static void sdmmc_idma_finalize(struct mmci_host *host, struct mmc_data *data)
  201. {
  202. writel_relaxed(0, host->base + MMCI_STM32_IDMACTRLR);
  203. if (!data->host_cookie)
  204. sdmmc_idma_unprep_data(host, data, 0);
  205. }
  206. static void mmci_sdmmc_set_clkreg(struct mmci_host *host, unsigned int desired)
  207. {
  208. unsigned int clk = 0, ddr = 0;
  209. if (host->mmc->ios.timing == MMC_TIMING_MMC_DDR52 ||
  210. host->mmc->ios.timing == MMC_TIMING_UHS_DDR50)
  211. ddr = MCI_STM32_CLK_DDR;
  212. /*
  213. * cclk = mclk / (2 * clkdiv)
  214. * clkdiv 0 => bypass
  215. * in ddr mode bypass is not possible
  216. */
  217. if (desired) {
  218. if (desired >= host->mclk && !ddr) {
  219. host->cclk = host->mclk;
  220. } else {
  221. clk = DIV_ROUND_UP(host->mclk, 2 * desired);
  222. if (clk > MCI_STM32_CLK_CLKDIV_MSK)
  223. clk = MCI_STM32_CLK_CLKDIV_MSK;
  224. host->cclk = host->mclk / (2 * clk);
  225. }
  226. } else {
  227. /*
  228. * while power-on phase the clock can't be define to 0,
  229. * Only power-off and power-cyc deactivate the clock.
  230. * if desired clock is 0, set max divider
  231. */
  232. clk = MCI_STM32_CLK_CLKDIV_MSK;
  233. host->cclk = host->mclk / (2 * clk);
  234. }
  235. /* Set actual clock for debug */
  236. if (host->mmc->ios.power_mode == MMC_POWER_ON)
  237. host->mmc->actual_clock = host->cclk;
  238. else
  239. host->mmc->actual_clock = 0;
  240. if (host->mmc->ios.bus_width == MMC_BUS_WIDTH_4)
  241. clk |= MCI_STM32_CLK_WIDEBUS_4;
  242. if (host->mmc->ios.bus_width == MMC_BUS_WIDTH_8)
  243. clk |= MCI_STM32_CLK_WIDEBUS_8;
  244. clk |= MCI_STM32_CLK_HWFCEN;
  245. clk |= host->clk_reg_add;
  246. clk |= ddr;
  247. /*
  248. * SDMMC_FBCK is selected when an external Delay Block is needed
  249. * with SDR104 or HS200.
  250. */
  251. if (host->mmc->ios.timing >= MMC_TIMING_UHS_SDR50) {
  252. clk |= MCI_STM32_CLK_BUSSPEED;
  253. if (host->mmc->ios.timing == MMC_TIMING_UHS_SDR104 ||
  254. host->mmc->ios.timing == MMC_TIMING_MMC_HS200) {
  255. clk &= ~MCI_STM32_CLK_SEL_MSK;
  256. clk |= MCI_STM32_CLK_SELFBCK;
  257. }
  258. }
  259. mmci_write_clkreg(host, clk);
  260. }
  261. static void sdmmc_dlyb_input_ck(struct sdmmc_dlyb *dlyb)
  262. {
  263. if (!dlyb || !dlyb->base)
  264. return;
  265. /* Output clock = Input clock */
  266. writel_relaxed(0, dlyb->base + DLYB_CR);
  267. }
  268. static void mmci_sdmmc_set_pwrreg(struct mmci_host *host, unsigned int pwr)
  269. {
  270. struct mmc_ios ios = host->mmc->ios;
  271. struct sdmmc_dlyb *dlyb = host->variant_priv;
  272. /* adds OF options */
  273. pwr = host->pwr_reg_add;
  274. sdmmc_dlyb_input_ck(dlyb);
  275. if (ios.power_mode == MMC_POWER_OFF) {
  276. /* Only a reset could power-off sdmmc */
  277. reset_control_assert(host->rst);
  278. udelay(2);
  279. reset_control_deassert(host->rst);
  280. /*
  281. * Set the SDMMC in Power-cycle state.
  282. * This will make that the SDMMC_D[7:0], SDMMC_CMD and SDMMC_CK
  283. * are driven low, to prevent the Card from being supplied
  284. * through the signal lines.
  285. */
  286. mmci_write_pwrreg(host, MCI_STM32_PWR_CYC | pwr);
  287. } else if (ios.power_mode == MMC_POWER_ON) {
  288. /*
  289. * After power-off (reset): the irq mask defined in probe
  290. * functionis lost
  291. * ault irq mask (probe) must be activated
  292. */
  293. writel(MCI_IRQENABLE | host->variant->start_err,
  294. host->base + MMCIMASK0);
  295. /* preserves voltage switch bits */
  296. pwr |= host->pwr_reg & (MCI_STM32_VSWITCHEN |
  297. MCI_STM32_VSWITCH);
  298. /*
  299. * After a power-cycle state, we must set the SDMMC in
  300. * Power-off. The SDMMC_D[7:0], SDMMC_CMD and SDMMC_CK are
  301. * driven high. Then we can set the SDMMC to Power-on state
  302. */
  303. mmci_write_pwrreg(host, MCI_PWR_OFF | pwr);
  304. mdelay(1);
  305. mmci_write_pwrreg(host, MCI_PWR_ON | pwr);
  306. }
  307. }
  308. static u32 sdmmc_get_dctrl_cfg(struct mmci_host *host)
  309. {
  310. u32 datactrl;
  311. datactrl = mmci_dctrl_blksz(host);
  312. if (host->mmc->card && mmc_card_sdio(host->mmc->card) &&
  313. host->data->blocks == 1)
  314. datactrl |= MCI_DPSM_STM32_MODE_SDIO;
  315. else if (host->data->stop && !host->mrq->sbc)
  316. datactrl |= MCI_DPSM_STM32_MODE_BLOCK_STOP;
  317. else
  318. datactrl |= MCI_DPSM_STM32_MODE_BLOCK;
  319. return datactrl;
  320. }
  321. static bool sdmmc_busy_complete(struct mmci_host *host, u32 status, u32 err_msk)
  322. {
  323. void __iomem *base = host->base;
  324. u32 busy_d0, busy_d0end, mask, sdmmc_status;
  325. mask = readl_relaxed(base + MMCIMASK0);
  326. sdmmc_status = readl_relaxed(base + MMCISTATUS);
  327. busy_d0end = sdmmc_status & MCI_STM32_BUSYD0END;
  328. busy_d0 = sdmmc_status & MCI_STM32_BUSYD0;
  329. /* complete if there is an error or busy_d0end */
  330. if ((status & err_msk) || busy_d0end)
  331. goto complete;
  332. /*
  333. * On response the busy signaling is reflected in the BUSYD0 flag.
  334. * if busy_d0 is in-progress we must activate busyd0end interrupt
  335. * to wait this completion. Else this request has no busy step.
  336. */
  337. if (busy_d0) {
  338. if (!host->busy_status) {
  339. writel_relaxed(mask | host->variant->busy_detect_mask,
  340. base + MMCIMASK0);
  341. host->busy_status = status &
  342. (MCI_CMDSENT | MCI_CMDRESPEND);
  343. }
  344. return false;
  345. }
  346. complete:
  347. if (host->busy_status) {
  348. writel_relaxed(mask & ~host->variant->busy_detect_mask,
  349. base + MMCIMASK0);
  350. host->busy_status = 0;
  351. }
  352. writel_relaxed(host->variant->busy_detect_mask, base + MMCICLEAR);
  353. return true;
  354. }
  355. static void sdmmc_dlyb_set_cfgr(struct sdmmc_dlyb *dlyb,
  356. int unit, int phase, bool sampler)
  357. {
  358. u32 cfgr;
  359. writel_relaxed(DLYB_CR_SEN | DLYB_CR_DEN, dlyb->base + DLYB_CR);
  360. cfgr = FIELD_PREP(DLYB_CFGR_UNIT_MASK, unit) |
  361. FIELD_PREP(DLYB_CFGR_SEL_MASK, phase);
  362. writel_relaxed(cfgr, dlyb->base + DLYB_CFGR);
  363. if (!sampler)
  364. writel_relaxed(DLYB_CR_DEN, dlyb->base + DLYB_CR);
  365. }
  366. static int sdmmc_dlyb_lng_tuning(struct mmci_host *host)
  367. {
  368. struct sdmmc_dlyb *dlyb = host->variant_priv;
  369. u32 cfgr;
  370. int i, lng, ret;
  371. for (i = 0; i <= DLYB_CFGR_UNIT_MAX; i++) {
  372. sdmmc_dlyb_set_cfgr(dlyb, i, DLYB_CFGR_SEL_MAX, true);
  373. ret = readl_relaxed_poll_timeout(dlyb->base + DLYB_CFGR, cfgr,
  374. (cfgr & DLYB_CFGR_LNGF),
  375. 1, DLYB_LNG_TIMEOUT_US);
  376. if (ret) {
  377. dev_warn(mmc_dev(host->mmc),
  378. "delay line cfg timeout unit:%d cfgr:%d\n",
  379. i, cfgr);
  380. continue;
  381. }
  382. lng = FIELD_GET(DLYB_CFGR_LNG_MASK, cfgr);
  383. if (lng < BIT(DLYB_NB_DELAY) && lng > 0)
  384. break;
  385. }
  386. if (i > DLYB_CFGR_UNIT_MAX)
  387. return -EINVAL;
  388. dlyb->unit = i;
  389. dlyb->max = __fls(lng);
  390. return 0;
  391. }
  392. static int sdmmc_dlyb_phase_tuning(struct mmci_host *host, u32 opcode)
  393. {
  394. struct sdmmc_dlyb *dlyb = host->variant_priv;
  395. int cur_len = 0, max_len = 0, end_of_len = 0;
  396. int phase;
  397. for (phase = 0; phase <= dlyb->max; phase++) {
  398. sdmmc_dlyb_set_cfgr(dlyb, dlyb->unit, phase, false);
  399. if (mmc_send_tuning(host->mmc, opcode, NULL)) {
  400. cur_len = 0;
  401. } else {
  402. cur_len++;
  403. if (cur_len > max_len) {
  404. max_len = cur_len;
  405. end_of_len = phase;
  406. }
  407. }
  408. }
  409. if (!max_len) {
  410. dev_err(mmc_dev(host->mmc), "no tuning point found\n");
  411. return -EINVAL;
  412. }
  413. writel_relaxed(0, dlyb->base + DLYB_CR);
  414. phase = end_of_len - max_len / 2;
  415. sdmmc_dlyb_set_cfgr(dlyb, dlyb->unit, phase, false);
  416. dev_dbg(mmc_dev(host->mmc), "unit:%d max_dly:%d phase:%d\n",
  417. dlyb->unit, dlyb->max, phase);
  418. return 0;
  419. }
  420. static int sdmmc_execute_tuning(struct mmc_host *mmc, u32 opcode)
  421. {
  422. struct mmci_host *host = mmc_priv(mmc);
  423. struct sdmmc_dlyb *dlyb = host->variant_priv;
  424. if (!dlyb || !dlyb->base)
  425. return -EINVAL;
  426. if (sdmmc_dlyb_lng_tuning(host))
  427. return -EINVAL;
  428. return sdmmc_dlyb_phase_tuning(host, opcode);
  429. }
  430. static void sdmmc_pre_sig_volt_vswitch(struct mmci_host *host)
  431. {
  432. /* clear the voltage switch completion flag */
  433. writel_relaxed(MCI_STM32_VSWENDC, host->base + MMCICLEAR);
  434. /* enable Voltage switch procedure */
  435. mmci_write_pwrreg(host, host->pwr_reg | MCI_STM32_VSWITCHEN);
  436. }
  437. static int sdmmc_post_sig_volt_switch(struct mmci_host *host,
  438. struct mmc_ios *ios)
  439. {
  440. unsigned long flags;
  441. u32 status;
  442. int ret = 0;
  443. spin_lock_irqsave(&host->lock, flags);
  444. if (ios->signal_voltage == MMC_SIGNAL_VOLTAGE_180 &&
  445. host->pwr_reg & MCI_STM32_VSWITCHEN) {
  446. mmci_write_pwrreg(host, host->pwr_reg | MCI_STM32_VSWITCH);
  447. spin_unlock_irqrestore(&host->lock, flags);
  448. /* wait voltage switch completion while 10ms */
  449. ret = readl_relaxed_poll_timeout(host->base + MMCISTATUS,
  450. status,
  451. (status & MCI_STM32_VSWEND),
  452. 10, SDMMC_VSWEND_TIMEOUT_US);
  453. writel_relaxed(MCI_STM32_VSWENDC | MCI_STM32_CKSTOPC,
  454. host->base + MMCICLEAR);
  455. spin_lock_irqsave(&host->lock, flags);
  456. mmci_write_pwrreg(host, host->pwr_reg &
  457. ~(MCI_STM32_VSWITCHEN | MCI_STM32_VSWITCH));
  458. }
  459. spin_unlock_irqrestore(&host->lock, flags);
  460. return ret;
  461. }
  462. static struct mmci_host_ops sdmmc_variant_ops = {
  463. .validate_data = sdmmc_idma_validate_data,
  464. .prep_data = sdmmc_idma_prep_data,
  465. .unprep_data = sdmmc_idma_unprep_data,
  466. .get_datactrl_cfg = sdmmc_get_dctrl_cfg,
  467. .dma_setup = sdmmc_idma_setup,
  468. .dma_start = sdmmc_idma_start,
  469. .dma_finalize = sdmmc_idma_finalize,
  470. .set_clkreg = mmci_sdmmc_set_clkreg,
  471. .set_pwrreg = mmci_sdmmc_set_pwrreg,
  472. .busy_complete = sdmmc_busy_complete,
  473. .pre_sig_volt_switch = sdmmc_pre_sig_volt_vswitch,
  474. .post_sig_volt_switch = sdmmc_post_sig_volt_switch,
  475. };
  476. void sdmmc_variant_init(struct mmci_host *host)
  477. {
  478. struct device_node *np = host->mmc->parent->of_node;
  479. void __iomem *base_dlyb;
  480. struct sdmmc_dlyb *dlyb;
  481. host->ops = &sdmmc_variant_ops;
  482. host->pwr_reg = readl_relaxed(host->base + MMCIPOWER);
  483. base_dlyb = devm_of_iomap(mmc_dev(host->mmc), np, 1, NULL);
  484. if (IS_ERR(base_dlyb))
  485. return;
  486. dlyb = devm_kzalloc(mmc_dev(host->mmc), sizeof(*dlyb), GFP_KERNEL);
  487. if (!dlyb)
  488. return;
  489. dlyb->base = base_dlyb;
  490. host->variant_priv = dlyb;
  491. host->mmc_ops->execute_tuning = sdmmc_execute_tuning;
  492. }