coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
gpio.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <mainboard/gpio.h>
4 #include <soc/gpe.h>
5 #include <soc/gpio.h>
6 
7 static const struct pad_config gpio_table[] = {
8  /* GPIO Group GPP_A */
9  PAD_CFG_NF(GPP_A0, NONE, DEEP, NF1),
10  PAD_CFG_NF(GPP_A1, NONE, DEEP, NF1),
11  PAD_CFG_NF(GPP_A2, NONE, DEEP, NF1),
12  PAD_CFG_NF(GPP_A3, NONE, DEEP, NF1),
13  PAD_CFG_NF(GPP_A4, NONE, DEEP, NF1),
14  PAD_CFG_NF(GPP_A5, NONE, DEEP, NF1),
15  PAD_CFG_NF(GPP_A6, NONE, DEEP, NF1),
16  PAD_CFG_NF(GPP_A7, NONE, DEEP, NF1),
17  PAD_CFG_NF(GPP_A8, NONE, DEEP, NF1),
18  PAD_CFG_NF(GPP_A9, NONE, DEEP, NF1),
19  PAD_CFG_NF(GPP_A10, NONE, DEEP, NF1),
20  PAD_CFG_NF(GPP_A11, NONE, DEEP, NF1),
22  PAD_CFG_NF(GPP_A13, NONE, DEEP, NF1),
23  PAD_CFG_NF(GPP_A14, NONE, DEEP, NF1),
24  PAD_CFG_NF(GPP_A15, NONE, DEEP, NF1),
25  PAD_CFG_NF(GPP_A16, NONE, DEEP, NF1),
28  /* GPP_A19 - RESERVED */
33  PAD_CFG_GPO(GPP_B0, 1, DEEP),
34  PAD_CFG_GPO(GPP_B1, 1, DEEP),
35  PAD_NC(GPP_B2, NONE),
36  PAD_NC(GPP_B3, NONE),
37  PAD_NC(GPP_B4, NONE),
38  PAD_NC(GPP_B5, NONE),
39  PAD_NC(GPP_B6, NONE),
40  PAD_NC(GPP_B7, NONE),
41  PAD_NC(GPP_B8, NONE),
42  PAD_NC(GPP_B9, NONE),
44  PAD_CFG_GPO(GPP_B11, 0, DEEP),
45  PAD_CFG_NF(GPP_B12, NONE, DEEP, NF1),
46  PAD_CFG_NF(GPP_B13, NONE, DEEP, NF1),
47  PAD_CFG_NF(GPP_B14, NONE, PLTRST, NF1),
53  PAD_CFG_GPO(GPP_B20, 1, PLTRST),
56  PAD_CFG_NF(GPP_B23, NONE, DEEP, NF2),
57 
58  /* GPIO Group GPP_C */
59  /* GPP_C0 - RESERVED */
60  /* GPP_C1 - RESERVED */
61  PAD_NC(GPP_C2, NONE),
62  /* GPP_C3 - RESERVED */
63  /* GPP_C4 - RESERVED */
64  PAD_CFG_GPO(GPP_C5, 1, DEEP),
65  /* GPP_C6 - RESERVED */
66  /* GPP_C7 - RESERVED */
67  PAD_NC(GPP_C8, NONE),
68  PAD_NC(GPP_C9, NONE),
81  PAD_CFG_GPI_SMI(GPP_C22, UP_20K, DEEP, EDGE_SINGLE, NONE),
83 
84  /* GPIO Group GPP_D */
85  PAD_NC(GPP_D0, NONE),
86  PAD_CFG_GPO(GPP_D1, 1, DEEP),
87  PAD_CFG_GPI_NMI(GPP_D2, UP_20K, DEEP, EDGE_SINGLE, NONE),
88  PAD_NC(GPP_D3, NONE),
89  PAD_CFG_GPO(GPP_D4, 0, PLTRST),
90  PAD_NC(GPP_D5, NONE),
91  PAD_NC(GPP_D6, NONE),
92  PAD_NC(GPP_D7, NONE),
93  PAD_NC(GPP_D8, NONE),
94  PAD_NC(GPP_D9, NONE),
100  PAD_NC(GPP_D15, NONE),
101  PAD_NC(GPP_D16, NONE),
102  PAD_NC(GPP_D17, NONE),
103  PAD_CFG_GPO(GPP_D18, 1, PLTRST),
104  PAD_CFG_GPO(GPP_D19, 1, PLTRST),
105  PAD_NC(GPP_D20, NONE),
106  PAD_CFG_GPO(GPP_D21, 0, DEEP),
107  PAD_NC(GPP_D22, NONE),
108  PAD_NC(GPP_D23, NONE),
109 
110  /* GPIO Group GPP_E */
111  PAD_NC(GPP_E0, NONE),
112  PAD_NC(GPP_E1, NONE),
113  PAD_NC(GPP_E2, NONE),
114  PAD_NC(GPP_E3, NONE),
115  PAD_NC(GPP_E4, NONE),
116  PAD_NC(GPP_E5, NONE),
117  PAD_CFG_GPI_NMI(GPP_E6, UP_20K, PLTRST, EDGE_SINGLE, NONE),
118  PAD_NC(GPP_E7, NONE),
119  PAD_CFG_NF(GPP_E8, NONE, DEEP, NF1),
120  PAD_CFG_NF(GPP_E9, NONE, DEEP, NF1),
121  PAD_CFG_NF(GPP_E10, NONE, DEEP, NF1),
122  PAD_CFG_NF(GPP_E11, NONE, DEEP, NF1),
123  PAD_CFG_NF(GPP_E12, NONE, DEEP, NF1),
124 
125  /* GPIO Group GPP_F */
126  PAD_NC(GPP_F0, NONE),
127  PAD_NC(GPP_F1, NONE),
128  PAD_NC(GPP_F2, NONE),
129  PAD_NC(GPP_F3, NONE),
130  PAD_NC(GPP_F4, NONE),
132  PAD_CFG_GPO(GPP_F6, 1, PLTRST),
133  PAD_CFG_GPO(GPP_F7, 1, PLTRST),
134  PAD_CFG_GPO(GPP_F8, 1, PLTRST),
135  PAD_NC(GPP_F9, NONE),
136  PAD_CFG_NF(GPP_F10, NONE, DEEP, NF1),
137  PAD_CFG_NF(GPP_F11, NONE, DEEP, NF1),
138  PAD_CFG_NF(GPP_F12, NONE, DEEP, NF1),
139  PAD_CFG_NF(GPP_F13, NONE, DEEP, NF1),
140  PAD_NC(GPP_F14, NONE),
141  PAD_CFG_NF(GPP_F15, NONE, DEEP, NF1),
142  PAD_CFG_NF(GPP_F16, NONE, DEEP, NF1),
143  PAD_NC(GPP_F17, NONE),
144  PAD_NC(GPP_F18, NONE),
145  PAD_NC(GPP_F19, NONE),
146  PAD_NC(GPP_F20, NONE),
147  PAD_NC(GPP_F21, NONE),
148  PAD_NC(GPP_F22, NONE),
149  PAD_CFG_GPO(GPP_F23, 0, RSMRST),
150  PAD_NC(GPP_G0, NONE),
151  PAD_NC(GPP_G1, NONE),
152  PAD_NC(GPP_G2, NONE),
153  PAD_NC(GPP_G3, NONE),
154  PAD_NC(GPP_G4, NONE),
155  PAD_NC(GPP_G5, NONE),
156  PAD_NC(GPP_G6, NONE),
157  PAD_NC(GPP_G7, NONE),
158  PAD_NC(GPP_G8, NONE),
159  PAD_NC(GPP_G9, NONE),
160  PAD_NC(GPP_G10, NONE),
161  PAD_NC(GPP_G11, NONE),
162  PAD_NC(GPP_G12, NONE),
163  PAD_NC(GPP_G13, NONE),
164  PAD_NC(GPP_G14, NONE),
165  PAD_NC(GPP_G15, NONE),
166  PAD_NC(GPP_G16, NONE),
167  PAD_NC(GPP_G17, NONE),
168  PAD_CFG_NF(GPP_G18, NONE, DEEP, NF1),
169  PAD_CFG_NF(GPP_G19, NONE, DEEP, NF1),
170  PAD_NC(GPP_G20, NONE),
171  PAD_NC(GPP_G21, NONE),
172  PAD_NC(GPP_G22, NONE),
173  PAD_NC(GPP_G23, NONE),
174  PAD_CFG_GPO(GPP_H0, 1, DEEP),
175  PAD_NC(GPP_H1, NONE),
176  PAD_CFG_GPO(GPP_H2, 1, DEEP),
177  PAD_CFG_NF(GPP_H3, NONE, DEEP, NF1),
178  PAD_NC(GPP_H4, NONE),
179  PAD_CFG_GPO(GPP_H5, 1, PLTRST),
180  PAD_CFG_GPO(GPP_H6, 1, PLTRST),
181  PAD_CFG_GPO(GPP_H7, 1, PLTRST),
182  PAD_CFG_GPO(GPP_H8, 1, PLTRST),
183  PAD_CFG_GPO(GPP_H9, 1, PLTRST),
184  PAD_CFG_NF(GPP_H10, NONE, DEEP, NF1),
185  PAD_CFG_NF(GPP_H11, NONE, DEEP, NF1),
186  PAD_NC(GPP_H12, NONE),
187  PAD_CFG_NF(GPP_H13, NONE, DEEP, NF1),
188  PAD_CFG_NF(GPP_H14, NONE, DEEP, NF1),
189  PAD_NC(GPP_H15, NONE),
190  PAD_CFG_NF(GPP_H16, NONE, DEEP, NF1),
191  PAD_CFG_NF(GPP_H17, NONE, DEEP, NF1),
192  PAD_NC(GPP_H18, NONE),
193  PAD_CFG_GPO(GPP_H19, 1, PLTRST),
194  PAD_CFG_GPO(GPP_H20, 1, PLTRST),
195  PAD_CFG_GPO(GPP_H21, 1, PLTRST),
196  PAD_CFG_GPO(GPP_H22, 1, PLTRST),
197  PAD_CFG_GPO(GPP_H23, 1, PLTRST),
198 
199  /* GPIO Group GPD */
200  PAD_NC(GPD0, NONE),
201  PAD_NC(GPD1, NONE),
202  PAD_CFG_NF(GPD2, NONE, PWROK, NF1),
203  PAD_CFG_NF(GPD3, NONE, PWROK, NF1),
204  PAD_CFG_NF(GPD4, NONE, PWROK, NF1),
205  PAD_CFG_NF(GPD5, NONE, PWROK, NF1),
206  PAD_CFG_NF(GPD6, NONE, PWROK, NF1),
207  PAD_NC(GPD7, NONE),
208  PAD_CFG_NF(GPD8, NONE, PWROK, NF1),
209  PAD_NC(GPD9, NONE),
210  PAD_NC(GPD10, NONE),
211  PAD_NC(GPD11, NONE),
212 
213  /* GPIO Group GPP_I */
214  PAD_CFG_NF(GPP_I0, NONE, DEEP, NF1),
215  PAD_CFG_NF(GPP_I1, NONE, DEEP, NF1),
216  PAD_CFG_NF(GPP_I2, NONE, DEEP, NF1),
217  PAD_CFG_NF(GPP_I3, NONE, PLTRST, NF1),
218  PAD_NC(GPP_I4, NONE),
219  PAD_CFG_NF(GPP_I5, NONE, DEEP, NF1),
220  PAD_CFG_NF(GPP_I6, NONE, DEEP, NF1),
221  PAD_CFG_NF(GPP_I7, NONE, DEEP, NF1),
222  PAD_CFG_NF(GPP_I8, NONE, DEEP, NF1),
223  PAD_CFG_NF(GPP_I9, NONE, DEEP, NF1),
224  PAD_CFG_NF(GPP_I10, NONE, DEEP, NF1),
225 };
226 
228 {
230 }
#define GPD11
#define GPP_A4
#define GPP_H22
#define GPP_C15
#define GPD3
#define GPP_H20
#define GPP_B6
Definition: gpio_soc_defs.h:59
#define GPP_H19
#define GPP_D1
#define GPD9
#define GPP_C2
#define GPP_D10
#define GPP_D8
#define GPP_D17
#define GPP_E3
#define GPP_A18
#define GPP_F21
#define GPP_C12
#define GPP_F12
#define GPP_F16
#define GPP_H15
#define GPP_H16
#define GPP_E0
#define GPP_F6
#define GPP_H18
#define GPP_D14
#define GPP_B1
Definition: gpio_soc_defs.h:54
#define GPP_F20
#define GPP_F23
#define GPP_C5
#define GPP_H11
#define GPP_A14
#define GPP_B12
Definition: gpio_soc_defs.h:65
#define GPP_H17
#define GPP_D12
#define GPP_B16
Definition: gpio_soc_defs.h:69
#define GPP_A5
#define GPP_B2
Definition: gpio_soc_defs.h:55
#define GPP_D7
#define GPP_B13
Definition: gpio_soc_defs.h:66
#define GPP_E6
#define GPP_F0
#define GPP_D6
#define GPP_D2
#define GPP_H12
#define GPP_H6
#define GPP_C9
#define GPP_H2
#define GPP_C22
#define GPP_H9
#define GPD0
#define GPP_D9
#define GPP_F5
#define GPP_B15
Definition: gpio_soc_defs.h:68
#define GPP_A2
#define GPP_H21
#define GPP_C23
#define GPP_H13
#define GPP_C8
#define GPP_D11
#define GPP_H7
#define GPP_A6
#define GPP_H1
#define GPP_C11
#define GPP_H14
#define GPP_D5
#define GPP_B22
Definition: gpio_soc_defs.h:75
#define GPP_A23
#define GPP_C18
#define GPP_F9
#define GPP_C13
#define GPP_E9
#define GPP_C17
#define GPP_E8
#define GPP_A7
#define GPP_E5
#define GPP_A0
#define GPD7
#define GPP_B8
Definition: gpio_soc_defs.h:61
#define GPP_C20
#define GPP_B20
Definition: gpio_soc_defs.h:73
#define GPP_A20
#define GPP_A16
#define GPP_F1
#define GPP_F17
#define GPP_A12
#define GPP_F15
#define GPP_D4
#define GPP_C10
#define GPD2
#define GPP_F10
#define GPP_A3
#define GPP_E7
#define GPP_C16
#define GPP_F7
#define GPD1
#define GPP_F13
#define GPP_D18
#define GPP_B19
Definition: gpio_soc_defs.h:72
#define GPP_E2
#define GPP_H0
#define GPP_H5
#define GPP_C21
#define GPP_B9
Definition: gpio_soc_defs.h:62
#define GPD10
#define GPP_F14
#define GPP_H3
#define GPP_F4
#define GPP_A10
#define GPP_A8
#define GPP_D0
#define GPP_A1
#define GPP_B14
Definition: gpio_soc_defs.h:67
#define GPP_B11
Definition: gpio_soc_defs.h:64
#define GPP_D13
#define GPP_B18
Definition: gpio_soc_defs.h:71
#define GPP_B5
Definition: gpio_soc_defs.h:58
#define GPP_B0
Definition: gpio_soc_defs.h:53
#define GPP_A11
#define GPP_C14
#define GPP_A15
#define GPP_A9
#define GPP_E10
#define GPP_F8
#define GPP_C19
#define GPD8
#define GPP_A13
#define GPP_A21
#define GPP_B23
Definition: gpio_soc_defs.h:76
#define GPP_B10
Definition: gpio_soc_defs.h:63
#define GPP_D19
#define GPP_F2
#define GPP_E11
#define GPD6
#define GPP_F18
#define GPP_B3
Definition: gpio_soc_defs.h:56
#define GPP_A22
#define GPP_F22
#define GPP_D15
#define GPP_F11
#define GPP_B21
Definition: gpio_soc_defs.h:74
#define GPD4
#define GPP_B4
Definition: gpio_soc_defs.h:57
#define GPP_D16
#define GPP_F3
#define GPP_H10
#define GPP_E12
#define GPP_A17
#define GPP_B17
Definition: gpio_soc_defs.h:70
#define GPP_E4
#define GPD5
#define GPP_E1
#define GPP_H8
#define GPP_F19
#define GPP_H4
#define GPP_H23
#define GPP_B7
Definition: gpio_soc_defs.h:60
#define GPP_D3
#define ARRAY_SIZE(a)
Definition: helpers.h:12
#define GPP_D23
#define GPP_G1
Definition: gpio_soc_defs.h:89
#define GPP_G7
Definition: gpio_soc_defs.h:95
#define GPP_D22
#define GPP_G4
Definition: gpio_soc_defs.h:92
#define GPP_G2
Definition: gpio_soc_defs.h:90
#define GPP_D21
#define GPP_G6
Definition: gpio_soc_defs.h:94
#define GPP_G0
Definition: gpio_soc_defs.h:88
#define GPP_D20
#define GPP_G3
Definition: gpio_soc_defs.h:91
#define GPP_G5
Definition: gpio_soc_defs.h:93
#define GPP_G21
#define GPP_G16
Definition: gpio_soc_defs.h:98
#define GPP_G8
Definition: gpio_soc_defs.h:90
#define GPP_G20
#define GPP_G12
Definition: gpio_soc_defs.h:94
#define GPP_G15
Definition: gpio_soc_defs.h:97
#define GPP_G17
Definition: gpio_soc_defs.h:99
#define GPP_G11
Definition: gpio_soc_defs.h:93
#define GPP_G23
#define GPP_G18
#define GPP_G19
#define GPP_G13
Definition: gpio_soc_defs.h:95
#define GPP_G14
Definition: gpio_soc_defs.h:96
#define GPP_G10
Definition: gpio_soc_defs.h:92
#define GPP_G22
#define GPP_G9
Definition: gpio_soc_defs.h:91
#define GPP_I5
#define GPP_I10
#define GPP_I8
#define GPP_I7
#define GPP_I3
#define GPP_I6
#define GPP_I9
#define GPP_I2
#define GPP_I0
#define GPP_I4
#define GPP_I1
void mainboard_configure_gpios(void)
Definition: gpio.c:223
const struct pad_config gpio_table[]
Definition: gpio.c:33
void gpio_configure_pads(const struct soc_amd_gpio *gpio_list_ptr, size_t size)
program a particular set of GPIO
Definition: gpio.c:307
#define PAD_NC(pin)
Definition: gpio_defs.h:263
#define PAD_CFG_GPI_SMI(pad, pull, rst, trig, inv)
Definition: gpio_defs.h:412
#define PAD_CFG_NF(pad, pull, rst, func)
Definition: gpio_defs.h:197
#define PAD_CFG_GPI_APIC_HIGH(pad, pull, rst)
Definition: gpio_defs.h:405
#define PAD_CFG_GPI_NMI(pad, pull, rst, trig, inv)
Definition: gpio_defs.h:477
#define PAD_CFG_GPO(pad, val, rst)
Definition: gpio_defs.h:247