xref: /openbmc/u-boot/arch/x86/include/asm/gpio.h (revision 7b6dc11c)
1 /*
2  * Copyright (c) 2012, Google Inc. All rights reserved.
3  * SPDX-License-Identifier:	GPL-2.0
4  */
5 
6 #ifndef _X86_GPIO_H_
7 #define _X86_GPIO_H_
8 
9 #include <linux/compiler.h>
10 #include <asm-generic/gpio.h>
11 
12 struct ich6_bank_platdata {
13 	uint16_t base_addr;
14 	const char *bank_name;
15 };
16 
17 #define GPIO_MODE_NATIVE	0
18 #define GPIO_MODE_GPIO		1
19 #define GPIO_MODE_NONE		1
20 
21 #define GPIO_DIR_OUTPUT		0
22 #define GPIO_DIR_INPUT		1
23 
24 #define GPIO_NO_INVERT		0
25 #define GPIO_INVERT		1
26 
27 #define GPIO_LEVEL_LOW		0
28 #define GPIO_LEVEL_HIGH		1
29 
30 #define GPIO_NO_BLINK		0
31 #define GPIO_BLINK		1
32 
33 #define GPIO_RESET_PWROK	0
34 #define GPIO_RESET_RSMRST	1
35 
36 struct pch_gpio_set1 {
37 	u32 gpio0:1;
38 	u32 gpio1:1;
39 	u32 gpio2:1;
40 	u32 gpio3:1;
41 	u32 gpio4:1;
42 	u32 gpio5:1;
43 	u32 gpio6:1;
44 	u32 gpio7:1;
45 	u32 gpio8:1;
46 	u32 gpio9:1;
47 	u32 gpio10:1;
48 	u32 gpio11:1;
49 	u32 gpio12:1;
50 	u32 gpio13:1;
51 	u32 gpio14:1;
52 	u32 gpio15:1;
53 	u32 gpio16:1;
54 	u32 gpio17:1;
55 	u32 gpio18:1;
56 	u32 gpio19:1;
57 	u32 gpio20:1;
58 	u32 gpio21:1;
59 	u32 gpio22:1;
60 	u32 gpio23:1;
61 	u32 gpio24:1;
62 	u32 gpio25:1;
63 	u32 gpio26:1;
64 	u32 gpio27:1;
65 	u32 gpio28:1;
66 	u32 gpio29:1;
67 	u32 gpio30:1;
68 	u32 gpio31:1;
69 } __packed;
70 
71 struct pch_gpio_set2 {
72 	u32 gpio32:1;
73 	u32 gpio33:1;
74 	u32 gpio34:1;
75 	u32 gpio35:1;
76 	u32 gpio36:1;
77 	u32 gpio37:1;
78 	u32 gpio38:1;
79 	u32 gpio39:1;
80 	u32 gpio40:1;
81 	u32 gpio41:1;
82 	u32 gpio42:1;
83 	u32 gpio43:1;
84 	u32 gpio44:1;
85 	u32 gpio45:1;
86 	u32 gpio46:1;
87 	u32 gpio47:1;
88 	u32 gpio48:1;
89 	u32 gpio49:1;
90 	u32 gpio50:1;
91 	u32 gpio51:1;
92 	u32 gpio52:1;
93 	u32 gpio53:1;
94 	u32 gpio54:1;
95 	u32 gpio55:1;
96 	u32 gpio56:1;
97 	u32 gpio57:1;
98 	u32 gpio58:1;
99 	u32 gpio59:1;
100 	u32 gpio60:1;
101 	u32 gpio61:1;
102 	u32 gpio62:1;
103 	u32 gpio63:1;
104 } __packed;
105 
106 struct pch_gpio_set3 {
107 	u32 gpio64:1;
108 	u32 gpio65:1;
109 	u32 gpio66:1;
110 	u32 gpio67:1;
111 	u32 gpio68:1;
112 	u32 gpio69:1;
113 	u32 gpio70:1;
114 	u32 gpio71:1;
115 	u32 gpio72:1;
116 	u32 gpio73:1;
117 	u32 gpio74:1;
118 	u32 gpio75:1;
119 } __packed;
120 
121 /*
122  * This hilariously complex structure came from Coreboot. The
123  * setup_pch_gpios() function uses it. It could be move to device tree, or
124  * adjust to use masks instead of bitfields.
125  */
126 struct pch_gpio_map {
127 	struct {
128 		const struct pch_gpio_set1 *mode;
129 		const struct pch_gpio_set1 *direction;
130 		const struct pch_gpio_set1 *level;
131 		const struct pch_gpio_set1 *reset;
132 		const struct pch_gpio_set1 *invert;
133 		const struct pch_gpio_set1 *blink;
134 	} set1;
135 	struct {
136 		const struct pch_gpio_set2 *mode;
137 		const struct pch_gpio_set2 *direction;
138 		const struct pch_gpio_set2 *level;
139 		const struct pch_gpio_set2 *reset;
140 	} set2;
141 	struct {
142 		const struct pch_gpio_set3 *mode;
143 		const struct pch_gpio_set3 *direction;
144 		const struct pch_gpio_set3 *level;
145 		const struct pch_gpio_set3 *reset;
146 	} set3;
147 };
148 
149 int gpio_ich6_pinctrl_init(void);
150 void setup_pch_gpios(u16 gpiobase, const struct pch_gpio_map *gpio);
151 void ich_gpio_set_gpio_map(const struct pch_gpio_map *map);
152 
153 #endif /* _X86_GPIO_H_ */
154