From fd844bd2d3445e8104b546a6d9402fd5a26c660d Mon Sep 17 00:00:00 2001 From: cjin Date: Fri, 4 Jul 2025 17:52:47 +0800 Subject: [PATCH] feat(modem): rename the sleep modem functions --- .../include/esp_private/sleep_modem.h | 22 ++++----- components/esp_hw_support/sleep_modem.c | 46 +++++++++---------- components/esp_phy/src/phy_init.c | 12 ++--- components/esp_wifi/src/wifi_init.c | 2 +- 4 files changed, 41 insertions(+), 41 deletions(-) diff --git a/components/esp_hw_support/include/esp_private/sleep_modem.h b/components/esp_hw_support/include/esp_private/sleep_modem.h index 1e2749ca49e..f21a97e4661 100644 --- a/components/esp_hw_support/include/esp_private/sleep_modem.h +++ b/components/esp_hw_support/include/esp_private/sleep_modem.h @@ -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 */ @@ -80,25 +80,25 @@ 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 */ -void sleep_modem_wifi_do_phy_retention(bool restore); +void sleep_modem_do_phy_retention(bool restore); /** * @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 */ @@ -200,21 +200,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. diff --git a/components/esp_hw_support/sleep_modem.c b/components/esp_hw_support/sleep_modem.c index 85b84afed2e..1e2b3b6bf7b 100644 --- a/components/esp_hw_support/sleep_modem.c +++ b/components/esp_hw_support/sleep_modem.c @@ -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 */ @@ -136,60 +136,60 @@ 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) +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_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; } 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 */ @@ -226,7 +226,7 @@ uint32_t IRAM_ATTR 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) ? BIT(16) : 0; + reject_triggers = (s_sleep_modem.phy_link != NULL) ? BIT(16) : 0; #endif 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 * 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; } diff --git a/components/esp_phy/src/phy_init.c b/components/esp_phy/src/phy_init.c index 2459da17fb3..ee4139cd244 100644 --- a/components/esp_phy/src/phy_init.c +++ b/components/esp_phy/src/phy_init.c @@ -335,8 +335,8 @@ void esp_phy_enable(esp_phy_modem_t modem) } else { #if SOC_PM_SUPPORT_PMU_MODEM_STATE && CONFIG_ESP_WIFI_ENHANCED_LIGHT_SLEEP if (!pm_mac_modem_rf_already_enabled()) { - if (sleep_modem_wifi_modem_state_enabled() && sleep_modem_wifi_modem_link_done()) { - sleep_modem_wifi_do_phy_retention(true); + if (sleep_modem_phy_link_enabled() && sleep_modem_phy_link_done()) { + sleep_modem_do_phy_retention(true); } else { phy_wakeup_init(); } @@ -402,8 +402,8 @@ 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()) { - sleep_modem_wifi_do_phy_retention(false); + if (sleep_modem_phy_link_enabled()) { + sleep_modem_do_phy_retention(false); } else #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 #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 @@ -506,7 +506,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); diff --git a/components/esp_wifi/src/wifi_init.c b/components/esp_wifi/src/wifi_init.c index 60b256546de..3da83e8079b 100644 --- a/components/esp_wifi/src/wifi_init.c +++ b/components/esp_wifi/src/wifi_init.c @@ -427,7 +427,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