feat(modem): rename the sleep modem functions

This commit is contained in:
cjin
2025-07-04 17:52:47 +08:00
parent 62397932f9
commit 226f11da96
4 changed files with 43 additions and 43 deletions

View File

@@ -80,26 +80,26 @@ void sleep_modem_mac_bb_power_up_prepare(void);
#if SOC_PM_SUPPORT_PMU_MODEM_STATE
/**
* @brief The retention action in the modem state of WiFi PHY module
* @brief The retention action in the modem state of PHY module
*
* @param restore true for restore the PHY context, false for backup the PHY context
* @param wifimac_link_is_sel true to trigger REGDMA via WiFi MAC link
* @param wifimac_link_is_sel true to trigger REGDMA via PHY link
*/
void sleep_modem_wifi_do_phy_retention(bool restore, bool wifimac_link_is_sel);
void sleep_modem_do_phy_retention(bool restore, bool wifimac_link_is_sel);
/**
* @brief Get WiFi modem state
*
* @return true or false for WiFi modem state is enabled or disabled
*/
bool sleep_modem_wifi_modem_state_enabled(void);
bool sleep_modem_modem_state_enabled(void);
/**
* @brief Get WiFi modem link done state
*
* @return true or false for WiFi modem link can be used to enable RF by REGDMA or can not be used
*/
bool sleep_modem_wifi_modem_link_done(void);
bool sleep_modem_modem_link_done(void);
#endif /* SOC_PM_SUPPORT_PMU_MODEM_STATE */
@@ -201,21 +201,21 @@ void esp_pm_unregister_light_sleep_default_params_config_callback(void);
#if SOC_PM_SUPPORT_PMU_MODEM_STATE
/**
* @brief Init Wi-Fi modem state.
* @brief Init phy link.
*
* This function init wifi modem state.
* This function init phy link.
* @return
* - ESP_OK on success
* - ESP_ERR_NO_MEM if no memory for link
*/
esp_err_t sleep_modem_wifi_modem_state_init(void);
esp_err_t sleep_modem_phy_init(void);
/**
* @brief Deinit Wi-Fi modem state.
* @brief Deinit phy link.
*
* This function deinit wifi modem state.
* This function deinit phy link.
*/
void sleep_modem_wifi_modem_state_deinit(void);
void sleep_modem_phy_deinit(void);
/**
* @brief Function to check Wi-Fi modem state to skip light sleep.

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -136,59 +136,59 @@ typedef struct sleep_modem_config {
void *phy_link;
union {
struct {
uint32_t modem_state_phy_done: 1;
uint32_t phy_link_done: 1;
uint32_t reserved: 31;
};
uint32_t flags;
};
} wifi;
};
} sleep_modem_config_t;
static sleep_modem_config_t s_sleep_modem = { .wifi.phy_link = NULL, .wifi.flags = 0 };
static sleep_modem_config_t s_sleep_modem = { .phy_link = NULL, .flags = 0 };
esp_err_t sleep_modem_wifi_modem_state_init(void)
esp_err_t sleep_modem_phy_init(void)
{
esp_err_t err = ESP_OK;
void *link = NULL;
if (s_sleep_modem.wifi.phy_link == NULL) {
if (s_sleep_modem.phy_link == NULL) {
err = sleep_phy_link_init(&link);
if (err == ESP_OK) {
s_sleep_modem.wifi.phy_link = link;
s_sleep_modem.wifi.flags = 0;
s_sleep_modem.phy_link = link;
s_sleep_modem.flags = 0;
}
}
return err;
}
__attribute__((unused)) void sleep_modem_wifi_modem_state_deinit(void)
__attribute__((unused)) void sleep_modem_phy_deinit(void)
{
if (s_sleep_modem.wifi.phy_link) {
sleep_phy_link_deinit(s_sleep_modem.wifi.phy_link);
s_sleep_modem.wifi.phy_link = NULL;
s_sleep_modem.wifi.flags = 0;
if (s_sleep_modem.phy_link) {
sleep_phy_link_deinit(s_sleep_modem.phy_link);
s_sleep_modem.phy_link = NULL;
s_sleep_modem.flags = 0;
}
}
void IRAM_ATTR sleep_modem_wifi_do_phy_retention(bool restore, bool wifimac_link_is_sel)
void IRAM_ATTR sleep_modem_do_phy_retention(bool restore, bool wifimac_link_is_sel)
{
sleep_phy_link_config(s_sleep_modem.wifi.phy_link, 1);
sleep_phy_link_config(s_sleep_modem.phy_link, 1);
sleep_retention_do_phy_retention(!restore, wifimac_link_is_sel);
sleep_phy_link_config(s_sleep_modem.wifi.phy_link, 0);
sleep_phy_link_config(s_sleep_modem.phy_link, 0);
if (!restore) {
s_sleep_modem.wifi.modem_state_phy_done = 1;
s_sleep_modem.phy_link_done = 1;
}
}
inline __attribute__((always_inline)) bool sleep_modem_wifi_modem_state_enabled(void)
inline __attribute__((always_inline)) bool sleep_modem_phy_link_enabled(void)
{
return (s_sleep_modem.wifi.phy_link != NULL);
return (s_sleep_modem.phy_link != NULL);
}
inline __attribute__((always_inline)) bool sleep_modem_wifi_modem_link_done(void)
inline __attribute__((always_inline)) bool sleep_modem_phy_link_done(void)
{
return (s_sleep_modem.wifi.modem_state_phy_done == 1);
return (s_sleep_modem.phy_link_done == 1);
}
#endif /* SOC_PM_SUPPORT_PMU_MODEM_STATE */
@@ -229,7 +229,7 @@ uint32_t sleep_modem_reject_triggers(void)
{
uint32_t reject_triggers = 0;
#if SOC_PM_SUPPORT_PMU_MODEM_STATE
reject_triggers = (s_sleep_modem.wifi.phy_link != NULL) ? PMU_MODEM_WAKEUP_PROTECT : 0;
reject_triggers = (s_sleep_modem.phy_link != NULL) ? PMU_MODEM_WAKEUP_PROTECT : 0;
#endif
return reject_triggers;
}
@@ -241,7 +241,7 @@ bool IRAM_ATTR sleep_modem_wifi_modem_state_skip_light_sleep(void)
/* To block the system from entering sleep before modem link done. In light
* sleep mode, the system may switch to modem state, which will cause
* hardware to fail to enable RF */
skip = sleep_modem_wifi_modem_state_enabled() && !sleep_modem_wifi_modem_link_done();
skip = sleep_modem_phy_link_enabled() && !sleep_modem_phy_link_done();
#endif
return skip;
}

