3 * Heiko Schocher, DENX Software Engineering, hs@denx.de.
6 * Copyright (C) 2012 Freescale Semiconductor, Inc.
8 * Author: Fabio Estevam <fabio.estevam@freescale.com>
10 * SPDX-License-Identifier: GPL-2.0+
13 #include <asm/arch/clock.h>
14 #include <asm/arch/imx-regs.h>
15 #include <asm/arch/iomux.h>
16 #include <asm/arch/mx6-pins.h>
17 #include <asm/errno.h>
19 #include <asm/imx-common/iomux-v3.h>
20 #include <asm/imx-common/boot_mode.h>
21 #include <asm/imx-common/mxc_i2c.h>
22 #include <asm/imx-common/video.h>
24 #include <fsl_esdhc.h>
27 #include <asm/arch/mxc_hdmi.h>
28 #include <asm/arch/crm_regs.h>
30 #include <ipu_pixfmt.h>
32 #include <asm/arch/sys_proto.h>
37 #include <../drivers/video/ipu.h>
38 #if defined(CONFIG_VIDEO_BMP_LOGO)
42 #define USDHC2_PAD_CTRL (PAD_CTL_SPEED_LOW | \
43 PAD_CTL_DSE_40ohm | PAD_CTL_SRE_FAST)
45 #define ECSPI1_CS0 IMX_GPIO_NR(4, 9) /* 4.3 display controller */
46 #define ECSPI4_CS0 IMX_GPIO_NR(3, 29)
47 #define SOFT_RESET_GPIO IMX_GPIO_NR(7, 13)
48 #define SD2_DRIVER_ENABLE IMX_GPIO_NR(7, 8)
50 struct i2c_pads_info i2c_pad_info3 = {
52 .i2c_mode = MX6_PAD_GPIO_5__I2C3_SCL | PC,
53 .gpio_mode = MX6_PAD_GPIO_5__GPIO1_IO05 | PC,
54 .gp = IMX_GPIO_NR(1, 5)
57 .i2c_mode = MX6_PAD_GPIO_6__I2C3_SDA | PC,
58 .gpio_mode = MX6_PAD_GPIO_6__GPIO1_IO06 | PC,
59 .gp = IMX_GPIO_NR(1, 6)
63 struct i2c_pads_info i2c_pad_info4 = {
65 .i2c_mode = MX6_PAD_GPIO_7__I2C4_SCL | PC,
66 .gpio_mode = MX6_PAD_GPIO_7__GPIO1_IO07 | PC,
67 .gp = IMX_GPIO_NR(1, 7)
70 .i2c_mode = MX6_PAD_GPIO_8__I2C4_SDA | PC,
71 .gpio_mode = MX6_PAD_GPIO_8__GPIO1_IO08 | PC,
72 .gp = IMX_GPIO_NR(1, 8)
76 iomux_v3_cfg_t const uart1_pads[] = {
77 MX6_PAD_CSI0_DAT10__UART1_TX_DATA | MUX_PAD_CTRL(UART_PAD_CTRL),
78 MX6_PAD_CSI0_DAT11__UART1_RX_DATA | MUX_PAD_CTRL(UART_PAD_CTRL),
79 MX6_PAD_EIM_D19__UART1_CTS_B | MUX_PAD_CTRL(UART_PAD_CTRL),
80 MX6_PAD_EIM_D20__UART1_RTS_B | MUX_PAD_CTRL(UART_PAD_CTRL),
83 iomux_v3_cfg_t const uart2_pads[] = {
84 MX6_PAD_EIM_D26__UART2_TX_DATA | MUX_PAD_CTRL(UART_PAD_CTRL),
85 MX6_PAD_EIM_D27__UART2_RX_DATA | MUX_PAD_CTRL(UART_PAD_CTRL),
88 iomux_v3_cfg_t const uart3_pads[] = {
89 MX6_PAD_EIM_D24__UART3_TX_DATA | MUX_PAD_CTRL(UART_PAD_CTRL),
90 MX6_PAD_EIM_D25__UART3_RX_DATA | MUX_PAD_CTRL(UART_PAD_CTRL),
91 MX6_PAD_EIM_D31__UART3_RTS_B | MUX_PAD_CTRL(UART_PAD_CTRL),
92 MX6_PAD_EIM_D23__UART3_CTS_B | MUX_PAD_CTRL(UART_PAD_CTRL),
95 iomux_v3_cfg_t const uart4_pads[] = {
96 MX6_PAD_KEY_COL0__UART4_TX_DATA | MUX_PAD_CTRL(UART_PAD_CTRL),
97 MX6_PAD_KEY_ROW0__UART4_RX_DATA | MUX_PAD_CTRL(UART_PAD_CTRL),
100 iomux_v3_cfg_t const gpio_pads[] = {
102 MX6_PAD_ENET_CRS_DV__GPIO1_IO25 | MUX_PAD_CTRL(NO_PAD_CTRL),
104 MX6_PAD_NANDF_CS3__GPIO6_IO16 | MUX_PAD_CTRL(NO_PAD_CTRL),
106 MX6_PAD_EIM_EB0__GPIO2_IO28 | MUX_PAD_CTRL(NO_PAD_CTRL),
108 MX6_PAD_EIM_A24__GPIO5_IO04 | MUX_PAD_CTRL(NO_PAD_CTRL),
110 MX6_PAD_EIM_EB1__GPIO2_IO29 | MUX_PAD_CTRL(NO_PAD_CTRL),
111 /* spi flash WP protect */
112 MX6_PAD_SD4_DAT7__GPIO2_IO15 | MUX_PAD_CTRL(NO_PAD_CTRL),
114 MX6_PAD_EIM_D29__GPIO3_IO29 | MUX_PAD_CTRL(NO_PAD_CTRL),
115 /* spi bus #2 SS driver enable */
116 MX6_PAD_EIM_A23__GPIO6_IO06 | MUX_PAD_CTRL(NO_PAD_CTRL),
117 /* RST_LOC# PHY reset input (has pull-down!)*/
118 MX6_PAD_GPIO_18__GPIO7_IO13 | MUX_PAD_CTRL(NO_PAD_CTRL),
119 /* SD 2 level shifter output enable */
120 MX6_PAD_SD3_RST__GPIO7_IO08 | MUX_PAD_CTRL(NO_PAD_CTRL),
121 /* SD1 card detect input */
122 MX6_PAD_ENET_RXD0__GPIO1_IO27 | MUX_PAD_CTRL(NO_PAD_CTRL),
123 /* SD1 write protect input */
124 MX6_PAD_DI0_PIN4__GPIO4_IO20 | MUX_PAD_CTRL(NO_PAD_CTRL),
125 /* SD2 card detect input */
126 MX6_PAD_GPIO_19__GPIO4_IO05 | MUX_PAD_CTRL(NO_PAD_CTRL),
127 /* SD2 write protect input */
128 MX6_PAD_SD4_DAT2__GPIO2_IO10 | MUX_PAD_CTRL(NO_PAD_CTRL),
129 /* Touchscreen IRQ */
130 MX6_PAD_SD4_DAT1__GPIO2_IO09 | MUX_PAD_CTRL(NO_PAD_CTRL),
133 static iomux_v3_cfg_t const misc_pads[] = {
134 /* USB_OTG_ID = GPIO1_24*/
135 MX6_PAD_ENET_RX_ER__USB_OTG_ID | MUX_PAD_CTRL(NO_PAD_CTRL),
136 /* H1 Power enable = GPIO1_0*/
137 MX6_PAD_GPIO_0__USB_H1_PWR | MUX_PAD_CTRL(NO_PAD_CTRL),
138 /* OTG Power enable = GPIO4_15*/
139 MX6_PAD_KEY_ROW4__USB_OTG_PWR | MUX_PAD_CTRL(NO_PAD_CTRL),
142 iomux_v3_cfg_t const enet_pads[] = {
143 MX6_PAD_ENET_MDIO__ENET_MDIO | MUX_PAD_CTRL(ENET_PAD_CTRL),
144 MX6_PAD_ENET_MDC__ENET_MDC | MUX_PAD_CTRL(ENET_PAD_CTRL),
145 MX6_PAD_RGMII_TXC__RGMII_TXC | MUX_PAD_CTRL(ENET_PAD_CTRL),
146 MX6_PAD_RGMII_TD0__RGMII_TD0 | MUX_PAD_CTRL(ENET_PAD_CTRL),
147 MX6_PAD_RGMII_TD1__RGMII_TD1 | MUX_PAD_CTRL(ENET_PAD_CTRL),
148 MX6_PAD_RGMII_TD2__RGMII_TD2 | MUX_PAD_CTRL(ENET_PAD_CTRL),
149 MX6_PAD_RGMII_TD3__RGMII_TD3 | MUX_PAD_CTRL(ENET_PAD_CTRL),
150 MX6_PAD_RGMII_TX_CTL__RGMII_TX_CTL | MUX_PAD_CTRL(ENET_PAD_CTRL),
151 MX6_PAD_ENET_REF_CLK__ENET_TX_CLK | MUX_PAD_CTRL(ENET_PAD_CTRL),
152 MX6_PAD_RGMII_RXC__RGMII_RXC | MUX_PAD_CTRL(ENET_PAD_CTRL),
153 MX6_PAD_RGMII_RD0__RGMII_RD0 | MUX_PAD_CTRL(ENET_PAD_CTRL),
154 MX6_PAD_RGMII_RD1__RGMII_RD1 | MUX_PAD_CTRL(ENET_PAD_CTRL),
155 MX6_PAD_RGMII_RD2__RGMII_RD2 | MUX_PAD_CTRL(ENET_PAD_CTRL),
156 MX6_PAD_RGMII_RD3__RGMII_RD3 | MUX_PAD_CTRL(ENET_PAD_CTRL),
157 MX6_PAD_RGMII_RX_CTL__RGMII_RX_CTL | MUX_PAD_CTRL(ENET_PAD_CTRL),
160 static iomux_v3_cfg_t const backlight_pads[] = {
161 /* backlight PWM brightness control */
162 MX6_PAD_GPIO_9__PWM1_OUT | MUX_PAD_CTRL(NO_PAD_CTRL),
163 /* backlight enable */
164 MX6_PAD_EIM_BCLK__GPIO6_IO31 | MUX_PAD_CTRL(NO_PAD_CTRL),
165 /* LCD power enable */
166 MX6_PAD_NANDF_CS2__GPIO6_IO15 | MUX_PAD_CTRL(NO_PAD_CTRL),
169 static iomux_v3_cfg_t const ecspi1_pads[] = {
170 MX6_PAD_EIM_D16__ECSPI1_SCLK | MUX_PAD_CTRL(SPI_PAD_CTRL),
171 MX6_PAD_EIM_D17__ECSPI1_MISO | MUX_PAD_CTRL(SPI_PAD_CTRL),
172 MX6_PAD_EIM_D18__ECSPI1_MOSI | MUX_PAD_CTRL(SPI_PAD_CTRL),
173 MX6_PAD_KEY_ROW1__GPIO4_IO09 | MUX_PAD_CTRL(SPI_PAD_CTRL),
176 static void setup_iomux_enet(void)
178 imx_iomux_v3_setup_multiple_pads(enet_pads, ARRAY_SIZE(enet_pads));
181 iomux_v3_cfg_t const ecspi4_pads[] = {
182 MX6_PAD_EIM_D21__ECSPI4_SCLK | MUX_PAD_CTRL(NO_PAD_CTRL),
183 MX6_PAD_EIM_D22__ECSPI4_MISO | MUX_PAD_CTRL(NO_PAD_CTRL),
184 MX6_PAD_EIM_D28__ECSPI4_MOSI | MUX_PAD_CTRL(NO_PAD_CTRL),
185 MX6_PAD_EIM_A25__GPIO5_IO02 | MUX_PAD_CTRL(NO_PAD_CTRL),
186 MX6_PAD_EIM_D29__GPIO3_IO29 | MUX_PAD_CTRL(NO_PAD_CTRL),
189 static iomux_v3_cfg_t const display_pads[] = {
190 MX6_PAD_DI0_DISP_CLK__IPU1_DI0_DISP_CLK | MUX_PAD_CTRL(DISP_PAD_CTRL),
191 MX6_PAD_DI0_PIN15__IPU1_DI0_PIN15,
192 MX6_PAD_DI0_PIN2__IPU1_DI0_PIN02,
193 MX6_PAD_DI0_PIN3__IPU1_DI0_PIN03,
194 MX6_PAD_DI0_PIN4__GPIO4_IO20,
195 MX6_PAD_DISP0_DAT0__IPU1_DISP0_DATA00,
196 MX6_PAD_DISP0_DAT1__IPU1_DISP0_DATA01,
197 MX6_PAD_DISP0_DAT2__IPU1_DISP0_DATA02,
198 MX6_PAD_DISP0_DAT3__IPU1_DISP0_DATA03,
199 MX6_PAD_DISP0_DAT4__IPU1_DISP0_DATA04,
200 MX6_PAD_DISP0_DAT5__IPU1_DISP0_DATA05,
201 MX6_PAD_DISP0_DAT6__IPU1_DISP0_DATA06,
202 MX6_PAD_DISP0_DAT7__IPU1_DISP0_DATA07,
203 MX6_PAD_DISP0_DAT8__IPU1_DISP0_DATA08,
204 MX6_PAD_DISP0_DAT9__IPU1_DISP0_DATA09,
205 MX6_PAD_DISP0_DAT10__IPU1_DISP0_DATA10,
206 MX6_PAD_DISP0_DAT11__IPU1_DISP0_DATA11,
207 MX6_PAD_DISP0_DAT12__IPU1_DISP0_DATA12,
208 MX6_PAD_DISP0_DAT13__IPU1_DISP0_DATA13,
209 MX6_PAD_DISP0_DAT14__IPU1_DISP0_DATA14,
210 MX6_PAD_DISP0_DAT15__IPU1_DISP0_DATA15,
211 MX6_PAD_DISP0_DAT16__IPU1_DISP0_DATA16,
212 MX6_PAD_DISP0_DAT17__IPU1_DISP0_DATA17,
213 MX6_PAD_DISP0_DAT18__IPU1_DISP0_DATA18,
214 MX6_PAD_DISP0_DAT19__IPU1_DISP0_DATA19,
215 MX6_PAD_DISP0_DAT20__IPU1_DISP0_DATA20,
216 MX6_PAD_DISP0_DAT21__IPU1_DISP0_DATA21,
217 MX6_PAD_DISP0_DAT22__IPU1_DISP0_DATA22,
218 MX6_PAD_DISP0_DAT23__IPU1_DISP0_DATA23,
221 int board_spi_cs_gpio(unsigned bus, unsigned cs)
223 if (bus == CONFIG_SF_DEFAULT_BUS && cs == CONFIG_SF_DEFAULT_CS)
224 return IMX_GPIO_NR(5, 2);
226 if (bus == 0 && cs == 0)
227 return IMX_GPIO_NR(4, 9);
232 static void setup_spi(void)
236 imx_iomux_v3_setup_multiple_pads(ecspi1_pads, ARRAY_SIZE(ecspi1_pads));
237 imx_iomux_v3_setup_multiple_pads(ecspi4_pads, ARRAY_SIZE(ecspi4_pads));
238 for (i = 0; i < 4; i++)
239 enable_spi_clk(true, i);
241 gpio_direction_output(ECSPI1_CS0, 1);
242 gpio_direction_output(ECSPI4_CS1, 0);
244 /* set cs0 to high (second device on spi bus #4) */
245 gpio_direction_output(ECSPI4_CS0, 1);
248 static void setup_iomux_uart(void)
250 switch (CONFIG_MXC_UART_BASE) {
252 imx_iomux_v3_setup_multiple_pads(uart1_pads,
253 ARRAY_SIZE(uart1_pads));
256 imx_iomux_v3_setup_multiple_pads(uart2_pads,
257 ARRAY_SIZE(uart2_pads));
260 imx_iomux_v3_setup_multiple_pads(uart3_pads,
261 ARRAY_SIZE(uart3_pads));
264 imx_iomux_v3_setup_multiple_pads(uart4_pads,
265 ARRAY_SIZE(uart4_pads));
270 int board_phy_config(struct phy_device *phydev)
272 /* control data pad skew - devaddr = 0x02, register = 0x04 */
273 ksz9031_phy_extended_write(phydev, 0x02,
274 MII_KSZ9031_EXT_RGMII_CTRL_SIG_SKEW,
275 MII_KSZ9031_MOD_DATA_NO_POST_INC, 0x0000);
276 /* rx data pad skew - devaddr = 0x02, register = 0x05 */
277 ksz9031_phy_extended_write(phydev, 0x02,
278 MII_KSZ9031_EXT_RGMII_RX_DATA_SKEW,
279 MII_KSZ9031_MOD_DATA_NO_POST_INC, 0x0000);
280 /* tx data pad skew - devaddr = 0x02, register = 0x06 */
281 ksz9031_phy_extended_write(phydev, 0x02,
282 MII_KSZ9031_EXT_RGMII_TX_DATA_SKEW,
283 MII_KSZ9031_MOD_DATA_NO_POST_INC, 0x0000);
284 /* gtx and rx clock pad skew - devaddr = 0x02, register = 0x08 */
285 ksz9031_phy_extended_write(phydev, 0x02,
286 MII_KSZ9031_EXT_RGMII_CLOCK_SKEW,
287 MII_KSZ9031_MOD_DATA_NO_POST_INC, 0x03FF);
289 if (phydev->drv->config)
290 phydev->drv->config(phydev);
295 int board_eth_init(bd_t *bis)
298 return cpu_eth_init(bis);
301 static int rotate_logo_one(unsigned char *out, unsigned char *in)
305 for (i = 0; i < BMP_LOGO_WIDTH; i++)
306 for (j = 0; j < BMP_LOGO_HEIGHT; j++)
307 out[j * BMP_LOGO_WIDTH + BMP_LOGO_HEIGHT - 1 - i] =
308 in[i * BMP_LOGO_WIDTH + j];
313 * Rotate the BMP_LOGO (only)
314 * Will only work, if the logo is square, as
315 * BMP_LOGO_HEIGHT and BMP_LOGO_WIDTH are defines, not variables
317 void rotate_logo(int rotations)
319 unsigned char out_logo[BMP_LOGO_WIDTH * BMP_LOGO_HEIGHT];
320 unsigned char *in_logo;
323 if (BMP_LOGO_WIDTH != BMP_LOGO_HEIGHT)
326 in_logo = bmp_logo_bitmap;
328 /* one 90 degree rotation */
329 if (rotations == 1 || rotations == 2 || rotations == 3)
330 rotate_logo_one(out_logo, in_logo);
332 /* second 90 degree rotation */
333 if (rotations == 2 || rotations == 3)
334 rotate_logo_one(in_logo, out_logo);
336 /* third 90 degree rotation */
338 rotate_logo_one(out_logo, in_logo);
340 /* copy result back to original array */
341 if (rotations == 1 || rotations == 3)
342 for (i = 0; i < BMP_LOGO_WIDTH; i++)
343 for (j = 0; j < BMP_LOGO_HEIGHT; j++)
344 in_logo[i * BMP_LOGO_WIDTH + j] =
345 out_logo[i * BMP_LOGO_WIDTH + j];
348 static void enable_display_power(void)
350 imx_iomux_v3_setup_multiple_pads(backlight_pads,
351 ARRAY_SIZE(backlight_pads));
353 /* backlight enable */
354 gpio_direction_output(IMX_GPIO_NR(6, 31), 1);
355 /* LCD power enable */
356 gpio_direction_output(IMX_GPIO_NR(6, 15), 1);
358 /* enable backlight PWM 1 */
359 if (pwm_init(0, 0, 0))
361 /* duty cycle 500ns, period: 3000ns */
362 if (pwm_config(0, 50000, 300000))
369 puts("error init pwm for backlight\n");
373 static void enable_lvds(struct display_info_t const *dev)
375 struct iomuxc *iomux = (struct iomuxc *)IOMUXC_BASE_ADDR;
376 struct mxc_ccm_reg *ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR;
378 s32 timeout = 100000;
381 reg = readl(&ccm->analog_pll_video);
382 reg |= BM_ANADIG_PLL_VIDEO_POWERDOWN;
383 writel(reg, &ccm->analog_pll_video);
385 /* set PLL5 to 232720000Hz */
386 reg &= ~BM_ANADIG_PLL_VIDEO_DIV_SELECT;
387 reg |= BF_ANADIG_PLL_VIDEO_DIV_SELECT(0x26);
388 reg &= ~BM_ANADIG_PLL_VIDEO_POST_DIV_SELECT;
389 reg |= BF_ANADIG_PLL_VIDEO_POST_DIV_SELECT(0);
390 writel(reg, &ccm->analog_pll_video);
392 writel(BF_ANADIG_PLL_VIDEO_NUM_A(0xC0238),
393 &ccm->analog_pll_video_num);
394 writel(BF_ANADIG_PLL_VIDEO_DENOM_B(0xF4240),
395 &ccm->analog_pll_video_denom);
397 reg &= ~BM_ANADIG_PLL_VIDEO_POWERDOWN;
398 writel(reg, &ccm->analog_pll_video);
401 if (readl(&ccm->analog_pll_video) & BM_ANADIG_PLL_VIDEO_LOCK)
404 printf("Warning: video pll lock timeout!\n");
406 reg = readl(&ccm->analog_pll_video);
407 reg |= BM_ANADIG_PLL_VIDEO_ENABLE;
408 reg &= ~BM_ANADIG_PLL_VIDEO_BYPASS;
409 writel(reg, &ccm->analog_pll_video);
411 /* set LDB0, LDB1 clk select to 000/000 (PLL5 clock) */
412 reg = readl(&ccm->cs2cdr);
413 reg &= ~(MXC_CCM_CS2CDR_LDB_DI0_CLK_SEL_MASK
414 | MXC_CCM_CS2CDR_LDB_DI1_CLK_SEL_MASK);
415 reg |= (0 << MXC_CCM_CS2CDR_LDB_DI0_CLK_SEL_OFFSET)
416 | (0 << MXC_CCM_CS2CDR_LDB_DI1_CLK_SEL_OFFSET);
417 writel(reg, &ccm->cs2cdr);
419 reg = readl(&ccm->cscmr2);
420 reg |= MXC_CCM_CSCMR2_LDB_DI0_IPU_DIV;
421 writel(reg, &ccm->cscmr2);
423 reg = readl(&ccm->chsccdr);
424 reg |= (CHSCCDR_CLK_SEL_LDB_DI0
425 << MXC_CCM_CHSCCDR_IPU1_DI0_CLK_SEL_OFFSET);
426 writel(reg, &ccm->chsccdr);
428 reg = IOMUXC_GPR2_BGREF_RRMODE_EXTERNAL_RES
429 | IOMUXC_GPR2_DI1_VS_POLARITY_ACTIVE_HIGH
430 | IOMUXC_GPR2_DI0_VS_POLARITY_ACTIVE_HIGH
431 | IOMUXC_GPR2_BIT_MAPPING_CH0_SPWG
432 | IOMUXC_GPR2_DATA_WIDTH_CH0_24BIT
433 | IOMUXC_GPR2_LVDS_CH1_MODE_DISABLED
434 | IOMUXC_GPR2_LVDS_CH0_MODE_ENABLED_DI0;
435 writel(reg, &iomux->gpr[2]);
437 reg = readl(&iomux->gpr[3]);
438 reg = (reg & ~IOMUXC_GPR3_LVDS0_MUX_CTL_MASK)
439 | (IOMUXC_GPR3_MUX_SRC_IPU1_DI0
440 << IOMUXC_GPR3_LVDS0_MUX_CTL_OFFSET);
441 writel(reg, &iomux->gpr[3]);
446 static void enable_spi_display(struct display_info_t const *dev)
448 struct iomuxc *iomux = (struct iomuxc *)IOMUXC_BASE_ADDR;
449 struct mxc_ccm_reg *ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR;
451 s32 timeout = 100000;
453 #if defined(CONFIG_VIDEO_BMP_LOGO)
454 rotate_logo(3); /* portrait display in landscape mode */
458 * set ldb clock to 28341000 Hz calculated through the formula:
459 * (XRES + LEFT_M + RIGHT_M + HSYNC_LEN) *
460 * (YRES + UPPER_M + LOWER_M + VSYNC_LEN) * REFRESH)
462 * https://community.freescale.com/thread/308170
464 ipu_set_ldb_clock(28341000);
466 reg = readl(&ccm->cs2cdr);
468 /* select pll 5 clock */
469 reg &= ~(MXC_CCM_CS2CDR_LDB_DI0_CLK_SEL_MASK
470 | MXC_CCM_CS2CDR_LDB_DI1_CLK_SEL_MASK);
471 writel(reg, &ccm->cs2cdr);
473 /* set PLL5 to 197994996Hz */
474 reg &= ~BM_ANADIG_PLL_VIDEO_DIV_SELECT;
475 reg |= BF_ANADIG_PLL_VIDEO_DIV_SELECT(0x21);
476 reg &= ~BM_ANADIG_PLL_VIDEO_POST_DIV_SELECT;
477 reg |= BF_ANADIG_PLL_VIDEO_POST_DIV_SELECT(0);
478 writel(reg, &ccm->analog_pll_video);
480 writel(BF_ANADIG_PLL_VIDEO_NUM_A(0xfbf4),
481 &ccm->analog_pll_video_num);
482 writel(BF_ANADIG_PLL_VIDEO_DENOM_B(0xf4240),
483 &ccm->analog_pll_video_denom);
485 reg &= ~BM_ANADIG_PLL_VIDEO_POWERDOWN;
486 writel(reg, &ccm->analog_pll_video);
489 if (readl(&ccm->analog_pll_video) & BM_ANADIG_PLL_VIDEO_LOCK)
492 printf("Warning: video pll lock timeout!\n");
494 reg = readl(&ccm->analog_pll_video);
495 reg |= BM_ANADIG_PLL_VIDEO_ENABLE;
496 reg &= ~BM_ANADIG_PLL_VIDEO_BYPASS;
497 writel(reg, &ccm->analog_pll_video);
499 /* set LDB0, LDB1 clk select to 000/000 (PLL5 clock) */
500 reg = readl(&ccm->cs2cdr);
501 reg &= ~(MXC_CCM_CS2CDR_LDB_DI0_CLK_SEL_MASK
502 | MXC_CCM_CS2CDR_LDB_DI1_CLK_SEL_MASK);
503 reg |= (0 << MXC_CCM_CS2CDR_LDB_DI0_CLK_SEL_OFFSET)
504 | (0 << MXC_CCM_CS2CDR_LDB_DI1_CLK_SEL_OFFSET);
505 writel(reg, &ccm->cs2cdr);
507 reg = readl(&ccm->cscmr2);
508 reg |= MXC_CCM_CSCMR2_LDB_DI0_IPU_DIV;
509 writel(reg, &ccm->cscmr2);
511 reg = readl(&ccm->chsccdr);
512 reg |= (CHSCCDR_CLK_SEL_LDB_DI0
513 << MXC_CCM_CHSCCDR_IPU1_DI0_CLK_SEL_OFFSET);
514 reg &= ~MXC_CCM_CHSCCDR_IPU1_DI0_PODF_MASK;
515 reg |= (2 << MXC_CCM_CHSCCDR_IPU1_DI0_PODF_OFFSET);
516 reg &= ~MXC_CCM_CHSCCDR_IPU1_DI0_PRE_CLK_SEL_MASK;
517 reg |= (2 << MXC_CCM_CHSCCDR_IPU1_DI0_PRE_CLK_SEL_OFFSET);
518 writel(reg, &ccm->chsccdr);
520 reg = IOMUXC_GPR2_BGREF_RRMODE_EXTERNAL_RES
521 | IOMUXC_GPR2_DI1_VS_POLARITY_ACTIVE_HIGH
522 | IOMUXC_GPR2_DI0_VS_POLARITY_ACTIVE_HIGH
523 | IOMUXC_GPR2_BIT_MAPPING_CH0_SPWG
524 | IOMUXC_GPR2_DATA_WIDTH_CH0_24BIT
525 | IOMUXC_GPR2_LVDS_CH1_MODE_DISABLED
526 | IOMUXC_GPR2_LVDS_CH0_MODE_ENABLED_DI0;
527 writel(reg, &iomux->gpr[2]);
529 reg = readl(&iomux->gpr[3]);
530 reg = (reg & ~IOMUXC_GPR3_LVDS0_MUX_CTL_MASK)
531 | (IOMUXC_GPR3_MUX_SRC_IPU1_DI0
532 << IOMUXC_GPR3_LVDS0_MUX_CTL_OFFSET);
533 writel(reg, &iomux->gpr[3]);
535 imx_iomux_v3_setup_multiple_pads(
537 ARRAY_SIZE(display_pads));
541 static void setup_display(void)
544 enable_display_power();
547 static void setup_iomux_gpio(void)
549 imx_iomux_v3_setup_multiple_pads(gpio_pads, ARRAY_SIZE(gpio_pads));
552 int board_early_init_f(void)
557 gpio_direction_output(SOFT_RESET_GPIO, 1);
558 gpio_direction_output(SD2_DRIVER_ENABLE, 1);
563 static void setup_i2c4(void)
565 setup_i2c(3, CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE,
569 static void setup_board_gpio(void)
571 /* enable all LEDs */
572 gpio_request(IMX_GPIO_NR(2, 13), "LED ena"); /* 25 */
573 gpio_direction_output(IMX_GPIO_NR(1, 25), 0);
575 /* switch off Status LEDs */
576 gpio_request(IMX_GPIO_NR(6, 16), "LED yellow"); /* 176 */
577 gpio_direction_output(IMX_GPIO_NR(6, 16), 1);
578 gpio_request(IMX_GPIO_NR(2, 28), "LED red"); /* 60 */
579 gpio_direction_output(IMX_GPIO_NR(2, 28), 1);
580 gpio_request(IMX_GPIO_NR(5, 4), "LED green"); /* 132 */
581 gpio_direction_output(IMX_GPIO_NR(5, 4), 1);
582 gpio_request(IMX_GPIO_NR(2, 29), "LED blue"); /* 61 */
583 gpio_direction_output(IMX_GPIO_NR(2, 29), 1);
586 static void setup_board_spi(void)
588 /* enable spi bus #2 SS drivers */
589 gpio_direction_output(IMX_GPIO_NR(6, 6), 1);
592 int board_late_init(void)
596 char const *panel = getenv("panel");
599 * Check the boot-source. If booting from NOR Flash,
602 gpio_request(IMX_GPIO_NR(7, 6), "bootsel0");
603 gpio_direction_input(IMX_GPIO_NR(7, 6));
604 gpio_request(IMX_GPIO_NR(7, 7), "bootsel1");
605 gpio_direction_input(IMX_GPIO_NR(7, 7));
606 gpio_request(IMX_GPIO_NR(7, 1), "bootsel2");
607 gpio_direction_input(IMX_GPIO_NR(7, 1));
608 bootmode |= (gpio_get_value(IMX_GPIO_NR(7, 6)) ? 1 : 0) << 0;
609 bootmode |= (gpio_get_value(IMX_GPIO_NR(7, 7)) ? 1 : 0) << 1;
610 bootmode |= (gpio_get_value(IMX_GPIO_NR(7, 1)) ? 1 : 0) << 2;
613 my_bootdelay = getenv("nor_bootdelay");
614 if (my_bootdelay != NULL)
615 setenv("bootdelay", my_bootdelay);
617 setenv("bootdelay", "-2");
620 /* if we have the lg panel, we can initialze it now */
622 if (!strcmp(panel, displays[1].mode.name))
623 lg4573_spi_startup(0, 0, 10000000, SPI_MODE_0);