1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2014 Wandboard
4 * Author: Tungyi Lin <tungyilin1127@gmail.com>
5 * Richard Hu <hakahu@gmail.com>
9 #include <asm/arch/clock.h>
10 #include <asm/arch/imx-regs.h>
11 #include <asm/arch/iomux.h>
12 #include <asm/arch/mx6-pins.h>
15 #include <asm/mach-imx/iomux-v3.h>
16 #include <asm/mach-imx/video.h>
18 #include <fsl_esdhc_imx.h>
19 #include <asm/arch/crm_regs.h>
21 #include <asm/arch/sys_proto.h>
25 #include <asm/arch/mx6-ddr.h>
32 #define IMX6DQ_DRIVE_STRENGTH 0x30
33 #define IMX6SDL_DRIVE_STRENGTH 0x28
35 /* configure MX6Q/DUAL mmdc DDR io registers */
36 static struct mx6dq_iomux_ddr_regs mx6dq_ddr_ioregs = {
37 .dram_sdclk_0 = IMX6DQ_DRIVE_STRENGTH,
38 .dram_sdclk_1 = IMX6DQ_DRIVE_STRENGTH,
39 .dram_cas = IMX6DQ_DRIVE_STRENGTH,
40 .dram_ras = IMX6DQ_DRIVE_STRENGTH,
41 .dram_reset = IMX6DQ_DRIVE_STRENGTH,
42 .dram_sdcke0 = IMX6DQ_DRIVE_STRENGTH,
43 .dram_sdcke1 = IMX6DQ_DRIVE_STRENGTH,
44 .dram_sdba2 = 0x00000000,
45 .dram_sdodt0 = IMX6DQ_DRIVE_STRENGTH,
46 .dram_sdodt1 = IMX6DQ_DRIVE_STRENGTH,
47 .dram_sdqs0 = IMX6DQ_DRIVE_STRENGTH,
48 .dram_sdqs1 = IMX6DQ_DRIVE_STRENGTH,
49 .dram_sdqs2 = IMX6DQ_DRIVE_STRENGTH,
50 .dram_sdqs3 = IMX6DQ_DRIVE_STRENGTH,
51 .dram_sdqs4 = IMX6DQ_DRIVE_STRENGTH,
52 .dram_sdqs5 = IMX6DQ_DRIVE_STRENGTH,
53 .dram_sdqs6 = IMX6DQ_DRIVE_STRENGTH,
54 .dram_sdqs7 = IMX6DQ_DRIVE_STRENGTH,
55 .dram_dqm0 = IMX6DQ_DRIVE_STRENGTH,
56 .dram_dqm1 = IMX6DQ_DRIVE_STRENGTH,
57 .dram_dqm2 = IMX6DQ_DRIVE_STRENGTH,
58 .dram_dqm3 = IMX6DQ_DRIVE_STRENGTH,
59 .dram_dqm4 = IMX6DQ_DRIVE_STRENGTH,
60 .dram_dqm5 = IMX6DQ_DRIVE_STRENGTH,
61 .dram_dqm6 = IMX6DQ_DRIVE_STRENGTH,
62 .dram_dqm7 = IMX6DQ_DRIVE_STRENGTH,
65 /* configure MX6Q/DUAL mmdc GRP io registers */
66 static struct mx6dq_iomux_grp_regs mx6dq_grp_ioregs = {
67 .grp_ddr_type = 0x000c0000,
68 .grp_ddrmode_ctl = 0x00020000,
69 .grp_ddrpke = 0x00000000,
70 .grp_addds = IMX6DQ_DRIVE_STRENGTH,
71 .grp_ctlds = IMX6DQ_DRIVE_STRENGTH,
72 .grp_ddrmode = 0x00020000,
73 .grp_b0ds = IMX6DQ_DRIVE_STRENGTH,
74 .grp_b1ds = IMX6DQ_DRIVE_STRENGTH,
75 .grp_b2ds = IMX6DQ_DRIVE_STRENGTH,
76 .grp_b3ds = IMX6DQ_DRIVE_STRENGTH,
77 .grp_b4ds = IMX6DQ_DRIVE_STRENGTH,
78 .grp_b5ds = IMX6DQ_DRIVE_STRENGTH,
79 .grp_b6ds = IMX6DQ_DRIVE_STRENGTH,
80 .grp_b7ds = IMX6DQ_DRIVE_STRENGTH,
83 /* configure MX6SOLO/DUALLITE mmdc DDR io registers */
84 struct mx6sdl_iomux_ddr_regs mx6sdl_ddr_ioregs = {
85 .dram_sdclk_0 = IMX6SDL_DRIVE_STRENGTH,
86 .dram_sdclk_1 = IMX6SDL_DRIVE_STRENGTH,
87 .dram_cas = IMX6SDL_DRIVE_STRENGTH,
88 .dram_ras = IMX6SDL_DRIVE_STRENGTH,
89 .dram_reset = IMX6SDL_DRIVE_STRENGTH,
90 .dram_sdcke0 = IMX6SDL_DRIVE_STRENGTH,
91 .dram_sdcke1 = IMX6SDL_DRIVE_STRENGTH,
92 .dram_sdba2 = 0x00000000,
93 .dram_sdodt0 = IMX6SDL_DRIVE_STRENGTH,
94 .dram_sdodt1 = IMX6SDL_DRIVE_STRENGTH,
95 .dram_sdqs0 = IMX6SDL_DRIVE_STRENGTH,
96 .dram_sdqs1 = IMX6SDL_DRIVE_STRENGTH,
97 .dram_sdqs2 = IMX6SDL_DRIVE_STRENGTH,
98 .dram_sdqs3 = IMX6SDL_DRIVE_STRENGTH,
99 .dram_sdqs4 = IMX6SDL_DRIVE_STRENGTH,
100 .dram_sdqs5 = IMX6SDL_DRIVE_STRENGTH,
101 .dram_sdqs6 = IMX6SDL_DRIVE_STRENGTH,
102 .dram_sdqs7 = IMX6SDL_DRIVE_STRENGTH,
103 .dram_dqm0 = IMX6SDL_DRIVE_STRENGTH,
104 .dram_dqm1 = IMX6SDL_DRIVE_STRENGTH,
105 .dram_dqm2 = IMX6SDL_DRIVE_STRENGTH,
106 .dram_dqm3 = IMX6SDL_DRIVE_STRENGTH,
107 .dram_dqm4 = IMX6SDL_DRIVE_STRENGTH,
108 .dram_dqm5 = IMX6SDL_DRIVE_STRENGTH,
109 .dram_dqm6 = IMX6SDL_DRIVE_STRENGTH,
110 .dram_dqm7 = IMX6SDL_DRIVE_STRENGTH,
113 /* configure MX6SOLO/DUALLITE mmdc GRP io registers */
114 struct mx6sdl_iomux_grp_regs mx6sdl_grp_ioregs = {
115 .grp_ddr_type = 0x000c0000,
116 .grp_ddrmode_ctl = 0x00020000,
117 .grp_ddrpke = 0x00000000,
118 .grp_addds = IMX6SDL_DRIVE_STRENGTH,
119 .grp_ctlds = IMX6SDL_DRIVE_STRENGTH,
120 .grp_ddrmode = 0x00020000,
121 .grp_b0ds = IMX6SDL_DRIVE_STRENGTH,
122 .grp_b1ds = IMX6SDL_DRIVE_STRENGTH,
123 .grp_b2ds = IMX6SDL_DRIVE_STRENGTH,
124 .grp_b3ds = IMX6SDL_DRIVE_STRENGTH,
125 .grp_b4ds = IMX6SDL_DRIVE_STRENGTH,
126 .grp_b5ds = IMX6SDL_DRIVE_STRENGTH,
127 .grp_b6ds = IMX6SDL_DRIVE_STRENGTH,
128 .grp_b7ds = IMX6SDL_DRIVE_STRENGTH,
132 static struct mx6_ddr3_cfg h5t04g63afr = {
146 static struct mx6_ddr3_cfg h5tq2g63dfr = {
159 static struct mx6_mmdc_calibration mx6q_2g_mmdc_calib = {
160 .p0_mpwldectrl0 = 0x001f001f,
161 .p0_mpwldectrl1 = 0x001f001f,
162 .p1_mpwldectrl0 = 0x001f001f,
163 .p1_mpwldectrl1 = 0x001f001f,
164 .p0_mpdgctrl0 = 0x4301030d,
165 .p0_mpdgctrl1 = 0x03020277,
166 .p1_mpdgctrl0 = 0x4300030a,
167 .p1_mpdgctrl1 = 0x02780248,
168 .p0_mprddlctl = 0x4536393b,
169 .p1_mprddlctl = 0x36353441,
170 .p0_mpwrdlctl = 0x41414743,
171 .p1_mpwrdlctl = 0x462f453f,
175 static struct mx6_ddr_sysinfo mem_q = {
178 /* config for full 4GB range so that get_mem_size() works */
191 static struct mx6_mmdc_calibration mx6dl_1g_mmdc_calib = {
192 .p0_mpwldectrl0 = 0x001f001f,
193 .p0_mpwldectrl1 = 0x001f001f,
194 .p1_mpwldectrl0 = 0x001f001f,
195 .p1_mpwldectrl1 = 0x001f001f,
196 .p0_mpdgctrl0 = 0x420e020e,
197 .p0_mpdgctrl1 = 0x02000200,
198 .p1_mpdgctrl0 = 0x42020202,
199 .p1_mpdgctrl1 = 0x01720172,
200 .p0_mprddlctl = 0x494c4f4c,
201 .p1_mprddlctl = 0x4a4c4c49,
202 .p0_mpwrdlctl = 0x3f3f3133,
203 .p1_mpwrdlctl = 0x39373f2e,
206 static struct mx6_mmdc_calibration mx6s_512m_mmdc_calib = {
207 .p0_mpwldectrl0 = 0x0040003c,
208 .p0_mpwldectrl1 = 0x0032003e,
209 .p0_mpdgctrl0 = 0x42350231,
210 .p0_mpdgctrl1 = 0x021a0218,
211 .p0_mprddlctl = 0x4b4b4e49,
212 .p0_mpwrdlctl = 0x3f3f3035,
216 static struct mx6_ddr_sysinfo mem_dl = {
219 /* config for full 4GB range so that get_mem_size() works */
232 /* DDR 32bit 512MB */
233 static struct mx6_ddr_sysinfo mem_s = {
236 /* config for full 4GB range so that get_mem_size() works */
249 static void ccgr_init(void)
251 struct mxc_ccm_reg *ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR;
253 writel(0x00C03F3F, &ccm->CCGR0);
254 writel(0x0030FC03, &ccm->CCGR1);
255 writel(0x0FFFC000, &ccm->CCGR2);
256 writel(0x3FF00000, &ccm->CCGR3);
257 writel(0x00FFF300, &ccm->CCGR4);
258 writel(0x0F0000C3, &ccm->CCGR5);
259 writel(0x000003FF, &ccm->CCGR6);
262 static void spl_dram_init(void)
264 if (is_cpu_type(MXC_CPU_MX6SOLO)) {
265 mx6sdl_dram_iocfg(32, &mx6sdl_ddr_ioregs, &mx6sdl_grp_ioregs);
266 mx6_dram_cfg(&mem_s, &mx6s_512m_mmdc_calib, &h5tq2g63dfr);
267 } else if (is_cpu_type(MXC_CPU_MX6DL)) {
268 mx6sdl_dram_iocfg(64, &mx6sdl_ddr_ioregs, &mx6sdl_grp_ioregs);
269 mx6_dram_cfg(&mem_dl, &mx6dl_1g_mmdc_calib, &h5tq2g63dfr);
270 } else if (is_cpu_type(MXC_CPU_MX6Q)) {
271 mx6dq_dram_iocfg(64, &mx6dq_ddr_ioregs, &mx6dq_grp_ioregs);
272 mx6_dram_cfg(&mem_q, &mx6q_2g_mmdc_calib, &h5t04g63afr);
278 static void setup_spi(void)
280 enable_spi_clk(true, 2);
283 #define UART_PAD_CTRL (PAD_CTL_PUS_100K_UP | \
284 PAD_CTL_SPEED_MED | PAD_CTL_DSE_40ohm | \
285 PAD_CTL_SRE_FAST | PAD_CTL_HYS)
287 static iomux_v3_cfg_t const uart1_pads[] = {
288 IOMUX_PADS(PAD_CSI0_DAT10__UART1_TX_DATA | MUX_PAD_CTRL(UART_PAD_CTRL)),
289 IOMUX_PADS(PAD_CSI0_DAT11__UART1_RX_DATA | MUX_PAD_CTRL(UART_PAD_CTRL)),
292 static void setup_iomux_uart(void)
294 SETUP_IOMUX_PADS(uart1_pads);
297 void board_init_f(ulong dummy)
301 /* setup AIPS and disable watchdog */
312 /* UART clocks enabled and gd valid - init serial console */
313 preloader_console_init();
315 /* enable ECSPI clocks */
318 /* DDR initialization */
322 void board_boot_order(u32 *spl_boot_list)
324 switch (spl_boot_device()) {
325 case BOOT_DEVICE_MMC2:
326 case BOOT_DEVICE_MMC1:
327 spl_boot_list[0] = BOOT_DEVICE_MMC2;
328 spl_boot_list[1] = BOOT_DEVICE_MMC1;
331 case BOOT_DEVICE_NOR:
332 spl_boot_list[0] = BOOT_DEVICE_NOR;
337 #ifdef CONFIG_SPL_LOAD_FIT
338 int board_fit_config_name_match(const char *name)
344 #ifdef CONFIG_SPL_OS_BOOT
345 int spl_start_uboot(void)
350 * We use BOOT_DEVICE_MMC1, but SD card is connected
353 * Correct "mapping" is delivered in board defined
354 * board_boot_order() function.
356 * SD card boot is regarded as a "development" one,
357 * hence we _always_ go through the u-boot.
360 if (spl_boot_device() == BOOT_DEVICE_MMC1)
363 /* break into full u-boot on 'c' */
364 if (serial_tstc() && serial_getc() == 'c')
368 ret = env_get_f("boot_os", s, sizeof(s));
369 if ((ret != -1) && (strcmp(s, "no") == 0))
373 * Check if SWUpdate recovery needs to be started
375 * recovery_status = NULL (not set - ret == -1) -> normal operation
377 * recovery_status = progress or
378 * recovery_status = failed or
379 * recovery_status = <any value> -> start SWUpdate
382 ret = env_get_f("recovery_status", s, sizeof(s));
388 #endif /* CONFIG_SPL_OS_BOOT */
390 #define WEIM_NOR_PAD_CTRL (PAD_CTL_PKE | PAD_CTL_PUE | \
391 PAD_CTL_PUS_100K_UP | PAD_CTL_SPEED_MED | \
392 PAD_CTL_DSE_40ohm | PAD_CTL_SRE_FAST)
394 #define NOR_WP IMX_GPIO_NR(1, 1)
396 static iomux_v3_cfg_t const eimnor_pads[] = {
397 IOMUX_PADS(PAD_EIM_D16__EIM_DATA16 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
398 IOMUX_PADS(PAD_EIM_D17__EIM_DATA17 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
399 IOMUX_PADS(PAD_EIM_D18__EIM_DATA18 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
400 IOMUX_PADS(PAD_EIM_D19__EIM_DATA19 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
401 IOMUX_PADS(PAD_EIM_D20__EIM_DATA20 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
402 IOMUX_PADS(PAD_EIM_D21__EIM_DATA21 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
403 IOMUX_PADS(PAD_EIM_D22__EIM_DATA22 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
404 IOMUX_PADS(PAD_EIM_D23__EIM_DATA23 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
405 IOMUX_PADS(PAD_EIM_D24__EIM_DATA24 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
406 IOMUX_PADS(PAD_EIM_D25__EIM_DATA25 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
407 IOMUX_PADS(PAD_EIM_D26__EIM_DATA26 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
408 IOMUX_PADS(PAD_EIM_D27__EIM_DATA27 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
409 IOMUX_PADS(PAD_EIM_D28__EIM_DATA28 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
410 IOMUX_PADS(PAD_EIM_D29__EIM_DATA29 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
411 IOMUX_PADS(PAD_EIM_D30__EIM_DATA30 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
412 IOMUX_PADS(PAD_EIM_D31__EIM_DATA31 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
413 IOMUX_PADS(PAD_EIM_DA0__EIM_AD00 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
414 IOMUX_PADS(PAD_EIM_DA1__EIM_AD01 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
415 IOMUX_PADS(PAD_EIM_DA2__EIM_AD02 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
416 IOMUX_PADS(PAD_EIM_DA3__EIM_AD03 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
417 IOMUX_PADS(PAD_EIM_DA4__EIM_AD04 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
418 IOMUX_PADS(PAD_EIM_DA5__EIM_AD05 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
419 IOMUX_PADS(PAD_EIM_DA6__EIM_AD06 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
420 IOMUX_PADS(PAD_EIM_DA7__EIM_AD07 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
421 IOMUX_PADS(PAD_EIM_DA8__EIM_AD08 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
422 IOMUX_PADS(PAD_EIM_DA9__EIM_AD09 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
423 IOMUX_PADS(PAD_EIM_DA10__EIM_AD10 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
424 IOMUX_PADS(PAD_EIM_DA11__EIM_AD11 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
425 IOMUX_PADS(PAD_EIM_DA12__EIM_AD12 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
426 IOMUX_PADS(PAD_EIM_DA13__EIM_AD13 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
427 IOMUX_PADS(PAD_EIM_DA14__EIM_AD14 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
428 IOMUX_PADS(PAD_EIM_DA15__EIM_AD15 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
429 IOMUX_PADS(PAD_EIM_A16__EIM_ADDR16 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
430 IOMUX_PADS(PAD_EIM_A17__EIM_ADDR17 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
431 IOMUX_PADS(PAD_EIM_A18__EIM_ADDR18 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
432 IOMUX_PADS(PAD_EIM_A19__EIM_ADDR19 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
433 IOMUX_PADS(PAD_EIM_A20__EIM_ADDR20 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
434 IOMUX_PADS(PAD_EIM_A21__EIM_ADDR21 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
435 IOMUX_PADS(PAD_EIM_A22__EIM_ADDR22 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
436 IOMUX_PADS(PAD_EIM_A23__EIM_ADDR23 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
437 IOMUX_PADS(PAD_EIM_A24__EIM_ADDR24 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
438 IOMUX_PADS(PAD_EIM_A25__EIM_ADDR25 | MUX_PAD_CTRL(WEIM_NOR_PAD_CTRL)),
439 IOMUX_PADS(PAD_EIM_OE__EIM_OE_B | MUX_PAD_CTRL(NO_PAD_CTRL)),
440 IOMUX_PADS(PAD_EIM_RW__EIM_RW | MUX_PAD_CTRL(NO_PAD_CTRL)),
441 IOMUX_PADS(PAD_EIM_CS0__EIM_CS0_B | MUX_PAD_CTRL(NO_PAD_CTRL)),
442 IOMUX_PADS(PAD_GPIO_1__GPIO1_IO01 | MUX_PAD_CTRL(NO_PAD_CTRL)),
445 static void eimnor_cs_setup(void)
447 struct weim *weim_regs = (struct weim *)WEIM_BASE_ADDR;
449 /* NOR configuration */
450 writel(0x00620181, &weim_regs->cs0gcr1);
451 writel(0x00000001, &weim_regs->cs0gcr2);
452 writel(0x0b020000, &weim_regs->cs0rcr1);
453 writel(0x0000b000, &weim_regs->cs0rcr2);
454 writel(0x0804a240, &weim_regs->cs0wcr1);
455 writel(0x00000000, &weim_regs->cs0wcr2);
457 writel(0x00000120, &weim_regs->wcr);
458 writel(0x00000010, &weim_regs->wiar);
459 writel(0x00000000, &weim_regs->ear);
461 set_chipselect_size(CS0_128);
464 static void setup_eimnor(void)
466 SETUP_IOMUX_PADS(eimnor_pads);
467 gpio_direction_output(NOR_WP, 1);
473 #define USDHC_PAD_CTRL (PAD_CTL_PUS_47K_UP | \
474 PAD_CTL_SPEED_LOW | PAD_CTL_DSE_80ohm | \
475 PAD_CTL_SRE_FAST | PAD_CTL_HYS)
477 #define USDHC2_CD_GPIO IMX_GPIO_NR(1, 4)
479 static iomux_v3_cfg_t const usdhc2_pads[] = {
480 IOMUX_PADS(PAD_SD2_CLK__SD2_CLK | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
481 IOMUX_PADS(PAD_SD2_CMD__SD2_CMD | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
482 IOMUX_PADS(PAD_SD2_DAT0__SD2_DATA0 | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
483 IOMUX_PADS(PAD_SD2_DAT1__SD2_DATA1 | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
484 IOMUX_PADS(PAD_SD2_DAT2__SD2_DATA2 | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
485 IOMUX_PADS(PAD_SD2_DAT3__SD2_DATA3 | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
486 /* Carrier MicroSD Card Detect */
487 IOMUX_PADS(PAD_GPIO_4__GPIO1_IO04 | MUX_PAD_CTRL(NO_PAD_CTRL)),
490 static iomux_v3_cfg_t const usdhc3_pads[] = {
491 IOMUX_PADS(PAD_SD3_CLK__SD3_CLK | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
492 IOMUX_PADS(PAD_SD3_CMD__SD3_CMD | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
493 IOMUX_PADS(PAD_SD3_DAT0__SD3_DATA0 | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
494 IOMUX_PADS(PAD_SD3_DAT1__SD3_DATA1 | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
495 IOMUX_PADS(PAD_SD3_DAT2__SD3_DATA2 | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
496 IOMUX_PADS(PAD_SD3_DAT3__SD3_DATA3 | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
497 IOMUX_PADS(PAD_SD3_DAT4__SD3_DATA4 | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
498 IOMUX_PADS(PAD_SD3_DAT5__SD3_DATA5 | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
499 IOMUX_PADS(PAD_SD3_DAT6__SD3_DATA6 | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
500 IOMUX_PADS(PAD_SD3_DAT7__SD3_DATA7 | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
501 IOMUX_PADS(PAD_SD3_RST__SD3_RESET | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
504 static struct fsl_esdhc_cfg usdhc_cfg[2] = {
509 int board_mmc_getcd(struct mmc *mmc)
511 struct fsl_esdhc_cfg *cfg = (struct fsl_esdhc_cfg *)mmc->priv;
514 switch (cfg->esdhc_base) {
515 case USDHC2_BASE_ADDR:
516 ret = !gpio_get_value(USDHC2_CD_GPIO);
518 case USDHC3_BASE_ADDR:
520 * eMMC don't have card detect pin - since it is soldered to the
529 int board_mmc_init(bd_t *bis)
536 * (U-Boot device node) (Physical Port)
537 * mmc0 Soldered on board eMMC device
540 for (index = 0; index < CONFIG_SYS_FSL_USDHC_NUM; ++index) {
543 SETUP_IOMUX_PADS(usdhc3_pads);
544 usdhc_cfg[0].sdhc_clk = mxc_get_clock(MXC_ESDHC3_CLK);
545 usdhc_cfg[0].max_bus_width = 8;
548 SETUP_IOMUX_PADS(usdhc2_pads);
549 usdhc_cfg[1].sdhc_clk = mxc_get_clock(MXC_ESDHC_CLK);
550 usdhc_cfg[1].max_bus_width = 4;
551 gpio_direction_input(USDHC2_CD_GPIO);
554 printf("Warning: More USDHC controllers (%d) than supported (%d)\n",
555 index + 1, CONFIG_SYS_FSL_USDHC_NUM);
559 ret = fsl_esdhc_initialize(bis, &usdhc_cfg[index]);
567 #ifdef CONFIG_SPL_BOARD_INIT
568 #define DISPLAY_EN IMX_GPIO_NR(1, 2)
569 void spl_board_init(void)
573 gpio_direction_output(DISPLAY_EN, 1);
575 #endif /* CONFIG_SPL_BOARD_INIT */