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-or-later */
2 
3 #include <baseboard/gpio.h>
4 #include <baseboard/variants.h>
5 #include <commonlib/helpers.h>
6 #include <soc/gpio.h>
7 
8 /* Pad configuration in ramstage */
9 static const struct pad_config override_gpio_table[] = {
10  /* A6 : ESPI_ALERT1# ==> NC */
11  PAD_NC(GPP_A6, NONE),
12  /* A7 : SRCCLK_OE7# ==> NC */
13  PAD_NC(GPP_A7, NONE),
14  /* A8 : SRCCLKREQ7# ==> NC */
15  PAD_NC(GPP_A8, NONE),
16  /* A12 : SATAXPCIE1 ==> NC */
18  /* A14 : USB_OC1# ==> NC */
20  /* A15 : USB_OC2# ==> NC */
22  /* A18 : DDSP_HPDB ==> NC */
24  /* A21 : DDPC_CTRCLK ==> NC */
26  /* A22 : DDPC_CTRLDATA ==> NC */
28 
29  /* B3 : PROC_GP2 ==> NC */
30  PAD_NC_LOCK(GPP_B3, NONE, LOCK_CONFIG),
31  /* B5 : ISH_I2C0_SDA ==> NC */
32  PAD_NC_LOCK(GPP_B5, NONE, LOCK_CONFIG),
33  /* B6 : ISH_I2C0_SCL ==> NC */
34  PAD_NC_LOCK(GPP_B6, NONE, LOCK_CONFIG),
35 
36  /* C3 : SML0CLK ==> NC */
37  PAD_NC(GPP_C3, NONE),
38  /* C4 : SML0DATA ==> NC */
39  PAD_NC(GPP_C4, NONE),
40 
41  /* D3 : ISH_GP3 ==> NC */
42  PAD_NC_LOCK(GPP_D3, NONE, LOCK_CONFIG),
43  /* D5 : SRCCLKREQ0# ==> NC */
44  PAD_NC(GPP_D5, NONE),
45  /* D9 : ISH_SPI_CS# ==> NC */
46  PAD_NC_LOCK(GPP_D9, NONE, LOCK_CONFIG),
47  /* D15 : ISH_UART0_RTS# ==> NC */
48  PAD_NC_LOCK(GPP_D15, NONE, LOCK_CONFIG),
49  /* D16 : ISH_UART0_CTS# ==> EN_WCAM_PWR */
50  PAD_CFG_GPO_LOCK(GPP_D16, 1, LOCK_CONFIG),
51  /* D17 : UART1_RXD ==> NC */
52  PAD_NC_LOCK(GPP_D17, NONE, LOCK_CONFIG),
53 
54  /* E0 : SATAXPCIE0 ==> NC */
55  PAD_NC(GPP_E0, NONE),
56  /* E3 : PROC_GP0 ==> NC */
57  PAD_NC(GPP_E3, NONE),
58  /* E4 : SATA_DEVSLP0 ==> NC */
59  PAD_NC(GPP_E4, NONE),
60  /* E7 : PROC_GP1 ==> NC */
61  PAD_NC(GPP_E7, NONE),
62  /* E10 : THC0_SPI1_CS# ==> NC */
63  PAD_NC_LOCK(GPP_E10, NONE, LOCK_CONFIG),
64  /* E16 : RSVD_TP ==> NC */
66  /* E17 : THC0_SPI1_INT# ==> NC */
67  PAD_NC_LOCK(GPP_E17, NONE, LOCK_CONFIG),
68  /* E18 : DDP1_CTRLCLK ==> NC */
70  /* E20 : DDP2_CTRLCLK ==> NC */
72 
73  /* F6 : CNV_PA_BLANKING ==> NC */
74  PAD_NC(GPP_F6, NONE),
75  /* F19 : SRCCLKREQ6# ==> NC */
77  /* F20 : EXT_PWR_GATE# ==> NC */
79  /* F21 : EXT_PWR_GATE2# ==> NC */
81 
82  /* H6 : I2C1_SDA ==> PCH_I2C_TPM_SDA_P2 */
83  PAD_CFG_NF_LOCK(GPP_H6, NONE, NF1, LOCK_CONFIG),
84  /* H7 : I2C1_SCL ==> PCH_I2C_TPM_SCL_P2 */
85  PAD_CFG_NF_LOCK(GPP_H7, NONE, NF1, LOCK_CONFIG),
86  /* H8 : I2C4_SDA ==> NC */
87  PAD_NC(GPP_H8, NONE),
88  /* H9 : I2C4_SCL ==> NC */
89  PAD_NC(GPP_H9, NONE),
90  /* H13 : I2C7_SCL ==> EN_PP3300_SD */
91  PAD_CFG_GPO_LOCK(GPP_H13, 1, LOCK_CONFIG),
92  /* H15 : DDPB_CTRLCLK ==> NC */
94  /* H17 : DDPB_CTRLDATA ==> NC*/
96  /* H19 : SRCCLKREQ4# ==> NC */
98  /* H21 : IMGCLKOUT2 ==> NC */
100  /* H22 : IMGCLKOUT3 ==> NC */
101  PAD_NC(GPP_H22, NONE),
102  /* H23 : SRCCLKREQ5# ==> NC */
103  PAD_NC(GPP_H23, NONE),
104 
105  /* S4 : SNDW2_CLK ==> NC */
106  PAD_NC(GPP_S4, NONE),
107  /* S5 : SNDW2_DATA ==> NC */
108  PAD_NC(GPP_S5, NONE),
109  /* S6 : SNDW3_CLK ==> NC */
110  PAD_NC(GPP_S6, NONE),
111  /* S7 : SNDW3_DATA ==> NC */
112  PAD_NC(GPP_S7, NONE),
113 
114  /* GPD11: LANPHYC ==> NC */
115  PAD_NC(GPD11, NONE),
116 };
117 
118 /* Early pad configuration in bootblock */
119 static const struct pad_config early_gpio_table[] = {
120  /* A13 : PMC_I2C_SCL ==> GSC_PCH_INT_ODL */
121  PAD_CFG_GPI_APIC(GPP_A13, NONE, PLTRST, LEVEL, INVERT),
122 
123  /* B4 : PROC_GP3 ==> SSD_PERST_L */
124  PAD_CFG_GPO(GPP_B4, 0, DEEP),
125  /* H6 : I2C1_SDA ==> PCH_I2C_TPM_SDA_P2 */
126  PAD_CFG_NF(GPP_H6, NONE, DEEP, NF1),
127  /* H7 : I2C1_SCL ==> PCH_I2C_TPM_SCL_P2 */
128  PAD_CFG_NF(GPP_H7, NONE, DEEP, NF1),
129  /*
130  * D1 : ISH_GP1 ==> FP_RST_ODL
131  * FP_RST_ODL comes out of reset as hi-z and does not have an external pull-down.
132  * To ensure proper power sequencing for the FPMCU device, reset signal is driven low
133  * early on in bootblock, followed by enabling of power. Reset signal is deasserted
134  * later on in ramstage. Since reset signal is asserted in bootblock, it results in
135  * FPMCU not working after a S3 resume. This is a known issue.
136  */
137  PAD_CFG_GPO(GPP_D1, 0, DEEP),
138  /* D2 : ISH_GP2 ==> EN_FP_PWR */
139  PAD_CFG_GPO(GPP_D2, 1, DEEP),
140  /* D11 : ISH_SPI_MISO ==> EN_PP3300_SSD */
141  PAD_CFG_GPO(GPP_D11, 1, DEEP),
142 
143  /* E0 : SATAXPCIE0 ==> NC */
144  PAD_NC(GPP_E0, NONE),
145  /* E13 : THC0_SPI1_IO2 ==> MEM_CH_SEL */
146  PAD_CFG_GPI(GPP_E13, NONE, DEEP),
147  /* E15 : RSVD_TP ==> PCH_WP_OD */
149  /* E16 : RSVD_TP ==> NC */
150  PAD_NC(GPP_E16, NONE),
151  /* F18 : THC1_SPI2_INT# ==> EC_IN_RW_OD */
152  PAD_CFG_GPI(GPP_F18, NONE, DEEP),
153  /* H10 : UART0_RXD ==> UART_PCH_RX_DBG_TX */
154  PAD_CFG_NF(GPP_H10, NONE, DEEP, NF2),
155  /* H11 : UART0_TXD ==> UART_PCH_TX_DBG_RX */
156  PAD_CFG_NF(GPP_H11, NONE, DEEP, NF2),
157  /* H13 : I2C7_SCL ==> EN_PP3300_SD */
158  PAD_CFG_GPO(GPP_H13, 1, DEEP),
159 };
160 
161 static const struct pad_config romstage_gpio_table[] = {
162  /* B4 : PROC_GP3 ==> SSD_PERST_L */
163  PAD_CFG_GPO(GPP_B4, 1, DEEP),
164  /* D18 : UART1_TXD ==> SD_PE_RST_L */
165  PAD_CFG_GPO(GPP_D18, 1, DEEP),
166 };
167 
168 const struct pad_config *variant_gpio_override_table(size_t *num)
169 {
171  return override_gpio_table;
172 }
173 
174 const struct pad_config *variant_early_gpio_table(size_t *num)
175 {
177  return early_gpio_table;
178 }
179 
180 const struct pad_config *variant_romstage_gpio_table(size_t *num)
181 {
183  return romstage_gpio_table;
184 }
#define GPD11
#define GPP_H22
#define GPP_B6
Definition: gpio_soc_defs.h:59
#define GPP_H19
#define GPP_D1
#define GPP_D17
#define GPP_E3
#define GPP_A18
#define GPP_F21
#define GPP_S4
#define GPP_H15
#define GPP_E0
#define GPP_F6
#define GPP_F20
#define GPP_H11
#define GPP_A14
#define GPP_H17
#define GPP_S5
#define GPP_D2
#define GPP_H6
#define GPP_H9
#define GPP_D9
#define GPP_E13
#define GPP_H21
#define GPP_H13
#define GPP_S7
#define GPP_D11
#define GPP_H7
#define GPP_A6
#define GPP_D5
#define GPP_A7
#define GPP_A12
#define GPP_E7
#define GPP_C4
#define GPP_D18
#define GPP_S6
#define GPP_E17
#define GPP_E18
#define GPP_A8
#define GPP_B5
Definition: gpio_soc_defs.h:58
#define GPP_E20
#define GPP_A15
#define GPP_E10
#define GPP_A13
#define GPP_A21
#define GPP_E15
#define GPP_E16
#define GPP_F18
#define GPP_B3
Definition: gpio_soc_defs.h:56
#define GPP_A22
#define GPP_D15
#define GPP_B4
Definition: gpio_soc_defs.h:57
#define GPP_D16
#define GPP_H10
#define GPP_C3
#define GPP_E4
#define GPP_H8
#define GPP_F19
#define GPP_H23
#define GPP_D3
#define ARRAY_SIZE(a)
Definition: helpers.h:12
const struct pad_config * variant_gpio_override_table(size_t *num)
Definition: gpio.c:198
const struct pad_config * variant_romstage_gpio_table(size_t *num)
Definition: gpio.c:210
const struct pad_config * variant_early_gpio_table(size_t *num)
Definition: gpio.c:204
static const struct pad_config override_gpio_table[]
Definition: gpio.c:9
static const struct pad_config romstage_gpio_table[]
Definition: gpio.c:161
static const struct pad_config early_gpio_table[]
Definition: gpio.c:119
#define PAD_NC(pin)
Definition: gpio_defs.h:263
#define PAD_CFG_NF_LOCK(pad, pull, func, lock_action)
Definition: gpio_defs.h:203
#define PAD_CFG_GPI(pad, pull, rst)
Definition: gpio_defs.h:284
#define PAD_NC_LOCK(pad, pull, lock_action)
Definition: gpio_defs.h:368
#define PAD_CFG_GPO_LOCK(pad, val, lock_action)
Definition: gpio_defs.h:254
#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
#define PAD_CFG_GPI_GPIO_DRIVER(pad, pull, rst)
Definition: gpio_defs.h:323