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  /* A11 : PCH_SPI_FPMCU_CS_L */
10  PAD_CFG_NF(GPP_A11, NONE, DEEP, NF2),
11  /* A12 : FPMCU_RST_ODL */
12  PAD_CFG_GPO(GPP_A12, 0, DEEP),
13  /* A18 : NC */
15  /* A19 : NC */
17  /* C12 : FPMCU_PCH_BOOT1 */
18  PAD_CFG_GPO(GPP_C12, 0, DEEP),
19  /* F1 : NC */
20  PAD_NC(GPP_F1, NONE),
21  /* F3 : MEM_STRAP_3 */
22  PAD_CFG_GPI(GPP_F3, NONE, PLTRST),
23  /* F10 : MEM_STRAP_2 */
24  PAD_CFG_GPI(GPP_F10, NONE, PLTRST),
25  /* F11 : EMMC_CMD ==> EMMC_CMD */
26  PAD_CFG_NF(GPP_F11, NONE, DEEP, NF1),
27  /* F12 : EMMC_DATA0 ==> EMMC_DAT0 */
28  PAD_CFG_NF(GPP_F12, NONE, DEEP, NF1),
29  /* F13 : EMMC_DATA1 ==> EMMC_DAT1 */
30  PAD_CFG_NF(GPP_F13, NONE, DEEP, NF1),
31  /* F14 : EMMC_DATA2 ==> EMMC_DAT2 */
32  PAD_CFG_NF(GPP_F14, NONE, DEEP, NF1),
33  /* F15 : EMMC_DATA3 ==> EMMC_DAT3 */
34  PAD_CFG_NF(GPP_F15, NONE, DEEP, NF1),
35  /* F16 : EMMC_DATA4 ==> EMMC_DAT4 */
36  PAD_CFG_NF(GPP_F16, NONE, DEEP, NF1),
37  /* F17 : EMMC_DATA5 ==> EMMC_DAT5 */
38  PAD_CFG_NF(GPP_F17, NONE, DEEP, NF1),
39  /* F18 : EMMC_DATA6 ==> EMMC_DAT6 */
40  PAD_CFG_NF(GPP_F18, NONE, DEEP, NF1),
41  /* F19 : EMMC_DATA7 ==> EMMC_DAT7 */
42  PAD_CFG_NF(GPP_F19, NONE, DEEP, NF1),
43  /* F20 : EMMC_RCLK ==> EMMC_RCLK */
44  PAD_CFG_NF(GPP_F20, NONE, DEEP, NF1),
45  /* F21 : EMMC_CLK ==> EMMC_CLK */
46  PAD_CFG_NF(GPP_F21, NONE, DEEP, NF1),
47  /* F22 : EMMC_RESET# ==> EMMC_RST_L */
48  PAD_CFG_NF(GPP_F22, NONE, DEEP, NF1),
49  /* H3 : SPKR_PA_EN */
50  PAD_CFG_GPO(GPP_H3, 0, DEEP),
51  /* H19 : MEM_STRAP_0 */
52  PAD_CFG_GPI(GPP_H19, NONE, PLTRST),
53  /* H22 : MEM_STRAP_1 */
54  PAD_CFG_GPI(GPP_H22, NONE, PLTRST),
55 };
56 
57 const struct pad_config *override_gpio_table(size_t *num)
58 {
59  *num = ARRAY_SIZE(gpio_table);
60  return gpio_table;
61 }
62 
63 /*
64  * GPIOs configured before ramstage
65  * Note: the Hatch platform's romstage will configure
66  * the MEM_STRAP_* (a.k.a GPIO_MEM_CONFIG_*) pins
67  * as inputs before it reads them, so they are not
68  * needed in this table.
69  */
70 static const struct pad_config early_gpio_table[] = {
71  /* B15 : H1_SLAVE_SPI_CS_L */
72  PAD_CFG_NF(GPP_B15, NONE, DEEP, NF1),
73  /* B16 : H1_SLAVE_SPI_CLK */
74  PAD_CFG_NF(GPP_B16, NONE, DEEP, NF1),
75  /* B17 : H1_SLAVE_SPI_MISO_R */
76  PAD_CFG_NF(GPP_B17, NONE, DEEP, NF1),
77  /* B18 : H1_SLAVE_SPI_MOSI_R */
78  PAD_CFG_NF(GPP_B18, NONE, DEEP, NF1),
79  /* C8 : UART_PCH_RX_DEBUG_TX */
80  PAD_CFG_NF(GPP_C8, NONE, DEEP, NF1),
81  /* C9 : UART_PCH_TX_DEBUG_RX */
82  PAD_CFG_NF(GPP_C9, NONE, DEEP, NF1),
83  /* C14 : BT_DISABLE_L */
84  PAD_CFG_GPO(GPP_C14, 0, DEEP),
85  /* PCH_WP_OD */
86  PAD_CFG_GPI(GPP_C20, NONE, DEEP),
87  /* C21 : H1_PCH_INT_ODL */
88  PAD_CFG_GPI_APIC(GPP_C21, NONE, PLTRST, LEVEL, INVERT),
89  /* C22 : EC_IN_RW_OD */
90  PAD_CFG_GPI(GPP_C22, NONE, DEEP),
91  /* C23 : WLAN_PE_RST# */
92  PAD_CFG_GPO(GPP_C23, 1, DEEP),
93  /* E1 : M2_SSD_PEDET */
94  PAD_CFG_NF(GPP_E1, NONE, DEEP, NF1),
95  /* E5 : SATA_DEVSLP1 */
96  PAD_CFG_NF(GPP_E5, NONE, PLTRST, NF1),
97  /* F2 : MEM_CH_SEL */
98  PAD_CFG_GPI(GPP_F2, NONE, PLTRST),
99  /* F11 : EMMC_CMD ==> EMMC_CMD */
100  PAD_CFG_NF(GPP_F11, NONE, DEEP, NF1),
101  /* F12 : EMMC_DATA0 ==> EMMC_DAT0 */
102  PAD_CFG_NF(GPP_F12, NONE, DEEP, NF1),
103  /* F13 : EMMC_DATA1 ==> EMMC_DAT1 */
104  PAD_CFG_NF(GPP_F13, NONE, DEEP, NF1),
105  /* F14 : EMMC_DATA2 ==> EMMC_DAT2 */
106  PAD_CFG_NF(GPP_F14, NONE, DEEP, NF1),
107  /* F15 : EMMC_DATA3 ==> EMMC_DAT3 */
108  PAD_CFG_NF(GPP_F15, NONE, DEEP, NF1),
109  /* F16 : EMMC_DATA4 ==> EMMC_DAT4 */
110  PAD_CFG_NF(GPP_F16, NONE, DEEP, NF1),
111  /* F17 : EMMC_DATA5 ==> EMMC_DAT5 */
112  PAD_CFG_NF(GPP_F17, NONE, DEEP, NF1),
113  /* F18 : EMMC_DATA6 ==> EMMC_DAT6 */
114  PAD_CFG_NF(GPP_F18, NONE, DEEP, NF1),
115  /* F19 : EMMC_DATA7 ==> EMMC_DAT7 */
116  PAD_CFG_NF(GPP_F19, NONE, DEEP, NF1),
117  /* F20 : EMMC_RCLK ==> EMMC_RCLK */
118  PAD_CFG_NF(GPP_F20, NONE, DEEP, NF1),
119  /* F21 : EMMC_CLK ==> EMMC_CLK */
120  PAD_CFG_NF(GPP_F21, NONE, DEEP, NF1),
121  /* F22 : EMMC_RESET# ==> EMMC_RST_L */
122  PAD_CFG_NF(GPP_F22, NONE, DEEP, NF1),
123 };
124 
125 const struct pad_config *variant_early_gpio_table(size_t *num)
126 {
128  return early_gpio_table;
129 }
130 
131 /*
132  * Default GPIO settings before entering non-S5 sleep states.
133  * Configure A12: FPMCU_RST_ODL as GPO before entering sleep.
134  * This guarantees that A12's native3 function is disabled.
135  * See commit c41b0e8ea3b2714bf6d6d88a6b66c333c6919f07.
136  */
137 static const struct pad_config default_sleep_gpio_table[] = {
138  PAD_CFG_GPO(GPP_A12, 1, DEEP), /* FPMCU_RST_ODL */
139 };
140 
141 /*
142  * GPIO settings before entering S5, which are same as default_sleep_gpio_table
143  * but also, turn off FPMCU.
144  */
145 static const struct pad_config s5_sleep_gpio_table[] = {
146  PAD_CFG_GPO(GPP_A12, 0, DEEP), /* FPMCU_RST_ODL */
147  PAD_CFG_GPO(GPP_C11, 0, DEEP), /* PCH_FP_PWR_EN */
148 };
149 
150 const struct pad_config *variant_sleep_gpio_table(u8 slp_typ, size_t *num)
151 {
152  if (slp_typ == ACPI_S5) {
154  return s5_sleep_gpio_table;
155  }
158 }
#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_C11
#define GPP_E5
#define GPP_C20
#define GPP_F1
#define GPP_F17
#define GPP_A12
#define GPP_F15
#define GPP_F10
#define GPP_F13
#define GPP_C21
#define GPP_F14
#define GPP_H3
#define GPP_B18
Definition: gpio_soc_defs.h:71
#define GPP_A11
#define GPP_C14
#define GPP_F2
#define GPP_F18
#define GPP_F22
#define GPP_F11
#define GPP_F3
#define GPP_B17
Definition: gpio_soc_defs.h:70
#define GPP_E1
#define GPP_F19
#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:137
static const struct pad_config gpio_table[]
Definition: gpio.c:8
static const struct pad_config s5_sleep_gpio_table[]
Definition: gpio.c:145
static const struct pad_config early_gpio_table[]
Definition: gpio.c:70
#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