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 <baseboard/gpio.h>
4 #include <baseboard/variants.h>
5 #include <commonlib/helpers.h>
7 
8 static const struct pad_config ssd_sku_gpio_table[] = {
9  /* A0 : SAR0_INT_ODL */
10  PAD_CFG_GPI_INT(GPP_A0, NONE, PLTRST, LEVEL),
11  /* A6 : SAR1_INT_ODL */
12  PAD_CFG_GPI_INT(GPP_A6, NONE, PLTRST, LEVEL),
13  /* A8 : PEN_GARAGE_DET_L (wake) */
14  PAD_CFG_GPI_SCI(GPP_A8, NONE, DEEP, EDGE_SINGLE, NONE),
15  /* A10 : FPMCU_PCH_BOOT1 */
16  PAD_CFG_GPO(GPP_A10, 0, DEEP),
17  /* A11 : PCH_SPI_FPMCU_CS_L */
18  PAD_CFG_NF(GPP_A11, NONE, DEEP, NF2),
19  /* A12 : FPMCU_RST_ODL */
20  PAD_CFG_GPO(GPP_A12, 0, DEEP),
21  /* C15 : WWAN_DPR_SAR_ODL
22  *
23  * TODO: Driver doesn't use this pin as of now. In case driver starts
24  * using this pin, expose this pin to driver.
25  */
26  PAD_CFG_GPO(GPP_C15, 1, DEEP),
27  /* F3 : MEM_STRAP_3 */
28  PAD_CFG_GPI(GPP_F3, NONE, PLTRST),
29  /* F10 : MEM_STRAP_2 */
30  PAD_CFG_GPI(GPP_F10, NONE, PLTRST),
31  /* F11 : EMMC_CMD ==> NC */
33  /* F12 : EMMC_DATA0 ==> NC */
35  /* F13 : EMMC_DATA1 ==> NC */
37  /* F14 : EMMC_DATA2 ==> NC */
39  /* F15 : EMMC_DATA3 ==> NC */
41  /* F16 : EMMC_DATA4 ==> NC */
43  /* F17 : EMMC_DATA5 ==> NC */
45  /* F18 : EMMC_DATA6 ==> NC */
47  /* F19 : EMMC_DATA7 ==> NC */
49  /* F20 : EMMC_RCLK ==> NC */
51  /* F21 : EMMC_CLK ==> NC */
53  /* F22 : EMMC_RESET# ==> NC */
55  /* H3 : SPKR_PA_EN */
56  PAD_CFG_GPO(GPP_H3, 0, DEEP),
57  /* H19 : MEM_STRAP_0 */
58  PAD_CFG_GPI(GPP_H19, NONE, PLTRST),
59  /* H22 : MEM_STRAP_1 */
60  PAD_CFG_GPI(GPP_H22, NONE, PLTRST),
61 };
62 
63 static const struct pad_config emmc_sku_gpio_table[] = {
64  /* A0 : SAR0_INT_ODL */
65  PAD_CFG_GPI_INT(GPP_A0, NONE, PLTRST, LEVEL),
66  /* A6 : SAR1_INT_ODL */
67  PAD_CFG_GPI_INT(GPP_A6, NONE, PLTRST, LEVEL),
68  /* A8 : PEN_GARAGE_DET_L (wake) */
69  PAD_CFG_GPI_SCI(GPP_A8, NONE, DEEP, EDGE_SINGLE, NONE),
70  /* A10 : FPMCU_PCH_BOOT1 */
71  PAD_CFG_GPO(GPP_A10, 0, DEEP),
72  /* A11 : PCH_SPI_FPMCU_CS_L */
73  PAD_CFG_NF(GPP_A11, NONE, DEEP, NF2),
74  /* A12 : FPMCU_RST_ODL */
75  PAD_CFG_GPO(GPP_A12, 0, DEEP),
76  /* E1 : M2_SSD_PEDET ==> NC */
77  PAD_NC(GPP_E1, NONE),
78  /* E4 : M2_SSD_PE_WAKE_ODL ==> NC */
79  PAD_NC(GPP_E4, NONE),
80  /* E5 : SATA_DEVSLP1 ==> NC */
81  PAD_NC(GPP_E5, NONE),
82  /* C15 : WWAN_DPR_SAR_ODL
83  *
84  * TODO: Driver doesn't use this pin as of now. In case driver starts
85  * using this pin, expose this pin to driver.
86  */
87  PAD_CFG_GPO(GPP_C15, 1, DEEP),
88  /* F3 : MEM_STRAP_3 */
89  PAD_CFG_GPI(GPP_F3, NONE, PLTRST),
90  /* F10 : MEM_STRAP_2 */
91  PAD_CFG_GPI(GPP_F10, NONE, PLTRST),
92  /* F11 : EMMC_CMD ==> EMMC_CMD */
93  PAD_CFG_NF(GPP_F11, NONE, DEEP, NF1),
94  /* F12 : EMMC_DATA0 ==> EMMC_DAT0 */
95  PAD_CFG_NF(GPP_F12, NONE, DEEP, NF1),
96  /* F13 : EMMC_DATA1 ==> EMMC_DAT1 */
97  PAD_CFG_NF(GPP_F13, NONE, DEEP, NF1),
98  /* F14 : EMMC_DATA2 ==> EMMC_DAT2 */
99  PAD_CFG_NF(GPP_F14, NONE, DEEP, NF1),
100  /* F15 : EMMC_DATA3 ==> EMMC_DAT3 */
101  PAD_CFG_NF(GPP_F15, NONE, DEEP, NF1),
102  /* F16 : EMMC_DATA4 ==> EMMC_DAT4 */
103  PAD_CFG_NF(GPP_F16, NONE, DEEP, NF1),
104  /* F17 : EMMC_DATA5 ==> EMMC_DAT5 */
105  PAD_CFG_NF(GPP_F17, NONE, DEEP, NF1),
106  /* F18 : EMMC_DATA6 ==> EMMC_DAT6 */
107  PAD_CFG_NF(GPP_F18, NONE, DEEP, NF1),
108  /* F19 : EMMC_DATA7 ==> EMMC_DAT7 */
109  PAD_CFG_NF(GPP_F19, NONE, DEEP, NF1),
110  /* F20 : EMMC_RCLK ==> EMMC_RCLK */
111  PAD_CFG_NF(GPP_F20, NONE, DEEP, NF1),
112  /* F21 : EMMC_CLK ==> EMMC_CLK */
113  PAD_CFG_NF(GPP_F21, NONE, DEEP, NF1),
114  /* F22 : EMMC_RESET# ==> EMMC_RST_L */
115  PAD_CFG_NF(GPP_F22, NONE, DEEP, NF1),
116  /* H3 : SPKR_PA_EN */
117  PAD_CFG_GPO(GPP_H3, 0, DEEP),
118  /* H19 : MEM_STRAP_0 */
119  PAD_CFG_GPI(GPP_H19, NONE, PLTRST),
120  /* H22 : MEM_STRAP_1 */
121  PAD_CFG_GPI(GPP_H22, NONE, PLTRST),
122 };
123 
124 static const struct pad_config gpio_table[] = {
125  /* A0 : SAR0_INT_ODL */
126  PAD_CFG_GPI_INT(GPP_A0, NONE, PLTRST, LEVEL),
127  /* A6 : SAR1_INT_ODL */
128  PAD_CFG_GPI_INT(GPP_A6, NONE, PLTRST, LEVEL),
129  /* A8 : PEN_GARAGE_DET_L (wake) */
130  PAD_CFG_GPI_SCI(GPP_A8, NONE, DEEP, EDGE_SINGLE, NONE),
131  /* A10 : FPMCU_PCH_BOOT1 */
132  PAD_CFG_GPO(GPP_A10, 0, DEEP),
133  /* A11 : PCH_SPI_FPMCU_CS_L */
134  PAD_CFG_NF(GPP_A11, NONE, DEEP, NF2),
135  /* A12 : FPMCU_RST_ODL */
136  PAD_CFG_GPO(GPP_A12, 0, DEEP),
137  /* C15 : WWAN_DPR_SAR_ODL
138  *
139  * TODO: Driver doesn't use this pin as of now. In case driver starts
140  * using this pin, expose this pin to driver.
141  */
142  PAD_CFG_GPO(GPP_C15, 1, DEEP),
143  /* F3 : MEM_STRAP_3 */
144  PAD_CFG_GPI(GPP_F3, NONE, PLTRST),
145  /* F10 : MEM_STRAP_2 */
146  PAD_CFG_GPI(GPP_F10, NONE, PLTRST),
147  /* F11 : EMMC_CMD ==> EMMC_CMD */
148  PAD_CFG_NF(GPP_F11, NONE, DEEP, NF1),
149  /* F12 : EMMC_DATA0 ==> EMMC_DAT0 */
150  PAD_CFG_NF(GPP_F12, NONE, DEEP, NF1),
151  /* F13 : EMMC_DATA1 ==> EMMC_DAT1 */
152  PAD_CFG_NF(GPP_F13, NONE, DEEP, NF1),
153  /* F14 : EMMC_DATA2 ==> EMMC_DAT2 */
154  PAD_CFG_NF(GPP_F14, NONE, DEEP, NF1),
155  /* F15 : EMMC_DATA3 ==> EMMC_DAT3 */
156  PAD_CFG_NF(GPP_F15, NONE, DEEP, NF1),
157  /* F16 : EMMC_DATA4 ==> EMMC_DAT4 */
158  PAD_CFG_NF(GPP_F16, NONE, DEEP, NF1),
159  /* F17 : EMMC_DATA5 ==> EMMC_DAT5 */
160  PAD_CFG_NF(GPP_F17, NONE, DEEP, NF1),
161  /* F18 : EMMC_DATA6 ==> EMMC_DAT6 */
162  PAD_CFG_NF(GPP_F18, NONE, DEEP, NF1),
163  /* F19 : EMMC_DATA7 ==> EMMC_DAT7 */
164  PAD_CFG_NF(GPP_F19, NONE, DEEP, NF1),
165  /* F20 : EMMC_RCLK ==> EMMC_RCLK */
166  PAD_CFG_NF(GPP_F20, NONE, DEEP, NF1),
167  /* F21 : EMMC_CLK ==> EMMC_CLK */
168  PAD_CFG_NF(GPP_F21, NONE, DEEP, NF1),
169  /* F22 : EMMC_RESET# ==> EMMC_RST_L */
170  PAD_CFG_NF(GPP_F22, NONE, DEEP, NF1),
171  /* H3 : SPKR_PA_EN */
172  PAD_CFG_GPO(GPP_H3, 0, DEEP),
173  /* H19 : MEM_STRAP_0 */
174  PAD_CFG_GPI(GPP_H19, NONE, PLTRST),
175  /* H22 : MEM_STRAP_1 */
176  PAD_CFG_GPI(GPP_H22, NONE, PLTRST),
177 };
178 
179 const struct pad_config *override_gpio_table(size_t *num)
180 {
182  /* For SSD SKU */
183  if (sku_id == 1 || sku_id == 3 || sku_id == 23 || sku_id == 24) {
185  return ssd_sku_gpio_table;
186  }
187  /* For eMMC SKU */
188  if (sku_id == 2 || sku_id == 4 || sku_id == 21 || sku_id == 22) {
190  return emmc_sku_gpio_table;
191  }
192  *num = ARRAY_SIZE(gpio_table);
193  return gpio_table;
194 }
195 
196 /*
197  * GPIOs configured before ramstage
198  * Note: the Hatch platform's romstage will configure
199  * the MEM_STRAP_* (a.k.a GPIO_MEM_CONFIG_*) pins
200  * as inputs before it reads them, so they are not
201  * needed in this table.
202  */
203 static const struct pad_config early_gpio_table[] = {
204  /* B15 : H1_SLAVE_SPI_CS_L */
205  PAD_CFG_NF(GPP_B15, NONE, DEEP, NF1),
206  /* B16 : H1_SLAVE_SPI_CLK */
207  PAD_CFG_NF(GPP_B16, NONE, DEEP, NF1),
208  /* B17 : H1_SLAVE_SPI_MISO_R */
209  PAD_CFG_NF(GPP_B17, NONE, DEEP, NF1),
210  /* B18 : H1_SLAVE_SPI_MOSI_R */
211  PAD_CFG_NF(GPP_B18, NONE, DEEP, NF1),
212  /* C8 : UART_PCH_RX_DEBUG_TX */
213  PAD_CFG_NF(GPP_C8, NONE, DEEP, NF1),
214  /* C9 : UART_PCH_TX_DEBUG_RX */
215  PAD_CFG_NF(GPP_C9, NONE, DEEP, NF1),
216  /* C14 : BT_DISABLE_L */
217  PAD_CFG_GPO(GPP_C14, 0, DEEP),
218  /* PCH_WP_OD */
219  PAD_CFG_GPI(GPP_C20, NONE, DEEP),
220  /* C21 : H1_PCH_INT_ODL */
221  PAD_CFG_GPI_APIC(GPP_C21, NONE, PLTRST, LEVEL, INVERT),
222  /* C22 : EC_IN_RW_OD */
223  PAD_CFG_GPI(GPP_C22, NONE, DEEP),
224  /* C23 : WLAN_PE_RST# */
225  PAD_CFG_GPO(GPP_C23, 1, DEEP),
226  /* E1 : M2_SSD_PEDET */
227  PAD_CFG_NF(GPP_E1, NONE, DEEP, NF1),
228  /* E5 : SATA_DEVSLP1 */
229  PAD_CFG_NF(GPP_E5, NONE, PLTRST, NF1),
230  /* F2 : MEM_CH_SEL */
231  PAD_CFG_GPI(GPP_F2, NONE, PLTRST),
232 };
233 
234 const struct pad_config *variant_early_gpio_table(size_t *num)
235 {
237  return early_gpio_table;
238 }
#define GPP_H22
#define GPP_C15
#define GPP_H19
#define GPP_F21
#define GPP_F12
#define GPP_F16
#define GPP_F20
#define GPP_B16
Definition: gpio_soc_defs.h:69
#define GPP_C9
#define GPP_C22
#define GPP_B15
Definition: gpio_soc_defs.h:68
#define GPP_C23
#define GPP_C8
#define GPP_A6
#define GPP_E5
#define GPP_A0
#define GPP_C20
#define GPP_F17
#define GPP_A12
#define GPP_F15
#define GPP_F10
#define GPP_F13
#define GPP_C21
#define GPP_F14
#define GPP_H3
#define GPP_A10
#define GPP_A8
#define GPP_B18
Definition: gpio_soc_defs.h:71
#define GPP_A11
#define GPP_C14
#define GPP_F2
#define GPP_F18
#define GPP_F22
#define GPP_F11
#define GPP_F3
#define GPP_B17
Definition: gpio_soc_defs.h:70
#define GPP_E4
#define GPP_E1
#define GPP_F19
uint32_t sku_id(void)
#define ARRAY_SIZE(a)
Definition: helpers.h:12
uint32_t google_chromeec_get_board_sku(void)
Definition: ec_skuid.c:6
const struct pad_config * variant_early_gpio_table(size_t *num)
Definition: gpio.c:204
const struct pad_config * override_gpio_table(size_t *num)
Definition: gpio.c:124
static const struct pad_config emmc_sku_gpio_table[]
Definition: gpio.c:63
static const struct pad_config ssd_sku_gpio_table[]
Definition: gpio.c:8
static const struct pad_config gpio_table[]
Definition: gpio.c:124
static const struct pad_config early_gpio_table[]
Definition: gpio.c:203
#define PAD_NC(pin)
Definition: gpio_defs.h:263
#define PAD_CFG_GPI(pad, pull, rst)
Definition: gpio_defs.h:284
#define PAD_CFG_NF(pad, pull, rst, func)
Definition: gpio_defs.h:197
#define PAD_CFG_GPI_INT(pad, pull, rst, trig)
Definition: gpio_defs.h:348
#define PAD_CFG_GPI_APIC(pad, pull, rst, trig, inv)
Definition: gpio_defs.h:376
#define PAD_CFG_GPO(pad, val, rst)
Definition: gpio_defs.h:247
#define PAD_CFG_GPI_SCI(pad, pull, rst, trig, inv)
Definition: gpio_defs.h:432
unsigned int uint32_t
Definition: stdint.h:14