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  /* C12 : FPMCU_PCH_BOOT1 */
14  PAD_CFG_GPO(GPP_C12, 0, DEEP),
15  /* C15 : WWAN_DPR_SAR_ODL
16  *
17  * TODO: Driver doesn't use this pin as of now. In case driver starts
18  * using this pin, expose this pin to driver.
19  */
20  PAD_CFG_GPO(GPP_C15, 1, DEEP),
21  /* D4 : Camera Privacy Status */
22  PAD_CFG_GPI_INT(GPP_D4, NONE, PLTRST, EDGE_BOTH),
23  /* E0 : View Angle Management */
24  PAD_CFG_GPO(GPP_E0, 0, DEEP),
25  /* F3 : MEM_STRAP_3 */
26  PAD_CFG_GPI(GPP_F3, NONE, PLTRST),
27  /* F10 : MEM_STRAP_2 */
28  PAD_CFG_GPI(GPP_F10, NONE, PLTRST),
29  /* F11 : EMMC_CMD ==> NC */
31  /* F12 : EMMC_DATA0 ==> NC */
33  /* F13 : EMMC_DATA1 ==> NC */
35  /* F14 : EMMC_DATA2 ==> NC */
37  /* F15 : EMMC_DATA3 ==> NC */
39  /* F16 : EMMC_DATA4 ==> NC */
41  /* F17 : EMMC_DATA5 ==> NC */
43  /* F18 : EMMC_DATA6 ==> NC */
45  /* F19 : EMMC_DATA7 ==> NC */
47  /* F20 : EMMC_RCLK ==> NC */
49  /* F21 : EMMC_CLK ==> NC */
51  /* F22 : EMMC_RESET# ==> NC */
53  /* H3 : SPKR_PA_EN */
54  PAD_CFG_GPO(GPP_H3, 0, DEEP),
55  /* H19 : MEM_STRAP_0 */
56  PAD_CFG_GPI(GPP_H19, NONE, PLTRST),
57  /* H22 : MEM_STRAP_1 */
58  PAD_CFG_GPI(GPP_H22, NONE, PLTRST),
59 };
60 
61 const struct pad_config *override_gpio_table(size_t *num)
62 {
63  *num = ARRAY_SIZE(gpio_table);
64  return gpio_table;
65 }
66 
67 /*
68  * GPIOs configured before ramstage
69  * Note: the Hatch platform's romstage will configure
70  * the MEM_STRAP_* (a.k.a GPIO_MEM_CONFIG_*) pins
71  * as inputs before it reads them, so they are not
72  * needed in this table.
73  */
74 static const struct pad_config early_gpio_table[] = {
75  /* B15 : H1_SLAVE_SPI_CS_L */
76  PAD_CFG_NF(GPP_B15, NONE, DEEP, NF1),
77  /* B16 : H1_SLAVE_SPI_CLK */
78  PAD_CFG_NF(GPP_B16, NONE, DEEP, NF1),
79  /* B17 : H1_SLAVE_SPI_MISO_R */
80  PAD_CFG_NF(GPP_B17, NONE, DEEP, NF1),
81  /* B18 : H1_SLAVE_SPI_MOSI_R */
82  PAD_CFG_NF(GPP_B18, NONE, DEEP, NF1),
83  /* C8 : UART_PCH_RX_DEBUG_TX */
84  PAD_CFG_NF(GPP_C8, NONE, DEEP, NF1),
85  /* C9 : UART_PCH_TX_DEBUG_RX */
86  PAD_CFG_NF(GPP_C9, NONE, DEEP, NF1),
87  /* C14 : BT_DISABLE_L */
88  PAD_CFG_GPO(GPP_C14, 0, DEEP),
89  /* PCH_WP_OD */
90  PAD_CFG_GPI(GPP_C20, NONE, DEEP),
91  /* C21 : H1_PCH_INT_ODL */
92  PAD_CFG_GPI_APIC(GPP_C21, NONE, PLTRST, LEVEL, INVERT),
93  /* C22 : EC_IN_RW_OD */
94  PAD_CFG_GPI(GPP_C22, NONE, DEEP),
95  /* C23 : WLAN_PE_RST# */
96  PAD_CFG_GPO(GPP_C23, 1, DEEP),
97  /* E1 : M2_SSD_PEDET */
98  PAD_CFG_NF(GPP_E1, NONE, DEEP, NF1),
99  /* E5 : SATA_DEVSLP1 */
100  PAD_CFG_NF(GPP_E5, NONE, PLTRST, NF1),
101  /* F2 : MEM_CH_SEL */
102  PAD_CFG_GPI(GPP_F2, NONE, PLTRST),
103 };
104 
105 const struct pad_config *variant_early_gpio_table(size_t *num)
106 {
108  return early_gpio_table;
109 }
110 
111 /*
112  * Default GPIO settings before entering non-S5 sleep states.
113  * Configure A12: FPMCU_RST_ODL as GPO before entering sleep.
114  * This guarantees that A12's native3 function is disabled.
115  * See commit c41b0e8ea3b2714bf6d6d88a6b66c333c6919f07.
116  */
117 static const struct pad_config default_sleep_gpio_table[] = {
118  PAD_CFG_GPO(GPP_A12, 1, DEEP), /* FPMCU_RST_ODL */
119 };
120 
121 /*
122  * GPIO settings before entering S5, which are same as default_sleep_gpio_table
123  * but also, turn off FPMCU.
124  */
125 static const struct pad_config s5_sleep_gpio_table[] = {
126  PAD_CFG_GPO(GPP_A12, 0, DEEP), /* FPMCU_RST_ODL */
127  PAD_CFG_GPO(GPP_C11, 0, DEEP), /* PCH_FP_PWR_EN */
128 };
129 
130 const struct pad_config *variant_sleep_gpio_table(u8 slp_typ, size_t *num)
131 {
132  if (slp_typ == ACPI_S5) {
134  return s5_sleep_gpio_table;
135  }
138 }
#define GPP_H22
#define GPP_C15
#define GPP_H19
#define GPP_F21
#define GPP_C12
#define GPP_F12
#define GPP_F16
#define GPP_E0
#define GPP_F20
#define GPP_B16
Definition: gpio_soc_defs.h:69
#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_F17
#define GPP_A12
#define GPP_F15
#define GPP_D4
#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:117
static const struct pad_config gpio_table[]
Definition: gpio.c:8
static const struct pad_config s5_sleep_gpio_table[]
Definition: gpio.c:125
static const struct pad_config early_gpio_table[]
Definition: gpio.c:74
#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_INT(pad, pull, rst, trig)
Definition: gpio_defs.h:348
#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