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 <acpi/acpi.h>
4 #include <baseboard/gpio.h>
5 #include <baseboard/variants.h>
6 #include <commonlib/helpers.h>
7 
8 static const struct pad_config gpio_table[] = {
9  /* A8 : PEN_GARAGE_DET_L (wake) */
10  PAD_CFG_GPI_SCI(GPP_A8, NONE, DEEP, EDGE_SINGLE, NONE),
11  /* A10 : FPMCU_PCH_BOOT1 */
12  PAD_CFG_GPO(GPP_A10, 0, DEEP),
13  /* A11 : PCH_SPI_FPMCU_CS_L */
14  PAD_CFG_NF(GPP_A11, NONE, DEEP, NF2),
15  /* A12 : FPMCU_RST_ODL */
16  PAD_CFG_GPO(GPP_A12, 0, DEEP),
17  /* A18 : ISH_GP0 ==> NC */
19  /* A19 : ISH_GP1 ==> NC */
21  /* A20 : ISH_GP2 ==> NC */
23  /* B19 : GSPI1_CS0# ==> NC */
25  /* C1 : SMBDATA ==> NC */
26  PAD_NC(GPP_C1, NONE),
27  /* C4 : TOUCHSCREEN_DIS_L */
28  PAD_CFG_GPO(GPP_C4, 0, DEEP),
29  /* C6 : GPP_C6 ==> NC */
30  PAD_NC(GPP_C6, NONE),
31  /* C7 : GPP_C7 ==> NC */
32  PAD_NC(GPP_C7, NONE),
33  /* C23 : UART2_CTS# ==> NC */
35  /* D5 : ISH_I2C0_SDA ==> NC */
36  PAD_NC(GPP_D5, NONE),
37  /* D6 : ISH_I2C0_SCL ==> NC */
38  PAD_NC(GPP_D6, NONE),
39  /* D7 : ISH_I2C1_SDA ==> NC */
40  PAD_NC(GPP_D7, NONE),
41  /* D8 : ISH_I2C1_SCL ==> NC */
42  PAD_NC(GPP_D8, NONE),
43  /* D10 : ISH_SPI_CLK ==> EN_PP3300_PP1800_FP */
44  PAD_CFG_GPO(GPP_D10, 0, DEEP),
45  /* D16 : USI_INT_L */
46  PAD_CFG_GPI_APIC(GPP_D16, NONE, PLTRST, LEVEL, INVERT),
47  /* D21 : SPI1_IO2 ==> NC */
49  /* F0 : GPP_F0 ==> NC */
50  PAD_NC(GPP_F0, NONE),
51  /* F1 : GPP_F1 ==> NC */
52  PAD_NC(GPP_F1, NONE),
53  /* F3 : GPP_F3 ==> MEM_STRAP_3 */
54  PAD_CFG_GPI(GPP_F3, NONE, PLTRST),
55  /* F10 : GPP_F10 ==> MEM_STRAP_2 */
56  PAD_CFG_GPI(GPP_F10, NONE, PLTRST),
57  /* F11 : EMMC_CMD ==> NC */
59  /* F20 : EMMC_RCLK ==> NC */
61  /* F21 : EMMC_CLK ==> NC */
63  /* F22 : EMMC_RESET# ==> NC */
65  /* G0 : GPP_G0 ==> NC */
66  PAD_NC(GPP_G0, NONE),
67  /* G1 : GPP_G1 ==> NC */
68  PAD_NC(GPP_G1, NONE),
69  /* G2 : GPP_G2 ==> NC */
70  PAD_NC(GPP_G2, NONE),
71  /* G3 : GPP_G3 ==> NC */
72  PAD_NC(GPP_G3, NONE),
73  /* G4 : GPP_G4 ==> NC */
74  PAD_NC(GPP_G4, NONE),
75  /* G5 : GPP_G5 ==> NC */
76  PAD_NC(GPP_G5, NONE),
77  /* G6 : GPP_G6 ==> NC */
78  PAD_NC(GPP_G6, NONE),
79  /* H3 : SPKR_PA_EN */
80  PAD_CFG_GPO(GPP_H3, 1, DEEP),
81  /* H4 : I2C2_SDA ==> NC */
82  PAD_NC(GPP_H4, NONE),
83  /* H5 : I2C2_SCL ==> NC */
84  PAD_NC(GPP_H5, NONE),
85  /* H13 : M2_SKT2_CFG1 ==> SPKR_RST_L */
86  PAD_CFG_GPO(GPP_H13, 1, DEEP),
87  /* H14 : M2_SKT2_CFG2 ==> TOUCHSCREEN_STOP_L */
88  PAD_CFG_GPO(GPP_H14, 1, PLTRST),
89  /* H19 : TIMESYNC[0] ==> MEM_STRAP_0 */
90  PAD_CFG_GPI(GPP_H19, NONE, PLTRST),
91  /* H22 : MEM_STRAP_1 */
92  PAD_CFG_GPI(GPP_H22, NONE, PLTRST),
93 };
94 
95 const struct pad_config *override_gpio_table(size_t *num)
96 {
97  *num = ARRAY_SIZE(gpio_table);
98  return gpio_table;
99 }
100 
101 /*
102  * GPIOs configured before ramstage
103  * Note: the Hatch platform's romstage will configure
104  * the MEM_STRAP_* (a.k.a GPIO_MEM_CONFIG_*) pins
105  * as inputs before it reads them, so they are not
106  * needed in this table.
107  */
108 static const struct pad_config early_gpio_table[] = {
109  /* B15 : H1_SLAVE_SPI_CS_L */
110  PAD_CFG_NF(GPP_B15, NONE, DEEP, NF1),
111  /* B16 : H1_SLAVE_SPI_CLK */
112  PAD_CFG_NF(GPP_B16, NONE, DEEP, NF1),
113  /* B17 : H1_SLAVE_SPI_MISO_R */
114  PAD_CFG_NF(GPP_B17, NONE, DEEP, NF1),
115  /* B18 : H1_SLAVE_SPI_MOSI_R */
116  PAD_CFG_NF(GPP_B18, NONE, DEEP, NF1),
117  /* C8 : UART_PCH_RX_DEBUG_TX */
118  PAD_CFG_NF(GPP_C8, NONE, DEEP, NF1),
119  /* C9 : UART_PCH_TX_DEBUG_RX */
120  PAD_CFG_NF(GPP_C9, NONE, DEEP, NF1),
121  /* C14 : BT_DISABLE_L */
122  PAD_CFG_GPO(GPP_C14, 0, DEEP),
123  /* PCH_WP_OD */
124  PAD_CFG_GPI(GPP_C20, NONE, DEEP),
125  /* C21 : H1_PCH_INT_ODL */
126  PAD_CFG_GPI_APIC(GPP_C21, NONE, PLTRST, LEVEL, INVERT),
127  /* C22 : EC_IN_RW_OD */
128  PAD_CFG_GPI(GPP_C22, NONE, DEEP),
129  /* E1 : M2_SSD_PEDET */
130  PAD_CFG_NF(GPP_E1, NONE, DEEP, NF1),
131  /* E5 : SATA_DEVSLP1 */
132  PAD_CFG_NF(GPP_E5, NONE, PLTRST, NF1),
133  /* F2 : MEM_CH_SEL */
134  PAD_CFG_GPI(GPP_F2, NONE, PLTRST),
135 };
136 
137 const struct pad_config *variant_early_gpio_table(size_t *num)
138 {
140  return early_gpio_table;
141 }
142 
143 /*
144  * Default GPIO settings before entering non-S5 sleep states.
145  * Configure A12: FPMCU_RST_ODL as GPO before entering sleep.
146  * This guarantees that A12's native3 function is disabled.
147  * See https://review.coreboot.org/c/coreboot/+/32111 .
148  */
149 static const struct pad_config default_sleep_gpio_table[] = {
150  PAD_CFG_GPO(GPP_A12, 1, DEEP), /* FPMCU_RST_ODL */
151 };
152 
153 /*
154  * GPIO settings before entering S5, which are same as
155  * default_sleep_gpio_table but also, turn off FPMCU.
156  */
157 static const struct pad_config s5_sleep_gpio_table[] = {
158  PAD_CFG_GPO(GPP_A12, 0, DEEP), /* FPMCU_RST_ODL */
159  PAD_CFG_GPO(GPP_C11, 0, DEEP), /* PCH_FP_PWR_EN */
160 };
161 
162 const struct pad_config *variant_sleep_gpio_table(u8 slp_typ, size_t *num)
163 {
164  if (slp_typ == ACPI_S5) {
166  return s5_sleep_gpio_table;
167  }
170 }
#define GPP_H22
#define GPP_H19
#define GPP_D10
#define GPP_D8
#define GPP_A18
#define GPP_F21
#define GPP_F20
#define GPP_B16
Definition: gpio_soc_defs.h:69
#define GPP_D7
#define GPP_F0
#define GPP_D6
#define GPP_A19
#define GPP_C9
#define GPP_C22
#define GPP_B15
Definition: gpio_soc_defs.h:68
#define GPP_C23
#define GPP_H13
#define GPP_C8
#define GPP_C11
#define GPP_H14
#define GPP_D5
#define GPP_E5
#define GPP_C20
#define GPP_A20
#define GPP_F1
#define GPP_A12
#define GPP_C6
#define GPP_F10
#define GPP_C4
#define GPP_B19
Definition: gpio_soc_defs.h:72
#define GPP_H5
#define GPP_C21
#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_C1
#define GPP_F2
#define GPP_F22
#define GPP_F11
#define GPP_D16
#define GPP_F3
#define GPP_B17
Definition: gpio_soc_defs.h:70
#define GPP_E1
#define GPP_H4
#define GPP_C7
#define ARRAY_SIZE(a)
Definition: helpers.h:12
#define GPP_G1
Definition: gpio_soc_defs.h:89
#define GPP_G4
Definition: gpio_soc_defs.h:92
#define GPP_G2
Definition: gpio_soc_defs.h:90
#define GPP_D21
#define GPP_G6
Definition: gpio_soc_defs.h:94
#define GPP_G0
Definition: gpio_soc_defs.h:88
#define GPP_G3
Definition: gpio_soc_defs.h:91
#define GPP_G5
Definition: gpio_soc_defs.h:93
@ ACPI_S5
Definition: acpi.h:1385
const struct pad_config * variant_early_gpio_table(size_t *num)
Definition: gpio.c:204
const struct pad_config *__weak variant_sleep_gpio_table(size_t *num)
Definition: gpio.c:466
const struct pad_config * override_gpio_table(size_t *num)
Definition: gpio.c:124
static const struct pad_config default_sleep_gpio_table[]
Definition: gpio.c:149
static const struct pad_config gpio_table[]
Definition: gpio.c:8
static const struct pad_config s5_sleep_gpio_table[]
Definition: gpio.c:157
static const struct pad_config early_gpio_table[]
Definition: gpio.c:108
#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
#define PAD_CFG_GPI_SCI(pad, pull, rst, trig, inv)
Definition: gpio_defs.h:432
uint8_t u8
Definition: stdint.h:45