1 // SPDX-License-Identifier: GPL-2.0+
3 * (C) Copyright 2009 Freescale Semiconductor, Inc.
8 #include <asm/global_data.h>
11 #include <asm/arch/imx-regs.h>
12 #include <asm/arch/iomux-mx51.h>
13 #include <linux/delay.h>
14 #include <linux/errno.h>
15 #include <asm/arch/sys_proto.h>
16 #include <asm/arch/crm_regs.h>
17 #include <asm/arch/clock.h>
18 #include <asm/mach-imx/mx5_video.h>
22 #include <fsl_esdhc_imx.h>
23 #include <power/pmic.h>
26 #include <usb/ehci-ci.h>
28 DECLARE_GLOBAL_DATA_PTR;
32 /* dram_init must store complete ramsize in gd->ram_size */
33 gd->ram_size = get_ram_size((void *)CFG_SYS_SDRAM_BASE,
38 #ifdef CONFIG_REVISION_TAG
39 u32 get_board_rev(void)
41 u32 rev = get_cpu_rev();
42 if (!gpio_get_value(IMX_GPIO_NR(1, 22)))
43 rev |= BOARD_REV_2_0 << BOARD_VER_OFFSET;
48 #define UART_PAD_CTRL (PAD_CTL_HYS | PAD_CTL_PUS_100K_DOWN | PAD_CTL_DSE_HIGH)
50 static void setup_iomux_uart(void)
52 static const iomux_v3_cfg_t uart_pads[] = {
53 MX51_PAD_UART1_RXD__UART1_RXD,
54 MX51_PAD_UART1_TXD__UART1_TXD,
55 NEW_PAD_CTRL(MX51_PAD_UART1_RTS__UART1_RTS, UART_PAD_CTRL),
56 NEW_PAD_CTRL(MX51_PAD_UART1_CTS__UART1_CTS, UART_PAD_CTRL),
59 imx_iomux_v3_setup_multiple_pads(uart_pads, ARRAY_SIZE(uart_pads));
63 static void setup_iomux_spi(void)
65 static const iomux_v3_cfg_t spi_pads[] = {
66 NEW_PAD_CTRL(MX51_PAD_CSPI1_MOSI__ECSPI1_MOSI, PAD_CTL_HYS |
67 PAD_CTL_DSE_HIGH | PAD_CTL_SRE_FAST),
68 NEW_PAD_CTRL(MX51_PAD_CSPI1_MISO__ECSPI1_MISO, PAD_CTL_HYS |
69 PAD_CTL_DSE_HIGH | PAD_CTL_SRE_FAST),
70 NEW_PAD_CTRL(MX51_PAD_CSPI1_SS1__ECSPI1_SS1,
72 MX51_PAD_CSPI1_SS0__ECSPI1_SS0,
73 NEW_PAD_CTRL(MX51_PAD_CSPI1_RDY__ECSPI1_RDY, MX51_PAD_CTRL_2),
74 NEW_PAD_CTRL(MX51_PAD_CSPI1_SCLK__ECSPI1_SCLK, PAD_CTL_HYS |
75 PAD_CTL_DSE_HIGH | PAD_CTL_SRE_FAST),
78 imx_iomux_v3_setup_multiple_pads(spi_pads, ARRAY_SIZE(spi_pads));
82 static void power_init(void)
85 struct mxc_ccm_reg *mxc_ccm = (struct mxc_ccm_reg *)MXC_CCM_BASE;
89 ret = pmic_init(CFG_FSL_PMIC_BUS);
93 p = pmic_get("FSL_PMIC");
97 /* Write needed to Power Gate 2 register */
98 pmic_reg_read(p, REG_POWER_MISC, &val);
100 pmic_reg_write(p, REG_POWER_MISC, val);
102 /* Externally powered */
103 pmic_reg_read(p, REG_CHARGE, &val);
104 val |= ICHRG0 | ICHRG1 | ICHRG2 | ICHRG3 | CHGAUTOB;
105 pmic_reg_write(p, REG_CHARGE, val);
107 /* power up the system first */
108 pmic_reg_write(p, REG_POWER_MISC, PWUP);
110 /* Set core voltage to 1.1V */
111 pmic_reg_read(p, REG_SW_0, &val);
112 val = (val & ~SWx_VOLT_MASK) | SWx_1_100V;
113 pmic_reg_write(p, REG_SW_0, val);
115 /* Setup VCC (SW2) to 1.25 */
116 pmic_reg_read(p, REG_SW_1, &val);
117 val = (val & ~SWx_VOLT_MASK) | SWx_1_250V;
118 pmic_reg_write(p, REG_SW_1, val);
120 /* Setup 1V2_DIG1 (SW3) to 1.25 */
121 pmic_reg_read(p, REG_SW_2, &val);
122 val = (val & ~SWx_VOLT_MASK) | SWx_1_250V;
123 pmic_reg_write(p, REG_SW_2, val);
126 /* Raise the core frequency to 800MHz */
127 writel(0x0, &mxc_ccm->cacrr);
129 /* Set switchers in Auto in NORMAL mode & STANDBY mode */
130 /* Setup the switcher mode for SW1 & SW2*/
131 pmic_reg_read(p, REG_SW_4, &val);
132 val = (val & ~((SWMODE_MASK << SWMODE1_SHIFT) |
133 (SWMODE_MASK << SWMODE2_SHIFT)));
134 val |= (SWMODE_AUTO_AUTO << SWMODE1_SHIFT) |
135 (SWMODE_AUTO_AUTO << SWMODE2_SHIFT);
136 pmic_reg_write(p, REG_SW_4, val);
138 /* Setup the switcher mode for SW3 & SW4 */
139 pmic_reg_read(p, REG_SW_5, &val);
140 val = (val & ~((SWMODE_MASK << SWMODE3_SHIFT) |
141 (SWMODE_MASK << SWMODE4_SHIFT)));
142 val |= (SWMODE_AUTO_AUTO << SWMODE3_SHIFT) |
143 (SWMODE_AUTO_AUTO << SWMODE4_SHIFT);
144 pmic_reg_write(p, REG_SW_5, val);
146 /* Set VDIG to 1.65V, VGEN3 to 1.8V, VCAM to 2.6V */
147 pmic_reg_read(p, REG_SETTING_0, &val);
148 val &= ~(VCAM_MASK | VGEN3_MASK | VDIG_MASK);
149 val |= VDIG_1_65 | VGEN3_1_8 | VCAM_2_6;
150 pmic_reg_write(p, REG_SETTING_0, val);
152 /* Set VVIDEO to 2.775V, VAUDIO to 3V, VSD to 3.15V */
153 pmic_reg_read(p, REG_SETTING_1, &val);
154 val &= ~(VVIDEO_MASK | VSD_MASK | VAUDIO_MASK);
155 val |= VSD_3_15 | VAUDIO_3_0 | VVIDEO_2_775;
156 pmic_reg_write(p, REG_SETTING_1, val);
158 /* Configure VGEN3 and VCAM regulators to use external PNP */
159 val = VGEN3CONFIG | VCAMCONFIG;
160 pmic_reg_write(p, REG_MODE_1, val);
163 /* Enable VGEN3, VCAM, VAUDIO, VVIDEO, VSD regulators */
164 val = VGEN3EN | VGEN3CONFIG | VCAMEN | VCAMCONFIG |
165 VVIDEOEN | VAUDIOEN | VSDEN;
166 pmic_reg_write(p, REG_MODE_1, val);
168 imx_iomux_v3_setup_pad(NEW_PAD_CTRL(MX51_PAD_EIM_A20__GPIO2_14,
170 gpio_request(IMX_GPIO_NR(2, 14), "gpio2_14");
171 gpio_direction_output(IMX_GPIO_NR(2, 14), 0);
175 gpio_set_value(IMX_GPIO_NR(2, 14), 1);
178 int board_early_init_f(void)
188 /* address of boot parameters */
189 gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
194 #ifdef CONFIG_BOARD_LATE_INIT
195 int board_late_init(void)
197 #ifdef CONFIG_MXC_SPI
207 * Do not overwrite the console
208 * Use always serial for U-Boot console
210 int overwrite_console(void)
217 puts("Board: MX51EVK\n");