blob: 1e06541838116d48546394a3de33ca6cbd969206 [file] [log] [blame]
Lokesh Vutlabc9979f2018-08-27 15:57:54 +05301// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com/
4 *
5 * Texas Instruments' K3 SD Host Controller Interface
6 */
7
8#include <clk.h>
9#include <common.h>
10#include <dm.h>
11#include <malloc.h>
12#include <power-domain.h>
Faiz Abbase9aed582019-06-11 00:43:38 +053013#include <regmap.h>
Lokesh Vutlabc9979f2018-08-27 15:57:54 +053014#include <sdhci.h>
Simon Glass9bc15642020-02-03 07:36:16 -070015#include <dm/device_compat.h>
Simon Glass4dcacfc2020-05-10 11:40:13 -060016#include <linux/bitops.h>
Simon Glassd66c5f72020-02-03 07:36:15 -070017#include <linux/err.h>
Lokesh Vutlabc9979f2018-08-27 15:57:54 +053018
Faiz Abbase9aed582019-06-11 00:43:38 +053019/* CTL_CFG Registers */
20#define CTL_CFG_2 0x14
21
22#define SLOTTYPE_MASK GENMASK(31, 30)
23#define SLOTTYPE_EMBEDDED BIT(30)
24
25/* PHY Registers */
26#define PHY_CTRL1 0x100
27#define PHY_CTRL2 0x104
28#define PHY_CTRL3 0x108
29#define PHY_CTRL4 0x10C
30#define PHY_CTRL5 0x110
31#define PHY_CTRL6 0x114
32#define PHY_STAT1 0x130
33#define PHY_STAT2 0x134
34
35#define IOMUX_ENABLE_SHIFT 31
36#define IOMUX_ENABLE_MASK BIT(IOMUX_ENABLE_SHIFT)
37#define OTAPDLYENA_SHIFT 20
38#define OTAPDLYENA_MASK BIT(OTAPDLYENA_SHIFT)
39#define OTAPDLYSEL_SHIFT 12
40#define OTAPDLYSEL_MASK GENMASK(15, 12)
41#define STRBSEL_SHIFT 24
Faiz Abbas8cc051e2020-01-16 19:42:19 +053042#define STRBSEL_4BIT_MASK GENMASK(27, 24)
43#define STRBSEL_8BIT_MASK GENMASK(31, 24)
Faiz Abbase9aed582019-06-11 00:43:38 +053044#define SEL50_SHIFT 8
45#define SEL50_MASK BIT(SEL50_SHIFT)
46#define SEL100_SHIFT 9
47#define SEL100_MASK BIT(SEL100_SHIFT)
Faiz Abbas8cc051e2020-01-16 19:42:19 +053048#define FREQSEL_SHIFT 8
49#define FREQSEL_MASK GENMASK(10, 8)
Faiz Abbase9aed582019-06-11 00:43:38 +053050#define DLL_TRIM_ICP_SHIFT 4
51#define DLL_TRIM_ICP_MASK GENMASK(7, 4)
52#define DR_TY_SHIFT 20
53#define DR_TY_MASK GENMASK(22, 20)
54#define ENDLL_SHIFT 1
55#define ENDLL_MASK BIT(ENDLL_SHIFT)
56#define DLLRDY_SHIFT 0
57#define DLLRDY_MASK BIT(DLLRDY_SHIFT)
58#define PDB_SHIFT 0
59#define PDB_MASK BIT(PDB_SHIFT)
60#define CALDONE_SHIFT 1
61#define CALDONE_MASK BIT(CALDONE_SHIFT)
62#define RETRIM_SHIFT 17
63#define RETRIM_MASK BIT(RETRIM_SHIFT)
64
65#define DRIVER_STRENGTH_50_OHM 0x0
66#define DRIVER_STRENGTH_33_OHM 0x1
67#define DRIVER_STRENGTH_66_OHM 0x2
68#define DRIVER_STRENGTH_100_OHM 0x3
69#define DRIVER_STRENGTH_40_OHM 0x4
70
Faiz Abbasd8fb3092019-06-11 00:43:31 +053071#define AM654_SDHCI_MIN_FREQ 400000
Lokesh Vutlabc9979f2018-08-27 15:57:54 +053072
Faiz Abbasd8fb3092019-06-11 00:43:31 +053073struct am654_sdhci_plat {
Lokesh Vutlabc9979f2018-08-27 15:57:54 +053074 struct mmc_config cfg;
75 struct mmc mmc;
Faiz Abbase9aed582019-06-11 00:43:38 +053076 struct regmap *base;
77 bool non_removable;
Faiz Abbas7101e122020-07-29 07:03:41 +053078 u32 otap_del_sel[MMC_MODES_END];
Faiz Abbase9aed582019-06-11 00:43:38 +053079 u32 trm_icp;
80 u32 drv_strength;
Faiz Abbas8cc051e2020-01-16 19:42:19 +053081 u32 strb_sel;
Faiz Abbasfd8be702019-06-13 10:29:51 +053082 u32 flags;
Faiz Abbasb7f57bb2021-02-04 15:10:48 +053083#define DLL_PRESENT BIT(0)
84#define IOMUX_PRESENT BIT(1)
85#define FREQSEL_2_BIT BIT(2)
86#define STRBSEL_4_BIT BIT(3)
Faiz Abbas947e8f32021-02-04 15:10:49 +053087#define DLL_CALIB BIT(4)
Lokesh Vutlabc9979f2018-08-27 15:57:54 +053088};
89
Faiz Abbasc6eb9e72020-02-26 13:44:33 +053090struct timing_data {
91 const char *binding;
92 u32 capability;
93};
94
95static const struct timing_data td[] = {
96 [MMC_LEGACY] = {"ti,otap-del-sel-legacy", 0},
97 [MMC_HS] = {"ti,otap-del-sel-mmc-hs", MMC_CAP(MMC_HS)},
98 [SD_HS] = {"ti,otap-del-sel-sd-hs", MMC_CAP(SD_HS)},
99 [UHS_SDR12] = {"ti,otap-del-sel-sdr12", MMC_CAP(UHS_SDR12)},
100 [UHS_SDR25] = {"ti,otap-del-sel-sdr25", MMC_CAP(UHS_SDR25)},
101 [UHS_SDR50] = {"ti,otap-del-sel-sdr50", MMC_CAP(UHS_SDR50)},
102 [UHS_SDR104] = {"ti,otap-del-sel-sdr104", MMC_CAP(UHS_SDR104)},
103 [UHS_DDR50] = {"ti,otap-del-sel-ddr50", MMC_CAP(UHS_DDR50)},
104 [MMC_DDR_52] = {"ti,otap-del-sel-ddr52", MMC_CAP(MMC_DDR_52)},
105 [MMC_HS_200] = {"ti,otap-del-sel-hs200", MMC_CAP(MMC_HS_200)},
106 [MMC_HS_400] = {"ti,otap-del-sel-hs400", MMC_CAP(MMC_HS_400)},
107};
108
Faiz Abbas8cc051e2020-01-16 19:42:19 +0530109struct am654_driver_data {
110 const struct sdhci_ops *ops;
111 u32 flags;
112};
113
Faiz Abbas7eecee62019-06-11 00:43:41 +0530114static void am654_sdhci_set_control_reg(struct sdhci_host *host)
115{
116 struct mmc *mmc = (struct mmc *)host->mmc;
117 u32 reg;
118
119 if (IS_SD(host->mmc) &&
120 mmc->signal_voltage == MMC_SIGNAL_VOLTAGE_180) {
121 reg = sdhci_readw(host, SDHCI_HOST_CONTROL2);
122 reg |= SDHCI_CTRL_VDD_180;
123 sdhci_writew(host, reg, SDHCI_HOST_CONTROL2);
124 }
125
126 sdhci_set_uhs_timing(host);
127}
128
Faiz Abbase9aed582019-06-11 00:43:38 +0530129static int am654_sdhci_set_ios_post(struct sdhci_host *host)
130{
131 struct udevice *dev = host->mmc->dev;
Simon Glassfa20e932020-12-03 16:55:20 -0700132 struct am654_sdhci_plat *plat = dev_get_plat(dev);
Faiz Abbase9aed582019-06-11 00:43:38 +0530133 unsigned int speed = host->mmc->clock;
Faiz Abbas8cc051e2020-01-16 19:42:19 +0530134 int sel50, sel100, freqsel;
Faiz Abbasc6eb9e72020-02-26 13:44:33 +0530135 u32 otap_del_sel;
Faiz Abbase9aed582019-06-11 00:43:38 +0530136 u32 mask, val;
137 int ret;
138
139 /* Reset SD Clock Enable */
140 val = sdhci_readw(host, SDHCI_CLOCK_CONTROL);
141 val &= ~SDHCI_CLOCK_CARD_EN;
142 sdhci_writew(host, val, SDHCI_CLOCK_CONTROL);
143
Faiz Abbas2c45a2c2021-02-04 15:10:47 +0530144 regmap_update_bits(plat->base, PHY_CTRL1, ENDLL_MASK, 0);
Faiz Abbase9aed582019-06-11 00:43:38 +0530145
146 /* restart clock */
147 sdhci_set_clock(host->mmc, speed);
148
149 /* switch phy back on */
150 if (speed > AM654_SDHCI_MIN_FREQ) {
Faiz Abbasc6eb9e72020-02-26 13:44:33 +0530151 otap_del_sel = plat->otap_del_sel[host->mmc->selected_mode];
Faiz Abbase9aed582019-06-11 00:43:38 +0530152 mask = OTAPDLYENA_MASK | OTAPDLYSEL_MASK;
153 val = (1 << OTAPDLYENA_SHIFT) |
Faiz Abbasc6eb9e72020-02-26 13:44:33 +0530154 (otap_del_sel << OTAPDLYSEL_SHIFT);
Faiz Abbas8cc051e2020-01-16 19:42:19 +0530155
156 /* Write to STRBSEL for HS400 speed mode */
157 if (host->mmc->selected_mode == MMC_HS_400) {
158 if (plat->flags & STRBSEL_4_BIT)
159 mask |= STRBSEL_4BIT_MASK;
160 else
161 mask |= STRBSEL_8BIT_MASK;
162
163 val |= plat->strb_sel << STRBSEL_SHIFT;
Faiz Abbase9aed582019-06-11 00:43:38 +0530164 }
165
Faiz Abbas8cc051e2020-01-16 19:42:19 +0530166 regmap_update_bits(plat->base, PHY_CTRL4, mask, val);
167
168 if (plat->flags & FREQSEL_2_BIT) {
169 switch (speed) {
170 case 200000000:
171 sel50 = 0;
172 sel100 = 0;
173 break;
174 case 100000000:
175 sel50 = 0;
176 sel100 = 1;
177 break;
178 default:
179 sel50 = 1;
180 sel100 = 0;
181 }
182
183 /* Configure PHY DLL frequency */
184 mask = SEL50_MASK | SEL100_MASK;
185 val = (sel50 << SEL50_SHIFT) | (sel100 << SEL100_SHIFT);
186 regmap_update_bits(plat->base, PHY_CTRL5, mask, val);
187 } else {
188 switch (speed) {
189 case 200000000:
190 freqsel = 0x0;
191 break;
192 default:
193 freqsel = 0x4;
194 }
195 regmap_update_bits(plat->base, PHY_CTRL5, FREQSEL_MASK,
196 freqsel << FREQSEL_SHIFT);
197 }
Faiz Abbase9aed582019-06-11 00:43:38 +0530198
Faiz Abbas947e8f32021-02-04 15:10:49 +0530199 /* Configure DLL TRIM */
200 mask = DLL_TRIM_ICP_MASK;
201 val = plat->trm_icp << DLL_TRIM_ICP_SHIFT;
202
203 /* Configure DLL driver strength */
204 mask |= DR_TY_MASK;
205 val |= plat->drv_strength << DR_TY_SHIFT;
206 regmap_update_bits(plat->base, PHY_CTRL1, mask, val);
207
Faiz Abbase9aed582019-06-11 00:43:38 +0530208 /* Enable DLL */
209 regmap_update_bits(plat->base, PHY_CTRL1, ENDLL_MASK,
210 0x1 << ENDLL_SHIFT);
211 /*
212 * Poll for DLL ready. Use a one second timeout.
213 * Works in all experiments done so far
214 */
215 ret = regmap_read_poll_timeout(plat->base, PHY_STAT1, val,
216 val & DLLRDY_MASK, 1000, 1000000);
217 if (ret)
218 return ret;
Faiz Abbase9aed582019-06-11 00:43:38 +0530219 }
220
221 return 0;
222}
223
Faiz Abbase9aed582019-06-11 00:43:38 +0530224int am654_sdhci_init(struct am654_sdhci_plat *plat)
225{
226 u32 ctl_cfg_2 = 0;
227 u32 mask, val;
228 int ret;
229
230 /* Reset OTAP to default value */
231 mask = OTAPDLYENA_MASK | OTAPDLYSEL_MASK;
232 regmap_update_bits(plat->base, PHY_CTRL4, mask, 0x0);
233
Faiz Abbas947e8f32021-02-04 15:10:49 +0530234 if (plat->flags & DLL_CALIB) {
Faiz Abbasfd8be702019-06-13 10:29:51 +0530235 regmap_read(plat->base, PHY_STAT1, &val);
236 if (~val & CALDONE_MASK) {
237 /* Calibrate IO lines */
238 regmap_update_bits(plat->base, PHY_CTRL1, PDB_MASK,
239 PDB_MASK);
240 ret = regmap_read_poll_timeout(plat->base, PHY_STAT1,
241 val, val & CALDONE_MASK,
242 1, 20);
243 if (ret)
244 return ret;
245 }
Faiz Abbasfd8be702019-06-13 10:29:51 +0530246 }
Faiz Abbase9aed582019-06-11 00:43:38 +0530247
248 /* Enable pins by setting IO mux to 0 */
Faiz Abbas8cc051e2020-01-16 19:42:19 +0530249 if (plat->flags & IOMUX_PRESENT)
250 regmap_update_bits(plat->base, PHY_CTRL1, IOMUX_ENABLE_MASK, 0);
Faiz Abbase9aed582019-06-11 00:43:38 +0530251
252 /* Set slot type based on SD or eMMC */
253 if (plat->non_removable)
254 ctl_cfg_2 = SLOTTYPE_EMBEDDED;
255
256 regmap_update_bits(plat->base, CTL_CFG_2, SLOTTYPE_MASK, ctl_cfg_2);
257
258 return 0;
259}
260
Faiz Abbase4425cb2020-02-26 13:44:34 +0530261#define MAX_SDCD_DEBOUNCE_TIME 2000
262static int am654_sdhci_deferred_probe(struct sdhci_host *host)
263{
264 struct udevice *dev = host->mmc->dev;
Simon Glassfa20e932020-12-03 16:55:20 -0700265 struct am654_sdhci_plat *plat = dev_get_plat(dev);
Faiz Abbase4425cb2020-02-26 13:44:34 +0530266 unsigned long start;
267 int val;
268
269 /*
270 * The controller takes about 1 second to debounce the card detect line
271 * and doesn't let us power on until that time is up. Instead of waiting
272 * for 1 second at every stage, poll on the CARD_PRESENT bit upto a
273 * maximum of 2 seconds to be safe..
274 */
275 start = get_timer(0);
276 do {
277 if (get_timer(start) > MAX_SDCD_DEBOUNCE_TIME)
278 return -ENOMEDIUM;
279
280 val = mmc_getcd(host->mmc);
281 } while (!val);
282
283 am654_sdhci_init(plat);
284
285 return sdhci_probe(dev);
286}
287
288const struct sdhci_ops am654_sdhci_ops = {
289 .deferred_probe = am654_sdhci_deferred_probe,
290 .set_ios_post = &am654_sdhci_set_ios_post,
291 .set_control_reg = &am654_sdhci_set_control_reg,
292};
293
294const struct am654_driver_data am654_drv_data = {
295 .ops = &am654_sdhci_ops,
Faiz Abbas947e8f32021-02-04 15:10:49 +0530296 .flags = IOMUX_PRESENT | FREQSEL_2_BIT | DLL_PRESENT | DLL_CALIB |
297 STRBSEL_4_BIT,
Faiz Abbase4425cb2020-02-26 13:44:34 +0530298};
299
300const struct am654_driver_data j721e_8bit_drv_data = {
301 .ops = &am654_sdhci_ops,
Faiz Abbas947e8f32021-02-04 15:10:49 +0530302 .flags = DLL_PRESENT | DLL_CALIB,
Faiz Abbase4425cb2020-02-26 13:44:34 +0530303};
304
305static int j721e_4bit_sdhci_set_ios_post(struct sdhci_host *host)
306{
307 struct udevice *dev = host->mmc->dev;
Simon Glassfa20e932020-12-03 16:55:20 -0700308 struct am654_sdhci_plat *plat = dev_get_plat(dev);
Faiz Abbase4425cb2020-02-26 13:44:34 +0530309 u32 otap_del_sel, mask, val;
310
311 otap_del_sel = plat->otap_del_sel[host->mmc->selected_mode];
312 mask = OTAPDLYENA_MASK | OTAPDLYSEL_MASK;
313 val = (1 << OTAPDLYENA_SHIFT) | (otap_del_sel << OTAPDLYSEL_SHIFT);
314 regmap_update_bits(plat->base, PHY_CTRL4, mask, val);
315
316 return 0;
317}
318
319const struct sdhci_ops j721e_4bit_sdhci_ops = {
320 .deferred_probe = am654_sdhci_deferred_probe,
321 .set_ios_post = &j721e_4bit_sdhci_set_ios_post,
322};
323
324const struct am654_driver_data j721e_4bit_drv_data = {
325 .ops = &j721e_4bit_sdhci_ops,
326 .flags = IOMUX_PRESENT,
327};
328
Faiz Abbasc6eb9e72020-02-26 13:44:33 +0530329static int sdhci_am654_get_otap_delay(struct udevice *dev,
330 struct mmc_config *cfg)
331{
Simon Glassfa20e932020-12-03 16:55:20 -0700332 struct am654_sdhci_plat *plat = dev_get_plat(dev);
Faiz Abbasc6eb9e72020-02-26 13:44:33 +0530333 int ret;
334 int i;
335
336 /* ti,otap-del-sel-legacy is mandatory */
337 ret = dev_read_u32(dev, "ti,otap-del-sel-legacy",
338 &plat->otap_del_sel[0]);
339 if (ret)
340 return ret;
341 /*
342 * Remove the corresponding capability if an otap-del-sel
343 * value is not found
344 */
345 for (i = MMC_HS; i <= MMC_HS_400; i++) {
346 ret = dev_read_u32(dev, td[i].binding, &plat->otap_del_sel[i]);
347 if (ret) {
348 dev_dbg(dev, "Couldn't find %s\n", td[i].binding);
349 /*
350 * Remove the corresponding capability
351 * if an otap-del-sel value is not found
352 */
353 cfg->host_caps &= ~td[i].capability;
354 }
355 }
356
357 return 0;
358}
359
Faiz Abbasd8fb3092019-06-11 00:43:31 +0530360static int am654_sdhci_probe(struct udevice *dev)
Lokesh Vutlabc9979f2018-08-27 15:57:54 +0530361{
Faiz Abbas8cc051e2020-01-16 19:42:19 +0530362 struct am654_driver_data *drv_data =
363 (struct am654_driver_data *)dev_get_driver_data(dev);
Simon Glassfa20e932020-12-03 16:55:20 -0700364 struct am654_sdhci_plat *plat = dev_get_plat(dev);
Lokesh Vutlabc9979f2018-08-27 15:57:54 +0530365 struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev);
366 struct sdhci_host *host = dev_get_priv(dev);
Faiz Abbase9aed582019-06-11 00:43:38 +0530367 struct mmc_config *cfg = &plat->cfg;
Lokesh Vutlabc9979f2018-08-27 15:57:54 +0530368 struct clk clk;
369 unsigned long clock;
370 int ret;
371
Faiz Abbasdc2bcc22020-01-16 19:42:18 +0530372 ret = clk_get_by_name(dev, "clk_xin", &clk);
Lokesh Vutlabc9979f2018-08-27 15:57:54 +0530373 if (ret) {
374 dev_err(dev, "failed to get clock\n");
375 return ret;
376 }
377
378 clock = clk_get_rate(&clk);
379 if (IS_ERR_VALUE(clock)) {
380 dev_err(dev, "failed to get rate\n");
381 return clock;
382 }
383
Lokesh Vutlabc9979f2018-08-27 15:57:54 +0530384 host->max_clk = clock;
Lokesh Vutlabc9979f2018-08-27 15:57:54 +0530385 host->mmc = &plat->mmc;
Faiz Abbase9aed582019-06-11 00:43:38 +0530386 host->mmc->dev = dev;
387 ret = sdhci_setup_cfg(cfg, host, cfg->f_max,
388 AM654_SDHCI_MIN_FREQ);
Lokesh Vutlabc9979f2018-08-27 15:57:54 +0530389 if (ret)
390 return ret;
Faiz Abbas8cc051e2020-01-16 19:42:19 +0530391
Faiz Abbasc6eb9e72020-02-26 13:44:33 +0530392 ret = sdhci_am654_get_otap_delay(dev, cfg);
393 if (ret)
394 return ret;
395
Faiz Abbas8cc051e2020-01-16 19:42:19 +0530396 host->ops = drv_data->ops;
Lokesh Vutlabc9979f2018-08-27 15:57:54 +0530397 host->mmc->priv = host;
Lokesh Vutlabc9979f2018-08-27 15:57:54 +0530398 upriv->mmc = host->mmc;
399
Faiz Abbase9aed582019-06-11 00:43:38 +0530400 regmap_init_mem_index(dev_ofnode(dev), &plat->base, 1);
401
Faiz Abbase4425cb2020-02-26 13:44:34 +0530402 return 0;
Lokesh Vutlabc9979f2018-08-27 15:57:54 +0530403}
404
Simon Glassaad29ae2020-12-03 16:55:21 -0700405static int am654_sdhci_of_to_plat(struct udevice *dev)
Lokesh Vutlabc9979f2018-08-27 15:57:54 +0530406{
Simon Glassfa20e932020-12-03 16:55:20 -0700407 struct am654_sdhci_plat *plat = dev_get_plat(dev);
Lokesh Vutlabc9979f2018-08-27 15:57:54 +0530408 struct sdhci_host *host = dev_get_priv(dev);
Faiz Abbase9aed582019-06-11 00:43:38 +0530409 struct mmc_config *cfg = &plat->cfg;
410 u32 drv_strength;
411 int ret;
Lokesh Vutlabc9979f2018-08-27 15:57:54 +0530412
413 host->name = dev->name;
414 host->ioaddr = (void *)dev_read_addr(dev);
Faiz Abbase9aed582019-06-11 00:43:38 +0530415 plat->non_removable = dev_read_bool(dev, "non-removable");
416
Faiz Abbasfd8be702019-06-13 10:29:51 +0530417 if (plat->flags & DLL_PRESENT) {
418 ret = dev_read_u32(dev, "ti,trm-icp", &plat->trm_icp);
419 if (ret)
420 return ret;
421
422 ret = dev_read_u32(dev, "ti,driver-strength-ohm",
423 &drv_strength);
424 if (ret)
425 return ret;
Faiz Abbase9aed582019-06-11 00:43:38 +0530426
Faiz Abbasfd8be702019-06-13 10:29:51 +0530427 switch (drv_strength) {
428 case 50:
429 plat->drv_strength = DRIVER_STRENGTH_50_OHM;
430 break;
431 case 33:
432 plat->drv_strength = DRIVER_STRENGTH_33_OHM;
433 break;
434 case 66:
435 plat->drv_strength = DRIVER_STRENGTH_66_OHM;
436 break;
437 case 100:
438 plat->drv_strength = DRIVER_STRENGTH_100_OHM;
439 break;
440 case 40:
441 plat->drv_strength = DRIVER_STRENGTH_40_OHM;
442 break;
443 default:
444 dev_err(dev, "Invalid driver strength\n");
445 return -EINVAL;
446 }
Faiz Abbase9aed582019-06-11 00:43:38 +0530447 }
448
449 ret = mmc_of_parse(dev, cfg);
450 if (ret)
451 return ret;
Lokesh Vutlabc9979f2018-08-27 15:57:54 +0530452
453 return 0;
454}
455
Faiz Abbasd8fb3092019-06-11 00:43:31 +0530456static int am654_sdhci_bind(struct udevice *dev)
Lokesh Vutlabc9979f2018-08-27 15:57:54 +0530457{
Faiz Abbas8cc051e2020-01-16 19:42:19 +0530458 struct am654_driver_data *drv_data =
459 (struct am654_driver_data *)dev_get_driver_data(dev);
Simon Glassfa20e932020-12-03 16:55:20 -0700460 struct am654_sdhci_plat *plat = dev_get_plat(dev);
Lokesh Vutlabc9979f2018-08-27 15:57:54 +0530461
Faiz Abbas8cc051e2020-01-16 19:42:19 +0530462 plat->flags = drv_data->flags;
463
Lokesh Vutlabc9979f2018-08-27 15:57:54 +0530464 return sdhci_bind(dev, &plat->mmc, &plat->cfg);
465}
466
Faiz Abbasd8fb3092019-06-11 00:43:31 +0530467static const struct udevice_id am654_sdhci_ids[] = {
Faiz Abbasfd8be702019-06-13 10:29:51 +0530468 {
469 .compatible = "ti,am654-sdhci-5.1",
Faiz Abbas8cc051e2020-01-16 19:42:19 +0530470 .data = (ulong)&am654_drv_data,
Faiz Abbasfd8be702019-06-13 10:29:51 +0530471 },
472 {
473 .compatible = "ti,j721e-sdhci-8bit",
Faiz Abbas8cc051e2020-01-16 19:42:19 +0530474 .data = (ulong)&j721e_8bit_drv_data,
Faiz Abbasfd8be702019-06-13 10:29:51 +0530475 },
476 {
477 .compatible = "ti,j721e-sdhci-4bit",
Faiz Abbas8cc051e2020-01-16 19:42:19 +0530478 .data = (ulong)&j721e_4bit_drv_data,
Faiz Abbasfd8be702019-06-13 10:29:51 +0530479 },
Lokesh Vutlabc9979f2018-08-27 15:57:54 +0530480 { }
481};
482
Faiz Abbasd8fb3092019-06-11 00:43:31 +0530483U_BOOT_DRIVER(am654_sdhci_drv) = {
484 .name = "am654_sdhci",
Lokesh Vutlabc9979f2018-08-27 15:57:54 +0530485 .id = UCLASS_MMC,
Faiz Abbasd8fb3092019-06-11 00:43:31 +0530486 .of_match = am654_sdhci_ids,
Simon Glassaad29ae2020-12-03 16:55:21 -0700487 .of_to_plat = am654_sdhci_of_to_plat,
Lokesh Vutlabc9979f2018-08-27 15:57:54 +0530488 .ops = &sdhci_ops,
Faiz Abbasd8fb3092019-06-11 00:43:31 +0530489 .bind = am654_sdhci_bind,
490 .probe = am654_sdhci_probe,
Simon Glass8a2b47f2020-12-03 16:55:17 -0700491 .priv_auto = sizeof(struct sdhci_host),
Simon Glass71fa5b42020-12-03 16:55:18 -0700492 .plat_auto = sizeof(struct am654_sdhci_plat),
Lokesh Vutlabc9979f2018-08-27 15:57:54 +0530493};