From e351f177905885c70d85f0b596ef2d59b46f04d5 Mon Sep 17 00:00:00 2001 From: Li Shuai Date: Tue, 4 Mar 2025 20:15:56 +0800 Subject: [PATCH] change(esp_hw_support): support power management dfs flow --- components/esp_hw_support/CMakeLists.txt | 6 ------ components/esp_hw_support/sleep_modes.c | 8 +++++++- components/esp_pm/pm_impl.c | 5 +++-- components/soc/esp32h21/include/soc/Kconfig.soc_caps.in | 4 ++++ components/soc/esp32h21/include/soc/soc_caps.h | 2 +- 5 files changed, 15 insertions(+), 10 deletions(-) diff --git a/components/esp_hw_support/CMakeLists.txt b/components/esp_hw_support/CMakeLists.txt index 11eb968678..267adb7ef1 100644 --- a/components/esp_hw_support/CMakeLists.txt +++ b/components/esp_hw_support/CMakeLists.txt @@ -171,12 +171,6 @@ set(public_include_dirs "include" "include/soc" "include/soc/${target}" "dma/include" "ldo/include" "debug_probe/include" "mspi_timing_tuning/include" "power_supply/include") -if(CONFIG_IDF_TARGET_ESP32H21) - list(REMOVE_ITEM srcs - "sleep_modes.c" # TODO: [ESP32H21] IDF-11515, IDF-11517 - ) -endif() - idf_component_register(SRCS ${srcs} INCLUDE_DIRS ${public_include_dirs} PRIV_INCLUDE_DIRS port/include include/esp_private diff --git a/components/esp_hw_support/sleep_modes.c b/components/esp_hw_support/sleep_modes.c index 0c31d4738b..db2629e21e 100644 --- a/components/esp_hw_support/sleep_modes.c +++ b/components/esp_hw_support/sleep_modes.c @@ -108,9 +108,12 @@ #elif CONFIG_IDF_TARGET_ESP32H2 #include "esp32h2/rom/rtc.h" #include "esp32h2/rom/cache.h" -#include "esp32h2/rom/rtc.h" #include "soc/extmem_reg.h" #include "hal/gpio_ll.h" +#elif CONFIG_IDF_TARGET_ESP32H21 +#include "esp32h21/rom/rtc.h" +#include "esp32h21/rom/cache.h" +#include "hal/gpio_ll.h" #elif CONFIG_IDF_TARGET_ESP32P4 #include "esp32p4/rom/rtc.h" #include "hal/gpio_ll.h" @@ -167,6 +170,9 @@ #elif CONFIG_IDF_TARGET_ESP32H2 #define DEFAULT_SLEEP_OUT_OVERHEAD_US (118) #define DEFAULT_HARDWARE_OUT_OVERHEAD_US (9) +#elif CONFIG_IDF_TARGET_ESP32H21 +#define DEFAULT_SLEEP_OUT_OVERHEAD_US (118) +#define DEFAULT_HARDWARE_OUT_OVERHEAD_US (9) #elif CONFIG_IDF_TARGET_ESP32P4 #define DEFAULT_SLEEP_OUT_OVERHEAD_US (324) #define DEFAULT_HARDWARE_OUT_OVERHEAD_US (240) diff --git a/components/esp_pm/pm_impl.c b/components/esp_pm/pm_impl.c index b43e23b572..2c70cea9c3 100644 --- a/components/esp_pm/pm_impl.c +++ b/components/esp_pm/pm_impl.c @@ -379,14 +379,15 @@ static esp_err_t esp_pm_sleep_configure(const void *vconfig) esp_err_t err = ESP_OK; const esp_pm_config_t* config = (const esp_pm_config_t*) vconfig; -#if ESP_SLEEP_POWER_DOWN_CPU +#if ESP_SLEEP_POWER_DOWN_CPU && CONFIG_SOC_LIGHT_SLEEP_SUPPORTED err = sleep_cpu_configure(config->light_sleep_enable); if (err != ESP_OK) { return err; } #endif - +#if CONFIG_SOC_LIGHT_SLEEP_SUPPORTED err = sleep_modem_configure(config->max_freq_mhz, config->min_freq_mhz, config->light_sleep_enable); +#endif return err; } diff --git a/components/soc/esp32h21/include/soc/Kconfig.soc_caps.in b/components/soc/esp32h21/include/soc/Kconfig.soc_caps.in index 1d84edc1f5..1dd84d1f56 100644 --- a/components/soc/esp32h21/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32h21/include/soc/Kconfig.soc_caps.in @@ -75,6 +75,10 @@ config SOC_PAU_SUPPORTED bool default y +config SOC_PM_SUPPORTED + bool + default y + config SOC_XTAL_SUPPORT_32M bool default y diff --git a/components/soc/esp32h21/include/soc/soc_caps.h b/components/soc/esp32h21/include/soc/soc_caps.h index ce568f4f1e..5e0b01f102 100644 --- a/components/soc/esp32h21/include/soc/soc_caps.h +++ b/components/soc/esp32h21/include/soc/soc_caps.h @@ -78,7 +78,7 @@ // #define SOC_LIGHT_SLEEP_SUPPORTED 1 //TODO: [ESP32H21] IDF-11517, IDF-11520 // #define SOC_DEEP_SLEEP_SUPPORTED 1 //TODO: [ESP32H21] IDF-11515 // #define SOC_MODEM_CLOCK_SUPPORTED 1 -// #define SOC_PM_SUPPORTED 1 +#define SOC_PM_SUPPORTED 1 /*-------------------------- XTAL CAPS ---------------------------------------*/ #define SOC_XTAL_SUPPORT_32M 1