forked from espressif/esp-idf
fix(pm): add mac/bb power down/up prepare for fix esp32c6 pll issue
This commit is contained in:
@@ -40,6 +40,24 @@ void mac_bb_power_up_cb_execute(void);
|
|||||||
|
|
||||||
#endif // CONFIG_MAC_BB_PD
|
#endif // CONFIG_MAC_BB_PD
|
||||||
|
|
||||||
|
#if SOC_PM_RETENTION_HAS_CLOCK_BUG
|
||||||
|
/**
|
||||||
|
* @brief MAC and baseband power down operation
|
||||||
|
*
|
||||||
|
* In light sleep mode, execute IEEE802154/Bluetooth module MAC and baseband
|
||||||
|
* power up and backup prepare operations.
|
||||||
|
*/
|
||||||
|
void mac_bb_power_down_prepare(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief MAC and baseband power up operation
|
||||||
|
*
|
||||||
|
* In light sleep mode, execute IEEE802154/Bluetooth module MAC and baseband
|
||||||
|
* power up and restore prepare operations.
|
||||||
|
*/
|
||||||
|
void mac_bb_power_up_prepare(void);
|
||||||
|
#endif // SOC_PM_RETENTION_HAS_CLOCK_BUG
|
||||||
|
|
||||||
#if SOC_PM_SUPPORT_PMU_MODEM_STATE
|
#if SOC_PM_SUPPORT_PMU_MODEM_STATE
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -390,3 +390,22 @@ static void esp_pm_light_sleep_default_params_config(int min_freq_mhz, int max_f
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if SOC_PM_RETENTION_HAS_CLOCK_BUG
|
||||||
|
static bool s_modem_sleep = false;
|
||||||
|
void IRAM_ATTR mac_bb_power_down_prepare(void)
|
||||||
|
{
|
||||||
|
if (s_modem_sleep == false) {
|
||||||
|
sleep_retention_do_extra_retention(true); // backup
|
||||||
|
s_modem_sleep = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void IRAM_ATTR mac_bb_power_up_prepare(void)
|
||||||
|
{
|
||||||
|
if (s_modem_sleep) {
|
||||||
|
sleep_retention_do_extra_retention(false); // restore
|
||||||
|
s_modem_sleep = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif /* SOC_PM_RETENTION_HAS_CLOCK_BUG */
|
||||||
|
@@ -624,6 +624,14 @@ 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
|
// Will switch to XTAL turn down MSPI speed
|
||||||
mspi_timing_change_speed_mode_cache_safe(true);
|
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
|
// Save current frequency and switch to XTAL
|
||||||
rtc_cpu_freq_config_t cpu_freq_config;
|
rtc_cpu_freq_config_t cpu_freq_config;
|
||||||
rtc_clk_cpu_freq_get_config(&cpu_freq_config);
|
rtc_clk_cpu_freq_get_config(&cpu_freq_config);
|
||||||
|
@@ -505,10 +505,8 @@ uint32_t IRAM_ATTR sleep_retention_get_modules(void)
|
|||||||
#if SOC_PM_RETENTION_HAS_CLOCK_BUG
|
#if SOC_PM_RETENTION_HAS_CLOCK_BUG
|
||||||
void sleep_retention_do_extra_retention(bool backup_or_restore)
|
void sleep_retention_do_extra_retention(bool backup_or_restore)
|
||||||
{
|
{
|
||||||
_lock_acquire_recursive(&s_retention.lock);
|
|
||||||
if (s_retention.highpri < SLEEP_RETENTION_REGDMA_LINK_HIGHEST_PRIORITY ||
|
if (s_retention.highpri < SLEEP_RETENTION_REGDMA_LINK_HIGHEST_PRIORITY ||
|
||||||
s_retention.highpri > SLEEP_RETENTION_REGDMA_LINK_LOWEST_PRIORITY) {
|
s_retention.highpri > SLEEP_RETENTION_REGDMA_LINK_LOWEST_PRIORITY) {
|
||||||
_lock_release_recursive(&s_retention.lock);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const uint32_t clk_bug_modules = SLEEP_RETENTION_MODULE_BLE_MAC | SLEEP_RETENTION_MODULE_802154_MAC;
|
const uint32_t clk_bug_modules = SLEEP_RETENTION_MODULE_BLE_MAC | SLEEP_RETENTION_MODULE_802154_MAC;
|
||||||
@@ -525,7 +523,6 @@ void sleep_retention_do_extra_retention(bool backup_or_restore)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
int refs = s_retention.extra_refs;
|
int refs = s_retention.extra_refs;
|
||||||
_lock_release_recursive(&s_retention.lock);
|
|
||||||
assert(refs >= 0 && refs <= cnt_modules);
|
assert(refs >= 0 && refs <= cnt_modules);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -999,6 +999,11 @@ void IRAM_ATTR esp_pm_impl_isr_hook(void)
|
|||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
leave_idle();
|
leave_idle();
|
||||||
|
/* it is necessary to restore the mac/bb REG before scheduling other tasks in FreeRTOS.*/
|
||||||
|
#if SOC_PM_RETENTION_HAS_CLOCK_BUG
|
||||||
|
mac_bb_power_up_prepare();
|
||||||
|
#endif // SOC_PM_RETENTION_HAS_CLOCK_BUG
|
||||||
|
|
||||||
#endif // CONFIG_FREERTOS_SYSTICK_USES_CCOUNT && portNUM_PROCESSORS == 2
|
#endif // CONFIG_FREERTOS_SYSTICK_USES_CCOUNT && portNUM_PROCESSORS == 2
|
||||||
#if CONFIG_FREERTOS_SMP
|
#if CONFIG_FREERTOS_SMP
|
||||||
portRESTORE_INTERRUPTS(state);
|
portRESTORE_INTERRUPTS(state);
|
||||||
|
Reference in New Issue
Block a user