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_E22, 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  /* EC_SYNC_IRQ */
56  PAD_CFG_GPI_APIC(GPP_A15, NONE, PLTRST, LEVEL, INVERT), /* MECC_HPD2 */
57 
58  PAD_CFG_GPO(GPP_H1, 1, DEEP), /* AUDIO_PWREN */
59 };
60 
61 /* Early pad configuration in bootblock */
62 static const struct pad_config early_gpio_table[] = {
63  /* UART */
64  PAD_CFG_NF(GPP_C20, NONE, DEEP, NF1), /* UART2 RX */
65  PAD_CFG_NF(GPP_C21, NONE, DEEP, NF1), /* UART2 TX */
66 
67  /* Audio */
68  PAD_CFG_NF(GPP_R0, NONE, DEEP, NF2), /* I2S0_HP_SCLK */
69  PAD_CFG_NF(GPP_R1, NONE, DEEP, NF2), /* I2S0_HP_SFRM */
70  PAD_CFG_NF(GPP_R2, NONE, DEEP, NF2), /* I2S0_HP_TX */
71  PAD_CFG_NF(GPP_R3, NONE, DEEP, NF2), /* I2S0_HP_RX */
72  PAD_CFG_NF(GPP_R4, DN_20K, DEEP, NF1), /* HDA_RST_L */
73 
74  PAD_CFG_NF(GPP_A7, NONE, DEEP, NF1), /* I2S2_SPKR_SCLK */
75  PAD_CFG_NF(GPP_A8, NONE, DEEP, NF1), /* I2S2_SPKR_SFRM */
76  PAD_CFG_NF(GPP_A9, NONE, DEEP, NF1), /* I2S2_SPKR_TX */
77  PAD_CFG_NF(GPP_A10, NONE, DEEP, NF1), /* I2S2_SPKR_RX */
78 
79  PAD_CFG_NF(GPP_S0, NONE, DEEP, NF1), /* SNDW0_HP_CLK */
80  PAD_CFG_NF(GPP_S1, NONE, DEEP, NF1), /* SNDW0_HP_DATA */
81 
82  PAD_CFG_NF(GPP_S2, NONE, DEEP, NF2), /* DMIC0_CLK_B */
83  PAD_CFG_NF(GPP_S6, NONE, DEEP, NF2), /* DMIC0_CLK_A */
84  PAD_CFG_NF(GPP_S7, NONE, DEEP, NF2), /* DMIC0_DATA */
85  PAD_CFG_NF(GPP_S3, NONE, DEEP, NF2), /* DMIC1_CLK_B */
86  PAD_CFG_NF(GPP_S4, NONE, DEEP, NF2), /* DMIC1_CLK_A */
87  PAD_CFG_NF(GPP_S5, NONE, DEEP, NF2), /* DMIC1_DATA */
88 
89  /* DP */
90  PAD_CFG_NF(GPP_L_BKLTEN, NONE, DEEP, NF1), /* L_BKLTEN */
91  PAD_CFG_NF(GPP_L_BKLTCTL, NONE, DEEP, NF1), /* L_BKLTCTL */
92  PAD_CFG_NF(GPP_L_VDDEN, NONE, DEEP, NF1), /* L_VDDEN */
93  PAD_CFG_NF(GPP_E14, NONE, DEEP, NF1), /* HPD_A */
94  PAD_CFG_NF(GPP_A18, NONE, DEEP, NF1), /* HPD_B */
95  PAD_CFG_NF(GPP_A19, NONE, DEEP, NF1), /* HPD_1 */
96  PAD_CFG_NF(GPP_E18, NONE, DEEP, NF1), /* DDP_1_CTRCLK */
97  PAD_CFG_NF(GPP_E19, NONE, DEEP, NF1), /* DDP_1_CTRDATA */
98 
99  /* TPM */
100  /* B19 : GSPI1_CS0B */
101  PAD_CFG_NF(GPP_B19, NONE, DEEP, NF1),
102  /* B20 : GSPI1_CLK */
103  PAD_CFG_NF(GPP_B20, NONE, DEEP, NF1),
104  /* B21 : GSPI1_MISO */
105  PAD_CFG_NF(GPP_B21, NONE, DEEP, NF1),
106  /* B22 : GSPI1_MOSI */
107  PAD_CFG_NF(GPP_B22, NONE, DEEP, NF1),
108 
109  /* WWAN */
110  PAD_CFG_GPO(GPP_D11, 1, DEEP), /* WWAN_PWREN */
111  PAD_CFG_NF(GPP_D7, NONE, DEEP, NF1), /* CLK SRC 2 */
112  PAD_CFG_GPI_SCI(GPP_C9, NONE, DEEP, LEVEL, INVERT), /* WWAN_WAKE_N */
113  PAD_CFG_GPO(GPP_C11, 1, DEEP), /* FULL_CARD_POWER_OFF_N */
114  PAD_CFG_GPO(GPP_C10, 1, DEEP), /* WWAN_RST_N */
115  PAD_CFG_GPO(GPP_B17, 1, DEEP), /* WWAN_PERST_N */
116  PAD_CFG_GPO(GPP_D15, 1, DEEP), /* WWAN_DISABLE_N */
117 };
118 
119 const struct pad_config *variant_gpio_table(size_t *num)
120 {
121  *num = ARRAY_SIZE(gpio_table);
122  return gpio_table;
123 }
124 
125 const struct pad_config *variant_early_gpio_table(size_t *num)
126 {
128  return early_gpio_table;
129 }
130 
131 static const struct cros_gpio cros_gpios[] = {
132  CROS_GPIO_REC_AL(CROS_GPIO_VIRTUAL, CROS_GPIO_DEVICE_NAME),
133 };
134 
#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_R0
#define GPP_S7
#define GPP_D11
#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_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_E22
#define GPP_L_BKLTCTL
#define GPP_B17
Definition: gpio_soc_defs.h:70
#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:62
static const struct cros_gpio cros_gpios[]
Definition: gpio.c:131
#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