blob: 18d36878efaff130c7f9703de1b02f78b8ca12cb [file] [log] [blame]
Thomas Chou1254c3d2010-12-24 13:12:21 +00001/*
2 * generic mmc spi driver
3 *
4 * Copyright (C) 2010 Thomas Chou <thomas@wytron.com.tw>
Bhargav Shaha1afe252019-07-08 04:10:48 +00005 * Copyright 2019 Bhargav Shah <bhargavshah1988@gmail.com>
6 *
Thomas Chou1254c3d2010-12-24 13:12:21 +00007 * Licensed under the GPL-2 or later.
8 */
9#include <common.h>
Jaehoon Chung7825d202016-07-19 16:33:36 +090010#include <errno.h>
Simon Glass0f2af882020-05-10 11:40:05 -060011#include <log.h>
Thomas Chou1254c3d2010-12-24 13:12:21 +000012#include <malloc.h>
13#include <part.h>
14#include <mmc.h>
Bhargav Shaha1afe252019-07-08 04:10:48 +000015#include <stdlib.h>
Simon Glass4dcacfc2020-05-10 11:40:13 -060016#include <linux/bitops.h>
Philipp Tomsich36b26d12018-11-25 19:22:18 +010017#include <u-boot/crc.h>
Thomas Chou1254c3d2010-12-24 13:12:21 +000018#include <linux/crc7.h>
Yoshinori Sato923c2072015-06-01 15:22:37 +090019#include <asm/byteorder.h>
Bhargav Shaha1afe252019-07-08 04:10:48 +000020#include <dm.h>
21#include <spi.h>
Thomas Chou1254c3d2010-12-24 13:12:21 +000022
23/* MMC/SD in SPI mode reports R1 status always */
Bhargav Shaha1afe252019-07-08 04:10:48 +000024#define R1_SPI_IDLE BIT(0)
25#define R1_SPI_ERASE_RESET BIT(1)
26#define R1_SPI_ILLEGAL_COMMAND BIT(2)
27#define R1_SPI_COM_CRC BIT(3)
28#define R1_SPI_ERASE_SEQ BIT(4)
29#define R1_SPI_ADDRESS BIT(5)
30#define R1_SPI_PARAMETER BIT(6)
Thomas Chou1254c3d2010-12-24 13:12:21 +000031/* R1 bit 7 is always zero, reuse this bit for error */
Bhargav Shaha1afe252019-07-08 04:10:48 +000032#define R1_SPI_ERROR BIT(7)
Thomas Chou1254c3d2010-12-24 13:12:21 +000033
34/* Response tokens used to ack each block written: */
35#define SPI_MMC_RESPONSE_CODE(x) ((x) & 0x1f)
36#define SPI_RESPONSE_ACCEPTED ((2 << 1)|1)
37#define SPI_RESPONSE_CRC_ERR ((5 << 1)|1)
38#define SPI_RESPONSE_WRITE_ERR ((6 << 1)|1)
39
40/* Read and write blocks start with these tokens and end with crc;
41 * on error, read tokens act like a subset of R2_SPI_* values.
42 */
Bhargav Shaha1afe252019-07-08 04:10:48 +000043/* single block write multiblock read */
44#define SPI_TOKEN_SINGLE 0xfe
45/* multiblock write */
46#define SPI_TOKEN_MULTI_WRITE 0xfc
47/* terminate multiblock write */
48#define SPI_TOKEN_STOP_TRAN 0xfd
Thomas Chou1254c3d2010-12-24 13:12:21 +000049
50/* MMC SPI commands start with a start bit "0" and a transmit bit "1" */
Bhargav Shaha1afe252019-07-08 04:10:48 +000051#define MMC_SPI_CMD(x) (0x40 | (x))
Thomas Chou1254c3d2010-12-24 13:12:21 +000052
53/* bus capability */
Bhargav Shaha1afe252019-07-08 04:10:48 +000054#define MMC_SPI_VOLTAGE (MMC_VDD_32_33 | MMC_VDD_33_34)
55#define MMC_SPI_MIN_CLOCK 400000 /* 400KHz to meet MMC spec */
56#define MMC_SPI_MAX_CLOCK 25000000 /* SD/MMC legacy speed */
Thomas Chou1254c3d2010-12-24 13:12:21 +000057
58/* timeout value */
Bhargav Shaha1afe252019-07-08 04:10:48 +000059#define CMD_TIMEOUT 8
60#define READ_TIMEOUT 3000000 /* 1 sec */
61#define WRITE_TIMEOUT 3000000 /* 1 sec */
62
Bin Mengf7260322019-08-30 21:15:33 -070063struct mmc_spi_plat {
Bhargav Shaha1afe252019-07-08 04:10:48 +000064 struct mmc_config cfg;
65 struct mmc mmc;
66};
Thomas Chou1254c3d2010-12-24 13:12:21 +000067
Bin Mengf7260322019-08-30 21:15:33 -070068struct mmc_spi_priv {
69 struct spi_slave *spi;
70};
71
Bhargav Shaha1afe252019-07-08 04:10:48 +000072static int mmc_spi_sendcmd(struct udevice *dev,
73 ushort cmdidx, u32 cmdarg, u32 resp_type,
74 u8 *resp, u32 resp_size,
75 bool resp_match, u8 resp_match_value)
Thomas Chou1254c3d2010-12-24 13:12:21 +000076{
Bhargav Shaha1afe252019-07-08 04:10:48 +000077 int i, rpos = 0, ret = 0;
78 u8 cmdo[7], r;
79
80 debug("%s: cmd%d cmdarg=0x%x resp_type=0x%x "
81 "resp_size=%d resp_match=%d resp_match_value=0x%x\n",
82 __func__, cmdidx, cmdarg, resp_type,
83 resp_size, resp_match, resp_match_value);
84
Thomas Chou1254c3d2010-12-24 13:12:21 +000085 cmdo[0] = 0xff;
86 cmdo[1] = MMC_SPI_CMD(cmdidx);
87 cmdo[2] = cmdarg >> 24;
88 cmdo[3] = cmdarg >> 16;
89 cmdo[4] = cmdarg >> 8;
90 cmdo[5] = cmdarg;
91 cmdo[6] = (crc7(0, &cmdo[1], 5) << 1) | 0x01;
Anup Pateld2c68c02019-07-17 04:23:38 +000092 ret = dm_spi_xfer(dev, sizeof(cmdo) * 8, cmdo, NULL, SPI_XFER_BEGIN);
Bhargav Shaha1afe252019-07-08 04:10:48 +000093 if (ret)
94 return ret;
95
96 ret = dm_spi_xfer(dev, 1 * 8, NULL, &r, 0);
97 if (ret)
98 return ret;
99
100 if (!resp || !resp_size)
101 return 0;
102
103 debug("%s: cmd%d", __func__, cmdidx);
104
105 if (resp_match) {
106 r = ~resp_match_value;
107 i = CMD_TIMEOUT;
Pragnesh Patel32ca52e2020-06-29 15:17:24 +0530108 while (i) {
Bhargav Shaha1afe252019-07-08 04:10:48 +0000109 ret = dm_spi_xfer(dev, 1 * 8, NULL, &r, 0);
110 if (ret)
111 return ret;
112 debug(" resp%d=0x%x", rpos, r);
113 rpos++;
Pragnesh Patel32ca52e2020-06-29 15:17:24 +0530114 i--;
115
Bhargav Shaha1afe252019-07-08 04:10:48 +0000116 if (r == resp_match_value)
117 break;
118 }
119 if (!i && (r != resp_match_value))
120 return -ETIMEDOUT;
Thomas Chou1254c3d2010-12-24 13:12:21 +0000121 }
Bhargav Shaha1afe252019-07-08 04:10:48 +0000122
123 for (i = 0; i < resp_size; i++) {
124 if (i == 0 && resp_match) {
125 resp[i] = resp_match_value;
126 continue;
127 }
128 ret = dm_spi_xfer(dev, 1 * 8, NULL, &r, 0);
129 if (ret)
130 return ret;
131 debug(" resp%d=0x%x", rpos, r);
132 rpos++;
133 resp[i] = r;
134 }
135
136 debug("\n");
137
138 return 0;
Thomas Chou1254c3d2010-12-24 13:12:21 +0000139}
140
Bhargav Shaha1afe252019-07-08 04:10:48 +0000141static int mmc_spi_readdata(struct udevice *dev,
142 void *xbuf, u32 bcnt, u32 bsize)
Thomas Chou1254c3d2010-12-24 13:12:21 +0000143{
Thomas Chou1254c3d2010-12-24 13:12:21 +0000144 u16 crc;
Bhargav Shaha1afe252019-07-08 04:10:48 +0000145 u8 *buf = xbuf, r1;
146 int i, ret = 0;
147
Thomas Chou1254c3d2010-12-24 13:12:21 +0000148 while (bcnt--) {
Bhargav Shaha1afe252019-07-08 04:10:48 +0000149 for (i = 0; i < READ_TIMEOUT; i++) {
150 ret = dm_spi_xfer(dev, 1 * 8, NULL, &r1, 0);
151 if (ret)
152 return ret;
153 if (r1 == SPI_TOKEN_SINGLE)
Thomas Chou1254c3d2010-12-24 13:12:21 +0000154 break;
155 }
Bhargav Shaha1afe252019-07-08 04:10:48 +0000156 debug("%s: data tok%d 0x%x\n", __func__, i, r1);
Thomas Chou1254c3d2010-12-24 13:12:21 +0000157 if (r1 == SPI_TOKEN_SINGLE) {
Bhargav Shaha1afe252019-07-08 04:10:48 +0000158 ret = dm_spi_xfer(dev, bsize * 8, NULL, buf, 0);
159 if (ret)
160 return ret;
161 ret = dm_spi_xfer(dev, 2 * 8, NULL, &crc, 0);
162 if (ret)
163 return ret;
Thomas Chou1254c3d2010-12-24 13:12:21 +0000164#ifdef CONFIG_MMC_SPI_CRC_ON
Bhargav Shaha1afe252019-07-08 04:10:48 +0000165 if (be16_to_cpu(crc16_ccitt(0, buf, bsize)) != crc) {
166 debug("%s: data crc error\n", __func__);
Thomas Chou1254c3d2010-12-24 13:12:21 +0000167 r1 = R1_SPI_COM_CRC;
168 break;
169 }
170#endif
171 r1 = 0;
172 } else {
173 r1 = R1_SPI_ERROR;
174 break;
175 }
176 buf += bsize;
177 }
Bhargav Shaha1afe252019-07-08 04:10:48 +0000178
179 if (r1 & R1_SPI_COM_CRC)
180 ret = -ECOMM;
181 else if (r1) /* other errors */
182 ret = -ETIMEDOUT;
183
184 return ret;
Thomas Chou1254c3d2010-12-24 13:12:21 +0000185}
186
Bhargav Shaha1afe252019-07-08 04:10:48 +0000187static int mmc_spi_writedata(struct udevice *dev, const void *xbuf,
188 u32 bcnt, u32 bsize, int multi)
Thomas Chou1254c3d2010-12-24 13:12:21 +0000189{
Thomas Chou1254c3d2010-12-24 13:12:21 +0000190 const u8 *buf = xbuf;
Bhargav Shaha1afe252019-07-08 04:10:48 +0000191 u8 r1, tok[2];
Thomas Chou1254c3d2010-12-24 13:12:21 +0000192 u16 crc;
Bhargav Shaha1afe252019-07-08 04:10:48 +0000193 int i, ret = 0;
194
Thomas Chou1254c3d2010-12-24 13:12:21 +0000195 tok[0] = 0xff;
196 tok[1] = multi ? SPI_TOKEN_MULTI_WRITE : SPI_TOKEN_SINGLE;
Bhargav Shaha1afe252019-07-08 04:10:48 +0000197
Thomas Chou1254c3d2010-12-24 13:12:21 +0000198 while (bcnt--) {
199#ifdef CONFIG_MMC_SPI_CRC_ON
Stefan Roese084ff1e2016-03-03 09:34:12 +0100200 crc = cpu_to_be16(crc16_ccitt(0, (u8 *)buf, bsize));
Thomas Chou1254c3d2010-12-24 13:12:21 +0000201#endif
Bhargav Shaha1afe252019-07-08 04:10:48 +0000202 dm_spi_xfer(dev, 2 * 8, tok, NULL, 0);
203 dm_spi_xfer(dev, bsize * 8, buf, NULL, 0);
204 dm_spi_xfer(dev, 2 * 8, &crc, NULL, 0);
205 for (i = 0; i < CMD_TIMEOUT; i++) {
206 dm_spi_xfer(dev, 1 * 8, NULL, &r1, 0);
Thomas Chou1254c3d2010-12-24 13:12:21 +0000207 if ((r1 & 0x10) == 0) /* response token */
208 break;
209 }
Bhargav Shaha1afe252019-07-08 04:10:48 +0000210 debug("%s: data tok%d 0x%x\n", __func__, i, r1);
Thomas Chou1254c3d2010-12-24 13:12:21 +0000211 if (SPI_MMC_RESPONSE_CODE(r1) == SPI_RESPONSE_ACCEPTED) {
Bhargav Shaha1afe252019-07-08 04:10:48 +0000212 debug("%s: data accepted\n", __func__);
213 for (i = 0; i < WRITE_TIMEOUT; i++) { /* wait busy */
214 dm_spi_xfer(dev, 1 * 8, NULL, &r1, 0);
Thomas Chou1254c3d2010-12-24 13:12:21 +0000215 if (i && r1 == 0xff) {
216 r1 = 0;
217 break;
218 }
219 }
Bhargav Shaha1afe252019-07-08 04:10:48 +0000220 if (i == WRITE_TIMEOUT) {
221 debug("%s: data write timeout 0x%x\n",
222 __func__, r1);
Thomas Chou1254c3d2010-12-24 13:12:21 +0000223 r1 = R1_SPI_ERROR;
224 break;
225 }
226 } else {
Bhargav Shaha1afe252019-07-08 04:10:48 +0000227 debug("%s: data error 0x%x\n", __func__, r1);
Thomas Chou1254c3d2010-12-24 13:12:21 +0000228 r1 = R1_SPI_COM_CRC;
229 break;
230 }
231 buf += bsize;
232 }
233 if (multi && bcnt == -1) { /* stop multi write */
234 tok[1] = SPI_TOKEN_STOP_TRAN;
Bhargav Shaha1afe252019-07-08 04:10:48 +0000235 dm_spi_xfer(dev, 2 * 8, tok, NULL, 0);
236 for (i = 0; i < WRITE_TIMEOUT; i++) { /* wait busy */
237 dm_spi_xfer(dev, 1 * 8, NULL, &r1, 0);
Thomas Chou1254c3d2010-12-24 13:12:21 +0000238 if (i && r1 == 0xff) {
239 r1 = 0;
240 break;
241 }
242 }
Bhargav Shaha1afe252019-07-08 04:10:48 +0000243 if (i == WRITE_TIMEOUT) {
244 debug("%s: data write timeout 0x%x\n", __func__, r1);
Thomas Chou1254c3d2010-12-24 13:12:21 +0000245 r1 = R1_SPI_ERROR;
246 }
247 }
Thomas Chou1254c3d2010-12-24 13:12:21 +0000248
Bhargav Shaha1afe252019-07-08 04:10:48 +0000249 if (r1 & R1_SPI_COM_CRC)
Jaehoon Chung7825d202016-07-19 16:33:36 +0900250 ret = -ECOMM;
Bhargav Shaha1afe252019-07-08 04:10:48 +0000251 else if (r1) /* other errors */
Jaehoon Chung7825d202016-07-19 16:33:36 +0900252 ret = -ETIMEDOUT;
Bhargav Shaha1afe252019-07-08 04:10:48 +0000253
254 return ret;
255}
256
257static int dm_mmc_spi_set_ios(struct udevice *dev)
258{
259 return 0;
260}
261
262static int dm_mmc_spi_request(struct udevice *dev, struct mmc_cmd *cmd,
263 struct mmc_data *data)
264{
265 int i, multi, ret = 0;
266 u8 *resp = NULL;
267 u32 resp_size = 0;
268 bool resp_match = false;
269 u8 resp8 = 0, resp40[5] = { 0 }, resp_match_value = 0;
270
271 dm_spi_claim_bus(dev);
272
273 for (i = 0; i < 4; i++)
274 cmd->response[i] = 0;
275
276 switch (cmd->cmdidx) {
277 case SD_CMD_APP_SEND_OP_COND:
278 case MMC_CMD_SEND_OP_COND:
279 resp = &resp8;
280 resp_size = sizeof(resp8);
281 cmd->cmdarg = 0x40000000;
282 break;
283 case SD_CMD_SEND_IF_COND:
284 resp = (u8 *)&resp40[0];
285 resp_size = sizeof(resp40);
286 resp_match = true;
287 resp_match_value = R1_SPI_IDLE;
288 break;
289 case MMC_CMD_SPI_READ_OCR:
290 resp = (u8 *)&resp40[0];
291 resp_size = sizeof(resp40);
292 break;
293 case MMC_CMD_SEND_STATUS:
294 case MMC_CMD_SET_BLOCKLEN:
295 case MMC_CMD_SPI_CRC_ON_OFF:
296 case MMC_CMD_STOP_TRANSMISSION:
297 resp = &resp8;
298 resp_size = sizeof(resp8);
299 resp_match = true;
300 resp_match_value = 0x0;
301 break;
302 case MMC_CMD_SEND_CSD:
303 case MMC_CMD_SEND_CID:
304 case MMC_CMD_READ_SINGLE_BLOCK:
305 case MMC_CMD_READ_MULTIPLE_BLOCK:
306 case MMC_CMD_WRITE_SINGLE_BLOCK:
307 case MMC_CMD_WRITE_MULTIPLE_BLOCK:
Pragnesh Patela01f57e2020-06-29 15:17:26 +0530308 case MMC_CMD_APP_CMD:
Pragnesh Patel049dc5f2020-06-29 15:17:25 +0530309 resp = &resp8;
310 resp_size = sizeof(resp8);
Bhargav Shaha1afe252019-07-08 04:10:48 +0000311 break;
312 default:
313 resp = &resp8;
314 resp_size = sizeof(resp8);
315 resp_match = true;
316 resp_match_value = R1_SPI_IDLE;
317 break;
318 };
319
320 ret = mmc_spi_sendcmd(dev, cmd->cmdidx, cmd->cmdarg, cmd->resp_type,
321 resp, resp_size, resp_match, resp_match_value);
322 if (ret)
Thomas Chou1254c3d2010-12-24 13:12:21 +0000323 goto done;
Bhargav Shaha1afe252019-07-08 04:10:48 +0000324
325 switch (cmd->cmdidx) {
326 case SD_CMD_APP_SEND_OP_COND:
327 case MMC_CMD_SEND_OP_COND:
328 cmd->response[0] = (resp8 & R1_SPI_IDLE) ? 0 : OCR_BUSY;
329 break;
330 case SD_CMD_SEND_IF_COND:
331 case MMC_CMD_SPI_READ_OCR:
332 cmd->response[0] = resp40[4];
333 cmd->response[0] |= (uint)resp40[3] << 8;
334 cmd->response[0] |= (uint)resp40[2] << 16;
335 cmd->response[0] |= (uint)resp40[1] << 24;
336 break;
337 case MMC_CMD_SEND_STATUS:
338 cmd->response[0] = (resp8 & 0xff) ?
339 MMC_STATUS_ERROR : MMC_STATUS_RDY_FOR_DATA;
340 break;
341 case MMC_CMD_SEND_CID:
342 case MMC_CMD_SEND_CSD:
343 ret = mmc_spi_readdata(dev, cmd->response, 1, 16);
344 if (ret)
345 return ret;
Thomas Chou1254c3d2010-12-24 13:12:21 +0000346 for (i = 0; i < 4; i++)
Bhargav Shaha1afe252019-07-08 04:10:48 +0000347 cmd->response[i] =
348 cpu_to_be32(cmd->response[i]);
349 break;
350 default:
351 cmd->response[0] = resp8;
352 break;
353 }
354
355 debug("%s: cmd%d resp0=0x%x resp1=0x%x resp2=0x%x resp3=0x%x\n",
356 __func__, cmd->cmdidx, cmd->response[0], cmd->response[1],
357 cmd->response[2], cmd->response[3]);
358
359 if (data) {
360 debug("%s: data flags=0x%x blocks=%d block_size=%d\n",
361 __func__, data->flags, data->blocks, data->blocksize);
362 multi = (cmd->cmdidx == MMC_CMD_WRITE_MULTIPLE_BLOCK);
Thomas Chou1254c3d2010-12-24 13:12:21 +0000363 if (data->flags == MMC_DATA_READ)
Bhargav Shaha1afe252019-07-08 04:10:48 +0000364 ret = mmc_spi_readdata(dev, data->dest,
365 data->blocks, data->blocksize);
Thomas Chou1254c3d2010-12-24 13:12:21 +0000366 else if (data->flags == MMC_DATA_WRITE)
Bhargav Shaha1afe252019-07-08 04:10:48 +0000367 ret = mmc_spi_writedata(dev, data->src,
368 data->blocks, data->blocksize,
369 multi);
Thomas Chou1254c3d2010-12-24 13:12:21 +0000370 }
Bhargav Shaha1afe252019-07-08 04:10:48 +0000371
Thomas Chou1254c3d2010-12-24 13:12:21 +0000372done:
Anup Pateld2c68c02019-07-17 04:23:38 +0000373 dm_spi_xfer(dev, 0, NULL, NULL, SPI_XFER_END);
374
Bhargav Shaha1afe252019-07-08 04:10:48 +0000375 dm_spi_release_bus(dev);
376
Thomas Chou1254c3d2010-12-24 13:12:21 +0000377 return ret;
378}
379
Bhargav Shaha1afe252019-07-08 04:10:48 +0000380static int mmc_spi_probe(struct udevice *dev)
Thomas Chou1254c3d2010-12-24 13:12:21 +0000381{
Bhargav Shaha1afe252019-07-08 04:10:48 +0000382 struct mmc_spi_priv *priv = dev_get_priv(dev);
Bin Mengf7260322019-08-30 21:15:33 -0700383 struct mmc_spi_plat *plat = dev_get_platdata(dev);
Bhargav Shaha1afe252019-07-08 04:10:48 +0000384 struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev);
385 char *name;
386
387 priv->spi = dev_get_parent_priv(dev);
388 if (!priv->spi->max_hz)
389 priv->spi->max_hz = MMC_SPI_MAX_CLOCK;
390 priv->spi->speed = 0;
391 priv->spi->mode = SPI_MODE_0;
392 priv->spi->wordlen = 8;
Pantelis Antoniou2c850462014-03-11 19:34:20 +0200393
Bhargav Shaha1afe252019-07-08 04:10:48 +0000394 name = malloc(strlen(dev->parent->name) + strlen(dev->name) + 4);
395 if (!name)
396 return -ENOMEM;
397 sprintf(name, "%s:%s", dev->parent->name, dev->name);
398
Bin Mengf7260322019-08-30 21:15:33 -0700399 plat->cfg.name = name;
400 plat->cfg.host_caps = MMC_MODE_SPI;
401 plat->cfg.voltages = MMC_SPI_VOLTAGE;
402 plat->cfg.f_min = MMC_SPI_MIN_CLOCK;
403 plat->cfg.f_max = priv->spi->max_hz;
404 plat->cfg.part_type = PART_TYPE_DOS;
405 plat->cfg.b_max = CONFIG_SYS_MMC_MAX_BLK_COUNT;
Bhargav Shaha1afe252019-07-08 04:10:48 +0000406
Bin Mengf7260322019-08-30 21:15:33 -0700407 plat->mmc.cfg = &plat->cfg;
408 plat->mmc.priv = priv;
409 plat->mmc.dev = dev;
Bhargav Shaha1afe252019-07-08 04:10:48 +0000410
Bin Mengf7260322019-08-30 21:15:33 -0700411 upriv->mmc = &plat->mmc;
Bhargav Shaha1afe252019-07-08 04:10:48 +0000412
Jaehoon Chungb6cd1d32016-12-30 15:30:16 +0900413 return 0;
Thomas Chou1254c3d2010-12-24 13:12:21 +0000414}
415
Bhargav Shaha1afe252019-07-08 04:10:48 +0000416static int mmc_spi_bind(struct udevice *dev)
Thomas Chou1254c3d2010-12-24 13:12:21 +0000417{
Bin Mengf7260322019-08-30 21:15:33 -0700418 struct mmc_spi_plat *plat = dev_get_platdata(dev);
Bhargav Shaha1afe252019-07-08 04:10:48 +0000419
Bin Mengf7260322019-08-30 21:15:33 -0700420 return mmc_bind(dev, &plat->mmc, &plat->cfg);
Thomas Chou1254c3d2010-12-24 13:12:21 +0000421}
422
Bhargav Shaha1afe252019-07-08 04:10:48 +0000423static const struct dm_mmc_ops mmc_spi_ops = {
424 .send_cmd = dm_mmc_spi_request,
425 .set_ios = dm_mmc_spi_set_ios,
Pantelis Antoniouc9e75912014-02-26 19:28:45 +0200426};
427
Bhargav Shaha1afe252019-07-08 04:10:48 +0000428static const struct udevice_id dm_mmc_spi_match[] = {
429 { .compatible = "mmc-spi-slot" },
430 { /* sentinel */ }
Pantelis Antoniou2c850462014-03-11 19:34:20 +0200431};
432
Bhargav Shaha1afe252019-07-08 04:10:48 +0000433U_BOOT_DRIVER(mmc_spi) = {
434 .name = "mmc_spi",
435 .id = UCLASS_MMC,
436 .of_match = dm_mmc_spi_match,
437 .ops = &mmc_spi_ops,
438 .probe = mmc_spi_probe,
439 .bind = mmc_spi_bind,
Bin Mengf7260322019-08-30 21:15:33 -0700440 .platdata_auto_alloc_size = sizeof(struct mmc_spi_plat),
Bhargav Shaha1afe252019-07-08 04:10:48 +0000441 .priv_auto_alloc_size = sizeof(struct mmc_spi_priv),
442};