diff --git a/components/esp_hw_support/port/esp32c6/pmu_sleep.c b/components/esp_hw_support/port/esp32c6/pmu_sleep.c index a2f28c4c52..92d88eea38 100644 --- a/components/esp_hw_support/port/esp32c6/pmu_sleep.c +++ b/components/esp_hw_support/port/esp32c6/pmu_sleep.c @@ -166,6 +166,19 @@ const pmu_sleep_config_t* pmu_sleep_config_default( analog_default.hp_sys.analog.xpd = 1; analog_default.hp_sys.analog.dbias = 2; } + + if (!(pd_flags & PMU_SLEEP_PD_XTAL)){ + analog_default.hp_sys.analog.xpd = 1; + analog_default.hp_sys.analog.pd_cur = 0; + analog_default.hp_sys.analog.bias_sleep = 0; + analog_default.hp_sys.analog.dbias = 25; + + analog_default.lp_sys[LP(SLEEP)].analog.xpd = 1; + analog_default.lp_sys[LP(SLEEP)].analog.pd_cur = 0; + analog_default.lp_sys[LP(SLEEP)].analog.bias_sleep = 0; + analog_default.lp_sys[LP(SLEEP)].analog.dbias = 26; + } + config->analog = analog_default; } return config; diff --git a/components/esp_hw_support/sleep_modes.c b/components/esp_hw_support/sleep_modes.c index babb9f6f8e..9b09db3c49 100644 --- a/components/esp_hw_support/sleep_modes.c +++ b/components/esp_hw_support/sleep_modes.c @@ -1567,6 +1567,22 @@ esp_err_t esp_sleep_pd_config(esp_sleep_pd_domain_t domain, esp_sleep_pd_option_ return ESP_OK; } +/** + * The modules in the CPU and modem power domains still depend on the top power domain. + * To be safe, the CPU and Modem power domains must also be powered off and saved when + * the TOP is powered off. If not power down XTAL, power down TOP is meaningless, and + * the XTAL clock control of some chips(esp32c6/esp32h2) depends on the top domain. + */ +#if SOC_PM_SUPPORT_TOP_PD +static inline bool top_domain_pd_allowed(void) { + return (cpu_domain_pd_allowed() && \ + clock_domain_pd_allowed() && \ + peripheral_domain_pd_allowed() && \ + modem_domain_pd_allowed() && \ + s_config.domain[ESP_PD_DOMAIN_XTAL].pd_option != ESP_PD_OPTION_ON); +} +#endif + static uint32_t get_power_down_flags(void) { // Where needed, convert AUTO options to ON. Later interpret AUTO as OFF. @@ -1628,11 +1644,6 @@ static uint32_t get_power_down_flags(void) } #endif // SOC_PM_SUPPORT_RTC_PERIPH_PD -#if SOC_PM_SUPPORT_CPU_PD - if (!cpu_domain_pd_allowed()) { - s_config.domain[ESP_PD_DOMAIN_CPU].pd_option = ESP_PD_OPTION_ON; - } -#endif /** * VDD_SDIO power domain shall be kept on during the light sleep * when CONFIG_ESP_SLEEP_POWER_DOWN_FLASH is not set and off when it is set. @@ -1649,23 +1660,7 @@ static uint32_t get_power_down_flags(void) #endif } #endif -#if SOC_PM_SUPPORT_MODEM_PD - if (!modem_domain_pd_allowed()) { - s_config.domain[ESP_PD_DOMAIN_MODEM].pd_option = ESP_PD_OPTION_ON; - } -#endif -/** - * The modules in the CPU and modem power domains still depend on the top power domain. - * To be safe, the CPU and Modem power domains must also be powered off and saved when - * the TOP is powered off. - */ -#if SOC_PM_SUPPORT_TOP_PD - if (!cpu_domain_pd_allowed() || !clock_domain_pd_allowed() || - !peripheral_domain_pd_allowed() || !modem_domain_pd_allowed()) { - s_config.domain[ESP_PD_DOMAIN_TOP].pd_option = ESP_PD_OPTION_ON; - } -#endif #ifdef CONFIG_IDF_TARGET_ESP32 s_config.domain[ESP_PD_DOMAIN_XTAL].pd_option = ESP_PD_OPTION_OFF; @@ -1702,7 +1697,7 @@ static uint32_t get_power_down_flags(void) #endif #if SOC_PM_SUPPORT_CPU_PD - if (s_config.domain[ESP_PD_DOMAIN_CPU].pd_option != ESP_PD_OPTION_ON) { + if ((s_config.domain[ESP_PD_DOMAIN_CPU].pd_option != ESP_PD_OPTION_ON) && cpu_domain_pd_allowed()) { pd_flags |= RTC_SLEEP_PD_CPU; } #endif @@ -1725,13 +1720,13 @@ static uint32_t get_power_down_flags(void) pd_flags |= RTC_SLEEP_PD_XTAL; } #if SOC_PM_SUPPORT_TOP_PD - if (s_config.domain[ESP_PD_DOMAIN_TOP].pd_option != ESP_PD_OPTION_ON) { + if ((s_config.domain[ESP_PD_DOMAIN_TOP].pd_option != ESP_PD_OPTION_ON) && top_domain_pd_allowed()) { pd_flags |= PMU_SLEEP_PD_TOP; } #endif #if SOC_PM_SUPPORT_MODEM_PD - if (s_config.domain[ESP_PD_DOMAIN_MODEM].pd_option != ESP_PD_OPTION_ON) { + if ((s_config.domain[ESP_PD_DOMAIN_MODEM].pd_option != ESP_PD_OPTION_ON) && modem_domain_pd_allowed()) { pd_flags |= RTC_SLEEP_PD_MODEM; } #endif