From 45c2900ec023d20192ce78ad24bc05a9b32c8ec2 Mon Sep 17 00:00:00 2001 From: wuzhenghui Date: Sun, 5 Feb 2023 17:18:49 +0800 Subject: [PATCH] resolve WIFI-5150 bugfix: Don't hold CS pin when VDDSDIO is power down to reduce the base current --- components/esp_hw_support/sleep_modes.c | 12 ++++++++---- examples/wifi/itwt/main/itwt.c | 8 +------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/components/esp_hw_support/sleep_modes.c b/components/esp_hw_support/sleep_modes.c index de53031741..463444dc34 100644 --- a/components/esp_hw_support/sleep_modes.c +++ b/components/esp_hw_support/sleep_modes.c @@ -592,8 +592,10 @@ static uint32_t IRAM_ATTR esp_sleep_start(uint32_t pd_flags, esp_sleep_mode_t mo /* On esp32c6, only the lp_aon pad hold function can only hold the GPIO state in the active mode. In order to avoid the leakage of the SPI cs pin, hold it here */ -#if CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP && CONFIG_ESP_SLEEP_FLASH_LEAKAGE_WORKAROUND - rtcio_ll_force_hold_enable(SPI_CS0_GPIO_NUM); +#if (CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP && CONFIG_ESP_SLEEP_FLASH_LEAKAGE_WORKAROUND) + if(!(pd_flags & PMU_SLEEP_PD_VDDSDIO)) { + rtcio_ll_force_hold_enable(SPI_CS0_GPIO_NUM); + } #endif #if SOC_PM_CPU_RETENTION_BY_SW @@ -607,8 +609,10 @@ static uint32_t IRAM_ATTR esp_sleep_start(uint32_t pd_flags, esp_sleep_mode_t mo #endif /* Unhold the SPI CS pin */ -#if CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP && CONFIG_ESP_SLEEP_FLASH_LEAKAGE_WORKAROUND - rtcio_ll_force_hold_disable(SPI_CS0_GPIO_NUM); +#if (CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP && CONFIG_ESP_SLEEP_FLASH_LEAKAGE_WORKAROUND) + if(!(pd_flags & PMU_SLEEP_PD_VDDSDIO)) { + rtcio_ll_force_hold_disable(SPI_CS0_GPIO_NUM); + } #endif } diff --git a/examples/wifi/itwt/main/itwt.c b/examples/wifi/itwt/main/itwt.c index 5d2488882b..147b78c2cc 100644 --- a/examples/wifi/itwt/main/itwt.c +++ b/examples/wifi/itwt/main/itwt.c @@ -246,13 +246,7 @@ void app_main(void) ret = nvs_flash_init(); } - // TODO: WIFI-5150 -#if CONFIG_PM_ENABLE && 0 - sleep_clock_system_retention_init(); - sleep_clock_modem_retention_init(); - sleep_sys_periph_retention_init(); - sleep_modem_wifi_modem_state_init(); - +#if CONFIG_PM_ENABLE // Configure dynamic frequency scaling: // maximum and minimum frequencies are set in sdkconfig, // automatic light sleep is enabled if tickless idle support is enabled.