From ff6992806458874cdc6028d052c562f7a0cec2a9 Mon Sep 17 00:00:00 2001 From: cjin Date: Tue, 26 Sep 2023 16:44:27 +0800 Subject: [PATCH] feat(pm): change power down prepare position --- components/esp_hw_support/sleep_modes.c | 8 -------- components/esp_pm/pm_impl.c | 7 +++++++ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/components/esp_hw_support/sleep_modes.c b/components/esp_hw_support/sleep_modes.c index 5136d6f980..4d03e5eecb 100644 --- a/components/esp_hw_support/sleep_modes.c +++ b/components/esp_hw_support/sleep_modes.c @@ -624,14 +624,6 @@ static esp_err_t IRAM_ATTR esp_sleep_start(uint32_t pd_flags, esp_sleep_mode_t m // Will switch to XTAL turn down MSPI speed mspi_timing_change_speed_mode_cache_safe(true); - /* - Since the modem requires a PLL clock to access modem REG, - it is necessary to back up the mac/bb REG before disabling the PLL clock. - */ -#if SOC_PM_RETENTION_HAS_CLOCK_BUG - mac_bb_power_down_prepare(); -#endif // SOC_PM_RETENTION_HAS_CLOCK_BUG - // Save current frequency and switch to XTAL rtc_cpu_freq_config_t cpu_freq_config; rtc_clk_cpu_freq_get_config(&cpu_freq_config); diff --git a/components/esp_pm/pm_impl.c b/components/esp_pm/pm_impl.c index 2c28e6d696..a8cfcf2f75 100644 --- a/components/esp_pm/pm_impl.c +++ b/components/esp_pm/pm_impl.c @@ -967,6 +967,13 @@ void esp_pm_impl_idle_hook(void) && !periph_should_skip_light_sleep() #endif ) { + /* + Since the modem requires a PLL clock to access modem REG, + it is necessary to back up the mac/bb REG before disabling the PLL clock. + */ +#if SOC_PM_RETENTION_HAS_CLOCK_BUG + mac_bb_power_down_prepare(); +#endif // SOC_PM_RETENTION_HAS_CLOCK_BUG esp_pm_lock_release(s_rtos_lock_handle[core_id]); s_core_idle[core_id] = true; }