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