From f686c2ef911b8d5627fc0e27d22e66961340dbdb Mon Sep 17 00:00:00 2001 From: cjin Date: Mon, 9 Mar 2026 10:57:10 +0800 Subject: [PATCH] feat(phy): support retention module for phy FE retgisters --- .../include/esp_private/sleep_retention.h | 11 ++++ components/esp_phy/esp32c5/phy_init_data.c | 59 +++++++++++++++---- components/esp_phy/esp32c6/phy_init_data.c | 42 +++++++++++-- components/esp_phy/esp32c61/phy_init_data.c | 59 +++++++++++++++---- components/esp_phy/include/esp_private/phy.h | 15 ++++- components/esp_phy/src/btbb_init.c | 12 ++-- components/esp_phy/src/phy_init.c | 6 +- .../esp32c5/include/soc/Kconfig.soc_caps.in | 2 +- .../include/soc/retention_periph_defs.h | 1 + components/soc/esp32c5/include/soc/soc_caps.h | 2 +- .../include/soc/retention_periph_defs.h | 1 + .../include/soc/retention_periph_defs.h | 1 + 12 files changed, 177 insertions(+), 34 deletions(-) diff --git a/components/esp_hw_support/include/esp_private/sleep_retention.h b/components/esp_hw_support/include/esp_private/sleep_retention.h index 033b0b6f1b6..587ddb1abd8 100644 --- a/components/esp_hw_support/include/esp_private/sleep_retention.h +++ b/components/esp_hw_support/include/esp_private/sleep_retention.h @@ -30,6 +30,17 @@ typedef struct { #define RETENTION_MODULE_BITMAP_INIT(module) { .bitmap[(SLEEP_RETENTION_MODULE_ ## module) >> 5] = BIT((SLEEP_RETENTION_MODULE_ ## module) % 32) } uint32_t bitmap[SLEEP_RETENTION_MODULE_BITMAP_SZ]; } sleep_retention_module_bitmap_t; + +/** + * @brief Set a bit in the retention module bitmap + * + * @param bitmap_ptr Pointer to the bitmap structure + * @param module Module number (e.g., SLEEP_RETENTION_MODULE_SYS_PERIPH) + */ +#define RETENTION_MODULE_BITMAP_SET(bitmap_ptr, module) \ +do { \ + (bitmap_ptr)->bitmap[(module) >> 5] |= BIT((module) % 32); \ +} while (0) typedef regdma_entry_buf_t sleep_retention_entries_t; typedef regdma_entries_config_t sleep_retention_entries_config_t; diff --git a/components/esp_phy/esp32c5/phy_init_data.c b/components/esp_phy/esp32c5/phy_init_data.c index fcf1e743e2b..bf7adc2b7a6 100644 --- a/components/esp_phy/esp32c5/phy_init_data.c +++ b/components/esp_phy/esp32c5/phy_init_data.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2024-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -290,21 +290,13 @@ static esp_err_t sleep_retention_wifi_bb_init(void *arg) #define N_REGS_WIFI_NRX() (145) #define N_REGS_WIFI_BB() (82) #define N_REGS_WIFI_BRX() (39) - #define N_REGS_WIFI_FE_COEX() (21) - #define N_REGS_WIFI_FE_DATA() (35) - #define N_REGS_WIFI_FE_CTRL() (56) - #define N_REGS_WIFI_FE_DATA_WIFI() (22) const static sleep_retention_entries_config_t bb_regs_retention[] = { [0] = { .config = REGDMA_LINK_CONTINUOUS_INIT(0x0b00, 0x600a7000, 0x600a7000, N_REGS_WIFI_AGC(), 0, 0), .owner = BIT(0) | BIT(1) }, /* AGC */ [1] = { .config = REGDMA_LINK_CONTINUOUS_INIT(0x0b01, 0x600a7400, 0x600a7400, N_REGS_WIFI_TX(), 0, 0), .owner = BIT(0) | BIT(1) }, /* TX */ [2] = { .config = REGDMA_LINK_CONTINUOUS_INIT(0x0b02, 0x600a7800, 0x600a7800, N_REGS_WIFI_NRX(), 0, 0), .owner = BIT(0) | BIT(1) }, /* NRX */ [3] = { .config = REGDMA_LINK_CONTINUOUS_INIT(0x0b03, 0x600a7c00, 0x600a7c00, N_REGS_WIFI_BB(), 0, 0), .owner = BIT(0) | BIT(1) }, /* BB */ - [4] = { .config = REGDMA_LINK_CONTINUOUS_INIT(0x0b05, 0x600a0000, 0x600a0000, N_REGS_WIFI_FE_COEX(), 0, 0), .owner = BIT(0) | BIT(1) }, /* FE COEX */ - [5] = { .config = REGDMA_LINK_CONTINUOUS_INIT(0x0b06, 0x600a8000, 0x600a8000, N_REGS_WIFI_BRX(), 0, 0), .owner = BIT(0) | BIT(1) }, /* BRX */ - [6] = { .config = REGDMA_LINK_CONTINUOUS_INIT(0x0b07, 0x600a0400, 0x600a0400, N_REGS_WIFI_FE_DATA(), 0, 0), .owner = BIT(0) | BIT(1) }, /* FE DATA */ - [7] = { .config = REGDMA_LINK_CONTINUOUS_INIT(0x0b08, 0x600a0800, 0x600a0800, N_REGS_WIFI_FE_CTRL(), 0, 0), .owner = BIT(0) | BIT(1) }, /* FE CTRL */ - [8] = { .config = REGDMA_LINK_CONTINUOUS_INIT(0x0b09, 0x600a0c00, 0x600a0c00, N_REGS_WIFI_FE_DATA_WIFI(),0, 0), .owner = BIT(0) | BIT(1) } /* FE WIFI DATA */ + [4] = { .config = REGDMA_LINK_CONTINUOUS_INIT(0x0b04, 0x600a8000, 0x600a8000, N_REGS_WIFI_BRX(), 0, 0), .owner = BIT(0) | BIT(1) }, /* BRX */ }; esp_err_t err = sleep_retention_entries_create(bb_regs_retention, ARRAY_SIZE(bb_regs_retention), 3, SLEEP_RETENTION_MODULE_WIFI_BB); ESP_RETURN_ON_ERROR(err, TAG, "failed to allocate memory for modem (%s) retention", "WiFi BB"); @@ -318,6 +310,7 @@ void esp_phy_sleep_data_init(void) .cbs = { .create = { .handle = sleep_retention_wifi_bb_init, .arg = NULL } }, .depends = RETENTION_MODULE_BITMAP_INIT(CLOCK_MODEM) }; + RETENTION_MODULE_BITMAP_SET(&init_param.depends, SLEEP_RETENTION_MODULE_PHY_FE); esp_err_t err = sleep_retention_module_init(SLEEP_RETENTION_MODULE_WIFI_BB, &init_param); if (err != ESP_OK) { ESP_LOGW(TAG, "WiFi BB sleep retention init failed"); @@ -342,4 +335,48 @@ void esp_phy_sleep_data_deinit(void) } } -#endif /* SOC_PM_MODEM_RETENTION_BY_REGDMA && CONFIG_MAC_BB_PD */ +static esp_err_t sleep_retention_phy_fe_init(void *arg) +{ + #define N_REGS_FE_COEX() (21) + #define N_REGS_FE_DATA() (35) + #define N_REGS_FE_CTRL() (56) + #define N_REGS_FE_DATA_WIFI() (22) + #define REG_FECOEX_BASE 0x600a0000 + #define REG_FEDATA_BASE 0x600a0400 + #define REG_FECTRL_BASE 0x600a0800 + #define REG_FEDATAWIFI_BASE 0x600a0c00 + + const static sleep_retention_entries_config_t phy_fe_regs_retention[] = { + [0] = { .config = REGDMA_LINK_CONTINUOUS_INIT(REGDMA_MODEM_FE_LINK(0), REG_FECOEX_BASE, REG_FECOEX_BASE, N_REGS_FE_COEX(), 0, 0), .owner = BIT(0) | BIT(1) }, /* FE COEX */ + [1] = { .config = REGDMA_LINK_CONTINUOUS_INIT(REGDMA_MODEM_FE_LINK(1), REG_FEDATA_BASE, REG_FEDATA_BASE, N_REGS_FE_DATA(), 0, 0), .owner = BIT(0) | BIT(1) }, /* FE DATA */ + [2] = { .config = REGDMA_LINK_CONTINUOUS_INIT(REGDMA_MODEM_FE_LINK(2), REG_FECTRL_BASE, REG_FECTRL_BASE, N_REGS_FE_CTRL(), 0, 0), .owner = BIT(0) | BIT(1) }, /* FE CTRL */ + [3] = { .config = REGDMA_LINK_CONTINUOUS_INIT(REGDMA_MODEM_FE_LINK(3), REG_FEDATAWIFI_BASE, REG_FEDATAWIFI_BASE, N_REGS_FE_DATA_WIFI(),0, 0), .owner = BIT(0) | BIT(1) } /* FE WIFI DATA */ + }; + esp_err_t err = sleep_retention_entries_create(phy_fe_regs_retention, ARRAY_SIZE(phy_fe_regs_retention), 3, SLEEP_RETENTION_MODULE_PHY_FE); + ESP_RETURN_ON_ERROR(err, TAG, "failed to allocate memory for modem (%s) retention", "PHY FE"); + ESP_LOGD(TAG, "PHY FE sleep retention initialization"); + return ESP_OK; +} + +void 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; + } +} + +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"); + return; + } +} +#endif // SOC_PM_MODEM_RETENTION_BY_REGDMA && CONFIG_MAC_BB_PD diff --git a/components/esp_phy/esp32c6/phy_init_data.c b/components/esp_phy/esp32c6/phy_init_data.c index a32c3c4668d..d7142ccf9c1 100644 --- a/components/esp_phy/esp32c6/phy_init_data.c +++ b/components/esp_phy/esp32c6/phy_init_data.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2016-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2016-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -161,14 +161,12 @@ static esp_err_t sleep_retention_wifi_bb_init(void *arg) #define N_REGS_WIFI_NRX() (136) #define N_REGS_WIFI_BB() (53) #define N_REGS_WIFI_BRX() (39) - #define N_REGS_WIFI_FE_COEX() (58) const static sleep_retention_entries_config_t bb_regs_retention[] = { [0] = { .config = REGDMA_LINK_CONTINUOUS_INIT(0x0b00, 0x600a7000, 0x600a7000, N_REGS_WIFI_AGC(), 0, 0), .owner = BIT(0) | BIT(1) }, /* AGC */ [1] = { .config = REGDMA_LINK_CONTINUOUS_INIT(0x0b01, 0x600a7400, 0x600a7400, N_REGS_WIFI_TX(), 0, 0), .owner = BIT(0) | BIT(1) }, /* TX */ [2] = { .config = REGDMA_LINK_CONTINUOUS_INIT(0x0b02, 0x600a7800, 0x600a7800, N_REGS_WIFI_NRX(), 0, 0), .owner = BIT(0) | BIT(1) }, /* NRX */ [3] = { .config = REGDMA_LINK_CONTINUOUS_INIT(0x0b03, 0x600a7c00, 0x600a7c00, N_REGS_WIFI_BB(), 0, 0), .owner = BIT(0) | BIT(1) }, /* BB */ - [4] = { .config = REGDMA_LINK_CONTINUOUS_INIT(0x0b05, 0x600a0000, 0x600a0000, N_REGS_WIFI_FE_COEX(), 0, 0), .owner = BIT(0) | BIT(1) }, /* FE COEX */ }; esp_err_t err = sleep_retention_entries_create(bb_regs_retention, ARRAY_SIZE(bb_regs_retention), 3, SLEEP_RETENTION_MODULE_WIFI_BB); ESP_RETURN_ON_ERROR(err, TAG, "failed to allocate memory for modem (%s) retention", "WiFi BB"); @@ -182,6 +180,7 @@ void esp_phy_sleep_data_init(void) .cbs = { .create = { .handle = sleep_retention_wifi_bb_init, .arg = NULL } }, .depends = RETENTION_MODULE_BITMAP_INIT(CLOCK_MODEM) }; + RETENTION_MODULE_BITMAP_SET(&init_param.depends, SLEEP_RETENTION_MODULE_PHY_FE); esp_err_t err = sleep_retention_module_init(SLEEP_RETENTION_MODULE_WIFI_BB, &init_param); if (err != ESP_OK) { ESP_LOGW(TAG, "WiFi BB sleep retention init failed"); @@ -206,4 +205,39 @@ void esp_phy_sleep_data_deinit(void) } } -#endif /* SOC_PM_MODEM_RETENTION_BY_REGDMA && CONFIG_MAC_BB_PD */ +static esp_err_t sleep_retention_phy_fe_init(void *arg) +{ + #define N_REGS_FE_COEX() (58) + #define REG_FECOEX_BASE 0x600a0000 + + const static sleep_retention_entries_config_t phy_fe_regs_retention[] = { + [0] = { .config = REGDMA_LINK_CONTINUOUS_INIT(REGDMA_MODEM_FE_LINK(0), REG_FECOEX_BASE, REG_FECOEX_BASE, N_REGS_FE_COEX(), 0, 0), .owner = BIT(0) | BIT(1) }, /* FE COEX */ + }; + esp_err_t err = sleep_retention_entries_create(phy_fe_regs_retention, ARRAY_SIZE(phy_fe_regs_retention), 3, SLEEP_RETENTION_MODULE_PHY_FE); + ESP_RETURN_ON_ERROR(err, TAG, "failed to allocate memory for modem (%s) retention", "PHY FE"); + ESP_LOGD(TAG, "PHY FE sleep retention initialization"); + return ESP_OK; +} + +void 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; + } +} + +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"); + return; + } +} +#endif // SOC_PM_MODEM_RETENTION_BY_REGDMA && CONFIG_MAC_BB_PD diff --git a/components/esp_phy/esp32c61/phy_init_data.c b/components/esp_phy/esp32c61/phy_init_data.c index b06b158688d..beae33d011a 100644 --- a/components/esp_phy/esp32c61/phy_init_data.c +++ b/components/esp_phy/esp32c61/phy_init_data.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2024-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -162,21 +162,13 @@ static esp_err_t sleep_retention_wifi_bb_init(void *arg) #define N_REGS_WIFI_NRX() (145) #define N_REGS_WIFI_BB() (82) #define N_REGS_WIFI_BRX() (39) - #define N_REGS_WIFI_FE_COEX() (21) - #define N_REGS_WIFI_FE_DATA() (34) - #define N_REGS_WIFI_FE_CTRL() (56) - #define N_REGS_WIFI_FE_WIFI() (21) const static sleep_retention_entries_config_t bb_regs_retention[] = { [0] = { .config = REGDMA_LINK_CONTINUOUS_INIT(0x0b00, 0x600a7000, 0x600a7000, N_REGS_WIFI_AGC(), 0, 0), .owner = BIT(0) | BIT(1) }, /* AGC */ [1] = { .config = REGDMA_LINK_CONTINUOUS_INIT(0x0b01, 0x600a7400, 0x600a7400, N_REGS_WIFI_TX(), 0, 0), .owner = BIT(0) | BIT(1) }, /* TX */ [2] = { .config = REGDMA_LINK_CONTINUOUS_INIT(0x0b02, 0x600a7800, 0x600a7800, N_REGS_WIFI_NRX(), 0, 0), .owner = BIT(0) | BIT(1) }, /* NRX */ [3] = { .config = REGDMA_LINK_CONTINUOUS_INIT(0x0b03, 0x600a7c00, 0x600a7c00, N_REGS_WIFI_BB(), 0, 0), .owner = BIT(0) | BIT(1) }, /* BB */ - [4] = { .config = REGDMA_LINK_CONTINUOUS_INIT(0x0b05, 0x600a0000, 0x600a0000, N_REGS_WIFI_FE_COEX(), 0, 0), .owner = BIT(0) | BIT(1) }, /* FE COEX */ - [5] = { .config = REGDMA_LINK_CONTINUOUS_INIT(0x0b06, 0x600a8000, 0x600a8000, N_REGS_WIFI_BRX(), 0, 0), .owner = BIT(0) | BIT(1) }, /* BRX */ - [6] = { .config = REGDMA_LINK_CONTINUOUS_INIT(0x0b07, 0x600a0400, 0x600a0400, N_REGS_WIFI_FE_DATA(), 0, 0), .owner = BIT(0) | BIT(1) }, /* FE DATA */ - [7] = { .config = REGDMA_LINK_CONTINUOUS_INIT(0x0b08, 0x600a0800, 0x600a0800, N_REGS_WIFI_FE_CTRL(), 0, 0), .owner = BIT(0) | BIT(1) }, /* FE CTRL */ - [8] = { .config = REGDMA_LINK_CONTINUOUS_INIT(0x0b09, 0x600a0c00, 0x600a0c00, N_REGS_WIFI_FE_WIFI(), 0, 0), .owner = BIT(0) | BIT(1) } /* FE WiFi DATA */ + [4] = { .config = REGDMA_LINK_CONTINUOUS_INIT(0x0b04, 0x600a8000, 0x600a8000, N_REGS_WIFI_BRX(), 0, 0), .owner = BIT(0) | BIT(1) }, /* BRX */ }; esp_err_t err = sleep_retention_entries_create(bb_regs_retention, ARRAY_SIZE(bb_regs_retention), 3, SLEEP_RETENTION_MODULE_WIFI_BB); ESP_RETURN_ON_ERROR(err, TAG, "failed to allocate memory for modem (%s) retention", "WiFi BB"); @@ -190,6 +182,7 @@ void esp_phy_sleep_data_init(void) .cbs = { .create = { .handle = sleep_retention_wifi_bb_init, .arg = NULL } }, .depends = RETENTION_MODULE_BITMAP_INIT(CLOCK_MODEM) }; + RETENTION_MODULE_BITMAP_SET(&init_param.depends, SLEEP_RETENTION_MODULE_PHY_FE); esp_err_t err = sleep_retention_module_init(SLEEP_RETENTION_MODULE_WIFI_BB, &init_param); if (err != ESP_OK) { ESP_LOGW(TAG, "WiFi BB sleep retention init failed"); @@ -214,4 +207,48 @@ void esp_phy_sleep_data_deinit(void) } } -#endif /* SOC_PM_MODEM_RETENTION_BY_REGDMA && CONFIG_MAC_BB_PD */ +static esp_err_t sleep_retention_phy_fe_init(void *arg) +{ + #define N_REGS_FE_COEX() (21) + #define N_REGS_FE_DATA() (34) + #define N_REGS_FE_CTRL() (56) + #define N_REGS_FE_DATA_WIFI() (21) + #define REG_FECOEX_BASE 0x600a0000 + #define REG_FEDATA_BASE 0x600a0400 + #define REG_FECTRL_BASE 0x600a0800 + #define REG_FEDATAWIFI_BASE 0x600a0c00 + + const static sleep_retention_entries_config_t phy_fe_regs_retention[] = { + [0] = { .config = REGDMA_LINK_CONTINUOUS_INIT(REGDMA_MODEM_FE_LINK(0), REG_FECOEX_BASE, REG_FECOEX_BASE, N_REGS_FE_COEX(), 0, 0), .owner = BIT(0) | BIT(1) }, /* FE COEX */ + [1] = { .config = REGDMA_LINK_CONTINUOUS_INIT(REGDMA_MODEM_FE_LINK(1), REG_FEDATA_BASE, REG_FEDATA_BASE, N_REGS_FE_DATA(), 0, 0), .owner = BIT(0) | BIT(1) }, /* FE DATA */ + [2] = { .config = REGDMA_LINK_CONTINUOUS_INIT(REGDMA_MODEM_FE_LINK(2), REG_FECTRL_BASE, REG_FECTRL_BASE, N_REGS_FE_CTRL(), 0, 0), .owner = BIT(0) | BIT(1) }, /* FE CTRL */ + [3] = { .config = REGDMA_LINK_CONTINUOUS_INIT(REGDMA_MODEM_FE_LINK(3), REG_FEDATAWIFI_BASE, REG_FEDATAWIFI_BASE, N_REGS_FE_DATA_WIFI(),0, 0), .owner = BIT(0) | BIT(1) } /* FE WIFI DATA */ + }; + esp_err_t err = sleep_retention_entries_create(phy_fe_regs_retention, ARRAY_SIZE(phy_fe_regs_retention), 3, SLEEP_RETENTION_MODULE_PHY_FE); + ESP_RETURN_ON_ERROR(err, TAG, "failed to allocate memory for modem (%s) retention", "PHY FE"); + ESP_LOGD(TAG, "PHY FE sleep retention initialization"); + return ESP_OK; +} + +void 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; + } +} + +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"); + return; + } +} +#endif // SOC_PM_MODEM_RETENTION_BY_REGDMA && CONFIG_MAC_BB_PD diff --git a/components/esp_phy/include/esp_private/phy.h b/components/esp_phy/include/esp_private/phy.h index ed9a51f737d..68d1c103d0e 100644 --- a/components/esp_phy/include/esp_private/phy.h +++ b/components/esp_phy/include/esp_private/phy.h @@ -257,7 +257,7 @@ void esp_phy_modem_rf_flag_update(void); #if SOC_PM_MODEM_RETENTION_BY_REGDMA && CONFIG_MAC_BB_PD /** - * @brief PHY module sleep data (includes AGC, TX, NRX, BB, FE, etc..) initialize. + * @brief PHY module sleep data (includes AGC, TX, NRX, BB, etc..) initialize. */ void esp_phy_sleep_data_init(void); @@ -282,6 +282,19 @@ void phy_wait_freq_hw_hop_done(void); */ void phy_track_temp_debug(uint8_t debug_flag, uint8_t track_temp); #endif +#if SOC_PM_MODEM_RETENTION_BY_REGDMA && CONFIG_MAC_BB_PD +/** + * @brief PHY module common memory (FE) initialize + * + */ +void esp_phy_fe_sleep_data_init(void); + +/** + * @brief PHY module common memory (FE) de-initialize + * + */ +void esp_phy_fe_sleep_data_deinit(void); +#endif // SOC_PM_MODEM_RETENTION_BY_REGDMA && CONFIG_MAC_BB_PD #if CONFIG_ESP_PHY_MULTIPLE_INIT_DATA_BIN /** diff --git a/components/esp_phy/src/btbb_init.c b/components/esp_phy/src/btbb_init.c index b6d0e82f89b..bee402cefd0 100644 --- a/components/esp_phy/src/btbb_init.c +++ b/components/esp_phy/src/btbb_init.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -21,6 +21,7 @@ static uint8_t s_btbb_access_ref = 0; #if SOC_PM_MODEM_RETENTION_BY_REGDMA && CONFIG_FREERTOS_USE_TICKLESS_IDLE #include "esp_private/sleep_retention.h" #include "btbb_retention_reg.h" +#include "esp_private/phy.h" static const char* TAG = "btbb_init"; #if SOC_PM_RETENTION_HAS_CLOCK_BUG @@ -32,11 +33,14 @@ static const char* TAG = "btbb_init"; static esp_err_t btbb_sleep_retention_init(void *arg) { const static sleep_retention_entries_config_t btbb_regs_retention[] = { - [0] = { .config = REGDMA_LINK_CONTINUOUS_INIT(REGDMA_MODEM_BT_BB_LINK(0x00), BB_PART_0_ADDR, BB_PART_0_ADDR, BB_PART_0_SIZE, 0, 0), .owner = BTBB_LINK_OWNER }, - [1] = { .config = REGDMA_LINK_CONTINUOUS_INIT(REGDMA_MODEM_BT_BB_LINK(0x01), BB_PART_1_ADDR, BB_PART_1_ADDR, BB_PART_1_SIZE, 0, 0), .owner = BTBB_LINK_OWNER }, + { .config = REGDMA_LINK_CONTINUOUS_INIT(REGDMA_MODEM_BT_BB_LINK(0x00), BB_PART_0_ADDR, BB_PART_0_ADDR, BB_PART_0_SIZE, 0, 0), .owner = BTBB_LINK_OWNER }, + { .config = REGDMA_LINK_CONTINUOUS_INIT(REGDMA_MODEM_BT_BB_LINK(0x01), BB_PART_1_ADDR, BB_PART_1_ADDR, BB_PART_1_SIZE, 0, 0), .owner = BTBB_LINK_OWNER }, #if BB_PART_CNT > 2 - [2] = { .config = REGDMA_LINK_CONTINUOUS_INIT(REGDMA_MODEM_BT_BB_LINK(0x02), BB_PART_2_ADDR, BB_PART_2_ADDR, BB_PART_2_SIZE, 0, 0), .owner = BTBB_LINK_OWNER }, + { .config = REGDMA_LINK_CONTINUOUS_INIT(REGDMA_MODEM_BT_BB_LINK(0x02), BB_PART_2_ADDR, BB_PART_2_ADDR, BB_PART_2_SIZE, 0, 0), .owner = BTBB_LINK_OWNER }, #endif // BB_PART_CNT > 2 +#if BB_PART_CNT > 3 + { .config = REGDMA_LINK_CONTINUOUS_INIT(REGDMA_MODEM_BT_BB_LINK(0x03), BB_PART_3_ADDR, BB_PART_3_ADDR, BB_PART_3_SIZE, 0, 0), .owner = BTBB_LINK_OWNER }, +#endif // BB_PART_CNT > 3 }; esp_err_t err = sleep_retention_entries_create(btbb_regs_retention, ARRAY_SIZE(btbb_regs_retention), REGDMA_LINK_PRI_BT_MAC_BB, SLEEP_RETENTION_MODULE_BT_BB); ESP_RETURN_ON_ERROR(err, TAG, "failed to allocate memory for btbb retention"); diff --git a/components/esp_phy/src/phy_init.c b/components/esp_phy/src/phy_init.c index 078e1abbe7b..2a5905c4adf 100644 --- a/components/esp_phy/src/phy_init.c +++ b/components/esp_phy/src/phy_init.c @@ -529,7 +529,9 @@ void esp_phy_modem_init(uint8_t modem) } #endif // SOC_PM_MODEM_RETENTION_BY_BACKUPDMA #if (SOC_PM_SUPPORT_PMU_MODEM_STATE && CONFIG_ESP_WIFI_ENHANCED_LIGHT_SLEEP) || CONFIG_ESP_PHY_HW_SWITCH_RF - sleep_modem_phy_init(modem); + if (sleep_modem_phy_init(modem) != ESP_OK) { + ESP_LOGE(TAG, "failed to initialize sleep modem phy"); + } #endif // (SOC_PM_SUPPORT_PMU_MODEM_STATE && CONFIG_ESP_WIFI_ENHANCED_LIGHT_SLEEP) || CONFIG_ESP_PHY_HW_SWITCH_RF _lock_release(&s_phy_access_lock); #endif // SOC_PM_MODEM_RETENTION_BY_BACKUPDMA || CONFIG_ESP_WIFI_ENHANCED_LIGHT_SLEEP @@ -584,6 +586,7 @@ void esp_mac_bb_pd_mem_init(void) } _lock_release(&s_phy_access_lock); #elif SOC_PM_MODEM_RETENTION_BY_REGDMA + esp_phy_fe_sleep_data_init(); esp_phy_sleep_data_init(); #endif } @@ -600,6 +603,7 @@ void esp_mac_bb_pd_mem_deinit(void) _lock_release(&s_phy_access_lock); #elif SOC_PM_MODEM_RETENTION_BY_REGDMA esp_phy_sleep_data_deinit(); + esp_phy_fe_sleep_data_deinit(); #endif } diff --git a/components/soc/esp32c5/include/soc/Kconfig.soc_caps.in b/components/soc/esp32c5/include/soc/Kconfig.soc_caps.in index 25921537dc7..829eee5c6f0 100644 --- a/components/soc/esp32c5/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32c5/include/soc/Kconfig.soc_caps.in @@ -1761,7 +1761,7 @@ config SOC_PM_PMU_MIN_SLP_SLOW_CLK_CYCLE_FIXED config SOC_PM_RETENTION_MODULE_NUM int - default 32 + default 40 config SOC_CLK_RC_FAST_SUPPORT_CALIBRATION bool diff --git a/components/soc/esp32c5/include/soc/retention_periph_defs.h b/components/soc/esp32c5/include/soc/retention_periph_defs.h index 4f4daf4e266..6bfdfebb11a 100644 --- a/components/soc/esp32c5/include/soc/retention_periph_defs.h +++ b/components/soc/esp32c5/include/soc/retention_periph_defs.h @@ -55,6 +55,7 @@ typedef enum periph_retention_module { SLEEP_RETENTION_MODULE_BT_BB = 29, SLEEP_RETENTION_MODULE_802154_MAC = 30, SLEEP_RETENTION_MODULE_MODEM_PHY = 31, + SLEEP_RETENTION_MODULE_PHY_FE = 32, SLEEP_RETENTION_MODULE_MAX = SOC_PM_RETENTION_MODULE_NUM - 1 } periph_retention_module_t; diff --git a/components/soc/esp32c5/include/soc/soc_caps.h b/components/soc/esp32c5/include/soc/soc_caps.h index 200cdbba4fb..dc0029ebbdb 100644 --- a/components/soc/esp32c5/include/soc/soc_caps.h +++ b/components/soc/esp32c5/include/soc/soc_caps.h @@ -676,7 +676,7 @@ #define SOC_PM_PMU_MIN_SLP_SLOW_CLK_CYCLE_FIXED (1) -#define SOC_PM_RETENTION_MODULE_NUM (32) +#define SOC_PM_RETENTION_MODULE_NUM (40) /*-------------------------- CLOCK SUBSYSTEM CAPS ----------------------------------------*/ #define SOC_CLK_RC_FAST_SUPPORT_CALIBRATION (1) diff --git a/components/soc/esp32c6/include/soc/retention_periph_defs.h b/components/soc/esp32c6/include/soc/retention_periph_defs.h index 1b30218bbb9..8fc111e4fe7 100644 --- a/components/soc/esp32c6/include/soc/retention_periph_defs.h +++ b/components/soc/esp32c6/include/soc/retention_periph_defs.h @@ -54,6 +54,7 @@ typedef enum periph_retention_module { SLEEP_RETENTION_MODULE_BLE_MAC = 28, SLEEP_RETENTION_MODULE_BT_BB = 29, SLEEP_RETENTION_MODULE_802154_MAC = 30, + SLEEP_RETENTION_MODULE_PHY_FE = 31, SLEEP_RETENTION_MODULE_MAX = SOC_PM_RETENTION_MODULE_NUM - 1 } periph_retention_module_t; diff --git a/components/soc/esp32c61/include/soc/retention_periph_defs.h b/components/soc/esp32c61/include/soc/retention_periph_defs.h index c0922649cae..0af803ece51 100644 --- a/components/soc/esp32c61/include/soc/retention_periph_defs.h +++ b/components/soc/esp32c61/include/soc/retention_periph_defs.h @@ -47,6 +47,7 @@ typedef enum periph_retention_module { SLEEP_RETENTION_MODULE_BLE_MAC = 28, SLEEP_RETENTION_MODULE_BT_BB = 29, SLEEP_RETENTION_MODULE_802154_MAC = 30, + SLEEP_RETENTION_MODULE_PHY_FE = 31, SLEEP_RETENTION_MODULE_MAX = SOC_PM_RETENTION_MODULE_NUM - 1 } periph_retention_module_t;