Skip to content

Commit 0f20fcb

Browse files
committed
fix(esp_hw_support): fix esp32c5 and esp32c61 wakeup failed when TOP rejects PD
1 parent 6540208 commit 0f20fcb

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

components/esp_hw_support/sleep_gpio.c

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -61,19 +61,6 @@ void esp_sleep_config_gpio_isolate(void)
6161
gpio_sleep_set_pull_mode(gpio_num, GPIO_FLOATING);
6262
}
6363
}
64-
#if CONFIG_ESP_SLEEP_PSRAM_LEAKAGE_WORKAROUND && CONFIG_SPIRAM
65-
int32_t mspi_io_cs1_io_num = esp_mspi_get_io(ESP_MSPI_IO_CS1);
66-
if (GPIO_IS_VALID_GPIO(mspi_io_cs1_io_num)) {
67-
gpio_sleep_set_pull_mode(mspi_io_cs1_io_num, GPIO_PULLUP_ONLY);
68-
}
69-
#endif // CONFIG_ESP_SLEEP_PSRAM_LEAKAGE_WORKAROUND && CONFIG_SPIRAM
70-
71-
#if CONFIG_ESP_SLEEP_FLASH_LEAKAGE_WORKAROUND
72-
int32_t mspi_io_cs0_io_num = esp_mspi_get_io(ESP_MSPI_IO_CS0);
73-
if (GPIO_IS_VALID_GPIO(mspi_io_cs0_io_num)) {
74-
gpio_sleep_set_pull_mode(esp_mspi_get_io(ESP_MSPI_IO_CS0), GPIO_PULLUP_ONLY);
75-
}
76-
#endif // CONFIG_ESP_SLEEP_FLASH_LEAKAGE_WORKAROUND
7764

7865
#if CONFIG_ESP_SLEEP_MSPI_NEED_ALL_IO_PU
7966
gpio_sleep_set_pull_mode(esp_mspi_get_io(ESP_MSPI_IO_CLK), GPIO_PULLUP_ONLY);
@@ -102,6 +89,21 @@ void esp_sleep_enable_gpio_switch(bool enable)
10289
ESP_EARLY_LOGI(TAG, "%s automatic switching of GPIO sleep configuration", enable ? "Enable" : "Disable");
10390
for (gpio_num_t gpio_num = GPIO_NUM_0; gpio_num < GPIO_NUM_MAX; gpio_num++) {
10491
if (GPIO_IS_VALID_GPIO(gpio_num)) {
92+
/* If the PSRAM is disable in ESP32xx chips equipped with PSRAM, there will be a large current leakage. */
93+
#if CONFIG_ESP_SLEEP_PSRAM_LEAKAGE_WORKAROUND && CONFIG_SPIRAM
94+
if (gpio_num == esp_mspi_get_io(ESP_MSPI_IO_CS1)) {
95+
gpio_sleep_sel_dis(gpio_num);
96+
continue;
97+
}
98+
#endif // CONFIG_ESP_SLEEP_PSRAM_LEAKAGE_WORKAROUND && CONFIG_SPIRAM
99+
100+
#if CONFIG_ESP_SLEEP_FLASH_LEAKAGE_WORKAROUND
101+
if (gpio_num == esp_mspi_get_io(ESP_MSPI_IO_CS0)) {
102+
gpio_sleep_sel_dis(gpio_num);
103+
continue;
104+
}
105+
#endif // CONFIG_ESP_SLEEP_FLASH_LEAKAGE_WORKAROUND
106+
105107
if (enable) {
106108
gpio_sleep_sel_en(gpio_num);
107109
} else {
@@ -190,13 +192,9 @@ void esp_deep_sleep_wakeup_io_reset(void)
190192
#if CONFIG_ESP_SLEEP_GPIO_RESET_WORKAROUND || CONFIG_PM_SLP_DISABLE_GPIO
191193
ESP_SYSTEM_INIT_FN(esp_sleep_startup_init, SECONDARY, BIT(0), 105)
192194
{
193-
/* If the TOP domain is powered off, the GPIO will also be powered off during sleep,
194-
and all configurations in the sleep state of GPIO will not take effect.*/
195-
#if !CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP
196195
// Configure to isolate (disable the Input/Output/Pullup/Pulldown
197196
// function of the pin) all GPIO pins in sleep state
198197
esp_sleep_config_gpio_isolate();
199-
#endif
200198
// Enable automatic switching of GPIO configuration
201199
esp_sleep_enable_gpio_switch(true);
202200
return ESP_OK;

0 commit comments

Comments
 (0)