blob: 2b45549a143645557b5e0e7194738601c96b1532 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Marek Vasut07133f22011-11-02 00:29:27 +00002/*
3 * Copyright (C) 2010 Marek Vasut <marek.vasut@gmail.com>
4 *
Marcel Ziswiler290e6bb2019-05-20 02:44:59 +02005 * Modified to add driver model (DM) support
6 * Copyright (C) 2019 Marcel Ziswiler <marcel@ziswiler.com>
7 *
Marek Vasut07133f22011-11-02 00:29:27 +00008 * Loosely based on the old code and Linux's PXA MMC driver
Marek Vasut07133f22011-11-02 00:29:27 +00009 */
10
Marek Vasut07133f22011-11-02 00:29:27 +000011#include <common.h>
Marek Vasut07133f22011-11-02 00:29:27 +000012#include <asm/arch/hardware.h>
13#include <asm/arch/regs-mmc.h>
Simon Glassc05ed002020-05-10 11:40:11 -060014#include <linux/delay.h>
Masahiro Yamada1221ce42016-09-21 11:28:55 +090015#include <linux/errno.h>
Marek Vasut07133f22011-11-02 00:29:27 +000016#include <asm/io.h>
Marcel Ziswiler290e6bb2019-05-20 02:44:59 +020017#include <dm.h>
18#include <dm/platform_data/pxa_mmc_gen.h>
Marcel Ziswiler54a5cf82015-08-16 04:16:27 +020019#include <malloc.h>
20#include <mmc.h>
Marek Vasut07133f22011-11-02 00:29:27 +000021
22/* PXAMMC Generic default config for various CPUs */
Marek Vasutabc20ab2011-11-26 07:20:07 +010023#if defined(CONFIG_CPU_PXA25X)
Marek Vasut07133f22011-11-02 00:29:27 +000024#define PXAMMC_FIFO_SIZE 1
25#define PXAMMC_MIN_SPEED 312500
26#define PXAMMC_MAX_SPEED 20000000
27#define PXAMMC_HOST_CAPS (0)
Marek Vasutabc20ab2011-11-26 07:20:07 +010028#elif defined(CONFIG_CPU_PXA27X)
Marek Vasut07133f22011-11-02 00:29:27 +000029#define PXAMMC_CRC_SKIP
30#define PXAMMC_FIFO_SIZE 32
31#define PXAMMC_MIN_SPEED 304000
32#define PXAMMC_MAX_SPEED 19500000
33#define PXAMMC_HOST_CAPS (MMC_MODE_4BIT)
34#elif defined(CONFIG_CPU_MONAHANS)
35#define PXAMMC_FIFO_SIZE 32
36#define PXAMMC_MIN_SPEED 304000
37#define PXAMMC_MAX_SPEED 26000000
38#define PXAMMC_HOST_CAPS (MMC_MODE_4BIT | MMC_MODE_HS)
39#else
40#error "This CPU isn't supported by PXA MMC!"
41#endif
42
43#define MMC_STAT_ERRORS \
44 (MMC_STAT_RES_CRC_ERROR | MMC_STAT_SPI_READ_ERROR_TOKEN | \
45 MMC_STAT_CRC_READ_ERROR | MMC_STAT_TIME_OUT_RESPONSE | \
46 MMC_STAT_READ_TIME_OUT | MMC_STAT_CRC_WRITE_ERROR)
47
48/* 1 millisecond (in wait cycles below it's 100 x 10uS waits) */
49#define PXA_MMC_TIMEOUT 100
50
51struct pxa_mmc_priv {
52 struct pxa_mmc_regs *regs;
53};
54
55/* Wait for bit to be set */
56static int pxa_mmc_wait(struct mmc *mmc, uint32_t mask)
57{
Pantelis Antoniou93bfd612014-03-11 19:34:20 +020058 struct pxa_mmc_priv *priv = mmc->priv;
Marek Vasut07133f22011-11-02 00:29:27 +000059 struct pxa_mmc_regs *regs = priv->regs;
60 unsigned int timeout = PXA_MMC_TIMEOUT;
61
62 /* Wait for bit to be set */
63 while (--timeout) {
64 if (readl(&regs->stat) & mask)
65 break;
66 udelay(10);
67 }
68
69 if (!timeout)
70 return -ETIMEDOUT;
71
72 return 0;
73}
74
75static int pxa_mmc_stop_clock(struct mmc *mmc)
76{
Pantelis Antoniou93bfd612014-03-11 19:34:20 +020077 struct pxa_mmc_priv *priv = mmc->priv;
Marek Vasut07133f22011-11-02 00:29:27 +000078 struct pxa_mmc_regs *regs = priv->regs;
79 unsigned int timeout = PXA_MMC_TIMEOUT;
80
81 /* If the clock aren't running, exit */
82 if (!(readl(&regs->stat) & MMC_STAT_CLK_EN))
83 return 0;
84
85 /* Tell the controller to turn off the clock */
86 writel(MMC_STRPCL_STOP_CLK, &regs->strpcl);
87
88 /* Wait until the clock are off */
89 while (--timeout) {
90 if (!(readl(&regs->stat) & MMC_STAT_CLK_EN))
91 break;
92 udelay(10);
93 }
94
95 /* The clock refused to stop, scream and die a painful death */
96 if (!timeout)
97 return -ETIMEDOUT;
98
99 /* The clock stopped correctly */
100 return 0;
101}
102
103static int pxa_mmc_start_cmd(struct mmc *mmc, struct mmc_cmd *cmd,
Marcel Ziswiler290e6bb2019-05-20 02:44:59 +0200104 uint32_t cmdat)
Marek Vasut07133f22011-11-02 00:29:27 +0000105{
Pantelis Antoniou93bfd612014-03-11 19:34:20 +0200106 struct pxa_mmc_priv *priv = mmc->priv;
Marek Vasut07133f22011-11-02 00:29:27 +0000107 struct pxa_mmc_regs *regs = priv->regs;
108 int ret;
109
110 /* The card can send a "busy" response */
Andy Fleming95b01c42012-09-06 15:23:13 -0500111 if (cmd->resp_type & MMC_RSP_BUSY)
Marek Vasut07133f22011-11-02 00:29:27 +0000112 cmdat |= MMC_CMDAT_BUSY;
113
114 /* Inform the controller about response type */
115 switch (cmd->resp_type) {
116 case MMC_RSP_R1:
117 case MMC_RSP_R1b:
118 cmdat |= MMC_CMDAT_R1;
119 break;
120 case MMC_RSP_R2:
121 cmdat |= MMC_CMDAT_R2;
122 break;
123 case MMC_RSP_R3:
124 cmdat |= MMC_CMDAT_R3;
125 break;
126 default:
127 break;
128 }
129
130 /* Load command and it's arguments into the controller */
131 writel(cmd->cmdidx, &regs->cmd);
132 writel(cmd->cmdarg >> 16, &regs->argh);
133 writel(cmd->cmdarg & 0xffff, &regs->argl);
134 writel(cmdat, &regs->cmdat);
135
136 /* Start the controller clock and wait until they are started */
137 writel(MMC_STRPCL_START_CLK, &regs->strpcl);
138
139 ret = pxa_mmc_wait(mmc, MMC_STAT_CLK_EN);
140 if (ret)
141 return ret;
142
143 /* Correct and happy end */
144 return 0;
145}
146
147static int pxa_mmc_cmd_done(struct mmc *mmc, struct mmc_cmd *cmd)
148{
Pantelis Antoniou93bfd612014-03-11 19:34:20 +0200149 struct pxa_mmc_priv *priv = mmc->priv;
Marek Vasut07133f22011-11-02 00:29:27 +0000150 struct pxa_mmc_regs *regs = priv->regs;
Marcel Ziswiler290e6bb2019-05-20 02:44:59 +0200151 u32 a, b, c;
Marek Vasut07133f22011-11-02 00:29:27 +0000152 int i;
153 int stat;
154
155 /* Read the controller status */
156 stat = readl(&regs->stat);
157
158 /*
159 * Linux says:
Marcel Ziswiler290e6bb2019-05-20 02:44:59 +0200160 * Did I mention this is Sick. We always need to
Marek Vasut07133f22011-11-02 00:29:27 +0000161 * discard the upper 8 bits of the first 16-bit word.
162 */
163 a = readl(&regs->res) & 0xffff;
164 for (i = 0; i < 4; i++) {
165 b = readl(&regs->res) & 0xffff;
166 c = readl(&regs->res) & 0xffff;
167 cmd->response[i] = (a << 24) | (b << 8) | (c >> 8);
168 a = c;
169 }
170
171 /* The command response didn't arrive */
Marcel Ziswiler290e6bb2019-05-20 02:44:59 +0200172 if (stat & MMC_STAT_TIME_OUT_RESPONSE) {
Marek Vasut07133f22011-11-02 00:29:27 +0000173 return -ETIMEDOUT;
Marcel Ziswiler290e6bb2019-05-20 02:44:59 +0200174 } else if (stat & MMC_STAT_RES_CRC_ERROR &&
175 cmd->resp_type & MMC_RSP_CRC) {
176#ifdef PXAMMC_CRC_SKIP
177 if (cmd->resp_type & MMC_RSP_136 &&
178 cmd->response[0] & (1 << 31))
Marek Vasut07133f22011-11-02 00:29:27 +0000179 printf("Ignoring CRC, this may be dangerous!\n");
180 else
181#endif
182 return -EILSEQ;
183 }
184
185 /* The command response was successfully read */
186 return 0;
187}
188
189static int pxa_mmc_do_read_xfer(struct mmc *mmc, struct mmc_data *data)
190{
Pantelis Antoniou93bfd612014-03-11 19:34:20 +0200191 struct pxa_mmc_priv *priv = mmc->priv;
Marek Vasut07133f22011-11-02 00:29:27 +0000192 struct pxa_mmc_regs *regs = priv->regs;
Marcel Ziswiler290e6bb2019-05-20 02:44:59 +0200193 u32 len;
194 u32 *buf = (uint32_t *)data->dest;
Marek Vasut07133f22011-11-02 00:29:27 +0000195 int size;
196 int ret;
197
198 len = data->blocks * data->blocksize;
199
200 while (len) {
201 /* The controller has data ready */
202 if (readl(&regs->i_reg) & MMC_I_REG_RXFIFO_RD_REQ) {
Masahiro Yamadab4141192014-11-07 03:03:31 +0900203 size = min(len, (uint32_t)PXAMMC_FIFO_SIZE);
Marek Vasut07133f22011-11-02 00:29:27 +0000204 len -= size;
205 size /= 4;
206
207 /* Read data into the buffer */
208 while (size--)
209 *buf++ = readl(&regs->rxfifo);
Marek Vasut07133f22011-11-02 00:29:27 +0000210 }
211
212 if (readl(&regs->stat) & MMC_STAT_ERRORS)
213 return -EIO;
214 }
215
216 /* Wait for the transmission-done interrupt */
217 ret = pxa_mmc_wait(mmc, MMC_STAT_DATA_TRAN_DONE);
218 if (ret)
219 return ret;
220
221 return 0;
222}
223
224static int pxa_mmc_do_write_xfer(struct mmc *mmc, struct mmc_data *data)
225{
Pantelis Antoniou93bfd612014-03-11 19:34:20 +0200226 struct pxa_mmc_priv *priv = mmc->priv;
Marek Vasut07133f22011-11-02 00:29:27 +0000227 struct pxa_mmc_regs *regs = priv->regs;
Marcel Ziswiler290e6bb2019-05-20 02:44:59 +0200228 u32 len;
229 u32 *buf = (uint32_t *)data->src;
Marek Vasut07133f22011-11-02 00:29:27 +0000230 int size;
231 int ret;
232
233 len = data->blocks * data->blocksize;
234
235 while (len) {
236 /* The controller is ready to receive data */
237 if (readl(&regs->i_reg) & MMC_I_REG_TXFIFO_WR_REQ) {
Masahiro Yamadab4141192014-11-07 03:03:31 +0900238 size = min(len, (uint32_t)PXAMMC_FIFO_SIZE);
Marek Vasut07133f22011-11-02 00:29:27 +0000239 len -= size;
240 size /= 4;
241
242 while (size--)
243 writel(*buf++, &regs->txfifo);
244
Masahiro Yamadab4141192014-11-07 03:03:31 +0900245 if (min(len, (uint32_t)PXAMMC_FIFO_SIZE) < 32)
Marek Vasut07133f22011-11-02 00:29:27 +0000246 writel(MMC_PRTBUF_BUF_PART_FULL, &regs->prtbuf);
247 }
248
249 if (readl(&regs->stat) & MMC_STAT_ERRORS)
250 return -EIO;
251 }
252
253 /* Wait for the transmission-done interrupt */
254 ret = pxa_mmc_wait(mmc, MMC_STAT_DATA_TRAN_DONE);
255 if (ret)
256 return ret;
257
258 /* Wait until the data are really written to the card */
259 ret = pxa_mmc_wait(mmc, MMC_STAT_PRG_DONE);
260 if (ret)
261 return ret;
262
263 return 0;
264}
265
Marcel Ziswiler290e6bb2019-05-20 02:44:59 +0200266static int pxa_mmc_send_cmd_common(struct pxa_mmc_priv *priv, struct mmc *mmc,
267 struct mmc_cmd *cmd, struct mmc_data *data)
Marek Vasut07133f22011-11-02 00:29:27 +0000268{
Marek Vasut07133f22011-11-02 00:29:27 +0000269 struct pxa_mmc_regs *regs = priv->regs;
Marcel Ziswiler290e6bb2019-05-20 02:44:59 +0200270 u32 cmdat = 0;
Marek Vasut07133f22011-11-02 00:29:27 +0000271 int ret;
272
273 /* Stop the controller */
274 ret = pxa_mmc_stop_clock(mmc);
275 if (ret)
276 return ret;
277
278 /* If we're doing data transfer, configure the controller accordingly */
279 if (data) {
280 writel(data->blocks, &regs->nob);
281 writel(data->blocksize, &regs->blklen);
282 /* This delay can be optimized, but stick with max value */
283 writel(0xffff, &regs->rdto);
284 cmdat |= MMC_CMDAT_DATA_EN;
285 if (data->flags & MMC_DATA_WRITE)
286 cmdat |= MMC_CMDAT_WRITE;
287 }
288
289 /* Run in 4bit mode if the card can do it */
290 if (mmc->bus_width == 4)
291 cmdat |= MMC_CMDAT_SD_4DAT;
292
293 /* Execute the command */
294 ret = pxa_mmc_start_cmd(mmc, cmd, cmdat);
295 if (ret)
296 return ret;
297
298 /* Wait until the command completes */
299 ret = pxa_mmc_wait(mmc, MMC_STAT_END_CMD_RES);
300 if (ret)
301 return ret;
302
303 /* Read back the result */
304 ret = pxa_mmc_cmd_done(mmc, cmd);
305 if (ret)
306 return ret;
307
308 /* In case there was a data transfer scheduled, do it */
309 if (data) {
310 if (data->flags & MMC_DATA_WRITE)
311 pxa_mmc_do_write_xfer(mmc, data);
312 else
313 pxa_mmc_do_read_xfer(mmc, data);
314 }
315
316 return 0;
317}
318
Marcel Ziswiler290e6bb2019-05-20 02:44:59 +0200319static int pxa_mmc_set_ios_common(struct pxa_mmc_priv *priv, struct mmc *mmc)
Marek Vasut07133f22011-11-02 00:29:27 +0000320{
Marek Vasut07133f22011-11-02 00:29:27 +0000321 struct pxa_mmc_regs *regs = priv->regs;
Marcel Ziswiler290e6bb2019-05-20 02:44:59 +0200322 u32 tmp;
323 u32 pxa_mmc_clock;
Marek Vasut07133f22011-11-02 00:29:27 +0000324
325 if (!mmc->clock) {
326 pxa_mmc_stop_clock(mmc);
Jaehoon Chung07b0b9c2016-12-30 15:30:16 +0900327 return 0;
Marek Vasut07133f22011-11-02 00:29:27 +0000328 }
329
330 /* PXA3xx can do 26MHz with special settings. */
331 if (mmc->clock == 26000000) {
332 writel(0x7, &regs->clkrt);
Jaehoon Chung07b0b9c2016-12-30 15:30:16 +0900333 return 0;
Marek Vasut07133f22011-11-02 00:29:27 +0000334 }
335
336 /* Set clock to the card the usual way. */
337 pxa_mmc_clock = 0;
Pantelis Antoniou93bfd612014-03-11 19:34:20 +0200338 tmp = mmc->cfg->f_max / mmc->clock;
Marek Vasut07133f22011-11-02 00:29:27 +0000339 tmp += tmp % 2;
340
341 while (tmp > 1) {
342 pxa_mmc_clock++;
343 tmp >>= 1;
344 }
345
346 writel(pxa_mmc_clock, &regs->clkrt);
Jaehoon Chung07b0b9c2016-12-30 15:30:16 +0900347
348 return 0;
Marek Vasut07133f22011-11-02 00:29:27 +0000349}
350
Marcel Ziswiler290e6bb2019-05-20 02:44:59 +0200351static int pxa_mmc_init_common(struct pxa_mmc_priv *priv, struct mmc *mmc)
Marek Vasut07133f22011-11-02 00:29:27 +0000352{
Marek Vasut07133f22011-11-02 00:29:27 +0000353 struct pxa_mmc_regs *regs = priv->regs;
354
355 /* Make sure the clock are stopped */
356 pxa_mmc_stop_clock(mmc);
357
358 /* Turn off SPI mode */
359 writel(0, &regs->spi);
360
361 /* Set up maximum timeout to wait for command response */
362 writel(MMC_RES_TO_MAX_MASK, &regs->resto);
363
364 /* Mask all interrupts */
365 writel(~(MMC_I_MASK_TXFIFO_WR_REQ | MMC_I_MASK_RXFIFO_RD_REQ),
Marcel Ziswiler290e6bb2019-05-20 02:44:59 +0200366 &regs->i_mask);
367
Marek Vasut07133f22011-11-02 00:29:27 +0000368 return 0;
369}
370
Marcel Ziswiler290e6bb2019-05-20 02:44:59 +0200371#if !CONFIG_IS_ENABLED(DM_MMC)
372static int pxa_mmc_init(struct mmc *mmc)
373{
374 struct pxa_mmc_priv *priv = mmc->priv;
375
376 return pxa_mmc_init_common(priv, mmc);
377}
378
379static int pxa_mmc_request(struct mmc *mmc, struct mmc_cmd *cmd,
380 struct mmc_data *data)
381{
382 struct pxa_mmc_priv *priv = mmc->priv;
383
384 return pxa_mmc_send_cmd_common(priv, mmc, cmd, data);
385}
386
387static int pxa_mmc_set_ios(struct mmc *mmc)
388{
389 struct pxa_mmc_priv *priv = mmc->priv;
390
391 return pxa_mmc_set_ios_common(priv, mmc);
392}
393
Pantelis Antoniouab769f22014-02-26 19:28:45 +0200394static const struct mmc_ops pxa_mmc_ops = {
395 .send_cmd = pxa_mmc_request,
396 .set_ios = pxa_mmc_set_ios,
397 .init = pxa_mmc_init,
398};
399
Pantelis Antoniou93bfd612014-03-11 19:34:20 +0200400static struct mmc_config pxa_mmc_cfg = {
401 .name = "PXA MMC",
402 .ops = &pxa_mmc_ops,
403 .voltages = MMC_VDD_32_33 | MMC_VDD_33_34,
404 .f_max = PXAMMC_MAX_SPEED,
405 .f_min = PXAMMC_MIN_SPEED,
406 .host_caps = PXAMMC_HOST_CAPS,
407 .b_max = CONFIG_SYS_MMC_MAX_BLK_COUNT,
408};
409
Marek Vasut07133f22011-11-02 00:29:27 +0000410int pxa_mmc_register(int card_index)
411{
412 struct mmc *mmc;
413 struct pxa_mmc_priv *priv;
Marcel Ziswiler290e6bb2019-05-20 02:44:59 +0200414 u32 reg;
Marek Vasut07133f22011-11-02 00:29:27 +0000415 int ret = -ENOMEM;
416
Marek Vasut07133f22011-11-02 00:29:27 +0000417 priv = malloc(sizeof(struct pxa_mmc_priv));
418 if (!priv)
Pantelis Antoniou93bfd612014-03-11 19:34:20 +0200419 goto err0;
420
421 memset(priv, 0, sizeof(*priv));
Marek Vasut07133f22011-11-02 00:29:27 +0000422
423 switch (card_index) {
424 case 0:
425 priv->regs = (struct pxa_mmc_regs *)MMC0_BASE;
426 break;
427 case 1:
428 priv->regs = (struct pxa_mmc_regs *)MMC1_BASE;
429 break;
430 default:
Pantelis Antoniou93bfd612014-03-11 19:34:20 +0200431 ret = -EINVAL;
Marek Vasut07133f22011-11-02 00:29:27 +0000432 printf("PXA MMC: Invalid MMC controller ID (card_index = %d)\n",
Marcel Ziswiler290e6bb2019-05-20 02:44:59 +0200433 card_index);
Pantelis Antoniou93bfd612014-03-11 19:34:20 +0200434 goto err1;
Marek Vasut07133f22011-11-02 00:29:27 +0000435 }
436
Marek Vasut07133f22011-11-02 00:29:27 +0000437#ifndef CONFIG_CPU_MONAHANS /* PXA2xx */
438 reg = readl(CKEN);
439 reg |= CKEN12_MMC;
440 writel(reg, CKEN);
441#else /* PXA3xx */
442 reg = readl(CKENA);
443 reg |= CKENA_12_MMC0 | CKENA_13_MMC1;
444 writel(reg, CKENA);
445#endif
446
Pantelis Antoniou93bfd612014-03-11 19:34:20 +0200447 mmc = mmc_create(&pxa_mmc_cfg, priv);
Marcel Ziswiler290e6bb2019-05-20 02:44:59 +0200448 if (!mmc)
Pantelis Antoniou93bfd612014-03-11 19:34:20 +0200449 goto err1;
Marek Vasut07133f22011-11-02 00:29:27 +0000450
451 return 0;
452
Marek Vasut07133f22011-11-02 00:29:27 +0000453err1:
Pantelis Antoniou93bfd612014-03-11 19:34:20 +0200454 free(priv);
Marek Vasut07133f22011-11-02 00:29:27 +0000455err0:
456 return ret;
457}
Marcel Ziswiler290e6bb2019-05-20 02:44:59 +0200458#else /* !CONFIG_IS_ENABLED(DM_MMC) */
459static int pxa_mmc_probe(struct udevice *dev)
460{
461 struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev);
Simon Glassc69cda22020-12-03 16:55:20 -0700462 struct pxa_mmc_plat *plat = dev_get_plat(dev);
Marcel Ziswiler290e6bb2019-05-20 02:44:59 +0200463 struct mmc_config *cfg = &plat->cfg;
464 struct mmc *mmc = &plat->mmc;
465 struct pxa_mmc_priv *priv = dev_get_priv(dev);
466 u32 reg;
467
468 upriv->mmc = mmc;
469
470 cfg->b_max = CONFIG_SYS_MMC_MAX_BLK_COUNT;
471 cfg->f_max = PXAMMC_MAX_SPEED;
472 cfg->f_min = PXAMMC_MIN_SPEED;
473 cfg->host_caps = PXAMMC_HOST_CAPS;
474 cfg->name = dev->name;
475 cfg->voltages = MMC_VDD_32_33 | MMC_VDD_33_34;
476
477 mmc->priv = priv;
478
479 priv->regs = plat->base;
480
481#ifndef CONFIG_CPU_MONAHANS /* PXA2xx */
482 reg = readl(CKEN);
483 reg |= CKEN12_MMC;
484 writel(reg, CKEN);
485#else /* PXA3xx */
486 reg = readl(CKENA);
487 reg |= CKENA_12_MMC0 | CKENA_13_MMC1;
488 writel(reg, CKENA);
489#endif
490
491 return pxa_mmc_init_common(priv, mmc);
492}
493
494static int pxa_mmc_send_cmd(struct udevice *dev, struct mmc_cmd *cmd,
495 struct mmc_data *data)
496{
Simon Glassc69cda22020-12-03 16:55:20 -0700497 struct pxa_mmc_plat *plat = dev_get_plat(dev);
Marcel Ziswiler290e6bb2019-05-20 02:44:59 +0200498 struct pxa_mmc_priv *priv = dev_get_priv(dev);
499
500 return pxa_mmc_send_cmd_common(priv, &plat->mmc, cmd, data);
501}
502
503static int pxa_mmc_set_ios(struct udevice *dev)
504{
Simon Glassc69cda22020-12-03 16:55:20 -0700505 struct pxa_mmc_plat *plat = dev_get_plat(dev);
Marcel Ziswiler290e6bb2019-05-20 02:44:59 +0200506 struct pxa_mmc_priv *priv = dev_get_priv(dev);
507
508 return pxa_mmc_set_ios_common(priv, &plat->mmc);
509}
510
511static const struct dm_mmc_ops pxa_mmc_ops = {
512 .get_cd = NULL,
513 .send_cmd = pxa_mmc_send_cmd,
514 .set_ios = pxa_mmc_set_ios,
515};
516
517#if CONFIG_IS_ENABLED(BLK)
518static int pxa_mmc_bind(struct udevice *dev)
519{
Simon Glassc69cda22020-12-03 16:55:20 -0700520 struct pxa_mmc_plat *plat = dev_get_plat(dev);
Marcel Ziswiler290e6bb2019-05-20 02:44:59 +0200521
522 return mmc_bind(dev, &plat->mmc, &plat->cfg);
523}
524#endif
525
526U_BOOT_DRIVER(pxa_mmc) = {
527#if CONFIG_IS_ENABLED(BLK)
528 .bind = pxa_mmc_bind,
529#endif
530 .id = UCLASS_MMC,
531 .name = "pxa_mmc",
532 .ops = &pxa_mmc_ops,
Simon Glass41575d82020-12-03 16:55:17 -0700533 .priv_auto = sizeof(struct pxa_mmc_priv),
Marcel Ziswiler290e6bb2019-05-20 02:44:59 +0200534 .probe = pxa_mmc_probe,
535};
536#endif /* !CONFIG_IS_ENABLED(DM_MMC) */