blob: 33f658fba7197280c7951e56a986e487dd09c828 [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;
83#define DLL_PRESENT (1 << 0)
Faiz Abbas8cc051e2020-01-16 19:42:19 +053084#define IOMUX_PRESENT (1 << 1)
85#define FREQSEL_2_BIT (1 << 2)
86#define STRBSEL_4_BIT (1 << 3)
Lokesh Vutlabc9979f2018-08-27 15:57:54 +053087};
88
Faiz Abbasc6eb9e72020-02-26 13:44:33 +053089struct timing_data {
90 const char *binding;
91 u32 capability;
92};
93
94static const struct timing_data td[] = {
95 [MMC_LEGACY] = {"ti,otap-del-sel-legacy", 0},
96 [MMC_HS] = {"ti,otap-del-sel-mmc-hs", MMC_CAP(MMC_HS)},
97 [SD_HS] = {"ti,otap-del-sel-sd-hs", MMC_CAP(SD_HS)},
98 [UHS_SDR12] = {"ti,otap-del-sel-sdr12", MMC_CAP(UHS_SDR12)},
99 [UHS_SDR25] = {"ti,otap-del-sel-sdr25", MMC_CAP(UHS_SDR25)},
100 [UHS_SDR50] = {"ti,otap-del-sel-sdr50", MMC_CAP(UHS_SDR50)},
101 [UHS_SDR104] = {"ti,otap-del-sel-sdr104", MMC_CAP(UHS_SDR104)},
102 [UHS_DDR50] = {"ti,otap-del-sel-ddr50", MMC_CAP(UHS_DDR50)},
103 [MMC_DDR_52] = {"ti,otap-del-sel-ddr52", MMC_CAP(MMC_DDR_52)},
104 [MMC_HS_200] = {"ti,otap-del-sel-hs200", MMC_CAP(MMC_HS_200)},
105 [MMC_HS_400] = {"ti,otap-del-sel-hs400", MMC_CAP(MMC_HS_400)},
106};
107
Faiz Abbas8cc051e2020-01-16 19:42:19 +0530108struct am654_driver_data {
109 const struct sdhci_ops *ops;
110 u32 flags;
111};
112
Faiz Abbas7eecee62019-06-11 00:43:41 +0530113static void am654_sdhci_set_control_reg(struct sdhci_host *host)
114{
115 struct mmc *mmc = (struct mmc *)host->mmc;
116 u32 reg;
117
118 if (IS_SD(host->mmc) &&
119 mmc->signal_voltage == MMC_SIGNAL_VOLTAGE_180) {
120 reg = sdhci_readw(host, SDHCI_HOST_CONTROL2);
121 reg |= SDHCI_CTRL_VDD_180;
122 sdhci_writew(host, reg, SDHCI_HOST_CONTROL2);
123 }
124
125 sdhci_set_uhs_timing(host);
126}
127
Faiz Abbase9aed582019-06-11 00:43:38 +0530128static int am654_sdhci_set_ios_post(struct sdhci_host *host)
129{
130 struct udevice *dev = host->mmc->dev;
Simon Glassfa20e932020-12-03 16:55:20 -0700131 struct am654_sdhci_plat *plat = dev_get_plat(dev);
Faiz Abbase9aed582019-06-11 00:43:38 +0530132 unsigned int speed = host->mmc->clock;
Faiz Abbas8cc051e2020-01-16 19:42:19 +0530133 int sel50, sel100, freqsel;
Faiz Abbasc6eb9e72020-02-26 13:44:33 +0530134 u32 otap_del_sel;
Faiz Abbase9aed582019-06-11 00:43:38 +0530135 u32 mask, val;
136 int ret;
137
138 /* Reset SD Clock Enable */
139 val = sdhci_readw(host, SDHCI_CLOCK_CONTROL);
140 val &= ~SDHCI_CLOCK_CARD_EN;
141 sdhci_writew(host, val, SDHCI_CLOCK_CONTROL);
142
Faiz Abbas2c45a2c2021-02-04 15:10:47 +0530143 regmap_update_bits(plat->base, PHY_CTRL1, ENDLL_MASK, 0);
Faiz Abbase9aed582019-06-11 00:43:38 +0530144
145 /* restart clock */
146 sdhci_set_clock(host->mmc, speed);
147
148 /* switch phy back on */
149 if (speed > AM654_SDHCI_MIN_FREQ) {
Faiz Abbasc6eb9e72020-02-26 13:44:33 +0530150 otap_del_sel = plat->otap_del_sel[host->mmc->selected_mode];
Faiz Abbase9aed582019-06-11 00:43:38 +0530151 mask = OTAPDLYENA_MASK | OTAPDLYSEL_MASK;
152 val = (1 << OTAPDLYENA_SHIFT) |
Faiz Abbasc6eb9e72020-02-26 13:44:33 +0530153 (otap_del_sel << OTAPDLYSEL_SHIFT);
Faiz Abbas8cc051e2020-01-16 19:42:19 +0530154
155 /* Write to STRBSEL for HS400 speed mode */
156 if (host->mmc->selected_mode == MMC_HS_400) {
157 if (plat->flags & STRBSEL_4_BIT)
158 mask |= STRBSEL_4BIT_MASK;
159 else
160 mask |= STRBSEL_8BIT_MASK;
161
162 val |= plat->strb_sel << STRBSEL_SHIFT;
Faiz Abbase9aed582019-06-11 00:43:38 +0530163 }
164
Faiz Abbas8cc051e2020-01-16 19:42:19 +0530165 regmap_update_bits(plat->base, PHY_CTRL4, mask, val);
166
167 if (plat->flags & FREQSEL_2_BIT) {
168 switch (speed) {
169 case 200000000:
170 sel50 = 0;
171 sel100 = 0;
172 break;
173 case 100000000:
174 sel50 = 0;
175 sel100 = 1;
176 break;
177 default:
178 sel50 = 1;
179 sel100 = 0;
180 }
181
182 /* Configure PHY DLL frequency */
183 mask = SEL50_MASK | SEL100_MASK;
184 val = (sel50 << SEL50_SHIFT) | (sel100 << SEL100_SHIFT);
185 regmap_update_bits(plat->base, PHY_CTRL5, mask, val);
186 } else {
187 switch (speed) {
188 case 200000000:
189 freqsel = 0x0;
190 break;
191 default:
192 freqsel = 0x4;
193 }
194 regmap_update_bits(plat->base, PHY_CTRL5, FREQSEL_MASK,
195 freqsel << FREQSEL_SHIFT);
196 }
Faiz Abbase9aed582019-06-11 00:43:38 +0530197
198 /* Enable DLL */
199 regmap_update_bits(plat->base, PHY_CTRL1, ENDLL_MASK,
200 0x1 << ENDLL_SHIFT);
201 /*
202 * Poll for DLL ready. Use a one second timeout.
203 * Works in all experiments done so far
204 */
205 ret = regmap_read_poll_timeout(plat->base, PHY_STAT1, val,
206 val & DLLRDY_MASK, 1000, 1000000);
207 if (ret)
208 return ret;
Faiz Abbase9aed582019-06-11 00:43:38 +0530209 }
210
211 return 0;
212}
213
Faiz Abbase9aed582019-06-11 00:43:38 +0530214int am654_sdhci_init(struct am654_sdhci_plat *plat)
215{
216 u32 ctl_cfg_2 = 0;
217 u32 mask, val;
218 int ret;
219
220 /* Reset OTAP to default value */
221 mask = OTAPDLYENA_MASK | OTAPDLYSEL_MASK;
222 regmap_update_bits(plat->base, PHY_CTRL4, mask, 0x0);
223
Faiz Abbasfd8be702019-06-13 10:29:51 +0530224 if (plat->flags & DLL_PRESENT) {
225 regmap_read(plat->base, PHY_STAT1, &val);
226 if (~val & CALDONE_MASK) {
227 /* Calibrate IO lines */
228 regmap_update_bits(plat->base, PHY_CTRL1, PDB_MASK,
229 PDB_MASK);
230 ret = regmap_read_poll_timeout(plat->base, PHY_STAT1,
231 val, val & CALDONE_MASK,
232 1, 20);
233 if (ret)
234 return ret;
235 }
Faiz Abbase9aed582019-06-11 00:43:38 +0530236
Faiz Abbasfd8be702019-06-13 10:29:51 +0530237 /* Configure DLL TRIM */
238 mask = DLL_TRIM_ICP_MASK;
239 val = plat->trm_icp << DLL_TRIM_ICP_SHIFT;
Faiz Abbase9aed582019-06-11 00:43:38 +0530240
Faiz Abbasfd8be702019-06-13 10:29:51 +0530241 /* Configure DLL driver strength */
242 mask |= DR_TY_MASK;
243 val |= plat->drv_strength << DR_TY_SHIFT;
244 regmap_update_bits(plat->base, PHY_CTRL1, mask, val);
245 }
Faiz Abbase9aed582019-06-11 00:43:38 +0530246
247 /* Enable pins by setting IO mux to 0 */
Faiz Abbas8cc051e2020-01-16 19:42:19 +0530248 if (plat->flags & IOMUX_PRESENT)
249 regmap_update_bits(plat->base, PHY_CTRL1, IOMUX_ENABLE_MASK, 0);
Faiz Abbase9aed582019-06-11 00:43:38 +0530250
251 /* Set slot type based on SD or eMMC */
252 if (plat->non_removable)
253 ctl_cfg_2 = SLOTTYPE_EMBEDDED;
254
255 regmap_update_bits(plat->base, CTL_CFG_2, SLOTTYPE_MASK, ctl_cfg_2);
256
257 return 0;
258}
259
Faiz Abbase4425cb2020-02-26 13:44:34 +0530260#define MAX_SDCD_DEBOUNCE_TIME 2000
261static int am654_sdhci_deferred_probe(struct sdhci_host *host)
262{
263 struct udevice *dev = host->mmc->dev;
Simon Glassfa20e932020-12-03 16:55:20 -0700264 struct am654_sdhci_plat *plat = dev_get_plat(dev);
Faiz Abbase4425cb2020-02-26 13:44:34 +0530265 unsigned long start;
266 int val;
267
268 /*
269 * The controller takes about 1 second to debounce the card detect line
270 * and doesn't let us power on until that time is up. Instead of waiting
271 * for 1 second at every stage, poll on the CARD_PRESENT bit upto a
272 * maximum of 2 seconds to be safe..
273 */
274 start = get_timer(0);
275 do {
276 if (get_timer(start) > MAX_SDCD_DEBOUNCE_TIME)
277 return -ENOMEDIUM;
278
279 val = mmc_getcd(host->mmc);
280 } while (!val);
281
282 am654_sdhci_init(plat);
283
284 return sdhci_probe(dev);
285}
286
287const struct sdhci_ops am654_sdhci_ops = {
288 .deferred_probe = am654_sdhci_deferred_probe,
289 .set_ios_post = &am654_sdhci_set_ios_post,
290 .set_control_reg = &am654_sdhci_set_control_reg,
291};
292
293const struct am654_driver_data am654_drv_data = {
294 .ops = &am654_sdhci_ops,
295 .flags = IOMUX_PRESENT | FREQSEL_2_BIT | DLL_PRESENT | STRBSEL_4_BIT,
296};
297
298const struct am654_driver_data j721e_8bit_drv_data = {
299 .ops = &am654_sdhci_ops,
300 .flags = DLL_PRESENT,
301};
302
303static int j721e_4bit_sdhci_set_ios_post(struct sdhci_host *host)
304{
305 struct udevice *dev = host->mmc->dev;
Simon Glassfa20e932020-12-03 16:55:20 -0700306 struct am654_sdhci_plat *plat = dev_get_plat(dev);
Faiz Abbase4425cb2020-02-26 13:44:34 +0530307 u32 otap_del_sel, mask, val;
308
309 otap_del_sel = plat->otap_del_sel[host->mmc->selected_mode];
310 mask = OTAPDLYENA_MASK | OTAPDLYSEL_MASK;
311 val = (1 << OTAPDLYENA_SHIFT) | (otap_del_sel << OTAPDLYSEL_SHIFT);
312 regmap_update_bits(plat->base, PHY_CTRL4, mask, val);
313
314 return 0;
315}
316
317const struct sdhci_ops j721e_4bit_sdhci_ops = {
318 .deferred_probe = am654_sdhci_deferred_probe,
319 .set_ios_post = &j721e_4bit_sdhci_set_ios_post,
320};
321
322const struct am654_driver_data j721e_4bit_drv_data = {
323 .ops = &j721e_4bit_sdhci_ops,
324 .flags = IOMUX_PRESENT,
325};
326
Faiz Abbasc6eb9e72020-02-26 13:44:33 +0530327static int sdhci_am654_get_otap_delay(struct udevice *dev,
328 struct mmc_config *cfg)
329{
Simon Glassfa20e932020-12-03 16:55:20 -0700330 struct am654_sdhci_plat *plat = dev_get_plat(dev);
Faiz Abbasc6eb9e72020-02-26 13:44:33 +0530331 int ret;
332 int i;
333
334 /* ti,otap-del-sel-legacy is mandatory */
335 ret = dev_read_u32(dev, "ti,otap-del-sel-legacy",
336 &plat->otap_del_sel[0]);
337 if (ret)
338 return ret;
339 /*
340 * Remove the corresponding capability if an otap-del-sel
341 * value is not found
342 */
343 for (i = MMC_HS; i <= MMC_HS_400; i++) {
344 ret = dev_read_u32(dev, td[i].binding, &plat->otap_del_sel[i]);
345 if (ret) {
346 dev_dbg(dev, "Couldn't find %s\n", td[i].binding);
347 /*
348 * Remove the corresponding capability
349 * if an otap-del-sel value is not found
350 */
351 cfg->host_caps &= ~td[i].capability;
352 }
353 }
354
355 return 0;
356}
357
Faiz Abbasd8fb3092019-06-11 00:43:31 +0530358static int am654_sdhci_probe(struct udevice *dev)
Lokesh Vutlabc9979f2018-08-27 15:57:54 +0530359{
Faiz Abbas8cc051e2020-01-16 19:42:19 +0530360 struct am654_driver_data *drv_data =
361 (struct am654_driver_data *)dev_get_driver_data(dev);
Simon Glassfa20e932020-12-03 16:55:20 -0700362 struct am654_sdhci_plat *plat = dev_get_plat(dev);
Lokesh Vutlabc9979f2018-08-27 15:57:54 +0530363 struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev);
364 struct sdhci_host *host = dev_get_priv(dev);
Faiz Abbase9aed582019-06-11 00:43:38 +0530365 struct mmc_config *cfg = &plat->cfg;
Lokesh Vutlabc9979f2018-08-27 15:57:54 +0530366 struct clk clk;
367 unsigned long clock;
368 int ret;
369
Faiz Abbasdc2bcc22020-01-16 19:42:18 +0530370 ret = clk_get_by_name(dev, "clk_xin", &clk);
Lokesh Vutlabc9979f2018-08-27 15:57:54 +0530371 if (ret) {
372 dev_err(dev, "failed to get clock\n");
373 return ret;
374 }
375
376 clock = clk_get_rate(&clk);
377 if (IS_ERR_VALUE(clock)) {
378 dev_err(dev, "failed to get rate\n");
379 return clock;
380 }
381
Lokesh Vutlabc9979f2018-08-27 15:57:54 +0530382 host->max_clk = clock;
Lokesh Vutlabc9979f2018-08-27 15:57:54 +0530383 host->mmc = &plat->mmc;
Faiz Abbase9aed582019-06-11 00:43:38 +0530384 host->mmc->dev = dev;
385 ret = sdhci_setup_cfg(cfg, host, cfg->f_max,
386 AM654_SDHCI_MIN_FREQ);
Lokesh Vutlabc9979f2018-08-27 15:57:54 +0530387 if (ret)
388 return ret;
Faiz Abbas8cc051e2020-01-16 19:42:19 +0530389
Faiz Abbasc6eb9e72020-02-26 13:44:33 +0530390 ret = sdhci_am654_get_otap_delay(dev, cfg);
391 if (ret)
392 return ret;
393
Faiz Abbas8cc051e2020-01-16 19:42:19 +0530394 host->ops = drv_data->ops;
Lokesh Vutlabc9979f2018-08-27 15:57:54 +0530395 host->mmc->priv = host;
Lokesh Vutlabc9979f2018-08-27 15:57:54 +0530396 upriv->mmc = host->mmc;
397
Faiz Abbase9aed582019-06-11 00:43:38 +0530398 regmap_init_mem_index(dev_ofnode(dev), &plat->base, 1);
399
Faiz Abbase4425cb2020-02-26 13:44:34 +0530400 return 0;
Lokesh Vutlabc9979f2018-08-27 15:57:54 +0530401}
402
Simon Glassaad29ae2020-12-03 16:55:21 -0700403static int am654_sdhci_of_to_plat(struct udevice *dev)
Lokesh Vutlabc9979f2018-08-27 15:57:54 +0530404{
Simon Glassfa20e932020-12-03 16:55:20 -0700405 struct am654_sdhci_plat *plat = dev_get_plat(dev);
Lokesh Vutlabc9979f2018-08-27 15:57:54 +0530406 struct sdhci_host *host = dev_get_priv(dev);
Faiz Abbase9aed582019-06-11 00:43:38 +0530407 struct mmc_config *cfg = &plat->cfg;
408 u32 drv_strength;
409 int ret;
Lokesh Vutlabc9979f2018-08-27 15:57:54 +0530410
411 host->name = dev->name;
412 host->ioaddr = (void *)dev_read_addr(dev);
Faiz Abbase9aed582019-06-11 00:43:38 +0530413 plat->non_removable = dev_read_bool(dev, "non-removable");
414
Faiz Abbasfd8be702019-06-13 10:29:51 +0530415 if (plat->flags & DLL_PRESENT) {
416 ret = dev_read_u32(dev, "ti,trm-icp", &plat->trm_icp);
417 if (ret)
418 return ret;
419
420 ret = dev_read_u32(dev, "ti,driver-strength-ohm",
421 &drv_strength);
422 if (ret)
423 return ret;
Faiz Abbase9aed582019-06-11 00:43:38 +0530424
Faiz Abbasfd8be702019-06-13 10:29:51 +0530425 switch (drv_strength) {
426 case 50:
427 plat->drv_strength = DRIVER_STRENGTH_50_OHM;
428 break;
429 case 33:
430 plat->drv_strength = DRIVER_STRENGTH_33_OHM;
431 break;
432 case 66:
433 plat->drv_strength = DRIVER_STRENGTH_66_OHM;
434 break;
435 case 100:
436 plat->drv_strength = DRIVER_STRENGTH_100_OHM;
437 break;
438 case 40:
439 plat->drv_strength = DRIVER_STRENGTH_40_OHM;
440 break;
441 default:
442 dev_err(dev, "Invalid driver strength\n");
443 return -EINVAL;
444 }
Faiz Abbase9aed582019-06-11 00:43:38 +0530445 }
446
447 ret = mmc_of_parse(dev, cfg);
448 if (ret)
449 return ret;
Lokesh Vutlabc9979f2018-08-27 15:57:54 +0530450
451 return 0;
452}
453
Faiz Abbasd8fb3092019-06-11 00:43:31 +0530454static int am654_sdhci_bind(struct udevice *dev)
Lokesh Vutlabc9979f2018-08-27 15:57:54 +0530455{
Faiz Abbas8cc051e2020-01-16 19:42:19 +0530456 struct am654_driver_data *drv_data =
457 (struct am654_driver_data *)dev_get_driver_data(dev);
Simon Glassfa20e932020-12-03 16:55:20 -0700458 struct am654_sdhci_plat *plat = dev_get_plat(dev);
Lokesh Vutlabc9979f2018-08-27 15:57:54 +0530459
Faiz Abbas8cc051e2020-01-16 19:42:19 +0530460 plat->flags = drv_data->flags;
461
Lokesh Vutlabc9979f2018-08-27 15:57:54 +0530462 return sdhci_bind(dev, &plat->mmc, &plat->cfg);
463}
464
Faiz Abbasd8fb3092019-06-11 00:43:31 +0530465static const struct udevice_id am654_sdhci_ids[] = {
Faiz Abbasfd8be702019-06-13 10:29:51 +0530466 {
467 .compatible = "ti,am654-sdhci-5.1",
Faiz Abbas8cc051e2020-01-16 19:42:19 +0530468 .data = (ulong)&am654_drv_data,
Faiz Abbasfd8be702019-06-13 10:29:51 +0530469 },
470 {
471 .compatible = "ti,j721e-sdhci-8bit",
Faiz Abbas8cc051e2020-01-16 19:42:19 +0530472 .data = (ulong)&j721e_8bit_drv_data,
Faiz Abbasfd8be702019-06-13 10:29:51 +0530473 },
474 {
475 .compatible = "ti,j721e-sdhci-4bit",
Faiz Abbas8cc051e2020-01-16 19:42:19 +0530476 .data = (ulong)&j721e_4bit_drv_data,
Faiz Abbasfd8be702019-06-13 10:29:51 +0530477 },
Lokesh Vutlabc9979f2018-08-27 15:57:54 +0530478 { }
479};
480
Faiz Abbasd8fb3092019-06-11 00:43:31 +0530481U_BOOT_DRIVER(am654_sdhci_drv) = {
482 .name = "am654_sdhci",
Lokesh Vutlabc9979f2018-08-27 15:57:54 +0530483 .id = UCLASS_MMC,
Faiz Abbasd8fb3092019-06-11 00:43:31 +0530484 .of_match = am654_sdhci_ids,
Simon Glassaad29ae2020-12-03 16:55:21 -0700485 .of_to_plat = am654_sdhci_of_to_plat,
Lokesh Vutlabc9979f2018-08-27 15:57:54 +0530486 .ops = &sdhci_ops,
Faiz Abbasd8fb3092019-06-11 00:43:31 +0530487 .bind = am654_sdhci_bind,
488 .probe = am654_sdhci_probe,
Simon Glass8a2b47f2020-12-03 16:55:17 -0700489 .priv_auto = sizeof(struct sdhci_host),
Simon Glass71fa5b42020-12-03 16:55:18 -0700490 .plat_auto = sizeof(struct am654_sdhci_plat),
Lokesh Vutlabc9979f2018-08-27 15:57:54 +0530491};