View File

@@ -344,7 +344,7 @@ void esp_phy_enable(esp_phy_modem_t modem)
#if SOC_PM_SUPPORT_PMU_MODEM_STATE && CONFIG_ESP_WIFI_ENHANCED_LIGHT_SLEEP
bool wifimac_link_is_sel = false;
if (!pm_mac_modem_rf_already_enabled()) {
if (sleep_modem_wifi_modem_state_enabled() && sleep_modem_wifi_modem_link_done()) {
if (sleep_modem_phy_link_enabled() && sleep_modem_phy_link_done()) {
#if SOC_PM_PAU_REGDMA_LINK_IDX_PHY && SOC_PM_PAU_REGDMA_MODEM_WIFIMAC_WORKAROUND
/*
* A race exists between SoC wakeup and modem state sleep. After modem initiates sleep,
@@ -356,9 +356,9 @@ void esp_phy_enable(esp_phy_modem_t modem)
* cleared by regdma closing RF with wifimac link.
* See WIFI-7246 for details.
*/
wifimac_link_is_sel = pm_get_wifimac_regdma_link_selection();
wifimac_link_is_sel = pm_get_wifimac_regdma_link_selection();
#endif
sleep_modem_wifi_do_phy_retention(true, wifimac_link_is_sel);
sleep_modem_do_phy_retention(true, wifimac_link_is_sel);
} else {
phy_wakeup_init();
}
@@ -423,12 +423,12 @@ void esp_phy_disable(esp_phy_modem_t modem)
#endif
#if SOC_PM_SUPPORT_PMU_MODEM_STATE && CONFIG_ESP_WIFI_ENHANCED_LIGHT_SLEEP
pm_mac_modem_clear_rf_power_state();
if (sleep_modem_wifi_modem_state_enabled()) {
bool wifimac_link_is_sel = false;
if (sleep_modem_phy_link_enabled()) {
bool wifimac_link_is_sel = false;
#if SOC_PM_PAU_REGDMA_LINK_IDX_PHY && SOC_PM_PAU_REGDMA_MODEM_WIFIMAC_WORKAROUND
wifimac_link_is_sel = pm_get_wifimac_regdma_link_selection();
#endif
sleep_modem_wifi_do_phy_retention(false, wifimac_link_is_sel);
sleep_modem_do_phy_retention(false, wifimac_link_is_sel);
} else
#endif /* SOC_PM_SUPPORT_PMU_MODEM_STATE && CONFIG_ESP_WIFI_ENHANCED_LIGHT_SLEEP */
{
@@ -506,7 +506,7 @@ void esp_phy_modem_init(void)
}
#endif // SOC_PM_MODEM_RETENTION_BY_BACKUPDMA
#if SOC_PM_SUPPORT_PMU_MODEM_STATE && CONFIG_ESP_WIFI_ENHANCED_LIGHT_SLEEP
sleep_modem_wifi_modem_state_init();
sleep_modem_phy_init();
#endif // CONFIG_ESP_WIFI_ENHANCED_LIGHT_SLEEP
_lock_release(&s_phy_access_lock);
#endif // SOC_PM_MODEM_RETENTION_BY_BACKUPDMA || CONFIG_ESP_WIFI_ENHANCED_LIGHT_SLEEP
@@ -531,7 +531,7 @@ void esp_phy_modem_deinit(void)
#endif // CONFIG_IDF_TARGET_ESP32C3
#endif // SOC_PM_MODEM_RETENTION_BY_BACKUPDMA
#if SOC_PM_SUPPORT_PMU_MODEM_STATE && CONFIG_ESP_WIFI_ENHANCED_LIGHT_SLEEP
sleep_modem_wifi_modem_state_deinit();
sleep_modem_phy_deinit();
#endif // CONFIG_ESP_WIFI_ENHANCED_LIGHT_SLEEP
}
_lock_release(&s_phy_access_lock);

View File

@@ -478,7 +478,7 @@ esp_err_t esp_wifi_init(const wifi_init_config_t *config)
esp_phy_modem_init();
#endif
#if CONFIG_ESP_WIFI_ENHANCED_LIGHT_SLEEP
if (sleep_modem_wifi_modem_state_enabled()) {
if (sleep_modem_phy_link_enabled()) {
esp_pm_register_skip_light_sleep_callback(sleep_modem_wifi_modem_state_skip_light_sleep);
esp_wifi_internal_modem_state_configure(true); /* require WiFi to enable automatically receives the beacon */
#if ESP_MODEM_RF_FLAG_UPDATE_CB_REQUIRED