xref: /openbmc/u-boot/board/armadeus/opos6uldev/board.c (revision d024236e5a31a2b4b82cbcc98b31b8170fc88d28)
1 /*
2  * Copyright (C) 2017 Armadeus Systems
3  *
4  * SPDX-License-Identifier:	GPL-2.0+
5  */
6 
7 #include <asm/arch/clock.h>
8 #include <asm/arch/mx6-pins.h>
9 #include <asm/arch/opos6ul.h>
10 #include <asm/arch/sys_proto.h>
11 #include <asm/gpio.h>
12 #include <asm/mach-imx/iomux-v3.h>
13 #include <asm/io.h>
14 #include <common.h>
15 
16 #ifdef CONFIG_VIDEO_MXS
17 #define LCD_PAD_CTRL ( \
18 	PAD_CTL_HYS | PAD_CTL_PUS_100K_UP | PAD_CTL_PUE | \
19 	PAD_CTL_PKE | PAD_CTL_SPEED_MED | PAD_CTL_DSE_40ohm \
20 )
21 
22 static iomux_v3_cfg_t const lcd_pads[] = {
23 	MX6_PAD_LCD_CLK__LCDIF_CLK | MUX_PAD_CTRL(LCD_PAD_CTRL),
24 	MX6_PAD_LCD_ENABLE__LCDIF_ENABLE | MUX_PAD_CTRL(LCD_PAD_CTRL),
25 	MX6_PAD_LCD_HSYNC__LCDIF_HSYNC | MUX_PAD_CTRL(LCD_PAD_CTRL),
26 	MX6_PAD_LCD_VSYNC__LCDIF_VSYNC | MUX_PAD_CTRL(LCD_PAD_CTRL),
27 	MX6_PAD_LCD_DATA00__LCDIF_DATA00 | MUX_PAD_CTRL(LCD_PAD_CTRL),
28 	MX6_PAD_LCD_DATA01__LCDIF_DATA01 | MUX_PAD_CTRL(LCD_PAD_CTRL),
29 	MX6_PAD_LCD_DATA02__LCDIF_DATA02 | MUX_PAD_CTRL(LCD_PAD_CTRL),
30 	MX6_PAD_LCD_DATA03__LCDIF_DATA03 | MUX_PAD_CTRL(LCD_PAD_CTRL),
31 	MX6_PAD_LCD_DATA04__LCDIF_DATA04 | MUX_PAD_CTRL(LCD_PAD_CTRL),
32 	MX6_PAD_LCD_DATA05__LCDIF_DATA05 | MUX_PAD_CTRL(LCD_PAD_CTRL),
33 	MX6_PAD_LCD_DATA06__LCDIF_DATA06 | MUX_PAD_CTRL(LCD_PAD_CTRL),
34 	MX6_PAD_LCD_DATA07__LCDIF_DATA07 | MUX_PAD_CTRL(LCD_PAD_CTRL),
35 	MX6_PAD_LCD_DATA08__LCDIF_DATA08 | MUX_PAD_CTRL(LCD_PAD_CTRL),
36 	MX6_PAD_LCD_DATA09__LCDIF_DATA09 | MUX_PAD_CTRL(LCD_PAD_CTRL),
37 	MX6_PAD_LCD_DATA10__LCDIF_DATA10 | MUX_PAD_CTRL(LCD_PAD_CTRL),
38 	MX6_PAD_LCD_DATA11__LCDIF_DATA11 | MUX_PAD_CTRL(LCD_PAD_CTRL),
39 	MX6_PAD_LCD_DATA12__LCDIF_DATA12 | MUX_PAD_CTRL(LCD_PAD_CTRL),
40 	MX6_PAD_LCD_DATA13__LCDIF_DATA13 | MUX_PAD_CTRL(LCD_PAD_CTRL),
41 	MX6_PAD_LCD_DATA14__LCDIF_DATA14 | MUX_PAD_CTRL(LCD_PAD_CTRL),
42 	MX6_PAD_LCD_DATA15__LCDIF_DATA15 | MUX_PAD_CTRL(LCD_PAD_CTRL),
43 	MX6_PAD_LCD_DATA16__LCDIF_DATA16 | MUX_PAD_CTRL(LCD_PAD_CTRL),
44 	MX6_PAD_LCD_DATA17__LCDIF_DATA17 | MUX_PAD_CTRL(LCD_PAD_CTRL),
45 
46 	MX6_PAD_NAND_ALE__GPIO4_IO10 | MUX_PAD_CTRL(NO_PAD_CTRL)
47 };
48 
49 int setup_lcd(void)
50 {
51 	struct gpio_desc backlight;
52 	int ret;
53 
54 	enable_lcdif_clock(LCDIF1_BASE_ADDR, 1);
55 
56 	imx_iomux_v3_setup_multiple_pads(lcd_pads, ARRAY_SIZE(lcd_pads));
57 
58 	/* Set Brightness to high */
59 	ret = dm_gpio_lookup_name("GPIO4_10", &backlight);
60 	if (ret) {
61 		printf("Cannot get GPIO4_10\n");
62 		return ret;
63 	}
64 
65 	ret = dm_gpio_request(&backlight, "backlight");
66 	if (ret) {
67 		printf("Cannot request GPIO4_10\n");
68 		return ret;
69 	}
70 
71 	dm_gpio_set_dir_flags(&backlight, GPIOD_IS_OUT);
72 	dm_gpio_set_value(&backlight, 1);
73 
74 	return 0;
75 }
76 #endif
77 
78 #ifdef CONFIG_USB_EHCI_MX6
79 #define USB_OTHERREGS_OFFSET	0x800
80 #define UCTRL_PWR_POL		(1 << 9)
81 
82 int board_ehci_hcd_init(int port)
83 {
84 	u32 *usbnc_usb_ctrl;
85 
86 	if (port > 1)
87 		return -EINVAL;
88 
89 	usbnc_usb_ctrl = (u32 *)(USB_BASE_ADDR + USB_OTHERREGS_OFFSET +
90 				 port * 4);
91 
92 	/* Set Power polarity */
93 	setbits_le32(usbnc_usb_ctrl, UCTRL_PWR_POL);
94 
95 	return 0;
96 }
97 #endif
98 
99 int opos6ul_board_late_init(void)
100 {
101 #ifdef CONFIG_VIDEO_MXS
102 	setup_lcd();
103 #endif
104 
105 	return 0;
106 }
107 
108 #ifdef CONFIG_SPL_BUILD
109 #define UART_PAD_CTRL (						\
110 	PAD_CTL_HYS | PAD_CTL_PUS_100K_UP | PAD_CTL_SPEED_MED |	\
111 	PAD_CTL_DSE_40ohm | PAD_CTL_SRE_FAST			\
112 )
113 
114 static iomux_v3_cfg_t const uart1_pads[] = {
115 	MX6_PAD_UART1_TX_DATA__UART1_DCE_TX | MUX_PAD_CTRL(UART_PAD_CTRL),
116 	MX6_PAD_UART1_RX_DATA__UART1_DCE_RX | MUX_PAD_CTRL(UART_PAD_CTRL),
117 };
118 
119 void opos6ul_setup_uart_debug(void)
120 {
121 	imx_iomux_v3_setup_multiple_pads(uart1_pads, ARRAY_SIZE(uart1_pads));
122 }
123 #endif /* CONFIG_SPL_BUILD */
124