mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 11:10:54 +03:00
change(esp_wifi): support wifi module retention runtime attach and detach
This commit is contained in:
@@ -142,7 +142,7 @@ ESP_SYSTEM_INIT_FN(sleep_clock_startup_init, SECONDARY, BIT(0), 106)
|
|||||||
{
|
{
|
||||||
sleep_retention_module_init_param_t init_param = {
|
sleep_retention_module_init_param_t init_param = {
|
||||||
.cbs = { .create = { .handle = sleep_clock_system_retention_init, .arg = NULL } },
|
.cbs = { .create = { .handle = sleep_clock_system_retention_init, .arg = NULL } },
|
||||||
.attribute = SLEEP_RETENTION_MODULE_ATTR_PASSIVE
|
.attribute = SLEEP_RETENTION_MODULE_ATTR_PASSIVE | SLEEP_RETENTION_MODULE_ATTR_ATTACH
|
||||||
};
|
};
|
||||||
sleep_retention_module_init(SLEEP_RETENTION_MODULE_CLOCK_SYSTEM, &init_param);
|
sleep_retention_module_init(SLEEP_RETENTION_MODULE_CLOCK_SYSTEM, &init_param);
|
||||||
|
|
||||||
@@ -150,7 +150,7 @@ ESP_SYSTEM_INIT_FN(sleep_clock_startup_init, SECONDARY, BIT(0), 106)
|
|||||||
init_param = (sleep_retention_module_init_param_t) {
|
init_param = (sleep_retention_module_init_param_t) {
|
||||||
.cbs = { .create = { .handle = sleep_clock_modem_retention_init, .arg = NULL } },
|
.cbs = { .create = { .handle = sleep_clock_modem_retention_init, .arg = NULL } },
|
||||||
.depends.bitmap[SLEEP_RETENTION_MODULE_CLOCK_SYSTEM >> 5] = BIT(SLEEP_RETENTION_MODULE_CLOCK_SYSTEM % 32),
|
.depends.bitmap[SLEEP_RETENTION_MODULE_CLOCK_SYSTEM >> 5] = BIT(SLEEP_RETENTION_MODULE_CLOCK_SYSTEM % 32),
|
||||||
.attribute = SLEEP_RETENTION_MODULE_ATTR_PASSIVE
|
.attribute = SLEEP_RETENTION_MODULE_ATTR_PASSIVE | SLEEP_RETENTION_MODULE_ATTR_ATTACH
|
||||||
};
|
};
|
||||||
sleep_retention_module_init(SLEEP_RETENTION_MODULE_CLOCK_MODEM, &init_param);
|
sleep_retention_module_init(SLEEP_RETENTION_MODULE_CLOCK_MODEM, &init_param);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -198,6 +198,7 @@ bool modem_domain_pd_allowed(void)
|
|||||||
#if SOC_PM_MODEM_RETENTION_BY_REGDMA && SOC_PAU_SUPPORTED
|
#if SOC_PM_MODEM_RETENTION_BY_REGDMA && SOC_PAU_SUPPORTED
|
||||||
const sleep_retention_module_bitmap_t inited_modules = sleep_retention_get_inited_modules();
|
const sleep_retention_module_bitmap_t inited_modules = sleep_retention_get_inited_modules();
|
||||||
const sleep_retention_module_bitmap_t created_modules = sleep_retention_get_created_modules();
|
const sleep_retention_module_bitmap_t created_modules = sleep_retention_get_created_modules();
|
||||||
|
const sleep_retention_module_bitmap_t retained_modules = sleep_retention_get_retained_modules();
|
||||||
|
|
||||||
sleep_retention_module_bitmap_t mask = (sleep_retention_module_bitmap_t){ .bitmap = { 0 } };
|
sleep_retention_module_bitmap_t mask = (sleep_retention_module_bitmap_t){ .bitmap = { 0 } };
|
||||||
#if SOC_WIFI_SUPPORTED
|
#if SOC_WIFI_SUPPORTED
|
||||||
@@ -215,7 +216,10 @@ bool modem_domain_pd_allowed(void)
|
|||||||
|
|
||||||
const sleep_retention_module_bitmap_t modem_domain_inited_modules = sleep_retention_module_bitmap_and(inited_modules, mask);
|
const sleep_retention_module_bitmap_t modem_domain_inited_modules = sleep_retention_module_bitmap_and(inited_modules, mask);
|
||||||
const sleep_retention_module_bitmap_t modem_domain_created_modules = sleep_retention_module_bitmap_and(created_modules, mask);
|
const sleep_retention_module_bitmap_t modem_domain_created_modules = sleep_retention_module_bitmap_and(created_modules, mask);
|
||||||
return sleep_retention_module_bitmap_eq(modem_domain_inited_modules, modem_domain_created_modules);
|
const sleep_retention_module_bitmap_t modem_domain_retained_modules = sleep_retention_module_bitmap_and(retained_modules, mask);
|
||||||
|
bool ic = sleep_retention_module_bitmap_eq(modem_domain_inited_modules, modem_domain_created_modules);
|
||||||
|
bool cr = sleep_retention_module_bitmap_eq(modem_domain_created_modules, modem_domain_retained_modules);
|
||||||
|
return ic && cr;
|
||||||
#else
|
#else
|
||||||
return false; /* MODEM power domain is controlled by each module (WiFi, Bluetooth or 15.4) of modem */
|
return false; /* MODEM power domain is controlled by each module (WiFi, Bluetooth or 15.4) of modem */
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -316,6 +316,7 @@ void esp_phy_sleep_data_init(void)
|
|||||||
{
|
{
|
||||||
sleep_retention_module_init_param_t init_param = {
|
sleep_retention_module_init_param_t init_param = {
|
||||||
.cbs = { .create = { .handle = sleep_retention_wifi_bb_init, .arg = NULL } },
|
.cbs = { .create = { .handle = sleep_retention_wifi_bb_init, .arg = NULL } },
|
||||||
|
.attribute = SLEEP_RETENTION_MODULE_ATTR_ATTACH,
|
||||||
.depends = RETENTION_MODULE_BITMAP_INIT(CLOCK_MODEM)
|
.depends = RETENTION_MODULE_BITMAP_INIT(CLOCK_MODEM)
|
||||||
};
|
};
|
||||||
esp_err_t err = sleep_retention_module_init(SLEEP_RETENTION_MODULE_WIFI_BB, &init_param);
|
esp_err_t err = sleep_retention_module_init(SLEEP_RETENTION_MODULE_WIFI_BB, &init_param);
|
||||||
@@ -326,12 +327,22 @@ void esp_phy_sleep_data_init(void)
|
|||||||
err = sleep_retention_module_allocate(SLEEP_RETENTION_MODULE_WIFI_BB);
|
err = sleep_retention_module_allocate(SLEEP_RETENTION_MODULE_WIFI_BB);
|
||||||
if (err != ESP_OK) {
|
if (err != ESP_OK) {
|
||||||
ESP_LOGW(TAG, "failed to allocate sleep retention linked list for wifi bb retention");
|
ESP_LOGW(TAG, "failed to allocate sleep retention linked list for wifi bb retention");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
err = sleep_retention_module_attach(SLEEP_RETENTION_MODULE_WIFI_BB);
|
||||||
|
if (err != ESP_OK) {
|
||||||
|
ESP_LOGW(TAG, "failed to attach sleep retention linked list for wifi bb retention");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void esp_phy_sleep_data_deinit(void)
|
void esp_phy_sleep_data_deinit(void)
|
||||||
{
|
{
|
||||||
esp_err_t err = sleep_retention_module_free(SLEEP_RETENTION_MODULE_WIFI_BB);
|
esp_err_t err = sleep_retention_module_detach(SLEEP_RETENTION_MODULE_WIFI_BB);
|
||||||
|
if (err != ESP_OK) {
|
||||||
|
ESP_LOGW(TAG, "failed to detach sleep retention linked list for wifi bb retention");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
err = sleep_retention_module_free(SLEEP_RETENTION_MODULE_WIFI_BB);
|
||||||
if (err != ESP_OK) {
|
if (err != ESP_OK) {
|
||||||
ESP_LOGW(TAG, "failed to free sleep retention linked list for wifi bb retention");
|
ESP_LOGW(TAG, "failed to free sleep retention linked list for wifi bb retention");
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -162,6 +162,10 @@ static void esp_wifi_mac_pd_mem_init(void)
|
|||||||
if (err != ESP_OK) {
|
if (err != ESP_OK) {
|
||||||
ESP_LOGW(TAG, "failed to allocate sleep retention linked list for wifi mac retention");
|
ESP_LOGW(TAG, "failed to allocate sleep retention linked list for wifi mac retention");
|
||||||
}
|
}
|
||||||
|
err = sleep_retention_module_attach(SLEEP_RETENTION_MODULE_WIFI_MAC);
|
||||||
|
if (err != ESP_OK) {
|
||||||
|
ESP_LOGW(TAG, "failed to attach sleep retention linked list for wifi mac retention");
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
esp_wifi_internal_set_mac_sleep(true);
|
esp_wifi_internal_set_mac_sleep(true);
|
||||||
}
|
}
|
||||||
@@ -169,7 +173,11 @@ static void esp_wifi_mac_pd_mem_deinit(void)
|
|||||||
{
|
{
|
||||||
esp_wifi_internal_set_mac_sleep(false);
|
esp_wifi_internal_set_mac_sleep(false);
|
||||||
#if SOC_PM_MODEM_RETENTION_BY_REGDMA
|
#if SOC_PM_MODEM_RETENTION_BY_REGDMA
|
||||||
esp_err_t err = sleep_retention_module_free(SLEEP_RETENTION_MODULE_WIFI_MAC);
|
esp_err_t err = sleep_retention_module_detach(SLEEP_RETENTION_MODULE_WIFI_MAC);
|
||||||
|
if (err != ESP_OK) {
|
||||||
|
ESP_LOGW(TAG, "failed to detach sleep retention linked list for wifi mac retention");
|
||||||
|
}
|
||||||
|
err = sleep_retention_module_free(SLEEP_RETENTION_MODULE_WIFI_MAC);
|
||||||
if (err != ESP_OK) {
|
if (err != ESP_OK) {
|
||||||
ESP_LOGW(TAG, "failed to free sleep retention linked list for wifi mac retention");
|
ESP_LOGW(TAG, "failed to free sleep retention linked list for wifi mac retention");
|
||||||
}
|
}
|
||||||
@@ -385,6 +393,7 @@ esp_err_t esp_wifi_init(const wifi_init_config_t *config)
|
|||||||
#if SOC_PM_MODEM_RETENTION_BY_REGDMA
|
#if SOC_PM_MODEM_RETENTION_BY_REGDMA
|
||||||
sleep_retention_module_init_param_t init_param = {
|
sleep_retention_module_init_param_t init_param = {
|
||||||
.cbs = { .create = { .handle = init_wifi_mac_sleep_retention, .arg = NULL } },
|
.cbs = { .create = { .handle = init_wifi_mac_sleep_retention, .arg = NULL } },
|
||||||
|
.attribute = SLEEP_RETENTION_MODULE_ATTR_ATTACH
|
||||||
};
|
};
|
||||||
init_param.depends.bitmap[SLEEP_RETENTION_MODULE_WIFI_BB >> 5] |= BIT(SLEEP_RETENTION_MODULE_WIFI_BB % 32);
|
init_param.depends.bitmap[SLEEP_RETENTION_MODULE_WIFI_BB >> 5] |= BIT(SLEEP_RETENTION_MODULE_WIFI_BB % 32);
|
||||||
init_param.depends.bitmap[SLEEP_RETENTION_MODULE_CLOCK_MODEM >> 5] |= BIT(SLEEP_RETENTION_MODULE_CLOCK_MODEM % 32);
|
init_param.depends.bitmap[SLEEP_RETENTION_MODULE_CLOCK_MODEM >> 5] |= BIT(SLEEP_RETENTION_MODULE_CLOCK_MODEM % 32);
|
||||||
|
|||||||
Reference in New Issue
Block a user