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  /* A18 : NC */
11  /* A19 : NC */
13  /* A22 : NC */
15  /* A23 : NC */
17  /* B20 : NC */
19  /* B21 : NC */
21  /* B22 : NC */
23  /* C11 : NC */
25  /* F1 : NC */
26  PAD_NC(GPP_F1, NONE),
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 : NC */
33  /* F12 : NC */
35  /* F13 : NC */
37  /* F14 : NC */
39  /* F15 : NC */
41  /* F16 : NC */
43  /* F17 : NC */
45  /* F18 : NC */
47  /* F19 : NC */
49  /* F20 : NC */
51  /* F21 : NC */
53  /* F22 : NC */
55  /* H6 : NC */
56  PAD_NC(GPP_H6, NONE),
57  /* H7 : NC */
58  PAD_NC(GPP_H7, NONE),
59  /* H19 : MEM_STRAP_0 */
60  PAD_CFG_GPI(GPP_H19, NONE, PLTRST),
61  /* H22 : MEM_STRAP_1 */
62  PAD_CFG_GPI(GPP_H22, NONE, PLTRST),
63 };
64 
65 static const struct pad_config gpio_table[] = {
66  /* A18 : NC */
68  /* A19 : NC */
70  /* A22 : NC */
72  /* A23 : NC */
74  /* B20 : NC */
76  /* B21 : NC */
78  /* B22 : NC */
80  /* C11 : NC */
82  /* F1 : NC */
83  PAD_NC(GPP_F1, NONE),
84  /* F3 : MEM_STRAP_3 */
85  PAD_CFG_GPI(GPP_F3, NONE, PLTRST),
86  /* F10 : MEM_STRAP_2 */
87  PAD_CFG_GPI(GPP_F10, NONE, PLTRST),
88  /* F11 : EMMC_CMD ==> EMMC_CMD */
89  PAD_CFG_NF(GPP_F11, NONE, DEEP, NF1),
90  /* F12 : EMMC_DATA0 ==> EMMC_DAT0 */
91  PAD_CFG_NF(GPP_F12, NONE, DEEP, NF1),
92  /* F13 : EMMC_DATA1 ==> EMMC_DAT1 */
93  PAD_CFG_NF(GPP_F13, NONE, DEEP, NF1),
94  /* F14 : EMMC_DATA2 ==> EMMC_DAT2 */
95  PAD_CFG_NF(GPP_F14, NONE, DEEP, NF1),
96  /* F15 : EMMC_DATA3 ==> EMMC_DAT3 */
97  PAD_CFG_NF(GPP_F15, NONE, DEEP, NF1),
98  /* F16 : EMMC_DATA4 ==> EMMC_DAT4 */
99  PAD_CFG_NF(GPP_F16, NONE, DEEP, NF1),
100  /* F17 : EMMC_DATA5 ==> EMMC_DAT5 */
101  PAD_CFG_NF(GPP_F17, NONE, DEEP, NF1),
102  /* F18 : EMMC_DATA6 ==> EMMC_DAT6 */
103  PAD_CFG_NF(GPP_F18, NONE, DEEP, NF1),
104  /* F19 : EMMC_DATA7 ==> EMMC_DAT7 */
105  PAD_CFG_NF(GPP_F19, NONE, DEEP, NF1),
106  /* F20 : EMMC_RCLK ==> EMMC_RCLK */
107  PAD_CFG_NF(GPP_F20, NONE, DEEP, NF1),
108  /* F21 : EMMC_CLK ==> EMMC_CLK */
109  PAD_CFG_NF(GPP_F21, NONE, DEEP, NF1),
110  /* F22 : EMMC_RESET# ==> EMMC_RST_L */
111  PAD_CFG_NF(GPP_F22, NONE, DEEP, NF1),
112  /* H3 : SPKR_PA_EN */
113  PAD_CFG_GPO(GPP_H3, 0, DEEP),
114  /* H6 : NC */
115  PAD_NC(GPP_H6, NONE),
116  /* H7 : NC */
117  PAD_NC(GPP_H7, NONE),
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 const struct pad_config *override_gpio_table(size_t *num)
125 {
127  /* For SSD SKU */
128  if ((sku_id == 2) || (sku_id == 4)) {
130  return ssd_sku_gpio_table;
131  }
132  *num = ARRAY_SIZE(gpio_table);
133  return gpio_table;
134 }
135 
136 /*
137  * GPIOs configured before ramstage
138  * Note: the Hatch platform's romstage will configure
139  * the MEM_STRAP_* (a.k.a GPIO_MEM_CONFIG_*) pins
140  * as inputs before it reads them, so they are not
141  * needed in this table.
142  */
143 static const struct pad_config early_gpio_table[] = {
144  /* A12 : NC */
145  PAD_NC(GPP_A12, NONE),
146  /* B15 : H1_SLAVE_SPI_CS_L */
147  PAD_CFG_NF(GPP_B15, NONE, DEEP, NF1),
148  /* B16 : H1_SLAVE_SPI_CLK */
149  PAD_CFG_NF(GPP_B16, NONE, DEEP, NF1),
150  /* B17 : H1_SLAVE_SPI_MISO_R */
151  PAD_CFG_NF(GPP_B17, NONE, DEEP, NF1),
152  /* B18 : H1_SLAVE_SPI_MOSI_R */
153  PAD_CFG_NF(GPP_B18, NONE, DEEP, NF1),
154  /* C8 : UART_PCH_RX_DEBUG_TX */
155  PAD_CFG_NF(GPP_C8, NONE, DEEP, NF1),
156  /* C9 : UART_PCH_TX_DEBUG_RX */
157  PAD_CFG_NF(GPP_C9, NONE, DEEP, NF1),
158  /* C14 : BT_DISABLE_L */
159  PAD_CFG_GPO(GPP_C14, 0, DEEP),
160  /* PCH_WP_OD */
161  PAD_CFG_GPI(GPP_C20, NONE, DEEP),
162  /* C21 : H1_PCH_INT_ODL */
163  PAD_CFG_GPI_APIC(GPP_C21, NONE, PLTRST, LEVEL, INVERT),
164  /* C22 : EC_IN_RW_OD */
165  PAD_CFG_GPI(GPP_C22, NONE, DEEP),
166  /* C23 : WLAN_PE_RST# */
167  PAD_CFG_GPO(GPP_C23, 1, DEEP),
168  /* E1 : M2_SSD_PEDET */
169  PAD_CFG_NF(GPP_E1, NONE, DEEP, NF1),
170  /* E5 : SATA_DEVSLP1 */
171  PAD_CFG_NF(GPP_E5, NONE, PLTRST, NF1),
172  /* F2 : MEM_CH_SEL */
173  PAD_CFG_GPI(GPP_F2, NONE, PLTRST),
174 };
175 
176 const struct pad_config *variant_early_gpio_table(size_t *num)
177 {
179  return early_gpio_table;
180 }
#define GPP_H22
#define GPP_H19
#define GPP_A18
#define GPP_F21
#define GPP_F12
#define GPP_F16
#define GPP_F20
#define GPP_B16
Definition: gpio_soc_defs.h:69
#define GPP_A19
#define GPP_H6
#define GPP_C9
#define GPP_C22
#define GPP_B15
Definition: gpio_soc_defs.h:68
#define GPP_C23
#define GPP_C8
#define GPP_H7
#define GPP_C11
#define GPP_B22
Definition: gpio_soc_defs.h:75
#define GPP_A23
#define GPP_E5
#define GPP_C20
#define GPP_B20
Definition: gpio_soc_defs.h:73
#define GPP_F1
#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_B18
Definition: gpio_soc_defs.h:71
#define GPP_C14
#define GPP_F2
#define GPP_F18
#define GPP_A22
#define GPP_F22
#define GPP_F11
#define GPP_B21
Definition: gpio_soc_defs.h:74
#define GPP_F3
#define GPP_B17
Definition: gpio_soc_defs.h:70
#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 ssd_sku_gpio_table[]
Definition: gpio.c:8
static const struct pad_config gpio_table[]
Definition: gpio.c:65
static const struct pad_config early_gpio_table[]
Definition: gpio.c:143
#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_APIC(pad, pull, rst, trig, inv)
Definition: gpio_defs.h:376
#define PAD_CFG_GPO(pad, val, rst)
Definition: gpio_defs.h:247
unsigned int uint32_t
Definition: stdint.h:14