blob: f4283d055fdab453bc51888a8828a2af78cf6416 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Marek Vasut06485cf2018-04-08 15:22:58 +02002/*
3 * Copyright (C) 2018 Marek Vasut <marek.vasut@gmail.com>
Marek Vasut06485cf2018-04-08 15:22:58 +02004 */
5
6#include <common.h>
7#include <clk.h>
8#include <fdtdec.h>
9#include <mmc.h>
10#include <dm.h>
11#include <linux/compat.h>
12#include <linux/dma-direction.h>
13#include <linux/io.h>
14#include <linux/sizes.h>
15#include <power/regulator.h>
16#include <asm/unaligned.h>
17
Marek Vasutfd83e762018-04-13 23:51:33 +020018#include "tmio-common.h"
Marek Vasut06485cf2018-04-08 15:22:58 +020019
Marek Vasute0781e42018-04-08 19:09:17 +020020#if CONFIG_IS_ENABLED(MMC_HS200_SUPPORT)
21
22/* SCC registers */
23#define RENESAS_SDHI_SCC_DTCNTL 0x800
24#define RENESAS_SDHI_SCC_DTCNTL_TAPEN BIT(0)
25#define RENESAS_SDHI_SCC_DTCNTL_TAPNUM_SHIFT 16
26#define RENESAS_SDHI_SCC_DTCNTL_TAPNUM_MASK 0xff
27#define RENESAS_SDHI_SCC_TAPSET 0x804
28#define RENESAS_SDHI_SCC_DT2FF 0x808
29#define RENESAS_SDHI_SCC_CKSEL 0x80c
30#define RENESAS_SDHI_SCC_CKSEL_DTSEL BIT(0)
31#define RENESAS_SDHI_SCC_RVSCNTL 0x810
32#define RENESAS_SDHI_SCC_RVSCNTL_RVSEN BIT(0)
33#define RENESAS_SDHI_SCC_RVSREQ 0x814
34#define RENESAS_SDHI_SCC_RVSREQ_RVSERR BIT(2)
35#define RENESAS_SDHI_SCC_SMPCMP 0x818
36#define RENESAS_SDHI_SCC_TMPPORT2 0x81c
Marek Vasutefea7a82018-06-13 08:02:55 +020037#define RENESAS_SDHI_SCC_TMPPORT2_HS400EN BIT(31)
38#define RENESAS_SDHI_SCC_TMPPORT2_HS400OSEL BIT(4)
Marek Vasute0781e42018-04-08 19:09:17 +020039
40#define RENESAS_SDHI_MAX_TAP 3
41
Marek Vasutfd83e762018-04-13 23:51:33 +020042static unsigned int renesas_sdhi_init_tuning(struct tmio_sd_priv *priv)
Marek Vasute0781e42018-04-08 19:09:17 +020043{
44 u32 reg;
45
46 /* Initialize SCC */
Marek Vasutfd83e762018-04-13 23:51:33 +020047 tmio_sd_writel(priv, 0, TMIO_SD_INFO1);
Marek Vasute0781e42018-04-08 19:09:17 +020048
Marek Vasutfd83e762018-04-13 23:51:33 +020049 reg = tmio_sd_readl(priv, TMIO_SD_CLKCTL);
50 reg &= ~TMIO_SD_CLKCTL_SCLKEN;
51 tmio_sd_writel(priv, reg, TMIO_SD_CLKCTL);
Marek Vasute0781e42018-04-08 19:09:17 +020052
53 /* Set sampling clock selection range */
Marek Vasutda4873d2018-06-13 08:02:55 +020054 tmio_sd_writel(priv, (0x8 << RENESAS_SDHI_SCC_DTCNTL_TAPNUM_SHIFT) |
55 RENESAS_SDHI_SCC_DTCNTL_TAPEN,
56 RENESAS_SDHI_SCC_DTCNTL);
Marek Vasute0781e42018-04-08 19:09:17 +020057
Marek Vasutfd83e762018-04-13 23:51:33 +020058 reg = tmio_sd_readl(priv, RENESAS_SDHI_SCC_CKSEL);
Marek Vasute0781e42018-04-08 19:09:17 +020059 reg |= RENESAS_SDHI_SCC_CKSEL_DTSEL;
Marek Vasutfd83e762018-04-13 23:51:33 +020060 tmio_sd_writel(priv, reg, RENESAS_SDHI_SCC_CKSEL);
Marek Vasute0781e42018-04-08 19:09:17 +020061
Marek Vasutfd83e762018-04-13 23:51:33 +020062 reg = tmio_sd_readl(priv, RENESAS_SDHI_SCC_RVSCNTL);
Marek Vasute0781e42018-04-08 19:09:17 +020063 reg &= ~RENESAS_SDHI_SCC_RVSCNTL_RVSEN;
Marek Vasutfd83e762018-04-13 23:51:33 +020064 tmio_sd_writel(priv, reg, RENESAS_SDHI_SCC_RVSCNTL);
Marek Vasute0781e42018-04-08 19:09:17 +020065
Marek Vasutfd83e762018-04-13 23:51:33 +020066 tmio_sd_writel(priv, 0x300 /* scc_tappos */,
Marek Vasute0781e42018-04-08 19:09:17 +020067 RENESAS_SDHI_SCC_DT2FF);
68
Marek Vasutfd83e762018-04-13 23:51:33 +020069 reg = tmio_sd_readl(priv, TMIO_SD_CLKCTL);
70 reg |= TMIO_SD_CLKCTL_SCLKEN;
71 tmio_sd_writel(priv, reg, TMIO_SD_CLKCTL);
Marek Vasute0781e42018-04-08 19:09:17 +020072
73 /* Read TAPNUM */
Marek Vasutfd83e762018-04-13 23:51:33 +020074 return (tmio_sd_readl(priv, RENESAS_SDHI_SCC_DTCNTL) >>
Marek Vasute0781e42018-04-08 19:09:17 +020075 RENESAS_SDHI_SCC_DTCNTL_TAPNUM_SHIFT) &
76 RENESAS_SDHI_SCC_DTCNTL_TAPNUM_MASK;
77}
78
Marek Vasutfd83e762018-04-13 23:51:33 +020079static void renesas_sdhi_reset_tuning(struct tmio_sd_priv *priv)
Marek Vasute0781e42018-04-08 19:09:17 +020080{
81 u32 reg;
82
83 /* Reset SCC */
Marek Vasutfd83e762018-04-13 23:51:33 +020084 reg = tmio_sd_readl(priv, TMIO_SD_CLKCTL);
85 reg &= ~TMIO_SD_CLKCTL_SCLKEN;
86 tmio_sd_writel(priv, reg, TMIO_SD_CLKCTL);
Marek Vasute0781e42018-04-08 19:09:17 +020087
Marek Vasutfd83e762018-04-13 23:51:33 +020088 reg = tmio_sd_readl(priv, RENESAS_SDHI_SCC_CKSEL);
Marek Vasute0781e42018-04-08 19:09:17 +020089 reg &= ~RENESAS_SDHI_SCC_CKSEL_DTSEL;
Marek Vasutfd83e762018-04-13 23:51:33 +020090 tmio_sd_writel(priv, reg, RENESAS_SDHI_SCC_CKSEL);
Marek Vasute0781e42018-04-08 19:09:17 +020091
Marek Vasutefea7a82018-06-13 08:02:55 +020092 reg = tmio_sd_readl(priv, RENESAS_SDHI_SCC_TMPPORT2);
93 reg &= ~(RENESAS_SDHI_SCC_TMPPORT2_HS400EN |
94 RENESAS_SDHI_SCC_TMPPORT2_HS400OSEL);
95 tmio_sd_writel(priv, reg, RENESAS_SDHI_SCC_TMPPORT2);
96
Marek Vasutfd83e762018-04-13 23:51:33 +020097 reg = tmio_sd_readl(priv, TMIO_SD_CLKCTL);
98 reg |= TMIO_SD_CLKCTL_SCLKEN;
99 tmio_sd_writel(priv, reg, TMIO_SD_CLKCTL);
Marek Vasute0781e42018-04-08 19:09:17 +0200100
Marek Vasutfd83e762018-04-13 23:51:33 +0200101 reg = tmio_sd_readl(priv, RENESAS_SDHI_SCC_RVSCNTL);
Marek Vasute0781e42018-04-08 19:09:17 +0200102 reg &= ~RENESAS_SDHI_SCC_RVSCNTL_RVSEN;
Marek Vasutfd83e762018-04-13 23:51:33 +0200103 tmio_sd_writel(priv, reg, RENESAS_SDHI_SCC_RVSCNTL);
Marek Vasute0781e42018-04-08 19:09:17 +0200104
Marek Vasutfd83e762018-04-13 23:51:33 +0200105 reg = tmio_sd_readl(priv, RENESAS_SDHI_SCC_RVSCNTL);
Marek Vasute0781e42018-04-08 19:09:17 +0200106 reg &= ~RENESAS_SDHI_SCC_RVSCNTL_RVSEN;
Marek Vasutfd83e762018-04-13 23:51:33 +0200107 tmio_sd_writel(priv, reg, RENESAS_SDHI_SCC_RVSCNTL);
Marek Vasute0781e42018-04-08 19:09:17 +0200108}
109
Marek Vasutfd83e762018-04-13 23:51:33 +0200110static void renesas_sdhi_prepare_tuning(struct tmio_sd_priv *priv,
Marek Vasute0781e42018-04-08 19:09:17 +0200111 unsigned long tap)
112{
113 /* Set sampling clock position */
Marek Vasutfd83e762018-04-13 23:51:33 +0200114 tmio_sd_writel(priv, tap, RENESAS_SDHI_SCC_TAPSET);
Marek Vasute0781e42018-04-08 19:09:17 +0200115}
116
Marek Vasutfd83e762018-04-13 23:51:33 +0200117static unsigned int renesas_sdhi_compare_scc_data(struct tmio_sd_priv *priv)
Marek Vasute0781e42018-04-08 19:09:17 +0200118{
119 /* Get comparison of sampling data */
Marek Vasutfd83e762018-04-13 23:51:33 +0200120 return tmio_sd_readl(priv, RENESAS_SDHI_SCC_SMPCMP);
Marek Vasute0781e42018-04-08 19:09:17 +0200121}
122
Marek Vasutfd83e762018-04-13 23:51:33 +0200123static int renesas_sdhi_select_tuning(struct tmio_sd_priv *priv,
Marek Vasute0781e42018-04-08 19:09:17 +0200124 unsigned int tap_num, unsigned int taps,
125 unsigned int smpcmp)
126{
127 unsigned long tap_cnt; /* counter of tuning success */
128 unsigned long tap_set; /* tap position */
129 unsigned long tap_start;/* start position of tuning success */
130 unsigned long tap_end; /* end position of tuning success */
131 unsigned long ntap; /* temporary counter of tuning success */
132 unsigned long match_cnt;/* counter of matching data */
133 unsigned long i;
134 bool select = false;
135 u32 reg;
136
137 /* Clear SCC_RVSREQ */
Marek Vasutfd83e762018-04-13 23:51:33 +0200138 tmio_sd_writel(priv, 0, RENESAS_SDHI_SCC_RVSREQ);
Marek Vasute0781e42018-04-08 19:09:17 +0200139
140 /* Merge the results */
141 for (i = 0; i < tap_num * 2; i++) {
142 if (!(taps & BIT(i))) {
143 taps &= ~BIT(i % tap_num);
144 taps &= ~BIT((i % tap_num) + tap_num);
145 }
146 if (!(smpcmp & BIT(i))) {
147 smpcmp &= ~BIT(i % tap_num);
148 smpcmp &= ~BIT((i % tap_num) + tap_num);
149 }
150 }
151
152 /*
153 * Find the longest consecutive run of successful probes. If that
154 * is more than RENESAS_SDHI_MAX_TAP probes long then use the
155 * center index as the tap.
156 */
157 tap_cnt = 0;
158 ntap = 0;
159 tap_start = 0;
160 tap_end = 0;
161 for (i = 0; i < tap_num * 2; i++) {
162 if (taps & BIT(i))
163 ntap++;
164 else {
165 if (ntap > tap_cnt) {
166 tap_start = i - ntap;
167 tap_end = i - 1;
168 tap_cnt = ntap;
169 }
170 ntap = 0;
171 }
172 }
173
174 if (ntap > tap_cnt) {
175 tap_start = i - ntap;
176 tap_end = i - 1;
177 tap_cnt = ntap;
178 }
179
180 /*
181 * If all of the TAP is OK, the sampling clock position is selected by
182 * identifying the change point of data.
183 */
184 if (tap_cnt == tap_num * 2) {
185 match_cnt = 0;
186 ntap = 0;
187 tap_start = 0;
188 tap_end = 0;
189 for (i = 0; i < tap_num * 2; i++) {
190 if (smpcmp & BIT(i))
191 ntap++;
192 else {
193 if (ntap > match_cnt) {
194 tap_start = i - ntap;
195 tap_end = i - 1;
196 match_cnt = ntap;
197 }
198 ntap = 0;
199 }
200 }
201 if (ntap > match_cnt) {
202 tap_start = i - ntap;
203 tap_end = i - 1;
204 match_cnt = ntap;
205 }
206 if (match_cnt)
207 select = true;
208 } else if (tap_cnt >= RENESAS_SDHI_MAX_TAP)
209 select = true;
210
211 if (select)
212 tap_set = ((tap_start + tap_end) / 2) % tap_num;
213 else
214 return -EIO;
215
216 /* Set SCC */
Marek Vasutfd83e762018-04-13 23:51:33 +0200217 tmio_sd_writel(priv, tap_set, RENESAS_SDHI_SCC_TAPSET);
Marek Vasute0781e42018-04-08 19:09:17 +0200218
219 /* Enable auto re-tuning */
Marek Vasutfd83e762018-04-13 23:51:33 +0200220 reg = tmio_sd_readl(priv, RENESAS_SDHI_SCC_RVSCNTL);
Marek Vasute0781e42018-04-08 19:09:17 +0200221 reg |= RENESAS_SDHI_SCC_RVSCNTL_RVSEN;
Marek Vasutfd83e762018-04-13 23:51:33 +0200222 tmio_sd_writel(priv, reg, RENESAS_SDHI_SCC_RVSCNTL);
Marek Vasute0781e42018-04-08 19:09:17 +0200223
224 return 0;
225}
226
227int renesas_sdhi_execute_tuning(struct udevice *dev, uint opcode)
228{
Marek Vasutfd83e762018-04-13 23:51:33 +0200229 struct tmio_sd_priv *priv = dev_get_priv(dev);
Marek Vasute0781e42018-04-08 19:09:17 +0200230 struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev);
231 struct mmc *mmc = upriv->mmc;
232 unsigned int tap_num;
233 unsigned int taps = 0, smpcmp = 0;
234 int i, ret = 0;
235 u32 caps;
236
237 /* Only supported on Renesas RCar */
Marek Vasutfd83e762018-04-13 23:51:33 +0200238 if (!(priv->caps & TMIO_SD_CAP_RCAR_UHS))
Marek Vasute0781e42018-04-08 19:09:17 +0200239 return -EINVAL;
240
241 /* clock tuning is not needed for upto 52MHz */
242 if (!((mmc->selected_mode == MMC_HS_200) ||
243 (mmc->selected_mode == UHS_SDR104) ||
244 (mmc->selected_mode == UHS_SDR50)))
245 return 0;
246
247 tap_num = renesas_sdhi_init_tuning(priv);
248 if (!tap_num)
249 /* Tuning is not supported */
250 goto out;
251
252 if (tap_num * 2 >= sizeof(taps) * 8) {
253 dev_err(dev,
254 "Too many taps, skipping tuning. Please consider updating size of taps field of tmio_mmc_host\n");
255 goto out;
256 }
257
258 /* Issue CMD19 twice for each tap */
259 for (i = 0; i < 2 * tap_num; i++) {
260 renesas_sdhi_prepare_tuning(priv, i % tap_num);
261
262 /* Force PIO for the tuning */
263 caps = priv->caps;
Marek Vasutfd83e762018-04-13 23:51:33 +0200264 priv->caps &= ~TMIO_SD_CAP_DMA_INTERNAL;
Marek Vasute0781e42018-04-08 19:09:17 +0200265
266 ret = mmc_send_tuning(mmc, opcode, NULL);
267
268 priv->caps = caps;
269
270 if (ret == 0)
271 taps |= BIT(i);
272
273 ret = renesas_sdhi_compare_scc_data(priv);
274 if (ret == 0)
275 smpcmp |= BIT(i);
276
277 mdelay(1);
278 }
279
280 ret = renesas_sdhi_select_tuning(priv, tap_num, taps, smpcmp);
281
282out:
283 if (ret < 0) {
284 dev_warn(dev, "Tuning procedure failed\n");
285 renesas_sdhi_reset_tuning(priv);
286 }
287
288 return ret;
289}
290#endif
291
292static int renesas_sdhi_set_ios(struct udevice *dev)
293{
Marek Vasutfd83e762018-04-13 23:51:33 +0200294 int ret = tmio_sd_set_ios(dev);
Marek Vasut33d38182018-04-09 20:47:31 +0200295
296 mdelay(10);
297
Marek Vasute0781e42018-04-08 19:09:17 +0200298#if CONFIG_IS_ENABLED(MMC_HS200_SUPPORT)
Marek Vasutfd83e762018-04-13 23:51:33 +0200299 struct tmio_sd_priv *priv = dev_get_priv(dev);
Marek Vasute0781e42018-04-08 19:09:17 +0200300
Marek Vasut35773802018-10-28 15:30:06 +0100301 if (priv->caps & TMIO_SD_CAP_RCAR_UHS)
302 renesas_sdhi_reset_tuning(priv);
Marek Vasute0781e42018-04-08 19:09:17 +0200303#endif
304
305 return ret;
306}
307
Marek Vasut576a6d92018-10-28 19:28:56 +0100308#if CONFIG_IS_ENABLED(MMC_UHS_SUPPORT)
309static int renesas_sdhi_wait_dat0(struct udevice *dev, int state, int timeout)
310{
311 int ret = -ETIMEDOUT;
312 bool dat0_high;
313 bool target_dat0_high = !!state;
314 struct tmio_sd_priv *priv = dev_get_priv(dev);
315
316 timeout = DIV_ROUND_UP(timeout, 10); /* check every 10 us. */
317 while (timeout--) {
318 dat0_high = !!(tmio_sd_readl(priv, TMIO_SD_INFO2) & TMIO_SD_INFO2_DAT0);
319 if (dat0_high == target_dat0_high) {
320 ret = 0;
321 break;
322 }
323 udelay(10);
324 }
325
326 return ret;
327}
328#endif
329
Marek Vasut06485cf2018-04-08 15:22:58 +0200330static const struct dm_mmc_ops renesas_sdhi_ops = {
Marek Vasutfd83e762018-04-13 23:51:33 +0200331 .send_cmd = tmio_sd_send_cmd,
Marek Vasute0781e42018-04-08 19:09:17 +0200332 .set_ios = renesas_sdhi_set_ios,
Marek Vasutfd83e762018-04-13 23:51:33 +0200333 .get_cd = tmio_sd_get_cd,
Marek Vasut576a6d92018-10-28 19:28:56 +0100334#if CONFIG_IS_ENABLED(MMC_UHS_SUPPORT) || CONFIG_IS_ENABLED(MMC_HS200_SUPPORT)
Marek Vasute0781e42018-04-08 19:09:17 +0200335 .execute_tuning = renesas_sdhi_execute_tuning,
336#endif
Marek Vasut576a6d92018-10-28 19:28:56 +0100337#if CONFIG_IS_ENABLED(MMC_UHS_SUPPORT)
338 .wait_dat0 = renesas_sdhi_wait_dat0,
339#endif
Marek Vasut06485cf2018-04-08 15:22:58 +0200340};
341
Marek Vasutfd83e762018-04-13 23:51:33 +0200342#define RENESAS_GEN2_QUIRKS TMIO_SD_CAP_RCAR_GEN2
Marek Vasut9db9e6a2018-04-08 18:49:52 +0200343#define RENESAS_GEN3_QUIRKS \
Marek Vasutfd83e762018-04-13 23:51:33 +0200344 TMIO_SD_CAP_64BIT | TMIO_SD_CAP_RCAR_GEN3 | TMIO_SD_CAP_RCAR_UHS
Marek Vasut9db9e6a2018-04-08 18:49:52 +0200345
Marek Vasut06485cf2018-04-08 15:22:58 +0200346static const struct udevice_id renesas_sdhi_match[] = {
Marek Vasut9db9e6a2018-04-08 18:49:52 +0200347 { .compatible = "renesas,sdhi-r8a7790", .data = RENESAS_GEN2_QUIRKS },
348 { .compatible = "renesas,sdhi-r8a7791", .data = RENESAS_GEN2_QUIRKS },
349 { .compatible = "renesas,sdhi-r8a7792", .data = RENESAS_GEN2_QUIRKS },
350 { .compatible = "renesas,sdhi-r8a7793", .data = RENESAS_GEN2_QUIRKS },
351 { .compatible = "renesas,sdhi-r8a7794", .data = RENESAS_GEN2_QUIRKS },
352 { .compatible = "renesas,sdhi-r8a7795", .data = RENESAS_GEN3_QUIRKS },
353 { .compatible = "renesas,sdhi-r8a7796", .data = RENESAS_GEN3_QUIRKS },
354 { .compatible = "renesas,sdhi-r8a77965", .data = RENESAS_GEN3_QUIRKS },
355 { .compatible = "renesas,sdhi-r8a77970", .data = RENESAS_GEN3_QUIRKS },
Marek Vasut8b2ae7d2018-04-26 13:19:29 +0200356 { .compatible = "renesas,sdhi-r8a77990", .data = RENESAS_GEN3_QUIRKS },
Marek Vasut9db9e6a2018-04-08 18:49:52 +0200357 { .compatible = "renesas,sdhi-r8a77995", .data = RENESAS_GEN3_QUIRKS },
Marek Vasut06485cf2018-04-08 15:22:58 +0200358 { /* sentinel */ }
359};
360
Marek Vasutda90a1b2018-06-13 08:02:55 +0200361static ulong renesas_sdhi_clk_get_rate(struct tmio_sd_priv *priv)
362{
363 return clk_get_rate(&priv->clk);
364}
365
Marek Vasutabe3e952018-04-08 17:45:23 +0200366static int renesas_sdhi_probe(struct udevice *dev)
367{
Masahiro Yamada19989d832018-04-20 18:14:24 +0900368 struct tmio_sd_priv *priv = dev_get_priv(dev);
Marek Vasutabe3e952018-04-08 17:45:23 +0200369 u32 quirks = dev_get_driver_data(dev);
Marek Vasut1949d482018-04-08 18:14:22 +0200370 struct fdt_resource reg_res;
371 DECLARE_GLOBAL_DATA_PTR;
372 int ret;
373
Marek Vasutda90a1b2018-06-13 08:02:55 +0200374 priv->clk_get_rate = renesas_sdhi_clk_get_rate;
375
Marek Vasut9db9e6a2018-04-08 18:49:52 +0200376 if (quirks == RENESAS_GEN2_QUIRKS) {
377 ret = fdt_get_resource(gd->fdt_blob, dev_of_offset(dev),
378 "reg", 0, &reg_res);
379 if (ret < 0) {
380 dev_err(dev, "\"reg\" resource not found, ret=%i\n",
381 ret);
382 return ret;
383 }
Marek Vasut1949d482018-04-08 18:14:22 +0200384
Marek Vasut9db9e6a2018-04-08 18:49:52 +0200385 if (fdt_resource_size(&reg_res) == 0x100)
Marek Vasutfd83e762018-04-13 23:51:33 +0200386 quirks |= TMIO_SD_CAP_16BIT;
Marek Vasut9db9e6a2018-04-08 18:49:52 +0200387 }
Marek Vasutabe3e952018-04-08 17:45:23 +0200388
Marek Vasutda90a1b2018-06-13 08:02:55 +0200389 ret = clk_get_by_index(dev, 0, &priv->clk);
Masahiro Yamada19989d832018-04-20 18:14:24 +0900390 if (ret < 0) {
391 dev_err(dev, "failed to get host clock\n");
392 return ret;
393 }
394
395 /* set to max rate */
Marek Vasutda90a1b2018-06-13 08:02:55 +0200396 ret = clk_set_rate(&priv->clk, 200000000);
397 if (ret < 0) {
Masahiro Yamada19989d832018-04-20 18:14:24 +0900398 dev_err(dev, "failed to set rate for host clock\n");
Marek Vasutda90a1b2018-06-13 08:02:55 +0200399 clk_free(&priv->clk);
400 return ret;
Masahiro Yamada19989d832018-04-20 18:14:24 +0900401 }
402
Marek Vasutda90a1b2018-06-13 08:02:55 +0200403 ret = clk_enable(&priv->clk);
Masahiro Yamada19989d832018-04-20 18:14:24 +0900404 if (ret) {
405 dev_err(dev, "failed to enable host clock\n");
406 return ret;
407 }
408
Marek Vasutfd83e762018-04-13 23:51:33 +0200409 ret = tmio_sd_probe(dev, quirks);
Marek Vasute0781e42018-04-08 19:09:17 +0200410#if CONFIG_IS_ENABLED(MMC_HS200_SUPPORT)
Marek Vasut35773802018-10-28 15:30:06 +0100411 if (!ret && (priv->caps & TMIO_SD_CAP_RCAR_UHS))
Marek Vasutda70ebb2018-08-30 15:27:26 +0200412 renesas_sdhi_reset_tuning(priv);
Marek Vasute0781e42018-04-08 19:09:17 +0200413#endif
414 return ret;
Marek Vasutabe3e952018-04-08 17:45:23 +0200415}
416
Marek Vasut06485cf2018-04-08 15:22:58 +0200417U_BOOT_DRIVER(renesas_sdhi) = {
418 .name = "renesas-sdhi",
419 .id = UCLASS_MMC,
420 .of_match = renesas_sdhi_match,
Marek Vasutfd83e762018-04-13 23:51:33 +0200421 .bind = tmio_sd_bind,
Marek Vasutabe3e952018-04-08 17:45:23 +0200422 .probe = renesas_sdhi_probe,
Marek Vasutfd83e762018-04-13 23:51:33 +0200423 .priv_auto_alloc_size = sizeof(struct tmio_sd_priv),
424 .platdata_auto_alloc_size = sizeof(struct tmio_sd_plat),
Marek Vasut06485cf2018-04-08 15:22:58 +0200425 .ops = &renesas_sdhi_ops,
426};