1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2016 Socionext Inc.
4 * Author: Masahiro Yamada <yamada.masahiro@socionext.com>
13 #include <asm/global_data.h>
14 #include <dm/device_compat.h>
15 #include <dm/pinctrl.h>
16 #include <linux/compat.h>
17 #include <linux/delay.h>
18 #include <linux/dma-mapping.h>
20 #include <linux/sizes.h>
21 #include <power/regulator.h>
22 #include <asm/unaligned.h>
24 #include "tmio-common.h"
26 DECLARE_GLOBAL_DATA_PTR;
28 static u64 tmio_sd_readq(struct tmio_sd_priv *priv, unsigned int reg)
30 return readq(priv->regbase + (reg << 1));
33 static void tmio_sd_writeq(struct tmio_sd_priv *priv,
34 u64 val, unsigned int reg)
36 writeq(val, priv->regbase + (reg << 1));
39 static u16 tmio_sd_readw(struct tmio_sd_priv *priv, unsigned int reg)
41 return readw(priv->regbase + (reg >> 1));
44 static void tmio_sd_writew(struct tmio_sd_priv *priv,
45 u16 val, unsigned int reg)
47 writew(val, priv->regbase + (reg >> 1));
50 u32 tmio_sd_readl(struct tmio_sd_priv *priv, unsigned int reg)
54 if (priv->caps & TMIO_SD_CAP_64BIT)
55 return readl(priv->regbase + (reg << 1));
56 else if (priv->caps & TMIO_SD_CAP_16BIT) {
57 val = readw(priv->regbase + (reg >> 1)) & 0xffff;
58 if ((reg == TMIO_SD_RSP10) || (reg == TMIO_SD_RSP32) ||
59 (reg == TMIO_SD_RSP54) || (reg == TMIO_SD_RSP76)) {
60 val |= readw(priv->regbase + (reg >> 1) + 2) << 16;
64 return readl(priv->regbase + reg);
67 void tmio_sd_writel(struct tmio_sd_priv *priv,
68 u32 val, unsigned int reg)
70 if (priv->caps & TMIO_SD_CAP_64BIT)
71 writel(val, priv->regbase + (reg << 1));
72 else if (priv->caps & TMIO_SD_CAP_16BIT) {
73 writew(val & 0xffff, priv->regbase + (reg >> 1));
74 if (reg == TMIO_SD_INFO1 || reg == TMIO_SD_INFO1_MASK ||
75 reg == TMIO_SD_INFO2 || reg == TMIO_SD_INFO2_MASK ||
77 writew(val >> 16, priv->regbase + (reg >> 1) + 2);
79 writel(val, priv->regbase + reg);
82 static int tmio_sd_check_error(struct udevice *dev, struct mmc_cmd *cmd)
84 struct tmio_sd_priv *priv = dev_get_priv(dev);
85 u32 info2 = tmio_sd_readl(priv, TMIO_SD_INFO2);
87 if (info2 & TMIO_SD_INFO2_ERR_RTO) {
89 * TIMEOUT must be returned for unsupported command. Do not
90 * display error log since this might be a part of sequence to
91 * distinguish between SD and MMC.
96 if (info2 & TMIO_SD_INFO2_ERR_TO) {
97 dev_err(dev, "timeout error\n");
101 if (info2 & (TMIO_SD_INFO2_ERR_END | TMIO_SD_INFO2_ERR_CRC |
102 TMIO_SD_INFO2_ERR_IDX)) {
103 if ((cmd->cmdidx != MMC_CMD_SEND_TUNING_BLOCK) &&
104 (cmd->cmdidx != MMC_CMD_SEND_TUNING_BLOCK_HS200))
105 dev_err(dev, "communication out of sync\n");
109 if (info2 & (TMIO_SD_INFO2_ERR_ILA | TMIO_SD_INFO2_ERR_ILR |
110 TMIO_SD_INFO2_ERR_ILW)) {
111 dev_err(dev, "illegal access\n");
118 static int tmio_sd_wait_for_irq(struct udevice *dev, struct mmc_cmd *cmd,
119 unsigned int reg, u32 flag)
121 struct tmio_sd_priv *priv = dev_get_priv(dev);
125 while (!(tmio_sd_readl(priv, reg) & flag)) {
127 dev_err(dev, "timeout\n");
131 ret = tmio_sd_check_error(dev, cmd);
141 #define tmio_pio_read_fifo(__width, __suffix) \
142 static void tmio_pio_read_fifo_##__width(struct tmio_sd_priv *priv, \
143 char *pbuf, uint blksz) \
145 u##__width *buf = (u##__width *)pbuf; \
148 if (likely(IS_ALIGNED((uintptr_t)buf, ((__width) / 8)))) { \
149 for (i = 0; i < blksz / ((__width) / 8); i++) { \
150 *buf++ = tmio_sd_read##__suffix(priv, \
154 for (i = 0; i < blksz / ((__width) / 8); i++) { \
156 data = tmio_sd_read##__suffix(priv, \
158 put_unaligned(data, buf++); \
163 tmio_pio_read_fifo(64, q)
164 tmio_pio_read_fifo(32, l)
165 tmio_pio_read_fifo(16, w)
167 static int tmio_sd_pio_read_one_block(struct udevice *dev, struct mmc_cmd *cmd,
168 char *pbuf, uint blocksize)
170 struct tmio_sd_priv *priv = dev_get_priv(dev);
173 /* wait until the buffer is filled with data */
174 ret = tmio_sd_wait_for_irq(dev, cmd, TMIO_SD_INFO2,
180 * Clear the status flag _before_ read the buffer out because
181 * TMIO_SD_INFO2_BRE is edge-triggered, not level-triggered.
183 tmio_sd_writel(priv, 0, TMIO_SD_INFO2);
185 if (priv->caps & TMIO_SD_CAP_64BIT)
186 tmio_pio_read_fifo_64(priv, pbuf, blocksize);
187 else if (priv->caps & TMIO_SD_CAP_16BIT)
188 tmio_pio_read_fifo_16(priv, pbuf, blocksize);
190 tmio_pio_read_fifo_32(priv, pbuf, blocksize);
195 #define tmio_pio_write_fifo(__width, __suffix) \
196 static void tmio_pio_write_fifo_##__width(struct tmio_sd_priv *priv, \
197 const char *pbuf, uint blksz)\
199 const u##__width *buf = (const u##__width *)pbuf; \
202 if (likely(IS_ALIGNED((uintptr_t)buf, ((__width) / 8)))) { \
203 for (i = 0; i < blksz / ((__width) / 8); i++) { \
204 tmio_sd_write##__suffix(priv, *buf++, \
208 for (i = 0; i < blksz / ((__width) / 8); i++) { \
209 u##__width data = get_unaligned(buf++); \
210 tmio_sd_write##__suffix(priv, data, \
216 tmio_pio_write_fifo(64, q)
217 tmio_pio_write_fifo(32, l)
218 tmio_pio_write_fifo(16, w)
220 static int tmio_sd_pio_write_one_block(struct udevice *dev, struct mmc_cmd *cmd,
221 const char *pbuf, uint blocksize)
223 struct tmio_sd_priv *priv = dev_get_priv(dev);
226 /* wait until the buffer becomes empty */
227 ret = tmio_sd_wait_for_irq(dev, cmd, TMIO_SD_INFO2,
232 tmio_sd_writel(priv, 0, TMIO_SD_INFO2);
234 if (priv->caps & TMIO_SD_CAP_64BIT)
235 tmio_pio_write_fifo_64(priv, pbuf, blocksize);
236 else if (priv->caps & TMIO_SD_CAP_16BIT)
237 tmio_pio_write_fifo_16(priv, pbuf, blocksize);
239 tmio_pio_write_fifo_32(priv, pbuf, blocksize);
244 static int tmio_sd_pio_xfer(struct udevice *dev, struct mmc_cmd *cmd,
245 struct mmc_data *data)
247 const char *src = data->src;
248 char *dest = data->dest;
251 for (i = 0; i < data->blocks; i++) {
252 if (data->flags & MMC_DATA_READ)
253 ret = tmio_sd_pio_read_one_block(dev, cmd, dest,
256 ret = tmio_sd_pio_write_one_block(dev, cmd, src,
261 if (data->flags & MMC_DATA_READ)
262 dest += data->blocksize;
264 src += data->blocksize;
270 static void tmio_sd_dma_start(struct tmio_sd_priv *priv,
275 tmio_sd_writel(priv, 0, TMIO_SD_DMA_INFO1);
276 tmio_sd_writel(priv, 0, TMIO_SD_DMA_INFO2);
279 tmp = tmio_sd_readl(priv, TMIO_SD_EXTMODE);
280 tmp |= TMIO_SD_EXTMODE_DMA_EN;
281 tmio_sd_writel(priv, tmp, TMIO_SD_EXTMODE);
283 tmio_sd_writel(priv, dma_addr & U32_MAX, TMIO_SD_DMA_ADDR_L);
285 /* suppress the warning "right shift count >= width of type" */
286 dma_addr >>= min_t(int, 32, 8 * sizeof(dma_addr));
288 tmio_sd_writel(priv, dma_addr & U32_MAX, TMIO_SD_DMA_ADDR_H);
290 tmio_sd_writel(priv, TMIO_SD_DMA_CTL_START, TMIO_SD_DMA_CTL);
293 static int tmio_sd_dma_wait_for_irq(struct udevice *dev, u32 flag,
296 struct tmio_sd_priv *priv = dev_get_priv(dev);
297 long wait = 1000000 + 10 * blocks;
299 while (!(tmio_sd_readl(priv, TMIO_SD_DMA_INFO1) & flag)) {
301 dev_err(dev, "timeout during DMA\n");
308 if (tmio_sd_readl(priv, TMIO_SD_DMA_INFO2)) {
309 dev_err(dev, "error during DMA\n");
316 static int tmio_sd_dma_xfer(struct udevice *dev, struct mmc_data *data)
318 struct tmio_sd_priv *priv = dev_get_priv(dev);
319 size_t len = data->blocks * data->blocksize;
321 enum dma_data_direction dir;
326 tmp = tmio_sd_readl(priv, TMIO_SD_DMA_MODE);
328 tmp |= priv->idma_bus_width;
330 if (data->flags & MMC_DATA_READ) {
332 dir = DMA_FROM_DEVICE;
334 * The DMA READ completion flag position differs on Socionext
335 * and Renesas SoCs. It is bit 20 on Socionext SoCs and using
336 * bit 17 is a hardware bug and forbidden. It is either bit 17
337 * or bit 20 on Renesas SoCs, depending on SoC.
339 poll_flag = priv->read_poll_flag;
340 tmp |= TMIO_SD_DMA_MODE_DIR_RD;
342 buf = (void *)data->src;
344 poll_flag = TMIO_SD_DMA_INFO1_END_WR;
345 tmp &= ~TMIO_SD_DMA_MODE_DIR_RD;
348 tmio_sd_writel(priv, tmp, TMIO_SD_DMA_MODE);
350 dma_addr = dma_map_single(buf, len, dir);
352 tmio_sd_dma_start(priv, dma_addr);
354 ret = tmio_sd_dma_wait_for_irq(dev, poll_flag, data->blocks);
356 if (poll_flag == TMIO_SD_DMA_INFO1_END_RD)
359 dma_unmap_single(dma_addr, len, dir);
364 /* check if the address is DMA'able */
365 static bool tmio_sd_addr_is_dmaable(struct mmc_data *data)
367 uintptr_t addr = (uintptr_t)data->src;
369 if (!IS_ALIGNED(addr, TMIO_SD_DMA_MINALIGN))
372 if (IS_ENABLED(CONFIG_RCAR_64)) {
373 if (!(data->flags & MMC_DATA_READ) && !IS_ALIGNED(addr, 128))
375 /* Gen3 DMA has 32bit limit */
376 if (sizeof(addr) > 4 && addr >> 32)
380 #ifdef CONFIG_SPL_BUILD
381 if (IS_ENABLED(CONFIG_ARCH_UNIPHIER) && !IS_ENABLED(CONFIG_ARM64)) {
383 * For UniPhier ARMv7 SoCs, the stack is allocated in locked
384 * ways of L2, which is unreachable from the DMA engine.
386 if (addr < CONFIG_SPL_STACK)
394 int tmio_sd_send_cmd(struct udevice *dev, struct mmc_cmd *cmd,
395 struct mmc_data *data)
397 struct tmio_sd_priv *priv = dev_get_priv(dev);
401 if (tmio_sd_readl(priv, TMIO_SD_INFO2) & TMIO_SD_INFO2_CBSY) {
402 dev_err(dev, "command busy\n");
406 /* clear all status flags */
407 tmio_sd_writel(priv, 0, TMIO_SD_INFO1);
408 tmio_sd_writel(priv, 0, TMIO_SD_INFO2);
410 /* disable DMA once */
411 tmp = tmio_sd_readl(priv, TMIO_SD_EXTMODE);
412 tmp &= ~TMIO_SD_EXTMODE_DMA_EN;
413 tmio_sd_writel(priv, tmp, TMIO_SD_EXTMODE);
415 tmio_sd_writel(priv, cmd->cmdarg, TMIO_SD_ARG);
420 tmio_sd_writel(priv, data->blocksize, TMIO_SD_SIZE);
421 tmio_sd_writel(priv, data->blocks, TMIO_SD_SECCNT);
423 /* Do not send CMD12 automatically */
424 tmp |= TMIO_SD_CMD_NOSTOP | TMIO_SD_CMD_DATA;
426 if (data->blocks > 1)
427 tmp |= TMIO_SD_CMD_MULTI;
429 if (data->flags & MMC_DATA_READ)
430 tmp |= TMIO_SD_CMD_RD;
434 * Do not use the response type auto-detection on this hardware.
435 * CMD8, for example, has different response types on SD and eMMC,
436 * while this controller always assumes the response type for SD.
437 * Set the response type manually.
439 switch (cmd->resp_type) {
441 tmp |= TMIO_SD_CMD_RSP_NONE;
444 tmp |= TMIO_SD_CMD_RSP_R1;
447 tmp |= TMIO_SD_CMD_RSP_R1B;
450 tmp |= TMIO_SD_CMD_RSP_R2;
453 tmp |= TMIO_SD_CMD_RSP_R3;
456 dev_err(dev, "unknown response type\n");
460 dev_dbg(dev, "sending CMD%d (SD_CMD=%08x, SD_ARG=%08x)\n",
461 cmd->cmdidx, tmp, cmd->cmdarg);
462 tmio_sd_writel(priv, tmp, TMIO_SD_CMD);
464 ret = tmio_sd_wait_for_irq(dev, cmd, TMIO_SD_INFO1,
469 if (cmd->resp_type & MMC_RSP_136) {
470 u32 rsp_127_104 = tmio_sd_readl(priv, TMIO_SD_RSP76);
471 u32 rsp_103_72 = tmio_sd_readl(priv, TMIO_SD_RSP54);
472 u32 rsp_71_40 = tmio_sd_readl(priv, TMIO_SD_RSP32);
473 u32 rsp_39_8 = tmio_sd_readl(priv, TMIO_SD_RSP10);
475 cmd->response[0] = ((rsp_127_104 & 0x00ffffff) << 8) |
476 ((rsp_103_72 & 0xff000000) >> 24);
477 cmd->response[1] = ((rsp_103_72 & 0x00ffffff) << 8) |
478 ((rsp_71_40 & 0xff000000) >> 24);
479 cmd->response[2] = ((rsp_71_40 & 0x00ffffff) << 8) |
480 ((rsp_39_8 & 0xff000000) >> 24);
481 cmd->response[3] = (rsp_39_8 & 0xffffff) << 8;
484 cmd->response[0] = tmio_sd_readl(priv, TMIO_SD_RSP10);
488 /* use DMA if the HW supports it and the buffer is aligned */
489 if (priv->caps & TMIO_SD_CAP_DMA_INTERNAL &&
490 tmio_sd_addr_is_dmaable(data))
491 ret = tmio_sd_dma_xfer(dev, data);
493 ret = tmio_sd_pio_xfer(dev, cmd, data);
497 ret = tmio_sd_wait_for_irq(dev, cmd, TMIO_SD_INFO1,
503 return tmio_sd_wait_for_irq(dev, cmd, TMIO_SD_INFO2,
504 TMIO_SD_INFO2_SCLKDIVEN);
507 static int tmio_sd_set_bus_width(struct tmio_sd_priv *priv,
512 switch (mmc->bus_width) {
515 val = TMIO_SD_OPTION_WIDTH_1;
518 val = TMIO_SD_OPTION_WIDTH_4;
521 val = TMIO_SD_OPTION_WIDTH_8;
527 tmp = tmio_sd_readl(priv, TMIO_SD_OPTION);
528 tmp &= ~TMIO_SD_OPTION_WIDTH_MASK;
530 tmio_sd_writel(priv, tmp, TMIO_SD_OPTION);
535 static void tmio_sd_set_ddr_mode(struct tmio_sd_priv *priv,
540 tmp = tmio_sd_readl(priv, TMIO_SD_IF_MODE);
542 tmp |= TMIO_SD_IF_MODE_DDR;
544 tmp &= ~TMIO_SD_IF_MODE_DDR;
545 tmio_sd_writel(priv, tmp, TMIO_SD_IF_MODE);
548 static ulong tmio_sd_clk_get_rate(struct tmio_sd_priv *priv)
550 return priv->clk_get_rate(priv);
553 static void tmio_sd_set_clk_rate(struct tmio_sd_priv *priv, struct mmc *mmc)
555 unsigned int divisor;
560 mclk = tmio_sd_clk_get_rate(priv);
562 divisor = DIV_ROUND_UP(mclk, mmc->clock);
564 /* Do not set divider to 0xff in DDR mode */
565 if (mmc->ddr_mode && (divisor == 1))
569 val = (priv->caps & TMIO_SD_CAP_RCAR) ?
570 TMIO_SD_CLKCTL_RCAR_DIV1 : TMIO_SD_CLKCTL_DIV1;
571 else if (divisor <= 2)
572 val = TMIO_SD_CLKCTL_DIV2;
573 else if (divisor <= 4)
574 val = TMIO_SD_CLKCTL_DIV4;
575 else if (divisor <= 8)
576 val = TMIO_SD_CLKCTL_DIV8;
577 else if (divisor <= 16)
578 val = TMIO_SD_CLKCTL_DIV16;
579 else if (divisor <= 32)
580 val = TMIO_SD_CLKCTL_DIV32;
581 else if (divisor <= 64)
582 val = TMIO_SD_CLKCTL_DIV64;
583 else if (divisor <= 128)
584 val = TMIO_SD_CLKCTL_DIV128;
585 else if (divisor <= 256)
586 val = TMIO_SD_CLKCTL_DIV256;
587 else if (divisor <= 512 || !(priv->caps & TMIO_SD_CAP_DIV1024))
588 val = TMIO_SD_CLKCTL_DIV512;
590 val = TMIO_SD_CLKCTL_DIV1024;
593 tmp = tmio_sd_readl(priv, TMIO_SD_CLKCTL);
595 !((tmp & TMIO_SD_CLKCTL_SCLKEN) &&
596 ((tmp & TMIO_SD_CLKCTL_DIV_MASK) == val))) {
598 * Stop the clock before changing its rate
599 * to avoid a glitch signal
601 tmp &= ~TMIO_SD_CLKCTL_SCLKEN;
602 tmio_sd_writel(priv, tmp, TMIO_SD_CLKCTL);
604 /* Change the clock rate. */
605 tmp &= ~TMIO_SD_CLKCTL_DIV_MASK;
609 /* Enable or Disable the clock */
610 if (mmc->clk_disable) {
611 tmp |= TMIO_SD_CLKCTL_OFFEN;
612 tmp &= ~TMIO_SD_CLKCTL_SCLKEN;
614 tmp &= ~TMIO_SD_CLKCTL_OFFEN;
615 tmp |= TMIO_SD_CLKCTL_SCLKEN;
618 tmio_sd_writel(priv, tmp, TMIO_SD_CLKCTL);
623 static void tmio_sd_set_pins(struct udevice *dev)
625 __maybe_unused struct mmc *mmc = mmc_get_mmc_dev(dev);
626 struct tmio_sd_priv *priv = dev_get_priv(dev);
628 if (CONFIG_IS_ENABLED(DM_REGULATOR) && priv->vqmmc_dev) {
629 if (mmc->signal_voltage == MMC_SIGNAL_VOLTAGE_180)
630 regulator_set_value(priv->vqmmc_dev, 1800000);
632 regulator_set_value(priv->vqmmc_dev, 3300000);
633 regulator_set_enable(priv->vqmmc_dev, true);
636 if (CONFIG_IS_ENABLED(PINCTRL)) {
637 if (mmc->signal_voltage == MMC_SIGNAL_VOLTAGE_180)
638 pinctrl_select_state(dev, "state_uhs");
640 pinctrl_select_state(dev, "default");
644 int tmio_sd_set_ios(struct udevice *dev)
646 struct tmio_sd_priv *priv = dev_get_priv(dev);
647 struct mmc *mmc = mmc_get_mmc_dev(dev);
650 dev_dbg(dev, "clock %uHz, DDRmode %d, width %u\n",
651 mmc->clock, mmc->ddr_mode, mmc->bus_width);
653 tmio_sd_set_clk_rate(priv, mmc);
654 ret = tmio_sd_set_bus_width(priv, mmc);
657 tmio_sd_set_ddr_mode(priv, mmc);
658 tmio_sd_set_pins(dev);
663 int tmio_sd_get_cd(struct udevice *dev)
665 struct tmio_sd_priv *priv = dev_get_priv(dev);
667 if (priv->caps & TMIO_SD_CAP_NONREMOVABLE)
670 return !!(tmio_sd_readl(priv, TMIO_SD_INFO1) &
674 static void tmio_sd_host_init(struct tmio_sd_priv *priv)
678 /* soft reset of the host */
679 tmp = tmio_sd_readl(priv, TMIO_SD_SOFT_RST);
680 tmp &= ~TMIO_SD_SOFT_RST_RSTX;
681 tmio_sd_writel(priv, tmp, TMIO_SD_SOFT_RST);
682 tmp |= TMIO_SD_SOFT_RST_RSTX;
683 tmio_sd_writel(priv, tmp, TMIO_SD_SOFT_RST);
685 /* FIXME: implement eMMC hw_reset */
687 tmio_sd_writel(priv, TMIO_SD_STOP_SEC, TMIO_SD_STOP);
690 * Connected to 32bit AXI.
691 * This register dropped backward compatibility at version 0x10.
692 * Write an appropriate value depending on the IP version.
694 if (priv->version >= 0x10) {
695 if (priv->caps & TMIO_SD_CAP_64BIT)
696 tmio_sd_writel(priv, 0x000, TMIO_SD_HOST_MODE);
698 tmio_sd_writel(priv, 0x101, TMIO_SD_HOST_MODE);
700 tmio_sd_writel(priv, 0x0, TMIO_SD_HOST_MODE);
703 if (priv->caps & TMIO_SD_CAP_DMA_INTERNAL) {
704 tmp = tmio_sd_readl(priv, TMIO_SD_DMA_MODE);
705 tmp |= TMIO_SD_DMA_MODE_ADDR_INC;
706 tmp |= priv->idma_bus_width;
707 tmio_sd_writel(priv, tmp, TMIO_SD_DMA_MODE);
711 int tmio_sd_bind(struct udevice *dev)
713 struct tmio_sd_plat *plat = dev_get_plat(dev);
715 return mmc_bind(dev, &plat->mmc, &plat->cfg);
718 int tmio_sd_probe(struct udevice *dev, u32 quirks)
720 struct tmio_sd_plat *plat = dev_get_plat(dev);
721 struct tmio_sd_priv *priv = dev_get_priv(dev);
722 struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev);
727 base = dev_read_addr(dev);
728 if (base == FDT_ADDR_T_NONE)
731 priv->regbase = devm_ioremap(dev, base, SZ_2K);
735 if (CONFIG_IS_ENABLED(DM_REGULATOR)) {
736 device_get_supply_regulator(dev, "vqmmc-supply",
739 regulator_set_value(priv->vqmmc_dev, 3300000);
742 ret = mmc_of_parse(dev, &plat->cfg);
744 dev_err(dev, "failed to parse host caps\n");
748 plat->cfg.name = dev->name;
749 plat->cfg.host_caps |= MMC_MODE_HS_52MHz | MMC_MODE_HS;
754 priv->version = tmio_sd_readl(priv, TMIO_SD_VERSION) &
756 dev_dbg(dev, "version %x\n", priv->version);
757 if (priv->version >= 0x10) {
758 priv->caps |= TMIO_SD_CAP_DMA_INTERNAL;
759 priv->caps |= TMIO_SD_CAP_DIV1024;
762 if (fdt_get_property(gd->fdt_blob, dev_of_offset(dev), "non-removable",
764 priv->caps |= TMIO_SD_CAP_NONREMOVABLE;
766 tmio_sd_host_init(priv);
768 mclk = tmio_sd_clk_get_rate(priv);
770 plat->cfg.voltages = MMC_VDD_165_195 | MMC_VDD_32_33 | MMC_VDD_33_34;
771 plat->cfg.f_min = mclk /
772 (priv->caps & TMIO_SD_CAP_DIV1024 ? 1024 : 512);
773 plat->cfg.f_max = mclk;
774 if (quirks & TMIO_SD_CAP_16BIT)
775 plat->cfg.b_max = U16_MAX; /* max value of TMIO_SD_SECCNT */
777 plat->cfg.b_max = U32_MAX; /* max value of TMIO_SD_SECCNT */
779 upriv->mmc = &plat->mmc;