1 /*
2  * Copyright (C) 2013 Gateworks Corporation
3  *
4  * Author: Tim Harvey <tharvey@gateworks.com>
5  *
6  * SPDX-License-Identifier: GPL-2.0+
7  */
8 
9 #ifndef _GWVENTANA_COMMON_H_
10 #define _GWVENTANA_COMMON_H_
11 
12 #include "ventana_eeprom.h"
13 
14 /* GPIO's common to all baseboards */
15 #define GP_PHY_RST	IMX_GPIO_NR(1, 30)
16 #define GP_SD3_CD	IMX_GPIO_NR(7, 0)
17 #define GP_RS232_EN	IMX_GPIO_NR(2, 11)
18 #define GP_MSATA_SEL	IMX_GPIO_NR(2, 8)
19 
20 #define UART_PAD_CTRL  (PAD_CTL_PKE | PAD_CTL_PUE |		\
21 	PAD_CTL_PUS_100K_UP | PAD_CTL_SPEED_MED |		\
22 	PAD_CTL_DSE_40ohm   | PAD_CTL_SRE_FAST  | PAD_CTL_HYS)
23 
24 #define USDHC_PAD_CTRL (PAD_CTL_PKE | PAD_CTL_PUE |		\
25 	PAD_CTL_PUS_47K_UP  | PAD_CTL_SPEED_LOW |		\
26 	PAD_CTL_DSE_80ohm   | PAD_CTL_SRE_FAST  | PAD_CTL_HYS)
27 
28 #define ENET_PAD_CTRL  (PAD_CTL_PKE | PAD_CTL_PUE |		\
29 	PAD_CTL_PUS_100K_UP | PAD_CTL_SPEED_MED	  |		\
30 	PAD_CTL_DSE_40ohm   | PAD_CTL_HYS)
31 
32 #define SPI_PAD_CTRL (PAD_CTL_HYS |				\
33 	PAD_CTL_PUS_100K_DOWN | PAD_CTL_SPEED_MED |		\
34 	PAD_CTL_DSE_40ohm     | PAD_CTL_SRE_FAST)
35 
36 #define I2C_PAD_CTRL  (PAD_CTL_PUS_100K_UP |			\
37 	PAD_CTL_SPEED_MED | PAD_CTL_DSE_40ohm | PAD_CTL_HYS |	\
38 	PAD_CTL_ODE | PAD_CTL_SRE_FAST)
39 
40 #define IRQ_PAD_CTRL  (PAD_CTL_PKE | PAD_CTL_PUE |		\
41 	PAD_CTL_PUS_100K_UP | PAD_CTL_SPEED_MED |		\
42 	PAD_CTL_DSE_34ohm | PAD_CTL_HYS | PAD_CTL_SRE_FAST)
43 
44 #define DIO_PAD_CFG   (MUX_PAD_CTRL(IRQ_PAD_CTRL) | MUX_MODE_SION)
45 
46 #define PC MUX_PAD_CTRL(I2C_PAD_CTRL)
47 
48 /*
49  * each baseboard has an optional set user configurable Digital IO lines which
50  * can be pinmuxed as a GPIO or in some cases a PWM
51  */
52 struct dio_cfg {
53 	iomux_v3_cfg_t gpio_padmux[2];
54 	unsigned gpio_param;
55 	iomux_v3_cfg_t pwm_padmux[2];
56 	unsigned pwm_param;
57 };
58 
59 struct ventana {
60 	/* pinmux */
61 	iomux_v3_cfg_t const *gpio_pads;
62 	int num_pads;
63 	/* DIO pinmux/val */
64 	struct dio_cfg *dio_cfg;
65 	int dio_num;
66 	/* various gpios (0 if non-existent) */
67 	int leds[3];
68 	int pcie_rst;
69 	int mezz_pwren;
70 	int mezz_irq;
71 	int rs485en;
72 	int gps_shdn;
73 	int vidin_en;
74 	int dioi2c_en;
75 	int pcie_sson;
76 	int usb_sel;
77 	int wdis;
78 	int msata_en;
79 	int rs232_en;
80 	int otgpwr_en;
81 	int vsel_pin;
82 	/* various features */
83 	bool usd_vsel;
84 };
85 
86 extern struct ventana gpio_cfg[GW_UNKNOWN];
87 
88 /* configure i2c iomux */
89 void setup_ventana_i2c(void);
90 /* configure uart iomux */
91 void setup_iomux_uart(void);
92 /* conifgure PMIC */
93 void setup_pmic(void);
94 /* configure gpio iomux/defaults */
95 void setup_iomux_gpio(int board, struct ventana_board_info *);
96 /* late setup of GPIO (configuration per baseboard and env) */
97 void setup_board_gpio(int board, struct ventana_board_info *);
98 
99 #endif /* #ifndef _GWVENTANA_COMMON_H_ */
100