feat(modem): rename the sleep modem functions

This commit is contained in:
cjin
2026-09-14 19:18:40 +08:00
parent 740bb89567
commit fd844bd2d3
4 changed files with 41 additions and 41 deletions
@@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2015-2026 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
@@ -80,25 +80,25 @@ void sleep_modem_mac_bb_power_up_prepare(void);
#if SOC_PM_SUPPORT_PMU_MODEM_STATE #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 restore true for restore the PHY context, false for backup the PHY context
*/ */
void sleep_modem_wifi_do_phy_retention(bool restore); void sleep_modem_do_phy_retention(bool restore);
/** /**
* @brief Get WiFi modem state * @brief Get WiFi modem state
* *
* @return true or false for WiFi modem state is enabled or disabled * @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 * @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 * @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 */ #endif /* SOC_PM_SUPPORT_PMU_MODEM_STATE */
@@ -200,21 +200,21 @@ void esp_pm_unregister_light_sleep_default_params_config_callback(void);
#if SOC_PM_SUPPORT_PMU_MODEM_STATE #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 * @return
* - ESP_OK on success * - ESP_OK on success
* - ESP_ERR_NO_MEM if no memory for link * - 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. * @brief Function to check Wi-Fi modem state to skip light sleep.
+23 -23
View File
@@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2015-2026 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
@@ -136,60 +136,60 @@ typedef struct sleep_modem_config {
void *phy_link; void *phy_link;
union { union {
struct { struct {
uint32_t modem_state_phy_done: 1; uint32_t phy_link_done: 1;
uint32_t reserved: 31; uint32_t reserved: 31;
}; };
uint32_t flags; uint32_t flags;
}; };
} wifi; };
} sleep_modem_config_t; } 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; esp_err_t err = ESP_OK;
void *link = NULL; void *link = NULL;
if (s_sleep_modem.wifi.phy_link == NULL) { if (s_sleep_modem.phy_link == NULL) {
err = sleep_phy_link_init(&link); err = sleep_phy_link_init(&link);
if (err == ESP_OK) { if (err == ESP_OK) {
s_sleep_modem.wifi.phy_link = link; s_sleep_modem.phy_link = link;
s_sleep_modem.wifi.flags = 0; s_sleep_modem.flags = 0;
} }
} }
return err; 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) { if (s_sleep_modem.phy_link) {
sleep_phy_link_deinit(s_sleep_modem.wifi.phy_link); sleep_phy_link_deinit(s_sleep_modem.phy_link);
s_sleep_modem.wifi.phy_link = NULL; s_sleep_modem.phy_link = NULL;
s_sleep_modem.wifi.flags = 0; s_sleep_modem.flags = 0;
} }
} }
void IRAM_ATTR sleep_modem_wifi_do_phy_retention(bool restore) void IRAM_ATTR sleep_modem_do_phy_retention(bool restore)
{ {
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_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) { if (!restore) {
s_sleep_modem.wifi.modem_state_phy_done = 1; s_sleep_modem.phy_link_done = 1;
} }
sleep_modem_state_phy_link_config(s_sleep_modem.wifi.phy_link, 0); sleep_modem_state_phy_link_config(s_sleep_modem.wifi.phy_link, 0);
} }
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 */ #endif /* SOC_PM_SUPPORT_PMU_MODEM_STATE */
@@ -226,7 +226,7 @@ uint32_t IRAM_ATTR sleep_modem_reject_triggers(void)
{ {
uint32_t reject_triggers = 0; uint32_t reject_triggers = 0;
#if SOC_PM_SUPPORT_PMU_MODEM_STATE #if SOC_PM_SUPPORT_PMU_MODEM_STATE
reject_triggers = (s_sleep_modem.wifi.phy_link != NULL) ? BIT(16) : 0; reject_triggers = (s_sleep_modem.phy_link != NULL) ? BIT(16) : 0;
#endif #endif
return reject_triggers; return reject_triggers;
} }
@@ -238,7 +238,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 /* 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 * sleep mode, the system may switch to modem state, which will cause
* hardware to fail to enable RF */ * 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 #endif
return skip; return skip;
} }
+6 -6
View File
@@ -335,8 +335,8 @@ void esp_phy_enable(esp_phy_modem_t modem)
} else { } else {
#if SOC_PM_SUPPORT_PMU_MODEM_STATE && CONFIG_ESP_WIFI_ENHANCED_LIGHT_SLEEP #if SOC_PM_SUPPORT_PMU_MODEM_STATE && CONFIG_ESP_WIFI_ENHANCED_LIGHT_SLEEP
if (!pm_mac_modem_rf_already_enabled()) { 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()) {
sleep_modem_wifi_do_phy_retention(true); sleep_modem_do_phy_retention(true);
} else { } else {
phy_wakeup_init(); phy_wakeup_init();
} }
@@ -402,8 +402,8 @@ void esp_phy_disable(esp_phy_modem_t modem)
#endif #endif
#if SOC_PM_SUPPORT_PMU_MODEM_STATE && CONFIG_ESP_WIFI_ENHANCED_LIGHT_SLEEP #if SOC_PM_SUPPORT_PMU_MODEM_STATE && CONFIG_ESP_WIFI_ENHANCED_LIGHT_SLEEP
pm_mac_modem_clear_rf_power_state(); pm_mac_modem_clear_rf_power_state();
if (sleep_modem_wifi_modem_state_enabled()) { if (sleep_modem_phy_link_enabled()) {
sleep_modem_wifi_do_phy_retention(false); sleep_modem_do_phy_retention(false);
} else } else
#endif /* SOC_PM_SUPPORT_PMU_MODEM_STATE && CONFIG_ESP_WIFI_ENHANCED_LIGHT_SLEEP */ #endif /* SOC_PM_SUPPORT_PMU_MODEM_STATE && CONFIG_ESP_WIFI_ENHANCED_LIGHT_SLEEP */
{ {
@@ -481,7 +481,7 @@ void esp_phy_modem_init(void)
} }
#endif // SOC_PM_MODEM_RETENTION_BY_BACKUPDMA #endif // SOC_PM_MODEM_RETENTION_BY_BACKUPDMA
#if SOC_PM_SUPPORT_PMU_MODEM_STATE && CONFIG_ESP_WIFI_ENHANCED_LIGHT_SLEEP #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 #endif // CONFIG_ESP_WIFI_ENHANCED_LIGHT_SLEEP
_lock_release(&s_phy_access_lock); _lock_release(&s_phy_access_lock);
#endif // SOC_PM_MODEM_RETENTION_BY_BACKUPDMA || CONFIG_ESP_WIFI_ENHANCED_LIGHT_SLEEP #endif // SOC_PM_MODEM_RETENTION_BY_BACKUPDMA || CONFIG_ESP_WIFI_ENHANCED_LIGHT_SLEEP
@@ -506,7 +506,7 @@ void esp_phy_modem_deinit(void)
#endif // CONFIG_IDF_TARGET_ESP32C3 #endif // CONFIG_IDF_TARGET_ESP32C3
#endif // SOC_PM_MODEM_RETENTION_BY_BACKUPDMA #endif // SOC_PM_MODEM_RETENTION_BY_BACKUPDMA
#if SOC_PM_SUPPORT_PMU_MODEM_STATE && CONFIG_ESP_WIFI_ENHANCED_LIGHT_SLEEP #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 #endif // CONFIG_ESP_WIFI_ENHANCED_LIGHT_SLEEP
} }
_lock_release(&s_phy_access_lock); _lock_release(&s_phy_access_lock);
+1 -1
View File
@@ -427,7 +427,7 @@ esp_err_t esp_wifi_init(const wifi_init_config_t *config)
esp_phy_modem_init(); esp_phy_modem_init();
#endif #endif
#if CONFIG_ESP_WIFI_ENHANCED_LIGHT_SLEEP #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_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 */ esp_wifi_internal_modem_state_configure(true); /* require WiFi to enable automatically receives the beacon */
#if ESP_MODEM_RF_FLAG_UPDATE_CB_REQUIRED #if ESP_MODEM_RF_FLAG_UPDATE_CB_REQUIRED