Merge branch 'fix/fix_flash_clock_changed_after_sleep_bak_v5.4' into 'release/v5.4'

fix(esp_hw_support): fix mspi clock freq changed after lightsleep (v5.4)

See merge request espressif/esp-idf!36002
This commit is contained in:
Jiang Jiang Jian
2025-01-07 10:55:43 +08:00
3 changed files with 32 additions and 16 deletions

View File

@@ -23,8 +23,14 @@
#include "esp_private/periph_ctrl.h"
#include "soc/rtc.h"
#include "hal/clk_tree_ll.h"
#include "hal/uart_ll.h"
#include "hal/uart_types.h"
#if __has_include("hal/mspi_timing_tuning_ll.h")
#include "hal/mspi_timing_tuning_ll.h"
#endif
#include "driver/gpio.h"
#include "freertos/FreeRTOS.h"
@@ -34,10 +40,6 @@
#include "xtensa/core-macros.h"
#endif
#if SOC_SPI_MEM_SUPPORT_TIMING_TUNING
#include "esp_private/mspi_timing_tuning.h"
#endif
#include "esp_private/pm_impl.h"
#include "esp_private/pm_trace.h"
#include "esp_private/esp_timer_private.h"
@@ -47,6 +49,9 @@
#include "esp_private/sleep_gpio.h"
#include "esp_private/sleep_modem.h"
#include "esp_private/uart_share_hw_ctrl.h"
#if MSPI_TIMING_LL_FLASH_CPU_CLK_SRC_BINDED
#include "esp_private/mspi_timing_tuning.h"
#endif
#include "esp_sleep.h"
#include "esp_memory_utils.h"
@@ -664,16 +669,16 @@ static void IRAM_ATTR do_switch(pm_mode_t new_mode)
if (switch_down) {
on_freq_update(old_ticks_per_us, new_ticks_per_us);
}
#if SOC_SPI_MEM_SUPPORT_TIMING_TUNING
if (new_config.source == SOC_CPU_CLK_SRC_PLL) {
rtc_clk_cpu_freq_set_config_fast(&new_config);
mspi_timing_change_speed_mode_cache_safe(false);
} else {
mspi_timing_change_speed_mode_cache_safe(true);
rtc_clk_cpu_freq_set_config_fast(&new_config);
}
#if MSPI_TIMING_LL_FLASH_CPU_CLK_SRC_BINDED
if (new_config.source_freq_mhz > clk_ll_xtal_load_freq_mhz()) {
rtc_clk_cpu_freq_set_config_fast(&new_config);
mspi_timing_change_speed_mode_cache_safe(false);
} else {
mspi_timing_change_speed_mode_cache_safe(true);
rtc_clk_cpu_freq_set_config_fast(&new_config);
}
#else
rtc_clk_cpu_freq_set_config_fast(&new_config);
rtc_clk_cpu_freq_set_config_fast(&new_config);
#endif
if (!switch_down) {
on_freq_update(old_ticks_per_us, new_ticks_per_us);