1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 #include <baseboard/gpio.h>
4 #include <baseboard/variants.h>
5 #include <commonlib/helpers.h>
8 /* GPIO configuration in ramstage */
9 /* Please make sure that *ALL* GPIOs are configured in this table */
10 static const struct soc_amd_gpio base_gpio_table
[] = {
12 PAD_NF(GPIO_0
, PWR_BTN_L
, PULL_NONE
),
14 PAD_NF(GPIO_1
, SYS_RESET_L
, PULL_NONE
),
16 PAD_NF_SCI(GPIO_2
, WAKE_L
, PULL_NONE
, EDGE_LOW
),
19 /* SOC_PEN_DETECT_ODL */
20 PAD_WAKE(GPIO_4
, PULL_NONE
, EDGE_HIGH
, S0i3
),
24 PAD_GPO(GPIO_6
, HIGH
),
25 /* EN_PP3300_TCHPAD */
26 PAD_GPO(GPIO_7
, HIGH
),
28 PAD_GPO(GPIO_8
, HIGH
),
29 /* SOC_TCHPAD_INT_ODL */
30 PAD_SCI(GPIO_9
, PULL_NONE
, EDGE_LOW
),
32 PAD_NF(GPIO_10
, S0A3
, PULL_NONE
),
34 PAD_GPO(GPIO_11
, LOW
),
36 PAD_GPO(GPIO_12
, LOW
),
37 /* GPIO_13 - GPIO_15: Not available */
39 PAD_NF(GPIO_16
, USB_OC0_L
, PULL_NONE
),
41 PAD_SCI(GPIO_17
, PULL_NONE
, EDGE_LOW
),
42 /* WWAN_AUX_RESET_L */
43 PAD_GPO(GPIO_18
, HIGH
),
45 PAD_NF(GPIO_19
, I2C3_SCL
, PULL_NONE
),
47 PAD_NF(GPIO_20
, I2C3_SDA
, PULL_NONE
),
49 PAD_SCI(GPIO_21
, PULL_NONE
, EDGE_LOW
),
51 PAD_SCI(GPIO_22
, PULL_NONE
, EDGE_LOW
),
53 PAD_NF(GPIO_23
, AC_PRES
, PULL_UP
),
55 PAD_GPO(GPIO_24
, HIGH
),
56 /* GPIO_25: Not available */
58 PAD_NFO(GPIO_26
, PCIE_RST_L
, HIGH
),
60 PAD_NFO(GPIO_27
, PCIE_RST1_L
, HIGH
),
61 /* GPIO_28: Not available */
62 /* WLAN_AUX_RESET (Active HIGH)*/
63 PAD_GPO(GPIO_29
, LOW
),
65 PAD_NF(GPIO_30
, ESPI_CS_L
, PULL_NONE
),
70 /* GPIO_33 - GPIO_39: Not available */
72 PAD_GPO(GPIO_40
, HIGH
),
73 /* GPIO_41: Not available */
74 /* WWAN_DPR_SAR_ODL */
75 PAD_GPO(GPIO_42
, LOW
),
76 /* GPIO_43 - GPIO_66: Not available */
78 PAD_GPI(GPIO_67
, PULL_NONE
),
79 /* EN_PP3300_TCHSCR */
80 PAD_GPO(GPIO_68
, HIGH
),
82 PAD_GPO(GPIO_69
, HIGH
),
84 PAD_GPO(GPIO_70
, LOW
),
85 /* GPIO_71 - GPIO_73: Not available */
88 /* RAM_ID_2 / DEV_BEEP_LRCLK */
89 PAD_GPI(GPIO_75
, PULL_NONE
),
91 PAD_GPO(GPIO_76
, HIGH
),
92 /* GPIO_77 - GPIO_83: Not available */
94 PAD_GPI(GPIO_84
, PULL_NONE
),
96 PAD_INT(GPIO_85
, PULL_NONE
, EDGE_LOW
, STATUS_DELIVERY
),
98 PAD_NF(GPIO_86
, SPI_CLK
, PULL_NONE
),
99 /* RAM_ID_1 / DEV_BEEP_DATA */
100 PAD_GPI(GPIO_87
, PULL_NONE
),
101 /* RAM_ID_3 / DEV_BEEP_BCLK */
102 PAD_GPI(GPIO_88
, PULL_NONE
),
104 PAD_GPI(GPIO_89
, PULL_NONE
),
106 PAD_GPI(GPIO_90
, PULL_NONE
),
107 /* SD_EX_PRSNT_L(Guybrush BoardID 1 only) / EC_IN_RW_OD */
108 PAD_GPI(GPIO_91
, PULL_NONE
),
110 PAD_NF(GPIO_92
, CLK_REQ0_L
, PULL_NONE
),
111 /* GPIO_93 - GPIO_103: Not available */
113 PAD_NF(GPIO_104
, SPI2_DO_ESPI2_D0
, PULL_NONE
),
115 PAD_NF(GPIO_105
, SPI2_DI_ESPI2_D1
, PULL_NONE
),
117 PAD_NF(GPIO_106
, SPI2_WP_L_ESPI2_D2
, PULL_NONE
),
119 PAD_NF(GPIO_107
, SPI2_HOLD_L_ESPI2_D3
, PULL_NONE
),
121 PAD_NF(GPIO_108
, ESPI_ALERT_D1
, PULL_NONE
),
122 /* RAM_ID_0 / DEV_BEEP_EN */
123 PAD_GPI(GPIO_109
, PULL_NONE
),
124 /* GPIO_110 - GPIO_112: Not available */
126 PAD_NF(GPIO_113
, I2C2_SCL
, PULL_NONE
),
128 PAD_NF(GPIO_114
, I2C2_SDA
, PULL_NONE
),
130 PAD_NF(GPIO_115
, CLK_REQ1_L
, PULL_NONE
),
132 PAD_NF(GPIO_116
, CLK_REQ2_L
, PULL_NONE
),
133 /* GPIO_117 - GPIO_119: Not available */
134 /* TCHSCR_REPORT_EN */
135 PAD_GPO(GPIO_120
, LOW
),
137 PAD_GPO(GPIO_121
, HIGH
),
138 /* GPIO_122 - GPIO_128: Not available */
139 /* SOC_DISABLE_DISP_BL */
140 PAD_GPO(GPIO_129
, LOW
),
142 PAD_GPO(GPIO_130
, LOW
),
144 PAD_NF(GPIO_131
, CLK_REQ3_L
, PULL_NONE
),
146 PAD_GPO(GPIO_132
, LOW
),
148 PAD_NF(GPIO_140
, UART1_TXD
, PULL_NONE
),
150 PAD_NF(GPIO_141
, UART0_RXD
, PULL_NONE
),
152 PAD_NF(GPIO_142
, UART1_RXD
, PULL_NONE
),
154 PAD_NF(GPIO_143
, UART0_TXD
, PULL_NONE
),
155 /* SOC_FPMCU_BOOT0 */
156 PAD_GPO(GPIO_144
, LOW
),
158 PAD_NF(GPIO_145
, I2C0_SCL
, PULL_NONE
),
160 PAD_NF(GPIO_146
, I2C0_SDA
, PULL_NONE
),
162 PAD_NF(GPIO_147
, I2C1_SCL
, PULL_NONE
),
164 PAD_NF(GPIO_148
, I2C1_SDA
, PULL_NONE
),
167 /* Early GPIO configuration */
168 static const struct soc_amd_gpio early_gpio_table
[] = {
169 /* Assert all AUX reset lines */
172 /* WWAN_AUX_RESET_L */
173 PAD_GPO(GPIO_18
, LOW
),
174 /* WLAN_AUX_RESET (ACTIVE HIGH) */
175 PAD_GPO(GPIO_29
, HIGH
),
176 /* SSD_AUX_RESET_L */
177 PAD_GPO(GPIO_40
, LOW
),
179 PAD_GPO(GPIO_69
, LOW
),
180 /* Guybrush BID>1, Other variants : Unused TP27; BID==1: SD_AUX_RESET_L */
183 /* Deassert PCIe Reset lines */
185 PAD_NFO(GPIO_26
, PCIE_RST_L
, HIGH
),
187 PAD_NFO(GPIO_27
, PCIE_RST1_L
, HIGH
),
189 /* Power on WLAN & WWAN */
191 PAD_GPO(GPIO_6
, HIGH
),
193 PAD_GPO(GPIO_8
, HIGH
),
195 /* Put WWAN into reset */
197 PAD_GPO(GPIO_24
, LOW
),
201 PAD_NF(GPIO_141
, UART0_RXD
, PULL_NONE
),
203 PAD_NF(GPIO_143
, UART0_TXD
, PULL_NONE
),
205 /* Support EC trusted */
206 /* SD_EX_PRSNT_L(Guybrush BoardID 1 only) / EC_IN_RW_OD */
207 PAD_GPI(GPIO_91
, PULL_NONE
),
210 static const struct soc_amd_gpio espi_gpio_table
[] = {
212 PAD_NF(GPIO_30
, ESPI_CS_L
, PULL_NONE
),
214 PAD_NF(GPIO_86
, SPI_CLK
, PULL_NONE
),
216 PAD_NF(GPIO_104
, SPI2_DO_ESPI2_D0
, PULL_NONE
),
218 PAD_NF(GPIO_105
, SPI2_DI_ESPI2_D1
, PULL_NONE
),
220 PAD_NF(GPIO_106
, SPI2_WP_L_ESPI2_D2
, PULL_NONE
),
222 PAD_NF(GPIO_107
, SPI2_HOLD_L_ESPI2_D3
, PULL_NONE
),
224 PAD_NF(GPIO_108
, ESPI_ALERT_D1
, PULL_NONE
),
227 static const struct soc_amd_gpio tpm_gpio_table
[] = {
229 PAD_NF(GPIO_19
, I2C3_SCL
, PULL_NONE
),
231 PAD_NF(GPIO_20
, I2C3_SDA
, PULL_NONE
),
233 PAD_INT(GPIO_85
, PULL_NONE
, EDGE_LOW
, STATUS_DELIVERY
),
236 /* Power-on timing requirements:
238 * FCP0# goes high (GPIO 6) to Reset# high (GPIO 24): 20ms min
239 * FCP0# goes high (GPIO 6) to PERST# high (GPIO 26): 100ms min
240 * PERST# high (GPIO 26) to PCIE Training (FSP-M): 23ms min
243 * Power (3.3 V) valid to PERST# high (GPIO_26): 50ms min
246 * Power (3.3 V) valid to PERST# high (GPIO_26): 50ms min
248 * RTS5250S / RTS5227S / RTS5261S
249 * Power (3.3 V) valid to PERST# high (GPIO_69/70): 1ms min
252 * Power (3.3 V) valid to PERST# high (GPIO_26): 50ms min (SUGGESTED)
254 * NVME adapters planned for Guybrush:
255 * No power on timings specified - Assumed to require PCIe Spec suggested
256 * guidelines. Testing seems to bear out this assumption.
259 static const struct soc_amd_gpio bootblock_gpio_table
[] = {
260 /* Enable WWAN, Deassert WWAN reset, keep WWAN PCIe Aux reset asserted */
262 PAD_GPO(GPIO_24
, HIGH
),
266 PAD_GPO(GPIO_130
, LOW
),
269 /* PCIE_RST needs to be brought high before FSP-M runs */
270 static const struct soc_amd_gpio romstage_gpio_table
[] = {
271 /* Deassert all AUX_RESET lines & PCIE_RST */
274 /* WWAN_AUX_RESET_L */
275 PAD_GPO(GPIO_18
, HIGH
),
276 /* WLAN_AUX_RESET (ACTIVE HIGH) */
277 PAD_GPO(GPIO_29
, LOW
),
278 /* SSD_AUX_RESET_L */
279 PAD_GPO(GPIO_40
, HIGH
),
281 PAD_GPO(GPIO_69
, HIGH
),
282 /* Guybrush BID>1, Other variants : Unused TP27; BID==1: SD_AUX_RESET_L */
285 PAD_NFO(GPIO_26
, PCIE_RST_L
, HIGH
),
286 /* Enable touchscreen, hold in reset */
287 /* EN_PP3300_TCHSCR */
288 PAD_GPO(GPIO_68
, HIGH
),
290 PAD_GPO(GPIO_121
, LOW
),
293 const struct soc_amd_gpio
*baseboard_romstage_gpio_table(size_t *size
)
295 *size
= ARRAY_SIZE(romstage_gpio_table
);
296 return romstage_gpio_table
;
299 const struct soc_amd_gpio
*__weak
variant_bootblock_gpio_table(size_t *size
)
301 *size
= ARRAY_SIZE(bootblock_gpio_table
);
302 return bootblock_gpio_table
;
305 const struct soc_amd_gpio
*baseboard_gpio_table(size_t *size
)
307 *size
= ARRAY_SIZE(base_gpio_table
);
308 return base_gpio_table
;
310 const struct soc_amd_gpio
*__weak
variant_override_gpio_table(size_t *size
)
316 const struct soc_amd_gpio
* __weak
variant_early_override_gpio_table(size_t *size
)
318 /* Note that when overriding this, board ID & CBI is not available */
323 const struct soc_amd_gpio
* __weak
variant_bootblock_override_gpio_table(size_t *size
)
329 const struct soc_amd_gpio
* __weak
variant_romstage_override_gpio_table(size_t *size
)
335 const struct soc_amd_gpio
*__weak
variant_early_gpio_table(size_t *size
)
337 *size
= ARRAY_SIZE(early_gpio_table
);
338 return early_gpio_table
;
341 const __weak
struct soc_amd_gpio
*variant_espi_gpio_table(size_t *size
)
343 *size
= ARRAY_SIZE(espi_gpio_table
);
344 return espi_gpio_table
;
347 const __weak
struct soc_amd_gpio
*variant_tpm_gpio_table(size_t *size
)
349 *size
= ARRAY_SIZE(tpm_gpio_table
);
350 return tpm_gpio_table
;