blob: ca24d2e45359c276c4fa9e473bb035c29d1d6b58 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Tim Harvey0cee2242015-05-08 18:28:35 -07002/*
3 * Copyright (C) 2013 Gateworks Corporation
4 *
5 * Author: Tim Harvey <tharvey@gateworks.com>
Tim Harvey0cee2242015-05-08 18:28:35 -07006 */
7
Simon Glass1e268642020-05-10 11:39:55 -06008#include <common.h>
Simon Glass0f2af882020-05-10 11:40:05 -06009#include <log.h>
Tim Harvey84ae1912017-03-13 08:51:03 -070010#include <asm/arch/clock.h>
Tim Harvey0cee2242015-05-08 18:28:35 -070011#include <asm/arch/mx6-pins.h>
12#include <asm/arch/sys_proto.h>
13#include <asm/gpio.h>
Stefano Babic33731bc2017-06-29 10:16:06 +020014#include <asm/mach-imx/mxc_i2c.h>
Simon Glass0af6e2d2019-08-01 09:46:52 -060015#include <env.h>
Yangbo Lu73340382019-06-21 11:42:28 +080016#include <fsl_esdhc_imx.h>
Tim Harvey0cee2242015-05-08 18:28:35 -070017#include <hwconfig.h>
Simon Glassdbd79542020-05-10 11:40:11 -060018#include <linux/delay.h>
Tim Harvey0cee2242015-05-08 18:28:35 -070019#include <power/pmic.h>
20#include <power/ltc3676_pmic.h>
21#include <power/pfuze100_pmic.h>
Tim Harvey08aec662021-07-24 10:40:42 -070022#include <power/mp5416.h>
Tim Harvey0cee2242015-05-08 18:28:35 -070023
24#include "common.h"
25
Tim Harvey0cee2242015-05-08 18:28:35 -070026/* UART2: Serial Console */
27static iomux_v3_cfg_t const uart2_pads[] = {
28 IOMUX_PADS(PAD_SD4_DAT7__UART2_TX_DATA | MUX_PAD_CTRL(UART_PAD_CTRL)),
29 IOMUX_PADS(PAD_SD4_DAT4__UART2_RX_DATA | MUX_PAD_CTRL(UART_PAD_CTRL)),
30};
31
32void setup_iomux_uart(void)
33{
Tim Harvey0cee2242015-05-08 18:28:35 -070034 SETUP_IOMUX_PADS(uart2_pads);
35}
36
Tim Harvey84ae1912017-03-13 08:51:03 -070037/* MMC */
Tim Harvey63537792017-03-17 07:30:38 -070038static iomux_v3_cfg_t const gw5904_emmc_pads[] = {
39 IOMUX_PADS(PAD_SD3_DAT0__SD3_DATA0 | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
40 IOMUX_PADS(PAD_SD3_DAT1__SD3_DATA1 | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
41 IOMUX_PADS(PAD_SD3_DAT2__SD3_DATA2 | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
42 IOMUX_PADS(PAD_SD3_DAT3__SD3_DATA3 | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
43 IOMUX_PADS(PAD_SD3_DAT4__SD3_DATA4 | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
44 IOMUX_PADS(PAD_SD3_DAT5__SD3_DATA5 | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
45 IOMUX_PADS(PAD_SD3_DAT6__SD3_DATA6 | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
46 IOMUX_PADS(PAD_SD3_DAT7__SD3_DATA7 | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
47 IOMUX_PADS(PAD_SD3_CLK__SD3_CLK | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
48 IOMUX_PADS(PAD_SD3_CMD__SD3_CMD | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
49 IOMUX_PADS(PAD_SD3_RST__SD3_RESET | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
50};
Tim Harvey4533c902017-03-17 07:32:21 -070051/* 4-bit microSD on SD2 */
52static iomux_v3_cfg_t const gw5904_mmc_pads[] = {
53 IOMUX_PADS(PAD_SD2_CLK__SD2_CLK | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
54 IOMUX_PADS(PAD_SD2_CMD__SD2_CMD | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
55 IOMUX_PADS(PAD_SD2_DAT0__SD2_DATA0 | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
56 IOMUX_PADS(PAD_SD2_DAT1__SD2_DATA1 | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
57 IOMUX_PADS(PAD_SD2_DAT2__SD2_DATA2 | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
58 IOMUX_PADS(PAD_SD2_DAT3__SD2_DATA3 | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
59 /* CD */
60 IOMUX_PADS(PAD_NANDF_CS0__GPIO6_IO11 | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
61};
Tim Harvey659441b2017-03-17 07:31:02 -070062/* 8-bit eMMC on SD2/NAND */
63static iomux_v3_cfg_t const gw560x_emmc_sd2_pads[] = {
64 IOMUX_PADS(PAD_SD2_CLK__SD2_CLK | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
65 IOMUX_PADS(PAD_SD2_CMD__SD2_CMD | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
66 IOMUX_PADS(PAD_SD2_DAT0__SD2_DATA0 | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
67 IOMUX_PADS(PAD_SD2_DAT1__SD2_DATA1 | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
68 IOMUX_PADS(PAD_SD2_DAT2__SD2_DATA2 | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
69 IOMUX_PADS(PAD_SD2_DAT3__SD2_DATA3 | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
70 IOMUX_PADS(PAD_NANDF_D4__SD2_DATA4 | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
71 IOMUX_PADS(PAD_NANDF_D5__SD2_DATA5 | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
72 IOMUX_PADS(PAD_NANDF_D6__SD2_DATA6 | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
73 IOMUX_PADS(PAD_NANDF_D7__SD2_DATA7 | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
74};
75
Tim Harvey84ae1912017-03-13 08:51:03 -070076static iomux_v3_cfg_t const usdhc3_pads[] = {
77 IOMUX_PADS(PAD_SD3_CLK__SD3_CLK | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
78 IOMUX_PADS(PAD_SD3_CMD__SD3_CMD | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
79 IOMUX_PADS(PAD_SD3_DAT0__SD3_DATA0 | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
80 IOMUX_PADS(PAD_SD3_DAT1__SD3_DATA1 | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
81 IOMUX_PADS(PAD_SD3_DAT2__SD3_DATA2 | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
82 IOMUX_PADS(PAD_SD3_DAT3__SD3_DATA3 | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
83 IOMUX_PADS(PAD_SD3_DAT5__GPIO7_IO00 | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
84};
85
Tim Harveyd04dc812019-02-04 13:10:49 -080086/*
87 * I2C pad configs:
88 * I2C1: GSC
89 * I2C2: PMIC,PCIe Switch,Clock,Mezz
90 * I2C3: Multimedia/Expansion
91 */
92static struct i2c_pads_info mx6q_i2c_pad_info[] = {
93 {
94 .scl = {
95 .i2c_mode = MX6Q_PAD_EIM_D21__I2C1_SCL | PC,
96 .gpio_mode = MX6Q_PAD_EIM_D21__GPIO3_IO21 | PC,
97 .gp = IMX_GPIO_NR(3, 21)
98 },
99 .sda = {
100 .i2c_mode = MX6Q_PAD_EIM_D28__I2C1_SDA | PC,
101 .gpio_mode = MX6Q_PAD_EIM_D28__GPIO3_IO28 | PC,
102 .gp = IMX_GPIO_NR(3, 28)
103 }
104 }, {
105 .scl = {
106 .i2c_mode = MX6Q_PAD_KEY_COL3__I2C2_SCL | PC,
107 .gpio_mode = MX6Q_PAD_KEY_COL3__GPIO4_IO12 | PC,
108 .gp = IMX_GPIO_NR(4, 12)
109 },
110 .sda = {
111 .i2c_mode = MX6Q_PAD_KEY_ROW3__I2C2_SDA | PC,
112 .gpio_mode = MX6Q_PAD_KEY_ROW3__GPIO4_IO13 | PC,
113 .gp = IMX_GPIO_NR(4, 13)
114 }
115 }, {
116 .scl = {
117 .i2c_mode = MX6Q_PAD_GPIO_3__I2C3_SCL | PC,
118 .gpio_mode = MX6Q_PAD_GPIO_3__GPIO1_IO03 | PC,
119 .gp = IMX_GPIO_NR(1, 3)
120 },
121 .sda = {
122 .i2c_mode = MX6Q_PAD_GPIO_6__I2C3_SDA | PC,
123 .gpio_mode = MX6Q_PAD_GPIO_6__GPIO1_IO06 | PC,
124 .gp = IMX_GPIO_NR(1, 6)
125 }
Tim Harvey0cee2242015-05-08 18:28:35 -0700126 }
127};
Tim Harvey0cee2242015-05-08 18:28:35 -0700128
Tim Harveyd04dc812019-02-04 13:10:49 -0800129static struct i2c_pads_info mx6dl_i2c_pad_info[] = {
130 {
131 .scl = {
132 .i2c_mode = MX6DL_PAD_EIM_D21__I2C1_SCL | PC,
133 .gpio_mode = MX6DL_PAD_EIM_D21__GPIO3_IO21 | PC,
134 .gp = IMX_GPIO_NR(3, 21)
135 },
136 .sda = {
137 .i2c_mode = MX6DL_PAD_EIM_D28__I2C1_SDA | PC,
138 .gpio_mode = MX6DL_PAD_EIM_D28__GPIO3_IO28 | PC,
139 .gp = IMX_GPIO_NR(3, 28)
140 }
141 }, {
142 .scl = {
143 .i2c_mode = MX6DL_PAD_KEY_COL3__I2C2_SCL | PC,
144 .gpio_mode = MX6DL_PAD_KEY_COL3__GPIO4_IO12 | PC,
145 .gp = IMX_GPIO_NR(4, 12)
146 },
147 .sda = {
148 .i2c_mode = MX6DL_PAD_KEY_ROW3__I2C2_SDA | PC,
149 .gpio_mode = MX6DL_PAD_KEY_ROW3__GPIO4_IO13 | PC,
150 .gp = IMX_GPIO_NR(4, 13)
151 }
152 }, {
153 .scl = {
154 .i2c_mode = MX6DL_PAD_GPIO_3__I2C3_SCL | PC,
155 .gpio_mode = MX6DL_PAD_GPIO_3__GPIO1_IO03 | PC,
156 .gp = IMX_GPIO_NR(1, 3)
157 },
158 .sda = {
159 .i2c_mode = MX6DL_PAD_GPIO_6__I2C3_SDA | PC,
160 .gpio_mode = MX6DL_PAD_GPIO_6__GPIO1_IO06 | PC,
161 .gp = IMX_GPIO_NR(1, 6)
162 }
Tim Harvey0cee2242015-05-08 18:28:35 -0700163 }
164};
165
Tim Harveyd04dc812019-02-04 13:10:49 -0800166void setup_ventana_i2c(int i2c)
Tim Harvey0cee2242015-05-08 18:28:35 -0700167{
Tim Harveyd04dc812019-02-04 13:10:49 -0800168 struct i2c_pads_info *p;
169
170 if (is_cpu_type(MXC_CPU_MX6Q))
171 p = &mx6q_i2c_pad_info[i2c];
172 else
173 p = &mx6dl_i2c_pad_info[i2c];
174
175 setup_i2c(i2c, CONFIG_SYS_I2C_SPEED, 0x7f, p);
Tim Harvey0cee2242015-05-08 18:28:35 -0700176}
177
178/*
179 * Baseboard specific GPIO
180 */
Tim Harvey0cee2242015-05-08 18:28:35 -0700181static iomux_v3_cfg_t const gw51xx_gpio_pads[] = {
Tim Harvey0cee2242015-05-08 18:28:35 -0700182 /* IOEXP_PWREN# */
183 IOMUX_PADS(PAD_EIM_A19__GPIO2_IO19 | DIO_PAD_CFG),
184 /* IOEXP_IRQ# */
185 IOMUX_PADS(PAD_EIM_A20__GPIO2_IO18 | MUX_PAD_CTRL(IRQ_PAD_CTRL)),
Tim Harvey0cee2242015-05-08 18:28:35 -0700186 /* GPS_SHDN */
187 IOMUX_PADS(PAD_GPIO_2__GPIO1_IO02 | DIO_PAD_CFG),
Tim Harvey0cee2242015-05-08 18:28:35 -0700188 /* PCIESKT_WDIS# */
189 IOMUX_PADS(PAD_GPIO_17__GPIO7_IO12 | DIO_PAD_CFG),
190};
191
192static iomux_v3_cfg_t const gw52xx_gpio_pads[] = {
Tim Harveyd7babd42017-03-13 08:51:08 -0700193 /* SD3_VSELECT */
194 IOMUX_PADS(PAD_NANDF_CS1__GPIO6_IO14 | DIO_PAD_CFG),
Tim Harvey2cb61c12016-07-15 07:14:22 -0700195 /* RS232_EN# */
196 IOMUX_PADS(PAD_SD4_DAT3__GPIO2_IO11 | DIO_PAD_CFG),
Tim Harvey86b75322016-05-24 11:03:56 -0700197 /* MSATA_EN */
198 IOMUX_PADS(PAD_SD4_DAT0__GPIO2_IO08 | DIO_PAD_CFG),
Tim Harvey0cee2242015-05-08 18:28:35 -0700199 /* IOEXP_PWREN# */
200 IOMUX_PADS(PAD_EIM_A19__GPIO2_IO19 | DIO_PAD_CFG),
201 /* IOEXP_IRQ# */
202 IOMUX_PADS(PAD_EIM_A20__GPIO2_IO18 | MUX_PAD_CTRL(IRQ_PAD_CTRL)),
Tim Harvey0cee2242015-05-08 18:28:35 -0700203 /* GPS_SHDN */
204 IOMUX_PADS(PAD_ENET_RXD0__GPIO1_IO27 | DIO_PAD_CFG),
205 /* USBOTG_SEL */
206 IOMUX_PADS(PAD_GPIO_2__GPIO1_IO02 | DIO_PAD_CFG),
Tim Harveydb7edfa2015-05-26 11:04:54 -0700207 /* RS485_EN */
208 IOMUX_PADS(PAD_SD3_DAT4__GPIO7_IO01 | DIO_PAD_CFG),
Tim Harvey0cee2242015-05-08 18:28:35 -0700209 /* PCIESKT_WDIS# */
210 IOMUX_PADS(PAD_GPIO_17__GPIO7_IO12 | DIO_PAD_CFG),
211};
212
213static iomux_v3_cfg_t const gw53xx_gpio_pads[] = {
Tim Harveyd7babd42017-03-13 08:51:08 -0700214 /* SD3_VSELECT */
215 IOMUX_PADS(PAD_NANDF_CS1__GPIO6_IO14 | DIO_PAD_CFG),
Tim Harvey2cb61c12016-07-15 07:14:22 -0700216 /* RS232_EN# */
217 IOMUX_PADS(PAD_SD4_DAT3__GPIO2_IO11 | DIO_PAD_CFG),
Tim Harvey86b75322016-05-24 11:03:56 -0700218 /* MSATA_EN */
219 IOMUX_PADS(PAD_SD4_DAT0__GPIO2_IO08 | DIO_PAD_CFG),
Tim Harvey0cee2242015-05-08 18:28:35 -0700220 /* IOEXP_PWREN# */
221 IOMUX_PADS(PAD_EIM_A19__GPIO2_IO19 | DIO_PAD_CFG),
222 /* IOEXP_IRQ# */
223 IOMUX_PADS(PAD_EIM_A20__GPIO2_IO18 | MUX_PAD_CTRL(IRQ_PAD_CTRL)),
224 /* DIOI2C_DIS# */
225 IOMUX_PADS(PAD_GPIO_19__GPIO4_IO05 | DIO_PAD_CFG),
226 /* GPS_SHDN */
227 IOMUX_PADS(PAD_ENET_RXD0__GPIO1_IO27 | DIO_PAD_CFG),
Tim Harveydb7edfa2015-05-26 11:04:54 -0700228 /* RS485_EN */
229 IOMUX_PADS(PAD_SD3_DAT4__GPIO7_IO01 | DIO_PAD_CFG),
Tim Harvey0cee2242015-05-08 18:28:35 -0700230 /* PCIESKT_WDIS# */
231 IOMUX_PADS(PAD_GPIO_17__GPIO7_IO12 | DIO_PAD_CFG),
Tim Harvey409fe9a2021-07-24 10:40:45 -0700232 /* J6_PWREN */
233 IOMUX_PADS(PAD_EIM_DA15__GPIO3_IO15 | DIO_PAD_CFG),
234 /* PCIEGBE_EN */
235 IOMUX_PADS(PAD_EIM_DA14__GPIO3_IO14 | DIO_PAD_CFG),
Tim Harvey0cee2242015-05-08 18:28:35 -0700236};
237
238static iomux_v3_cfg_t const gw54xx_gpio_pads[] = {
Tim Harveyd7babd42017-03-13 08:51:08 -0700239 /* SD3_VSELECT */
240 IOMUX_PADS(PAD_NANDF_CS1__GPIO6_IO14 | DIO_PAD_CFG),
Tim Harvey2cb61c12016-07-15 07:14:22 -0700241 /* RS232_EN# */
242 IOMUX_PADS(PAD_SD4_DAT3__GPIO2_IO11 | DIO_PAD_CFG),
Tim Harvey86b75322016-05-24 11:03:56 -0700243 /* MSATA_EN */
244 IOMUX_PADS(PAD_SD4_DAT0__GPIO2_IO08 | DIO_PAD_CFG),
Tim Harvey0cee2242015-05-08 18:28:35 -0700245 /* MIPI_DIO */
246 IOMUX_PADS(PAD_SD1_DAT3__GPIO1_IO21 | DIO_PAD_CFG),
247 /* RS485_EN */
248 IOMUX_PADS(PAD_EIM_D24__GPIO3_IO24 | DIO_PAD_CFG),
249 /* IOEXP_PWREN# */
Tim Harveydb7edfa2015-05-26 11:04:54 -0700250 IOMUX_PADS(PAD_EIM_A19__GPIO2_IO19 | DIO_PAD_CFG),
Tim Harvey0cee2242015-05-08 18:28:35 -0700251 /* IOEXP_IRQ# */
Tim Harveydb7edfa2015-05-26 11:04:54 -0700252 IOMUX_PADS(PAD_EIM_A20__GPIO2_IO18 | MUX_PAD_CTRL(IRQ_PAD_CTRL)),
Tim Harvey0cee2242015-05-08 18:28:35 -0700253 /* DIOI2C_DIS# */
254 IOMUX_PADS(PAD_GPIO_19__GPIO4_IO05 | DIO_PAD_CFG),
Tim Harveydb7edfa2015-05-26 11:04:54 -0700255 /* RS485_EN */
256 IOMUX_PADS(PAD_SD3_DAT4__GPIO7_IO01 | DIO_PAD_CFG),
Tim Harvey0cee2242015-05-08 18:28:35 -0700257 /* PCIESKT_WDIS# */
258 IOMUX_PADS(PAD_DISP0_DAT23__GPIO5_IO17 | DIO_PAD_CFG),
259};
260
261static iomux_v3_cfg_t const gw551x_gpio_pads[] = {
Tim Harvey0cee2242015-05-08 18:28:35 -0700262 /* PCIESKT_WDIS# */
263 IOMUX_PADS(PAD_GPIO_17__GPIO7_IO12 | DIO_PAD_CFG),
264};
265
266static iomux_v3_cfg_t const gw552x_gpio_pads[] = {
Tim Harvey86b75322016-05-24 11:03:56 -0700267 /* MSATA_EN */
268 IOMUX_PADS(PAD_SD4_DAT0__GPIO2_IO08 | DIO_PAD_CFG),
Tim Harveydb7edfa2015-05-26 11:04:54 -0700269 /* USBOTG_SEL */
270 IOMUX_PADS(PAD_GPIO_7__GPIO1_IO07 | DIO_PAD_CFG),
Tim Harvey0cee2242015-05-08 18:28:35 -0700271 /* MX6_DIO[4:9] */
272 IOMUX_PADS(PAD_CSI0_PIXCLK__GPIO5_IO18 | DIO_PAD_CFG),
273 IOMUX_PADS(PAD_CSI0_DATA_EN__GPIO5_IO20 | DIO_PAD_CFG),
274 IOMUX_PADS(PAD_CSI0_VSYNC__GPIO5_IO21 | DIO_PAD_CFG),
275 IOMUX_PADS(PAD_CSI0_DAT4__GPIO5_IO22 | DIO_PAD_CFG),
276 IOMUX_PADS(PAD_CSI0_DAT5__GPIO5_IO23 | DIO_PAD_CFG),
277 IOMUX_PADS(PAD_CSI0_DAT7__GPIO5_IO25 | DIO_PAD_CFG),
278 /* PCIEGBE1_OFF# */
279 IOMUX_PADS(PAD_GPIO_1__GPIO1_IO01 | DIO_PAD_CFG),
280 /* PCIEGBE2_OFF# */
281 IOMUX_PADS(PAD_GPIO_2__GPIO1_IO02 | DIO_PAD_CFG),
282 /* PCIESKT_WDIS# */
283 IOMUX_PADS(PAD_GPIO_17__GPIO7_IO12 | DIO_PAD_CFG),
284};
285
Tim Harvey892068c2016-05-24 11:03:58 -0700286static iomux_v3_cfg_t const gw553x_gpio_pads[] = {
Tim Harveyd7babd42017-03-13 08:51:08 -0700287 /* SD3_VSELECT */
288 IOMUX_PADS(PAD_NANDF_CS1__GPIO6_IO14 | DIO_PAD_CFG),
Tim Harvey892068c2016-05-24 11:03:58 -0700289 /* PCIESKT_WDIS# */
290 IOMUX_PADS(PAD_GPIO_17__GPIO7_IO12 | DIO_PAD_CFG),
291};
292
Tim Harvey659441b2017-03-17 07:31:02 -0700293static iomux_v3_cfg_t const gw560x_gpio_pads[] = {
294 /* RS232_EN# */
295 IOMUX_PADS(PAD_SD4_DAT3__GPIO2_IO11 | DIO_PAD_CFG),
Tim Harvey659441b2017-03-17 07:31:02 -0700296 /* IOEXP_PWREN# */
297 IOMUX_PADS(PAD_EIM_A19__GPIO2_IO19 | DIO_PAD_CFG),
298 /* IOEXP_IRQ# */
299 IOMUX_PADS(PAD_EIM_A20__GPIO2_IO18 | MUX_PAD_CTRL(IRQ_PAD_CTRL)),
300 /* DIOI2C_DIS# */
301 IOMUX_PADS(PAD_GPIO_19__GPIO4_IO05 | DIO_PAD_CFG),
Tim Harvey659441b2017-03-17 07:31:02 -0700302 /* RS485_EN */
303 IOMUX_PADS(PAD_SD3_DAT4__GPIO7_IO01 | DIO_PAD_CFG),
304 /* PCIESKT_WDIS# */
305 IOMUX_PADS(PAD_GPIO_17__GPIO7_IO12 | DIO_PAD_CFG),
Tim Harvey659441b2017-03-17 07:31:02 -0700306 /* 12V0_PWR_EN */
307 IOMUX_PADS(PAD_DISP0_DAT5__GPIO4_IO26 | DIO_PAD_CFG),
308};
309
Tim Harvey5852a332019-02-04 13:10:58 -0800310static iomux_v3_cfg_t const gw5901_gpio_pads[] = {
Tim Harvey5852a332019-02-04 13:10:58 -0800311 /* ETH1_EN */
312 IOMUX_PADS(PAD_GPIO_1__GPIO1_IO01 | DIO_PAD_CFG),
Tim Harvey5852a332019-02-04 13:10:58 -0800313 /* PMIC reset */
314 IOMUX_PADS(PAD_DISP0_DAT8__WDOG1_B | DIO_PAD_CFG),
315 /* COM_CFGA/B/C/D */
316 IOMUX_PADS(PAD_DISP0_DAT20__GPIO5_IO14 | DIO_PAD_CFG),
317 IOMUX_PADS(PAD_DISP0_DAT21__GPIO5_IO15 | DIO_PAD_CFG),
318 IOMUX_PADS(PAD_DISP0_DAT22__GPIO5_IO16 | DIO_PAD_CFG),
319 IOMUX_PADS(PAD_DISP0_DAT23__GPIO5_IO17 | DIO_PAD_CFG),
320 /* ETI_IRQ# */
321 IOMUX_PADS(PAD_GPIO_5__GPIO1_IO05 | DIO_PAD_CFG),
322 /* DIO_IRQ# */
323 IOMUX_PADS(PAD_GPIO_7__GPIO1_IO07 | DIO_PAD_CFG),
324 /* FIBER_SIGDET */
325 IOMUX_PADS(PAD_GPIO_9__GPIO1_IO09 | DIO_PAD_CFG),
326};
327
328static iomux_v3_cfg_t const gw5902_gpio_pads[] = {
Tim Harvey5852a332019-02-04 13:10:58 -0800329 /* UART1_EN# */
330 IOMUX_PADS(PAD_SD4_DAT3__GPIO2_IO11 | DIO_PAD_CFG),
Tim Harvey5852a332019-02-04 13:10:58 -0800331 /* 5V_UVLO */
332 IOMUX_PADS(PAD_GPIO_17__GPIO7_IO12 | DIO_PAD_CFG),
333 /* ETI_IRQ# */
334 IOMUX_PADS(PAD_GPIO_5__GPIO1_IO05 | DIO_PAD_CFG),
335 /* DIO_IRQ# */
336 IOMUX_PADS(PAD_GPIO_7__GPIO1_IO07 | DIO_PAD_CFG),
Tim Harvey5852a332019-02-04 13:10:58 -0800337};
338
Tim Harvey4533c902017-03-17 07:32:21 -0700339static iomux_v3_cfg_t const gw5903_gpio_pads[] = {
340 /* BKLT_12VEN */
341 IOMUX_PADS(PAD_GPIO_7__GPIO1_IO07 | DIO_PAD_CFG),
342 /* EMMY_PDN# */
343 IOMUX_PADS(PAD_NANDF_D2__GPIO2_IO02 | DIO_PAD_CFG),
344 /* EMMY_CFG1# */
345 IOMUX_PADS(PAD_NANDF_D3__GPIO2_IO03 | DIO_PAD_CFG),
346 /* EMMY_CFG1# */
347 IOMUX_PADS(PAD_NANDF_D4__GPIO2_IO04 | DIO_PAD_CFG),
348 /* USBH1_PEN (EHCI) */
349 IOMUX_PADS(PAD_EIM_D31__GPIO3_IO31 | DIO_PAD_CFG),
Tim Harvey4533c902017-03-17 07:32:21 -0700350 /* USBDPC_PEN */
351 IOMUX_PADS(PAD_KEY_ROW0__GPIO4_IO07 | DIO_PAD_CFG),
352 /* TOUCH_RST */
353 IOMUX_PADS(PAD_KEY_COL1__GPIO4_IO08 | DIO_PAD_CFG),
354 /* AUDIO_RST# */
355 IOMUX_PADS(PAD_DISP0_DAT23__GPIO5_IO17 | DIO_PAD_CFG),
356 /* UART1_TEN# */
357 IOMUX_PADS(PAD_CSI0_DAT12__GPIO5_IO30 | DIO_PAD_CFG),
Tim Harvey4533c902017-03-17 07:32:21 -0700358 /* LVDS_BKLEN # */
359 IOMUX_PADS(PAD_GPIO_17__GPIO7_IO12 | DIO_PAD_CFG),
360 /* RGMII_PDWN# */
361 IOMUX_PADS(PAD_ENET_CRS_DV__GPIO1_IO25 | DIO_PAD_CFG),
362 /* TOUCH_IRQ# */
363 IOMUX_PADS(PAD_KEY_COL0__GPIO4_IO06 | DIO_PAD_CFG),
364 /* TOUCH_RST# */
365 IOMUX_PADS(PAD_KEY_COL1__GPIO4_IO08 | DIO_PAD_CFG),
366};
367
Tim Harvey63537792017-03-17 07:30:38 -0700368static iomux_v3_cfg_t const gw5904_gpio_pads[] = {
Tim Harvey63537792017-03-17 07:30:38 -0700369 /* IOEXP_PWREN# */
370 IOMUX_PADS(PAD_EIM_A19__GPIO2_IO19 | DIO_PAD_CFG),
371 /* IOEXP_IRQ# */
372 IOMUX_PADS(PAD_EIM_A20__GPIO2_IO18 | MUX_PAD_CTRL(IRQ_PAD_CTRL)),
373 /* DIOI2C_DIS# */
374 IOMUX_PADS(PAD_GPIO_19__GPIO4_IO05 | DIO_PAD_CFG),
375 /* UART_RS485 */
376 IOMUX_PADS(PAD_DISP0_DAT2__GPIO4_IO23 | DIO_PAD_CFG),
377 /* UART_HALF */
378 IOMUX_PADS(PAD_DISP0_DAT3__GPIO4_IO24 | DIO_PAD_CFG),
379 /* SKT1_WDIS# */
380 IOMUX_PADS(PAD_DISP0_DAT17__GPIO5_IO11 | DIO_PAD_CFG),
381 /* SKT1_RST# */
382 IOMUX_PADS(PAD_DISP0_DAT18__GPIO5_IO12 | DIO_PAD_CFG),
383 /* SKT2_WDIS# */
384 IOMUX_PADS(PAD_DISP0_DAT19__GPIO5_IO13 | DIO_PAD_CFG),
385 /* SKT2_RST# */
386 IOMUX_PADS(PAD_GPIO_0__GPIO1_IO00 | DIO_PAD_CFG),
387 /* M2_OFF# */
388 IOMUX_PADS(PAD_SD2_DAT0__GPIO1_IO15 | DIO_PAD_CFG),
389 /* M2_WDIS# */
390 IOMUX_PADS(PAD_SD2_DAT1__GPIO1_IO14 | DIO_PAD_CFG),
391 /* M2_RST# */
392 IOMUX_PADS(PAD_SD2_DAT2__GPIO1_IO13 | DIO_PAD_CFG),
Tim Harvey2df50462019-02-04 13:10:57 -0800393 /* RS232_EN# */
394 IOMUX_PADS(PAD_SD4_DAT3__GPIO2_IO11 | DIO_PAD_CFG),
Tim Harvey63537792017-03-17 07:30:38 -0700395};
396
Tim Harveya2d24c92019-02-04 13:10:50 -0800397static iomux_v3_cfg_t const gw5905_gpio_pads[] = {
398 /* EMMY_PDN# */
399 IOMUX_PADS(PAD_NANDF_D3__GPIO2_IO03 | DIO_PAD_CFG),
Tim Harveya2d24c92019-02-04 13:10:50 -0800400 /* MIPI_RST */
401 IOMUX_PADS(PAD_SD2_DAT0__GPIO1_IO15 | DIO_PAD_CFG),
402 /* MIPI_PWDN */
403 IOMUX_PADS(PAD_SD2_DAT1__GPIO1_IO14 | DIO_PAD_CFG),
404 /* USBEHCI_SEL */
405 IOMUX_PADS(PAD_GPIO_7__GPIO1_IO07 | DIO_PAD_CFG),
Tim Harveya2d24c92019-02-04 13:10:50 -0800406 /* LVDS_BKLEN # */
407 IOMUX_PADS(PAD_GPIO_17__GPIO7_IO12 | DIO_PAD_CFG),
408 /* PCIESKT_WDIS# */
409 IOMUX_PADS(PAD_GPIO_18__GPIO7_IO13 | DIO_PAD_CFG),
410 /* SPK_SHDN# */
411 IOMUX_PADS(PAD_GPIO_19__GPIO4_IO05 | DIO_PAD_CFG),
Tim Harveya2d24c92019-02-04 13:10:50 -0800412 /* DECT_RST# */
413 IOMUX_PADS(PAD_DISP0_DAT20__GPIO5_IO14 | DIO_PAD_CFG),
414 /* USBH1_PEN (EHCI) */
415 IOMUX_PADS(PAD_EIM_D31__GPIO3_IO31 | DIO_PAD_CFG),
416 /* LVDS_PWM */
417 IOMUX_PADS(PAD_GPIO_9__GPIO1_IO09 | DIO_PAD_CFG),
418 /* CODEC_RST */
419 IOMUX_PADS(PAD_DISP0_DAT23__GPIO5_IO17 | DIO_PAD_CFG),
420 /* GYRO_CONTROL/DATA_EN */
421 IOMUX_PADS(PAD_CSI0_DAT8__GPIO5_IO26 | DIO_PAD_CFG),
422 /* TOUCH_RST */
423 IOMUX_PADS(PAD_KEY_COL1__GPIO4_IO08 | DIO_PAD_CFG),
424 /* TOUCH_IRQ */
425 IOMUX_PADS(PAD_KEY_COL0__GPIO4_IO06 | DIO_PAD_CFG),
426};
427
Tim Harvey08aec662021-07-24 10:40:42 -0700428static iomux_v3_cfg_t const gw5910_gpio_pads[] = {
429 /* SD3_VSELECT */
430 IOMUX_PADS(PAD_NANDF_CS1__GPIO6_IO14 | DIO_PAD_CFG),
431 /* RS232_EN# */
432 IOMUX_PADS(PAD_SD4_DAT3__GPIO2_IO11 | DIO_PAD_CFG),
433 /* RF_RESET# */
434 IOMUX_PADS(PAD_GPIO_7__GPIO1_IO07 | DIO_PAD_CFG),
435 /* RF_BOOT */
436 IOMUX_PADS(PAD_GPIO_8__GPIO1_IO08 | DIO_PAD_CFG),
437 /* PCIESKT_WDIS# */
438 IOMUX_PADS(PAD_GPIO_17__GPIO7_IO12 | DIO_PAD_CFG),
439};
440
Tim Harveyd67ad6e2021-07-24 10:40:43 -0700441static iomux_v3_cfg_t const gw5912_gpio_pads[] = {
442 /* SD3_VSELECT */
443 IOMUX_PADS(PAD_NANDF_CS1__GPIO6_IO14 | DIO_PAD_CFG),
444 /* RS232_EN# */
445 IOMUX_PADS(PAD_SD4_DAT3__GPIO2_IO11 | DIO_PAD_CFG),
446 /* PCIESKT_WDIS# */
447 IOMUX_PADS(PAD_GPIO_0__GPIO1_IO00 | DIO_PAD_CFG),
448};
449
Tim Harvey41595b52016-07-15 07:14:23 -0700450/* Digital I/O */
451struct dio_cfg gw51xx_dio[] = {
452 {
453 { IOMUX_PADS(PAD_SD1_DAT0__GPIO1_IO16) },
454 IMX_GPIO_NR(1, 16),
455 { 0, 0 },
456 0
457 },
458 {
459 { IOMUX_PADS(PAD_SD1_DAT2__GPIO1_IO19) },
460 IMX_GPIO_NR(1, 19),
461 { IOMUX_PADS(PAD_SD1_DAT2__PWM2_OUT) },
462 2
463 },
464 {
465 { IOMUX_PADS(PAD_SD1_DAT1__GPIO1_IO17) },
466 IMX_GPIO_NR(1, 17),
467 { IOMUX_PADS(PAD_SD1_DAT1__PWM3_OUT) },
468 3
469 },
470 {
471 { IOMUX_PADS(PAD_SD1_CMD__GPIO1_IO18) },
472 IMX_GPIO_NR(1, 18),
473 { IOMUX_PADS(PAD_SD1_CMD__PWM4_OUT) },
474 4
475 },
476};
477
478struct dio_cfg gw52xx_dio[] = {
479 {
480 { IOMUX_PADS(PAD_SD1_DAT0__GPIO1_IO16) },
481 IMX_GPIO_NR(1, 16),
482 { 0, 0 },
483 0
484 },
485 {
486 { IOMUX_PADS(PAD_SD1_DAT2__GPIO1_IO19) },
487 IMX_GPIO_NR(1, 19),
488 { IOMUX_PADS(PAD_SD1_DAT2__PWM2_OUT) },
489 2
490 },
491 {
492 { IOMUX_PADS(PAD_SD1_DAT1__GPIO1_IO17) },
493 IMX_GPIO_NR(1, 17),
494 { IOMUX_PADS(PAD_SD1_DAT1__PWM3_OUT) },
495 3
496 },
497 {
498 { IOMUX_PADS(PAD_SD1_CLK__GPIO1_IO20) },
499 IMX_GPIO_NR(1, 20),
500 { 0, 0 },
501 0
502 },
503};
504
505struct dio_cfg gw53xx_dio[] = {
506 {
507 { IOMUX_PADS(PAD_SD1_DAT0__GPIO1_IO16) },
508 IMX_GPIO_NR(1, 16),
509 { 0, 0 },
510 0
511 },
512 {
513 { IOMUX_PADS(PAD_SD1_DAT2__GPIO1_IO19) },
514 IMX_GPIO_NR(1, 19),
515 { IOMUX_PADS(PAD_SD1_DAT2__PWM2_OUT) },
516 2
517 },
518 {
519 { IOMUX_PADS(PAD_SD1_DAT1__GPIO1_IO17) },
520 IMX_GPIO_NR(1, 17),
521 { IOMUX_PADS(PAD_SD1_DAT1__PWM3_OUT) },
522 3
523 },
524 {
525 {IOMUX_PADS(PAD_SD1_CLK__GPIO1_IO20) },
526 IMX_GPIO_NR(1, 20),
527 { 0, 0 },
528 0
529 },
530};
531
532struct dio_cfg gw54xx_dio[] = {
533 {
534 { IOMUX_PADS(PAD_GPIO_9__GPIO1_IO09) },
535 IMX_GPIO_NR(1, 9),
536 { IOMUX_PADS(PAD_GPIO_9__PWM1_OUT) },
537 1
538 },
539 {
540 { IOMUX_PADS(PAD_SD1_DAT2__GPIO1_IO19) },
541 IMX_GPIO_NR(1, 19),
542 { IOMUX_PADS(PAD_SD1_DAT2__PWM2_OUT) },
543 2
544 },
545 {
546 { IOMUX_PADS(PAD_SD4_DAT1__GPIO2_IO09) },
547 IMX_GPIO_NR(2, 9),
548 { IOMUX_PADS(PAD_SD4_DAT1__PWM3_OUT) },
549 3
550 },
551 {
552 { IOMUX_PADS(PAD_SD4_DAT2__GPIO2_IO10) },
553 IMX_GPIO_NR(2, 10),
554 { IOMUX_PADS(PAD_SD4_DAT2__PWM4_OUT) },
555 4
556 },
557};
558
559struct dio_cfg gw551x_dio[] = {
560 {
561 { IOMUX_PADS(PAD_SD1_DAT2__GPIO1_IO19) },
562 IMX_GPIO_NR(1, 19),
563 { IOMUX_PADS(PAD_SD1_DAT2__PWM2_OUT) },
564 2
565 },
566 {
567 { IOMUX_PADS(PAD_SD1_DAT1__GPIO1_IO17) },
568 IMX_GPIO_NR(1, 17),
569 { IOMUX_PADS(PAD_SD1_DAT1__PWM3_OUT) },
570 3
571 },
572};
573
574struct dio_cfg gw552x_dio[] = {
575 {
576 { IOMUX_PADS(PAD_SD1_DAT0__GPIO1_IO16) },
577 IMX_GPIO_NR(1, 16),
578 { 0, 0 },
579 0
580 },
581 {
582 { IOMUX_PADS(PAD_SD1_DAT2__GPIO1_IO19) },
583 IMX_GPIO_NR(1, 19),
584 { IOMUX_PADS(PAD_SD1_DAT2__PWM2_OUT) },
585 2
586 },
587 {
588 { IOMUX_PADS(PAD_SD1_DAT1__GPIO1_IO17) },
589 IMX_GPIO_NR(1, 17),
590 { IOMUX_PADS(PAD_SD1_DAT1__PWM3_OUT) },
591 3
592 },
593 {
594 {IOMUX_PADS(PAD_SD1_CLK__GPIO1_IO20) },
595 IMX_GPIO_NR(1, 20),
596 { 0, 0 },
597 0
598 },
Tim Harveyb1243da2016-07-15 07:14:24 -0700599 {
600 {IOMUX_PADS(PAD_CSI0_PIXCLK__GPIO5_IO18) },
601 IMX_GPIO_NR(5, 18),
602 { 0, 0 },
603 0
604 },
605 {
606 {IOMUX_PADS(PAD_CSI0_DATA_EN__GPIO5_IO20) },
607 IMX_GPIO_NR(5, 20),
608 { 0, 0 },
609 0
610 },
611 {
612 {IOMUX_PADS(PAD_CSI0_VSYNC__GPIO5_IO21) },
613 IMX_GPIO_NR(5, 21),
614 { 0, 0 },
615 0
616 },
617 {
618 {IOMUX_PADS(PAD_CSI0_DAT4__GPIO5_IO22) },
619 IMX_GPIO_NR(5, 22),
620 { 0, 0 },
621 0
622 },
623 {
624 {IOMUX_PADS(PAD_CSI0_DAT5__GPIO5_IO23) },
625 IMX_GPIO_NR(5, 23),
626 { 0, 0 },
627 0
628 },
629 {
630 {IOMUX_PADS(PAD_CSI0_DAT7__GPIO5_IO25) },
631 IMX_GPIO_NR(5, 25),
632 { 0, 0 },
633 0
634 },
Tim Harvey41595b52016-07-15 07:14:23 -0700635};
636
637struct dio_cfg gw553x_dio[] = {
638 {
639 { IOMUX_PADS(PAD_SD1_DAT0__GPIO1_IO16) },
640 IMX_GPIO_NR(1, 16),
641 { 0, 0 },
642 0
643 },
644 {
645 { IOMUX_PADS(PAD_SD1_DAT2__GPIO1_IO19) },
646 IMX_GPIO_NR(1, 19),
647 { IOMUX_PADS(PAD_SD1_DAT2__PWM2_OUT) },
648 2
649 },
650 {
651 { IOMUX_PADS(PAD_SD1_DAT1__GPIO1_IO17) },
652 IMX_GPIO_NR(1, 17),
653 { IOMUX_PADS(PAD_SD1_DAT1__PWM3_OUT) },
654 3
655 },
656 {
657 { IOMUX_PADS(PAD_SD1_CMD__GPIO1_IO18) },
658 IMX_GPIO_NR(1, 18),
659 { IOMUX_PADS(PAD_SD1_CMD__PWM4_OUT) },
660 4
661 },
662};
Tim Harvey0cee2242015-05-08 18:28:35 -0700663
Tim Harvey659441b2017-03-17 07:31:02 -0700664struct dio_cfg gw560x_dio[] = {
665 {
666 { IOMUX_PADS(PAD_SD1_DAT0__GPIO1_IO16) },
667 IMX_GPIO_NR(1, 16),
668 { 0, 0 },
669 0
670 },
671 {
672 { IOMUX_PADS(PAD_SD1_DAT2__GPIO1_IO19) },
673 IMX_GPIO_NR(1, 19),
674 { IOMUX_PADS(PAD_SD1_DAT2__PWM2_OUT) },
675 2
676 },
677 {
678 { IOMUX_PADS(PAD_SD1_DAT1__GPIO1_IO17) },
679 IMX_GPIO_NR(1, 17),
680 { IOMUX_PADS(PAD_SD1_DAT1__PWM3_OUT) },
681 3
682 },
683 {
684 {IOMUX_PADS(PAD_SD1_CLK__GPIO1_IO20) },
685 IMX_GPIO_NR(1, 20),
686 { 0, 0 },
687 0
688 },
689};
690
Tim Harvey5852a332019-02-04 13:10:58 -0800691struct dio_cfg gw5901_dio[] = {
692 {
693 { IOMUX_PADS(PAD_DISP0_DAT20__GPIO5_IO14) },
694 IMX_GPIO_NR(5, 14),
695 { 0, 0 },
696 0
697 },
698 {
699 { IOMUX_PADS(PAD_DISP0_DAT21__GPIO5_IO15) },
700 IMX_GPIO_NR(5, 15),
701 { 0, 0 },
702 0
703 },
704 {
705 { IOMUX_PADS(PAD_DISP0_DAT22__GPIO5_IO16) },
706 IMX_GPIO_NR(5, 16),
707 { 0, 0 },
708 0
709 },
710 {
711 { IOMUX_PADS(PAD_DISP0_DAT23__GPIO5_IO17) },
712 IMX_GPIO_NR(5, 17),
713 { 0, 0 },
714 0
715 },
716};
717
718struct dio_cfg gw5902_dio[] = {
719 {
720 { IOMUX_PADS(PAD_DISP0_DAT20__GPIO5_IO14) },
721 IMX_GPIO_NR(5, 14),
722 { 0, 0 },
723 0
724 },
725 {
726 { IOMUX_PADS(PAD_DISP0_DAT21__GPIO5_IO15) },
727 IMX_GPIO_NR(5, 15),
728 { 0, 0 },
729 0
730 },
731 {
732 { IOMUX_PADS(PAD_DISP0_DAT22__GPIO5_IO16) },
733 IMX_GPIO_NR(5, 16),
734 { 0, 0 },
735 0
736 },
737 {
738 { IOMUX_PADS(PAD_DISP0_DAT23__GPIO5_IO17) },
739 IMX_GPIO_NR(5, 17),
740 { 0, 0 },
741 0
742 },
743};
744
Tim Harvey4533c902017-03-17 07:32:21 -0700745struct dio_cfg gw5903_dio[] = {
746};
747
Tim Harvey63537792017-03-17 07:30:38 -0700748struct dio_cfg gw5904_dio[] = {
749 {
750 { IOMUX_PADS(PAD_SD1_DAT0__GPIO1_IO16) },
751 IMX_GPIO_NR(1, 16),
752 { 0, 0 },
753 0
754 },
755 {
756 { IOMUX_PADS(PAD_SD1_DAT2__GPIO1_IO19) },
757 IMX_GPIO_NR(1, 19),
758 { IOMUX_PADS(PAD_SD1_DAT2__PWM2_OUT) },
759 2
760 },
761 {
762 { IOMUX_PADS(PAD_SD1_DAT1__GPIO1_IO17) },
763 IMX_GPIO_NR(1, 17),
764 { IOMUX_PADS(PAD_SD1_DAT1__PWM3_OUT) },
765 3
766 },
767 {
768 {IOMUX_PADS(PAD_SD1_CLK__GPIO1_IO20) },
769 IMX_GPIO_NR(1, 20),
770 { 0, 0 },
771 0
772 },
773 {
774 {IOMUX_PADS(PAD_NANDF_D0__GPIO2_IO00) },
775 IMX_GPIO_NR(2, 0),
776 { 0, 0 },
777 0
778 },
779 {
780 {IOMUX_PADS(PAD_NANDF_D1__GPIO2_IO01) },
781 IMX_GPIO_NR(2, 1),
782 { 0, 0 },
783 0
784 },
785 {
786 {IOMUX_PADS(PAD_NANDF_D2__GPIO2_IO02) },
787 IMX_GPIO_NR(2, 2),
788 { 0, 0 },
789 0
790 },
791 {
792 {IOMUX_PADS(PAD_NANDF_D3__GPIO2_IO03) },
793 IMX_GPIO_NR(2, 3),
794 { 0, 0 },
795 0
796 },
797 {
798 {IOMUX_PADS(PAD_NANDF_D4__GPIO2_IO04) },
799 IMX_GPIO_NR(2, 4),
800 { 0, 0 },
801 0
802 },
803 {
804 {IOMUX_PADS(PAD_NANDF_D5__GPIO2_IO05) },
805 IMX_GPIO_NR(2, 5),
806 { 0, 0 },
807 0
808 },
809 {
810 {IOMUX_PADS(PAD_NANDF_D6__GPIO2_IO06) },
811 IMX_GPIO_NR(2, 6),
812 { 0, 0 },
813 0
814 },
815 {
816 {IOMUX_PADS(PAD_NANDF_D7__GPIO2_IO07) },
817 IMX_GPIO_NR(2, 7),
818 { 0, 0 },
819 0
820 },
821};
822
Tim Harveyb7c48a92019-02-04 13:10:54 -0800823struct dio_cfg gw5906_dio[] = {
824 {
825 { IOMUX_PADS(PAD_SD1_DAT0__GPIO1_IO16) },
826 IMX_GPIO_NR(1, 16),
827 { 0, 0 },
828 0
829 },
830 {
831 { IOMUX_PADS(PAD_SD1_DAT2__GPIO1_IO19) },
832 IMX_GPIO_NR(1, 19),
833 { IOMUX_PADS(PAD_SD1_DAT2__PWM2_OUT) },
834 2
835 },
836 {
837 { IOMUX_PADS(PAD_SD1_DAT1__GPIO1_IO17) },
838 IMX_GPIO_NR(1, 17),
839 { IOMUX_PADS(PAD_SD1_DAT1__PWM3_OUT) },
840 3
841 },
842 {
843 {IOMUX_PADS(PAD_SD1_CLK__GPIO1_IO20) },
844 IMX_GPIO_NR(1, 20),
845 { 0, 0 },
846 0
847 },
848};
849
Tim Harveyb7c9f362021-07-24 10:40:44 -0700850struct dio_cfg gw5913_dio[] = {
851 {
852 { IOMUX_PADS(PAD_SD1_DAT0__GPIO1_IO16) },
853 IMX_GPIO_NR(1, 16),
854 { 0, 0 },
855 0
856 },
857 {
858 { IOMUX_PADS(PAD_SD1_DAT2__GPIO1_IO19) },
859 IMX_GPIO_NR(1, 19),
860 { IOMUX_PADS(PAD_SD1_DAT2__PWM2_OUT) },
861 2
862 },
863 {
864 { IOMUX_PADS(PAD_SD1_DAT1__GPIO1_IO17) },
865 IMX_GPIO_NR(1, 17),
866 { IOMUX_PADS(PAD_SD1_DAT1__PWM3_OUT) },
867 3
868 },
869 {
870 { IOMUX_PADS(PAD_SD1_CMD__GPIO1_IO18) },
871 IMX_GPIO_NR(1, 18),
872 { IOMUX_PADS(PAD_SD1_CMD__PWM4_OUT) },
873 4
874 },
875 {
876 { IOMUX_PADS(PAD_SD2_DAT0__GPIO1_IO15) },
877 IMX_GPIO_NR(1, 15),
878 { 0, 0 },
879 0
880 },
881 {
882 { IOMUX_PADS(PAD_SD2_DAT1__GPIO1_IO14) },
883 IMX_GPIO_NR(1, 14),
884 { 0, 0 },
885 0
886 },
887 {
888 { IOMUX_PADS(PAD_GPIO_19__GPIO4_IO05) },
889 IMX_GPIO_NR(4, 5),
890 { 0, 0 },
891 0
892 },
893};
894
Tim Harvey0cee2242015-05-08 18:28:35 -0700895/*
896 * Board Specific GPIO
897 */
898struct ventana gpio_cfg[GW_UNKNOWN] = {
899 /* GW5400proto */
900 {
901 .gpio_pads = gw54xx_gpio_pads,
902 .num_pads = ARRAY_SIZE(gw54xx_gpio_pads)/2,
Tim Harvey41595b52016-07-15 07:14:23 -0700903 .dio_cfg = gw54xx_dio,
904 .dio_num = ARRAY_SIZE(gw54xx_dio),
Tim Harvey0cee2242015-05-08 18:28:35 -0700905 .mezz_pwren = IMX_GPIO_NR(4, 7),
906 .mezz_irq = IMX_GPIO_NR(4, 9),
907 .rs485en = IMX_GPIO_NR(3, 24),
908 .dioi2c_en = IMX_GPIO_NR(4, 5),
909 .pcie_sson = IMX_GPIO_NR(1, 20),
Tim Harvey63537792017-03-17 07:30:38 -0700910 .mmc_cd = IMX_GPIO_NR(7, 0),
Tim Harveyd67ad6e2021-07-24 10:40:43 -0700911 .wdis = -1,
Tim Harvey0cee2242015-05-08 18:28:35 -0700912 },
913
914 /* GW51xx */
915 {
916 .gpio_pads = gw51xx_gpio_pads,
917 .num_pads = ARRAY_SIZE(gw51xx_gpio_pads)/2,
Tim Harvey41595b52016-07-15 07:14:23 -0700918 .dio_cfg = gw51xx_dio,
919 .dio_num = ARRAY_SIZE(gw51xx_dio),
Tim Harvey0cee2242015-05-08 18:28:35 -0700920 .mezz_pwren = IMX_GPIO_NR(2, 19),
921 .mezz_irq = IMX_GPIO_NR(2, 18),
922 .gps_shdn = IMX_GPIO_NR(1, 2),
Tim Harvey0cee2242015-05-08 18:28:35 -0700923 .wdis = IMX_GPIO_NR(7, 12),
924 },
925
926 /* GW52xx */
927 {
928 .gpio_pads = gw52xx_gpio_pads,
929 .num_pads = ARRAY_SIZE(gw52xx_gpio_pads)/2,
Tim Harvey41595b52016-07-15 07:14:23 -0700930 .dio_cfg = gw52xx_dio,
931 .dio_num = ARRAY_SIZE(gw52xx_dio),
Tim Harvey0cee2242015-05-08 18:28:35 -0700932 .mezz_pwren = IMX_GPIO_NR(2, 19),
933 .mezz_irq = IMX_GPIO_NR(2, 18),
934 .gps_shdn = IMX_GPIO_NR(1, 27),
Tim Harvey0cee2242015-05-08 18:28:35 -0700935 .usb_sel = IMX_GPIO_NR(1, 2),
936 .wdis = IMX_GPIO_NR(7, 12),
Tim Harvey86b75322016-05-24 11:03:56 -0700937 .msata_en = GP_MSATA_SEL,
Tim Harvey2cb61c12016-07-15 07:14:22 -0700938 .rs232_en = GP_RS232_EN,
Tim Harveyd7babd42017-03-13 08:51:08 -0700939 .vsel_pin = IMX_GPIO_NR(6, 14),
Tim Harvey63537792017-03-17 07:30:38 -0700940 .mmc_cd = IMX_GPIO_NR(7, 0),
Tim Harvey0cee2242015-05-08 18:28:35 -0700941 },
942
943 /* GW53xx */
944 {
945 .gpio_pads = gw53xx_gpio_pads,
946 .num_pads = ARRAY_SIZE(gw53xx_gpio_pads)/2,
Tim Harvey41595b52016-07-15 07:14:23 -0700947 .dio_cfg = gw53xx_dio,
948 .dio_num = ARRAY_SIZE(gw53xx_dio),
Tim Harvey0cee2242015-05-08 18:28:35 -0700949 .mezz_pwren = IMX_GPIO_NR(2, 19),
950 .mezz_irq = IMX_GPIO_NR(2, 18),
951 .gps_shdn = IMX_GPIO_NR(1, 27),
Tim Harvey0cee2242015-05-08 18:28:35 -0700952 .wdis = IMX_GPIO_NR(7, 12),
Tim Harvey86b75322016-05-24 11:03:56 -0700953 .msata_en = GP_MSATA_SEL,
Tim Harvey2cb61c12016-07-15 07:14:22 -0700954 .rs232_en = GP_RS232_EN,
Tim Harveyd7babd42017-03-13 08:51:08 -0700955 .vsel_pin = IMX_GPIO_NR(6, 14),
Tim Harvey63537792017-03-17 07:30:38 -0700956 .mmc_cd = IMX_GPIO_NR(7, 0),
Tim Harvey0cee2242015-05-08 18:28:35 -0700957 },
958
959 /* GW54xx */
960 {
961 .gpio_pads = gw54xx_gpio_pads,
962 .num_pads = ARRAY_SIZE(gw54xx_gpio_pads)/2,
Tim Harvey41595b52016-07-15 07:14:23 -0700963 .dio_cfg = gw54xx_dio,
964 .dio_num = ARRAY_SIZE(gw54xx_dio),
Tim Harvey0cee2242015-05-08 18:28:35 -0700965 .mezz_pwren = IMX_GPIO_NR(2, 19),
966 .mezz_irq = IMX_GPIO_NR(2, 18),
967 .rs485en = IMX_GPIO_NR(7, 1),
Tim Harvey0cee2242015-05-08 18:28:35 -0700968 .dioi2c_en = IMX_GPIO_NR(4, 5),
969 .pcie_sson = IMX_GPIO_NR(1, 20),
970 .wdis = IMX_GPIO_NR(5, 17),
Tim Harvey86b75322016-05-24 11:03:56 -0700971 .msata_en = GP_MSATA_SEL,
Tim Harvey2cb61c12016-07-15 07:14:22 -0700972 .rs232_en = GP_RS232_EN,
Tim Harveyd7babd42017-03-13 08:51:08 -0700973 .vsel_pin = IMX_GPIO_NR(6, 14),
Tim Harvey63537792017-03-17 07:30:38 -0700974 .mmc_cd = IMX_GPIO_NR(7, 0),
Tim Harvey0cee2242015-05-08 18:28:35 -0700975 },
976
977 /* GW551x */
978 {
979 .gpio_pads = gw551x_gpio_pads,
980 .num_pads = ARRAY_SIZE(gw551x_gpio_pads)/2,
Tim Harvey41595b52016-07-15 07:14:23 -0700981 .dio_cfg = gw551x_dio,
982 .dio_num = ARRAY_SIZE(gw551x_dio),
Tim Harvey0cee2242015-05-08 18:28:35 -0700983 .wdis = IMX_GPIO_NR(7, 12),
984 },
985
986 /* GW552x */
987 {
988 .gpio_pads = gw552x_gpio_pads,
989 .num_pads = ARRAY_SIZE(gw552x_gpio_pads)/2,
Tim Harvey41595b52016-07-15 07:14:23 -0700990 .dio_cfg = gw552x_dio,
991 .dio_num = ARRAY_SIZE(gw552x_dio),
Tim Harveydb7edfa2015-05-26 11:04:54 -0700992 .usb_sel = IMX_GPIO_NR(1, 7),
Tim Harvey0cee2242015-05-08 18:28:35 -0700993 .wdis = IMX_GPIO_NR(7, 12),
Tim Harvey86b75322016-05-24 11:03:56 -0700994 .msata_en = GP_MSATA_SEL,
Tim Harvey0cee2242015-05-08 18:28:35 -0700995 },
Tim Harvey892068c2016-05-24 11:03:58 -0700996
997 /* GW553x */
998 {
999 .gpio_pads = gw553x_gpio_pads,
1000 .num_pads = ARRAY_SIZE(gw553x_gpio_pads)/2,
Tim Harvey41595b52016-07-15 07:14:23 -07001001 .dio_cfg = gw553x_dio,
1002 .dio_num = ARRAY_SIZE(gw553x_dio),
Tim Harvey892068c2016-05-24 11:03:58 -07001003 .wdis = IMX_GPIO_NR(7, 12),
Tim Harveyd7babd42017-03-13 08:51:08 -07001004 .vsel_pin = IMX_GPIO_NR(6, 14),
Tim Harvey63537792017-03-17 07:30:38 -07001005 .mmc_cd = IMX_GPIO_NR(7, 0),
1006 },
1007
Tim Harvey659441b2017-03-17 07:31:02 -07001008 /* GW560x */
1009 {
1010 .gpio_pads = gw560x_gpio_pads,
1011 .num_pads = ARRAY_SIZE(gw560x_gpio_pads)/2,
1012 .dio_cfg = gw560x_dio,
1013 .dio_num = ARRAY_SIZE(gw560x_dio),
Tim Harvey659441b2017-03-17 07:31:02 -07001014 .mezz_pwren = IMX_GPIO_NR(2, 19),
1015 .mezz_irq = IMX_GPIO_NR(2, 18),
1016 .rs232_en = GP_RS232_EN,
Tim Harvey659441b2017-03-17 07:31:02 -07001017 .wdis = IMX_GPIO_NR(7, 12),
Tim Harvey659441b2017-03-17 07:31:02 -07001018 .mmc_cd = IMX_GPIO_NR(7, 0),
1019 },
1020
Tim Harvey5852a332019-02-04 13:10:58 -08001021 /* GW5901 */
1022 {
1023 .gpio_pads = gw5901_gpio_pads,
1024 .num_pads = ARRAY_SIZE(gw5901_gpio_pads)/2,
1025 .dio_cfg = gw5901_dio,
Tim Harveyd67ad6e2021-07-24 10:40:43 -07001026 .wdis = -1,
Tim Harvey5852a332019-02-04 13:10:58 -08001027 },
1028
1029 /* GW5902 */
1030 {
1031 .gpio_pads = gw5902_gpio_pads,
1032 .num_pads = ARRAY_SIZE(gw5902_gpio_pads)/2,
1033 .dio_cfg = gw5902_dio,
Tim Harvey5852a332019-02-04 13:10:58 -08001034 .rs232_en = GP_RS232_EN,
Tim Harveyd67ad6e2021-07-24 10:40:43 -07001035 .wdis = -1,
Tim Harvey5852a332019-02-04 13:10:58 -08001036 },
1037
Tim Harvey4533c902017-03-17 07:32:21 -07001038 /* GW5903 */
1039 {
1040 .gpio_pads = gw5903_gpio_pads,
1041 .num_pads = ARRAY_SIZE(gw5903_gpio_pads)/2,
1042 .dio_cfg = gw5903_dio,
1043 .dio_num = ARRAY_SIZE(gw5903_dio),
Tim Harvey4533c902017-03-17 07:32:21 -07001044 .mmc_cd = IMX_GPIO_NR(6, 11),
Tim Harveyd67ad6e2021-07-24 10:40:43 -07001045 .wdis = -1,
Tim Harvey4533c902017-03-17 07:32:21 -07001046 },
1047
Tim Harvey63537792017-03-17 07:30:38 -07001048 /* GW5904 */
1049 {
1050 .gpio_pads = gw5904_gpio_pads,
1051 .num_pads = ARRAY_SIZE(gw5904_gpio_pads)/2,
1052 .dio_cfg = gw5904_dio,
1053 .dio_num = ARRAY_SIZE(gw5904_dio),
Tim Harvey63537792017-03-17 07:30:38 -07001054 .mezz_pwren = IMX_GPIO_NR(2, 19),
1055 .mezz_irq = IMX_GPIO_NR(2, 18),
Tim Harveyd67ad6e2021-07-24 10:40:43 -07001056 .wdis = -1,
Tim Harvey892068c2016-05-24 11:03:58 -07001057 },
Tim Harveya2d24c92019-02-04 13:10:50 -08001058
1059 /* GW5905 */
1060 {
1061 .gpio_pads = gw5905_gpio_pads,
1062 .num_pads = ARRAY_SIZE(gw5905_gpio_pads)/2,
Tim Harveya2d24c92019-02-04 13:10:50 -08001063 .wdis = IMX_GPIO_NR(7, 13),
1064 },
Tim Harveyb7c48a92019-02-04 13:10:54 -08001065
1066 /* GW5906 */
1067 {
1068 .gpio_pads = gw552x_gpio_pads,
1069 .num_pads = ARRAY_SIZE(gw552x_gpio_pads)/2,
1070 .dio_cfg = gw5906_dio,
1071 .dio_num = ARRAY_SIZE(gw5906_dio),
Tim Harveyb7c48a92019-02-04 13:10:54 -08001072 .usb_sel = IMX_GPIO_NR(1, 7),
1073 .wdis = IMX_GPIO_NR(7, 12),
1074 .msata_en = GP_MSATA_SEL,
Tim Harveyb7c48a92019-02-04 13:10:54 -08001075 },
Tim Harvey83cad802019-02-04 13:10:55 -08001076
1077 /* GW5907 */
1078 {
1079 .gpio_pads = gw51xx_gpio_pads,
1080 .num_pads = ARRAY_SIZE(gw51xx_gpio_pads)/2,
1081 .dio_cfg = gw51xx_dio,
1082 .dio_num = ARRAY_SIZE(gw51xx_dio),
Tim Harvey83cad802019-02-04 13:10:55 -08001083 .wdis = IMX_GPIO_NR(7, 12),
Tim Harvey83cad802019-02-04 13:10:55 -08001084 },
Tim Harveyc2625402019-02-04 13:10:56 -08001085
1086 /* GW5908 */
1087 {
1088 .gpio_pads = gw53xx_gpio_pads,
1089 .num_pads = ARRAY_SIZE(gw53xx_gpio_pads)/2,
1090 .dio_cfg = gw53xx_dio,
1091 .dio_num = ARRAY_SIZE(gw53xx_dio),
Tim Harveyc2625402019-02-04 13:10:56 -08001092 .mezz_pwren = IMX_GPIO_NR(2, 19),
1093 .mezz_irq = IMX_GPIO_NR(2, 18),
1094 .gps_shdn = IMX_GPIO_NR(1, 27),
Tim Harveyc2625402019-02-04 13:10:56 -08001095 .wdis = IMX_GPIO_NR(7, 12),
1096 .msata_en = GP_MSATA_SEL,
1097 .rs232_en = GP_RS232_EN,
1098 },
Tim Harvey2df50462019-02-04 13:10:57 -08001099
1100 /* GW5909 */
1101 {
1102 .gpio_pads = gw5904_gpio_pads,
1103 .num_pads = ARRAY_SIZE(gw5904_gpio_pads)/2,
1104 .dio_cfg = gw5904_dio,
1105 .dio_num = ARRAY_SIZE(gw5904_dio),
Tim Harvey2df50462019-02-04 13:10:57 -08001106 .mezz_pwren = IMX_GPIO_NR(2, 19),
1107 .mezz_irq = IMX_GPIO_NR(2, 18),
Tim Harveyd67ad6e2021-07-24 10:40:43 -07001108 .wdis = -1,
Tim Harvey2df50462019-02-04 13:10:57 -08001109 },
Tim Harvey08aec662021-07-24 10:40:42 -07001110
1111 /* GW5910 */
1112 {
1113 .gpio_pads = gw5910_gpio_pads,
1114 .num_pads = ARRAY_SIZE(gw5910_gpio_pads) / 2,
1115 .dio_cfg = gw52xx_dio,
1116 .dio_num = ARRAY_SIZE(gw52xx_dio),
1117 .wdis = IMX_GPIO_NR(7, 12),
1118 .rs232_en = GP_RS232_EN,
1119 .vsel_pin = IMX_GPIO_NR(6, 14),
1120 .mmc_cd = IMX_GPIO_NR(7, 0),
1121 },
Tim Harveyd67ad6e2021-07-24 10:40:43 -07001122
1123 /* GW5912 */
1124 {
1125 .gpio_pads = gw5912_gpio_pads,
1126 .num_pads = ARRAY_SIZE(gw5912_gpio_pads) / 2,
1127 .dio_cfg = gw54xx_dio,
1128 .dio_num = ARRAY_SIZE(gw54xx_dio),
1129 .wdis = IMX_GPIO_NR(1, 0),
1130 .rs232_en = GP_RS232_EN,
1131 .vsel_pin = IMX_GPIO_NR(6, 14),
1132 .mmc_cd = IMX_GPIO_NR(7, 0),
1133 },
Tim Harveyb7c9f362021-07-24 10:40:44 -07001134
1135 /* GW5913 */
1136 {
1137 .gpio_pads = gw5912_gpio_pads,
1138 .num_pads = ARRAY_SIZE(gw5912_gpio_pads) / 2,
1139 .dio_cfg = gw5913_dio,
1140 .dio_num = ARRAY_SIZE(gw5913_dio),
1141 .wdis = IMX_GPIO_NR(1, 0),
1142 },
Tim Harvey0cee2242015-05-08 18:28:35 -07001143};
1144
Tim Harveya2d24c92019-02-04 13:10:50 -08001145#define SETUP_GPIO_OUTPUT(gpio, name, level) \
1146 gpio_request(gpio, name); \
1147 gpio_direction_output(gpio, level);
1148#define SETUP_GPIO_INPUT(gpio, name) \
1149 gpio_request(gpio, name); \
1150 gpio_direction_input(gpio);
Tim Harvey0cee2242015-05-08 18:28:35 -07001151void setup_iomux_gpio(int board, struct ventana_board_info *info)
1152{
Tim Harvey0cee2242015-05-08 18:28:35 -07001153 if (board >= GW_UNKNOWN)
1154 return;
1155
1156 /* board specific iomux */
1157 imx_iomux_v3_setup_multiple_pads(gpio_cfg[board].gpio_pads,
1158 gpio_cfg[board].num_pads);
1159
Tim Harvey2cb61c12016-07-15 07:14:22 -07001160 /* RS232_EN# */
1161 if (gpio_cfg[board].rs232_en) {
Tim Harvey6ea02c92017-03-13 08:51:05 -07001162 gpio_request(gpio_cfg[board].rs232_en, "rs232_en#");
Tim Harvey2cb61c12016-07-15 07:14:22 -07001163 gpio_direction_output(gpio_cfg[board].rs232_en, 0);
1164 }
1165
Tim Harvey86b75322016-05-24 11:03:56 -07001166 /* MSATA Enable - default to PCI */
1167 if (gpio_cfg[board].msata_en) {
1168 gpio_request(gpio_cfg[board].msata_en, "msata_en");
1169 gpio_direction_output(gpio_cfg[board].msata_en, 0);
1170 }
1171
Tim Harvey0cee2242015-05-08 18:28:35 -07001172 /* Expansion Mezzanine IO */
1173 if (gpio_cfg[board].mezz_pwren) {
1174 gpio_request(gpio_cfg[board].mezz_pwren, "mezz_pwr");
1175 gpio_direction_output(gpio_cfg[board].mezz_pwren, 0);
1176 }
1177 if (gpio_cfg[board].mezz_irq) {
1178 gpio_request(gpio_cfg[board].mezz_irq, "mezz_irq#");
1179 gpio_direction_input(gpio_cfg[board].mezz_irq);
1180 }
1181
1182 /* RS485 Transmit Enable */
1183 if (gpio_cfg[board].rs485en) {
1184 gpio_request(gpio_cfg[board].rs485en, "rs485_en");
1185 gpio_direction_output(gpio_cfg[board].rs485en, 0);
1186 }
1187
1188 /* GPS_SHDN */
1189 if (gpio_cfg[board].gps_shdn) {
1190 gpio_request(gpio_cfg[board].gps_shdn, "gps_shdn");
1191 gpio_direction_output(gpio_cfg[board].gps_shdn, 1);
1192 }
1193
Tim Harvey0cee2242015-05-08 18:28:35 -07001194 /* DIOI2C_DIS# */
1195 if (gpio_cfg[board].dioi2c_en) {
1196 gpio_request(gpio_cfg[board].dioi2c_en, "dioi2c_dis#");
1197 gpio_direction_output(gpio_cfg[board].dioi2c_en, 0);
1198 }
1199
1200 /* PCICK_SSON: disable spread-spectrum clock */
1201 if (gpio_cfg[board].pcie_sson) {
1202 gpio_request(gpio_cfg[board].pcie_sson, "pci_sson");
1203 gpio_direction_output(gpio_cfg[board].pcie_sson, 0);
1204 }
1205
1206 /* USBOTG mux routing */
1207 if (gpio_cfg[board].usb_sel) {
1208 gpio_request(gpio_cfg[board].usb_sel, "usb_pcisel");
1209 gpio_direction_output(gpio_cfg[board].usb_sel, 0);
1210 }
1211
1212 /* PCISKT_WDIS# (Wireless disable GPIO to miniPCIe sockets) */
Tim Harveyd67ad6e2021-07-24 10:40:43 -07001213 if (gpio_cfg[board].wdis != -1) {
Tim Harvey0cee2242015-05-08 18:28:35 -07001214 gpio_request(gpio_cfg[board].wdis, "wlan_dis");
1215 gpio_direction_output(gpio_cfg[board].wdis, 1);
1216 }
Tim Harvey147b5762016-05-24 11:03:59 -07001217
1218 /* sense vselect pin to see if we support uhs-i */
Tim Harveyd7babd42017-03-13 08:51:08 -07001219 if (gpio_cfg[board].vsel_pin) {
1220 gpio_request(gpio_cfg[board].vsel_pin, "sd3_vselect");
1221 gpio_direction_input(gpio_cfg[board].vsel_pin);
1222 gpio_cfg[board].usd_vsel = !gpio_get_value(gpio_cfg[board].vsel_pin);
1223 }
Tim Harvey63537792017-03-17 07:30:38 -07001224
1225 /* microSD CD */
1226 if (gpio_cfg[board].mmc_cd) {
1227 gpio_request(gpio_cfg[board].mmc_cd, "sd_cd");
1228 gpio_direction_input(gpio_cfg[board].mmc_cd);
1229 }
1230
1231 /* Anything else board specific */
1232 switch(board) {
Tim Harvey409fe9a2021-07-24 10:40:45 -07001233 case GW53xx:
1234 gpio_request(IMX_GPIO_NR(3, 15), "j6_pwren");
1235 gpio_direction_output(IMX_GPIO_NR(3, 15), 1);
1236 gpio_request(IMX_GPIO_NR(3, 14), "gbe_en");
1237 gpio_direction_output(IMX_GPIO_NR(3, 14), 1);
1238 break;
Tim Harvey659441b2017-03-17 07:31:02 -07001239 case GW560x:
1240 gpio_request(IMX_GPIO_NR(4, 26), "12p0_en");
1241 gpio_direction_output(IMX_GPIO_NR(4, 26), 1);
1242 break;
Tim Harvey5852a332019-02-04 13:10:58 -08001243 case GW5902:
Tim Harvey5852a332019-02-04 13:10:58 -08001244 SETUP_GPIO_OUTPUT(IMX_GPIO_NR(7, 12), "5P0V_EN", 1);
1245 break;
Tim Harvey4533c902017-03-17 07:32:21 -07001246 case GW5903:
1247 gpio_request(IMX_GPIO_NR(3, 31) , "usbh1-ehci_pwr");
1248 gpio_direction_output(IMX_GPIO_NR(3, 31), 1);
1249 gpio_request(IMX_GPIO_NR(4, 15) , "usbh2-otg_pwr");
1250 gpio_direction_output(IMX_GPIO_NR(4, 15), 1);
1251 gpio_request(IMX_GPIO_NR(4, 7) , "usbdpc_pwr");
1252 gpio_direction_output(IMX_GPIO_NR(4, 15), 1);
1253 gpio_request(IMX_GPIO_NR(1, 25) , "rgmii_en");
1254 gpio_direction_output(IMX_GPIO_NR(1, 25), 1);
1255 gpio_request(IMX_GPIO_NR(4, 6) , "touch_irq#");
1256 gpio_direction_input(IMX_GPIO_NR(4, 6));
1257 gpio_request(IMX_GPIO_NR(4, 8) , "touch_rst");
1258 gpio_direction_output(IMX_GPIO_NR(4, 8), 1);
1259 gpio_request(IMX_GPIO_NR(1, 7) , "bklt_12ven");
1260 gpio_direction_output(IMX_GPIO_NR(1, 7), 1);
1261 break;
Tim Harvey2df50462019-02-04 13:10:57 -08001262 case GW5909:
Tim Harvey63537792017-03-17 07:30:38 -07001263 case GW5904:
Tim Harvey74107f72019-02-04 13:10:59 -08001264 gpio_request(IMX_GPIO_NR(4, 23), "rs485_en");
1265 gpio_direction_output(IMX_GPIO_NR(4, 23), 0);
Tim Harvey63537792017-03-17 07:30:38 -07001266 gpio_request(IMX_GPIO_NR(5, 11), "skt1_wdis#");
1267 gpio_direction_output(IMX_GPIO_NR(5, 11), 1);
1268 gpio_request(IMX_GPIO_NR(5, 12), "skt1_rst#");
1269 gpio_direction_output(IMX_GPIO_NR(5, 12), 1);
1270 gpio_request(IMX_GPIO_NR(5, 13), "skt2_wdis#");
1271 gpio_direction_output(IMX_GPIO_NR(5, 13), 1);
1272 gpio_request(IMX_GPIO_NR(1, 15), "m2_off#");
1273 gpio_direction_output(IMX_GPIO_NR(1, 15), 1);
1274 gpio_request(IMX_GPIO_NR(1, 14), "m2_wdis#");
1275 gpio_direction_output(IMX_GPIO_NR(1, 14), 1);
1276 gpio_request(IMX_GPIO_NR(1, 13), "m2_rst#");
1277 gpio_direction_output(IMX_GPIO_NR(1, 13), 1);
1278 break;
Tim Harveya2d24c92019-02-04 13:10:50 -08001279 case GW5905:
1280 SETUP_GPIO_OUTPUT(IMX_GPIO_NR(1, 7), "usb_pcisel", 0);
1281 SETUP_GPIO_OUTPUT(IMX_GPIO_NR(1, 9), "lvds_cabc", 1);
1282 SETUP_GPIO_OUTPUT(IMX_GPIO_NR(1, 14), "mipi_pdwn", 1);
1283 SETUP_GPIO_OUTPUT(IMX_GPIO_NR(1, 15), "mipi_rst#", 0);
1284 SETUP_GPIO_OUTPUT(IMX_GPIO_NR(2, 3), "emmy_pdwn#", 1);
1285 SETUP_GPIO_OUTPUT(IMX_GPIO_NR(4, 5), "spk_shdn#", 0);
1286 SETUP_GPIO_OUTPUT(IMX_GPIO_NR(4, 8), "touch_rst", 0);
1287 SETUP_GPIO_OUTPUT(IMX_GPIO_NR(4, 6), "touch_irq", 0);
1288 SETUP_GPIO_OUTPUT(IMX_GPIO_NR(5, 5), "flash_en1", 0);
1289 SETUP_GPIO_OUTPUT(IMX_GPIO_NR(5, 6), "flash_en2", 0);
1290 SETUP_GPIO_OUTPUT(IMX_GPIO_NR(5, 14), "dect_rst#", 1);
1291 SETUP_GPIO_OUTPUT(IMX_GPIO_NR(5, 17), "codec_rst#", 0);
1292 SETUP_GPIO_OUTPUT(IMX_GPIO_NR(5, 26), "imu_den", 1);
1293 SETUP_GPIO_OUTPUT(IMX_GPIO_NR(7, 12), "lvds_cabc", 0);
1294 mdelay(100);
1295 /*
1296 * gauruntee touch controller comes out of reset with INT
1297 * low for address
1298 */
1299 SETUP_GPIO_OUTPUT(IMX_GPIO_NR(4, 8), "touch_rst", 1);
1300 break;
Tim Harvey08aec662021-07-24 10:40:42 -07001301 case GW5910:
1302 /* CC1352 */
1303 SETUP_GPIO_OUTPUT(IMX_GPIO_NR(1, 7), "rf_reset#", 1);
1304 SETUP_GPIO_OUTPUT(IMX_GPIO_NR(1, 8), "rf_boot", 1);
1305 break;
Tim Harvey63537792017-03-17 07:30:38 -07001306 }
Tim Harvey0cee2242015-05-08 18:28:35 -07001307}
1308
1309/* setup GPIO pinmux and default configuration per baseboard and env */
1310void setup_board_gpio(int board, struct ventana_board_info *info)
1311{
1312 const char *s;
1313 char arg[10];
1314 size_t len;
1315 int i;
Simon Glass64b723f2017-08-03 12:22:12 -06001316 int quiet = simple_strtol(env_get("quiet"), NULL, 10);
Tim Harvey0cee2242015-05-08 18:28:35 -07001317
1318 if (board >= GW_UNKNOWN)
1319 return;
1320
1321 /* RS232_EN# */
Tim Harvey2cb61c12016-07-15 07:14:22 -07001322 if (gpio_cfg[board].rs232_en) {
1323 gpio_direction_output(gpio_cfg[board].rs232_en,
1324 (hwconfig("rs232")) ? 0 : 1);
1325 }
Tim Harvey0cee2242015-05-08 18:28:35 -07001326
1327 /* MSATA Enable */
Tim Harvey86b75322016-05-24 11:03:56 -07001328 if (gpio_cfg[board].msata_en && is_cpu_type(MXC_CPU_MX6Q)) {
Tim Harvey0cee2242015-05-08 18:28:35 -07001329 gpio_direction_output(GP_MSATA_SEL,
Tim Harvey86b75322016-05-24 11:03:56 -07001330 (hwconfig("msata")) ? 1 : 0);
Tim Harvey0cee2242015-05-08 18:28:35 -07001331 }
1332
1333 /* USBOTG Select (PCISKT or FrontPanel) */
1334 if (gpio_cfg[board].usb_sel) {
1335 gpio_direction_output(gpio_cfg[board].usb_sel,
1336 (hwconfig("usb_pcisel")) ? 1 : 0);
1337 }
1338
1339 /*
1340 * Configure DIO pinmux/padctl registers
1341 * see IMX6DQRM/IMX6SDLRM IOMUXC_SW_PAD_CTL_PAD_* register definitions
1342 */
Tim Harvey41595b52016-07-15 07:14:23 -07001343 for (i = 0; i < gpio_cfg[board].dio_num; i++) {
Tim Harvey0cee2242015-05-08 18:28:35 -07001344 struct dio_cfg *cfg = &gpio_cfg[board].dio_cfg[i];
1345 iomux_v3_cfg_t ctrl = DIO_PAD_CFG;
1346 unsigned cputype = is_cpu_type(MXC_CPU_MX6Q) ? 0 : 1;
1347
1348 if (!cfg->gpio_padmux[0] && !cfg->gpio_padmux[1])
1349 continue;
1350 sprintf(arg, "dio%d", i);
1351 if (!hwconfig(arg))
1352 continue;
1353 s = hwconfig_subarg(arg, "padctrl", &len);
1354 if (s) {
Simon Glass3ff49ec2021-07-24 09:03:29 -06001355 ctrl = MUX_PAD_CTRL(hextoul(s, NULL)
Tim Harvey0cee2242015-05-08 18:28:35 -07001356 & 0x1ffff) | MUX_MODE_SION;
1357 }
1358 if (hwconfig_subarg_cmp(arg, "mode", "gpio")) {
1359 if (!quiet) {
1360 printf("DIO%d: GPIO%d_IO%02d (gpio-%d)\n", i,
1361 (cfg->gpio_param/32)+1,
1362 cfg->gpio_param%32,
1363 cfg->gpio_param);
1364 }
1365 imx_iomux_v3_setup_pad(cfg->gpio_padmux[cputype] |
1366 ctrl);
1367 gpio_requestf(cfg->gpio_param, "dio%d", i);
1368 gpio_direction_input(cfg->gpio_param);
Tim Harveyc0e03c32016-05-24 11:03:54 -07001369 } else if (hwconfig_subarg_cmp(arg, "mode", "pwm") &&
Tim Harvey0cee2242015-05-08 18:28:35 -07001370 cfg->pwm_padmux) {
Tim Harvey8d2d8df2016-05-24 11:03:55 -07001371 if (!cfg->pwm_param) {
1372 printf("DIO%d: Error: pwm config invalid\n",
1373 i);
1374 continue;
1375 }
Tim Harvey0cee2242015-05-08 18:28:35 -07001376 if (!quiet)
1377 printf("DIO%d: pwm%d\n", i, cfg->pwm_param);
1378 imx_iomux_v3_setup_pad(cfg->pwm_padmux[cputype] |
1379 MUX_PAD_CTRL(ctrl));
1380 }
1381 }
1382
1383 if (!quiet) {
Tim Harvey86b75322016-05-24 11:03:56 -07001384 if (gpio_cfg[board].msata_en && is_cpu_type(MXC_CPU_MX6Q)) {
Tim Harvey0cee2242015-05-08 18:28:35 -07001385 printf("MSATA: %s\n", (hwconfig("msata") ?
1386 "enabled" : "disabled"));
1387 }
Tim Harvey2cb61c12016-07-15 07:14:22 -07001388 if (gpio_cfg[board].rs232_en) {
1389 printf("RS232: %s\n", (hwconfig("rs232")) ?
1390 "enabled" : "disabled");
1391 }
Tim Harvey0cee2242015-05-08 18:28:35 -07001392 }
1393}
1394
1395/* setup board specific PMIC */
Tim Harvey195bc972015-05-08 18:28:37 -07001396void setup_pmic(void)
Tim Harvey0cee2242015-05-08 18:28:35 -07001397{
1398 struct pmic *p;
Tim Harvey659441b2017-03-17 07:31:02 -07001399 struct ventana_board_info ventana_info;
1400 int board = read_eeprom(CONFIG_I2C_GSC, &ventana_info);
Simon Glass4148d752017-04-26 22:27:47 -06001401 const int i2c_pmic = 1;
Tim Harvey0cee2242015-05-08 18:28:35 -07001402 u32 reg;
Tim Harvey5a1760b2021-06-11 12:46:22 -07001403 char rev;
1404 int i;
1405
1406 /* determine board revision */
1407 rev = 'A';
1408 for (i = sizeof(ventana_info.model) - 1; i > 0; i--) {
1409 if (ventana_info.model[i] >= 'A') {
1410 rev = ventana_info.model[i];
1411 break;
1412 }
1413 }
Tim Harvey0cee2242015-05-08 18:28:35 -07001414
Simon Glass4148d752017-04-26 22:27:47 -06001415 i2c_set_bus_num(i2c_pmic);
Tim Harvey195bc972015-05-08 18:28:37 -07001416
Tim Harvey0cee2242015-05-08 18:28:35 -07001417 /* configure PFUZE100 PMIC */
Tim Harvey195bc972015-05-08 18:28:37 -07001418 if (!i2c_probe(CONFIG_POWER_PFUZE100_I2C_ADDR)) {
1419 debug("probed PFUZE100@0x%x\n", CONFIG_POWER_PFUZE100_I2C_ADDR);
Simon Glass4148d752017-04-26 22:27:47 -06001420 power_pfuze100_init(i2c_pmic);
Tim Harvey0cee2242015-05-08 18:28:35 -07001421 p = pmic_get("PFUZE100");
1422 if (p && !pmic_probe(p)) {
1423 pmic_reg_read(p, PFUZE100_DEVICEID, &reg);
1424 printf("PMIC: PFUZE100 ID=0x%02x\n", reg);
1425
1426 /* Set VGEN1 to 1.5V and enable */
1427 pmic_reg_read(p, PFUZE100_VGEN1VOL, &reg);
1428 reg &= ~(LDO_VOL_MASK);
1429 reg |= (LDOA_1_50V | LDO_EN);
1430 pmic_reg_write(p, PFUZE100_VGEN1VOL, reg);
1431
1432 /* Set SWBST to 5.0V and enable */
1433 pmic_reg_read(p, PFUZE100_SWBSTCON1, &reg);
1434 reg &= ~(SWBST_MODE_MASK | SWBST_VOL_MASK);
Marek Vasut2aaeb912015-11-26 14:08:50 +01001435 reg |= (SWBST_5_00V | (SWBST_MODE_AUTO << SWBST_MODE_SHIFT));
Tim Harvey0cee2242015-05-08 18:28:35 -07001436 pmic_reg_write(p, PFUZE100_SWBSTCON1, reg);
Tim Harvey5a1760b2021-06-11 12:46:22 -07001437
1438 if (board == GW54xx && (rev == 'G')) {
1439 /* Disable VGEN5 */
1440 pmic_reg_write(p, PFUZE100_VGEN5VOL, 0);
1441
1442 /* Set VGEN6 to 2.5V and enable */
1443 pmic_reg_read(p, PFUZE100_VGEN6VOL, &reg);
1444 reg &= ~(LDO_VOL_MASK);
1445 reg |= (LDOB_2_50V | LDO_EN);
1446 pmic_reg_write(p, PFUZE100_VGEN6VOL, reg);
1447 }
Tim Harvey0cee2242015-05-08 18:28:35 -07001448 }
Tim Harvey0bf47d72021-06-11 12:46:23 -07001449
1450 /* put all switchers in continuous mode */
1451 pmic_reg_read(p, PFUZE100_SW1ABMODE, &reg);
1452 reg &= ~(SW_MODE_MASK);
1453 reg |= PWM_PWM;
1454 pmic_reg_write(p, PFUZE100_SW1ABMODE, reg);
1455
1456 pmic_reg_read(p, PFUZE100_SW2MODE, &reg);
1457 reg &= ~(SW_MODE_MASK);
1458 reg |= PWM_PWM;
1459 pmic_reg_write(p, PFUZE100_SW2MODE, reg);
1460
1461 pmic_reg_read(p, PFUZE100_SW3AMODE, &reg);
1462 reg &= ~(SW_MODE_MASK);
1463 reg |= PWM_PWM;
1464 pmic_reg_write(p, PFUZE100_SW3AMODE, reg);
1465
1466 pmic_reg_read(p, PFUZE100_SW3BMODE, &reg);
1467 reg &= ~(SW_MODE_MASK);
1468 reg |= PWM_PWM;
1469 pmic_reg_write(p, PFUZE100_SW3BMODE, reg);
1470
1471 pmic_reg_read(p, PFUZE100_SW4MODE, &reg);
1472 reg &= ~(SW_MODE_MASK);
1473 reg |= PWM_PWM;
1474 pmic_reg_write(p, PFUZE100_SW4MODE, reg);
Tim Harvey0cee2242015-05-08 18:28:35 -07001475 }
1476
1477 /* configure LTC3676 PMIC */
Tim Harvey195bc972015-05-08 18:28:37 -07001478 else if (!i2c_probe(CONFIG_POWER_LTC3676_I2C_ADDR)) {
1479 debug("probed LTC3676@0x%x\n", CONFIG_POWER_LTC3676_I2C_ADDR);
Simon Glass4148d752017-04-26 22:27:47 -06001480 power_ltc3676_init(i2c_pmic);
Tim Harvey0cee2242015-05-08 18:28:35 -07001481 p = pmic_get("LTC3676_PMIC");
Tim Harvey659441b2017-03-17 07:31:02 -07001482 if (!p || pmic_probe(p))
1483 return;
1484 puts("PMIC: LTC3676\n");
1485 /*
1486 * set board-specific scalar for max CPU frequency
1487 * per CPU based on the LDO enabled Operating Ranges
1488 * defined in the respective IMX6DQ and IMX6SDL
1489 * datasheets. The voltage resulting from the R1/R2
1490 * feedback inputs on Ventana is 1308mV. Note that this
1491 * is a bit shy of the Vmin of 1350mV in the datasheet
1492 * for LDO enabled mode but is as high as we can go.
1493 */
1494 switch (board) {
1495 case GW560x:
1496 /* mask PGOOD during SW3 transition */
1497 pmic_reg_write(p, LTC3676_DVB3B,
1498 0x1f | LTC3676_PGOOD_MASK);
1499 /* set SW3 (VDD_ARM) */
1500 pmic_reg_write(p, LTC3676_DVB3A, 0x1f);
1501 break;
Tim Harvey4533c902017-03-17 07:32:21 -07001502 case GW5903:
Tim Harveya2d24c92019-02-04 13:10:50 -08001503 /* mask PGOOD during SW3 transition */
Tim Harvey5f2a1892017-03-21 07:50:13 -07001504 pmic_reg_write(p, LTC3676_DVB3B,
1505 0x1f | LTC3676_PGOOD_MASK);
1506 /* set SW3 (VDD_ARM) */
1507 pmic_reg_write(p, LTC3676_DVB3A, 0x1f);
1508
Tim Harvey4533c902017-03-17 07:32:21 -07001509 /* mask PGOOD during SW4 transition */
1510 pmic_reg_write(p, LTC3676_DVB4B,
1511 0x1f | LTC3676_PGOOD_MASK);
1512 /* set SW4 (VDD_SOC) */
1513 pmic_reg_write(p, LTC3676_DVB4A, 0x1f);
1514 break;
Tim Harveya2d24c92019-02-04 13:10:50 -08001515 case GW5905:
1516 /* mask PGOOD during SW1 transition */
1517 pmic_reg_write(p, LTC3676_DVB1B,
1518 0x1f | LTC3676_PGOOD_MASK);
1519 /* set SW1 (VDD_ARM) */
1520 pmic_reg_write(p, LTC3676_DVB1A, 0x1f);
1521
1522 /* mask PGOOD during SW3 transition */
1523 pmic_reg_write(p, LTC3676_DVB3B,
1524 0x1f | LTC3676_PGOOD_MASK);
1525 /* set SW3 (VDD_SOC) */
1526 pmic_reg_write(p, LTC3676_DVB3A, 0x1f);
1527 break;
Tim Harvey659441b2017-03-17 07:31:02 -07001528 default:
Tim Harvey0cee2242015-05-08 18:28:35 -07001529 /* mask PGOOD during SW1 transition */
1530 pmic_reg_write(p, LTC3676_DVB1B,
1531 0x1f | LTC3676_PGOOD_MASK);
1532 /* set SW1 (VDD_SOC) */
1533 pmic_reg_write(p, LTC3676_DVB1A, 0x1f);
1534
1535 /* mask PGOOD during SW3 transition */
1536 pmic_reg_write(p, LTC3676_DVB3B,
1537 0x1f | LTC3676_PGOOD_MASK);
1538 /* set SW3 (VDD_ARM) */
1539 pmic_reg_write(p, LTC3676_DVB3A, 0x1f);
1540 }
Tim Harvey3b1db852021-06-11 12:46:24 -07001541
1542 /* put all switchers in continuous mode */
1543 pmic_reg_write(p, LTC3676_BUCK1, 0xc0);
1544 pmic_reg_write(p, LTC3676_BUCK2, 0xc0);
1545 pmic_reg_write(p, LTC3676_BUCK3, 0xc0);
1546 pmic_reg_write(p, LTC3676_BUCK4, 0xc0);
Tim Harvey0cee2242015-05-08 18:28:35 -07001547 }
Tim Harvey08aec662021-07-24 10:40:42 -07001548
1549 /* configure MP5416 PMIC */
1550 else if (!i2c_probe(0x69)) {
1551 puts("PMIC: MP5416\n");
1552 switch (board) {
1553 case GW5910:
1554 /* SW1: VDD_ARM 1.2V -> (1.275 to 1.475) */
1555 reg = MP5416_VSET_EN | MP5416_VSET_SW1_SVAL(1475000);
1556 i2c_write(0x69, MP5416_VSET_SW1, 1, (uint8_t *)&reg, 1);
1557 /* SW4: VDD_SOC 1.2V -> (1.350 to 1.475) */
1558 reg = MP5416_VSET_EN | MP5416_VSET_SW4_SVAL(1475000);
1559 i2c_write(0x69, MP5416_VSET_SW4, 1, (uint8_t *)&reg, 1);
1560 break;
1561 }
1562 }
Tim Harvey0cee2242015-05-08 18:28:35 -07001563}
Tim Harvey84ae1912017-03-13 08:51:03 -07001564
Tim Harvey28db4e42021-07-24 10:40:32 -07001565#include <fdt_support.h>
1566#define WDOG1_ADDR 0x20bc000
1567#define WDOG2_ADDR 0x20c0000
1568#define GPIO3_ADDR 0x20a4000
1569#define USDHC3_ADDR 0x2198000
1570
1571static void ft_board_wdog_fixup(void *blob, phys_addr_t addr)
1572{
1573 int off = fdt_node_offset_by_compat_reg(blob, "fsl,imx6q-wdt", addr);
1574
1575 if (off) {
1576 fdt_delprop(blob, off, "ext-reset-output");
1577 fdt_delprop(blob, off, "fsl,ext-reset-output");
1578 }
1579}
1580
1581void ft_early_fixup(void *blob, int board_type)
1582{
1583 struct ventana_board_info *info = &ventana_info;
1584 char rev = 0;
1585 int i;
1586
1587 /* determine board revision */
1588 for (i = sizeof(ventana_info.model) - 1; i > 0; i--) {
1589 if (ventana_info.model[i] >= 'A') {
1590 rev = ventana_info.model[i];
1591 break;
1592 }
1593 }
1594
1595 /*
1596 * Board model specific fixups
1597 */
1598 switch (board_type) {
1599 case GW51xx:
1600 /*
1601 * disable wdog node for GW51xx-A/B to work around
1602 * errata causing wdog timer to be unreliable.
1603 */
1604 if (rev >= 'A' && rev < 'C') {
1605 i = fdt_node_offset_by_compat_reg(blob, "fsl,imx6q-wdt",
1606 WDOG1_ADDR);
1607 if (i)
1608 fdt_status_disabled(blob, i);
1609 }
1610
1611 /* GW51xx-E adds WDOG1_B external reset */
1612 if (rev < 'E')
1613 ft_board_wdog_fixup(blob, WDOG1_ADDR);
1614 break;
1615
1616 case GW52xx:
1617 /* GW522x Uses GPIO3_IO23 instead of GPIO1_IO29 */
1618 if (info->model[4] == '2') {
1619 u32 handle = 0;
1620 u32 *range = NULL;
1621
1622 i = fdt_node_offset_by_compatible(blob, -1,
1623 "fsl,imx6q-pcie");
1624 if (i)
1625 range = (u32 *)fdt_getprop(blob, i,
1626 "reset-gpio", NULL);
1627
1628 if (range) {
1629 i = fdt_node_offset_by_compat_reg(blob,
1630 "fsl,imx6q-gpio", GPIO3_ADDR);
1631 if (i)
1632 handle = fdt_get_phandle(blob, i);
1633 if (handle) {
1634 range[0] = cpu_to_fdt32(handle);
1635 range[1] = cpu_to_fdt32(23);
1636 }
1637 }
1638
1639 /* these have broken usd_vsel */
1640 if (strstr((const char *)info->model, "SP318-B") ||
1641 strstr((const char *)info->model, "SP331-B"))
1642 gpio_cfg[board_type].usd_vsel = 0;
1643
1644 /* GW522x-B adds WDOG1_B external reset */
1645 if (rev < 'B')
1646 ft_board_wdog_fixup(blob, WDOG1_ADDR);
1647 }
1648
1649 /* GW520x-E adds WDOG1_B external reset */
1650 else if (info->model[4] == '0' && rev < 'E')
1651 ft_board_wdog_fixup(blob, WDOG1_ADDR);
1652 break;
1653
1654 case GW53xx:
1655 /* GW53xx-E adds WDOG1_B external reset */
1656 if (rev < 'E')
1657 ft_board_wdog_fixup(blob, WDOG1_ADDR);
Tim Harvey409fe9a2021-07-24 10:40:45 -07001658
1659 /* GW53xx-G has an adv7280 instead of an adv7180 */
1660 else if (rev > 'F') {
1661 i = fdt_node_offset_by_compatible(blob, -1, "adi,adv7180");
1662 if (i) {
1663 fdt_setprop_string(blob, i, "compatible", "adi,adv7280");
1664 fdt_setprop_empty(blob, i, "adv,force-bt656-4");
1665 }
1666 }
Tim Harvey28db4e42021-07-24 10:40:32 -07001667 break;
1668
1669 case GW54xx:
1670 /*
1671 * disable serial2 node for GW54xx for compatibility with older
1672 * 3.10.x kernel that improperly had this node enabled in the DT
1673 */
1674 fdt_set_status_by_alias(blob, "serial2", FDT_STATUS_DISABLED,
1675 0);
1676
1677 /* GW54xx-E adds WDOG2_B external reset */
1678 if (rev < 'E')
1679 ft_board_wdog_fixup(blob, WDOG2_ADDR);
1680 break;
1681
1682 case GW551x:
1683 /* GW551x-C adds WDOG1_B external reset */
1684 if (rev < 'C')
1685 ft_board_wdog_fixup(blob, WDOG1_ADDR);
1686 break;
1687 case GW5901:
1688 case GW5902:
1689 /* GW5901/GW5901 revB adds WDOG1_B as an external reset */
1690 if (rev < 'B')
1691 ft_board_wdog_fixup(blob, WDOG1_ADDR);
1692 break;
1693 }
1694
1695 /* remove no-1-8-v if UHS-I support is present */
1696 if (gpio_cfg[board_type].usd_vsel) {
1697 debug("Enabling UHS-I support\n");
1698 i = fdt_node_offset_by_compat_reg(blob, "fsl,imx6q-usdhc",
1699 USDHC3_ADDR);
1700 if (i)
1701 fdt_delprop(blob, i, "no-1-8-v");
1702 }
1703}
1704
Yangbo Lu73340382019-06-21 11:42:28 +08001705#ifdef CONFIG_FSL_ESDHC_IMX
Tim Harvey659441b2017-03-17 07:31:02 -07001706static struct fsl_esdhc_cfg usdhc_cfg[2];
Tim Harvey84ae1912017-03-13 08:51:03 -07001707
Masahiro Yamadaf7ed78b2020-06-26 15:13:33 +09001708int board_mmc_init(struct bd_info *bis)
Tim Harvey84ae1912017-03-13 08:51:03 -07001709{
Tim Harvey63537792017-03-17 07:30:38 -07001710 struct ventana_board_info ventana_info;
1711 int board_type = read_eeprom(CONFIG_I2C_GSC, &ventana_info);
1712 int ret;
Tim Harvey84ae1912017-03-13 08:51:03 -07001713
Tim Harvey63537792017-03-17 07:30:38 -07001714 switch (board_type) {
1715 case GW52xx:
1716 case GW53xx:
1717 case GW54xx:
1718 case GW553x:
Tim Harvey08aec662021-07-24 10:40:42 -07001719 case GW5910:
Tim Harveyd67ad6e2021-07-24 10:40:43 -07001720 case GW5912:
Tim Harvey63537792017-03-17 07:30:38 -07001721 /* usdhc3: 4bit microSD */
1722 SETUP_IOMUX_PADS(usdhc3_pads);
Tim Harvey659441b2017-03-17 07:31:02 -07001723 usdhc_cfg[0].esdhc_base = USDHC3_BASE_ADDR;
1724 usdhc_cfg[0].sdhc_clk = mxc_get_clock(MXC_ESDHC3_CLK);
1725 usdhc_cfg[0].max_bus_width = 4;
1726 return fsl_esdhc_initialize(bis, &usdhc_cfg[0]);
1727 case GW560x:
1728 /* usdhc2: 8-bit eMMC */
1729 SETUP_IOMUX_PADS(gw560x_emmc_sd2_pads);
1730 usdhc_cfg[0].esdhc_base = USDHC2_BASE_ADDR;
1731 usdhc_cfg[0].sdhc_clk = mxc_get_clock(MXC_ESDHC2_CLK);
1732 usdhc_cfg[0].max_bus_width = 8;
1733 ret = fsl_esdhc_initialize(bis, &usdhc_cfg[0]);
1734 if (ret)
1735 return ret;
1736 /* usdhc3: 4-bit microSD */
1737 SETUP_IOMUX_PADS(usdhc3_pads);
1738 usdhc_cfg[1].esdhc_base = USDHC3_BASE_ADDR;
1739 usdhc_cfg[1].sdhc_clk = mxc_get_clock(MXC_ESDHC3_CLK);
1740 usdhc_cfg[1].max_bus_width = 4;
1741 return fsl_esdhc_initialize(bis, &usdhc_cfg[1]);
Tim Harvey4533c902017-03-17 07:32:21 -07001742 case GW5903:
1743 /* usdhc3: 8-bit eMMC */
1744 SETUP_IOMUX_PADS(gw5904_emmc_pads);
1745 usdhc_cfg[0].esdhc_base = USDHC3_BASE_ADDR;
1746 usdhc_cfg[0].sdhc_clk = mxc_get_clock(MXC_ESDHC3_CLK);
1747 usdhc_cfg[0].max_bus_width = 8;
1748 ret = fsl_esdhc_initialize(bis, &usdhc_cfg[0]);
1749 if (ret)
1750 return ret;
1751 /* usdhc2: 4-bit microSD */
1752 SETUP_IOMUX_PADS(gw5904_mmc_pads);
1753 usdhc_cfg[1].esdhc_base = USDHC2_BASE_ADDR;
1754 usdhc_cfg[1].sdhc_clk = mxc_get_clock(MXC_ESDHC2_CLK);
1755 usdhc_cfg[1].max_bus_width = 4;
1756 return fsl_esdhc_initialize(bis, &usdhc_cfg[1]);
Tim Harvey63537792017-03-17 07:30:38 -07001757 case GW5904:
Tim Harveya2d24c92019-02-04 13:10:50 -08001758 case GW5905:
Tim Harvey2df50462019-02-04 13:10:57 -08001759 case GW5909:
Tim Harvey63537792017-03-17 07:30:38 -07001760 /* usdhc3: 8bit eMMC */
1761 SETUP_IOMUX_PADS(gw5904_emmc_pads);
Tim Harvey659441b2017-03-17 07:31:02 -07001762 usdhc_cfg[0].esdhc_base = USDHC3_BASE_ADDR;
1763 usdhc_cfg[0].sdhc_clk = mxc_get_clock(MXC_ESDHC3_CLK);
1764 usdhc_cfg[0].max_bus_width = 8;
1765 return fsl_esdhc_initialize(bis, &usdhc_cfg[0]);
Tim Harvey63537792017-03-17 07:30:38 -07001766 default:
1767 /* doesn't have MMC */
Tim Harveyd0744d12021-06-11 12:46:28 -07001768 printf("None");
Tim Harvey63537792017-03-17 07:30:38 -07001769 return -1;
1770 }
Tim Harvey84ae1912017-03-13 08:51:03 -07001771}
1772
1773int board_mmc_getcd(struct mmc *mmc)
1774{
Tim Harvey63537792017-03-17 07:30:38 -07001775 struct ventana_board_info ventana_info;
1776 struct fsl_esdhc_cfg *cfg = (struct fsl_esdhc_cfg *)mmc->priv;
1777 int board = read_eeprom(CONFIG_I2C_GSC, &ventana_info);
1778 int gpio = gpio_cfg[board].mmc_cd;
1779
Tim Harvey84ae1912017-03-13 08:51:03 -07001780 /* Card Detect */
Tim Harvey63537792017-03-17 07:30:38 -07001781 switch (board) {
Tim Harvey659441b2017-03-17 07:31:02 -07001782 case GW560x:
1783 /* emmc is always present */
1784 if (cfg->esdhc_base == USDHC2_BASE_ADDR)
1785 return 1;
1786 break;
Tim Harvey4533c902017-03-17 07:32:21 -07001787 case GW5903:
Tim Harvey63537792017-03-17 07:30:38 -07001788 case GW5904:
Tim Harveya2d24c92019-02-04 13:10:50 -08001789 case GW5905:
Tim Harvey2df50462019-02-04 13:10:57 -08001790 case GW5909:
Tim Harvey63537792017-03-17 07:30:38 -07001791 /* emmc is always present */
1792 if (cfg->esdhc_base == USDHC3_BASE_ADDR)
1793 return 1;
1794 break;
1795 }
1796
1797 if (gpio) {
1798 debug("%s: gpio%d=%d\n", __func__, gpio, gpio_get_value(gpio));
1799 return !gpio_get_value(gpio);
1800 }
1801
1802 return -1;
Tim Harvey84ae1912017-03-13 08:51:03 -07001803}
Tim Harvey63537792017-03-17 07:30:38 -07001804
Yangbo Lu73340382019-06-21 11:42:28 +08001805#endif /* CONFIG_FSL_ESDHC_IMX */