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  /* A19 : DDSP_HPD1 ==> NC */
14  /* A20 : DDSP_HPD2 ==> NC */
16  /* A21 : DDPC_CTRCLK ==> NC */
18  /* A22 : DDPC_CTRLDATA ==> NC */
20 
21  /* B2 : VRALERT# ==> NC */
22  PAD_NC(GPP_B2, NONE),
23  /* B3 : PROC_GP2 ==> NC */
24  PAD_NC(GPP_B3, NONE),
25  /* B15 : TIME_SYNC0 ==> NC */
27 
28  /* C3 : GPP_C3 ==> SML0_SMBCLK */
29  PAD_CFG_NF(GPP_C3, NONE, DEEP, NF1),
30  /* C4 : GPP_C4 ==> SML0_SMBDATA */
31  PAD_CFG_NF(GPP_C4, NONE, DEEP, NF1),
32 
33  /* D3 : ISH_GP3 ==> NC */
34  PAD_NC(GPP_D3, NONE),
35  /* D5 : SRCCLKREQ0# ==> SSD_CLKREQ_ODL */
36  PAD_CFG_NF(GPP_D5, NONE, DEEP, NF1),
37  /* D13 : ISH_UART0_RXD ==> NC */
39  /* D14 : ISH_UART0_TXD ==> NC */
41  /* D15 : ISH_UART0_RTS# ==> NC */
43  /* D19 : I2S_MCLK1_OUT ==> NC */
45 
46  /* E3 : PROC_GP0 ==> NC */
47  PAD_NC(GPP_E3, NONE),
48  /* E5 : SATA_DEVSLP1 ==> NC */
49  PAD_NC(GPP_E5, NONE),
50  /* E7 : PROC_GP1 ==> NC */
51  PAD_NC(GPP_E7, NONE),
52  /* E20 : DDP2_CTRLCLK ==> NC */
54  /* E21 : DDP2_CTRLDATA ==> NC */
56  /* E22 : DDPA_CTRLCLK ==> NC */
58  /* E23 : DDPA_CTRLDATA ==> NC */
60 
61  /* F19 : SRCCLKREQ6# ==> NC */
63  /* F20 : EXT_PWR_GATE# ==> NC */
65 
66  /* H21 : IMGCLKOUT2 ==> VPRO_STRAP */
67  PAD_CFG_GPI(GPP_H21, NONE, DEEP),
68  /* H22 : IMGCLKOUT3 ==> NC */
70 
71  /* R4 : HDA_RST# ==> DMIC_CLK0_R */
72  PAD_CFG_NF(GPP_R4, NONE, DEEP, NF3),
73  /* R5 : HDA_SDI1 ==> DMIC_DATA0_R */
74  PAD_CFG_NF(GPP_R5, NONE, DEEP, NF3),
75  /* R6 : I2S2_TXD ==> NC */
76  PAD_NC(GPP_R6, NONE),
77  /* R7 : I2S2_RXD ==> NC */
78  PAD_NC(GPP_R7, NONE),
79 
80  /* S0 : SNDW0_CLK ==> I2S_SPKR_SCLK_R */
81  PAD_CFG_NF(GPP_S0, NONE, DEEP, NF4),
82  /* S1 : SNDW0_DATA ==> I2S_SPKR_SFRM_R */
83  PAD_CFG_NF(GPP_S1, NONE, DEEP, NF4),
84  /* S2 : SNDW1_CLK ==> I2S_PCH_TX_SPKR_RX_R */
85  PAD_CFG_NF(GPP_S2, NONE, DEEP, NF4),
86  /* S3 : SNDW1_DATA ==> I2S_PCH_RX_SPKR_TX */
87  PAD_CFG_NF(GPP_S3, NONE, DEEP, NF4),
88  /* S4 : SNDW2_CLK ==> NC */
89  PAD_NC(GPP_S4, NONE),
90  /* S5 : SNDW2_DATA ==> NC */
91  PAD_NC(GPP_S5, NONE),
92  /* S6 : SNDW3_CLK ==> NC */
93  PAD_NC(GPP_S6, NONE),
94  /* S7 : SNDW3_DATA ==> NC */
95  PAD_NC(GPP_S7, NONE),
96 
97  /* T2 : GPP_T2 ==> eMMC_CFG */
98  PAD_CFG_GPI(GPP_T2, NONE, DEEP),
99 
100  /* GPD11: LANPHYC ==> NC */
101  PAD_NC(GPD11, NONE),
102 };
103 
104 /* Early pad configuration in bootblock */
105 static const struct pad_config early_gpio_table[] = {
106  /* A12 : SATAXPCIE1 ==> EN_PP3300_WWAN */
107  PAD_CFG_GPO(GPP_A12, 1, DEEP),
108  /* A13 : PMC_I2C_SCL ==> GSC_PCH_INT_ODL */
109  PAD_CFG_GPI_APIC(GPP_A13, NONE, PLTRST, LEVEL, INVERT),
110  /* B3 : PROC_GP2 ==> eMMC_PERST_L */
111  PAD_CFG_GPO(GPP_B3, 0, DEEP),
112  /* B4 : PROC_GP3 ==> SSD_PERST_L */
113  PAD_CFG_GPO(GPP_B4, 0, DEEP),
114  /* H6 : I2C1_SDA ==> PCH_I2C_TPM_SDA */
115  PAD_CFG_NF(GPP_H6, NONE, DEEP, NF1),
116  /* H7 : I2C1_SCL ==> PCH_I2C_TPM_SCL */
117  PAD_CFG_NF(GPP_H7, NONE, DEEP, NF1),
118  /*
119  * D1 : ISH_GP1 ==> FP_RST_ODL
120  * FP_RST_ODL comes out of reset as hi-z and does not have an external pull-down.
121  * To ensure proper power sequencing for the FPMCU device, reset signal is driven low
122  * early on in bootblock, followed by enabling of power. Reset signal is deasserted
123  * later on in ramstage. Since reset signal is asserted in bootblock, it results in
124  * FPMCU not working after a S3 resume. This is a known issue.
125  */
126  PAD_CFG_GPO(GPP_D1, 0, DEEP),
127  /* D2 : ISH_GP2 ==> EN_FP_PWR */
128  PAD_CFG_GPO(GPP_D2, 1, DEEP),
129  /* D11 : ISH_SPI_MISO ==> EN_PP3300_SSD */
130  PAD_CFG_GPO(GPP_D11, 1, DEEP),
131  /* D18 : UART1_TXD ==> SD_PE_RST_L */
132  PAD_CFG_GPO(GPP_D18, 0, PLTRST),
133  /* E0 : SATAXPCIE0 ==> WWAN_PERST_L (updated in ramstage) */
134  PAD_CFG_GPO(GPP_E0, 0, DEEP),
135  /* E13 : THC0_SPI1_IO2 ==> MEM_CH_SEL */
136  PAD_CFG_GPI(GPP_E13, NONE, DEEP),
137  /* E16 : RSVD_TP ==> WWAN_RST_L (updated in ramstage) */
138  PAD_CFG_GPO(GPP_E16, 0, DEEP),
139  /* E15 : RSVD_TP ==> PCH_WP_OD */
141  /* F18 : THC1_SPI2_INT# ==> EC_IN_RW_OD */
142  PAD_CFG_GPI(GPP_F18, NONE, DEEP),
143  /* F21 : EXT_PWR_GATE2# ==> WWAN_FCPO_L (updated in romstage) */
144  PAD_CFG_GPO(GPP_F21, 0, DEEP),
145  /* H10 : UART0_RXD ==> UART_PCH_RX_DBG_TX */
146  PAD_CFG_NF(GPP_H10, NONE, DEEP, NF2),
147  /* H11 : UART0_TXD ==> UART_PCH_TX_DBG_RX */
148  PAD_CFG_NF(GPP_H11, NONE, DEEP, NF2),
149  /* H13 : I2C7_SCL ==> EN_PP3300_SD */
150  PAD_CFG_GPO(GPP_H13, 1, PLTRST),
151 
152  /* CPU PCIe VGPIO for PEG60 */
153  PAD_CFG_NF_VWEN(GPP_vGPIO_PCIE_48, NONE, PLTRST, NF1),
154  PAD_CFG_NF_VWEN(GPP_vGPIO_PCIE_49, NONE, PLTRST, NF1),
155  PAD_CFG_NF_VWEN(GPP_vGPIO_PCIE_50, NONE, PLTRST, NF1),
156  PAD_CFG_NF_VWEN(GPP_vGPIO_PCIE_51, NONE, PLTRST, NF1),
157  PAD_CFG_NF_VWEN(GPP_vGPIO_PCIE_52, NONE, PLTRST, NF1),
158  PAD_CFG_NF_VWEN(GPP_vGPIO_PCIE_53, NONE, PLTRST, NF1),
159  PAD_CFG_NF_VWEN(GPP_vGPIO_PCIE_54, NONE, PLTRST, NF1),
160  PAD_CFG_NF_VWEN(GPP_vGPIO_PCIE_55, NONE, PLTRST, NF1),
161  PAD_CFG_NF_VWEN(GPP_vGPIO_PCIE_56, NONE, PLTRST, NF1),
162  PAD_CFG_NF_VWEN(GPP_vGPIO_PCIE_57, NONE, PLTRST, NF1),
163  PAD_CFG_NF_VWEN(GPP_vGPIO_PCIE_58, NONE, PLTRST, NF1),
164  PAD_CFG_NF_VWEN(GPP_vGPIO_PCIE_59, NONE, PLTRST, NF1),
165  PAD_CFG_NF_VWEN(GPP_vGPIO_PCIE_60, NONE, PLTRST, NF1),
166  PAD_CFG_NF_VWEN(GPP_vGPIO_PCIE_61, NONE, PLTRST, NF1),
167  PAD_CFG_NF_VWEN(GPP_vGPIO_PCIE_62, NONE, PLTRST, NF1),
168  PAD_CFG_NF_VWEN(GPP_vGPIO_PCIE_63, NONE, PLTRST, NF1),
169  PAD_CFG_NF_VWEN(GPP_vGPIO_PCIE_76, NONE, PLTRST, NF1),
170  PAD_CFG_NF_VWEN(GPP_vGPIO_PCIE_77, NONE, PLTRST, NF1),
171  PAD_CFG_NF_VWEN(GPP_vGPIO_PCIE_78, NONE, PLTRST, NF1),
172  PAD_CFG_NF_VWEN(GPP_vGPIO_PCIE_79, NONE, PLTRST, NF1),
173 };
174 
175 static const struct pad_config romstage_gpio_table[] = {
176  /* B4 : PROC_GP3 ==> SSD_PERST_L */
177  PAD_CFG_GPO(GPP_B4, 1, DEEP),
178  /* F21 : EXT_PWR_GATE2# ==> WWAN_FCPO_L (set here for correct power sequencing) */
179  PAD_CFG_GPO(GPP_F21, 1, DEEP),
180 };
181 
182 const struct pad_config *variant_gpio_override_table(size_t *num)
183 {
185  return override_gpio_table;
186 }
187 
188 const struct pad_config *variant_early_gpio_table(size_t *num)
189 {
191  return early_gpio_table;
192 }
193 
194 const struct pad_config *variant_romstage_gpio_table(size_t *num)
195 {
197  return romstage_gpio_table;
198 }
#define GPD11
#define GPP_H22
#define GPP_vGPIO_PCIE_57
#define GPP_D1
#define GPP_E3
#define GPP_F21
#define GPP_vGPIO_PCIE_48
#define GPP_S4
#define GPP_vGPIO_PCIE_55
#define GPP_R4
#define GPP_vGPIO_PCIE_78
#define GPP_E0
#define GPP_R7
#define GPP_vGPIO_PCIE_76
#define GPP_D14
#define GPP_F20
#define GPP_S0
#define GPP_H11
#define GPP_vGPIO_PCIE_53
#define GPP_vGPIO_PCIE_62
#define GPP_S5
#define GPP_B2
Definition: gpio_soc_defs.h:55
#define GPP_vGPIO_PCIE_49
#define GPP_vGPIO_PCIE_50
#define GPP_vGPIO_PCIE_77
#define GPP_A19
#define GPP_D2
#define GPP_H6
#define GPP_R6
#define GPP_B15
Definition: gpio_soc_defs.h:68
#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_S3
#define GPP_E23
#define GPP_E5
#define GPP_S1
#define GPP_vGPIO_PCIE_60
#define GPP_vGPIO_PCIE_54
#define GPP_A20
#define GPP_A12
#define GPP_E7
#define GPP_C4
#define GPP_D18
#define GPP_S6
#define GPP_D13
#define GPP_vGPIO_PCIE_52
#define GPP_R5
#define GPP_E20
#define GPP_A13
#define GPP_S2
#define GPP_vGPIO_PCIE_59
#define GPP_A21
#define GPP_E15
#define GPP_E16
#define GPP_D19
#define GPP_vGPIO_PCIE_61
#define GPP_T2
Definition: gpio_soc_defs.h:93
#define GPP_vGPIO_PCIE_63
#define GPP_vGPIO_PCIE_58
#define GPP_F18
#define GPP_B3
Definition: gpio_soc_defs.h:56
#define GPP_A22
#define GPP_vGPIO_PCIE_51
#define GPP_D15
#define GPP_vGPIO_PCIE_79
#define GPP_B4
Definition: gpio_soc_defs.h:57
#define GPP_E22
#define GPP_H10
#define GPP_E21
#define GPP_C3
#define GPP_vGPIO_PCIE_56
#define GPP_F19
#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:175
static const struct pad_config early_gpio_table[]
Definition: gpio.c:105
#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_NF_VWEN(pad, pull, rst, func)
Definition: gpio_defs.h:241
#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