coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
msdc.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3  * MTK MSDC Host Controller interface specific code
4  */
5 #include <assert.h>
6 #include <cbmem.h>
9 #include <console/console.h>
10 #include <delay.h>
11 #include <device/mmio.h>
12 #include <lib.h>
13 #include <soc/msdc.h>
14 #include <string.h>
15 #include <timer.h>
16 
17 static inline void msdc_set_field(void *reg, u32 field, u32 val)
18 {
19  clrsetbits32(reg, field, val << __ffs(field));
20 }
21 
22 /*
23  * Periodically poll an address until a condition is met or a timeout occurs
24  * @addr: Address to poll
25  * @mask: mask condition
26  * @timeout: Timeout in us, 0 means never timeout
27  *
28  * Returns 0 on success and -MSDC_NOT_READY upon a timeout.
29  */
30 static int msdc_poll_timeout(void *addr, u32 mask)
31 {
32  struct stopwatch timer;
34  u32 reg;
35 
36  do {
37  reg = read32(addr);
38  if (stopwatch_expired(&timer))
39  return -MSDC_NOT_READY;
40  udelay(1);
41  } while (reg & mask);
42 
43  return MSDC_SUCCESS;
44 }
45 
46 /*
47  * Wait for a bit mask in a given register. To avoid endless loops, a
48  * time-out is implemented here.
49  */
50 static int msdc_wait_done(void *addr, u32 mask, u32 *status)
51 {
52  struct stopwatch timer;
54  u32 reg;
55 
56  do {
57  reg = read32(addr);
58  if (stopwatch_expired(&timer)) {
59  if (status)
60  *status = reg;
61  return -MSDC_NOT_READY;
62  }
63  udelay(1);
64  } while (!(reg & mask));
65 
66  if (status)
67  *status = reg;
68 
69  return MSDC_SUCCESS;
70 }
71 
72 static void msdc_reset_hw(struct msdc_ctrlr *host)
73 {
74  u32 val;
75 
78  msdc_error("Softwave reset timeout!\n");
79 
82  msdc_error("Clear FIFO timeout!\n");
83 
84  val = read32(host->base + MSDC_INT);
85  write32(host->base + MSDC_INT, val);
86 }
87 
88 static void msdc_init_hw(struct msdc_ctrlr *host)
89 {
90  /* Configure to MMC/SD mode */
92 
93  /* Reset */
94  msdc_reset_hw(host);
95 
96  /* Set PIO mode */
98 
99  write32(host->top_base + EMMC_TOP_CONTROL, 0);
100  write32(host->top_base + EMMC_TOP_CMD, 0);
101 
102  write32(host->base + MSDC_IOCON, 0);
104  write32(host->base + MSDC_PATCH_BIT, 0x403c0046);
106  write32(host->base + MSDC_PATCH_BIT1, 0xffff4089);
108 
113 
114  clrbits32(host->base + MSDC_PATCH_BIT1, (1 << 7));
115 
117  if (host->top_base)
119  else
121  /* Use async fifo, then no need to tune internal delay */
124 
125  if (host->top_base) {
130  } else {
131  setbits32(host->base + MSDC_PAD_TUNE,
133  }
134 
135  /* Configure to enable SDIO mode. Otherwise, sdio cmd5 will fail. */
137 
138  /* Config SDIO device detect interrupt function */
141 
142  /* Configure to default data timeout */
144 
145  msdc_debug("init hardware done!\n");
146 }
147 
148 static void msdc_fifo_clr(struct msdc_ctrlr *host)
149 {
151 
153  msdc_error("Clear FIFO timeout!\n");
154 }
155 
156 static u32 msdc_cmd_find_resp(struct msdc_ctrlr *host, struct mmc_command *cmd)
157 {
158  switch (cmd->resp_type) {
159  case CARD_RSP_R1:
160  return 0x1;
161  case CARD_RSP_R1b:
162  return 0x7;
163  case CARD_RSP_R2:
164  return 0x2;
165  case CARD_RSP_R3:
166  return 0x3;
167  case CARD_RSP_NONE:
168  default:
169  return 0x0;
170  }
171 }
172 
173 static bool msdc_cmd_is_ready(struct msdc_ctrlr *host)
174 {
175  int ret;
176 
178  if (ret != MSDC_SUCCESS) {
179  msdc_error("CMD bus busy detected, SDC_STS: %#x\n",
180  read32(host->base + SDC_STS));
181  msdc_reset_hw(host);
182  return false;
183  }
184 
186  if (ret != MSDC_SUCCESS) {
187  msdc_error("SD controller busy detected, SDC_STS: %#x\n",
188  read32(host->base + SDC_STS));
189  msdc_reset_hw(host);
190  return false;
191  }
192 
193  return true;
194 }
195 
197  struct mmc_command *cmd,
198  struct mmc_data *data)
199 {
200  u32 opcode = cmd->cmdidx;
201  u32 resp_type = msdc_cmd_find_resp(host, cmd);
202  u32 blocksize = 0;
203  u32 dtype = 0;
204  u32 rawcmd = 0;
205 
206  switch (opcode) {
209  dtype = 2;
210  break;
214  dtype = 1;
215  break;
216  case MMC_CMD_SEND_STATUS:
217  if (data)
218  dtype = 1;
219  }
220 
221  if (data) {
222  if (data->flags == DATA_FLAG_READ)
223  rawcmd |= SDC_CMD_WR;
224 
225  if (data->blocks > 1)
226  dtype = 2;
227 
228  blocksize = data->blocksize;
229  }
230 
231  rawcmd |= (opcode << SDC_CMD_CMD_S) & SDC_CMD_CMD_M;
232  rawcmd |= (resp_type << SDC_CMD_RSPTYP_S) & SDC_CMD_RSPTYP_M;
233  rawcmd |= (blocksize << SDC_CMD_BLK_LEN_S) & SDC_CMD_BLK_LEN_M;
234  rawcmd |= (dtype << SDC_CMD_DTYPE_S) & SDC_CMD_DTYPE_M;
235 
236  if (opcode == MMC_CMD_STOP_TRANSMISSION)
237  rawcmd |= SDC_CMD_STOP;
238 
239  return rawcmd;
240 }
241 
242 static int msdc_cmd_done(struct msdc_ctrlr *host, int events,
243  struct mmc_command *cmd)
244 {
245  u32 *rsp = cmd->response;
246  int ret = 0;
247 
248  if (cmd->resp_type & CARD_RSP_PRESENT) {
249  if (cmd->resp_type & CARD_RSP_136) {
250  rsp[0] = read32(host->base + SDC_RESP3);
251  rsp[1] = read32(host->base + SDC_RESP2);
252  rsp[2] = read32(host->base + SDC_RESP1);
253  rsp[3] = read32(host->base + SDC_RESP0);
254  } else {
255  rsp[0] = read32(host->base + SDC_RESP0);
256  }
257  }
258 
259  if (!(events & MSDC_INT_CMDRDY)) {
260  if (cmd->cmdidx != MMC_CMD_AUTO_TUNING_SEQUENCE) {
261  /*
262  * should not clear fifo/interrupt as the tune data
263  * may have already come.
264  */
265  msdc_reset_hw(host);
266  }
267  if (events & MSDC_INT_CMDTMO)
268  ret = -ETIMEDOUT;
269  else
270  ret = -EIO;
271  }
272 
273  return ret;
274 }
275 
276 static int msdc_start_command(struct msdc_ctrlr *host, struct mmc_command *cmd,
277  struct mmc_data *data)
278 {
279  u32 rawcmd, status;
280  u32 blocks = 0;
281  int ret;
282 
283  if (!msdc_cmd_is_ready(host))
284  return -EIO;
285 
286  if (read32(host->base + MSDC_FIFOCS) &
288  msdc_error("TX/RX FIFO non-empty before start of IO. Reset\n");
289  msdc_reset_hw(host);
290  }
291 
292  msdc_fifo_clr(host);
293 
294  rawcmd = msdc_cmd_prepare_raw_cmd(host, cmd, data);
295 
296  if (data)
297  blocks = data->blocks;
298 
300  write32(host->base + SDC_BLK_NUM, blocks);
301  write32(host->base + SDC_ARG, cmd->cmdarg);
302  write32(host->base + SDC_CMD, rawcmd);
303 
304  ret = msdc_wait_done(host->base + MSDC_INT, CMD_INTS_MASK, &status);
305  if (ret != MSDC_SUCCESS)
306  status = MSDC_INT_CMDTMO;
307 
308  return msdc_cmd_done(host, status, cmd);
309 }
310 
311 static int msdc_send_command(struct sd_mmc_ctrlr *ctrlr,
312  struct mmc_command *cmd, struct mmc_data *data)
313 {
314  struct msdc_ctrlr *host;
315 
316  host = container_of(ctrlr, struct msdc_ctrlr, sd_mmc_ctrlr);
317 
318  return msdc_start_command(host, cmd, data);
319 }
320 
321 static void msdc_set_clock(struct msdc_ctrlr *host, u32 clock)
322 {
323  u32 mode, mode_shift;
324  u32 div, div_mask;
325  const u32 div_width = 12;
326  u32 sclk;
327  u32 hclk = host->src_hz;
328  struct sd_mmc_ctrlr *ctrlr = &host->sd_mmc_ctrlr;
329 
330  if (clock >= hclk) {
331  mode = 0x1; /* no divisor */
332  div = 0;
333  sclk = hclk;
334  } else {
335  mode = 0x0; /* use divisor */
336  if (clock >= (hclk / 2)) {
337  div = 0; /* mean div = 1/2 */
338  sclk = hclk / 2; /* sclk = clk / 2 */
339  } else {
340  div = DIV_ROUND_UP(hclk, clock * 4);
341  sclk = (hclk >> 2) / div;
342  }
343  }
344 
345  div_mask = (1 << div_width) - 1;
346  mode_shift = 8 + div_width;
347  assert(div <= div_mask);
348 
349  clrsetbits_le32(host->base + MSDC_CFG, (0x3 << mode_shift) | (div_mask << 8),
350  (mode << mode_shift) | (div << 8));
352  msdc_error("Failed while wait clock stable!\n");
353 
354  ctrlr->bus_hz = sclk;
355  msdc_debug("sclk: %d\n", sclk);
356 }
357 
358 static void msdc_set_buswidth(struct msdc_ctrlr *host, u32 width)
359 {
360  u32 val = read32(host->base + SDC_CFG);
361 
362  val &= ~SDC_CFG_BUSWIDTH;
363 
364  switch (width) {
365  default:
366  case 1:
367  val |= (MSDC_BUS_1BITS << 16);
368  break;
369  case 4:
370  val |= (MSDC_BUS_4BITS << 16);
371  break;
372  case 8:
373  val |= (MSDC_BUS_8BITS << 16);
374  break;
375  }
376 
377  write32(host->base + SDC_CFG, val);
378  msdc_trace("Bus Width = %d\n", width);
379 }
380 
381 static void msdc_set_ios(struct sd_mmc_ctrlr *ctrlr)
382 {
383  struct msdc_ctrlr *host;
384 
385  host = container_of(ctrlr, struct msdc_ctrlr, sd_mmc_ctrlr);
386 
387  /* Set the clock frequency */
388  if (ctrlr->bus_hz != ctrlr->request_hz)
389  msdc_set_clock(host, ctrlr->request_hz);
390 
391  msdc_set_buswidth(host, ctrlr->bus_width);
392 
393 }
394 
395 static void msdc_update_pointers(struct msdc_ctrlr *host)
396 {
397  struct sd_mmc_ctrlr *ctrlr = &host->sd_mmc_ctrlr;
398 
399  /* Update the routine pointers */
400  ctrlr->send_cmd = &msdc_send_command;
401  ctrlr->set_ios = &msdc_set_ios;
402 
403  ctrlr->f_min = 400 * 1000;
404  ctrlr->f_max = 52 * 1000 * 1000;
405  ctrlr->bus_width = 1;
406  ctrlr->caps |= DRVR_CAP_HS | DRVR_CAP_HC;
407  ctrlr->voltages = 0x40ff8080;
408 }
409 
410 static void add_msdc(struct msdc_ctrlr *host)
411 {
412  struct sd_mmc_ctrlr *ctrlr = &host->sd_mmc_ctrlr;
413 
414  msdc_update_pointers(host);
415 
416  /* Initialize the MTK MSDC controller */
417  msdc_init_hw(host);
418 
419  /* Display the results */
420  msdc_trace("%#010x: ctrlr->caps\n", ctrlr->caps);
421  msdc_trace("%d.%03d MHz: ctrlr->f_max\n",
422  ctrlr->f_max / 1000000,
423  (ctrlr->f_max / 1000) % 1000);
424  msdc_trace("%d.%03d MHz: ctrlr->f_min\n",
425  ctrlr->f_min / 1000000,
426  (ctrlr->f_min / 1000) % 1000);
427  msdc_trace("%#010x: ctrlr->voltages\n", ctrlr->voltages);
428 }
429 
430 static void msdc_controller_init(struct msdc_ctrlr *host, void *base, void *top_base)
431 {
432  memset(host, 0, sizeof(*host));
433  host->base = base;
434  host->top_base = top_base;
435  host->src_hz = 50 * 1000 * 1000;
436 
437  add_msdc(host);
438 }
439 
441 {
442  int32_t *ms_cbmem;
443 
444  ms_cbmem = cbmem_add(CBMEM_ID_MMC_STATUS, sizeof(status));
445 
446  if (ms_cbmem == NULL) {
448  "%s: Failed to add early mmc wake status to cbmem!\n",
449  __func__);
450  return;
451  }
452 
453  printk(BIOS_DEBUG, "Early init status = %d\n", status);
454  *ms_cbmem = status;
455 }
456 
457 int mtk_emmc_early_init(void *base, void *top_base)
458 {
459  struct storage_media media = { 0 };
460  int err;
461  struct msdc_ctrlr msdc_host;
462  struct sd_mmc_ctrlr *mmc_ctrlr = &msdc_host.sd_mmc_ctrlr;
463 
464  /* Init mtk mmc ctrlr */
465  msdc_controller_init(&msdc_host, base, top_base);
466 
467  media.ctrlr = mmc_ctrlr;
468  SET_CLOCK(mmc_ctrlr, 400 * 1000);
469  SET_BUS_WIDTH(mmc_ctrlr, 1);
470 
471  /* Reset emmc, send CMD0 */
472  if (sd_mmc_go_idle(&media))
473  goto out_err;
474 
475  /* Send CMD1 */
476  err = mmc_send_op_cond(&media);
477  if (err == 0)
479  else if (err == CARD_IN_PROGRESS)
481  else
482  goto out_err;
483 
484  return 0;
485 
486 out_err:
488  return -1;
489 }
static void write32(void *addr, uint32_t val)
Definition: mmio.h:40
static uint32_t read32(const void *addr)
Definition: mmio.h:22
void * memset(void *dstpp, int c, size_t len)
Definition: memset.c:12
#define assert(statement)
Definition: assert.h:74
static int width
Definition: bochs.c:42
#define DIV_ROUND_UP(x, y)
Definition: helpers.h:60
void * cbmem_add(u32 id, u64 size)
Definition: imd_cbmem.c:144
#define CBMEM_ID_MMC_STATUS
Definition: cbmem_id.h:35
static u32 addr
Definition: cirrus.c:14
static int msdc_wait_done(void *addr, u32 mask, u32 *status)
Definition: msdc.c:50
static void msdc_fifo_clr(struct msdc_ctrlr *host)
Definition: msdc.c:148
int mtk_emmc_early_init(void *base, void *top_base)
Definition: msdc.c:457
static int msdc_send_command(struct sd_mmc_ctrlr *ctrlr, struct mmc_command *cmd, struct mmc_data *data)
Definition: msdc.c:311
static void msdc_set_ios(struct sd_mmc_ctrlr *ctrlr)
Definition: msdc.c:381
static void msdc_update_pointers(struct msdc_ctrlr *host)
Definition: msdc.c:395
static int msdc_poll_timeout(void *addr, u32 mask)
Definition: msdc.c:30
static void msdc_set_buswidth(struct msdc_ctrlr *host, u32 width)
Definition: msdc.c:358
static bool msdc_cmd_is_ready(struct msdc_ctrlr *host)
Definition: msdc.c:173
static void msdc_init_hw(struct msdc_ctrlr *host)
Definition: msdc.c:88
static u32 msdc_cmd_prepare_raw_cmd(struct msdc_ctrlr *host, struct mmc_command *cmd, struct mmc_data *data)
Definition: msdc.c:196
static int msdc_start_command(struct msdc_ctrlr *host, struct mmc_command *cmd, struct mmc_data *data)
Definition: msdc.c:276
static int msdc_cmd_done(struct msdc_ctrlr *host, int events, struct mmc_command *cmd)
Definition: msdc.c:242
static void msdc_reset_hw(struct msdc_ctrlr *host)
Definition: msdc.c:72
static void add_msdc(struct msdc_ctrlr *host)
Definition: msdc.c:410
static void set_early_mmc_wake_status(int32_t status)
Definition: msdc.c:440
static void msdc_set_field(void *reg, u32 field, u32 val)
Definition: msdc.c:17
static void msdc_controller_init(struct msdc_ctrlr *host, void *base, void *top_base)
Definition: msdc.c:430
static void msdc_set_clock(struct msdc_ctrlr *host, u32 clock)
Definition: msdc.c:321
static u32 msdc_cmd_find_resp(struct msdc_ctrlr *host, struct mmc_command *cmd)
Definition: msdc.c:156
#define printk(level,...)
Definition: stdlib.h:16
int mmc_send_op_cond(struct storage_media *media)
Definition: mmc.c:45
#define EIO
Definition: errno.h:10
#define container_of(ptr, type, member)
container_of - cast a member of a structure out to the containing structure
Definition: helpers.h:33
#define setbits32(addr, set)
Definition: mmio.h:21
#define clrsetbits32(addr, clear, set)
Definition: mmio.h:16
#define clrbits32(addr, clear)
Definition: mmio.h:26
#define clrsetbits_le32(addr, clear, set)
Definition: endian.h:65
static int stopwatch_expired(struct stopwatch *sw)
Definition: timer.h:152
static void stopwatch_init_usecs_expire(struct stopwatch *sw, long us)
Definition: timer.h:127
#define ETIMEDOUT
Definition: kempld_i2c.c:48
static int __ffs(u32 x)
Definition: lib.h:55
#define BIOS_DEBUG
BIOS_DEBUG - Verbose output.
Definition: loglevel.h:128
#define BIOS_ERR
BIOS_ERR - System in incomplete state.
Definition: loglevel.h:72
#define SDC_CMD_WR
Definition: msdc.h:93
#define SDC_RESP3
Definition: msdc.h:27
#define MSDC_PATCH_BIT
Definition: msdc.h:36
#define MSDC_FIFOCS
Definition: msdc.h:17
#define msdc_debug(format...)
Definition: msdc.h:164
#define SDC_CFG_SDIOIDE
Definition: msdc.h:83
#define MSDC_CFG_PIO
Definition: msdc.h:64
#define MSDC_PB2_RESPWAIT
Definition: msdc.h:115
#define SDC_RX_ENH_EN
Definition: msdc.h:131
#define EMMC50_CFG0
Definition: msdc.h:44
#define SDC_FIFO_CFG_WRVALIDSEL
Definition: msdc.h:125
#define MSDC_IOCON_DDLSEL
Definition: msdc.h:68
#define MSDC_PAD_TUNE
Definition: msdc.h:39
#define SDC_STS
Definition: msdc.h:23
#define SDC_CMD_BLK_LEN_S
Definition: msdc.h:95
#define MSDC_INT
Definition: msdc.h:15
#define SDC_RESP0
Definition: msdc.h:24
#define msdc_error(format...)
Definition: msdc.h:166
#define msdc_trace(format...)
Definition: msdc.h:165
#define SDC_CMD_CMD_S
Definition: msdc.h:87
#define MSDC_TIMEOUT_US
Definition: msdc.h:137
#define SDC_STS_CMDBUSY
Definition: msdc.h:100
#define MSDC_BUS_4BITS
Definition: msdc.h:141
#define CMD_TIMEOUT_MS
Definition: msdc.h:136
#define SDC_CMD
Definition: msdc.h:21
#define MSDC_BUS_8BITS
Definition: msdc.h:142
#define MSDC_CFG_CKSTB
Definition: msdc.h:65
#define SDC_FIFO_CFG
Definition: msdc.h:47
#define MSDC_PATCH_BIT2
Definition: msdc.h:38
#define MSDC_SUCCESS
Definition: msdc.h:144
#define SDC_BLK_NUM
Definition: msdc.h:28
#define MSDC_PATCH_BIT1
Definition: msdc.h:37
#define SDC_CMD_BLK_LEN_M
Definition: msdc.h:96
#define MSDC_PATCH_BIT1_STOP_DLY
Definition: msdc.h:110
#define MSDC_BUS_1BITS
Definition: msdc.h:140
#define MSDC_FIFOCS_CLR
Definition: msdc.h:78
#define MSDC_NOT_READY
Definition: msdc.h:145
#define MSDC_IOCON
Definition: msdc.h:13
#define SDC_STS_SDCBUSY
Definition: msdc.h:99
#define MSDC_INT_CMDTMO
Definition: msdc.h:72
#define SDC_DAT1_IRQ_TRIGGER
Definition: msdc.h:103
#define PAD_DAT_RD_RXDLY_SEL
Definition: msdc.h:129
#define EMMC_TOP_CMD
Definition: msdc.h:53
#define SDC_ARG
Definition: msdc.h:22
#define PAD_CMD_RD_RXDLY_SEL
Definition: msdc.h:134
#define SDC_CFG_BUSWIDTH
Definition: msdc.h:81
#define MSDC_PATCH_BIT2_CFGRESP
Definition: msdc.h:113
#define SDC_FIFO_CFG_RDVALIDSEL
Definition: msdc.h:126
#define SDC_CFG_SDIO
Definition: msdc.h:82
#define SDC_CMD_DTYPE_M
Definition: msdc.h:92
#define SDC_CMD_CMD_M
Definition: msdc.h:88
#define DATA_K_VALUE_SEL
Definition: msdc.h:130
#define MSDC_CKGEN_MSDC_DLY_SEL
Definition: msdc.h:107
#define MSDC_INT_CMDRDY
Definition: msdc.h:71
#define SDC_CMD_STOP
Definition: msdc.h:94
#define MSDC_CFG_RST
Definition: msdc.h:63
#define SDC_CMD_RSPTYP_S
Definition: msdc.h:89
#define MSDC_PATCH_BIT2_CFGCRCSTS
Definition: msdc.h:114
#define MSDC_CFG
Definition: msdc.h:12
#define MSDC_FIFOCS_RXCNT
Definition: msdc.h:76
#define SDC_CMD_DTYPE_S
Definition: msdc.h:91
#define SDC_RESP2
Definition: msdc.h:26
#define CMD_INTS_MASK
Definition: msdc.h:150
#define SDC_RESP1
Definition: msdc.h:25
#define MSDC_PAD_TUNE_RD_SEL
Definition: msdc.h:118
#define EMMC_TOP_CONTROL
Definition: msdc.h:52
#define MSDC_PAD_TUNE_CMD_SEL
Definition: msdc.h:119
#define MSDC_CFG_MODE
Definition: msdc.h:61
#define SDC_RX_ENHANCE_EN
Definition: msdc.h:104
#define EMMC50_CFG_CFCSTS_SEL
Definition: msdc.h:122
#define SDC_CFG_DTOC
Definition: msdc.h:84
#define SDC_CFG
Definition: msdc.h:20
#define MSDC_FIFOCS_TXCNT
Definition: msdc.h:77
#define SDC_CMD_RSPTYP_M
Definition: msdc.h:90
#define SDC_ADV_CFG0
Definition: msdc.h:29
static struct storage_media media
Definition: sd_media.c:21
int sd_mmc_go_idle(struct storage_media *media)
Definition: sd_mmc.c:68
#define SET_BUS_WIDTH(ctrlr, width)
Definition: sd_mmc.h:15
#define SET_CLOCK(ctrlr, clock_hz)
Definition: sd_mmc.h:21
#define MMC_CMD_WRITE_MULTIPLE_BLOCK
Definition: sd_mmc_ctrlr.h:41
#define CARD_RSP_136
Definition: sd_mmc_ctrlr.h:70
#define CARD_RSP_NONE
Definition: sd_mmc_ctrlr.h:75
#define DATA_FLAG_READ
Definition: sd_mmc_ctrlr.h:113
#define CARD_RSP_R1
Definition: sd_mmc_ctrlr.h:76
#define CARD_RSP_R2
Definition: sd_mmc_ctrlr.h:79
#define MMC_CMD_SEND_STATUS
Definition: sd_mmc_ctrlr.h:36
#define CARD_RSP_R3
Definition: sd_mmc_ctrlr.h:80
#define CARD_IN_PROGRESS
Definition: sd_mmc_ctrlr.h:14
#define CARD_RSP_PRESENT
Definition: sd_mmc_ctrlr.h:69
#define MMC_CMD_READ_SINGLE_BLOCK
Definition: sd_mmc_ctrlr.h:38
#define MMC_CMD_READ_MULTIPLE_BLOCK
Definition: sd_mmc_ctrlr.h:39
#define MMC_CMD_AUTO_TUNING_SEQUENCE
Definition: sd_mmc_ctrlr.h:48
#define MMC_CMD_STOP_TRANSMISSION
Definition: sd_mmc_ctrlr.h:35
#define DRVR_CAP_HS
Definition: sd_mmc_ctrlr.h:176
#define MMC_CMD_WRITE_SINGLE_BLOCK
Definition: sd_mmc_ctrlr.h:40
@ MMC_STATUS_CMD1_READY
Definition: sd_mmc_ctrlr.h:20
@ MMC_STATUS_CMD1_IN_PROGRESS
Definition: sd_mmc_ctrlr.h:21
@ MMC_STATUS_NEED_RESET
Definition: sd_mmc_ctrlr.h:18
#define CARD_RSP_R1b
Definition: sd_mmc_ctrlr.h:77
#define DRVR_CAP_HC
Definition: sd_mmc_ctrlr.h:175
uintptr_t base
Definition: uart.c:17
static const int mask[4]
Definition: gpio.c:308
#define NULL
Definition: stddef.h:19
uint32_t u32
Definition: stdint.h:51
signed int int32_t
Definition: stdint.h:13
uint32_t response[4]
Definition: sd_mmc_ctrlr.h:91
uint32_t cmdarg
Definition: sd_mmc_ctrlr.h:86
uint16_t cmdidx
Definition: sd_mmc_ctrlr.h:25
uint32_t resp_type
Definition: sd_mmc_ctrlr.h:67
uint32_t blocksize
Definition: sd_mmc_ctrlr.h:117
uint32_t flags
Definition: sd_mmc_ctrlr.h:111
uint32_t blocks
Definition: sd_mmc_ctrlr.h:116
uint32_t src_hz
Definition: msdc.h:159
void * top_base
Definition: msdc.h:156
uint32_t clock
Definition: msdc.h:158
struct sd_mmc_ctrlr sd_mmc_ctrlr
Definition: msdc.h:154
void * base
Definition: msdc.h:155
uint32_t f_min
Definition: sd_mmc_ctrlr.h:152
uint32_t f_max
Definition: sd_mmc_ctrlr.h:153
uint32_t voltages
Definition: sd_mmc_ctrlr.h:129
uint32_t bus_width
Definition: sd_mmc_ctrlr.h:166
uint32_t bus_hz
Definition: sd_mmc_ctrlr.h:155
uint32_t caps
Definition: sd_mmc_ctrlr.h:167
int(* send_cmd)(struct sd_mmc_ctrlr *ctrlr, struct mmc_command *cmd, struct mmc_data *data)
Definition: sd_mmc_ctrlr.h:121
uint32_t request_hz
Definition: sd_mmc_ctrlr.h:154
void(* set_ios)(struct sd_mmc_ctrlr *ctrlr)
Definition: sd_mmc_ctrlr.h:123
struct sd_mmc_ctrlr * ctrlr
Definition: storage.h:63
u8 val
Definition: sys.c:300
void udelay(uint32_t us)
Definition: udelay.c:15