diff --git a/components/esp_hw_support/port/esp32s2/rtc_clk.c b/components/esp_hw_support/port/esp32s2/rtc_clk.c index f2111b73e7..47f2e47c80 100644 --- a/components/esp_hw_support/port/esp32s2/rtc_clk.c +++ b/components/esp_hw_support/port/esp32s2/rtc_clk.c @@ -21,6 +21,10 @@ #include "esp_hw_log.h" #include "sdkconfig.h" #include "hal/clk_tree_ll.h" +#ifndef BOOTLOADER_BUILD +#include "esp_private/systimer.h" +#include "hal/systimer_ll.h" +#endif static const char *TAG = "rtc_clk"; @@ -468,6 +472,9 @@ static void rtc_clk_cpu_freq_to_xtal(int cpu_freq, int div) /* no need to adjust the REF_TICK, default register value already set it to 1MHz with any cpu clock source */ /* switch clock source */ clk_ll_cpu_set_src(SOC_CPU_CLK_SRC_XTAL); +#ifndef BOOTLOADER_BUILD + systimer_ll_set_step_for_xtal(&SYSTIMER, systimer_us_to_ticks(1) / cpu_freq); +#endif rtc_clk_apb_freq_update(cpu_freq * MHZ); /* lower the voltage diff --git a/components/esp_pm/pm_impl.c b/components/esp_pm/pm_impl.c index 8cc301746d..a576d0d1ac 100644 --- a/components/esp_pm/pm_impl.c +++ b/components/esp_pm/pm_impl.c @@ -572,15 +572,6 @@ void IRAM_ATTR esp_pm_impl_switch_mode(pm_mode_t mode, */ static void IRAM_ATTR on_freq_update(uint32_t old_ticks_per_us, uint32_t ticks_per_us) { -#if !CONFIG_IDF_TARGET_ESP32 - uint32_t old_apb_ticks_per_us = MIN(old_ticks_per_us, 80); - uint32_t apb_ticks_per_us = MIN(ticks_per_us, 80); - /* Update APB frequency value used by the timer */ - if (old_apb_ticks_per_us != apb_ticks_per_us) { - esp_timer_private_update_apb_freq(apb_ticks_per_us); - } -#endif - #ifdef CONFIG_FREERTOS_SYSTICK_USES_CCOUNT #ifdef XT_RTOS_TIMER_INT /* Calculate new tick divisor */ diff --git a/components/esp_timer/include/esp_private/esp_timer_private.h b/components/esp_timer/include/esp_private/esp_timer_private.h index 37aaeac03f..c40d96cd40 100644 --- a/components/esp_timer/include/esp_private/esp_timer_private.h +++ b/components/esp_timer/include/esp_private/esp_timer_private.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2017-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2017-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -24,16 +24,6 @@ #ifdef __cplusplus extern "C" { #endif - -/** - * @brief Notify esp_timer implementation that APB frequency has changed - * - * Called by the frequency switching code. - * - * @param apb_ticks_per_us new number of APB clock ticks per microsecond - */ -void esp_timer_private_update_apb_freq(uint32_t apb_ticks_per_us); - /** * @brief Set esp_timer time to a certain value * diff --git a/components/esp_timer/private_include/esp_timer_impl.h b/components/esp_timer/private_include/esp_timer_impl.h index 50bdd06d75..2e32f43d90 100644 --- a/components/esp_timer/private_include/esp_timer_impl.h +++ b/components/esp_timer/private_include/esp_timer_impl.h @@ -76,15 +76,6 @@ void esp_timer_impl_set_alarm(uint64_t timestamp); */ void esp_timer_impl_set_alarm_id(uint64_t timestamp, unsigned alarm_id); -/** - * @brief Notify esp_timer implementation that APB frequency has changed - * - * Called by the frequency switching code. - * - * @param apb_ticks_per_us new number of APB clock ticks per microsecond - */ -void esp_timer_impl_update_apb_freq(uint32_t apb_ticks_per_us); - /** * @brief Adjust current esp_timer time by a certain value * diff --git a/components/esp_timer/src/esp_timer_impl_systimer.c b/components/esp_timer/src/esp_timer_impl_systimer.c index 2b6c9050bc..d642db58f8 100644 --- a/components/esp_timer/src/esp_timer_impl_systimer.c +++ b/components/esp_timer/src/esp_timer_impl_systimer.c @@ -129,13 +129,6 @@ static void ESP_TIMER_IRAM_ATTR timer_alarm_isr(void *arg) #endif // ISR_HANDLERS != 1 } -void ESP_TIMER_IRAM_ATTR esp_timer_impl_update_apb_freq(uint32_t apb_ticks_per_us) -{ -#if !SOC_SYSTIMER_FIXED_DIVIDER - systimer_hal_on_apb_freq_update(&systimer_hal, apb_ticks_per_us); -#endif -} - void esp_timer_impl_set(uint64_t new_us) { portENTER_CRITICAL_SAFE(&s_time_update_lock); @@ -253,6 +246,5 @@ uint64_t esp_timer_impl_get_alarm_reg(void) return val; } -void esp_timer_private_update_apb_freq(uint32_t apb_ticks_per_us) __attribute__((alias("esp_timer_impl_update_apb_freq"))); void esp_timer_private_set(uint64_t new_us) __attribute__((alias("esp_timer_impl_set"))); void esp_timer_private_advance(int64_t time_diff_us) __attribute__((alias("esp_timer_impl_advance")));