Wisley Chen | 1597a21 | 2020-10-31 00:51:06 +0800 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
| 2 | |
Nick Vaccaro | 2f78ce0 | 2021-02-16 19:06:16 -0800 | [diff] [blame] | 3 | #include <acpi/acpi.h> |
Wisley Chen | 1597a21 | 2020-10-31 00:51:06 +0800 | [diff] [blame] | 4 | #include <baseboard/gpio.h> |
| 5 | #include <baseboard/variants.h> |
| 6 | #include <commonlib/helpers.h> |
| 7 | |
| 8 | /* Pad configuration in ramstage */ |
| 9 | static const struct pad_config override_gpio_table[] = { |
| 10 | /* A7 : I2S2_SCLK ==> EN_PP3300_TRACKPAD */ |
| 11 | PAD_CFG_GPO(GPP_A7, 1, DEEP), |
| 12 | /* A8 : I2S2_SFRM ==> EN_PP3300_TOUCHSCREEN */ |
Matt DeVillier | 7ed6130 | 2022-12-21 08:38:17 -0600 | [diff] [blame^] | 13 | PAD_CFG_GPO(GPP_A8, 1, DEEP), |
Wisley Chen | 1597a21 | 2020-10-31 00:51:06 +0800 | [diff] [blame] | 14 | /* A10 : I2S2_RXD ==> EN_SPKR_PA */ |
| 15 | PAD_CFG_GPO(GPP_A10, 1, DEEP), |
| 16 | /* A13 : PMC_I2C_SCL ==> BT_DISABLE_L */ |
| 17 | PAD_CFG_GPO(GPP_A13, 1, DEEP), |
| 18 | /* A16 : USB_OC3# ==> USB_C0_OC_ODL */ |
| 19 | PAD_CFG_NF(GPP_A16, NONE, DEEP, NF1), |
| 20 | /* A18 : DDSP_HPDB ==> HDMI_HPD */ |
| 21 | PAD_CFG_NF(GPP_A18, NONE, DEEP, NF1), |
Wisley Chen | 1597a21 | 2020-10-31 00:51:06 +0800 | [diff] [blame] | 22 | /* A22 : DDPC_CTRLDATA ==> EN_HDMI_PWR */ |
| 23 | PAD_CFG_GPO(GPP_A22, 1, DEEP), |
| 24 | /* A23 : I2S1_SCLK ==> I2S1_SPKR_SCLK */ |
| 25 | PAD_CFG_NF(GPP_A23, NONE, DEEP, NF1), |
| 26 | |
| 27 | /* B2 : VRALERT# ==> EN_PP3300_SSD */ |
Nick Vaccaro | 123fd50 | 2021-06-11 18:10:36 -0700 | [diff] [blame] | 28 | PAD_CFG_GPO(GPP_B2, 1, PLTRST), |
Wisley Chen | 1597a21 | 2020-10-31 00:51:06 +0800 | [diff] [blame] | 29 | /* B3 : CPU_GP2 ==> PEN_DET_ODL */ |
| 30 | PAD_CFG_GPI(GPP_B3, NONE, DEEP), |
| 31 | /* B4 : CPU_GP3==> EN_PP3300_EMMC */ |
| 32 | PAD_CFG_GPO(GPP_B4, 1, DEEP), |
Wisley Chen | 1597a21 | 2020-10-31 00:51:06 +0800 | [diff] [blame] | 33 | /* B9 : I2C5_SDA ==> PCH_I2C5_TRACKPAD_SDA */ |
| 34 | PAD_CFG_NF(GPP_B9, NONE, DEEP, NF1), |
| 35 | /* B10 : I2C5_SCL ==> PCH_I2C5_TRACKPAD_SCL */ |
| 36 | PAD_CFG_NF(GPP_B10, NONE, DEEP, NF1), |
| 37 | /* B19 : GSPI1_CS0# ==> PCH_GSPI1_FPMCU_CS_L */ |
| 38 | PAD_CFG_NF(GPP_B19, NONE, DEEP, NF1), |
| 39 | /* B20 : GSPI1_CLK ==> PCH_GSPI1_FPMCU_CLK */ |
| 40 | PAD_CFG_NF(GPP_B20, NONE, DEEP, NF1), |
| 41 | /* B21 : GSPI1_MISO ==> PCH_GSPI1_FPMCU_MISO */ |
| 42 | PAD_CFG_NF(GPP_B21, NONE, DEEP, NF1), |
| 43 | |
| 44 | /* C0 : SMBCLK ==> EN_PP3300_WLAN */ |
| 45 | PAD_CFG_GPO(GPP_C0, 1, DEEP), |
Wisley Chen | 1597a21 | 2020-10-31 00:51:06 +0800 | [diff] [blame] | 46 | /* C2 : SMBALERT# ==> GPP_C2_STRAP */ |
| 47 | PAD_NC(GPP_C2, DN_20K), |
| 48 | /* C3 : EMMC_PE_WAKE_ODL*/ |
| 49 | PAD_CFG_GPI(GPP_C3, NONE, DEEP), |
| 50 | /* C4 : EMMC_PERST_L*/ |
| 51 | PAD_CFG_GPO(GPP_C4, 1, DEEP), |
| 52 | |
| 53 | /* C5 : SML0ALERT# ==> GPP_C5_BOOT_STRAP_0 */ |
| 54 | PAD_NC(GPP_C5, DN_20K), |
| 55 | /* C10 : UART0_RTS# ==> USI_RST_L */ |
Matt DeVillier | 7ed6130 | 2022-12-21 08:38:17 -0600 | [diff] [blame^] | 56 | PAD_CFG_GPO(GPP_C10, 1, DEEP), |
Wisley Chen | 1597a21 | 2020-10-31 00:51:06 +0800 | [diff] [blame] | 57 | /* C16 : I2C0_SDA ==> PCH_I2C0_1V8_AUDIO_SDA */ |
| 58 | PAD_CFG_NF(GPP_C16, NONE, DEEP, NF1), |
| 59 | /* C17 : I2C0_SCL ==> PCH_I2C0_1V8_AUDIO_SCL */ |
| 60 | PAD_CFG_NF(GPP_C17, NONE, DEEP, NF1), |
| 61 | /* C18 : I2C1_SDA ==> PCH_I2C1_TOUCH_USI_SDA */ |
| 62 | PAD_CFG_NF(GPP_C18, NONE, DEEP, NF1), |
| 63 | /* C19 : I2C1_SCL ==> PCH_I2C1_TOUCH_USI_SCL */ |
| 64 | PAD_CFG_NF(GPP_C19, NONE, DEEP, NF1), |
| 65 | /* C20 : UART2_RXD ==> FPMCU_INT_L */ |
| 66 | PAD_CFG_GPI_INT(GPP_C20, NONE, PLTRST, LEVEL), |
| 67 | /* C22 : UART2_RTS# ==> PCH_FPMCU_BOOT0 */ |
| 68 | PAD_CFG_GPO(GPP_C22, 0, DEEP), |
Wisley Chen | 1597a21 | 2020-10-31 00:51:06 +0800 | [diff] [blame] | 69 | |
| 70 | /* D6 : SRCCLKREQ1# ==> WLAN_CLKREQ_ODL */ |
| 71 | PAD_CFG_NF(GPP_D6, NONE, DEEP, NF1), |
Wisley Chen | 1597a21 | 2020-10-31 00:51:06 +0800 | [diff] [blame] | 72 | /* D8 : SRCCLKREQ3# ==> SD_CLKREQ_ODL */ |
| 73 | PAD_CFG_NF(GPP_D8, NONE, DEEP, NF1), |
| 74 | /* D12 : ISH_SPI_MOSI ==> PCH_GSPI2_CVF_MOSI_STRAP */ |
| 75 | PAD_CFG_NF(GPP_D12, DN_20K, DEEP, NF7), |
| 76 | /* D13 : ISH_UART0_RXD ==> UART_ISH_RX_DEBUG_TX */ |
| 77 | PAD_CFG_NF(GPP_D13, NONE, DEEP, NF1), |
| 78 | /* D14 : ISH_UART0_TXD ==> UART_ISH_TX_DEBUG_RX */ |
| 79 | PAD_CFG_NF(GPP_D14, NONE, DEEP, NF1), |
| 80 | /* D16 : ISH_UART0_CTS# ==> EN_PP3300_SD */ |
| 81 | PAD_CFG_GPO(GPP_D16, 1, DEEP), |
| 82 | /* D17 : ISH_GP4 ==> EN_FCAM_PWR */ |
| 83 | PAD_CFG_GPO(GPP_D17, 1, DEEP), |
| 84 | |
| 85 | /* E1 : SPI1_IO2 ==> PEN_DET_ODL */ |
| 86 | PAD_CFG_GPI_SCI_LOW(GPP_E1, NONE, DEEP, EDGE_SINGLE), |
| 87 | /* E2 : SPI1_IO3 ==> WLAN_PCIE_WAKE_ODL */ |
| 88 | PAD_CFG_GPI(GPP_E2, NONE, DEEP), |
| 89 | /* E3 : CPU_GP0 ==> USI_REPORT_EN */ |
| 90 | PAD_CFG_GPO(GPP_E3, 0, DEEP), |
| 91 | /* E4 : SATA_DEVSLP0 ==> M2_SSD_PE_WAKE_ODL */ |
| 92 | PAD_CFG_GPI(GPP_E4, NONE, DEEP), |
| 93 | /* E6 : THC0_SPI1_RST# ==> GPP_E6_STRAP */ |
| 94 | PAD_CFG_GPI(GPP_E6, NONE, DEEP), |
| 95 | /* E7 : CPU_GP1 ==> USI_INT */ |
| 96 | PAD_CFG_GPI_APIC(GPP_E7, NONE, PLTRST, LEVEL, NONE), |
| 97 | /* E8 : SPI1_CS1# ==> SLP_S0IX */ |
| 98 | PAD_CFG_GPO(GPP_E8, 0, DEEP), |
| 99 | /* E11 : SPI1_CLK ==> SD_PE_WAKE_ODL */ |
| 100 | PAD_CFG_GPI(GPP_E11, NONE, DEEP), |
| 101 | /* E15 : ISH_GP6 ==> TRACKPAD_INT_ODL */ |
| 102 | PAD_CFG_GPI_IRQ_WAKE(GPP_E15, NONE, DEEP, LEVEL, INVERT), |
| 103 | /* E18 : DDP1_CTRLCLK ==> NC */ |
| 104 | PAD_NC(GPP_E18, NONE), |
| 105 | /* E20 : DDP2_CTRLCLK ==> NC */ |
| 106 | PAD_NC(GPP_E20, NONE), |
| 107 | /* E21 : DDP2_CTRLDATA ==> NC */ |
| 108 | PAD_NC(GPP_E21, NONE), |
| 109 | |
| 110 | /* F7 : GPPF7_STRAP ==> GPP_F7_STRAP */ |
| 111 | PAD_NC(GPP_F7, DN_20K), |
| 112 | /* F8 : I2S_MCLK2_INOUT ==> HP_INT_L */ |
| 113 | PAD_CFG_GPI_INT(GPP_F8, NONE, PLTRST, EDGE_BOTH), |
| 114 | /* F11 : THC1_SPI2_CLK ==> NC */ |
| 115 | PAD_NC(GPP_F11, NONE), |
| 116 | /* F12 : GSXDOUT ==> NC */ |
| 117 | PAD_NC(GPP_F12, NONE), |
| 118 | |
| 119 | /* F13 : GSXDOUT ==> WiFi_DISABLE_L */ |
| 120 | PAD_CFG_GPO(GPP_F13, 1, DEEP), |
| 121 | /* F19 : SRCCLKREQ6# ==> WLAN_INT_L */ |
| 122 | PAD_CFG_GPI_SCI_LOW(GPP_F19, NONE, DEEP, EDGE_SINGLE), |
| 123 | |
| 124 | /* H0 : GPPH0_BOOT_STRAP1 */ |
| 125 | PAD_NC(GPP_H0, DN_20K), |
| 126 | /* H1 : GPPH1_BOOT_STRAP2 */ |
| 127 | PAD_NC(GPP_H1, DN_20K), |
| 128 | /* H2 : GPPH2_BOOT_STRAP3 */ |
| 129 | PAD_NC(GPP_H2, DN_20K), |
| 130 | /* H3 : SX_EXIT_HOLDOFF# ==> SD_PERST_L */ |
| 131 | PAD_CFG_GPO(GPP_H3, 1, DEEP), |
Wisley Chen | 982f64d | 2020-11-18 21:10:20 +0800 | [diff] [blame] | 132 | /* H10 : SRCCLKREQ4# ==> WLAN_PERST_L*/ |
| 133 | PAD_CFG_GPO(GPP_H10, 1, DEEP), |
| 134 | /* H11 : SRCCLKREQ5# ==> EMMC_CLKREQ_ODL*/ |
| 135 | PAD_CFG_NF(GPP_H11, NONE, DEEP, NF1), |
Wisley Chen | 1597a21 | 2020-10-31 00:51:06 +0800 | [diff] [blame] | 136 | /* H16 : DDPB_CTRLCLK ==> DDIB_HDMI_CTRLCLK */ |
| 137 | PAD_CFG_NF(GPP_H16, NONE, DEEP, NF1), |
| 138 | /* H17 : DDPB_CTRLDATA ==> DDPB_HDMI_CTRLDATA */ |
| 139 | PAD_CFG_NF(GPP_H17, NONE, DEEP, NF1), |
| 140 | /* H19 : TIME_SYNC0 ==> USER_PRES_FP_ODL */ |
| 141 | PAD_CFG_GPI(GPP_H19, NONE, DEEP), |
| 142 | |
| 143 | /* R0 : HDA_BCLK ==> I2S0_HP_SCLK */ |
| 144 | PAD_CFG_NF(GPP_R0, NONE, DEEP, NF2), |
| 145 | /* R1 : HDA_SYNC ==> I2S0_HP_SFRM */ |
| 146 | PAD_CFG_NF(GPP_R1, NONE, DEEP, NF2), |
| 147 | /* R2 : HDA_SDO ==> I2S0_PCH_TX_HP_RX_STRAP */ |
| 148 | PAD_CFG_NF(GPP_R2, DN_20K, DEEP, NF2), |
| 149 | /* R3 : HDA_SDIO ==> I2S0_PCH_RX_HP_TX */ |
| 150 | PAD_CFG_NF(GPP_R3, NONE, DEEP, NF2), |
| 151 | /* R5 : HDA_SDI1 ==> I2S1_PCH_RX_SPKR_TX */ |
| 152 | PAD_CFG_NF(GPP_R5, NONE, DEEP, NF2), |
| 153 | /* R6 : I2S1_TXD ==> I2S1_PCH_RX_SPKR_RX */ |
| 154 | PAD_CFG_NF(GPP_R6, NONE, DEEP, NF2), |
| 155 | /* R7 : I2S1_SFRM ==> I2S1_SPKR_SFRM */ |
| 156 | PAD_CFG_NF(GPP_R7, NONE, DEEP, NF2), |
| 157 | |
| 158 | /* S0 : SNDW0_CLK ==> SNDW0_HP_CLK */ |
| 159 | PAD_CFG_NF(GPP_S0, NONE, DEEP, NF1), |
| 160 | /* S1 : SNDW0_DATA ==> SNDW0_HP_DATA */ |
| 161 | PAD_CFG_NF(GPP_S1, NONE, DEEP, NF1), |
| 162 | /* S6 : SNDW3_CLK ==> DMIC_CLK0 */ |
| 163 | PAD_CFG_NF(GPP_S6, NONE, DEEP, NF2), |
| 164 | /* S7 : SNDW3_DATA ==> DMIC_DATA0 */ |
| 165 | PAD_CFG_NF(GPP_S7, NONE, DEEP, NF2), |
| 166 | |
| 167 | /* GPD9: SLP_WLAN# ==> SLP_WLAN_L */ |
| 168 | PAD_CFG_NF(GPD9, NONE, DEEP, NF1), |
| 169 | |
| 170 | }; |
| 171 | |
| 172 | /* Early pad configuration in bootblock */ |
| 173 | static const struct pad_config early_gpio_table[] = { |
Michael Niewöhner | cf2f700 | 2020-12-21 03:46:58 +0100 | [diff] [blame] | 174 | /* C8 : UART0 RX */ |
| 175 | PAD_CFG_NF(GPP_C8, NONE, DEEP, NF1), |
| 176 | /* C9 : UART0 TX */ |
| 177 | PAD_CFG_NF(GPP_C9, NONE, DEEP, NF1), |
| 178 | |
Wisley Chen | 1597a21 | 2020-10-31 00:51:06 +0800 | [diff] [blame] | 179 | /* A12 : SATAXPCIE1 ==> M2_SSD_PEDET */ |
| 180 | PAD_CFG_NF(GPP_A12, NONE, DEEP, NF1), |
Alex Levin | ecf06e5 | 2020-12-09 15:37:47 -0800 | [diff] [blame] | 181 | /* A13 : PMC_I2C_SCL ==> BT_DISABLE_L */ |
| 182 | /* assert reset on reboot */ |
| 183 | PAD_CFG_GPO(GPP_A13, 0, DEEP), |
Wisley Chen | 1597a21 | 2020-10-31 00:51:06 +0800 | [diff] [blame] | 184 | /* A17 : DDSP_HPDC ==> MEM_CH_SEL */ |
| 185 | PAD_CFG_GPI(GPP_A17, NONE, DEEP), |
Wisley Chen | 982f64d | 2020-11-18 21:10:20 +0800 | [diff] [blame] | 186 | /* B2 : VRALERT# ==> EN_PP3300_SSD */ |
Nick Vaccaro | 123fd50 | 2021-06-11 18:10:36 -0700 | [diff] [blame] | 187 | PAD_CFG_GPO(GPP_B2, 1, PLTRST), |
Wisley Chen | 982f64d | 2020-11-18 21:10:20 +0800 | [diff] [blame] | 188 | /* B4 : CPU_GP3==> EN_PP3300_EMMC */ |
| 189 | PAD_CFG_GPO(GPP_B4, 1, DEEP), |
| 190 | |
Wisley Chen | 1597a21 | 2020-10-31 00:51:06 +0800 | [diff] [blame] | 191 | |
| 192 | /* B11 : PMCALERT# ==> PCH_WP_OD */ |
| 193 | PAD_CFG_GPI_GPIO_DRIVER(GPP_B11, NONE, DEEP), |
| 194 | /* B15 : GSPI0_CS0# ==> PCH_GSPI0_H1_TPM_CS_L */ |
| 195 | PAD_CFG_NF(GPP_B15, NONE, DEEP, NF1), |
| 196 | /* B16 : GSPI0_CLK ==> PCH_GSPI0_H1_TPM_CLK */ |
| 197 | PAD_CFG_NF(GPP_B16, NONE, DEEP, NF1), |
| 198 | /* B17 : GSPI0_MISO ==> PCH_GSPIO_H1_TPM_MISO */ |
| 199 | PAD_CFG_NF(GPP_B17, NONE, DEEP, NF1), |
| 200 | /* B18 : GSPI0_MOSI ==> PCH_GSPI0_H1_TPM_MOSI_STRAP */ |
| 201 | PAD_CFG_NF(GPP_B18, DN_20K, DEEP, NF1), |
| 202 | |
| 203 | /* C0 : SMBCLK ==> EN_PP3300_WLAN */ |
| 204 | PAD_CFG_GPO(GPP_C0, 1, DEEP), |
| 205 | /* C21 : UART2_TXD ==> H1_PCH_INT_ODL */ |
| 206 | PAD_CFG_GPI_APIC(GPP_C21, NONE, PLTRST, LEVEL, INVERT), |
| 207 | /* C22 : UART2_RTS# ==> PCH_FPMCU_BOOT0 */ |
| 208 | PAD_CFG_GPO(GPP_C22, 0, DEEP), |
| 209 | |
| 210 | /* D16 : ISH_UART0_CTS# ==> EN_PP3300_SD */ |
| 211 | PAD_CFG_GPO(GPP_D16, 1, DEEP), |
| 212 | |
Wisley Chen | 982f64d | 2020-11-18 21:10:20 +0800 | [diff] [blame] | 213 | /* H10 : SRCCLKREQ5# ==> WLAN_PERST_L */ |
| 214 | PAD_CFG_GPO(GPP_H10, 1, DEEP), |
Wisley Chen | 1597a21 | 2020-10-31 00:51:06 +0800 | [diff] [blame] | 215 | }; |
| 216 | |
| 217 | const struct pad_config *variant_override_gpio_table(size_t *num) |
| 218 | { |
| 219 | *num = ARRAY_SIZE(override_gpio_table); |
| 220 | return override_gpio_table; |
| 221 | } |
| 222 | |
| 223 | const struct pad_config *variant_early_gpio_table(size_t *num) |
| 224 | { |
| 225 | *num = ARRAY_SIZE(early_gpio_table); |
| 226 | return early_gpio_table; |
| 227 | } |
Nick Vaccaro | 2f78ce0 | 2021-02-16 19:06:16 -0800 | [diff] [blame] | 228 | |
| 229 | /* GPIO settings before entering S5 */ |
| 230 | static const struct pad_config s5_sleep_gpio_table[] = { |
| 231 | PAD_CFG_GPO(GPP_C23, 0, DEEP), /* FPMCU_RST_ODL */ |
| 232 | PAD_CFG_GPO(GPP_A21, 0, DEEP), /* EN_FP_PWR */ |
| 233 | }; |
| 234 | |
| 235 | const struct pad_config *variant_sleep_gpio_table(u8 slp_typ, size_t *num) |
| 236 | { |
| 237 | if (slp_typ == ACPI_S5) { |
| 238 | *num = ARRAY_SIZE(s5_sleep_gpio_table); |
| 239 | return s5_sleep_gpio_table; |
| 240 | } |
| 241 | *num = 0; |
| 242 | return NULL; |
| 243 | } |
Matt DeVillier | 7ed6130 | 2022-12-21 08:38:17 -0600 | [diff] [blame^] | 244 | |
| 245 | /* GPIOs needed to be set in romstage. */ |
| 246 | static const struct pad_config romstage_gpio_table[] = { |
| 247 | /* Enable touchscreen, hold in reset */ |
| 248 | /* A8 : I2S2_SFRM ==> EN_PP3300_TOUCHSCREEN */ |
| 249 | PAD_CFG_GPO(GPP_A8, 1, DEEP), |
| 250 | /* C10 : UART0_RTS# ==> USI_RST_L */ |
| 251 | PAD_CFG_GPO(GPP_C10, 0, DEEP), |
| 252 | }; |
| 253 | |
| 254 | const struct pad_config *variant_romstage_gpio_table(size_t *num) |
| 255 | { |
| 256 | *num = ARRAY_SIZE(romstage_gpio_table); |
| 257 | return romstage_gpio_table; |
| 258 | } |