From 6bd6be3ed8c3bc044a120394e8f8de547a6a8f6d Mon Sep 17 00:00:00 2001 From: wuzhenghui Date: Wed, 26 Feb 2025 14:03:20 +0800 Subject: [PATCH] fix(esp_hw_support): warning instead of error when enabling uart/gpio wakeup in pd_top sleep --- components/esp_hw_support/include/esp_sleep.h | 2 -- components/esp_hw_support/sleep_modes.c | 6 ++---- components/esp_pm/Kconfig | 10 +++++++++- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/components/esp_hw_support/include/esp_sleep.h b/components/esp_hw_support/include/esp_sleep.h index f2160be194..38d1f8cd48 100644 --- a/components/esp_hw_support/include/esp_sleep.h +++ b/components/esp_hw_support/include/esp_sleep.h @@ -481,7 +481,6 @@ esp_err_t esp_deep_sleep_enable_gpio_wakeup(uint64_t gpio_pin_mask, esp_deepslee * @return * - ESP_OK on success * - ESP_ERR_INVALID_STATE if wakeup triggers conflict - * - ESP_ERR_NOT_SUPPORTED if GPIO wakeup source is not available */ esp_err_t esp_sleep_enable_gpio_wakeup(void); @@ -501,7 +500,6 @@ esp_err_t esp_sleep_enable_gpio_wakeup(void); * @return * - ESP_OK on success * - ESP_ERR_INVALID_ARG if wakeup from given UART is not supported - * - ESP_ERR_NOT_SUPPORTED if UART wakeup source is not available */ esp_err_t esp_sleep_enable_uart_wakeup(int uart_num); diff --git a/components/esp_hw_support/sleep_modes.c b/components/esp_hw_support/sleep_modes.c index 9f2fc4c8b3..c3875fa07c 100644 --- a/components/esp_hw_support/sleep_modes.c +++ b/components/esp_hw_support/sleep_modes.c @@ -2056,8 +2056,7 @@ esp_err_t esp_deep_sleep_enable_gpio_wakeup(uint64_t gpio_pin_mask, esp_deepslee esp_err_t esp_sleep_enable_gpio_wakeup(void) { #if CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP - ESP_LOGE(TAG, "%s wakeup source is not available if the peripheral power domain is powered down in sleep", "GPIO"); - return ESP_ERR_NOT_SUPPORTED; + ESP_LOGW(TAG, "%s wakeup source is not available if the peripheral power domain is powered down in sleep", "GPIO"); #endif #if CONFIG_IDF_TARGET_ESP32 if (s_config.wakeup_triggers & (RTC_TOUCH_TRIG_EN | RTC_ULP_TRIG_EN)) { @@ -2072,8 +2071,7 @@ esp_err_t esp_sleep_enable_gpio_wakeup(void) esp_err_t esp_sleep_enable_uart_wakeup(int uart_num) { #if CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP - ESP_LOGE(TAG, "%s wakeup source is not available if the peripheral power domain is powered down in sleep", "UART"); - return ESP_ERR_NOT_SUPPORTED; + ESP_LOGW(TAG, "%s wakeup source is not available if the peripheral power domain is powered down in sleep", "UART"); #endif if (uart_num == UART_NUM_0) { s_config.wakeup_triggers |= RTC_UART0_TRIG_EN; diff --git a/components/esp_pm/Kconfig b/components/esp_pm/Kconfig index b5edbee70a..b4fbae2b2c 100644 --- a/components/esp_pm/Kconfig +++ b/components/esp_pm/Kconfig @@ -146,7 +146,7 @@ menu "Power Management" select PM_POWER_DOWN_CPU_IN_LIGHT_SLEEP if !SOC_CPU_IN_TOP_DOMAIN default n #TODO: enable by default if periph init/deinit management supported (WIFI-5252) help - If enabled, digital peripherals will be powered down in light sleep, all related peripherals will + If enabled, digital peripherals will try to powered down in light sleep, then all related peripherals will not be available during sleep, including wake-up sources from the peripherals (For detailed availability information, see the note of the corresponding wakeup source enable function). The chip will automatically save/restore register context during sleep/wakeup to make the upper layer @@ -171,6 +171,14 @@ menu "Power Management" of freertos to not be compensated correctly when returning from sleep and cause the system to crash. To avoid this, you can increase FREERTOS_IDLE_TIME_BEFORE_SLEEP threshold in menuconfig. + Note3: Enabling this option does not necessarily mean that the peripheral power domain will be + turned down during sleep. The control priority of `esp_sleep_pd_config` is higher than this option, + user code can still prevent the peripheral power domain from powering down during sleep by + `esp_sleep_pd_config(ESP_PD_DOMAIN_TOP, ESP_PD_OPTION_ON)`. In addition, whether the peripheral power + domain is powered down during sleep also depends on the sleep working strategy selected by the driver. + If any module belonging to the peripheral power domain chooses not to be powered down during sleep, + then the peripheral power domain will not be powered off either. + config PM_UPDATE_CCOMPARE_HLI_WORKAROUND bool default y if PM_ENABLE && BTDM_CTRL_HLI