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  /* A18 : NC */
11  /* A19 : NC */
13  /* A20 : NC */
15  /* A22 : NC */
17  /* A23 : NC */
19 
20  /* B8 : NC */
21  PAD_NC(GPP_B8, NONE),
22  /* B20 : NC */
24  /* B21 : NC */
26  /* B22 : NC */
28 
29  /* C1 : NC */
30  PAD_NC(GPP_C1, NONE),
31  /* C12 : EN_PP3300_TSP_DX */
32  PAD_CFG_GPO(GPP_C12, 0, DEEP),
33  /* C13 : EC_PCH_INT_L - needs to wake the system */
34  PAD_CFG_GPI_IRQ_WAKE(GPP_C13, NONE, PLTRST, LEVEL, INVERT),
35  /* C23 : UART2_CTS# ==> NC */
37 
38  /* D16 : TOUCHSCREEN_INT_L */
39  PAD_CFG_GPI_APIC(GPP_D16, NONE, PLTRST, LEVEL, INVERT),
40  /* D19 : DMIC_CLK_0_SNDW4_CLK */
41  PAD_CFG_NF(GPP_D19, DN_20K, DEEP, NF1),
42 
43  /* E4 : M2_SSD_PE_WAKE_ODL ==> NC */
44  PAD_NC(GPP_E4, NONE),
45  /* E5 : SATA_DEVSLP1 ==> NC */
46  PAD_NC(GPP_E5, NONE),
47 
48  /* F1 : GPP_F1 ==> NC */
49  PAD_NC(GPP_F1, NONE),
50  /* F3 : MEM_STRAP_3 */
51  PAD_CFG_GPI(GPP_F3, NONE, PLTRST),
52  /* F10 : MEM_STRAP_2 */
53  PAD_CFG_GPI(GPP_F10, NONE, PLTRST),
54  /* F11 : EMMC_CMD ==> EMMC_CMD */
55  PAD_CFG_NF(GPP_F11, NONE, DEEP, NF1),
56  /* F12 : EMMC_DATA0 ==> EMMC_DAT0 */
57  PAD_CFG_NF(GPP_F12, NONE, DEEP, NF1),
58  /* F13 : EMMC_DATA1 ==> EMMC_DAT1 */
59  PAD_CFG_NF(GPP_F13, NONE, DEEP, NF1),
60  /* F14 : EMMC_DATA2 ==> EMMC_DAT2 */
61  PAD_CFG_NF(GPP_F14, NONE, DEEP, NF1),
62  /* F15 : EMMC_DATA3 ==> EMMC_DAT3 */
63  PAD_CFG_NF(GPP_F15, NONE, DEEP, NF1),
64  /* F16 : EMMC_DATA4 ==> EMMC_DAT4 */
65  PAD_CFG_NF(GPP_F16, NONE, DEEP, NF1),
66  /* F17 : EMMC_DATA5 ==> EMMC_DAT5 */
67  PAD_CFG_NF(GPP_F17, NONE, DEEP, NF1),
68  /* F18 : EMMC_DATA6 ==> EMMC_DAT6 */
69  PAD_CFG_NF(GPP_F18, NONE, DEEP, NF1),
70  /* F19 : EMMC_DATA7 ==> EMMC_DAT7 */
71  PAD_CFG_NF(GPP_F19, NONE, DEEP, NF1),
72  /* F20 : EMMC_RCLK ==> EMMC_RCLK */
73  PAD_CFG_NF(GPP_F20, NONE, DEEP, NF1),
74  /* F21 : EMMC_CLK ==> EMMC_CLK */
75  PAD_CFG_NF(GPP_F21, NONE, DEEP, NF1),
76  /* F22 : EMMC_RESET# ==> EMMC_RST_L */
77  PAD_CFG_NF(GPP_F22, NONE, DEEP, NF1),
78 
79  /* H3 : SPKR_PA_EN */
80  PAD_CFG_GPO(GPP_H3, 0, DEEP),
81  /* H4 : NC */
82  PAD_NC(GPP_H4, NONE),
83  /* H5 : NC */
84  PAD_NC(GPP_H5, NONE),
85  /* H19 : MEM_STRAP_0 */
86  PAD_CFG_GPI(GPP_H19, NONE, PLTRST),
87  /* H22 : MEM_STRAP_1 */
88  PAD_CFG_GPI(GPP_H22, NONE, PLTRST),
89 };
90 
91 const struct pad_config *override_gpio_table(size_t *num)
92 {
93  *num = ARRAY_SIZE(gpio_table);
94  return gpio_table;
95 }
96 
97 /*
98  * GPIOs configured before ramstage
99  * Note: the Hatch platform's romstage will configure
100  * the MEM_STRAP_* (a.k.a GPIO_MEM_CONFIG_*) pins
101  * as inputs before it reads them, so they are not
102  * needed in this table.
103  */
104 static const struct pad_config early_gpio_table[] = {
105  /* B15 : H1_SLAVE_SPI_CS_L */
106  PAD_CFG_NF(GPP_B15, NONE, DEEP, NF1),
107  /* B16 : H1_SLAVE_SPI_CLK */
108  PAD_CFG_NF(GPP_B16, NONE, DEEP, NF1),
109  /* B17 : H1_SLAVE_SPI_MISO_R */
110  PAD_CFG_NF(GPP_B17, NONE, DEEP, NF1),
111  /* B18 : H1_SLAVE_SPI_MOSI_R */
112  PAD_CFG_NF(GPP_B18, NONE, DEEP, NF1),
113  /* C8 : UART_PCH_RX_DEBUG_TX */
114  PAD_CFG_NF(GPP_C8, NONE, DEEP, NF1),
115  /* C9 : UART_PCH_TX_DEBUG_RX */
116  PAD_CFG_NF(GPP_C9, NONE, DEEP, NF1),
117  /* C14 : BT_DISABLE_L */
118  PAD_CFG_GPO(GPP_C14, 0, DEEP),
119  /* PCH_WP_OD */
120  PAD_CFG_GPI(GPP_C20, NONE, DEEP),
121  /* C21 : H1_PCH_INT_ODL */
122  PAD_CFG_GPI_APIC(GPP_C21, NONE, PLTRST, LEVEL, INVERT),
123  /* C22 : EC_IN_RW_OD */
124  PAD_CFG_GPI(GPP_C22, NONE, DEEP),
125  /* E1 : M2_SSD_PEDET */
126  PAD_CFG_NF(GPP_E1, NONE, DEEP, NF1),
127  /* E5 : SATA_DEVSLP1 */
128  PAD_CFG_NF(GPP_E5, NONE, PLTRST, NF1),
129  /* F2 : MEM_CH_SEL */
130  PAD_CFG_GPI(GPP_F2, NONE, PLTRST),
131  /* F3 : PCH_MEM_STRAP3 */
132  PAD_CFG_GPI(GPP_F3, NONE, PLTRST),
133  /* F10 : PCH_MEM_STRAP2 */
134  PAD_CFG_GPI(GPP_F10, NONE, PLTRST),
135  /* H19 : PCH_MEM_STRAP0 */
136  PAD_CFG_GPI(GPP_H19, NONE, PLTRST),
137  /* H22 : PCH_MEM_STRAP1 */
138  PAD_CFG_GPI(GPP_H22, NONE, PLTRST),
139 };
140 
141 const struct pad_config *variant_early_gpio_table(size_t *num)
142 {
144  return early_gpio_table;
145 }
146 
147 /*
148  * Default GPIO settings before entering non-S5 sleep states.
149  * Configure A12: FPMCU_RST_ODL as GPO before entering sleep.
150  * This guarantees that A12's native3 function is disabled.
151  * See https://review.coreboot.org/c/coreboot/+/32111 .
152  */
153 static const struct pad_config default_sleep_gpio_table[] = {
154 
155 };
156 
157 /*
158  * GPIO settings before entering S5, which are same as
159  * default_sleep_gpio_table but also, turn off FPMCU.
160  */
161 static const struct pad_config s5_sleep_gpio_table[] = {
162 
163 };
164 
165 const struct pad_config *variant_sleep_gpio_table(u8 slp_typ, size_t *num)
166 {
167  if (slp_typ == ACPI_S5) {
169  return s5_sleep_gpio_table;
170  }
173 }
#define GPP_H22
#define GPP_H19
#define GPP_A18
#define GPP_F21
#define GPP_C12
#define GPP_F12
#define GPP_F16
#define GPP_F20
#define GPP_B16
Definition: gpio_soc_defs.h:69
#define GPP_A19
#define GPP_C9
#define GPP_C22
#define GPP_B15
Definition: gpio_soc_defs.h:68
#define GPP_C23
#define GPP_C8
#define GPP_B22
Definition: gpio_soc_defs.h:75
#define GPP_A23
#define GPP_C13
#define GPP_E5
#define GPP_B8
Definition: gpio_soc_defs.h:61
#define GPP_C20
#define GPP_B20
Definition: gpio_soc_defs.h:73
#define GPP_A20
#define GPP_F1
#define GPP_F17
#define GPP_F15
#define GPP_F10
#define GPP_F13
#define GPP_H5
#define GPP_C21
#define GPP_F14
#define GPP_H3
#define GPP_B18
Definition: gpio_soc_defs.h:71
#define GPP_C14
#define GPP_D19
#define GPP_C1
#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_D16
#define GPP_F3
#define GPP_B17
Definition: gpio_soc_defs.h:70
#define GPP_E4
#define GPP_E1
#define GPP_F19
#define GPP_H4
#define ARRAY_SIZE(a)
Definition: helpers.h:12
@ 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:153
static const struct pad_config gpio_table[]
Definition: gpio.c:8
static const struct pad_config s5_sleep_gpio_table[]
Definition: gpio.c:161
static const struct pad_config early_gpio_table[]
Definition: gpio.c:104
#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
uint8_t u8
Definition: stdint.h:45