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 <baseboard/gpio.h>
4 #include <baseboard/variants.h>
5 #include <types.h>
6 #include <vendorcode/google/chromeos/chromeos.h>
7 
8 /* Pad configuration in ramstage */
9 static const struct pad_config gpio_table[] = {
10  /* PCH M.2 SSD */
11  PAD_CFG_GPO(GPP_B16, 1, DEEP),
12  PAD_CFG_GPO(GPP_H0, 1, DEEP),
13 
14  /* Camera */
15  PAD_CFG_NF(GPP_H6, NONE, DEEP, NF1), /* I2C3_SDA */
16  PAD_CFG_NF(GPP_H7, NONE, DEEP, NF1), /* I2C3_SCL */
17  PAD_CFG_NF(GPP_B9, NONE, DEEP, NF1), /* I2C5_SDA */
18  PAD_CFG_NF(GPP_B10, NONE, DEEP, NF1), /* I2C5_SCL */
19  PAD_CFG_GPO(GPP_B23, 0, DEEP),
20  PAD_CFG_GPO(GPP_C15, 0, DEEP),
21  PAD_CFG_GPO(GPP_R6, 0, DEEP),
22  PAD_CFG_GPO(GPP_H12, 0, DEEP),
23 
24  /* Image clock: IMGCLKOUT_0, IMGCLKOUT_1 */
25  PAD_CFG_NF(GPP_D4, NONE, DEEP, NF1),
26  PAD_CFG_NF(GPP_H20, NONE, DEEP, NF1),
27 
28  /* ISH UART0 RX/TX */
29  PAD_CFG_NF(GPP_D13, NONE, DEEP, NF1),
30  PAD_CFG_NF(GPP_D14, NONE, DEEP, NF1),
31 
32  /* ISH I2C0 */
33  PAD_CFG_NF(GPP_B5, NONE, DEEP, NF1),
34  PAD_CFG_NF(GPP_B6, NONE, DEEP, NF1),
35 
36  /* ISH GPI 0-6 */
37  PAD_CFG_NF(GPP_D0, NONE, DEEP, NF1),
38  PAD_CFG_NF(GPP_D1, NONE, DEEP, NF1),
39  PAD_CFG_NF(GPP_D2, NONE, DEEP, NF1),
40  PAD_CFG_NF(GPP_D3, NONE, DEEP, NF1),
41  PAD_CFG_NF(GPP_D17, NONE, DEEP, NF1),
42  PAD_CFG_NF(GPP_D18, NONE, DEEP, NF1),
43  PAD_CFG_NF(GPP_E15, NONE, DEEP, NF1),
44  PAD_CFG_NF(GPP_E16, NONE, DEEP, NF1),
45 
46  /* Audio */
47  PAD_CFG_NF(GPP_C16, NONE, DEEP, NF1), /* I2C0_SDA */
48  PAD_CFG_NF(GPP_C17, NONE, DEEP, NF1), /* I2C0_SCL */
49  PAD_CFG_GPO(GPP_C5, 1, DEEP),
50  PAD_CFG_GPI_APIC(GPP_C12, NONE, DEEP, EDGE_BOTH, INVERT), /* AUDIO JACK IRQ */
51 
52  PAD_CFG_NF(GPP_D19, NONE, DEEP, NF1), /* I2S_MCLK1 */
53  PAD_CFG_NF(GPP_F8, NONE, DEEP, NF1), /* I2S_MCLK2 */
54 
55  /* CNVi */
56  PAD_CFG_NF(GPP_F4, NONE, DEEP, NF1), /* CNV_RF_RST_L */
57  PAD_CFG_NF(GPP_F5, NONE, DEEP, NF3), /* CNV_CLKREQ0 */
58 
59  /* EC_SYNC_IRQ */
60  PAD_CFG_GPI_APIC(GPP_A15, NONE, PLTRST, LEVEL, INVERT), /* MECC_HPD2 */
61 
62  PAD_CFG_GPO(GPP_H1, 1, DEEP), /* AUDIO_PWREN */
63 };
64 
65 /* Early pad configuration in bootblock */
66 static const struct pad_config early_gpio_table[] = {
67  /* UART */
68  PAD_CFG_NF(GPP_C20, NONE, DEEP, NF1), /* UART2 RX */
69  PAD_CFG_NF(GPP_C21, NONE, DEEP, NF1), /* UART2 TX */
70 
71  /* Audio */
72  PAD_CFG_NF(GPP_R0, NONE, DEEP, NF2), /* I2S0_HP_SCLK */
73  PAD_CFG_NF(GPP_R1, NONE, DEEP, NF2), /* I2S0_HP_SFRM */
74  PAD_CFG_NF(GPP_R2, NONE, DEEP, NF2), /* I2S0_HP_TX */
75  PAD_CFG_NF(GPP_R3, NONE, DEEP, NF2), /* I2S0_HP_RX */
76  PAD_CFG_NF(GPP_R4, DN_20K, DEEP, NF1), /* HDA_RST_L */
77 
78  PAD_CFG_NF(GPP_A7, NONE, DEEP, NF1), /* I2S2_SPKR_SCLK */
79  PAD_CFG_NF(GPP_A8, NONE, DEEP, NF1), /* I2S2_SPKR_SFRM */
80  PAD_CFG_NF(GPP_A9, NONE, DEEP, NF1), /* I2S2_SPKR_TX */
81  PAD_CFG_NF(GPP_A10, NONE, DEEP, NF1), /* I2S2_SPKR_RX */
82 
83  PAD_CFG_NF(GPP_S0, NONE, DEEP, NF1), /* SNDW0_HP_CLK */
84  PAD_CFG_NF(GPP_S1, NONE, DEEP, NF1), /* SNDW0_HP_DATA */
85 
86  PAD_CFG_NF(GPP_S2, NONE, DEEP, NF2), /* DMIC0_CLK_B */
87  PAD_CFG_NF(GPP_S6, NONE, DEEP, NF2), /* DMIC0_CLK_A */
88  PAD_CFG_NF(GPP_S7, NONE, DEEP, NF2), /* DMIC0_DATA */
89  PAD_CFG_NF(GPP_S3, NONE, DEEP, NF2), /* DMIC1_CLK_B */
90  PAD_CFG_NF(GPP_S4, NONE, DEEP, NF2), /* DMIC1_CLK_A */
91  PAD_CFG_NF(GPP_S5, NONE, DEEP, NF2), /* DMIC1_DATA */
92 
93  /* DP */
94  PAD_CFG_NF(GPP_L_BKLTEN, NONE, DEEP, NF1), /* L_BKLTEN */
95  PAD_CFG_NF(GPP_L_BKLTCTL, NONE, DEEP, NF1), /* L_BKLTCTL */
96  PAD_CFG_NF(GPP_L_VDDEN, NONE, DEEP, NF1), /* L_VDDEN */
97  PAD_CFG_NF(GPP_E14, NONE, DEEP, NF1), /* HPD_A */
98  PAD_CFG_NF(GPP_A18, NONE, DEEP, NF1), /* HPD_B */
99  PAD_CFG_NF(GPP_A19, NONE, DEEP, NF1), /* HPD_1 */
100  PAD_CFG_NF(GPP_E18, NONE, DEEP, NF1), /* DDP_1_CTRCLK */
101  PAD_CFG_NF(GPP_E19, NONE, DEEP, NF1), /* DDP_1_CTRDATA */
102 
103  /* TPM */
104  /* B19 : GSPI1_CS0B */
105  PAD_CFG_NF(GPP_B19, NONE, DEEP, NF1),
106  /* B20 : GSPI1_CLK */
107  PAD_CFG_NF(GPP_B20, NONE, DEEP, NF1),
108  /* B21 : GSPI1_MISO */
109  PAD_CFG_NF(GPP_B21, NONE, DEEP, NF1),
110  /* B22 : GSPI1_MOSI */
111  PAD_CFG_NF(GPP_B22, NONE, DEEP, NF1),
112 
113  /* WWAN */
114  PAD_CFG_GPO(GPP_H23, 1, DEEP), /* WWAN_PWREN */
115  PAD_CFG_NF(GPP_D7, NONE, DEEP, NF1), /* CLK SRC 2 */
116  PAD_CFG_GPI_SCI(GPP_C9, NONE, DEEP, LEVEL, INVERT), /* WWAN_WAKE_N */
117  PAD_CFG_GPO(GPP_C11, 1, DEEP), /* FULL_CARD_POWER_OFF_N */
118  PAD_CFG_GPO(GPP_C10, 1, DEEP), /* WWAN_RST_N */
119  PAD_CFG_GPO(GPP_B17, 1, DEEP), /* WWAN_PERST_N */
120  PAD_CFG_GPO(GPP_D15, 1, DEEP), /* WWAN_DISABLE_N */
121 };
122 
123 const struct pad_config *variant_gpio_table(size_t *num)
124 {
125  *num = ARRAY_SIZE(gpio_table);
126  return gpio_table;
127 }
128 
129 const struct pad_config *variant_early_gpio_table(size_t *num)
130 {
132  return early_gpio_table;
133 }
134 
135 static const struct cros_gpio cros_gpios[] = {
136  CROS_GPIO_REC_AL(CROS_GPIO_VIRTUAL, CROS_GPIO_DEVICE_NAME),
137 };
138 
#define GPP_C15
#define GPP_H20
#define GPP_B6
Definition: gpio_soc_defs.h:59
#define GPP_D1
#define GPP_D17
#define GPP_A18
#define GPP_C12
#define GPP_S4
#define GPP_R4
#define GPP_D14
#define GPP_S0
#define GPP_C5
#define GPP_S5
#define GPP_B16
Definition: gpio_soc_defs.h:69
#define GPP_D7
#define GPP_R3
#define GPP_A19
#define GPP_D2
#define GPP_H12
#define GPP_H6
#define GPP_C9
#define GPP_R6
#define GPP_R0
#define GPP_F5
#define GPP_S7
#define GPP_H7
#define GPP_H1
#define GPP_C11
#define GPP_B22
Definition: gpio_soc_defs.h:75
#define GPP_S3
#define GPP_E14
#define GPP_C17
#define GPP_A7
#define GPP_S1
#define GPP_C20
#define GPP_B20
Definition: gpio_soc_defs.h:73
#define GPP_L_VDDEN
#define GPP_L_BKLTEN
#define GPP_D4
#define GPP_C10
#define GPP_C16
#define GPP_D18
#define GPP_S6
#define GPP_B19
Definition: gpio_soc_defs.h:72
#define GPP_E19
#define GPP_H0
#define GPP_C21
#define GPP_R2
#define GPP_B9
Definition: gpio_soc_defs.h:62
#define GPP_E18
#define GPP_F4
#define GPP_A10
#define GPP_A8
#define GPP_D0
#define GPP_D13
#define GPP_B5
Definition: gpio_soc_defs.h:58
#define GPP_A15
#define GPP_A9
#define GPP_F8
#define GPP_S2
#define GPP_B23
Definition: gpio_soc_defs.h:76
#define GPP_E15
#define GPP_B10
Definition: gpio_soc_defs.h:63
#define GPP_E16
#define GPP_D19
#define GPP_D15
#define GPP_B21
Definition: gpio_soc_defs.h:74
#define GPP_L_BKLTCTL
#define GPP_B17
Definition: gpio_soc_defs.h:70
#define GPP_H23
#define GPP_D3
#define GPP_R1
#define ARRAY_SIZE(a)
Definition: helpers.h:12
const struct pad_config * variant_early_gpio_table(size_t *num)
Definition: gpio.c:204
const struct pad_config *__weak variant_gpio_table(size_t *num)
Definition: gpio.c:406
DECLARE_CROS_GPIOS(cros_gpios)
static const struct pad_config gpio_table[]
Definition: gpio.c:9
static const struct pad_config early_gpio_table[]
Definition: gpio.c:66
static const struct cros_gpio cros_gpios[]
Definition: gpio.c:135
#define CROS_GPIO_DEVICE_NAME
Definition: gpio.h:14
#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