diff --git a/components/esp_hw_support/include/esp_private/esp_pau.h b/components/esp_hw_support/include/esp_private/esp_pau.h index f82d0f7dbbe..6617b244995 100644 --- a/components/esp_hw_support/include/esp_private/esp_pau.h +++ b/components/esp_hw_support/include/esp_private/esp_pau.h @@ -26,11 +26,13 @@ extern "C" { void pau_regdma_set_entry_link_addr(pau_regdma_link_addr_t *link_entries); #if SOC_PM_SUPPORT_PMU_MODEM_STATE +#if SOC_PM_PAU_REGDMA_LINK_MODEM /** * @brief Set the address of WiFi MAC REGDMA Link in modem state * @param link_addr linked lists address */ void pau_regdma_set_modem_link_addr(void *link_addr); +#endif // SOC_PM_PAU_REGDMA_LINK_MODEM /** * @brief Software trigger regdma to perform modem link backup 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 5e6aa72fa3f..03d7437159a 100644 --- a/components/esp_hw_support/include/esp_private/sleep_modem.h +++ b/components/esp_hw_support/include/esp_private/sleep_modem.h @@ -227,7 +227,7 @@ void sleep_modem_wifi_modem_state_deinit(void); bool sleep_modem_wifi_modem_state_skip_light_sleep(void); /** - * @brief Function to initialize and create the modem state phy link + * @brief Function to initialize and create the phy link * @param link_head the pointer that point to the head of the created phy link * @return * - ESP_OK on success @@ -235,24 +235,24 @@ bool sleep_modem_wifi_modem_state_skip_light_sleep(void); * - ESP_ERR_INVALID_ARG if value is out of range * - ESP_ERR_INVALID_STATE if the phy module retention state is invalid */ -esp_err_t sleep_modem_state_phy_link_init(void **link_head); +esp_err_t sleep_phy_link_init(void **link_head); /** - * @brief Function to destroy and de-initialize modem state phy link + * @brief Function to destroy and de-initialize phy link * @param link_head the phy link head will be destroyed * @return * - ESP_OK on success * - ESP_ERR_INVALID_ARG if value is out of range * - ESP_ERR_INVALID_STATE if the phy module retention state is invalid */ -esp_err_t sleep_modem_state_phy_link_deinit(void *link_head); +esp_err_t sleep_phy_link_deinit(void *link_head); /** * @brief Function to configure PHY link regdma description at runtime * @param link_context PHY link regdma description conteoxt pointer * @param flags A bitmap to indicate the PHY link regdma description configuration flag */ -void sleep_modem_state_phy_link_config(void *link_context, uint32_t flags); +void sleep_phy_link_config(void *link_context, uint32_t flags); #endif #ifdef __cplusplus diff --git a/components/esp_hw_support/lowpower/CMakeLists.txt b/components/esp_hw_support/lowpower/CMakeLists.txt index 0fb1e23e53b..a45919a3e27 100644 --- a/components/esp_hw_support/lowpower/CMakeLists.txt +++ b/components/esp_hw_support/lowpower/CMakeLists.txt @@ -38,7 +38,7 @@ if((CONFIG_SOC_PM_SUPPORT_MODEM_PD OR CONFIG_SOC_PM_SUPPORT_TOP_PD) AND CONFIG_S endif() if(CONFIG_SOC_PM_SUPPORT_PMU_MODEM_STATE) - list(APPEND srcs "port/${target}/sleep_modem_state.c") + list(APPEND srcs "port/${target}/sleep_phy.c") endif() add_prefix(srcs "${CMAKE_CURRENT_LIST_DIR}/" "${srcs}") diff --git a/components/esp_hw_support/lowpower/port/esp32c5/sleep_modem_state.c b/components/esp_hw_support/lowpower/port/esp32c5/sleep_phy.c similarity index 95% rename from components/esp_hw_support/lowpower/port/esp32c5/sleep_modem_state.c rename to components/esp_hw_support/lowpower/port/esp32c5/sleep_phy.c index d754172e00d..72b0879912a 100644 --- a/components/esp_hw_support/lowpower/port/esp32c5/sleep_modem_state.c +++ b/components/esp_hw_support/lowpower/port/esp32c5/sleep_phy.c @@ -45,7 +45,7 @@ typedef struct { void *regdma_desc[DESC_IDX_I2C_MST_DIS + 1]; } sleep_modem_state_phy_link_context_t; -static esp_err_t sleep_modem_state_phy_wifi_init(void *arg) +static esp_err_t sleep_phy_retention_init(void *arg) { #define WIFIMAC_ENTRY() (BIT(SOC_PM_PAU_REGDMA_LINK_IDX_WIFIMAC)) @@ -96,12 +96,12 @@ static esp_err_t sleep_modem_state_phy_wifi_init(void *arg) } #endif -esp_err_t sleep_modem_state_phy_link_init(void **link_head) +esp_err_t sleep_phy_link_init(void **link_context) { esp_err_t err = ESP_OK; #if SOC_PM_PAU_REGDMA_LINK_IDX_WIFIMAC - sleep_retention_module_init_param_t init_param = { .cbs = { .create = { .handle = sleep_modem_state_phy_wifi_init, .arg = NULL } } }; + sleep_retention_module_init_param_t init_param = { .cbs = { .create = { .handle = sleep_phy_retention_init, .arg = NULL } } }; err = sleep_retention_module_init(SLEEP_RETENTION_MODULE_MODEM_PHY, &init_param); if (err == ESP_OK) { err = sleep_retention_module_allocate(SLEEP_RETENTION_MODULE_MODEM_PHY); @@ -118,7 +118,7 @@ esp_err_t sleep_modem_state_phy_link_init(void **link_head) } } if (err == ESP_OK) { - *link_head = (void *)&phy_link_context; + *link_context = (void *)&phy_link_context; } } } @@ -126,7 +126,7 @@ esp_err_t sleep_modem_state_phy_link_init(void **link_head) return err; } -void IRAM_ATTR sleep_modem_state_phy_link_config(void *link_context, uint32_t flags) +void IRAM_ATTR sleep_phy_link_config(void *link_context, uint32_t flags) { #if SOC_PM_PAU_REGDMA_LINK_IDX_WIFIMAC sleep_modem_state_phy_link_context_t *phy_link_context = (sleep_modem_state_phy_link_context_t *)link_context; @@ -141,7 +141,7 @@ void IRAM_ATTR sleep_modem_state_phy_link_config(void *link_context, uint32_t fl #endif } -esp_err_t sleep_modem_state_phy_link_deinit(void *link_head) +esp_err_t sleep_phy_link_deinit(void *link_head) { esp_err_t err = ESP_OK; #if SOC_PM_PAU_REGDMA_LINK_IDX_WIFIMAC diff --git a/components/esp_hw_support/lowpower/port/esp32c6/sleep_modem_state.c b/components/esp_hw_support/lowpower/port/esp32c6/sleep_phy.c similarity index 90% rename from components/esp_hw_support/lowpower/port/esp32c6/sleep_modem_state.c rename to components/esp_hw_support/lowpower/port/esp32c6/sleep_phy.c index 24ae81a91df..69d6b4286eb 100644 --- a/components/esp_hw_support/lowpower/port/esp32c6/sleep_modem_state.c +++ b/components/esp_hw_support/lowpower/port/esp32c6/sleep_phy.c @@ -40,14 +40,14 @@ typedef struct { #define DESC_IDX_I2C_MST_SEL (1) #define DESC_IDX_I2C_MST_DIS (2) void *regdma_desc[DESC_IDX_I2C_MST_DIS + 1]; -} sleep_modem_state_phy_link_context_t; +} sleep_phy_link_context_t; -esp_err_t sleep_modem_state_phy_link_init(void **link_head) +esp_err_t sleep_phy_link_init(void **link_head) { esp_err_t err = ESP_OK; -#if SOC_PM_PAU_REGDMA_LINK_WIFIMAC - static regdma_link_config_t wifi_modem_config[] = { +#if SOC_PM_PAU_REGDMA_LINK_MODEM + static regdma_link_config_t phy_modem_config[] = { [0] = REGDMA_LINK_CONTINUOUS_INIT(REGDMA_MODEM_FE_LINK(0), MODEM_FE_DATA_BASE, MODEM_FE_DATA_BASE, 41, 0, 0), [1] = REGDMA_LINK_CONTINUOUS_INIT(REGDMA_MODEM_FE_LINK(1), MODEM_FE_CTRL_BASE, MODEM_FE_CTRL_BASE, 87, 0, 0), @@ -100,12 +100,12 @@ esp_err_t sleep_modem_state_phy_link_init(void **link_head) [38] = REGDMA_LINK_WRITE_INIT(REGDMA_PHY_LINK(0x24), PMU_SLP_WAKEUP_CNTL7_REG, 0x9730000, 0xffff0000, 0, 1) }; extern uint32_t phy_ana_i2c_master_burst_rf_onoff(bool on); - wifi_modem_config[7].write_wait.value = phy_ana_i2c_master_burst_rf_onoff(true); - wifi_modem_config[22].write_wait.value = phy_ana_i2c_master_burst_rf_onoff(false); + phy_modem_config[7].write_wait.value = phy_ana_i2c_master_burst_rf_onoff(true); + phy_modem_config[22].write_wait.value = phy_ana_i2c_master_burst_rf_onoff(false); void *link = NULL; - for (int i = ARRAY_SIZE(wifi_modem_config) - 1; (err == ESP_OK) && (i >= 0); i--) { - void *next = regdma_link_init_safe(&wifi_modem_config[i], false, 0, link); + for (int i = ARRAY_SIZE(phy_modem_config) - 1; (err == ESP_OK) && (i >= 0); i--) { + void *next = regdma_link_init_safe(&phy_modem_config[i], false, 0, link); if (next) { link = next; } else { @@ -117,7 +117,7 @@ esp_err_t sleep_modem_state_phy_link_init(void **link_head) pau_regdma_set_modem_link_addr(link); const int id_array[] = { REGDMA_PHY_LINK(0x00), REGDMA_PHY_LINK(0x01), REGDMA_PHY_LINK(0x1b) }; - static DRAM_ATTR sleep_modem_state_phy_link_context_t phy_link_context; + static DRAM_ATTR sleep_phy_link_context_t phy_link_context; for (int i = 0; (err == ESP_OK) && (i < ARRAY_SIZE(phy_link_context.regdma_desc)); i++) { void *desc = regdma_find_link_by_id(link, 0, id_array[i]); @@ -136,9 +136,9 @@ esp_err_t sleep_modem_state_phy_link_init(void **link_head) return err; } -void IRAM_ATTR sleep_modem_state_phy_link_config(void *link_context, uint32_t flags) +void IRAM_ATTR sleep_phy_link_config(void *link_context, uint32_t flags) { - sleep_modem_state_phy_link_context_t *phy_link_context = (sleep_modem_state_phy_link_context_t *)link_context; + sleep_phy_link_context_t *phy_link_context = (sleep_phy_link_context_t *)link_context; if (flags & BIT(0)) { regdma_link_set_skip_flag(phy_link_context->regdma_desc[DESC_IDX_I2C_MST_ENA], true, true); @@ -151,9 +151,9 @@ void IRAM_ATTR sleep_modem_state_phy_link_config(void *link_context, uint32_t fl } } -esp_err_t sleep_modem_state_phy_link_deinit(void *link_head) +esp_err_t sleep_phy_link_deinit(void *link_head) { -#if SOC_PM_PAU_REGDMA_LINK_WIFIMAC +#if SOC_PM_PAU_REGDMA_LINK_MODEM regdma_link_destroy(((sleep_modem_state_phy_link_context_t *)link_head)->link_head, 0); #endif return ESP_OK; diff --git a/components/esp_hw_support/lowpower/port/esp32c61/sleep_modem_state.c b/components/esp_hw_support/lowpower/port/esp32c61/sleep_phy.c similarity index 96% rename from components/esp_hw_support/lowpower/port/esp32c61/sleep_modem_state.c rename to components/esp_hw_support/lowpower/port/esp32c61/sleep_phy.c index cb3623011c2..3205314f40c 100644 --- a/components/esp_hw_support/lowpower/port/esp32c61/sleep_modem_state.c +++ b/components/esp_hw_support/lowpower/port/esp32c61/sleep_phy.c @@ -39,7 +39,7 @@ typedef struct { void *regdma_desc[DESC_IDX_I2C_MST_DIS + 1]; } sleep_modem_state_phy_link_context_t; -esp_err_t sleep_modem_state_phy_link_init(void **link_head) +esp_err_t sleep_phy_link_init(void **link_context) { esp_err_t err = ESP_OK; @@ -124,14 +124,14 @@ esp_err_t sleep_modem_state_phy_link_init(void **link_head) } if (err == ESP_OK) { phy_link_context.link_head = link; - *link_head = (void *)&phy_link_context; + *link_context = (void *)&phy_link_context; } } #endif return err; } -void IRAM_ATTR sleep_modem_state_phy_link_config(void *link_context, uint32_t flags) +void IRAM_ATTR sleep_phy_link_config(void *link_context, uint32_t flags) { sleep_modem_state_phy_link_context_t *phy_link_context = (sleep_modem_state_phy_link_context_t *)link_context; @@ -144,10 +144,10 @@ void IRAM_ATTR sleep_modem_state_phy_link_config(void *link_context, uint32_t fl } } -esp_err_t sleep_modem_state_phy_link_deinit(void *link_head) +esp_err_t sleep_phy_link_deinit(void *link_context) { #if SOC_PM_PAU_REGDMA_LINK_WIFIMAC - regdma_link_destroy(((sleep_modem_state_phy_link_context_t *)link_head)->link_head, 0); + regdma_link_destroy(((sleep_modem_state_phy_link_context_t *)link_context)->link_head, 0); #endif return ESP_OK; } diff --git a/components/esp_hw_support/port/pau_regdma.c b/components/esp_hw_support/port/pau_regdma.c index 4c992d34231..2b0d66aa9dd 100644 --- a/components/esp_hw_support/port/pau_regdma.c +++ b/components/esp_hw_support/port/pau_regdma.c @@ -69,7 +69,7 @@ void pau_regdma_set_entry_link_addr(pau_regdma_link_addr_t *link_entries) } #if SOC_PM_SUPPORT_PMU_MODEM_STATE -#if SOC_PM_PAU_REGDMA_LINK_WIFIMAC +#if SOC_PM_PAU_REGDMA_LINK_MODEM void pau_regdma_set_modem_link_addr(void *link_addr) { pau_hal_set_regdma_modem_link_addr(PAU_instance()->hal, link_addr); diff --git a/components/esp_hw_support/sleep_modem.c b/components/esp_hw_support/sleep_modem.c index 7d4fd527cee..85b84afed2e 100644 --- a/components/esp_hw_support/sleep_modem.c +++ b/components/esp_hw_support/sleep_modem.c @@ -153,7 +153,7 @@ esp_err_t sleep_modem_wifi_modem_state_init(void) void *link = NULL; if (s_sleep_modem.wifi.phy_link == NULL) { - err = sleep_modem_state_phy_link_init(&link); + err = sleep_phy_link_init(&link); if (err == ESP_OK) { s_sleep_modem.wifi.phy_link = link; s_sleep_modem.wifi.flags = 0; @@ -165,7 +165,7 @@ esp_err_t sleep_modem_wifi_modem_state_init(void) __attribute__((unused)) void sleep_modem_wifi_modem_state_deinit(void) { if (s_sleep_modem.wifi.phy_link) { - sleep_modem_state_phy_link_deinit(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; } @@ -173,11 +173,10 @@ __attribute__((unused)) void sleep_modem_wifi_modem_state_deinit(void) void IRAM_ATTR sleep_modem_wifi_do_phy_retention(bool restore) { - sleep_modem_state_phy_link_config(s_sleep_modem.wifi.phy_link, 1); - if (restore) { - pau_regdma_trigger_modem_link_restore(); - } else { - pau_regdma_trigger_modem_link_backup(); + sleep_phy_link_config(s_sleep_modem.wifi.phy_link, 1); + sleep_retention_do_phy_retention(!restore, wifimac_link_is_sel); + sleep_phy_link_config(s_sleep_modem.wifi.phy_link, 0); + if (!restore) { s_sleep_modem.wifi.modem_state_phy_done = 1; } sleep_modem_state_phy_link_config(s_sleep_modem.wifi.phy_link, 0); diff --git a/components/hal/include/hal/pau_hal.h b/components/hal/include/hal/pau_hal.h index 5311e6bc617..37490e3cc9a 100644 --- a/components/hal/include/hal/pau_hal.h +++ b/components/hal/include/hal/pau_hal.h @@ -38,7 +38,7 @@ typedef struct { void pau_hal_set_regdma_entry_link_addr(pau_hal_context_t *hal, pau_regdma_link_addr_t *link_addr); #if SOC_PM_SUPPORT_PMU_MODEM_STATE -#if SOC_PM_PAU_REGDMA_LINK_WIFIMAC +#if SOC_PM_PAU_REGDMA_LINK_MODEM /** * @brief Set regdma modem link address * diff --git a/components/soc/esp32c6/include/soc/Kconfig.soc_caps.in b/components/soc/esp32c6/include/soc/Kconfig.soc_caps.in index 1f3ee7b9f10..5fbeb0d6456 100644 --- a/components/soc/esp32c6/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32c6/include/soc/Kconfig.soc_caps.in @@ -1455,7 +1455,7 @@ config SOC_PM_PAU_REGDMA_LINK_MULTI_ADDR bool default y -config SOC_PM_PAU_REGDMA_LINK_WIFIMAC +config SOC_PM_PAU_REGDMA_LINK_MODEM bool default y diff --git a/components/soc/esp32c6/include/soc/soc_caps.h b/components/soc/esp32c6/include/soc/soc_caps.h index 5999495327f..63813baacf3 100644 --- a/components/soc/esp32c6/include/soc/soc_caps.h +++ b/components/soc/esp32c6/include/soc/soc_caps.h @@ -568,7 +568,7 @@ #define SOC_PM_PAU_LINK_NUM (4) #define SOC_PM_PAU_REGDMA_LINK_MULTI_ADDR (1) -#define SOC_PM_PAU_REGDMA_LINK_WIFIMAC (1) +#define SOC_PM_PAU_REGDMA_LINK_MODEM (1) #define SOC_PM_PAU_REGDMA_UPDATE_CACHE_BEFORE_WAIT_COMPARE (1) #define SOC_PM_PMU_MIN_SLP_SLOW_CLK_CYCLE_FIXED (1) diff --git a/components/soc/esp32h2/include/soc/Kconfig.soc_caps.in b/components/soc/esp32h2/include/soc/Kconfig.soc_caps.in index 028e178dc0c..e9455a8a01b 100644 --- a/components/soc/esp32h2/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32h2/include/soc/Kconfig.soc_caps.in @@ -1415,7 +1415,7 @@ config SOC_PM_PAU_REGDMA_LINK_MULTI_ADDR bool default y -config SOC_PM_PAU_REGDMA_LINK_WIFIMAC +config SOC_PM_PAU_REGDMA_LINK_MODEM bool default y diff --git a/components/soc/esp32h2/include/soc/soc_caps.h b/components/soc/esp32h2/include/soc/soc_caps.h index 7ee548e1b1b..ce6be19ed0d 100644 --- a/components/soc/esp32h2/include/soc/soc_caps.h +++ b/components/soc/esp32h2/include/soc/soc_caps.h @@ -570,7 +570,7 @@ #define SOC_PM_PAU_LINK_NUM (4) #define SOC_PM_PAU_REGDMA_LINK_MULTI_ADDR (1) -#define SOC_PM_PAU_REGDMA_LINK_WIFIMAC (1) +#define SOC_PM_PAU_REGDMA_LINK_MODEM (1) #define SOC_PM_PAU_REGDMA_UPDATE_CACHE_BEFORE_WAIT_COMPARE (1)