1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright 2007, 2010-2011 Freescale Semiconductor, Inc
6 * Based vaguely on the pxa mmc code:
8 * Kyle Harris, Nexus Technologies, Inc. kharris@nexus-tech.net
18 #include <power/regulator.h>
20 #include <fsl_esdhc.h>
21 #include <fdt_support.h>
24 #include <asm-generic/gpio.h>
25 #include <dm/pinctrl.h>
27 DECLARE_GLOBAL_DATA_PTR;
29 #define SDHCI_IRQ_EN_BITS (IRQSTATEN_CC | IRQSTATEN_TC | \
31 IRQSTATEN_CTOE | IRQSTATEN_CCE | IRQSTATEN_CEBE | \
32 IRQSTATEN_CIE | IRQSTATEN_DTOE | IRQSTATEN_DCE | \
33 IRQSTATEN_DEBE | IRQSTATEN_BRR | IRQSTATEN_BWR | \
35 #define MAX_TUNING_LOOP 40
38 uint dsaddr; /* SDMA system address register */
39 uint blkattr; /* Block attributes register */
40 uint cmdarg; /* Command argument register */
41 uint xfertyp; /* Transfer type register */
42 uint cmdrsp0; /* Command response 0 register */
43 uint cmdrsp1; /* Command response 1 register */
44 uint cmdrsp2; /* Command response 2 register */
45 uint cmdrsp3; /* Command response 3 register */
46 uint datport; /* Buffer data port register */
47 uint prsstat; /* Present state register */
48 uint proctl; /* Protocol control register */
49 uint sysctl; /* System Control Register */
50 uint irqstat; /* Interrupt status register */
51 uint irqstaten; /* Interrupt status enable register */
52 uint irqsigen; /* Interrupt signal enable register */
53 uint autoc12err; /* Auto CMD error status register */
54 uint hostcapblt; /* Host controller capabilities register */
55 uint wml; /* Watermark level register */
56 uint mixctrl; /* For USDHC */
57 char reserved1[4]; /* reserved */
58 uint fevt; /* Force event register */
59 uint admaes; /* ADMA error status register */
60 uint adsaddr; /* ADMA system address register */
64 uint clktunectrlstatus;
72 uint tuning_ctrl; /* on i.MX6/7/8 */
74 uint hostver; /* Host controller version register */
75 char reserved6[4]; /* reserved */
76 uint dmaerraddr; /* DMA error address register */
77 char reserved7[4]; /* reserved */
78 uint dmaerrattr; /* DMA error attribute register */
79 char reserved8[4]; /* reserved */
80 uint hostcapblt2; /* Host controller capabilities register 2 */
81 char reserved9[8]; /* reserved */
82 uint tcr; /* Tuning control register */
83 char reserved10[28]; /* reserved */
84 uint sddirctl; /* SD direction control register */
85 char reserved11[712];/* reserved */
86 uint scr; /* eSDHC control register */
89 struct fsl_esdhc_plat {
90 struct mmc_config cfg;
94 struct esdhc_soc_data {
100 * struct fsl_esdhc_priv
102 * @esdhc_regs: registers of the sdhc controller
103 * @sdhc_clk: Current clk of the sdhc controller
104 * @bus_width: bus width, 1bit, 4bit or 8bit
107 * Following is used when Driver Model is enabled for MMC
108 * @dev: pointer for the device
109 * @non_removable: 0: removable; 1: non-removable
110 * @wp_enable: 1: enable checking wp; 0: no check
111 * @vs18_enable: 1: use 1.8V voltage; 0: use 3.3V
112 * @flags: ESDHC_FLAG_xx in include/fsl_esdhc.h
113 * @caps: controller capabilities
114 * @tuning_step: tuning step setting in tuning_ctrl register
115 * @start_tuning_tap: the start point for tuning in tuning_ctrl register
116 * @strobe_dll_delay_target: settings in strobe_dllctrl
117 * @signal_voltage: indicating the current voltage
118 * @cd_gpio: gpio for card detection
119 * @wp_gpio: gpio for write protection
121 struct fsl_esdhc_priv {
122 struct fsl_esdhc *esdhc_regs;
123 unsigned int sdhc_clk;
126 unsigned int bus_width;
127 #if !CONFIG_IS_ENABLED(BLK)
137 u32 tuning_start_tap;
138 u32 strobe_dll_delay_target;
140 #if IS_ENABLED(CONFIG_DM_REGULATOR)
141 struct udevice *vqmmc_dev;
142 struct udevice *vmmc_dev;
144 #ifdef CONFIG_DM_GPIO
145 struct gpio_desc cd_gpio;
146 struct gpio_desc wp_gpio;
150 /* Return the XFERTYP flags for a given command and data packet */
151 static uint esdhc_xfertyp(struct mmc_cmd *cmd, struct mmc_data *data)
156 xfertyp |= XFERTYP_DPSEL;
157 #ifndef CONFIG_SYS_FSL_ESDHC_USE_PIO
158 xfertyp |= XFERTYP_DMAEN;
160 if (data->blocks > 1) {
161 xfertyp |= XFERTYP_MSBSEL;
162 xfertyp |= XFERTYP_BCEN;
163 #ifdef CONFIG_SYS_FSL_ERRATUM_ESDHC111
164 xfertyp |= XFERTYP_AC12EN;
168 if (data->flags & MMC_DATA_READ)
169 xfertyp |= XFERTYP_DTDSEL;
172 if (cmd->resp_type & MMC_RSP_CRC)
173 xfertyp |= XFERTYP_CCCEN;
174 if (cmd->resp_type & MMC_RSP_OPCODE)
175 xfertyp |= XFERTYP_CICEN;
176 if (cmd->resp_type & MMC_RSP_136)
177 xfertyp |= XFERTYP_RSPTYP_136;
178 else if (cmd->resp_type & MMC_RSP_BUSY)
179 xfertyp |= XFERTYP_RSPTYP_48_BUSY;
180 else if (cmd->resp_type & MMC_RSP_PRESENT)
181 xfertyp |= XFERTYP_RSPTYP_48;
183 if (cmd->cmdidx == MMC_CMD_STOP_TRANSMISSION)
184 xfertyp |= XFERTYP_CMDTYP_ABORT;
186 return XFERTYP_CMD(cmd->cmdidx) | xfertyp;
189 #ifdef CONFIG_SYS_FSL_ESDHC_USE_PIO
191 * PIO Read/Write Mode reduce the performace as DMA is not used in this mode.
193 static void esdhc_pio_read_write(struct fsl_esdhc_priv *priv,
194 struct mmc_data *data)
196 struct fsl_esdhc *regs = priv->esdhc_regs;
204 if (data->flags & MMC_DATA_READ) {
205 blocks = data->blocks;
208 start = get_timer(0);
209 size = data->blocksize;
210 irqstat = esdhc_read32(®s->irqstat);
211 while (!(esdhc_read32(®s->prsstat) & PRSSTAT_BREN)) {
212 if (get_timer(start) > PIO_TIMEOUT) {
213 printf("\nData Read Failed in PIO Mode.");
217 while (size && (!(irqstat & IRQSTAT_TC))) {
218 udelay(100); /* Wait before last byte transfer complete */
219 irqstat = esdhc_read32(®s->irqstat);
220 databuf = in_le32(®s->datport);
221 *((uint *)buffer) = databuf;
228 blocks = data->blocks;
229 buffer = (char *)data->src;
231 start = get_timer(0);
232 size = data->blocksize;
233 irqstat = esdhc_read32(®s->irqstat);
234 while (!(esdhc_read32(®s->prsstat) & PRSSTAT_BWEN)) {
235 if (get_timer(start) > PIO_TIMEOUT) {
236 printf("\nData Write Failed in PIO Mode.");
240 while (size && (!(irqstat & IRQSTAT_TC))) {
241 udelay(100); /* Wait before last byte transfer complete */
242 databuf = *((uint *)buffer);
245 irqstat = esdhc_read32(®s->irqstat);
246 out_le32(®s->datport, databuf);
254 static int esdhc_setup_data(struct fsl_esdhc_priv *priv, struct mmc *mmc,
255 struct mmc_data *data)
258 struct fsl_esdhc *regs = priv->esdhc_regs;
259 #if defined(CONFIG_FSL_LAYERSCAPE) || defined(CONFIG_S32V234) || \
265 wml_value = data->blocksize/4;
267 if (data->flags & MMC_DATA_READ) {
268 if (wml_value > WML_RD_WML_MAX)
269 wml_value = WML_RD_WML_MAX_VAL;
271 esdhc_clrsetbits32(®s->wml, WML_RD_WML_MASK, wml_value);
272 #ifndef CONFIG_SYS_FSL_ESDHC_USE_PIO
273 #if defined(CONFIG_FSL_LAYERSCAPE) || defined(CONFIG_S32V234) || \
275 addr = virt_to_phys((void *)(data->dest));
276 if (upper_32_bits(addr))
277 printf("Error found for upper 32 bits\n");
279 esdhc_write32(®s->dsaddr, lower_32_bits(addr));
281 esdhc_write32(®s->dsaddr, (u32)data->dest);
285 #ifndef CONFIG_SYS_FSL_ESDHC_USE_PIO
286 flush_dcache_range((ulong)data->src,
287 (ulong)data->src+data->blocks
290 if (wml_value > WML_WR_WML_MAX)
291 wml_value = WML_WR_WML_MAX_VAL;
292 if (priv->wp_enable) {
293 if ((esdhc_read32(®s->prsstat) &
294 PRSSTAT_WPSPL) == 0) {
295 printf("\nThe SD card is locked. Can not write to a locked card.\n\n");
300 esdhc_clrsetbits32(®s->wml, WML_WR_WML_MASK,
302 #ifndef CONFIG_SYS_FSL_ESDHC_USE_PIO
303 #if defined(CONFIG_FSL_LAYERSCAPE) || defined(CONFIG_S32V234) || \
305 addr = virt_to_phys((void *)(data->src));
306 if (upper_32_bits(addr))
307 printf("Error found for upper 32 bits\n");
309 esdhc_write32(®s->dsaddr, lower_32_bits(addr));
311 esdhc_write32(®s->dsaddr, (u32)data->src);
316 esdhc_write32(®s->blkattr, data->blocks << 16 | data->blocksize);
318 /* Calculate the timeout period for data transactions */
320 * 1)Timeout period = (2^(timeout+13)) SD Clock cycles
321 * 2)Timeout period should be minimum 0.250sec as per SD Card spec
322 * So, Number of SD Clock cycles for 0.25sec should be minimum
323 * (SD Clock/sec * 0.25 sec) SD Clock cycles
324 * = (mmc->clock * 1/4) SD Clock cycles
326 * => (2^(timeout+13)) >= mmc->clock * 1/4
327 * Taking log2 both the sides
328 * => timeout + 13 >= log2(mmc->clock/4)
329 * Rounding up to next power of 2
330 * => timeout + 13 = log2(mmc->clock/4) + 1
331 * => timeout + 13 = fls(mmc->clock/4)
333 * However, the MMC spec "It is strongly recommended for hosts to
334 * implement more than 500ms timeout value even if the card
335 * indicates the 250ms maximum busy length." Even the previous
336 * value of 300ms is known to be insufficient for some cards.
338 * => timeout + 13 = fls(mmc->clock/2)
340 timeout = fls(mmc->clock/2);
349 #ifdef CONFIG_SYS_FSL_ERRATUM_ESDHC_A001
350 if ((timeout == 4) || (timeout == 8) || (timeout == 12))
354 #ifdef ESDHCI_QUIRK_BROKEN_TIMEOUT_VALUE
357 esdhc_clrsetbits32(®s->sysctl, SYSCTL_TIMEOUT_MASK, timeout << 16);
362 static void check_and_invalidate_dcache_range
363 (struct mmc_cmd *cmd,
364 struct mmc_data *data) {
367 unsigned size = roundup(ARCH_DMA_MINALIGN,
368 data->blocks*data->blocksize);
369 #if defined(CONFIG_FSL_LAYERSCAPE) || defined(CONFIG_S32V234) || \
373 addr = virt_to_phys((void *)(data->dest));
374 if (upper_32_bits(addr))
375 printf("Error found for upper 32 bits\n");
377 start = lower_32_bits(addr);
379 start = (unsigned)data->dest;
382 invalidate_dcache_range(start, end);
386 * Sends a command out on the bus. Takes the mmc pointer,
387 * a command pointer, and an optional data pointer.
389 static int esdhc_send_cmd_common(struct fsl_esdhc_priv *priv, struct mmc *mmc,
390 struct mmc_cmd *cmd, struct mmc_data *data)
395 u32 flags = IRQSTAT_CC | IRQSTAT_CTOE;
396 struct fsl_esdhc *regs = priv->esdhc_regs;
398 #ifdef CONFIG_SYS_FSL_ERRATUM_ESDHC111
399 if (cmd->cmdidx == MMC_CMD_STOP_TRANSMISSION)
403 esdhc_write32(®s->irqstat, -1);
407 /* Wait for the bus to be idle */
408 while ((esdhc_read32(®s->prsstat) & PRSSTAT_CICHB) ||
409 (esdhc_read32(®s->prsstat) & PRSSTAT_CIDHB))
412 while (esdhc_read32(®s->prsstat) & PRSSTAT_DLA)
415 /* Wait at least 8 SD clock cycles before the next command */
417 * Note: This is way more than 8 cycles, but 1ms seems to
418 * resolve timing issues with some cards
422 /* Set up for a data transfer if we have one */
424 err = esdhc_setup_data(priv, mmc, data);
428 if (data->flags & MMC_DATA_READ)
429 check_and_invalidate_dcache_range(cmd, data);
432 /* Figure out the transfer arguments */
433 xfertyp = esdhc_xfertyp(cmd, data);
436 esdhc_write32(®s->irqsigen, 0);
438 /* Send the command */
439 esdhc_write32(®s->cmdarg, cmd->cmdarg);
440 #if defined(CONFIG_FSL_USDHC)
441 esdhc_write32(®s->mixctrl,
442 (esdhc_read32(®s->mixctrl) & 0xFFFFFF80) | (xfertyp & 0x7F)
443 | (mmc->ddr_mode ? XFERTYP_DDREN : 0));
444 esdhc_write32(®s->xfertyp, xfertyp & 0xFFFF0000);
446 esdhc_write32(®s->xfertyp, xfertyp);
449 if ((cmd->cmdidx == MMC_CMD_SEND_TUNING_BLOCK) ||
450 (cmd->cmdidx == MMC_CMD_SEND_TUNING_BLOCK_HS200))
453 /* Wait for the command to complete */
454 while (!(esdhc_read32(®s->irqstat) & flags))
457 irqstat = esdhc_read32(®s->irqstat);
459 if (irqstat & CMD_ERR) {
464 if (irqstat & IRQSTAT_CTOE) {
469 /* Switch voltage to 1.8V if CMD11 succeeded */
470 if (cmd->cmdidx == SD_CMD_SWITCH_UHS18V) {
471 esdhc_setbits32(®s->vendorspec, ESDHC_VENDORSPEC_VSELECT);
473 printf("Run CMD11 1.8V switch\n");
474 /* Sleep for 5 ms - max time for card to switch to 1.8V */
478 /* Workaround for ESDHC errata ENGcm03648 */
479 if (!data && (cmd->resp_type & MMC_RSP_BUSY)) {
482 /* Poll on DATA0 line for cmd with busy signal for 600 ms */
483 while (timeout > 0 && !(esdhc_read32(®s->prsstat) &
490 printf("Timeout waiting for DAT0 to go high!\n");
496 /* Copy the response to the response buffer */
497 if (cmd->resp_type & MMC_RSP_136) {
498 u32 cmdrsp3, cmdrsp2, cmdrsp1, cmdrsp0;
500 cmdrsp3 = esdhc_read32(®s->cmdrsp3);
501 cmdrsp2 = esdhc_read32(®s->cmdrsp2);
502 cmdrsp1 = esdhc_read32(®s->cmdrsp1);
503 cmdrsp0 = esdhc_read32(®s->cmdrsp0);
504 cmd->response[0] = (cmdrsp3 << 8) | (cmdrsp2 >> 24);
505 cmd->response[1] = (cmdrsp2 << 8) | (cmdrsp1 >> 24);
506 cmd->response[2] = (cmdrsp1 << 8) | (cmdrsp0 >> 24);
507 cmd->response[3] = (cmdrsp0 << 8);
509 cmd->response[0] = esdhc_read32(®s->cmdrsp0);
511 /* Wait until all of the blocks are transferred */
513 #ifdef CONFIG_SYS_FSL_ESDHC_USE_PIO
514 esdhc_pio_read_write(priv, data);
516 flags = DATA_COMPLETE;
517 if ((cmd->cmdidx == MMC_CMD_SEND_TUNING_BLOCK) ||
518 (cmd->cmdidx == MMC_CMD_SEND_TUNING_BLOCK_HS200)) {
523 irqstat = esdhc_read32(®s->irqstat);
525 if (irqstat & IRQSTAT_DTOE) {
530 if (irqstat & DATA_ERR) {
534 } while ((irqstat & flags) != flags);
537 * Need invalidate the dcache here again to avoid any
538 * cache-fill during the DMA operations such as the
539 * speculative pre-fetching etc.
541 if (data->flags & MMC_DATA_READ)
542 check_and_invalidate_dcache_range(cmd, data);
547 /* Reset CMD and DATA portions on error */
549 esdhc_write32(®s->sysctl, esdhc_read32(®s->sysctl) |
551 while (esdhc_read32(®s->sysctl) & SYSCTL_RSTC)
555 esdhc_write32(®s->sysctl,
556 esdhc_read32(®s->sysctl) |
558 while ((esdhc_read32(®s->sysctl) & SYSCTL_RSTD))
562 /* If this was CMD11, then notify that power cycle is needed */
563 if (cmd->cmdidx == SD_CMD_SWITCH_UHS18V)
564 printf("CMD11 to switch to 1.8V mode failed, card requires power cycle.\n");
567 esdhc_write32(®s->irqstat, -1);
572 static void set_sysctl(struct fsl_esdhc_priv *priv, struct mmc *mmc, uint clock)
574 struct fsl_esdhc *regs = priv->esdhc_regs;
578 /* For i.MX53 eSDHCv3, SYSCTL.SDCLKFS may not be set to 0. */
579 int pre_div = (regs == (struct fsl_esdhc *)MMC_SDHC3_BASE_ADDR) ? 2 : 1;
586 int ddr_pre_div = mmc->ddr_mode ? 2 : 1;
587 int sdhc_clk = priv->sdhc_clk;
590 if (clock < mmc->cfg->f_min)
591 clock = mmc->cfg->f_min;
593 while (sdhc_clk / (16 * pre_div * ddr_pre_div) > clock && pre_div < 256)
596 while (sdhc_clk / (div * pre_div * ddr_pre_div) > clock && div < 16)
602 clk = (pre_div << 8) | (div << 4);
604 #ifdef CONFIG_FSL_USDHC
605 esdhc_clrbits32(®s->vendorspec, VENDORSPEC_CKEN);
607 esdhc_clrbits32(®s->sysctl, SYSCTL_CKEN);
610 esdhc_clrsetbits32(®s->sysctl, SYSCTL_CLOCK_MASK, clk);
614 #ifdef CONFIG_FSL_USDHC
615 esdhc_setbits32(®s->vendorspec, VENDORSPEC_PEREN | VENDORSPEC_CKEN);
617 esdhc_setbits32(®s->sysctl, SYSCTL_PEREN | SYSCTL_CKEN);
623 #ifdef CONFIG_FSL_ESDHC_USE_PERIPHERAL_CLK
624 static void esdhc_clock_control(struct fsl_esdhc_priv *priv, bool enable)
626 struct fsl_esdhc *regs = priv->esdhc_regs;
630 value = esdhc_read32(®s->sysctl);
633 value |= SYSCTL_CKEN;
635 value &= ~SYSCTL_CKEN;
637 esdhc_write32(®s->sysctl, value);
640 value = PRSSTAT_SDSTB;
641 while (!(esdhc_read32(®s->prsstat) & value)) {
643 printf("fsl_esdhc: Internal clock never stabilised.\n");
652 #ifdef MMC_SUPPORTS_TUNING
653 static int esdhc_change_pinstate(struct udevice *dev)
655 struct fsl_esdhc_priv *priv = dev_get_priv(dev);
658 switch (priv->mode) {
661 ret = pinctrl_select_state(dev, "state_100mhz");
665 ret = pinctrl_select_state(dev, "state_200mhz");
668 ret = pinctrl_select_state(dev, "default");
673 printf("%s %d error\n", __func__, priv->mode);
678 static void esdhc_reset_tuning(struct mmc *mmc)
680 struct fsl_esdhc_priv *priv = dev_get_priv(mmc->dev);
681 struct fsl_esdhc *regs = priv->esdhc_regs;
683 if (priv->flags & ESDHC_FLAG_USDHC) {
684 if (priv->flags & ESDHC_FLAG_STD_TUNING) {
685 esdhc_clrbits32(®s->autoc12err,
686 MIX_CTRL_SMPCLK_SEL |
692 static int esdhc_set_timing(struct mmc *mmc)
694 struct fsl_esdhc_priv *priv = dev_get_priv(mmc->dev);
695 struct fsl_esdhc *regs = priv->esdhc_regs;
698 mixctrl = readl(®s->mixctrl);
699 mixctrl &= ~(MIX_CTRL_DDREN | MIX_CTRL_HS400_EN);
701 switch (mmc->selected_mode) {
704 esdhc_reset_tuning(mmc);
714 writel(mixctrl, ®s->mixctrl);
718 mixctrl |= MIX_CTRL_DDREN;
719 writel(mixctrl, ®s->mixctrl);
722 printf("Not supported %d\n", mmc->selected_mode);
726 priv->mode = mmc->selected_mode;
728 return esdhc_change_pinstate(mmc->dev);
731 static int esdhc_set_voltage(struct mmc *mmc)
733 struct fsl_esdhc_priv *priv = dev_get_priv(mmc->dev);
734 struct fsl_esdhc *regs = priv->esdhc_regs;
737 priv->signal_voltage = mmc->signal_voltage;
738 switch (mmc->signal_voltage) {
739 case MMC_SIGNAL_VOLTAGE_330:
740 if (priv->vs18_enable)
742 #ifdef CONFIG_DM_REGULATOR
743 if (!IS_ERR_OR_NULL(priv->vqmmc_dev)) {
744 ret = regulator_set_value(priv->vqmmc_dev, 3300000);
746 printf("Setting to 3.3V error");
754 esdhc_clrbits32(®s->vendorspec, ESDHC_VENDORSPEC_VSELECT);
755 if (!(esdhc_read32(®s->vendorspec) &
756 ESDHC_VENDORSPEC_VSELECT))
760 case MMC_SIGNAL_VOLTAGE_180:
761 #ifdef CONFIG_DM_REGULATOR
762 if (!IS_ERR_OR_NULL(priv->vqmmc_dev)) {
763 ret = regulator_set_value(priv->vqmmc_dev, 1800000);
765 printf("Setting to 1.8V error");
770 esdhc_setbits32(®s->vendorspec, ESDHC_VENDORSPEC_VSELECT);
771 if (esdhc_read32(®s->vendorspec) & ESDHC_VENDORSPEC_VSELECT)
775 case MMC_SIGNAL_VOLTAGE_120:
782 static void esdhc_stop_tuning(struct mmc *mmc)
786 cmd.cmdidx = MMC_CMD_STOP_TRANSMISSION;
788 cmd.resp_type = MMC_RSP_R1b;
790 dm_mmc_send_cmd(mmc->dev, &cmd, NULL);
793 static int fsl_esdhc_execute_tuning(struct udevice *dev, uint32_t opcode)
795 struct fsl_esdhc_plat *plat = dev_get_platdata(dev);
796 struct fsl_esdhc_priv *priv = dev_get_priv(dev);
797 struct fsl_esdhc *regs = priv->esdhc_regs;
798 struct mmc *mmc = &plat->mmc;
799 u32 irqstaten = readl(®s->irqstaten);
800 u32 irqsigen = readl(®s->irqsigen);
801 int i, ret = -ETIMEDOUT;
804 /* clock tuning is not needed for upto 52MHz */
805 if (mmc->clock <= 52000000)
808 /* This is readw/writew SDHCI_HOST_CONTROL2 when tuning */
809 if (priv->flags & ESDHC_FLAG_STD_TUNING) {
810 val = readl(®s->autoc12err);
811 mixctrl = readl(®s->mixctrl);
812 val &= ~MIX_CTRL_SMPCLK_SEL;
813 mixctrl &= ~(MIX_CTRL_FBCLK_SEL | MIX_CTRL_AUTO_TUNE_EN);
815 val |= MIX_CTRL_EXE_TUNE;
816 mixctrl |= MIX_CTRL_FBCLK_SEL | MIX_CTRL_AUTO_TUNE_EN;
818 writel(val, ®s->autoc12err);
819 writel(mixctrl, ®s->mixctrl);
822 /* sdhci_writew(host, SDHCI_TRNS_READ, SDHCI_TRANSFER_MODE); */
823 mixctrl = readl(®s->mixctrl);
824 mixctrl = MIX_CTRL_DTDSEL_READ | (mixctrl & ~MIX_CTRL_SDHCI_MASK);
825 writel(mixctrl, ®s->mixctrl);
827 writel(IRQSTATEN_BRR, ®s->irqstaten);
828 writel(IRQSTATEN_BRR, ®s->irqsigen);
831 * Issue opcode repeatedly till Execute Tuning is set to 0 or the number
832 * of loops reaches 40 times.
834 for (i = 0; i < MAX_TUNING_LOOP; i++) {
837 if (opcode == MMC_CMD_SEND_TUNING_BLOCK_HS200) {
838 if (mmc->bus_width == 8)
839 writel(0x7080, ®s->blkattr);
840 else if (mmc->bus_width == 4)
841 writel(0x7040, ®s->blkattr);
843 writel(0x7040, ®s->blkattr);
846 /* sdhci_writew(host, SDHCI_TRNS_READ, SDHCI_TRANSFER_MODE) */
847 val = readl(®s->mixctrl);
848 val = MIX_CTRL_DTDSEL_READ | (val & ~MIX_CTRL_SDHCI_MASK);
849 writel(val, ®s->mixctrl);
851 /* We are using STD tuning, no need to check return value */
852 mmc_send_tuning(mmc, opcode, NULL);
854 ctrl = readl(®s->autoc12err);
855 if ((!(ctrl & MIX_CTRL_EXE_TUNE)) &&
856 (ctrl & MIX_CTRL_SMPCLK_SEL)) {
858 * need to wait some time, make sure sd/mmc fininsh
859 * send out tuning data, otherwise, the sd/mmc can't
860 * response to any command when the card still out
861 * put the tuning data.
868 /* Add 1ms delay for SD and eMMC */
872 writel(irqstaten, ®s->irqstaten);
873 writel(irqsigen, ®s->irqsigen);
875 esdhc_stop_tuning(mmc);
881 static int esdhc_set_ios_common(struct fsl_esdhc_priv *priv, struct mmc *mmc)
883 struct fsl_esdhc *regs = priv->esdhc_regs;
884 int ret __maybe_unused;
886 #ifdef CONFIG_FSL_ESDHC_USE_PERIPHERAL_CLK
887 /* Select to use peripheral clock */
888 esdhc_clock_control(priv, false);
889 esdhc_setbits32(®s->scr, ESDHCCTL_PCS);
890 esdhc_clock_control(priv, true);
892 /* Set the clock speed */
893 if (priv->clock != mmc->clock)
894 set_sysctl(priv, mmc, mmc->clock);
896 #ifdef MMC_SUPPORTS_TUNING
897 if (mmc->clk_disable) {
898 #ifdef CONFIG_FSL_USDHC
899 esdhc_clrbits32(®s->vendorspec, VENDORSPEC_CKEN);
901 esdhc_clrbits32(®s->sysctl, SYSCTL_CKEN);
904 #ifdef CONFIG_FSL_USDHC
905 esdhc_setbits32(®s->vendorspec, VENDORSPEC_PEREN |
908 esdhc_setbits32(®s->sysctl, SYSCTL_PEREN | SYSCTL_CKEN);
912 if (priv->mode != mmc->selected_mode) {
913 ret = esdhc_set_timing(mmc);
915 printf("esdhc_set_timing error %d\n", ret);
920 if (priv->signal_voltage != mmc->signal_voltage) {
921 ret = esdhc_set_voltage(mmc);
923 printf("esdhc_set_voltage error %d\n", ret);
929 /* Set the bus width */
930 esdhc_clrbits32(®s->proctl, PROCTL_DTW_4 | PROCTL_DTW_8);
932 if (mmc->bus_width == 4)
933 esdhc_setbits32(®s->proctl, PROCTL_DTW_4);
934 else if (mmc->bus_width == 8)
935 esdhc_setbits32(®s->proctl, PROCTL_DTW_8);
940 static int esdhc_init_common(struct fsl_esdhc_priv *priv, struct mmc *mmc)
942 struct fsl_esdhc *regs = priv->esdhc_regs;
945 /* Reset the entire host controller */
946 esdhc_setbits32(®s->sysctl, SYSCTL_RSTA);
948 /* Wait until the controller is available */
949 start = get_timer(0);
950 while ((esdhc_read32(®s->sysctl) & SYSCTL_RSTA)) {
951 if (get_timer(start) > 1000)
955 #if defined(CONFIG_FSL_USDHC)
956 /* RSTA doesn't reset MMC_BOOT register, so manually reset it */
957 esdhc_write32(®s->mmcboot, 0x0);
958 /* Reset MIX_CTRL and CLK_TUNE_CTRL_STATUS regs to 0 */
959 esdhc_write32(®s->mixctrl, 0x0);
960 esdhc_write32(®s->clktunectrlstatus, 0x0);
962 /* Put VEND_SPEC to default value */
963 if (priv->vs18_enable)
964 esdhc_write32(®s->vendorspec, (VENDORSPEC_INIT |
965 ESDHC_VENDORSPEC_VSELECT));
967 esdhc_write32(®s->vendorspec, VENDORSPEC_INIT);
969 /* Disable DLL_CTRL delay line */
970 esdhc_write32(®s->dllctrl, 0x0);
974 /* Enable cache snooping */
975 esdhc_write32(®s->scr, 0x00000040);
978 #ifndef CONFIG_FSL_USDHC
979 esdhc_setbits32(®s->sysctl, SYSCTL_HCKEN | SYSCTL_IPGEN);
981 esdhc_setbits32(®s->vendorspec, VENDORSPEC_HCKEN | VENDORSPEC_IPGEN);
984 /* Set the initial clock speed */
985 mmc_set_clock(mmc, 400000, MMC_CLK_ENABLE);
987 /* Disable the BRR and BWR bits in IRQSTAT */
988 esdhc_clrbits32(®s->irqstaten, IRQSTATEN_BRR | IRQSTATEN_BWR);
990 /* Put the PROCTL reg back to the default */
991 esdhc_write32(®s->proctl, PROCTL_INIT);
993 /* Set timout to the maximum value */
994 esdhc_clrsetbits32(®s->sysctl, SYSCTL_TIMEOUT_MASK, 14 << 16);
999 static int esdhc_getcd_common(struct fsl_esdhc_priv *priv)
1001 struct fsl_esdhc *regs = priv->esdhc_regs;
1004 #ifdef CONFIG_ESDHC_DETECT_QUIRK
1005 if (CONFIG_ESDHC_DETECT_QUIRK)
1009 #if CONFIG_IS_ENABLED(DM_MMC)
1010 if (priv->non_removable)
1012 #ifdef CONFIG_DM_GPIO
1013 if (dm_gpio_is_valid(&priv->cd_gpio))
1014 return dm_gpio_get_value(&priv->cd_gpio);
1018 while (!(esdhc_read32(®s->prsstat) & PRSSTAT_CINS) && --timeout)
1024 static int esdhc_reset(struct fsl_esdhc *regs)
1028 /* reset the controller */
1029 esdhc_setbits32(®s->sysctl, SYSCTL_RSTA);
1031 /* hardware clears the bit when it is done */
1032 start = get_timer(0);
1033 while ((esdhc_read32(®s->sysctl) & SYSCTL_RSTA)) {
1034 if (get_timer(start) > 100) {
1035 printf("MMC/SD: Reset never completed.\n");
1043 #if !CONFIG_IS_ENABLED(DM_MMC)
1044 static int esdhc_getcd(struct mmc *mmc)
1046 struct fsl_esdhc_priv *priv = mmc->priv;
1048 return esdhc_getcd_common(priv);
1051 static int esdhc_init(struct mmc *mmc)
1053 struct fsl_esdhc_priv *priv = mmc->priv;
1055 return esdhc_init_common(priv, mmc);
1058 static int esdhc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd,
1059 struct mmc_data *data)
1061 struct fsl_esdhc_priv *priv = mmc->priv;
1063 return esdhc_send_cmd_common(priv, mmc, cmd, data);
1066 static int esdhc_set_ios(struct mmc *mmc)
1068 struct fsl_esdhc_priv *priv = mmc->priv;
1070 return esdhc_set_ios_common(priv, mmc);
1073 static const struct mmc_ops esdhc_ops = {
1074 .getcd = esdhc_getcd,
1076 .send_cmd = esdhc_send_cmd,
1077 .set_ios = esdhc_set_ios,
1081 static int fsl_esdhc_init(struct fsl_esdhc_priv *priv,
1082 struct fsl_esdhc_plat *plat)
1084 struct mmc_config *cfg;
1085 struct fsl_esdhc *regs;
1086 u32 caps, voltage_caps;
1092 regs = priv->esdhc_regs;
1094 /* First reset the eSDHC controller */
1095 ret = esdhc_reset(regs);
1099 #ifndef CONFIG_FSL_USDHC
1100 esdhc_setbits32(®s->sysctl, SYSCTL_PEREN | SYSCTL_HCKEN
1101 | SYSCTL_IPGEN | SYSCTL_CKEN);
1102 /* Clearing tuning bits in case ROM has set it already */
1103 esdhc_write32(®s->mixctrl, 0);
1104 esdhc_write32(®s->autoc12err, 0);
1105 esdhc_write32(®s->clktunectrlstatus, 0);
1107 esdhc_setbits32(®s->vendorspec, VENDORSPEC_PEREN |
1108 VENDORSPEC_HCKEN | VENDORSPEC_IPGEN | VENDORSPEC_CKEN);
1111 if (priv->vs18_enable)
1112 esdhc_setbits32(®s->vendorspec, ESDHC_VENDORSPEC_VSELECT);
1114 writel(SDHCI_IRQ_EN_BITS, ®s->irqstaten);
1116 #ifndef CONFIG_DM_MMC
1117 memset(cfg, '\0', sizeof(*cfg));
1121 caps = esdhc_read32(®s->hostcapblt);
1123 #ifdef CONFIG_SYS_FSL_ERRATUM_ESDHC135
1124 caps = caps & ~(ESDHC_HOSTCAPBLT_SRS |
1125 ESDHC_HOSTCAPBLT_VS18 | ESDHC_HOSTCAPBLT_VS30);
1128 /* T4240 host controller capabilities register should have VS33 bit */
1129 #ifdef CONFIG_SYS_FSL_MMC_HAS_CAPBLT_VS33
1130 caps = caps | ESDHC_HOSTCAPBLT_VS33;
1133 if (caps & ESDHC_HOSTCAPBLT_VS18)
1134 voltage_caps |= MMC_VDD_165_195;
1135 if (caps & ESDHC_HOSTCAPBLT_VS30)
1136 voltage_caps |= MMC_VDD_29_30 | MMC_VDD_30_31;
1137 if (caps & ESDHC_HOSTCAPBLT_VS33)
1138 voltage_caps |= MMC_VDD_32_33 | MMC_VDD_33_34;
1140 cfg->name = "FSL_SDHC";
1141 #if !CONFIG_IS_ENABLED(DM_MMC)
1142 cfg->ops = &esdhc_ops;
1144 #ifdef CONFIG_SYS_SD_VOLTAGE
1145 cfg->voltages = CONFIG_SYS_SD_VOLTAGE;
1147 cfg->voltages = MMC_VDD_32_33 | MMC_VDD_33_34;
1149 if ((cfg->voltages & voltage_caps) == 0) {
1150 printf("voltage not supported by controller\n");
1154 if (priv->bus_width == 8)
1155 cfg->host_caps = MMC_MODE_4BIT | MMC_MODE_8BIT;
1156 else if (priv->bus_width == 4)
1157 cfg->host_caps = MMC_MODE_4BIT;
1159 cfg->host_caps = MMC_MODE_4BIT | MMC_MODE_8BIT;
1160 #ifdef CONFIG_SYS_FSL_ESDHC_HAS_DDR_MODE
1161 cfg->host_caps |= MMC_MODE_DDR_52MHz;
1164 if (priv->bus_width > 0) {
1165 if (priv->bus_width < 8)
1166 cfg->host_caps &= ~MMC_MODE_8BIT;
1167 if (priv->bus_width < 4)
1168 cfg->host_caps &= ~MMC_MODE_4BIT;
1171 if (caps & ESDHC_HOSTCAPBLT_HSS)
1172 cfg->host_caps |= MMC_MODE_HS_52MHz | MMC_MODE_HS;
1174 #ifdef CONFIG_ESDHC_DETECT_8_BIT_QUIRK
1175 if (CONFIG_ESDHC_DETECT_8_BIT_QUIRK)
1176 cfg->host_caps &= ~MMC_MODE_8BIT;
1179 cfg->host_caps |= priv->caps;
1181 cfg->f_min = 400000;
1182 cfg->f_max = min(priv->sdhc_clk, (u32)200000000);
1184 cfg->b_max = CONFIG_SYS_MMC_MAX_BLK_COUNT;
1186 writel(0, ®s->dllctrl);
1187 if (priv->flags & ESDHC_FLAG_USDHC) {
1188 if (priv->flags & ESDHC_FLAG_STD_TUNING) {
1189 u32 val = readl(®s->tuning_ctrl);
1191 val |= ESDHC_STD_TUNING_EN;
1192 val &= ~ESDHC_TUNING_START_TAP_MASK;
1193 val |= priv->tuning_start_tap;
1194 val &= ~ESDHC_TUNING_STEP_MASK;
1195 val |= (priv->tuning_step) << ESDHC_TUNING_STEP_SHIFT;
1196 writel(val, ®s->tuning_ctrl);
1203 #if !CONFIG_IS_ENABLED(DM_MMC)
1204 static int fsl_esdhc_cfg_to_priv(struct fsl_esdhc_cfg *cfg,
1205 struct fsl_esdhc_priv *priv)
1210 priv->esdhc_regs = (struct fsl_esdhc *)(unsigned long)(cfg->esdhc_base);
1211 priv->bus_width = cfg->max_bus_width;
1212 priv->sdhc_clk = cfg->sdhc_clk;
1213 priv->wp_enable = cfg->wp_enable;
1214 priv->vs18_enable = cfg->vs18_enable;
1219 int fsl_esdhc_initialize(bd_t *bis, struct fsl_esdhc_cfg *cfg)
1221 struct fsl_esdhc_plat *plat;
1222 struct fsl_esdhc_priv *priv;
1229 priv = calloc(sizeof(struct fsl_esdhc_priv), 1);
1232 plat = calloc(sizeof(struct fsl_esdhc_plat), 1);
1238 ret = fsl_esdhc_cfg_to_priv(cfg, priv);
1240 debug("%s xlate failure\n", __func__);
1246 ret = fsl_esdhc_init(priv, plat);
1248 debug("%s init failure\n", __func__);
1254 mmc = mmc_create(&plat->cfg, priv);
1263 int fsl_esdhc_mmc_init(bd_t *bis)
1265 struct fsl_esdhc_cfg *cfg;
1267 cfg = calloc(sizeof(struct fsl_esdhc_cfg), 1);
1268 cfg->esdhc_base = CONFIG_SYS_FSL_ESDHC_ADDR;
1269 cfg->sdhc_clk = gd->arch.sdhc_clk;
1270 return fsl_esdhc_initialize(bis, cfg);
1274 #ifdef CONFIG_FSL_ESDHC_ADAPTER_IDENT
1275 void mmc_adapter_card_type_ident(void)
1280 card_id = QIXIS_READ(present) & QIXIS_SDID_MASK;
1281 gd->arch.sdhc_adapter = card_id;
1284 case QIXIS_ESDHC_ADAPTER_TYPE_EMMC45:
1285 value = QIXIS_READ(brdcfg[5]);
1286 value |= (QIXIS_DAT4 | QIXIS_DAT5_6_7);
1287 QIXIS_WRITE(brdcfg[5], value);
1289 case QIXIS_ESDHC_ADAPTER_TYPE_SDMMC_LEGACY:
1290 value = QIXIS_READ(pwr_ctl[1]);
1291 value |= QIXIS_EVDD_BY_SDHC_VS;
1292 QIXIS_WRITE(pwr_ctl[1], value);
1294 case QIXIS_ESDHC_ADAPTER_TYPE_EMMC44:
1295 value = QIXIS_READ(brdcfg[5]);
1296 value |= (QIXIS_SDCLKIN | QIXIS_SDCLKOUT);
1297 QIXIS_WRITE(brdcfg[5], value);
1299 case QIXIS_ESDHC_ADAPTER_TYPE_RSV:
1301 case QIXIS_ESDHC_ADAPTER_TYPE_MMC:
1303 case QIXIS_ESDHC_ADAPTER_TYPE_SD:
1305 case QIXIS_ESDHC_NO_ADAPTER:
1313 #ifdef CONFIG_OF_LIBFDT
1314 __weak int esdhc_status_fixup(void *blob, const char *compat)
1316 #ifdef CONFIG_FSL_ESDHC_PIN_MUX
1317 if (!hwconfig("esdhc")) {
1318 do_fixup_by_compat(blob, compat, "status", "disabled",
1319 sizeof("disabled"), 1);
1326 void fdt_fixup_esdhc(void *blob, bd_t *bd)
1328 const char *compat = "fsl,esdhc";
1330 if (esdhc_status_fixup(blob, compat))
1333 #ifdef CONFIG_FSL_ESDHC_USE_PERIPHERAL_CLK
1334 do_fixup_by_compat_u32(blob, compat, "peripheral-frequency",
1335 gd->arch.sdhc_clk, 1);
1337 do_fixup_by_compat_u32(blob, compat, "clock-frequency",
1338 gd->arch.sdhc_clk, 1);
1340 #ifdef CONFIG_FSL_ESDHC_ADAPTER_IDENT
1341 do_fixup_by_compat_u32(blob, compat, "adapter-type",
1342 (u32)(gd->arch.sdhc_adapter), 1);
1347 #if CONFIG_IS_ENABLED(DM_MMC)
1348 #include <asm/arch/clock.h>
1349 __weak void init_clk_usdhc(u32 index)
1353 static int fsl_esdhc_probe(struct udevice *dev)
1355 struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev);
1356 struct fsl_esdhc_plat *plat = dev_get_platdata(dev);
1357 struct fsl_esdhc_priv *priv = dev_get_priv(dev);
1358 const void *fdt = gd->fdt_blob;
1359 int node = dev_of_offset(dev);
1360 struct esdhc_soc_data *data =
1361 (struct esdhc_soc_data *)dev_get_driver_data(dev);
1362 #ifdef CONFIG_DM_REGULATOR
1363 struct udevice *vqmmc_dev;
1370 addr = dev_read_addr(dev);
1371 if (addr == FDT_ADDR_T_NONE)
1374 priv->esdhc_regs = (struct fsl_esdhc *)addr;
1378 priv->flags = data->flags;
1379 priv->caps = data->caps;
1382 val = dev_read_u32_default(dev, "bus-width", -1);
1384 priv->bus_width = 8;
1386 priv->bus_width = 4;
1388 priv->bus_width = 1;
1390 val = fdtdec_get_int(fdt, node, "fsl,tuning-step", 1);
1391 priv->tuning_step = val;
1392 val = fdtdec_get_int(fdt, node, "fsl,tuning-start-tap",
1393 ESDHC_TUNING_START_TAP_DEFAULT);
1394 priv->tuning_start_tap = val;
1395 val = fdtdec_get_int(fdt, node, "fsl,strobe-dll-delay-target",
1396 ESDHC_STROBE_DLL_CTRL_SLV_DLY_TARGET_DEFAULT);
1397 priv->strobe_dll_delay_target = val;
1399 if (dev_read_bool(dev, "non-removable")) {
1400 priv->non_removable = 1;
1402 priv->non_removable = 0;
1403 #ifdef CONFIG_DM_GPIO
1404 gpio_request_by_name(dev, "cd-gpios", 0, &priv->cd_gpio,
1409 priv->wp_enable = 1;
1411 #ifdef CONFIG_DM_GPIO
1412 ret = gpio_request_by_name(dev, "wp-gpios", 0, &priv->wp_gpio,
1415 priv->wp_enable = 0;
1418 priv->vs18_enable = 0;
1420 #ifdef CONFIG_DM_REGULATOR
1422 * If emmc I/O has a fixed voltage at 1.8V, this must be provided,
1423 * otherwise, emmc will work abnormally.
1425 ret = device_get_supply_regulator(dev, "vqmmc-supply", &vqmmc_dev);
1427 dev_dbg(dev, "no vqmmc-supply\n");
1429 ret = regulator_set_enable(vqmmc_dev, true);
1431 dev_err(dev, "fail to enable vqmmc-supply\n");
1435 if (regulator_get_value(vqmmc_dev) == 1800000)
1436 priv->vs18_enable = 1;
1440 if (fdt_get_property(fdt, node, "no-1-8-v", NULL))
1441 priv->caps &= ~(UHS_CAPS | MMC_MODE_HS200);
1445 * Because lack of clk driver, if SDHC clk is not enabled,
1446 * need to enable it first before this driver is invoked.
1448 * we use MXC_ESDHC_CLK to get clk freq.
1449 * If one would like to make this function work,
1450 * the aliases should be provided in dts as this:
1458 * Then if your board only supports mmc2 and mmc3, but we can
1459 * correctly get the seq as 2 and 3, then let mxc_get_clock
1463 init_clk_usdhc(dev->seq);
1465 priv->sdhc_clk = mxc_get_clock(MXC_ESDHC_CLK + dev->seq);
1466 if (priv->sdhc_clk <= 0) {
1467 dev_err(dev, "Unable to get clk for %s\n", dev->name);
1471 ret = fsl_esdhc_init(priv, plat);
1473 dev_err(dev, "fsl_esdhc_init failure\n");
1478 mmc->cfg = &plat->cfg;
1482 return esdhc_init_common(priv, mmc);
1485 #if CONFIG_IS_ENABLED(DM_MMC)
1486 static int fsl_esdhc_get_cd(struct udevice *dev)
1488 struct fsl_esdhc_priv *priv = dev_get_priv(dev);
1491 return esdhc_getcd_common(priv);
1494 static int fsl_esdhc_send_cmd(struct udevice *dev, struct mmc_cmd *cmd,
1495 struct mmc_data *data)
1497 struct fsl_esdhc_plat *plat = dev_get_platdata(dev);
1498 struct fsl_esdhc_priv *priv = dev_get_priv(dev);
1500 return esdhc_send_cmd_common(priv, &plat->mmc, cmd, data);
1503 static int fsl_esdhc_set_ios(struct udevice *dev)
1505 struct fsl_esdhc_plat *plat = dev_get_platdata(dev);
1506 struct fsl_esdhc_priv *priv = dev_get_priv(dev);
1508 return esdhc_set_ios_common(priv, &plat->mmc);
1511 static const struct dm_mmc_ops fsl_esdhc_ops = {
1512 .get_cd = fsl_esdhc_get_cd,
1513 .send_cmd = fsl_esdhc_send_cmd,
1514 .set_ios = fsl_esdhc_set_ios,
1515 #ifdef MMC_SUPPORTS_TUNING
1516 .execute_tuning = fsl_esdhc_execute_tuning,
1521 static struct esdhc_soc_data usdhc_imx7d_data = {
1522 .flags = ESDHC_FLAG_USDHC | ESDHC_FLAG_STD_TUNING
1523 | ESDHC_FLAG_HAVE_CAP1 | ESDHC_FLAG_HS200
1525 .caps = UHS_CAPS | MMC_MODE_HS200 | MMC_MODE_DDR_52MHz |
1526 MMC_MODE_HS_52MHz | MMC_MODE_HS,
1529 static const struct udevice_id fsl_esdhc_ids[] = {
1530 { .compatible = "fsl,imx6ul-usdhc", },
1531 { .compatible = "fsl,imx6sx-usdhc", },
1532 { .compatible = "fsl,imx6sl-usdhc", },
1533 { .compatible = "fsl,imx6q-usdhc", },
1534 { .compatible = "fsl,imx7d-usdhc", .data = (ulong)&usdhc_imx7d_data,},
1535 { .compatible = "fsl,imx7ulp-usdhc", },
1536 { .compatible = "fsl,esdhc", },
1540 #if CONFIG_IS_ENABLED(BLK)
1541 static int fsl_esdhc_bind(struct udevice *dev)
1543 struct fsl_esdhc_plat *plat = dev_get_platdata(dev);
1545 return mmc_bind(dev, &plat->mmc, &plat->cfg);
1549 U_BOOT_DRIVER(fsl_esdhc) = {
1550 .name = "fsl-esdhc-mmc",
1552 .of_match = fsl_esdhc_ids,
1553 .ops = &fsl_esdhc_ops,
1554 #if CONFIG_IS_ENABLED(BLK)
1555 .bind = fsl_esdhc_bind,
1557 .probe = fsl_esdhc_probe,
1558 .platdata_auto_alloc_size = sizeof(struct fsl_esdhc_plat),
1559 .priv_auto_alloc_size = sizeof(struct fsl_esdhc_priv),