1 /* SPDX-License-Identifier: GPL-2.0-only */
3 #include <baseboard/variants.h>
5 #include <soc/southbridge.h>
6 #include <variant/gpio.h>
9 * As a rule of thumb, GPIO pins used by coreboot should be initialized at
10 * bootblock while GPIO pins used only by the OS should be initialized at
13 static const struct soc_amd_gpio gpio_set_stage_reset
[] = {
14 /* GPIO_4 - EN_PP3300_WLAN */
15 PAD_GPO(GPIO_4
, HIGH
),
17 /* GPIO_6 - APU_RST_L / EC_SMI_ODL, SMI gets configured in ramstage */
18 PAD_GPI(GPIO_6
, PULL_UP
),
20 /* GPIO_9 - H1_PCH_INT_ODL */
21 PAD_INT(GPIO_9
, PULL_UP
, EDGE_LOW
, STATUS
),
23 /* GPIO_15 - EC_IN_RW_OD */
24 PAD_GPI(GPIO_15
, PULL_UP
),
26 /* GPIO_22 - EC_SCI_ODL, SCI gets configured in ramstage */
27 PAD_GPI(GPIO_22
, PULL_UP
),
29 /* GPIO_24 - EC_PCH_WAKE_L, SCI gets configured in ramstage */
30 PAD_GPI(GPIO_24
, PULL_UP
),
32 /* GPIO_26 - APU_PCIE_RST_L */
33 PAD_NF(GPIO_26
, PCIE_RST_L
, PULL_NONE
),
35 /* GPIO_40 - EMMC_BRIDGE_RST */
36 PAD_GPO(GPIO_40
, LOW
),
38 /* GPIO_74 - LPC_CLK0_EC_R */
39 PAD_NF(GPIO_74
, LPCCLK0
, PULL_DOWN
),
41 /* GPIO_92 - WLAN_PCIE_CLKREQ_3V3_ODL */
42 PAD_NF(GPIO_92
, CLK_REQ0_L
, PULL_UP
),
44 /* GPIO_122 - APU_BIOS_FLASH_WP_L */
45 PAD_GPI(GPIO_122
, PULL_NONE
),
47 /* GPIO_131 - CONFIG_STRAP3 */
48 PAD_GPI(GPIO_131
, PULL_NONE
),
50 /* GPIO_132 - CONFIG_STRAP4 */
51 PAD_GPI(GPIO_132
, PULL_NONE
),
53 /* GPIO_136 - UART_PCH_RX_DEBUG_TX */
54 PAD_NF(GPIO_136
, UART0_RXD
, PULL_NONE
),
56 /* GPIO_138 - UART_PCH_TX_DEBUG_RX */
57 PAD_NF(GPIO_138
, UART0_TXD
, PULL_NONE
),
59 /* GPIO_139 - CONFIG_STRAP1 */
60 PAD_GPI(GPIO_139
, PULL_NONE
),
62 /* GPIO_142 - CONFIG_STRAP2 */
63 PAD_GPI(GPIO_142
, PULL_NONE
),
66 static const struct soc_amd_gpio gpio_wlan_rst_early_reset
[] = {
67 /* GPIO_70 - WLAN_PE_RST_L */
68 PAD_GPO(GPIO_70
, HIGH
),
71 static const struct soc_amd_gpio gpio_set_stage_rom
[] = {
72 /* Enable touchscreen, hold in reset */
73 /* GPIO_76 - EN_PP3300_TOUCHSCREEN */
74 PAD_GPO(GPIO_76
, HIGH
),
75 /* GPIO_85 - TOUCHSCREEN_RST (Active High) */
76 PAD_GPO(GPIO_85
, HIGH
),
77 /* GPIO_133 - APU_EDP_BKLTEN_L (backlight - Active LOW) */
78 PAD_GPO(GPIO_133
, HIGH
),
81 static const struct soc_amd_gpio gpio_set_stage_ram
[] = {
82 /* GPIO_0 - EC_PCH_PWR_BTN_ODL */
83 PAD_NF(GPIO_0
, PWR_BTN_L
, PULL_UP
),
85 /* GPIO_1 - SYS_RST_ODL */
86 PAD_NF(GPIO_1
, SYS_RESET_L
, PULL_UP
),
88 /* GPIO_2 - WLAN_PCIE_WAKE_3V3_ODL */
89 PAD_NF_SCI(GPIO_2
, WAKE_L
, PULL_UP
, EDGE_LOW
),
91 /* GPIO_3 - MEM_VOLT_SEL */
92 PAD_GPI(GPIO_3
, PULL_UP
),
94 /* GPIO_5 - PCH_TRACKPAD_INT_3V3_ODL, SCI */
95 PAD_SCI(GPIO_5
, PULL_UP
, EDGE_LOW
),
97 /* GPIO_6 - APU_RST_L / EC_SMI_ODL, SMI */
98 PAD_SMI(GPIO_6
, PULL_UP
, LEVEL_LOW
),
100 /* GPIO_7 - APU_PWROK_OD (currently not used) */
101 PAD_GPI(GPIO_7
, PULL_UP
),
103 /* GPIO_8 - DDR_ALERT_3V3_L (currently not used) */
104 PAD_GPI(GPIO_8
, PULL_UP
),
106 /* GPIO_10 - SLP_S0_L, EC_SYNC_IRQ */
107 PAD_GPI(GPIO_10
, PULL_UP
),
109 /* GPIO_11 - TOUCHSCREEN_INT_3V3_ODL, SCI */
110 PAD_SCI(GPIO_11
, PULL_UP
, EDGE_LOW
),
112 /* GPIO_12 - EN_PP3300_TRACKPAD */
113 PAD_GPO(GPIO_12
, HIGH
),
115 /* GPIO_13 - APU_PEN_PDCT_ODL (currently not used) */
116 PAD_GPI(GPIO_13
, PULL_UP
),
118 /* GPIO_14 - APU_HP_INT_ODL, SCI */
119 PAD_SCI(GPIO_14
, PULL_UP
, EDGE_LOW
),
121 /* GPIO_16 - USB_C0_OC_L */
122 PAD_NF(GPIO_16
, USB_OC0_L
, PULL_UP
),
124 /* GPIO_17 - USB_C1_OC_L */
125 PAD_NF(GPIO_17
, USB_OC1_L
, PULL_UP
),
127 /* GPIO_18 - USB_A0_OC_ODL */
128 PAD_NF(GPIO_18
, USB_OC2_L
, PULL_UP
),
130 /* GPIO_19 - APU_I2C_SCL3 (Touchscreen) */
131 PAD_NF(GPIO_19
, I2C3_SCL
, PULL_UP
),
133 /* GPIO_20 - APU_I2C_SDA3 (Touchscreen) */
134 PAD_NF(GPIO_20
, I2C3_SDA
, PULL_UP
),
136 /* GPIO_21 - APU_PEN_INT_ODL, SCI */
137 PAD_SCI(GPIO_21
, PULL_UP
, EDGE_LOW
),
139 /* GPIO_22 - EC_SCI_ODL, SCI */
140 PAD_SCI(GPIO_22
, PULL_UP
, EDGE_LOW
),
142 /* GPIO_24 - EC_PCH_WAKE_L, SCI */
143 PAD_SCI(GPIO_24
, PULL_UP
, EDGE_LOW
),
145 /* GPIO_25 - SD_CD */
146 PAD_NF(GPIO_25
, SD0_CD
, PULL_UP
),
148 /* GPIO_42 - S5_MUX_CTRL */
149 PAD_NF(GPIO_42
, S5_MUX_CTRL
, PULL_NONE
),
151 /* GPIO_67 - PEN_RESET */
152 PAD_GPO(GPIO_67
, LOW
),
154 /* GPIO_75 - Unused (strap) (R139/R130) */
155 PAD_GPI(GPIO_75
, PULL_UP
),
157 /* GPIO_76 - EN_PP3300_TOUCHSCREEN */
158 PAD_GPO(GPIO_76
, HIGH
),
160 /* GPIO_84 - HUB_RST (Active High) */
161 PAD_GPO(GPIO_84
, LOW
),
163 /* GPIO_85 - TOUCHSCREEN_RST (Active High) */
164 PAD_GPO(GPIO_85
, LOW
),
166 /* GPIO_86 - Unused (TP109) */
167 PAD_GPI(GPIO_86
, PULL_UP
),
169 /* GPIO_87 - LPC_SERIRQ */
170 PAD_NF(GPIO_87
, SERIRQ
, PULL_NONE
),
172 /* GPIO_88 - LPC_CLKRUN_L */
173 PAD_NF(GPIO_88
, LPC_CLKRUN_L
, PULL_NONE
),
175 /* GPIO_90 - EN_PP3300_CAMERA */
176 PAD_GPO(GPIO_90
, HIGH
),
178 /* GPIO_91 - DMIC_CLK1_EN */
179 PAD_GPO(GPIO_91
, HIGH
),
181 /* GPIO_93 - EMMC_RST */
182 PAD_GPO(GPIO_93
, LOW
),
184 /* GPIO_101 - SD_WP_L */
185 PAD_NF(GPIO_101
, SD0_WP
, PULL_DOWN
),
187 /* GPIO_102 - EN_SD_SOCKET_PWR */
188 PAD_NF(GPIO_102
, SD0_PWR_CTRL
, PULL_DOWN
),
190 /* GPIO_113 - APU_I2C_SCL2 (Pen & Trackpad) */
191 PAD_NF(GPIO_113
, I2C2_SCL
, PULL_UP
),
193 /* GPIO_114 - APU_I2C_SDA2 (Pen & Trackpad) */
194 PAD_NF(GPIO_114
, I2C2_SDA
, PULL_UP
),
196 /* GPIO_115 - Unused (TP127) */
197 PAD_GPI(GPIO_115
, PULL_UP
),
199 /* GPIO_116 - PCIE_EMMC_CLKREQ_L */
200 PAD_NF(GPIO_116
, CLK_REQ2_L
, PULL_NONE
),
202 /* GPIO_118 - PCH_SPI_CS0_L */
203 PAD_NF(GPIO_118
, SPI_CS1_L
, PULL_NONE
),
205 /* GPIO_119 - SPK_PA_EN */
206 PAD_GPO(GPIO_119
, LOW
),
208 /* GPIO_126 - DMIC_CLK2_EN */
209 PAD_GPO(GPIO_126
, HIGH
),
211 /* GPIO_129 - APU_KBRST_L */
212 PAD_NF(GPIO_129
, KBRST_L
, PULL_UP
),
214 /* GPIO_130 - Unused (TP55) */
215 PAD_GPI(GPIO_130
, PULL_UP
),
217 /* GPIO_135 - BCLK Buffer Enable */
218 PAD_GPO(GPIO_135
, HIGH
),
220 /* GPIO_137 - Unused (TP27) */
221 PAD_GPI(GPIO_137
, PULL_UP
),
223 /* GPIO_140 - I2S_BCLK_R (init to func0, used for I2S) */
224 PAD_NF(GPIO_140
, UART1_CTS_L
, PULL_NONE
),
226 /* GPIO_141 - I2S2_DATA_MIC2 (init to func0, used for I2S) */
227 PAD_NF(GPIO_141
, UART1_RXD
, PULL_NONE
),
229 /* GPIO_143 - I2S2_DATA (init to func0, used for I2S) */
230 PAD_NF(GPIO_143
, UART1_TXD
, PULL_NONE
),
232 /* GPIO_144 - I2S_LR_R (init to func0, used for I2S) */
233 PAD_NF(GPIO_144
, UART1_INTR
, PULL_NONE
),
235 /* GPIO_145 - PCH_I2C_AUDIO_SCL */
236 PAD_NF(GPIO_145
, I2C0_SCL
, PULL_NONE
),
238 /* GPIO_146 - PCH_I2C_AUDIO_SDA */
239 PAD_NF(GPIO_146
, I2C0_SDA
, PULL_NONE
),
241 /* GPIO_147 - PCH_I2C_H1_TPM_SCL */
242 PAD_NF(GPIO_147
, I2C1_SCL
, PULL_NONE
),
244 /* GPIO_148 - PCH_I2C_H1_TPM_SDA */
245 PAD_NF(GPIO_148
, I2C1_SDA
, PULL_NONE
),
249 struct soc_amd_gpio
*variant_early_gpio_table(size_t *size
)
251 *size
= ARRAY_SIZE(gpio_set_stage_reset
);
252 return gpio_set_stage_reset
;
256 struct soc_amd_gpio
*variant_wlan_rst_early_gpio_table(size_t *size
)
258 *size
= ARRAY_SIZE(gpio_wlan_rst_early_reset
);
259 return gpio_wlan_rst_early_reset
;
263 struct soc_amd_gpio
*baseboard_romstage_gpio_table(size_t *size
)
265 *size
= ARRAY_SIZE(gpio_set_stage_rom
);
266 return gpio_set_stage_rom
;
270 struct soc_amd_gpio
*variant_gpio_table(size_t *size
)
272 *size
= ARRAY_SIZE(gpio_set_stage_ram
);
273 return gpio_set_stage_ram
;
276 int __weak
variant_get_xhci_oc_map(uint16_t *map
)
278 *map
= USB_OC0
<< OC_PORT0_SHIFT
; /* USB-C Port0/4 = OC0 */
279 *map
|= USB_OC1
<< OC_PORT1_SHIFT
; /* USB-C Port1/5 = OC1 */
280 *map
|= USB_OC2
<< OC_PORT2_SHIFT
; /* USB-A HUB Port2/6 = OC2 */
281 *map
|= USB_OC_DISABLE
<< OC_PORT3_SHIFT
;
285 int __weak
variant_get_ehci_oc_map(uint16_t *map
)
287 *map
= USB_OC_DISABLE_ALL
;