Raul E Rangel | b3c4132 | 2020-05-20 14:07:41 -0600 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
| 2 | |
| 3 | #include <baseboard/variants.h> |
Furquan Shaikh | 8302585 | 2020-06-22 10:45:12 -0700 | [diff] [blame] | 4 | #include <delay.h> |
| 5 | #include <gpio.h> |
Raul E Rangel | b3c4132 | 2020-05-20 14:07:41 -0600 | [diff] [blame] | 6 | #include <soc/gpio.h> |
| 7 | #include <soc/smi.h> |
| 8 | #include <stdlib.h> |
Raul E Rangel | b3c4132 | 2020-05-20 14:07:41 -0600 | [diff] [blame] | 9 | #include <variant/gpio.h> |
| 10 | |
Raul E Rangel | b3c4132 | 2020-05-20 14:07:41 -0600 | [diff] [blame] | 11 | static const struct soc_amd_gpio gpio_set_stage_ram[] = { |
Raul E Rangel | b3c4132 | 2020-05-20 14:07:41 -0600 | [diff] [blame] | 12 | /* PWR_BTN_L */ |
Furquan Shaikh | dce0ce9 | 2020-07-17 11:16:50 -0700 | [diff] [blame] | 13 | PAD_NF(GPIO_0, PWR_BTN_L, PULL_NONE), |
Raul E Rangel | b3c4132 | 2020-05-20 14:07:41 -0600 | [diff] [blame] | 14 | /* SYS_RESET_L */ |
| 15 | PAD_NF(GPIO_1, SYS_RESET_L, PULL_NONE), |
Rob Barnes | d1095c7 | 2020-09-25 14:16:46 -0600 | [diff] [blame] | 16 | /* WIFI_PCIE_WAKE_ODL */ |
Felix Held | f8e440c | 2021-03-24 00:17:35 +0100 | [diff] [blame^] | 17 | PAD_NF_SCI(GPIO_2, WAKE_L, PULL_NONE, EDGE_LOW), |
Furquan Shaikh | fd4fbe8 | 2020-07-21 22:29:49 -0700 | [diff] [blame] | 18 | /* H1_FCH_INT_ODL */ |
| 19 | PAD_INT(GPIO_3, PULL_NONE, EDGE_LOW, STATUS_DELIVERY), |
Raul E Rangel | b3c4132 | 2020-05-20 14:07:41 -0600 | [diff] [blame] | 20 | /* PEN_DETECT_ODL */ |
Furquan Shaikh | ffbf5d9 | 2020-06-30 14:07:46 -0700 | [diff] [blame] | 21 | PAD_WAKE(GPIO_4, PULL_NONE, EDGE_HIGH, S3), |
Raul E Rangel | b3c4132 | 2020-05-20 14:07:41 -0600 | [diff] [blame] | 22 | /* PEN_POWER_EN - Enabled*/ |
| 23 | PAD_GPO(GPIO_5, HIGH), |
Furquan Shaikh | 462f3ed | 2020-06-18 01:44:21 -0700 | [diff] [blame] | 24 | /* EN_PWR_TOUCHPAD */ |
| 25 | PAD_GPO(GPIO_6, HIGH), |
Raul E Rangel | b3c4132 | 2020-05-20 14:07:41 -0600 | [diff] [blame] | 26 | /* I2S_SDIN */ |
| 27 | PAD_NF(GPIO_7, ACP_I2S_SDIN, PULL_NONE), |
| 28 | /* I2S_LRCLK - Bit banged in depthcharge */ |
| 29 | PAD_NF(GPIO_8, ACP_I2S_LRCLK, PULL_NONE), |
| 30 | /* TOUCHPAD_INT_ODL */ |
Furquan Shaikh | ffbf5d9 | 2020-06-30 14:07:46 -0700 | [diff] [blame] | 31 | PAD_SCI(GPIO_9, PULL_NONE, EDGE_LOW), |
Martin Roth | 6a62cc8 | 2020-12-02 16:37:58 -0700 | [diff] [blame] | 32 | /* S0iX SLP - goes to EC */ |
| 33 | PAD_GPO(GPIO_10, HIGH), |
Raul E Rangel | b3c4132 | 2020-05-20 14:07:41 -0600 | [diff] [blame] | 34 | /* EC_IN_RW_OD */ |
Furquan Shaikh | dce0ce9 | 2020-07-17 11:16:50 -0700 | [diff] [blame] | 35 | PAD_GPI(GPIO_11, PULL_NONE), |
Raul E Rangel | b3c4132 | 2020-05-20 14:07:41 -0600 | [diff] [blame] | 36 | /* USI_INT_ODL */ |
Furquan Shaikh | dce0ce9 | 2020-07-17 11:16:50 -0700 | [diff] [blame] | 37 | PAD_GPI(GPIO_12, PULL_NONE), |
Furquan Shaikh | fd4fbe8 | 2020-07-21 22:29:49 -0700 | [diff] [blame] | 38 | /* GPIO_13 - GPIO_15: Not available */ |
Furquan Shaikh | dce0ce9 | 2020-07-17 11:16:50 -0700 | [diff] [blame] | 39 | /* USB_OC0_L - USB C0/A0 */ |
| 40 | PAD_NF(GPIO_16, USB_OC0_L, PULL_NONE), |
Raul E Rangel | b3c4132 | 2020-05-20 14:07:41 -0600 | [diff] [blame] | 41 | /* USB_OC1_L - USB C1 */ |
Furquan Shaikh | dce0ce9 | 2020-07-17 11:16:50 -0700 | [diff] [blame] | 42 | PAD_NF(GPIO_17, USB_OC1_L, PULL_NONE), |
Raul E Rangel | b3c4132 | 2020-05-20 14:07:41 -0600 | [diff] [blame] | 43 | /* WIFI_DISABLE */ |
| 44 | PAD_GPO(GPIO_18, LOW), |
Furquan Shaikh | fd4fbe8 | 2020-07-21 22:29:49 -0700 | [diff] [blame] | 45 | /* I2C3_SCL - H1 */ |
| 46 | PAD_NF(GPIO_19, I2C3_SCL, PULL_NONE), |
| 47 | /* I2C3_SDA - H1 */ |
| 48 | PAD_NF(GPIO_20, I2C3_SDA, PULL_NONE), |
Raul E Rangel | b3c4132 | 2020-05-20 14:07:41 -0600 | [diff] [blame] | 49 | /* EMMC_CMD */ |
Furquan Shaikh | dce0ce9 | 2020-07-17 11:16:50 -0700 | [diff] [blame] | 50 | PAD_NF(GPIO_21, EMMC_CMD, PULL_NONE), |
Raul E Rangel | b3c4132 | 2020-05-20 14:07:41 -0600 | [diff] [blame] | 51 | /* EC_FCH_SCI_ODL */ |
Furquan Shaikh | dce0ce9 | 2020-07-17 11:16:50 -0700 | [diff] [blame] | 52 | PAD_SCI(GPIO_22, PULL_NONE, EDGE_LOW), |
Raul E Rangel | b3c4132 | 2020-05-20 14:07:41 -0600 | [diff] [blame] | 53 | /* AC_PRES */ |
| 54 | PAD_NF(GPIO_23, AC_PRES, PULL_UP), |
Furquan Shaikh | 489ffef | 2020-06-30 14:08:27 -0700 | [diff] [blame] | 55 | /* EC_FCH_WAKE_L */ |
| 56 | PAD_SCI(GPIO_24, PULL_NONE, EDGE_LOW), |
Furquan Shaikh | fd4fbe8 | 2020-07-21 22:29:49 -0700 | [diff] [blame] | 57 | /* GPIO_25: Not available */ |
| 58 | /* PCIE_RST0_L - Fixed timings */ |
| 59 | PAD_NF(GPIO_26, PCIE_RST_L, PULL_NONE), |
| 60 | /* GPIO_27: Configured in bootblock. */ |
| 61 | /* GPIO_28: Not available */ |
| 62 | /* GPIO_29: Handled in bootblock for wifi power/reset control. */ |
| 63 | /* FCH_ESPI_EC_CS_L */ |
| 64 | PAD_NF(GPIO_30, ESPI_CS_L, PULL_NONE), |
Furquan Shaikh | dce0ce9 | 2020-07-17 11:16:50 -0700 | [diff] [blame] | 65 | /* EC_AP_INT_ODL (Sensor Framesync) */ |
| 66 | PAD_GPI(GPIO_31, PULL_NONE), |
Furquan Shaikh | 5474f8e | 2020-08-05 14:54:39 -0700 | [diff] [blame] | 67 | /* EN_PWR_TOUCHSCREEN */ |
| 68 | PAD_GPO(GPIO_32, LOW), |
Furquan Shaikh | fd4fbe8 | 2020-07-21 22:29:49 -0700 | [diff] [blame] | 69 | /* GPIO_33 - GPIO_39: Not available */ |
| 70 | /* NVME_AUX_RESET_L */ |
| 71 | PAD_GPO(GPIO_40, HIGH), |
| 72 | /* GPIO_41: Not available */ |
| 73 | /* GPIO_42: Handled in bootblock for wifi power/reset control. */ |
| 74 | /* GPIO_43 - GPIO_66: Not available */ |
Furquan Shaikh | 462f3ed | 2020-06-18 01:44:21 -0700 | [diff] [blame] | 75 | /* DMIC_SEL */ |
Raul E Rangel | b3c4132 | 2020-05-20 14:07:41 -0600 | [diff] [blame] | 76 | /* |
Furquan Shaikh | 462f3ed | 2020-06-18 01:44:21 -0700 | [diff] [blame] | 77 | * Make sure Ext ROM Sharing is disabled before using this GPIO. Otherwise SPI flash |
| 78 | * access will be very slow. |
Raul E Rangel | b3c4132 | 2020-05-20 14:07:41 -0600 | [diff] [blame] | 79 | */ |
Furquan Shaikh | 462f3ed | 2020-06-18 01:44:21 -0700 | [diff] [blame] | 80 | PAD_GPO(GPIO_67, LOW), // Select Camera 1 Dmic |
Kevin Chiu | 768f59a | 2020-09-26 20:34:28 +0800 | [diff] [blame] | 81 | /* EMMC_RESET_L */ |
| 82 | PAD_GPO(GPIO_68, HIGH), |
Furquan Shaikh | fd4fbe8 | 2020-07-21 22:29:49 -0700 | [diff] [blame] | 83 | /* RAM ID 3 */ |
Raul E Rangel | b3c4132 | 2020-05-20 14:07:41 -0600 | [diff] [blame] | 84 | PAD_GPI(GPIO_69, PULL_NONE), |
| 85 | /* EMMC_CLK */ |
| 86 | PAD_NF(GPIO_70, EMMC_CLK, PULL_NONE), |
Furquan Shaikh | fd4fbe8 | 2020-07-21 22:29:49 -0700 | [diff] [blame] | 87 | /* GPIO_71 - GPIO_73: Not available */ |
Raul E Rangel | b3c4132 | 2020-05-20 14:07:41 -0600 | [diff] [blame] | 88 | /* EMMC_DATA4 */ |
| 89 | PAD_NF(GPIO_74, EMMC_DATA4, PULL_NONE), |
| 90 | /* EMMC_DATA6 */ |
| 91 | PAD_NF(GPIO_75, EMMC_DATA6, PULL_NONE), |
| 92 | /* EN_PWR_CAMERA */ |
| 93 | PAD_GPO(GPIO_76, HIGH), |
Furquan Shaikh | fd4fbe8 | 2020-07-21 22:29:49 -0700 | [diff] [blame] | 94 | /* GPIO_77 - GPIO_83: Not available */ |
Josie Nordrum | cc72e15 | 2020-08-03 11:39:41 -0600 | [diff] [blame] | 95 | /* HP_INT_ODL */ |
| 96 | PAD_GPI(GPIO_84, PULL_NONE), |
Chris Wang | ad481c4 | 2020-12-01 17:14:17 +0800 | [diff] [blame] | 97 | /* APU_EDP_BL_DISABLE */ |
| 98 | PAD_GPO(GPIO_85, LOW), |
Martin Roth | 11c765c | 2020-11-17 09:55:58 -0700 | [diff] [blame] | 99 | /* RAM ID 2 - Keep High */ |
| 100 | PAD_GPO(GPIO_86, HIGH), |
Raul E Rangel | b3c4132 | 2020-05-20 14:07:41 -0600 | [diff] [blame] | 101 | /* EMMC_DATA7 */ |
| 102 | PAD_NF(GPIO_87, EMMC_DATA7, PULL_NONE), |
| 103 | /* EMMC_DATA5 */ |
| 104 | PAD_NF(GPIO_88, EMMC_DATA5, PULL_NONE), |
Furquan Shaikh | 79dba4a | 2020-08-04 17:16:33 -0700 | [diff] [blame] | 105 | /* GPIO_89 - unused */ |
| 106 | PAD_NC(GPIO_89), |
Raul E Rangel | b3c4132 | 2020-05-20 14:07:41 -0600 | [diff] [blame] | 107 | /* RAM ID 1 */ |
| 108 | PAD_GPI(GPIO_90, PULL_NONE), |
Furquan Shaikh | 7f892b5 | 2020-07-21 22:54:16 -0700 | [diff] [blame] | 109 | /* EN_SPKR */ |
Raul E Rangel | b3c4132 | 2020-05-20 14:07:41 -0600 | [diff] [blame] | 110 | PAD_GPO(GPIO_91, LOW), |
Furquan Shaikh | fd4fbe8 | 2020-07-21 22:29:49 -0700 | [diff] [blame] | 111 | /* CLK_REQ0_L - WIFI */ |
| 112 | PAD_NF(GPIO_92, CLK_REQ0_L, PULL_NONE), |
| 113 | /* GPIO_93 - GPIO_103: Not available */ |
Raul E Rangel | b3c4132 | 2020-05-20 14:07:41 -0600 | [diff] [blame] | 114 | /* EMMC_DATA0 */ |
| 115 | PAD_NF(GPIO_104, EMMC_DATA0, PULL_NONE), |
| 116 | /* EMMC_DATA1 */ |
| 117 | PAD_NF(GPIO_105, EMMC_DATA1, PULL_NONE), |
| 118 | /* EMMC_DATA2 */ |
| 119 | PAD_NF(GPIO_106, EMMC_DATA2, PULL_NONE), |
| 120 | /* EMMC_DATA3 */ |
| 121 | PAD_NF(GPIO_107, EMMC_DATA3, PULL_NONE), |
Furquan Shaikh | fd4fbe8 | 2020-07-21 22:29:49 -0700 | [diff] [blame] | 122 | /* ESPI_ALERT_L */ |
| 123 | PAD_NF(GPIO_108, ESPI_ALERT_L, PULL_UP), |
Raul E Rangel | b3c4132 | 2020-05-20 14:07:41 -0600 | [diff] [blame] | 124 | /* EMMC_DS */ |
| 125 | PAD_NF(GPIO_109, EMMC_DS, PULL_NONE), |
Furquan Shaikh | fd4fbe8 | 2020-07-21 22:29:49 -0700 | [diff] [blame] | 126 | /* GPIO_110 - GPIO112: Not available */ |
Raul E Rangel | b3c4132 | 2020-05-20 14:07:41 -0600 | [diff] [blame] | 127 | /* I2C2_SCL - USI/Touchpad */ |
Furquan Shaikh | dce0ce9 | 2020-07-17 11:16:50 -0700 | [diff] [blame] | 128 | PAD_NF(GPIO_113, I2C2_SCL, PULL_NONE), |
Raul E Rangel | b3c4132 | 2020-05-20 14:07:41 -0600 | [diff] [blame] | 129 | /* I2C2_SDA - USI/Touchpad */ |
Furquan Shaikh | dce0ce9 | 2020-07-17 11:16:50 -0700 | [diff] [blame] | 130 | PAD_NF(GPIO_114, I2C2_SDA, PULL_NONE), |
Furquan Shaikh | fd4fbe8 | 2020-07-21 22:29:49 -0700 | [diff] [blame] | 131 | /* CLK_REQ1_L - SD Card */ |
| 132 | PAD_NF(GPIO_115, CLK_REQ1_L, PULL_NONE), |
| 133 | /* CLK_REQ2_L - NVMe */ |
| 134 | PAD_NF(GPIO_116, CLK_REQ2_L, PULL_NONE), |
| 135 | /* GPIO_117 - GPIO_128: Not available */ |
Raul E Rangel | b3c4132 | 2020-05-20 14:07:41 -0600 | [diff] [blame] | 136 | /* KBRST_L */ |
Furquan Shaikh | dce0ce9 | 2020-07-17 11:16:50 -0700 | [diff] [blame] | 137 | PAD_NF(GPIO_129, KBRST_L, PULL_NONE), |
Furquan Shaikh | fd4fbe8 | 2020-07-21 22:29:49 -0700 | [diff] [blame] | 138 | /* GPIO_130 - GPIO_131: Not available */ |
Raul E Rangel | b3c4132 | 2020-05-20 14:07:41 -0600 | [diff] [blame] | 139 | /* RAM ID 0 */ |
| 140 | PAD_GPI(GPIO_132, PULL_NONE), |
Furquan Shaikh | fd4fbe8 | 2020-07-21 22:29:49 -0700 | [diff] [blame] | 141 | /* GPIO_133 - GPIO_134: Not available */ |
Raul E Rangel | b3c4132 | 2020-05-20 14:07:41 -0600 | [diff] [blame] | 142 | /* DEV_BEEP_CODEC_IN (Dev beep Data out) */ |
| 143 | PAD_GPI(GPIO_135, PULL_NONE), |
Furquan Shaikh | fd4fbe8 | 2020-07-21 22:29:49 -0700 | [diff] [blame] | 144 | /* UART0_RXD - DEBUG */ |
| 145 | PAD_NF(GPIO_136, UART0_RXD, PULL_NONE), |
Furquan Shaikh | ca36acf | 2020-07-03 10:32:41 -0700 | [diff] [blame] | 146 | /* BIOS_FLASH_WP_ODL */ |
| 147 | PAD_GPI(GPIO_137, PULL_NONE), |
Furquan Shaikh | fd4fbe8 | 2020-07-21 22:29:49 -0700 | [diff] [blame] | 148 | /* UART0_TXD - DEBUG */ |
| 149 | PAD_NF(GPIO_138, UART0_TXD, PULL_NONE), |
Raul E Rangel | b3c4132 | 2020-05-20 14:07:41 -0600 | [diff] [blame] | 150 | /* DEV_BEEP_BCLK */ |
| 151 | PAD_GPI(GPIO_139, PULL_NONE), |
Furquan Shaikh | cc6c41f | 2020-08-04 20:16:55 -0700 | [diff] [blame] | 152 | /* USI_RESET_L */ |
| 153 | PAD_GPO(GPIO_140, LOW), |
Raul E Rangel | b3c4132 | 2020-05-20 14:07:41 -0600 | [diff] [blame] | 154 | /* USB_HUB_RST_L */ |
| 155 | PAD_GPO(GPIO_141, HIGH), |
Furquan Shaikh | fd4fbe8 | 2020-07-21 22:29:49 -0700 | [diff] [blame] | 156 | /* SD_AUX_RESET_L */ |
| 157 | PAD_GPO(GPIO_142, HIGH), |
Raul E Rangel | b3c4132 | 2020-05-20 14:07:41 -0600 | [diff] [blame] | 158 | /* BT_DISABLE */ |
| 159 | PAD_GPO(GPIO_143, LOW), |
Furquan Shaikh | dcee4b6 | 2020-07-22 00:47:40 -0700 | [diff] [blame] | 160 | /* USI_REPORT_EN */ |
| 161 | PAD_GPO(GPIO_144, LOW), |
Raul E Rangel | b3c4132 | 2020-05-20 14:07:41 -0600 | [diff] [blame] | 162 | }; |
| 163 | |
| 164 | const __weak |
Raul E Rangel | b3c4132 | 2020-05-20 14:07:41 -0600 | [diff] [blame] | 165 | struct soc_amd_gpio *variant_base_gpio_table(size_t *size) |
| 166 | { |
| 167 | *size = ARRAY_SIZE(gpio_set_stage_ram); |
| 168 | return gpio_set_stage_ram; |
| 169 | } |
| 170 | |
Furquan Shaikh | 70b7fa1 | 2020-06-29 11:56:04 -0700 | [diff] [blame] | 171 | static void wifi_power_reset_configure_active_low_power(void) |
Furquan Shaikh | 8302585 | 2020-06-22 10:45:12 -0700 | [diff] [blame] | 172 | { |
| 173 | /* |
| 174 | * Configure WiFi GPIOs such that: |
| 175 | * - WIFI_AUX_RESET is configured first to assert PERST# to WiFi device. |
Furquan Shaikh | 70b7fa1 | 2020-06-29 11:56:04 -0700 | [diff] [blame] | 176 | * - Enable power to WiFi using EN_PWR_WIFI_L. |
Furquan Shaikh | 8302585 | 2020-06-22 10:45:12 -0700 | [diff] [blame] | 177 | * - Wait for 50ms after power to WiFi is enabled. |
Furquan Shaikh | 70b7fa1 | 2020-06-29 11:56:04 -0700 | [diff] [blame] | 178 | * - Deassert WIFI_AUX_RESET. |
Furquan Shaikh | 8302585 | 2020-06-22 10:45:12 -0700 | [diff] [blame] | 179 | */ |
| 180 | static const struct soc_amd_gpio v3_wifi_table[] = { |
| 181 | /* WIFI_AUX_RESET */ |
| 182 | PAD_GPO(GPIO_29, HIGH), |
Furquan Shaikh | 70b7fa1 | 2020-06-29 11:56:04 -0700 | [diff] [blame] | 183 | /* EN_PWR_WIFI_L */ |
| 184 | PAD_GPO(GPIO_42, LOW), |
Furquan Shaikh | 8302585 | 2020-06-22 10:45:12 -0700 | [diff] [blame] | 185 | }; |
| 186 | program_gpios(v3_wifi_table, ARRAY_SIZE(v3_wifi_table)); |
| 187 | |
| 188 | mdelay(50); |
| 189 | gpio_set(GPIO_29, 0); |
| 190 | } |
| 191 | |
Furquan Shaikh | 70b7fa1 | 2020-06-29 11:56:04 -0700 | [diff] [blame] | 192 | static void wifi_power_reset_configure_active_high_power(void) |
| 193 | { |
| 194 | /* |
| 195 | * When GPIO_42 is configured as active high for enabling WiFi power, WIFI_AUX_RESET |
| 196 | * gets pulled high because of external PU to PP3300_WIFI. Thus, EN_PWR_WIFI needs to be |
| 197 | * set low before driving it high to trigger a WiFi power cycle to meet PCIe |
| 198 | * requirements. Thus, configure GPIOs such that: |
| 199 | * - WIFI_AUX_RESET is configured first to assert PERST# to WiFi device |
| 200 | * - Disable power to WiFi. |
| 201 | * - Wait 10ms for WiFi power to go low. |
| 202 | * - Enable power to WiFi using EN_PWR_WIFI. |
| 203 | * - Deassert WIFI_AUX_RESET. |
| 204 | */ |
| 205 | static const struct soc_amd_gpio v3_wifi_table[] = { |
| 206 | /* WIFI_AUX_RESET */ |
| 207 | PAD_GPO(GPIO_29, HIGH), |
| 208 | /* EN_PWR_WIFI */ |
| 209 | PAD_GPO(GPIO_42, LOW), |
| 210 | }; |
| 211 | program_gpios(v3_wifi_table, ARRAY_SIZE(v3_wifi_table)); |
| 212 | |
| 213 | mdelay(10); |
| 214 | gpio_set(GPIO_42, 1); |
| 215 | mdelay(50); |
| 216 | gpio_set(GPIO_29, 0); |
| 217 | } |
| 218 | |
Furquan Shaikh | 30ee0d8 | 2020-07-07 12:50:55 -0700 | [diff] [blame] | 219 | static void wifi_power_reset_configure_v3(void) |
Furquan Shaikh | 70b7fa1 | 2020-06-29 11:56:04 -0700 | [diff] [blame] | 220 | { |
Furquan Shaikh | 30ee0d8 | 2020-07-07 12:50:55 -0700 | [diff] [blame] | 221 | if (variant_has_active_low_wifi_power()) |
Furquan Shaikh | 70b7fa1 | 2020-06-29 11:56:04 -0700 | [diff] [blame] | 222 | wifi_power_reset_configure_active_low_power(); |
| 223 | else |
| 224 | wifi_power_reset_configure_active_high_power(); |
| 225 | } |
| 226 | |
Furquan Shaikh | 8302585 | 2020-06-22 10:45:12 -0700 | [diff] [blame] | 227 | static void wifi_power_reset_configure_pre_v3(void) |
| 228 | { |
| 229 | /* |
| 230 | * Configure WiFi GPIOs such that: |
| 231 | * - WIFI_AUX_RESET_L is configured first to assert PERST# to WiFi device. |
| 232 | * - Disable power to WiFi since GPIO_29 goes high on PWRGOOD but has a glitch on RESET# |
| 233 | * deassertion causing WiFi to enter a bad state. |
| 234 | * - Wait 10ms for WiFi power to go low. |
| 235 | * - Enable power to WiFi using EN_PWR_WIFI. |
| 236 | * - Wait for 50ms after power to WiFi is enabled. |
| 237 | * - Deassert WIFI_AUX_RESET_L. |
| 238 | */ |
| 239 | static const struct soc_amd_gpio pre_v3_wifi_table[] = { |
| 240 | /* WIFI_AUX_RESET_L */ |
| 241 | PAD_GPO(GPIO_42, LOW), |
| 242 | /* EN_PWR_WIFI */ |
| 243 | PAD_GPO(GPIO_29, LOW), |
| 244 | }; |
| 245 | program_gpios(pre_v3_wifi_table, ARRAY_SIZE(pre_v3_wifi_table)); |
| 246 | |
| 247 | mdelay(10); |
| 248 | gpio_set(GPIO_29, 1); |
| 249 | mdelay(50); |
| 250 | gpio_set(GPIO_42, 1); |
| 251 | } |
| 252 | |
Furquan Shaikh | 56f949c | 2020-07-15 13:58:59 -0700 | [diff] [blame] | 253 | __weak void variant_pcie_gpio_configure(void) |
Furquan Shaikh | 8302585 | 2020-06-22 10:45:12 -0700 | [diff] [blame] | 254 | { |
Furquan Shaikh | 56f949c | 2020-07-15 13:58:59 -0700 | [diff] [blame] | 255 | static const struct soc_amd_gpio pcie_gpio_table[] = { |
| 256 | /* PCIE_RST1_L - Variable timings (May remove) */ |
| 257 | PAD_NF(GPIO_27, PCIE_RST1_L, PULL_NONE), |
| 258 | /* NVME_AUX_RESET_L */ |
| 259 | PAD_GPO(GPIO_40, HIGH), |
| 260 | /* CLK_REQ0_L - WIFI */ |
Furquan Shaikh | dce0ce9 | 2020-07-17 11:16:50 -0700 | [diff] [blame] | 261 | PAD_NF(GPIO_92, CLK_REQ0_L, PULL_NONE), |
Furquan Shaikh | 56f949c | 2020-07-15 13:58:59 -0700 | [diff] [blame] | 262 | /* CLK_REQ1_L - SD Card */ |
Furquan Shaikh | dce0ce9 | 2020-07-17 11:16:50 -0700 | [diff] [blame] | 263 | PAD_NF(GPIO_115, CLK_REQ1_L, PULL_NONE), |
Furquan Shaikh | 56f949c | 2020-07-15 13:58:59 -0700 | [diff] [blame] | 264 | /* CLK_REQ2_L - NVMe */ |
Furquan Shaikh | dce0ce9 | 2020-07-17 11:16:50 -0700 | [diff] [blame] | 265 | PAD_NF(GPIO_116, CLK_REQ2_L, PULL_NONE), |
Furquan Shaikh | 56f949c | 2020-07-15 13:58:59 -0700 | [diff] [blame] | 266 | /* SD_AUX_RESET_L */ |
| 267 | PAD_GPO(GPIO_142, HIGH), |
| 268 | }; |
| 269 | |
| 270 | program_gpios(pcie_gpio_table, ARRAY_SIZE(pcie_gpio_table)); |
| 271 | |
Furquan Shaikh | 9f47a05 | 2020-06-24 00:03:06 -0700 | [diff] [blame] | 272 | /* Deassert PCIE_RST1_L */ |
| 273 | gpio_set(GPIO_27, 1); |
| 274 | |
Furquan Shaikh | 30ee0d8 | 2020-07-07 12:50:55 -0700 | [diff] [blame] | 275 | if (variant_uses_v3_schematics()) |
| 276 | wifi_power_reset_configure_v3(); |
Furquan Shaikh | 8302585 | 2020-06-22 10:45:12 -0700 | [diff] [blame] | 277 | else |
| 278 | wifi_power_reset_configure_pre_v3(); |
| 279 | } |
Furquan Shaikh | 189a5c7 | 2020-06-29 18:50:50 -0700 | [diff] [blame] | 280 | |
Martin Roth | 726504a | 2020-10-30 16:41:32 -0600 | [diff] [blame] | 281 | __weak void finalize_gpios(int slp_typ) |
| 282 | { |
| 283 | } |
| 284 | |
| 285 | const __weak struct soc_amd_gpio *variant_bootblock_gpio_table(size_t *size, int slp_typ) |
| 286 | { |
| 287 | *size = 0; |
| 288 | return NULL; |
| 289 | } |
| 290 | |
Furquan Shaikh | 189a5c7 | 2020-06-29 18:50:50 -0700 | [diff] [blame] | 291 | static const struct soc_amd_gpio gpio_sleep_table[] = { |
Martin Roth | 6a62cc8 | 2020-12-02 16:37:58 -0700 | [diff] [blame] | 292 | /* S0iX SLP */ |
| 293 | PAD_GPO(GPIO_10, LOW), |
Furquan Shaikh | 189a5c7 | 2020-06-29 18:50:50 -0700 | [diff] [blame] | 294 | /* PCIE_RST1_L */ |
| 295 | PAD_GPO(GPIO_27, LOW), |
Furquan Shaikh | 70b7fa1 | 2020-06-29 11:56:04 -0700 | [diff] [blame] | 296 | /* |
| 297 | * On pre-v3 schematics, GPIO_29 is EN_PWR_WIFI. So, setting to high should be no-op. |
| 298 | * On v3+ schematics, GPIO_29 is WIFI_AUX_RESET. Setting to high ensures that PERST# is |
| 299 | * asserted to WiFi device until coreboot reconfigures GPIO_29 on resume path. |
| 300 | */ |
| 301 | PAD_GPO(GPIO_29, HIGH), |
Furquan Shaikh | 189a5c7 | 2020-06-29 18:50:50 -0700 | [diff] [blame] | 302 | /* NVME_AUX_RESET_L */ |
| 303 | PAD_GPO(GPIO_40, LOW), |
| 304 | /* EN_PWR_CAMERA */ |
| 305 | PAD_GPO(GPIO_76, LOW), |
| 306 | }; |
| 307 | |
| 308 | const __weak struct soc_amd_gpio *variant_sleep_gpio_table(size_t *size, int slp_typ) |
| 309 | { |
| 310 | *size = ARRAY_SIZE(gpio_sleep_table); |
| 311 | return gpio_sleep_table; |
| 312 | } |