Eric Lai | 6bb5b9a | 2021-03-09 13:05:47 +0800 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
| 2 | |
| 3 | #include <baseboard/gpio.h> |
| 4 | #include <baseboard/variants.h> |
| 5 | #include <commonlib/helpers.h> |
Eric Lai | 0b18296 | 2021-03-09 15:33:01 +0800 | [diff] [blame] | 6 | #include <soc/gpio.h> |
Eric Lai | 6bb5b9a | 2021-03-09 13:05:47 +0800 | [diff] [blame] | 7 | |
| 8 | /* GPIO configuration in ramstage*/ |
| 9 | static const struct soc_amd_gpio base_gpio_table[] = { |
Eric Lai | 0b18296 | 2021-03-09 15:33:01 +0800 | [diff] [blame] | 10 | /* PWR_BTN_L */ |
| 11 | PAD_NF(GPIO_0, PWR_BTN_L, PULL_NONE), |
| 12 | /* SYS_RESET_L */ |
| 13 | PAD_NF(GPIO_1, SYS_RESET_L, PULL_NONE), |
| 14 | /* WAKE_L */ |
| 15 | PAD_NF(GPIO_2, WAKE_L, PULL_NONE), |
Eric Lai | 4f4e86e | 2021-03-09 15:58:23 +0800 | [diff] [blame] | 16 | /* GSC_SOC_INT_L */ |
| 17 | PAD_INT(GPIO_3, PULL_NONE, EDGE_LOW, STATUS_DELIVERY), |
Eric Lai | 0b18296 | 2021-03-09 15:33:01 +0800 | [diff] [blame] | 18 | /* AGPIO4 */ |
| 19 | PAD_NC(GPIO_4), |
| 20 | /* AGPIO5 */ |
| 21 | PAD_NC(GPIO_5), |
Eric Lai | 4f4e86e | 2021-03-09 15:58:23 +0800 | [diff] [blame] | 22 | /* EN_PP3300_WLAN */ |
| 23 | PAD_GPO(GPIO_6, LOW), |
Eric Lai | 0b18296 | 2021-03-09 15:33:01 +0800 | [diff] [blame] | 24 | /* AGPIO7 */ |
| 25 | PAD_NC(GPIO_7), |
Eric Lai | 4f4e86e | 2021-03-09 15:58:23 +0800 | [diff] [blame] | 26 | /* EN_PP3300_LAN */ |
| 27 | PAD_GPO(GPIO_8, LOW), |
| 28 | /* SD_EX_PRSNT_L */ |
| 29 | PAD_GPI(GPIO_9, PULL_NONE), |
Eric Lai | 0b18296 | 2021-03-09 15:33:01 +0800 | [diff] [blame] | 30 | /* S0A3 */ |
| 31 | PAD_NF(GPIO_10, S0A3, PULL_NONE), |
| 32 | /* AGPIO11 */ |
| 33 | PAD_NC(GPIO_11), |
Eric Lai | 4f4e86e | 2021-03-09 15:58:23 +0800 | [diff] [blame] | 34 | /* SLP_S3_GATED */ |
| 35 | PAD_GPO(GPIO_12, LOW), |
Eric Lai | 0b18296 | 2021-03-09 15:33:01 +0800 | [diff] [blame] | 36 | /* GPIO_13 - GPIO_15: Not available */ |
| 37 | /* USB_FAULT_ODL */ |
| 38 | PAD_NF(GPIO_16, USB_OC0_L, PULL_NONE), |
| 39 | /* AGPIO17 */ |
| 40 | PAD_NC(GPIO_17), |
Eric Lai | 4f4e86e | 2021-03-09 15:58:23 +0800 | [diff] [blame] | 41 | /* LAN_AUX_RESET_L */ |
| 42 | PAD_GPO(GPIO_18, LOW), |
Eric Lai | 0b18296 | 2021-03-09 15:33:01 +0800 | [diff] [blame] | 43 | /* I2C3_SCL */ |
| 44 | PAD_NF(GPIO_19, I2C3_SCL, PULL_NONE), |
| 45 | /* I2C3_SDA */ |
| 46 | PAD_NF(GPIO_20, I2C3_SDA, PULL_NONE), |
| 47 | /* AGPIO21 */ |
| 48 | PAD_NC(GPIO_21), |
Eric Lai | 4f4e86e | 2021-03-09 15:58:23 +0800 | [diff] [blame] | 49 | /* EC_SOC_WAKE_ODL */ |
| 50 | PAD_WAKE(GPIO_22, PULL_NONE, EDGE_LOW, S0i3), |
Eric Lai | 0b18296 | 2021-03-09 15:33:01 +0800 | [diff] [blame] | 51 | /* AC_PRES */ |
| 52 | PAD_NF(GPIO_23, AC_PRES, PULL_UP), |
Eric Lai | 4f4e86e | 2021-03-09 15:58:23 +0800 | [diff] [blame] | 53 | /* HUB_RST_L */ |
| 54 | PAD_GPO(GPIO_24, LOW), |
Eric Lai | 0b18296 | 2021-03-09 15:33:01 +0800 | [diff] [blame] | 55 | /* GPIO_25: Not available */ |
| 56 | /* PCIE_RST0_L */ |
| 57 | PAD_NF(GPIO_26, PCIE_RST_L, PULL_NONE), |
| 58 | /* PCIE_RST1_L */ |
| 59 | PAD_NF(GPIO_27, PCIE_RST1_L, PULL_NONE), |
| 60 | /* GPIO_28: Not available */ |
Eric Lai | 4f4e86e | 2021-03-09 15:58:23 +0800 | [diff] [blame] | 61 | /* WLAN_AUX_RESET */ |
| 62 | PAD_GPO(GPIO_29, HIGH), |
Eric Lai | 0b18296 | 2021-03-09 15:33:01 +0800 | [diff] [blame] | 63 | /* ESPI_CS_L */ |
| 64 | PAD_NF(GPIO_30, ESPI_CS_L, PULL_NONE), |
| 65 | /* AGPIO31 */ |
| 66 | PAD_NC(GPIO_31), |
| 67 | /* AGPIO32 */ |
| 68 | PAD_NC(GPIO_32), |
| 69 | /* GPIO_33 - GPIO_39: Not available */ |
Eric Lai | 4f4e86e | 2021-03-09 15:58:23 +0800 | [diff] [blame] | 70 | /* SSD_AUX_RESET_L */ |
| 71 | PAD_GPO(GPIO_40, LOW), |
Eric Lai | 0b18296 | 2021-03-09 15:33:01 +0800 | [diff] [blame] | 72 | /* GPIO_41: Not available */ |
| 73 | /* EGPIO42 */ |
| 74 | PAD_NC(GPIO_42), |
| 75 | /* GPIO_43 - GPIO_66: Not available */ |
Eric Lai | 4f4e86e | 2021-03-09 15:58:23 +0800 | [diff] [blame] | 76 | /* SOC_BIOS_WP_L */ |
| 77 | PAD_GPI(GPIO_67, PULL_NONE), |
Eric Lai | 0b18296 | 2021-03-09 15:33:01 +0800 | [diff] [blame] | 78 | /* AGPIO68 */ |
| 79 | PAD_NC(GPIO_68), |
| 80 | /* AGPIO69 */ |
| 81 | PAD_NC(GPIO_69), |
Eric Lai | 4f4e86e | 2021-03-09 15:58:23 +0800 | [diff] [blame] | 82 | /* SD_AUX_RESET_L */ |
| 83 | PAD_GPO(GPIO_70, LOW), |
Eric Lai | 0b18296 | 2021-03-09 15:33:01 +0800 | [diff] [blame] | 84 | /* GPIO_71 - GPIO_73: Not available */ |
| 85 | /* EGPIO74 */ |
| 86 | PAD_NC(GPIO_74), |
| 87 | /* EGPIO75 */ |
| 88 | PAD_NC(GPIO_75), |
| 89 | /* EGPIO76 */ |
| 90 | PAD_NC(GPIO_76), |
| 91 | /* GPIO_77 - GPIO_83: Not available */ |
Eric Lai | 4f4e86e | 2021-03-09 15:58:23 +0800 | [diff] [blame] | 92 | /* EC_SOC_INT_ODL */ |
| 93 | PAD_GPI(GPIO_84, PULL_NONE), |
Eric Lai | 0b18296 | 2021-03-09 15:33:01 +0800 | [diff] [blame] | 94 | /* AGPIO85 */ |
| 95 | PAD_NC(GPIO_85), |
| 96 | /* SPI_CLK2 */ |
| 97 | PAD_NF(GPIO_86, SPI_CLK, PULL_NONE), |
| 98 | /* AGPIO87 */ |
| 99 | PAD_NC(GPIO_87), |
| 100 | /* AGPIO88 */ |
| 101 | PAD_NC(GPIO_88), |
| 102 | /* AGPIO89 */ |
| 103 | PAD_NC(GPIO_89), |
Eric Lai | 4f4e86e | 2021-03-09 15:58:23 +0800 | [diff] [blame] | 104 | /* HP_INT_ODL */ |
| 105 | PAD_GPI(GPIO_90, PULL_NONE), |
| 106 | /* PWM_3V3_BUZZER */ |
| 107 | PAD_GPO(GPIO_91, LOW), |
Eric Lai | 0b18296 | 2021-03-09 15:33:01 +0800 | [diff] [blame] | 108 | /* CLK_REQ0_L */ |
| 109 | PAD_NF(GPIO_92, CLK_REQ0_L, PULL_NONE), |
| 110 | /* GPIO_93 - GPIO_103: Not available */ |
Eric Lai | 73b9fa69 | 2021-03-15 15:54:54 +0800 | [diff] [blame] | 111 | /* GPIO_104 - GPIO_108: eSPI configured in early stage */ |
Eric Lai | 0b18296 | 2021-03-09 15:33:01 +0800 | [diff] [blame] | 112 | /* EGPIO109 */ |
| 113 | PAD_NC(GPIO_109), |
| 114 | /* GPIO_110 - GPIO_112: Not available */ |
| 115 | /* I2C2_SCL */ |
| 116 | PAD_NF(GPIO_113, I2C2_SCL, PULL_NONE), |
| 117 | /* I2C2_SDA */ |
| 118 | PAD_NF(GPIO_114, I2C2_SDA, PULL_NONE), |
| 119 | /* CLK_REQ1_L */ |
| 120 | PAD_NF(GPIO_115, CLK_REQ1_L, PULL_NONE), |
| 121 | /* CLK_REQ2_L */ |
| 122 | PAD_NF(GPIO_116, CLK_REQ2_L, PULL_NONE), |
| 123 | /* GPIO_117 - GPIO_119: Not available */ |
| 124 | /* EGPIO120 */ |
| 125 | PAD_NC(GPIO_120), |
| 126 | /* EGPIO121 */ |
| 127 | PAD_NC(GPIO_121), |
| 128 | /* GPIO_122 - GPIO_128: Not available */ |
| 129 | /* AGPIO129 */ |
| 130 | PAD_NC(GPIO_129), |
Eric Lai | 4f4e86e | 2021-03-09 15:58:23 +0800 | [diff] [blame] | 131 | /* WLAN_DISABLE */ |
| 132 | PAD_GPO(GPIO_130, HIGH), |
Eric Lai | 0b18296 | 2021-03-09 15:33:01 +0800 | [diff] [blame] | 133 | /* CLK_REQ3_L */ |
| 134 | PAD_NF(GPIO_131, CLK_REQ3_L, PULL_NONE), |
Eric Lai | 4f4e86e | 2021-03-09 15:58:23 +0800 | [diff] [blame] | 135 | /* BT_DISABLE */ |
| 136 | PAD_GPO(GPIO_132, HIGH), |
Eric Lai | 0b18296 | 2021-03-09 15:33:01 +0800 | [diff] [blame] | 137 | /* EGPIO140 */ |
| 138 | PAD_NC(GPIO_140), |
| 139 | /* UART0_RXD */ |
| 140 | PAD_NF(GPIO_141, UART0_RXD, PULL_NONE), |
| 141 | /* EGPIO142 */ |
| 142 | PAD_NC(GPIO_142), |
| 143 | /* UART0_TXD */ |
| 144 | PAD_NF(GPIO_143, UART0_TXD, PULL_NONE), |
| 145 | /* AGPIO144 */ |
| 146 | PAD_NC(GPIO_144), |
| 147 | /* I2C0_SCL */ |
| 148 | PAD_NF(GPIO_145, I2C0_SCL, PULL_NONE), |
| 149 | /* I2C0_SDA */ |
| 150 | PAD_NF(GPIO_146, I2C0_SDA, PULL_NONE), |
| 151 | /* I2C1_SCL */ |
| 152 | PAD_NF(GPIO_147, I2C1_SCL, PULL_NONE), |
| 153 | /* I2C1_SDA */ |
| 154 | PAD_NF(GPIO_148, I2C1_SDA, PULL_NONE), |
Eric Lai | 6bb5b9a | 2021-03-09 13:05:47 +0800 | [diff] [blame] | 155 | }; |
| 156 | |
Eric Lai | d807c80 | 2021-03-15 15:52:03 +0800 | [diff] [blame] | 157 | /* Early GPIO configuration */ |
| 158 | static const struct soc_amd_gpio early_gpio_table[] = { |
Eric Lai | 73b9fa69 | 2021-03-15 15:54:54 +0800 | [diff] [blame] | 159 | /* ESPI1_DATA0 */ |
| 160 | PAD_NF(GPIO_104, SPI2_DO_ESPI2_D0, PULL_NONE), |
| 161 | /* ESPI1_DATA1 */ |
| 162 | PAD_NF(GPIO_105, SPI2_DI_ESPI2_D1, PULL_NONE), |
| 163 | /* ESPI1_DATA2 */ |
| 164 | PAD_NF(GPIO_106, EMMC_SPI2_WP_L_ESPI2_D2, PULL_NONE), |
| 165 | /* ESPI1_DATA3 */ |
| 166 | PAD_NF(GPIO_107, SPI2_HOLD_L_ESPI2_D3, PULL_NONE), |
| 167 | /* ESPI_ALERT_L */ |
| 168 | PAD_NF(GPIO_108, ESPI_ALERT_D1, PULL_NONE), |
Eric Lai | 6bb5b9a | 2021-03-09 13:05:47 +0800 | [diff] [blame] | 169 | }; |
| 170 | |
Eric Lai | 1954c1f | 2021-03-18 16:30:09 +0800 | [diff] [blame^] | 171 | /* GPIO configuration for sleep */ |
| 172 | static const struct soc_amd_gpio sleep_gpio_table[] = { |
| 173 | /* TODO: Fill sleep gpio configuration */ |
| 174 | }; |
| 175 | |
Eric Lai | 6bb5b9a | 2021-03-09 13:05:47 +0800 | [diff] [blame] | 176 | const struct soc_amd_gpio *__weak variant_base_gpio_table(size_t *size) |
| 177 | { |
| 178 | *size = ARRAY_SIZE(base_gpio_table); |
| 179 | return base_gpio_table; |
| 180 | } |
| 181 | const struct soc_amd_gpio *__weak variant_override_gpio_table(size_t *size) |
| 182 | { |
| 183 | *size = 0; |
| 184 | return NULL; |
| 185 | } |
Eric Lai | d807c80 | 2021-03-15 15:52:03 +0800 | [diff] [blame] | 186 | const struct soc_amd_gpio *__weak variant_early_gpio_table(size_t *size) |
Eric Lai | 6bb5b9a | 2021-03-09 13:05:47 +0800 | [diff] [blame] | 187 | { |
Eric Lai | d807c80 | 2021-03-15 15:52:03 +0800 | [diff] [blame] | 188 | *size = ARRAY_SIZE(early_gpio_table); |
| 189 | return early_gpio_table; |
Eric Lai | 6bb5b9a | 2021-03-09 13:05:47 +0800 | [diff] [blame] | 190 | } |
Eric Lai | 1954c1f | 2021-03-18 16:30:09 +0800 | [diff] [blame^] | 191 | const __weak struct soc_amd_gpio *variant_sleep_gpio_table(size_t *size) |
| 192 | { |
| 193 | *size = ARRAY_SIZE(sleep_gpio_table); |
| 194 | return sleep_gpio_table; |
| 195 | } |