1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2016 Socionext Inc.
4 * Author: Masahiro Yamada <yamada.masahiro@socionext.com>
13 #include <dm/device_compat.h>
14 #include <dm/pinctrl.h>
15 #include <linux/compat.h>
16 #include <linux/dma-mapping.h>
18 #include <linux/sizes.h>
19 #include <power/regulator.h>
20 #include <asm/unaligned.h>
22 #include "tmio-common.h"
24 DECLARE_GLOBAL_DATA_PTR;
26 static u64 tmio_sd_readq(struct tmio_sd_priv *priv, unsigned int reg)
28 return readq(priv->regbase + (reg << 1));
31 static void tmio_sd_writeq(struct tmio_sd_priv *priv,
32 u64 val, unsigned int reg)
34 writeq(val, priv->regbase + (reg << 1));
37 static u16 tmio_sd_readw(struct tmio_sd_priv *priv, unsigned int reg)
39 return readw(priv->regbase + (reg >> 1));
42 static void tmio_sd_writew(struct tmio_sd_priv *priv,
43 u16 val, unsigned int reg)
45 writew(val, priv->regbase + (reg >> 1));
48 u32 tmio_sd_readl(struct tmio_sd_priv *priv, unsigned int reg)
52 if (priv->caps & TMIO_SD_CAP_64BIT)
53 return readl(priv->regbase + (reg << 1));
54 else if (priv->caps & TMIO_SD_CAP_16BIT) {
55 val = readw(priv->regbase + (reg >> 1)) & 0xffff;
56 if ((reg == TMIO_SD_RSP10) || (reg == TMIO_SD_RSP32) ||
57 (reg == TMIO_SD_RSP54) || (reg == TMIO_SD_RSP76)) {
58 val |= readw(priv->regbase + (reg >> 1) + 2) << 16;
62 return readl(priv->regbase + reg);
65 void tmio_sd_writel(struct tmio_sd_priv *priv,
66 u32 val, unsigned int reg)
68 if (priv->caps & TMIO_SD_CAP_64BIT)
69 writel(val, priv->regbase + (reg << 1));
70 else if (priv->caps & TMIO_SD_CAP_16BIT) {
71 writew(val & 0xffff, priv->regbase + (reg >> 1));
72 if (reg == TMIO_SD_INFO1 || reg == TMIO_SD_INFO1_MASK ||
73 reg == TMIO_SD_INFO2 || reg == TMIO_SD_INFO2_MASK ||
75 writew(val >> 16, priv->regbase + (reg >> 1) + 2);
77 writel(val, priv->regbase + reg);
80 static int tmio_sd_check_error(struct udevice *dev, struct mmc_cmd *cmd)
82 struct tmio_sd_priv *priv = dev_get_priv(dev);
83 u32 info2 = tmio_sd_readl(priv, TMIO_SD_INFO2);
85 if (info2 & TMIO_SD_INFO2_ERR_RTO) {
87 * TIMEOUT must be returned for unsupported command. Do not
88 * display error log since this might be a part of sequence to
89 * distinguish between SD and MMC.
94 if (info2 & TMIO_SD_INFO2_ERR_TO) {
95 dev_err(dev, "timeout error\n");
99 if (info2 & (TMIO_SD_INFO2_ERR_END | TMIO_SD_INFO2_ERR_CRC |
100 TMIO_SD_INFO2_ERR_IDX)) {
101 if ((cmd->cmdidx != MMC_CMD_SEND_TUNING_BLOCK) &&
102 (cmd->cmdidx != MMC_CMD_SEND_TUNING_BLOCK_HS200))
103 dev_err(dev, "communication out of sync\n");
107 if (info2 & (TMIO_SD_INFO2_ERR_ILA | TMIO_SD_INFO2_ERR_ILR |
108 TMIO_SD_INFO2_ERR_ILW)) {
109 dev_err(dev, "illegal access\n");
116 static int tmio_sd_wait_for_irq(struct udevice *dev, struct mmc_cmd *cmd,
117 unsigned int reg, u32 flag)
119 struct tmio_sd_priv *priv = dev_get_priv(dev);
123 while (!(tmio_sd_readl(priv, reg) & flag)) {
125 dev_err(dev, "timeout\n");
129 ret = tmio_sd_check_error(dev, cmd);
139 #define tmio_pio_read_fifo(__width, __suffix) \
140 static void tmio_pio_read_fifo_##__width(struct tmio_sd_priv *priv, \
141 char *pbuf, uint blksz) \
143 u##__width *buf = (u##__width *)pbuf; \
146 if (likely(IS_ALIGNED((uintptr_t)buf, ((__width) / 8)))) { \
147 for (i = 0; i < blksz / ((__width) / 8); i++) { \
148 *buf++ = tmio_sd_read##__suffix(priv, \
152 for (i = 0; i < blksz / ((__width) / 8); i++) { \
154 data = tmio_sd_read##__suffix(priv, \
156 put_unaligned(data, buf++); \
161 tmio_pio_read_fifo(64, q)
162 tmio_pio_read_fifo(32, l)
163 tmio_pio_read_fifo(16, w)
165 static int tmio_sd_pio_read_one_block(struct udevice *dev, struct mmc_cmd *cmd,
166 char *pbuf, uint blocksize)
168 struct tmio_sd_priv *priv = dev_get_priv(dev);
171 /* wait until the buffer is filled with data */
172 ret = tmio_sd_wait_for_irq(dev, cmd, TMIO_SD_INFO2,
178 * Clear the status flag _before_ read the buffer out because
179 * TMIO_SD_INFO2_BRE is edge-triggered, not level-triggered.
181 tmio_sd_writel(priv, 0, TMIO_SD_INFO2);
183 if (priv->caps & TMIO_SD_CAP_64BIT)
184 tmio_pio_read_fifo_64(priv, pbuf, blocksize);
185 else if (priv->caps & TMIO_SD_CAP_16BIT)
186 tmio_pio_read_fifo_16(priv, pbuf, blocksize);
188 tmio_pio_read_fifo_32(priv, pbuf, blocksize);
193 #define tmio_pio_write_fifo(__width, __suffix) \
194 static void tmio_pio_write_fifo_##__width(struct tmio_sd_priv *priv, \
195 const char *pbuf, uint blksz)\
197 const u##__width *buf = (const u##__width *)pbuf; \
200 if (likely(IS_ALIGNED((uintptr_t)buf, ((__width) / 8)))) { \
201 for (i = 0; i < blksz / ((__width) / 8); i++) { \
202 tmio_sd_write##__suffix(priv, *buf++, \
206 for (i = 0; i < blksz / ((__width) / 8); i++) { \
207 u##__width data = get_unaligned(buf++); \
208 tmio_sd_write##__suffix(priv, data, \
214 tmio_pio_write_fifo(64, q)
215 tmio_pio_write_fifo(32, l)
216 tmio_pio_write_fifo(16, w)
218 static int tmio_sd_pio_write_one_block(struct udevice *dev, struct mmc_cmd *cmd,
219 const char *pbuf, uint blocksize)
221 struct tmio_sd_priv *priv = dev_get_priv(dev);
224 /* wait until the buffer becomes empty */
225 ret = tmio_sd_wait_for_irq(dev, cmd, TMIO_SD_INFO2,
230 tmio_sd_writel(priv, 0, TMIO_SD_INFO2);
232 if (priv->caps & TMIO_SD_CAP_64BIT)
233 tmio_pio_write_fifo_64(priv, pbuf, blocksize);
234 else if (priv->caps & TMIO_SD_CAP_16BIT)
235 tmio_pio_write_fifo_16(priv, pbuf, blocksize);
237 tmio_pio_write_fifo_32(priv, pbuf, blocksize);
242 static int tmio_sd_pio_xfer(struct udevice *dev, struct mmc_cmd *cmd,
243 struct mmc_data *data)
245 const char *src = data->src;
246 char *dest = data->dest;
249 for (i = 0; i < data->blocks; i++) {
250 if (data->flags & MMC_DATA_READ)
251 ret = tmio_sd_pio_read_one_block(dev, cmd, dest,
254 ret = tmio_sd_pio_write_one_block(dev, cmd, src,
259 if (data->flags & MMC_DATA_READ)
260 dest += data->blocksize;
262 src += data->blocksize;
268 static void tmio_sd_dma_start(struct tmio_sd_priv *priv,
273 tmio_sd_writel(priv, 0, TMIO_SD_DMA_INFO1);
274 tmio_sd_writel(priv, 0, TMIO_SD_DMA_INFO2);
277 tmp = tmio_sd_readl(priv, TMIO_SD_EXTMODE);
278 tmp |= TMIO_SD_EXTMODE_DMA_EN;
279 tmio_sd_writel(priv, tmp, TMIO_SD_EXTMODE);
281 tmio_sd_writel(priv, dma_addr & U32_MAX, TMIO_SD_DMA_ADDR_L);
283 /* suppress the warning "right shift count >= width of type" */
284 dma_addr >>= min_t(int, 32, 8 * sizeof(dma_addr));
286 tmio_sd_writel(priv, dma_addr & U32_MAX, TMIO_SD_DMA_ADDR_H);
288 tmio_sd_writel(priv, TMIO_SD_DMA_CTL_START, TMIO_SD_DMA_CTL);
291 static int tmio_sd_dma_wait_for_irq(struct udevice *dev, u32 flag,
294 struct tmio_sd_priv *priv = dev_get_priv(dev);
295 long wait = 1000000 + 10 * blocks;
297 while (!(tmio_sd_readl(priv, TMIO_SD_DMA_INFO1) & flag)) {
299 dev_err(dev, "timeout during DMA\n");
306 if (tmio_sd_readl(priv, TMIO_SD_DMA_INFO2)) {
307 dev_err(dev, "error during DMA\n");
314 static int tmio_sd_dma_xfer(struct udevice *dev, struct mmc_data *data)
316 struct tmio_sd_priv *priv = dev_get_priv(dev);
317 size_t len = data->blocks * data->blocksize;
319 enum dma_data_direction dir;
324 tmp = tmio_sd_readl(priv, TMIO_SD_DMA_MODE);
326 if (data->flags & MMC_DATA_READ) {
328 dir = DMA_FROM_DEVICE;
330 * The DMA READ completion flag position differs on Socionext
331 * and Renesas SoCs. It is bit 20 on Socionext SoCs and using
332 * bit 17 is a hardware bug and forbidden. It is either bit 17
333 * or bit 20 on Renesas SoCs, depending on SoC.
335 poll_flag = priv->read_poll_flag;
336 tmp |= TMIO_SD_DMA_MODE_DIR_RD;
338 buf = (void *)data->src;
340 poll_flag = TMIO_SD_DMA_INFO1_END_WR;
341 tmp &= ~TMIO_SD_DMA_MODE_DIR_RD;
344 tmio_sd_writel(priv, tmp, TMIO_SD_DMA_MODE);
346 dma_addr = dma_map_single(buf, len, dir);
348 tmio_sd_dma_start(priv, dma_addr);
350 ret = tmio_sd_dma_wait_for_irq(dev, poll_flag, data->blocks);
352 if (poll_flag == TMIO_SD_DMA_INFO1_END_RD)
355 dma_unmap_single(dma_addr, len, dir);
360 /* check if the address is DMA'able */
361 static bool tmio_sd_addr_is_dmaable(const char *src)
363 uintptr_t addr = (uintptr_t)src;
365 if (!IS_ALIGNED(addr, TMIO_SD_DMA_MINALIGN))
368 #if defined(CONFIG_RCAR_GEN3)
369 /* Gen3 DMA has 32bit limit */
374 #if defined(CONFIG_ARCH_UNIPHIER) && !defined(CONFIG_ARM64) && \
375 defined(CONFIG_SPL_BUILD)
377 * For UniPhier ARMv7 SoCs, the stack is allocated in the locked ways
378 * of L2, which is unreachable from the DMA engine.
380 if (addr < CONFIG_SPL_STACK)
387 int tmio_sd_send_cmd(struct udevice *dev, struct mmc_cmd *cmd,
388 struct mmc_data *data)
390 struct tmio_sd_priv *priv = dev_get_priv(dev);
394 if (tmio_sd_readl(priv, TMIO_SD_INFO2) & TMIO_SD_INFO2_CBSY) {
395 dev_err(dev, "command busy\n");
399 /* clear all status flags */
400 tmio_sd_writel(priv, 0, TMIO_SD_INFO1);
401 tmio_sd_writel(priv, 0, TMIO_SD_INFO2);
403 /* disable DMA once */
404 tmp = tmio_sd_readl(priv, TMIO_SD_EXTMODE);
405 tmp &= ~TMIO_SD_EXTMODE_DMA_EN;
406 tmio_sd_writel(priv, tmp, TMIO_SD_EXTMODE);
408 tmio_sd_writel(priv, cmd->cmdarg, TMIO_SD_ARG);
413 tmio_sd_writel(priv, data->blocksize, TMIO_SD_SIZE);
414 tmio_sd_writel(priv, data->blocks, TMIO_SD_SECCNT);
416 /* Do not send CMD12 automatically */
417 tmp |= TMIO_SD_CMD_NOSTOP | TMIO_SD_CMD_DATA;
419 if (data->blocks > 1)
420 tmp |= TMIO_SD_CMD_MULTI;
422 if (data->flags & MMC_DATA_READ)
423 tmp |= TMIO_SD_CMD_RD;
427 * Do not use the response type auto-detection on this hardware.
428 * CMD8, for example, has different response types on SD and eMMC,
429 * while this controller always assumes the response type for SD.
430 * Set the response type manually.
432 switch (cmd->resp_type) {
434 tmp |= TMIO_SD_CMD_RSP_NONE;
437 tmp |= TMIO_SD_CMD_RSP_R1;
440 tmp |= TMIO_SD_CMD_RSP_R1B;
443 tmp |= TMIO_SD_CMD_RSP_R2;
446 tmp |= TMIO_SD_CMD_RSP_R3;
449 dev_err(dev, "unknown response type\n");
453 dev_dbg(dev, "sending CMD%d (SD_CMD=%08x, SD_ARG=%08x)\n",
454 cmd->cmdidx, tmp, cmd->cmdarg);
455 tmio_sd_writel(priv, tmp, TMIO_SD_CMD);
457 ret = tmio_sd_wait_for_irq(dev, cmd, TMIO_SD_INFO1,
462 if (cmd->resp_type & MMC_RSP_136) {
463 u32 rsp_127_104 = tmio_sd_readl(priv, TMIO_SD_RSP76);
464 u32 rsp_103_72 = tmio_sd_readl(priv, TMIO_SD_RSP54);
465 u32 rsp_71_40 = tmio_sd_readl(priv, TMIO_SD_RSP32);
466 u32 rsp_39_8 = tmio_sd_readl(priv, TMIO_SD_RSP10);
468 cmd->response[0] = ((rsp_127_104 & 0x00ffffff) << 8) |
469 ((rsp_103_72 & 0xff000000) >> 24);
470 cmd->response[1] = ((rsp_103_72 & 0x00ffffff) << 8) |
471 ((rsp_71_40 & 0xff000000) >> 24);
472 cmd->response[2] = ((rsp_71_40 & 0x00ffffff) << 8) |
473 ((rsp_39_8 & 0xff000000) >> 24);
474 cmd->response[3] = (rsp_39_8 & 0xffffff) << 8;
477 cmd->response[0] = tmio_sd_readl(priv, TMIO_SD_RSP10);
481 /* use DMA if the HW supports it and the buffer is aligned */
482 if (priv->caps & TMIO_SD_CAP_DMA_INTERNAL &&
483 tmio_sd_addr_is_dmaable(data->src))
484 ret = tmio_sd_dma_xfer(dev, data);
486 ret = tmio_sd_pio_xfer(dev, cmd, data);
490 ret = tmio_sd_wait_for_irq(dev, cmd, TMIO_SD_INFO1,
496 return tmio_sd_wait_for_irq(dev, cmd, TMIO_SD_INFO2,
497 TMIO_SD_INFO2_SCLKDIVEN);
500 static int tmio_sd_set_bus_width(struct tmio_sd_priv *priv,
505 switch (mmc->bus_width) {
508 val = TMIO_SD_OPTION_WIDTH_1;
511 val = TMIO_SD_OPTION_WIDTH_4;
514 val = TMIO_SD_OPTION_WIDTH_8;
520 tmp = tmio_sd_readl(priv, TMIO_SD_OPTION);
521 tmp &= ~TMIO_SD_OPTION_WIDTH_MASK;
523 tmio_sd_writel(priv, tmp, TMIO_SD_OPTION);
528 static void tmio_sd_set_ddr_mode(struct tmio_sd_priv *priv,
533 tmp = tmio_sd_readl(priv, TMIO_SD_IF_MODE);
535 tmp |= TMIO_SD_IF_MODE_DDR;
537 tmp &= ~TMIO_SD_IF_MODE_DDR;
538 tmio_sd_writel(priv, tmp, TMIO_SD_IF_MODE);
541 static ulong tmio_sd_clk_get_rate(struct tmio_sd_priv *priv)
543 return priv->clk_get_rate(priv);
546 static void tmio_sd_set_clk_rate(struct tmio_sd_priv *priv, struct mmc *mmc)
548 unsigned int divisor;
553 mclk = tmio_sd_clk_get_rate(priv);
555 divisor = DIV_ROUND_UP(mclk, mmc->clock);
557 /* Do not set divider to 0xff in DDR mode */
558 if (mmc->ddr_mode && (divisor == 1))
562 val = (priv->caps & TMIO_SD_CAP_RCAR) ?
563 TMIO_SD_CLKCTL_RCAR_DIV1 : TMIO_SD_CLKCTL_DIV1;
564 else if (divisor <= 2)
565 val = TMIO_SD_CLKCTL_DIV2;
566 else if (divisor <= 4)
567 val = TMIO_SD_CLKCTL_DIV4;
568 else if (divisor <= 8)
569 val = TMIO_SD_CLKCTL_DIV8;
570 else if (divisor <= 16)
571 val = TMIO_SD_CLKCTL_DIV16;
572 else if (divisor <= 32)
573 val = TMIO_SD_CLKCTL_DIV32;
574 else if (divisor <= 64)
575 val = TMIO_SD_CLKCTL_DIV64;
576 else if (divisor <= 128)
577 val = TMIO_SD_CLKCTL_DIV128;
578 else if (divisor <= 256)
579 val = TMIO_SD_CLKCTL_DIV256;
580 else if (divisor <= 512 || !(priv->caps & TMIO_SD_CAP_DIV1024))
581 val = TMIO_SD_CLKCTL_DIV512;
583 val = TMIO_SD_CLKCTL_DIV1024;
586 tmp = tmio_sd_readl(priv, TMIO_SD_CLKCTL);
588 !((tmp & TMIO_SD_CLKCTL_SCLKEN) &&
589 ((tmp & TMIO_SD_CLKCTL_DIV_MASK) == val))) {
591 * Stop the clock before changing its rate
592 * to avoid a glitch signal
594 tmp &= ~TMIO_SD_CLKCTL_SCLKEN;
595 tmio_sd_writel(priv, tmp, TMIO_SD_CLKCTL);
597 /* Change the clock rate. */
598 tmp &= ~TMIO_SD_CLKCTL_DIV_MASK;
602 /* Enable or Disable the clock */
603 if (mmc->clk_disable) {
604 tmp |= TMIO_SD_CLKCTL_OFFEN;
605 tmp &= ~TMIO_SD_CLKCTL_SCLKEN;
607 tmp &= ~TMIO_SD_CLKCTL_OFFEN;
608 tmp |= TMIO_SD_CLKCTL_SCLKEN;
611 tmio_sd_writel(priv, tmp, TMIO_SD_CLKCTL);
616 static void tmio_sd_set_pins(struct udevice *dev)
618 __maybe_unused struct mmc *mmc = mmc_get_mmc_dev(dev);
620 #ifdef CONFIG_DM_REGULATOR
621 struct tmio_sd_priv *priv = dev_get_priv(dev);
623 if (priv->vqmmc_dev) {
624 if (mmc->signal_voltage == MMC_SIGNAL_VOLTAGE_180)
625 regulator_set_value(priv->vqmmc_dev, 1800000);
627 regulator_set_value(priv->vqmmc_dev, 3300000);
628 regulator_set_enable(priv->vqmmc_dev, true);
632 #ifdef CONFIG_PINCTRL
633 if (mmc->signal_voltage == MMC_SIGNAL_VOLTAGE_180)
634 pinctrl_select_state(dev, "state_uhs");
636 pinctrl_select_state(dev, "default");
640 int tmio_sd_set_ios(struct udevice *dev)
642 struct tmio_sd_priv *priv = dev_get_priv(dev);
643 struct mmc *mmc = mmc_get_mmc_dev(dev);
646 dev_dbg(dev, "clock %uHz, DDRmode %d, width %u\n",
647 mmc->clock, mmc->ddr_mode, mmc->bus_width);
649 tmio_sd_set_clk_rate(priv, mmc);
650 ret = tmio_sd_set_bus_width(priv, mmc);
653 tmio_sd_set_ddr_mode(priv, mmc);
654 tmio_sd_set_pins(dev);
659 int tmio_sd_get_cd(struct udevice *dev)
661 struct tmio_sd_priv *priv = dev_get_priv(dev);
663 if (priv->caps & TMIO_SD_CAP_NONREMOVABLE)
666 return !!(tmio_sd_readl(priv, TMIO_SD_INFO1) &
670 static void tmio_sd_host_init(struct tmio_sd_priv *priv)
674 /* soft reset of the host */
675 tmp = tmio_sd_readl(priv, TMIO_SD_SOFT_RST);
676 tmp &= ~TMIO_SD_SOFT_RST_RSTX;
677 tmio_sd_writel(priv, tmp, TMIO_SD_SOFT_RST);
678 tmp |= TMIO_SD_SOFT_RST_RSTX;
679 tmio_sd_writel(priv, tmp, TMIO_SD_SOFT_RST);
681 /* FIXME: implement eMMC hw_reset */
683 tmio_sd_writel(priv, TMIO_SD_STOP_SEC, TMIO_SD_STOP);
686 * Connected to 32bit AXI.
687 * This register dropped backward compatibility at version 0x10.
688 * Write an appropriate value depending on the IP version.
690 if (priv->version >= 0x10) {
691 if (priv->caps & TMIO_SD_CAP_64BIT)
692 tmio_sd_writel(priv, 0x000, TMIO_SD_HOST_MODE);
694 tmio_sd_writel(priv, 0x101, TMIO_SD_HOST_MODE);
696 tmio_sd_writel(priv, 0x0, TMIO_SD_HOST_MODE);
699 if (priv->caps & TMIO_SD_CAP_DMA_INTERNAL) {
700 tmp = tmio_sd_readl(priv, TMIO_SD_DMA_MODE);
701 tmp |= TMIO_SD_DMA_MODE_ADDR_INC;
702 tmio_sd_writel(priv, tmp, TMIO_SD_DMA_MODE);
706 int tmio_sd_bind(struct udevice *dev)
708 struct tmio_sd_plat *plat = dev_get_platdata(dev);
710 return mmc_bind(dev, &plat->mmc, &plat->cfg);
713 int tmio_sd_probe(struct udevice *dev, u32 quirks)
715 struct tmio_sd_plat *plat = dev_get_platdata(dev);
716 struct tmio_sd_priv *priv = dev_get_priv(dev);
717 struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev);
722 base = devfdt_get_addr(dev);
723 if (base == FDT_ADDR_T_NONE)
726 priv->regbase = devm_ioremap(dev, base, SZ_2K);
730 #ifdef CONFIG_DM_REGULATOR
731 device_get_supply_regulator(dev, "vqmmc-supply", &priv->vqmmc_dev);
733 regulator_set_value(priv->vqmmc_dev, 3300000);
736 ret = mmc_of_parse(dev, &plat->cfg);
738 dev_err(dev, "failed to parse host caps\n");
742 plat->cfg.name = dev->name;
743 plat->cfg.host_caps |= MMC_MODE_HS_52MHz | MMC_MODE_HS;
748 priv->version = tmio_sd_readl(priv, TMIO_SD_VERSION) &
750 dev_dbg(dev, "version %x\n", priv->version);
751 if (priv->version >= 0x10) {
752 priv->caps |= TMIO_SD_CAP_DMA_INTERNAL;
753 priv->caps |= TMIO_SD_CAP_DIV1024;
756 if (fdt_get_property(gd->fdt_blob, dev_of_offset(dev), "non-removable",
758 priv->caps |= TMIO_SD_CAP_NONREMOVABLE;
760 tmio_sd_host_init(priv);
762 mclk = tmio_sd_clk_get_rate(priv);
764 plat->cfg.voltages = MMC_VDD_165_195 | MMC_VDD_32_33 | MMC_VDD_33_34;
765 plat->cfg.f_min = mclk /
766 (priv->caps & TMIO_SD_CAP_DIV1024 ? 1024 : 512);
767 plat->cfg.f_max = mclk;
768 if (quirks & TMIO_SD_CAP_16BIT)
769 plat->cfg.b_max = U16_MAX; /* max value of TMIO_SD_SECCNT */
771 plat->cfg.b_max = U32_MAX; /* max value of TMIO_SD_SECCNT */
773 upriv->mmc = &plat->mmc;