mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-01 18:50:34 +03:00
change(esp_hw_support): do timergroup watchdogs retention by needs
This commit is contained in:
@@ -674,8 +674,19 @@ FORCE_INLINE_ATTR void misc_modules_sleep_prepare(bool deep_sleep)
|
||||
/**
|
||||
* These save-restore workaround should be moved to lower layer
|
||||
*/
|
||||
FORCE_INLINE_ATTR void misc_modules_wake_prepare(void)
|
||||
FORCE_INLINE_ATTR void misc_modules_wake_prepare(uint32_t pd_flags)
|
||||
{
|
||||
#if CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP
|
||||
if (pd_flags & PMU_SLEEP_PD_TOP) {
|
||||
// There is no driver to manage the flashboot watchdog, and it is definitely be in off state when
|
||||
// the system is running, after waking up from pd_top sleep, shut it down by software here.
|
||||
wdt_hal_context_t mwdt_ctx = {.inst = WDT_MWDT0, .mwdt_dev = &TIMERG0};
|
||||
wdt_hal_write_protect_disable(&mwdt_ctx);
|
||||
wdt_hal_set_flashboot_en(&mwdt_ctx, false);
|
||||
wdt_hal_write_protect_enable(&mwdt_ctx);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if SOC_USB_SERIAL_JTAG_SUPPORTED && !SOC_USB_SERIAL_JTAG_SUPPORT_LIGHT_SLEEP
|
||||
sleep_console_usj_pad_restore();
|
||||
#endif
|
||||
@@ -1043,7 +1054,7 @@ static esp_err_t IRAM_ATTR esp_sleep_start(uint32_t pd_flags, esp_sleep_mode_t m
|
||||
sleep_retention_do_system_retention(false);
|
||||
}
|
||||
#endif
|
||||
misc_modules_wake_prepare();
|
||||
misc_modules_wake_prepare(pd_flags);
|
||||
}
|
||||
|
||||
#if SOC_SPI_MEM_SUPPORT_TIMING_TUNING
|
||||
|
||||
@@ -57,14 +57,6 @@ static __attribute__((unused)) esp_err_t sleep_sys_periph_uart0_retention_init(v
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static __attribute__((unused)) esp_err_t sleep_sys_periph_tg0_retention_init(void *arg)
|
||||
{
|
||||
esp_err_t err = sleep_retention_entries_create(tg_regs_retention, ARRAY_SIZE(tg_regs_retention), REGDMA_LINK_PRI_SYS_PERIPH_LOW, SLEEP_RETENTION_MODULE_SYS_PERIPH);
|
||||
ESP_RETURN_ON_ERROR(err, TAG, "failed to allocate memory for digital peripherals (%s) retention", "Timer Group");
|
||||
ESP_LOGD(TAG, "Timer Group sleep retention initialization");
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static __attribute__((unused)) esp_err_t sleep_sys_periph_iomux_retention_init(void *arg)
|
||||
{
|
||||
esp_err_t err = sleep_retention_entries_create(iomux_regs_retention, ARRAY_SIZE(iomux_regs_retention), REGDMA_LINK_PRI_SYS_PERIPH_LOW, SLEEP_RETENTION_MODULE_SYS_PERIPH);
|
||||
@@ -126,8 +118,6 @@ static __attribute__((unused)) esp_err_t sleep_sys_periph_retention_init(void *a
|
||||
#endif
|
||||
err = sleep_sys_periph_uart0_retention_init(arg);
|
||||
if(err) goto error;
|
||||
err = sleep_sys_periph_tg0_retention_init(arg);
|
||||
if(err) goto error;
|
||||
err = sleep_sys_periph_iomux_retention_init(arg);
|
||||
if(err) goto error;
|
||||
err = sleep_sys_periph_spimem_retention_init(arg);
|
||||
@@ -147,9 +137,7 @@ bool peripheral_domain_pd_allowed(void)
|
||||
#if CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP
|
||||
const uint32_t inited_modules = sleep_retention_get_inited_modules();
|
||||
const uint32_t created_modules = sleep_retention_get_created_modules();
|
||||
const uint32_t mask = (const uint32_t) (BIT(SLEEP_RETENTION_MODULE_SYS_PERIPH));
|
||||
|
||||
return ((inited_modules & mask) == (created_modules & mask));
|
||||
return (((inited_modules ^ created_modules) & TOP_DOMAIN_PERIPHERALS_BM) == 0);
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user