mirror of
https://github.com/espressif/esp-idf.git
synced 2025-09-30 19:19:21 +00:00
Merge branch 'bugfix/stop_tg_wdt_in_xpd_xtal_lightsleep_v5.1' into 'release/v5.1'
fix(esp_hw_support): stop tg wdt in xpd xtal lightsleep (v5.1) See merge request espressif/esp-idf!31140
This commit is contained in:
@@ -26,6 +26,15 @@
|
||||
#include "driver/rtc_io.h"
|
||||
#include "hal/rtc_io_hal.h"
|
||||
|
||||
#if SOC_SLEEP_SYSTIMER_STALL_WORKAROUND
|
||||
#include "hal/systimer_ll.h"
|
||||
#endif
|
||||
|
||||
#if SOC_SLEEP_TGWDT_STOP_WORKAROUND
|
||||
#include "hal/mwdt_ll.h"
|
||||
#include "hal/timer_ll.h"
|
||||
#endif
|
||||
|
||||
#if SOC_PM_SUPPORT_PMU_MODEM_STATE
|
||||
#include "esp_private/pm_impl.h"
|
||||
#endif
|
||||
@@ -463,6 +472,52 @@ static void IRAM_ATTR resume_cache(void) {
|
||||
}
|
||||
}
|
||||
|
||||
#if SOC_SLEEP_TGWDT_STOP_WORKAROUND
|
||||
static uint32_t s_stopped_tgwdt_bmap = 0;
|
||||
#endif
|
||||
|
||||
// Must be called from critical sections.
|
||||
static void IRAM_ATTR suspend_timers(uint32_t pd_flags) {
|
||||
if (!(pd_flags & RTC_SLEEP_PD_XTAL)) {
|
||||
#if SOC_SLEEP_TGWDT_STOP_WORKAROUND
|
||||
/* If timegroup implemented task watchdog or interrupt watchdog is running, we have to stop it. */
|
||||
for (uint32_t tg_num = 0; tg_num < SOC_TIMER_GROUPS; ++tg_num) {
|
||||
if (mwdt_ll_check_if_enabled(TIMER_LL_GET_HW(tg_num))) {
|
||||
mwdt_ll_write_protect_disable(TIMER_LL_GET_HW(tg_num));
|
||||
mwdt_ll_disable(TIMER_LL_GET_HW(tg_num));
|
||||
mwdt_ll_write_protect_enable(TIMER_LL_GET_HW(tg_num));
|
||||
s_stopped_tgwdt_bmap |= BIT(tg_num);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if SOC_SLEEP_SYSTIMER_STALL_WORKAROUND
|
||||
for (uint32_t counter_id = 0; counter_id < SOC_SYSTIMER_COUNTER_NUM; ++counter_id) {
|
||||
systimer_ll_enable_counter(&SYSTIMER, counter_id, false);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
// Must be called from critical sections.
|
||||
static void IRAM_ATTR resume_timers(uint32_t pd_flags) {
|
||||
if (!(pd_flags & RTC_SLEEP_PD_XTAL)) {
|
||||
#if SOC_SLEEP_SYSTIMER_STALL_WORKAROUND
|
||||
for (uint32_t counter_id = 0; counter_id < SOC_SYSTIMER_COUNTER_NUM; ++counter_id) {
|
||||
systimer_ll_enable_counter(&SYSTIMER, counter_id, true);
|
||||
}
|
||||
#endif
|
||||
#if SOC_SLEEP_TGWDT_STOP_WORKAROUND
|
||||
for (uint32_t tg_num = 0; tg_num < SOC_TIMER_GROUPS; ++tg_num) {
|
||||
if (s_stopped_tgwdt_bmap & BIT(tg_num)) {
|
||||
mwdt_ll_write_protect_disable(TIMER_LL_GET_HW(tg_num));
|
||||
mwdt_ll_enable(TIMER_LL_GET_HW(tg_num));
|
||||
mwdt_ll_write_protect_enable(TIMER_LL_GET_HW(tg_num));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
// [refactor-todo] provide target logic for body of uart functions below
|
||||
static void IRAM_ATTR flush_uarts(void)
|
||||
{
|
||||
@@ -817,11 +872,6 @@ static esp_err_t IRAM_ATTR esp_sleep_start(uint32_t pd_flags, esp_sleep_mode_t m
|
||||
}
|
||||
}
|
||||
|
||||
#if CONFIG_ESP_SLEEP_SYSTIMER_STALL_WORKAROUND
|
||||
if (!(pd_flags & RTC_SLEEP_PD_XTAL)) {
|
||||
rtc_sleep_systimer_enable(false);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (should_skip_sleep) {
|
||||
result = ESP_ERR_SLEEP_REJECT;
|
||||
@@ -857,6 +907,7 @@ static esp_err_t IRAM_ATTR esp_sleep_start(uint32_t pd_flags, esp_sleep_mode_t m
|
||||
#endif
|
||||
#endif // SOC_PM_SUPPORT_DEEPSLEEP_CHECK_STUB_ONLY
|
||||
} else {
|
||||
suspend_timers(pd_flags);
|
||||
/* Cache Suspend 1: will wait cache idle in cache suspend to avoid cache load wrong data after spi io isolation */
|
||||
suspend_cache();
|
||||
/* On esp32c6, only the lp_aon pad hold function can only hold the GPIO state in the active mode.
|
||||
@@ -894,13 +945,8 @@ static esp_err_t IRAM_ATTR esp_sleep_start(uint32_t pd_flags, esp_sleep_mode_t m
|
||||
#endif
|
||||
/* Cache Resume 1: Resume cache for continue running*/
|
||||
resume_cache();
|
||||
resume_timers(pd_flags);
|
||||
}
|
||||
|
||||
#if CONFIG_ESP_SLEEP_SYSTIMER_STALL_WORKAROUND
|
||||
if (!(pd_flags & RTC_SLEEP_PD_XTAL)) {
|
||||
rtc_sleep_systimer_enable(true);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if CONFIG_ESP_SLEEP_CACHE_SAFE_ASSERTION
|
||||
|
Reference in New Issue
Block a user