fix(phy): add fe dependency when enable rf with regdma

This commit is contained in:
cjin
2026-08-03 10:21:32 +08:00
parent 6f5e9e7b8e
commit 12474f80a7
6 changed files with 173 additions and 79 deletions
+35 -15
View File
@@ -148,12 +148,15 @@ const esp_phy_init_data_t phy_init_data= { {
const char __attribute__((section(".rodata"))) phy_init_magic_post[] = PHY_INIT_MAGIC;
#if SOC_PM_MODEM_RETENTION_BY_REGDMA && CONFIG_MAC_BB_PD
#if SOC_PM_MODEM_RETENTION_BY_REGDMA && (CONFIG_MAC_BB_PD || CONFIG_ESP_PHY_HW_SWITCH_RF)
#include "esp_private/sleep_retention.h"
static const char* TAG = "phy_sleep";
static _lock_t s_phy_fe_retention_lock;
uint8_t s_phy_fe_retention_ref = 0;
#endif // SOC_PM_MODEM_RETENTION_BY_REGDMA && (CONFIG_MAC_BB_PD || CONFIG_ESP_PHY_HW_SWITCH_RF)
#if SOC_PM_MODEM_RETENTION_BY_REGDMA && CONFIG_MAC_BB_PD
static esp_err_t sleep_retention_wifi_bb_init(void *arg)
{
#define N_REGS_WIFI_AGC() (121)
@@ -223,7 +226,9 @@ void esp_phy_sleep_data_deinit(void)
ESP_LOGW(TAG, "WiFi BB sleep retention deinit failed");
}
}
#endif // SOC_PM_MODEM_RETENTION_BY_REGDMA && CONFIG_MAC_BB_PD
#if SOC_PM_MODEM_RETENTION_BY_REGDMA && (CONFIG_MAC_BB_PD || CONFIG_ESP_PHY_HW_SWITCH_RF)
static esp_err_t sleep_retention_phy_fe_init(void *arg)
{
#define N_REGS_FE_COEX() (58)
@@ -238,25 +243,40 @@ static esp_err_t sleep_retention_phy_fe_init(void *arg)
return ESP_OK;
}
void esp_phy_fe_sleep_data_init(void)
esp_err_t esp_phy_fe_sleep_data_init(void)
{
sleep_retention_module_init_param_t init_param = {
.cbs = { .create = { .handle = sleep_retention_phy_fe_init, .arg = NULL } },
.attribute = SLEEP_RETENTION_MODULE_ATTR_PASSIVE | SLEEP_RETENTION_MODULE_ATTR_ATTACH
};
esp_err_t err = sleep_retention_module_init(SLEEP_RETENTION_MODULE_PHY_FE, &init_param);
if (err != ESP_OK) {
ESP_LOGW(TAG, "PHY FE sleep retention init failed");
return;
_lock_acquire(&s_phy_fe_retention_lock);
if (s_phy_fe_retention_ref++ == 0) {
sleep_retention_module_init_param_t init_param = {
.cbs = { .create = { .handle = sleep_retention_phy_fe_init, .arg = NULL } },
.attribute = SLEEP_RETENTION_MODULE_ATTR_PASSIVE | SLEEP_RETENTION_MODULE_ATTR_ATTACH
};
esp_err_t err = sleep_retention_module_init(SLEEP_RETENTION_MODULE_PHY_FE, &init_param);
if (err != ESP_OK) {
ESP_LOGW(TAG, "PHY FE sleep retention init failed");
s_phy_fe_retention_ref --;
_lock_release(&s_phy_fe_retention_lock);
return err;
}
}
_lock_release(&s_phy_fe_retention_lock);
return ESP_OK;
}
void esp_phy_fe_sleep_data_deinit(void)
{
esp_err_t err = sleep_retention_module_deinit(SLEEP_RETENTION_MODULE_PHY_FE);
if (err != ESP_OK) {
ESP_LOGW(TAG, "PHY FE sleep retention deinit failed");
_lock_acquire(&s_phy_fe_retention_lock);
if (s_phy_fe_retention_ref == 0) {
_lock_release(&s_phy_fe_retention_lock);
return;
}
if (--s_phy_fe_retention_ref == 0) {
esp_err_t err = sleep_retention_module_deinit(SLEEP_RETENTION_MODULE_PHY_FE);
if (err != ESP_OK) {
ESP_LOGW(TAG, "PHY FE sleep retention deinit failed");
}
}
_lock_release(&s_phy_fe_retention_lock);
}
#endif // SOC_PM_MODEM_RETENTION_BY_REGDMA && CONFIG_MAC_BB_PD
#endif // SOC_PM_MODEM_RETENTION_BY_REGDMA && (CONFIG_MAC_BB_PD || CONFIG_ESP_PHY_HW_SWITCH_RF)