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  /* A14 : USB_OC1# ==> NC */
16  /* A15 : USB_OC2# ==> NC */
18  /* A21 : DDPC_CTRCLK ==> NC */
20  /* A22 : DDPC_CTRLDATA ==> NC */
22 
23  /* B2 : VRALERT# ==> NC */
24  PAD_NC(GPP_B2, NONE),
25  /* B3 : PROC_GP2 ==> eMMC_PERST_L */
26  PAD_CFG_GPO(GPP_B3, 1, DEEP),
27  /* B15 : TIME_SYNC0 ==> NC */
28  PAD_NC_LOCK(GPP_B15, NONE, LOCK_CONFIG),
29 
30  /* C3 : SML0CLK ==> NC */
31  PAD_NC(GPP_C3, NONE),
32  /* C4 : SML0DATA ==> NC */
33  PAD_NC(GPP_C4, NONE),
34 
35  /* D3 : ISH_GP3 ==> NC */
36  PAD_NC_LOCK(GPP_D3, NONE, LOCK_CONFIG),
37  /* D5 : SRCCLKREQ0# ==> SSD_CLKREQ_ODL */
38  PAD_CFG_NF(GPP_D5, NONE, DEEP, NF1),
39  /* D6 : SRCCLKREQ1# ==> NC */
40  PAD_NC(GPP_D6, NONE),
41  /* D13 : ISH_UART0_RXD ==> NC */
42  PAD_NC_LOCK(GPP_D13, NONE, LOCK_CONFIG),
43  /* D14 : ISH_UART0_TXD ==> USB_A1_RT_RST_ODL */
44  PAD_CFG_GPO_LOCK(GPP_D14, 1, LOCK_CONFIG),
45  /* D18 : UART1_TXD ==> SD_PE_RST_L */
46  PAD_CFG_GPO_LOCK(GPP_D18, 1, LOCK_CONFIG),
47 
48  /* E3 : PROC_GP0 ==> NC */
49  PAD_NC(GPP_E3, NONE),
50  /* E7 : PROC_GP1 ==> NC */
51  PAD_NC(GPP_E7, NONE),
52  /* E20 : USB_C1_LSX_SOC_TX ==> EN_PP3300_eMMC */
53  PAD_CFG_GPO(GPP_E20, 1, DEEP),
54  /* E21 : DDP2_CTRLDATA ==> NC */
56 
57  /* F19 : SRCCLKREQ6# ==> EMMC_CLKREQ_ODL */
58  PAD_CFG_NF(GPP_F19, NONE, DEEP, NF1),
59  /* F20 : EXT_PWR_GATE# ==> NC */
61 
62  /* H6 : I2C1_SDA ==> PCH_I2C_TPM_SDA */
63  PAD_CFG_NF_LOCK(GPP_H6, NONE, NF1, LOCK_CONFIG),
64  /* H7 : I2C1_SCL ==> PCH_I2C_TPM_SCL */
65  PAD_CFG_NF_LOCK(GPP_H7, NONE, NF1, LOCK_CONFIG),
66  /* H19 : SRCCLKREQ4# ==> NC */
68  /* H21 : IMGCLKOUT2 ==> NC */
70  /* H22 : IMGCLKOUT3 ==> NC */
72  /* H23 : SRCCLKREQ5# ==> NC */
74 
75  /* S6 : SNDW3_CLK ==> NC */
76  PAD_NC(GPP_S6, NONE),
77  /* S7 : SNDW3_DATA ==> NC */
78  PAD_NC(GPP_S7, NONE),
79 
80  /* T2 : GPP_T2 ==> eMMC_CFG */
81  PAD_CFG_GPI(GPP_T2, NONE, DEEP),
82 
83  /* GPD11: LANPHYC ==> NC */
84  PAD_NC(GPD11, NONE),
85 };
86 
87 /* Early pad configuration in bootblock */
88 static const struct pad_config early_gpio_table[] = {
89  /* A12 : SATAXPCIE1 ==> EN_PPVAR_WWAN */
90  PAD_CFG_GPO(GPP_A12, 1, DEEP),
91  /* A13 : PMC_I2C_SCL ==> GSC_PCH_INT_ODL */
92  PAD_CFG_GPI_APIC(GPP_A13, NONE, PLTRST, LEVEL, INVERT),
93  /* B3 : PROC_GP2 ==> eMMC_PERST_L */
94  PAD_CFG_GPO(GPP_B3, 0, DEEP),
95  /* B4 : PROC_GP3 ==> SSD_PERST_L */
96  PAD_CFG_GPO(GPP_B4, 0, DEEP),
97  /* H6 : I2C1_SDA ==> PCH_I2C_TPM_SDA */
98  PAD_CFG_NF(GPP_H6, NONE, DEEP, NF1),
99  /* H7 : I2C1_SCL ==> PCH_I2C_TPM_SCL */
100  PAD_CFG_NF(GPP_H7, NONE, DEEP, NF1),
101  /*
102  * D1 : ISH_GP1 ==> FP_RST_ODL
103  * FP_RST_ODL comes out of reset as hi-z and does not have an external pull-down.
104  * To ensure proper power sequencing for the FPMCU device, reset signal is driven low
105  * early on in bootblock, followed by enabling of power. Reset signal is deasserted
106  * later on in ramstage. Since reset signal is asserted in bootblock, it results in
107  * FPMCU not working after a S3 resume. This is a known issue.
108  */
109  PAD_CFG_GPO(GPP_D1, 0, DEEP),
110  /* D2 : ISH_GP2 ==> EN_FP_PWR */
111  PAD_CFG_GPO(GPP_D2, 1, DEEP),
112  /* D11 : ISH_SPI_MISO ==> EN_PP3300_SSD */
113  PAD_CFG_GPO(GPP_D11, 1, DEEP),
114  /* D18 : UART1_TXD ==> SD_PE_RST_L */
115  PAD_CFG_GPO(GPP_D18, 0, PLTRST),
116  /* E0 : SATAXPCIE0 ==> WWAN_PERST_L (updated in ramstage)*/
117  PAD_CFG_GPO(GPP_E0, 0, DEEP),
118  /* E13 : THC0_SPI1_IO2 ==> MEM_CH_SEL */
119  PAD_CFG_GPI(GPP_E13, NONE, DEEP),
120  /* E16 : RSVD_TP ==> WWAN_RST_L (updated in ramstage)*/
121  PAD_CFG_GPO(GPP_E16, 0, DEEP),
122  /* E15 : RSVD_TP ==> PCH_WP_OD */
124  /* E20 : USB_C1_LSX_SOC_TX ==> EN_PP3300_eMMC */
125  PAD_CFG_GPO(GPP_E20, 1, DEEP),
126  /* F21 : EXT_PWR_GATE2# ==> WWAN_FCPO_L (updated in romstage) */
127  PAD_CFG_GPO(GPP_F21, 0, DEEP),
128  /* F18 : THC1_SPI2_INT# ==> EC_IN_RW_OD */
129  PAD_CFG_GPI(GPP_F18, NONE, DEEP),
130  /* H10 : UART0_RXD ==> UART_PCH_RX_DBG_TX */
131  PAD_CFG_NF(GPP_H10, NONE, DEEP, NF2),
132  /* H11 : UART0_TXD ==> UART_PCH_TX_DBG_RX */
133  PAD_CFG_NF(GPP_H11, NONE, DEEP, NF2),
134  /* H13 : I2C7_SCL ==> EN_PP3300_SD */
135  PAD_CFG_GPO(GPP_H13, 1, PLTRST),
136 };
137 
138 static const struct pad_config romstage_gpio_table[] = {
139  /* A12 : SATAXPCIE1 ==> EN_PPVAR_WWAN (set here for correct power sequencing) */
140  PAD_CFG_GPO(GPP_A12, 1, DEEP),
141  /* B4 : PROC_GP3 ==> SSD_PERST_L */
142  PAD_CFG_GPO(GPP_B4, 1, DEEP),
143  /* F21 : EXT_PWR_GATE2# ==> WWAN_FCPO_L (set here for correct power sequencing) */
144  PAD_CFG_GPO(GPP_F21, 1, DEEP),
145 };
146 
147 const struct pad_config *variant_gpio_override_table(size_t *num)
148 {
150  return override_gpio_table;
151 }
152 
153 const struct pad_config *variant_early_gpio_table(size_t *num)
154 {
156  return early_gpio_table;
157 }
158 
159 const struct pad_config *variant_romstage_gpio_table(size_t *num)
160 {
162  return romstage_gpio_table;
163 }
#define GPD11
#define GPP_H22
#define GPP_H19
#define GPP_D1
#define GPP_E3
#define GPP_F21
#define GPP_E0
#define GPP_D14
#define GPP_F20
#define GPP_H11
#define GPP_A14
#define GPP_B2
Definition: gpio_soc_defs.h:55
#define GPP_D6
#define GPP_D2
#define GPP_H6
#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_A7
#define GPP_A12
#define GPP_E7
#define GPP_C4
#define GPP_D18
#define GPP_S6
#define GPP_D13
#define GPP_E20
#define GPP_A15
#define GPP_A13
#define GPP_A21
#define GPP_E15
#define GPP_E16
#define GPP_T2
Definition: gpio_soc_defs.h:93
#define GPP_F18
#define GPP_B3
Definition: gpio_soc_defs.h:56
#define GPP_A22
#define GPP_B4
Definition: gpio_soc_defs.h:57
#define GPP_H10
#define GPP_E21
#define GPP_C3
#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:138
static const struct pad_config early_gpio_table[]
Definition: gpio.c:88
#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