Merge branch 'feat/sleep_retention_expand_module_bitmap_v5.3' into 'release/v5.3'

backport v5.3: expand the number of sleep retention modules supported on different chips

See merge request espressif/esp-idf!35491
This commit is contained in:
Jiang Jiang Jian
2025-02-14 13:29:03 +08:00
37 changed files with 589 additions and 397 deletions

View File

@@ -612,7 +612,7 @@ static esp_err_t sleep_modem_ble_mac_modem_state_init(uint8_t extra)
int retention_args = extra; int retention_args = extra;
sleep_retention_module_init_param_t init_param = { sleep_retention_module_init_param_t init_param = {
.cbs = { .create = { .handle = sleep_modem_ble_mac_retention_init, .arg = &retention_args } }, .cbs = { .create = { .handle = sleep_modem_ble_mac_retention_init, .arg = &retention_args } },
.depends = BIT(SLEEP_RETENTION_MODULE_BT_BB) .depends = RETENTION_MODULE_BITMAP_INIT(BT_BB)
}; };
esp_err_t err = sleep_retention_module_init(SLEEP_RETENTION_MODULE_BLE_MAC, &init_param); esp_err_t err = sleep_retention_module_init(SLEEP_RETENTION_MODULE_BLE_MAC, &init_param);
if (err == ESP_OK) { if (err == ESP_OK) {

View File

@@ -603,7 +603,7 @@ static esp_err_t sleep_modem_ble_mac_modem_state_init(uint8_t extra)
int retention_args = extra; int retention_args = extra;
sleep_retention_module_init_param_t init_param = { sleep_retention_module_init_param_t init_param = {
.cbs = { .create = { .handle = sleep_modem_ble_mac_retention_init, .arg = &retention_args } }, .cbs = { .create = { .handle = sleep_modem_ble_mac_retention_init, .arg = &retention_args } },
.depends = BIT(SLEEP_RETENTION_MODULE_BT_BB) .depends = RETENTION_MODULE_BITMAP_INIT(BT_BB)
}; };
esp_err_t err = sleep_retention_module_init(SLEEP_RETENTION_MODULE_BLE_MAC, &init_param); esp_err_t err = sleep_retention_module_init(SLEEP_RETENTION_MODULE_BLE_MAC, &init_param);
if (err == ESP_OK) { if (err == ESP_OK) {

View File

@@ -41,7 +41,7 @@ static void gptimer_create_retention_module(gptimer_t *timer)
int group_id = timer->group->group_id; int group_id = timer->group->group_id;
int timer_id = timer->timer_id; int timer_id = timer->timer_id;
sleep_retention_module_t module = tg_timer_reg_retention_info[group_id][timer_id].module; sleep_retention_module_t module = tg_timer_reg_retention_info[group_id][timer_id].module;
if ((sleep_retention_get_inited_modules() & BIT(module)) && !(sleep_retention_get_created_modules() & BIT(module))) { if (sleep_retention_is_module_inited(module) && !sleep_retention_is_module_created(module)) {
if (sleep_retention_module_allocate(module) != ESP_OK) { if (sleep_retention_module_allocate(module) != ESP_OK) {
// even though the sleep retention module create failed, GPTimer driver should still work, so just warning here // even though the sleep retention module create failed, GPTimer driver should still work, so just warning here
ESP_LOGW(TAG, "create retention link failed on TimerGroup%d Timer%d, power domain won't be turned off during sleep", group_id, timer_id); ESP_LOGW(TAG, "create retention link failed on TimerGroup%d Timer%d, power domain won't be turned off during sleep", group_id, timer_id);
@@ -86,7 +86,7 @@ static esp_err_t gptimer_register_to_group(gptimer_t *timer)
.arg = (void *)timer .arg = (void *)timer
}, },
}, },
.depends = BIT(SLEEP_RETENTION_MODULE_CLOCK_SYSTEM) .depends = RETENTION_MODULE_BITMAP_INIT(CLOCK_SYSTEM)
}; };
if (sleep_retention_module_init(module, &init_param) != ESP_OK) { if (sleep_retention_module_init(module, &init_param) != ESP_OK) {
// even though the sleep retention module init failed, RMT driver should still work, so just warning here // even though the sleep retention module init failed, RMT driver should still work, so just warning here
@@ -107,7 +107,7 @@ static void gptimer_unregister_from_group(gptimer_t *timer)
#if GPTIMER_USE_RETENTION_LINK #if GPTIMER_USE_RETENTION_LINK
sleep_retention_module_t module = tg_timer_reg_retention_info[group->group_id][timer_id].module; sleep_retention_module_t module = tg_timer_reg_retention_info[group->group_id][timer_id].module;
if (sleep_retention_get_created_modules() & BIT(module)) { if (sleep_retention_is_module_created(module)) {
sleep_retention_module_free(module); sleep_retention_module_free(module);
} }
sleep_retention_module_deinit(module); sleep_retention_module_deinit(module);

View File

@@ -223,7 +223,7 @@ static void uart_module_enable(uart_port_t uart_num)
.arg = &uart_context[uart_num], .arg = &uart_context[uart_num],
}, },
}, },
.depends = BIT(SLEEP_RETENTION_MODULE_CLOCK_SYSTEM), .depends = RETENTION_MODULE_BITMAP_INIT(CLOCK_SYSTEM)
}; };
if (sleep_retention_module_init(module, &init_param) == ESP_OK) { if (sleep_retention_module_init(module, &init_param) == ESP_OK) {
uart_context[uart_num].retention_link_inited = true; uart_context[uart_num].retention_link_inited = true;

View File

@@ -36,7 +36,7 @@ static esp_err_t sleep_gdma_channel_retention_init(void *arg)
int group_id = parg->group_id; int group_id = parg->group_id;
int pair_id = parg->pair_id; int pair_id = parg->pair_id;
sleep_retention_module_bitmap_t module = GDMA_CH_RETENTION_GET_MODULE_ID(group_id, pair_id); sleep_retention_module_t module = GDMA_CH_RETENTION_GET_MODULE_ID(group_id, pair_id);
esp_err_t err = sleep_retention_entries_create(gdma_chx_regs_retention[group_id][pair_id].link_list, gdma_chx_regs_retention[group_id][pair_id].link_num, REGDMA_LINK_PRI_GDMA, module); esp_err_t err = sleep_retention_entries_create(gdma_chx_regs_retention[group_id][pair_id].link_list, gdma_chx_regs_retention[group_id][pair_id].link_num, REGDMA_LINK_PRI_GDMA, module);
if (err == ESP_OK) { if (err == ESP_OK) {
ESP_LOGD(TAG, "GDMA pair (%d, %d) retention initialization", group_id, pair_id); ESP_LOGD(TAG, "GDMA pair (%d, %d) retention initialization", group_id, pair_id);
@@ -51,9 +51,9 @@ esp_err_t gdma_sleep_retention_init(int group_id, int pair_id)
gdma_channel_retention_arg_t arg = { .group_id = group_id, .pair_id = pair_id }; gdma_channel_retention_arg_t arg = { .group_id = group_id, .pair_id = pair_id };
sleep_retention_module_init_param_t init_param = { sleep_retention_module_init_param_t init_param = {
.cbs = { .create = { .handle = sleep_gdma_channel_retention_init, .arg = &arg } }, .cbs = { .create = { .handle = sleep_gdma_channel_retention_init, .arg = &arg } },
.depends = BIT(SLEEP_RETENTION_MODULE_CLOCK_SYSTEM) .depends = RETENTION_MODULE_BITMAP_INIT(CLOCK_SYSTEM)
}; };
sleep_retention_module_bitmap_t module = GDMA_CH_RETENTION_GET_MODULE_ID(group_id, pair_id); sleep_retention_module_t module = GDMA_CH_RETENTION_GET_MODULE_ID(group_id, pair_id);
esp_err_t err = sleep_retention_module_init(module, &init_param); esp_err_t err = sleep_retention_module_init(module, &init_param);
if (err == ESP_OK) { if (err == ESP_OK) {
err = sleep_retention_module_allocate(module); err = sleep_retention_module_allocate(module);

View File

@@ -35,7 +35,7 @@ extern "C" {
* @param module The module identifier of the current linked list node * @param module The module identifier of the current linked list node
* @return Created REGDMA linked list node pointer * @return Created REGDMA linked list node pointer
*/ */
void *regdma_link_new_continuous(void *backup, void *buff, int len, void *restore, void *next, bool skip_b, bool skip_r, int id, uint32_t module); void *regdma_link_new_continuous(void *backup, void *buff, int len, void *restore, void *next, bool skip_b, bool skip_r, int id, int module);
/** /**
* @brief Create a REGDMA addr_map type linked list node without retention buffer and the retention buffer is passed in by the caller * @brief Create a REGDMA addr_map type linked list node without retention buffer and the retention buffer is passed in by the caller
@@ -52,7 +52,7 @@ void *regdma_link_new_continuous(void *backup, void *buff, int len, void *restor
* @param module The module identifier of the current linked list node * @param module The module identifier of the current linked list node
* @return Created REGDMA linked list node pointer * @return Created REGDMA linked list node pointer
*/ */
void *regdma_link_new_addr_map(void *backup, void *buff, uint32_t bitmap[4], int len, void *restore, void *next, bool skip_b, bool skip_r, int id, uint32_t module); void *regdma_link_new_addr_map(void *backup, void *buff, uint32_t bitmap[4], int len, void *restore, void *next, bool skip_b, bool skip_r, int id, int module);
/** /**
* @brief Create a REGDMA write type linked list node without retention buffer and the retention buffer is passed in by the caller * @brief Create a REGDMA write type linked list node without retention buffer and the retention buffer is passed in by the caller
@@ -66,7 +66,7 @@ void *regdma_link_new_addr_map(void *backup, void *buff, uint32_t bitmap[4], int
* @param module The module identifier of the current linked list node * @param module The module identifier of the current linked list node
* @return Created REGDMA linked list node pointer * @return Created REGDMA linked list node pointer
*/ */
void *regdma_link_new_write(void *backup, uint32_t value, uint32_t mask, void *next, bool skip_b, bool skip_r, int id, uint32_t module); void *regdma_link_new_write(void *backup, uint32_t value, uint32_t mask, void *next, bool skip_b, bool skip_r, int id, int module);
/** /**
* @brief Create a REGDMA write type linked list node without retention buffer and the retention buffer is passed in by the caller * @brief Create a REGDMA write type linked list node without retention buffer and the retention buffer is passed in by the caller
@@ -80,7 +80,7 @@ void *regdma_link_new_write(void *backup, uint32_t value, uint32_t mask, void *n
* @param module The module identifier of the current linked list node * @param module The module identifier of the current linked list node
* @return Created REGDMA linked list node pointer * @return Created REGDMA linked list node pointer
*/ */
void *regdma_link_new_wait(void *backup, uint32_t value, uint32_t mask, void *next, bool skip_b, bool skip_r, int id, uint32_t module); void *regdma_link_new_wait(void *backup, uint32_t value, uint32_t mask, void *next, bool skip_b, bool skip_r, int id, int module);
/** /**
* @brief Create a REGDMA continuouos branch list node without retention buffer and the retention buffer is passed in by the caller * @brief Create a REGDMA continuouos branch list node without retention buffer and the retention buffer is passed in by the caller
@@ -95,7 +95,7 @@ void *regdma_link_new_wait(void *backup, uint32_t value, uint32_t mask, void *ne
* @param module The module identifier of the current linked list node * @param module The module identifier of the current linked list node
* @return Created REGDMA linked list node pointer * @return Created REGDMA linked list node pointer
*/ */
void *regdma_link_new_branch_continuous(void *backup, void *buff, int len, void *restore, regdma_entry_buf_t *next, bool skip_b, bool skip_r, int id, uint32_t module); void *regdma_link_new_branch_continuous(void *backup, void *buff, int len, void *restore, regdma_entry_buf_t *next, bool skip_b, bool skip_r, int id, int module);
/** /**
* @brief Create a REGDMA addr_map branch list node without retention buffer and the retention buffer is passed in by the caller * @brief Create a REGDMA addr_map branch list node without retention buffer and the retention buffer is passed in by the caller
@@ -112,7 +112,7 @@ void *regdma_link_new_branch_continuous(void *backup, void *buff, int len, void
* @param module The module identifier of the current linked list node * @param module The module identifier of the current linked list node
* @return Created REGDMA linked list node pointer * @return Created REGDMA linked list node pointer
*/ */
void *regdma_link_new_branch_addr_map(void *backup, void *buff, uint32_t bitmap[4], int len, void *restore, regdma_entry_buf_t *next, bool skip_b, bool skip_r, int id, uint32_t module); void *regdma_link_new_branch_addr_map(void *backup, void *buff, uint32_t bitmap[4], int len, void *restore, regdma_entry_buf_t *next, bool skip_b, bool skip_r, int id, int module);
/** /**
* @brief Create a REGDMA write branch list node without retention buffer and the retention buffer is passed in by the caller * @brief Create a REGDMA write branch list node without retention buffer and the retention buffer is passed in by the caller
@@ -126,7 +126,7 @@ void *regdma_link_new_branch_addr_map(void *backup, void *buff, uint32_t bitmap[
* @param module The module identifier of the current linked list node * @param module The module identifier of the current linked list node
* @return Created REGDMA linked list node pointer * @return Created REGDMA linked list node pointer
*/ */
void *regdma_link_new_branch_write(void *backup, uint32_t value, uint32_t mask, regdma_entry_buf_t *next, bool skip_b, bool skip_r, int id, uint32_t module); void *regdma_link_new_branch_write(void *backup, uint32_t value, uint32_t mask, regdma_entry_buf_t *next, bool skip_b, bool skip_r, int id, int module);
/** /**
* @brief Create a REGDMA wait branch list node without retention buffer and the retention buffer is passed in by the caller * @brief Create a REGDMA wait branch list node without retention buffer and the retention buffer is passed in by the caller
@@ -140,7 +140,7 @@ void *regdma_link_new_branch_write(void *backup, uint32_t value, uint32_t mask,
* @param module The module identifier of the current linked list node * @param module The module identifier of the current linked list node
* @return Created REGDMA linked list node pointer * @return Created REGDMA linked list node pointer
*/ */
void *regdma_link_new_branch_wait(void *backup, uint32_t value, uint32_t mask, regdma_entry_buf_t *next, bool skip_b, bool skip_r, int id, uint32_t module); void *regdma_link_new_branch_wait(void *backup, uint32_t value, uint32_t mask, regdma_entry_buf_t *next, bool skip_b, bool skip_r, int id, int module);
/** /**
* @brief Create a default REGDMA continuous type linked list node with retention buffer * @brief Create a default REGDMA continuous type linked list node with retention buffer
@@ -154,7 +154,7 @@ void *regdma_link_new_branch_wait(void *backup, uint32_t value, uint32_t mask, r
* @param module The module identifier of the current linked list node * @param module The module identifier of the current linked list node
* @return Created REGDMA linked list node pointer * @return Created REGDMA linked list node pointer
*/ */
void *regdma_link_new_continuous_default(void *backup, int len, void *restore, void *next, bool skip_b, bool skip_r, int id, uint32_t module); void *regdma_link_new_continuous_default(void *backup, int len, void *restore, void *next, bool skip_b, bool skip_r, int id, int module);
/** /**
* @brief Create a default REGDMA addr_map type linked list node with retention buffer * @brief Create a default REGDMA addr_map type linked list node with retention buffer
@@ -170,7 +170,7 @@ void *regdma_link_new_continuous_default(void *backup, int len, void *restore, v
* @param module The module identifier of the current linked list node * @param module The module identifier of the current linked list node
* @return Created REGDMA linked list node pointer * @return Created REGDMA linked list node pointer
*/ */
void *regdma_link_new_addr_map_default(void *backup, uint32_t bitmap[4], int len, void *restore, void *next, bool skip_b, bool skip_r, int id, uint32_t module); void *regdma_link_new_addr_map_default(void *backup, uint32_t bitmap[4], int len, void *restore, void *next, bool skip_b, bool skip_r, int id, int module);
/** /**
* @brief Create a default REGDMA write type linked list node with retention buffer * @brief Create a default REGDMA write type linked list node with retention buffer
@@ -184,7 +184,7 @@ void *regdma_link_new_addr_map_default(void *backup, uint32_t bitmap[4], int len
* @param module The module identifier of the current linked list node * @param module The module identifier of the current linked list node
* @return Created REGDMA linked list node pointer * @return Created REGDMA linked list node pointer
*/ */
void *regdma_link_new_write_default(void *backup, uint32_t value, uint32_t mask, void *next, bool skip_b, bool skip_r, int id, uint32_t module); void *regdma_link_new_write_default(void *backup, uint32_t value, uint32_t mask, void *next, bool skip_b, bool skip_r, int id, int module);
/** /**
* @brief Create a default REGDMA wait type linked list node with retention buffer * @brief Create a default REGDMA wait type linked list node with retention buffer
@@ -198,7 +198,7 @@ void *regdma_link_new_write_default(void *backup, uint32_t value, uint32_t mask,
* @param module The module identifier of the current linked list node * @param module The module identifier of the current linked list node
* @return Created REGDMA linked list node pointer * @return Created REGDMA linked list node pointer
*/ */
void *regdma_link_new_wait_default(void *backup, uint32_t value, uint32_t mask, void *next, bool skip_b, bool skip_r, int id, uint32_t module); void *regdma_link_new_wait_default(void *backup, uint32_t value, uint32_t mask, void *next, bool skip_b, bool skip_r, int id, int module);
/** /**
* @brief Create a default REGDMA continuous branch list node with retention buffer * @brief Create a default REGDMA continuous branch list node with retention buffer
@@ -212,7 +212,7 @@ void *regdma_link_new_wait_default(void *backup, uint32_t value, uint32_t mask,
* @param module The module identifier of the current linked list node * @param module The module identifier of the current linked list node
* @return Created REGDMA linked list node pointer * @return Created REGDMA linked list node pointer
*/ */
void *regdma_link_new_branch_continuous_default(void *backup, int len, void *restore, regdma_entry_buf_t *next, bool skip_b, bool skip_r, int id, uint32_t module); void *regdma_link_new_branch_continuous_default(void *backup, int len, void *restore, regdma_entry_buf_t *next, bool skip_b, bool skip_r, int id, int module);
/** /**
* @brief Create a default REGDMA addr_map branch list node with retention buffer * @brief Create a default REGDMA addr_map branch list node with retention buffer
@@ -228,7 +228,7 @@ void *regdma_link_new_branch_continuous_default(void *backup, int len, void *res
* @param module The module identifier of the current linked list node * @param module The module identifier of the current linked list node
* @return Created REGDMA linked list node pointer * @return Created REGDMA linked list node pointer
*/ */
void *regdma_link_new_branch_addr_map_default(void *backup, uint32_t bitmap[4], int len, void *restore, regdma_entry_buf_t *next, bool skip_b, bool skip_r, int id, uint32_t module); void *regdma_link_new_branch_addr_map_default(void *backup, uint32_t bitmap[4], int len, void *restore, regdma_entry_buf_t *next, bool skip_b, bool skip_r, int id, int module);
/** /**
* @brief Create a default REGDMA write branch list node with retention buffer * @brief Create a default REGDMA write branch list node with retention buffer
@@ -242,7 +242,7 @@ void *regdma_link_new_branch_addr_map_default(void *backup, uint32_t bitmap[4],
* @param module The module identifier of the current linked list node * @param module The module identifier of the current linked list node
* @return Created REGDMA linked list node pointer * @return Created REGDMA linked list node pointer
*/ */
void *regdma_link_new_branch_write_default(void *backup, uint32_t value, uint32_t mask, regdma_entry_buf_t *next, bool skip_b, bool skip_r, int id, uint32_t module); void *regdma_link_new_branch_write_default(void *backup, uint32_t value, uint32_t mask, regdma_entry_buf_t *next, bool skip_b, bool skip_r, int id, int module);
/** /**
* @brief Create a default REGDMA wait branch list node with retention buffer * @brief Create a default REGDMA wait branch list node with retention buffer
@@ -256,7 +256,7 @@ void *regdma_link_new_branch_write_default(void *backup, uint32_t value, uint32_
* @param module The module identifier of the current linked list node * @param module The module identifier of the current linked list node
* @return Created REGDMA linked list node pointer * @return Created REGDMA linked list node pointer
*/ */
void *regdma_link_new_branch_wait_default(void *backup, uint32_t value, uint32_t mask, regdma_entry_buf_t *next, bool skip_b, bool skip_r, int id, uint32_t module); void *regdma_link_new_branch_wait_default(void *backup, uint32_t value, uint32_t mask, regdma_entry_buf_t *next, bool skip_b, bool skip_r, int id, int module);
/** /**
* @brief Create and initialize a REGDMA linked list node through configuration parameters * @brief Create and initialize a REGDMA linked list node through configuration parameters
@@ -267,7 +267,7 @@ void *regdma_link_new_branch_wait_default(void *backup, uint32_t value, uint32_t
* @param args next pointer, Since REGDMA supports 4 entries, it supports up to 4 variable parameter next pointers, and more will be ignored * @param args next pointer, Since REGDMA supports 4 entries, it supports up to 4 variable parameter next pointers, and more will be ignored
* @return Initialized REGDMA linked list head node pointer * @return Initialized REGDMA linked list head node pointer
*/ */
void *regdma_link_init(const regdma_link_config_t *config, bool branch, uint32_t module, int nentry, ...); void *regdma_link_init(const regdma_link_config_t *config, bool branch, int module, int nentry, ...);
/** /**
* @brief Get REGDMA linked list node mode through configuration parameters * @brief Get REGDMA linked list node mode through configuration parameters
@@ -361,7 +361,7 @@ uint32_t regdma_link_get_owner_bitmap(void *link, void *tail, int entry);
* @param module Module bitmap Identification * @param module Module bitmap Identification
* @return The found head node pointer or NULL * @return The found head node pointer or NULL
*/ */
void *regdma_find_module_link_head(void *link, void *tail, int entry, uint32_t module); void *regdma_find_module_link_head(void *link, void *tail, int entry, int module);
/** /**
* @brief Find the tail node of the specified module in the REGDMA linked list indicated by the * @brief Find the tail node of the specified module in the REGDMA linked list indicated by the
@@ -372,7 +372,7 @@ void *regdma_find_module_link_head(void *link, void *tail, int entry, uint32_t m
* @param module Module bitmap Identification * @param module Module bitmap Identification
* @return The found tail node pointer or NULL * @return The found tail node pointer or NULL
*/ */
void *regdma_find_module_link_tail(void *link, void *tail, int entry, uint32_t module); void *regdma_find_module_link_tail(void *link, void *tail, int entry, int module);
/** /**
* @brief Find the tail node of the previous module of the specified module in the REGDMA linked list * @brief Find the tail node of the previous module of the specified module in the REGDMA linked list
@@ -383,7 +383,7 @@ void *regdma_find_module_link_tail(void *link, void *tail, int entry, uint32_t m
* @param module Module bitmap Identification * @param module Module bitmap Identification
* @return The found tail node pointer or NULL * @return The found tail node pointer or NULL
*/ */
void *regdma_find_prev_module_link_tail(void *link, void *tail, int entry, uint32_t module); void *regdma_find_prev_module_link_tail(void *link, void *tail, int entry, int module);
/** /**
* @brief Find the head node of the next module of the specified module in the REGDMA linked list * @brief Find the head node of the next module of the specified module in the REGDMA linked list
@@ -394,7 +394,7 @@ void *regdma_find_prev_module_link_tail(void *link, void *tail, int entry, uint3
* @param module Module bitmap Identification * @param module Module bitmap Identification
* @return The found head node pointer or NULL * @return The found head node pointer or NULL
*/ */
void *regdma_find_next_module_link_head(void *link, void *tail, int entry, uint32_t module); void *regdma_find_next_module_link_head(void *link, void *tail, int entry, int module);
#define regdma_link_init_safe(pcfg, branch, module, ...) regdma_link_init((pcfg), (branch), (module), __VA_NARG__(__VA_ARGS__), ##__VA_ARGS__) #define regdma_link_init_safe(pcfg, branch, module, ...) regdma_link_init((pcfg), (branch), (module), __VA_NARG__(__VA_ARGS__), ##__VA_ARGS__)

View File

@@ -17,6 +17,8 @@ extern "C" {
#include "esp_regdma.h" #include "esp_regdma.h"
#include "soc/retention_periph_defs.h" #include "soc/retention_periph_defs.h"
#define SLEEP_RETENTION_MODULE_BITMAP_SZ ((SLEEP_RETENTION_MODULE_MAX >> 5) + 1)
/** /**
* @file sleep_retention.h * @file sleep_retention.h
* *
@@ -24,7 +26,10 @@ extern "C" {
* includes sleep retention list creation, destruction and debugging interfaces. * includes sleep retention list creation, destruction and debugging interfaces.
*/ */
typedef periph_retention_module_t sleep_retention_module_t; typedef periph_retention_module_t sleep_retention_module_t;
typedef periph_retention_module_bitmap_t sleep_retention_module_bitmap_t; 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;
typedef regdma_entry_buf_t sleep_retention_entries_t; typedef regdma_entry_buf_t sleep_retention_entries_t;
typedef regdma_entries_config_t sleep_retention_entries_config_t; typedef regdma_entries_config_t sleep_retention_entries_config_t;
@@ -149,7 +154,7 @@ esp_err_t sleep_retention_module_free(sleep_retention_module_t module);
* *
* @return the bitmap for all modules that require sleep retention * @return the bitmap for all modules that require sleep retention
*/ */
uint32_t sleep_retention_get_inited_modules(void); sleep_retention_module_bitmap_t sleep_retention_get_inited_modules(void);
/** /**
* @brief Get all created modules that require sleep retention * @brief Get all created modules that require sleep retention
@@ -162,7 +167,74 @@ uint32_t sleep_retention_get_inited_modules(void);
* @return the bitmap for all modules that have successfully created a sleep * @return the bitmap for all modules that have successfully created a sleep
* retention context * retention context
*/ */
uint32_t sleep_retention_get_created_modules(void); sleep_retention_module_bitmap_t sleep_retention_get_created_modules(void);
/**
* @brief Get the initialization state of module
*
* @param module module number
*
* @return false if the module is not initialized or the module number is
* invalid, otherwise return true
*/
bool sleep_retention_is_module_inited(sleep_retention_module_t module);
/**
* @brief Get the creation state of module
*
* @param module module number
*
* @return false if the module is not created or the module number is
* invalid, otherwise return true
*/
bool sleep_retention_is_module_created(sleep_retention_module_t module);
/**
* @brief Calculates the bitwise logical and of the module bitmap and return results
*
* This is an unprotected interface. It can only be called by the sleep procedure.
*
* @param op0 module bitmap operator 0
* @param op1 module bitmap operator 1
*
* @return the bitwise logical and result of module bitmap
*/
sleep_retention_module_bitmap_t sleep_retention_module_bitmap_and(sleep_retention_module_bitmap_t op0, sleep_retention_module_bitmap_t op1);
/**
* @brief Calculates the bitwise logical or of the module bitmap and return results
*
* This is an unprotected interface. It can only be called by the sleep procedure.
*
* @param op0 module bitmap operator 0
* @param op1 module bitmap operator 1
*
* @return the bitwise logical or result of module bitmap
*/
sleep_retention_module_bitmap_t sleep_retention_module_bitmap_or(sleep_retention_module_bitmap_t op0, sleep_retention_module_bitmap_t op1);
/**
* @brief Calculates the bitwise logical not of the module bitmap and return results
*
* This is an unprotected interface. It can only be called by the sleep procedure.
*
* @param op0 module bitmap operator
*
* @return the bitwise logical not result of module bitmap
*/
sleep_retention_module_bitmap_t sleep_retention_module_bitmap_not(sleep_retention_module_bitmap_t op);
/**
* @brief Compares the module bitmap values are equal and return results
*
* This is an unprotected interface. It can only be called by the sleep procedure.
*
* @param op0 module bitmap operator 0
* @param op1 module bitmap operator 1
*
* @return If the module bitmap values are equal then return true, otherwise return false
*/
bool sleep_retention_module_bitmap_eq(sleep_retention_module_bitmap_t op0, sleep_retention_module_bitmap_t op1);
#if SOC_PM_RETENTION_HAS_CLOCK_BUG #if SOC_PM_RETENTION_HAS_CLOCK_BUG
/** /**

View File

@@ -21,7 +21,7 @@
#define REGDMA_LINK_ADDR_ALIGN (4) #define REGDMA_LINK_ADDR_ALIGN (4)
#define REGDMA_LINK_MEM_TYPE_CAPS (MALLOC_CAP_DMA | MALLOC_CAP_DEFAULT) #define REGDMA_LINK_MEM_TYPE_CAPS (MALLOC_CAP_DMA | MALLOC_CAP_DEFAULT)
void * regdma_link_new_continuous(void *backup, void *buff, int len, void *restore, void *next, bool skip_b, bool skip_r, int id, uint32_t module) void * regdma_link_new_continuous(void *backup, void *buff, int len, void *restore, void *next, bool skip_b, bool skip_r, int id, int module)
{ {
regdma_link_continuous_t *link = (regdma_link_continuous_t *)heap_caps_aligned_alloc( regdma_link_continuous_t *link = (regdma_link_continuous_t *)heap_caps_aligned_alloc(
REGDMA_LINK_ADDR_ALIGN, REGDMA_LINK_ADDR_ALIGN,
@@ -37,7 +37,7 @@ void * regdma_link_new_continuous(void *backup, void *buff, int len, void *resto
return NULL; return NULL;
} }
void * regdma_link_new_addr_map(void *backup, void *buff, uint32_t bitmap[4], int len, void *restore, void *next, bool skip_b, bool skip_r, int id, uint32_t module) void * regdma_link_new_addr_map(void *backup, void *buff, uint32_t bitmap[4], int len, void *restore, void *next, bool skip_b, bool skip_r, int id, int module)
{ {
regdma_link_addr_map_t *link = (regdma_link_addr_map_t *)heap_caps_aligned_alloc( regdma_link_addr_map_t *link = (regdma_link_addr_map_t *)heap_caps_aligned_alloc(
REGDMA_LINK_ADDR_ALIGN, REGDMA_LINK_ADDR_ALIGN,
@@ -53,7 +53,7 @@ void * regdma_link_new_addr_map(void *backup, void *buff, uint32_t bitmap[4], in
return NULL; return NULL;
} }
void * regdma_link_new_write(void *backup, uint32_t value, uint32_t mask, void *next, bool skip_b, bool skip_r, int id, uint32_t module) void * regdma_link_new_write(void *backup, uint32_t value, uint32_t mask, void *next, bool skip_b, bool skip_r, int id, int module)
{ {
regdma_link_write_wait_t *link = (regdma_link_write_wait_t *)heap_caps_aligned_alloc( regdma_link_write_wait_t *link = (regdma_link_write_wait_t *)heap_caps_aligned_alloc(
REGDMA_LINK_ADDR_ALIGN, sizeof(regdma_link_write_wait_t), REGDMA_LINK_MEM_TYPE_CAPS); REGDMA_LINK_ADDR_ALIGN, sizeof(regdma_link_write_wait_t), REGDMA_LINK_MEM_TYPE_CAPS);
@@ -65,7 +65,7 @@ void * regdma_link_new_write(void *backup, uint32_t value, uint32_t mask, void *
return NULL; return NULL;
} }
void * regdma_link_new_wait(void *backup, uint32_t value, uint32_t mask, void *next, bool skip_b, bool skip_r, int id, uint32_t module) void * regdma_link_new_wait(void *backup, uint32_t value, uint32_t mask, void *next, bool skip_b, bool skip_r, int id, int module)
{ {
regdma_link_write_wait_t *link = (regdma_link_write_wait_t *)heap_caps_aligned_alloc( regdma_link_write_wait_t *link = (regdma_link_write_wait_t *)heap_caps_aligned_alloc(
REGDMA_LINK_ADDR_ALIGN, sizeof(regdma_link_write_wait_t), REGDMA_LINK_MEM_TYPE_CAPS); REGDMA_LINK_ADDR_ALIGN, sizeof(regdma_link_write_wait_t), REGDMA_LINK_MEM_TYPE_CAPS);
@@ -77,7 +77,7 @@ void * regdma_link_new_wait(void *backup, uint32_t value, uint32_t mask, void *n
return NULL; return NULL;
} }
void * regdma_link_new_branch_continuous(void *backup, void *buff, int len, void *restore, regdma_entry_buf_t *next, bool skip_b, bool skip_r, int id, uint32_t module) void * regdma_link_new_branch_continuous(void *backup, void *buff, int len, void *restore, regdma_entry_buf_t *next, bool skip_b, bool skip_r, int id, int module)
{ {
regdma_link_branch_continuous_t *link = (regdma_link_branch_continuous_t *)heap_caps_aligned_alloc( regdma_link_branch_continuous_t *link = (regdma_link_branch_continuous_t *)heap_caps_aligned_alloc(
REGDMA_LINK_ADDR_ALIGN, REGDMA_LINK_ADDR_ALIGN,
@@ -93,7 +93,7 @@ void * regdma_link_new_branch_continuous(void *backup, void *buff, int len, void
return NULL; return NULL;
} }
void * regdma_link_new_branch_addr_map(void *backup, void *buff, uint32_t bitmap[4], int len, void *restore, regdma_entry_buf_t *next, bool skip_b, bool skip_r, int id, uint32_t module) void * regdma_link_new_branch_addr_map(void *backup, void *buff, uint32_t bitmap[4], int len, void *restore, regdma_entry_buf_t *next, bool skip_b, bool skip_r, int id, int module)
{ {
regdma_link_branch_addr_map_t *link = (regdma_link_branch_addr_map_t *)heap_caps_aligned_alloc( regdma_link_branch_addr_map_t *link = (regdma_link_branch_addr_map_t *)heap_caps_aligned_alloc(
REGDMA_LINK_ADDR_ALIGN, REGDMA_LINK_ADDR_ALIGN,
@@ -109,7 +109,7 @@ void * regdma_link_new_branch_addr_map(void *backup, void *buff, uint32_t bitmap
return NULL; return NULL;
} }
void * regdma_link_new_branch_write(void *backup, uint32_t value, uint32_t mask, regdma_entry_buf_t *next, bool skip_b, bool skip_r, int id, uint32_t module) void * regdma_link_new_branch_write(void *backup, uint32_t value, uint32_t mask, regdma_entry_buf_t *next, bool skip_b, bool skip_r, int id, int module)
{ {
regdma_link_branch_write_wait_t *link = (regdma_link_branch_write_wait_t *)heap_caps_aligned_alloc( regdma_link_branch_write_wait_t *link = (regdma_link_branch_write_wait_t *)heap_caps_aligned_alloc(
REGDMA_LINK_ADDR_ALIGN, sizeof(regdma_link_branch_write_wait_t), REGDMA_LINK_MEM_TYPE_CAPS); REGDMA_LINK_ADDR_ALIGN, sizeof(regdma_link_branch_write_wait_t), REGDMA_LINK_MEM_TYPE_CAPS);
@@ -121,7 +121,7 @@ void * regdma_link_new_branch_write(void *backup, uint32_t value, uint32_t mask,
return NULL; return NULL;
} }
void * regdma_link_new_branch_wait(void *backup, uint32_t value, uint32_t mask, regdma_entry_buf_t *next, bool skip_b, bool skip_r, int id, uint32_t module) void * regdma_link_new_branch_wait(void *backup, uint32_t value, uint32_t mask, regdma_entry_buf_t *next, bool skip_b, bool skip_r, int id, int module)
{ {
regdma_link_branch_write_wait_t *link = (regdma_link_branch_write_wait_t *)heap_caps_aligned_alloc( regdma_link_branch_write_wait_t *link = (regdma_link_branch_write_wait_t *)heap_caps_aligned_alloc(
REGDMA_LINK_ADDR_ALIGN, sizeof(regdma_link_branch_write_wait_t), REGDMA_LINK_MEM_TYPE_CAPS); REGDMA_LINK_ADDR_ALIGN, sizeof(regdma_link_branch_write_wait_t), REGDMA_LINK_MEM_TYPE_CAPS);
@@ -133,48 +133,48 @@ void * regdma_link_new_branch_wait(void *backup, uint32_t value, uint32_t mask,
return NULL; return NULL;
} }
void * regdma_link_new_continuous_default(void *backup, int len, void *restore, void *next, bool skip_b, bool skip_r, int id, uint32_t module) void * regdma_link_new_continuous_default(void *backup, int len, void *restore, void *next, bool skip_b, bool skip_r, int id, int module)
{ {
return regdma_link_new_continuous(backup, NULL, len, restore, next, skip_b, skip_r, id, module); return regdma_link_new_continuous(backup, NULL, len, restore, next, skip_b, skip_r, id, module);
} }
void * regdma_link_new_addr_map_default(void *backup, uint32_t bitmap[4], int len, void *restore, void *next, bool skip_b, bool skip_r, int id, uint32_t module) void * regdma_link_new_addr_map_default(void *backup, uint32_t bitmap[4], int len, void *restore, void *next, bool skip_b, bool skip_r, int id, int module)
{ {
return regdma_link_new_addr_map(backup, NULL, bitmap, len, restore, next, skip_b, skip_r, id, module); return regdma_link_new_addr_map(backup, NULL, bitmap, len, restore, next, skip_b, skip_r, id, module);
} }
void * regdma_link_new_write_default(void *backup, uint32_t value, uint32_t mask, void *next, bool skip_b, bool skip_r, int id, uint32_t module) void * regdma_link_new_write_default(void *backup, uint32_t value, uint32_t mask, void *next, bool skip_b, bool skip_r, int id, int module)
{ {
return regdma_link_new_write(backup, value, mask, next, skip_b, skip_r, id, module); return regdma_link_new_write(backup, value, mask, next, skip_b, skip_r, id, module);
} }
void * regdma_link_new_wait_default(void *backup, uint32_t value, uint32_t mask, void *next, bool skip_b, bool skip_r, int id, uint32_t module) void * regdma_link_new_wait_default(void *backup, uint32_t value, uint32_t mask, void *next, bool skip_b, bool skip_r, int id, int module)
{ {
return regdma_link_new_wait(backup, value, mask, next, skip_b, skip_r, id, module); return regdma_link_new_wait(backup, value, mask, next, skip_b, skip_r, id, module);
} }
void * regdma_link_new_branch_continuous_default(void *backup, int len, void *restore, regdma_entry_buf_t *next, bool skip_b, bool skip_r, int id, uint32_t module) void * regdma_link_new_branch_continuous_default(void *backup, int len, void *restore, regdma_entry_buf_t *next, bool skip_b, bool skip_r, int id, int module)
{ {
return regdma_link_new_branch_continuous(backup, NULL, len, restore, next, skip_b, skip_r, id, module); return regdma_link_new_branch_continuous(backup, NULL, len, restore, next, skip_b, skip_r, id, module);
} }
void * regdma_link_new_branch_addr_map_default(void *backup, uint32_t bitmap[4], int len, void *restore, regdma_entry_buf_t *next, bool skip_b, bool skip_r, int id, uint32_t module) void * regdma_link_new_branch_addr_map_default(void *backup, uint32_t bitmap[4], int len, void *restore, regdma_entry_buf_t *next, bool skip_b, bool skip_r, int id, int module)
{ {
return regdma_link_new_branch_addr_map(backup, NULL, bitmap, len, restore, next, skip_b, skip_r, id, module); return regdma_link_new_branch_addr_map(backup, NULL, bitmap, len, restore, next, skip_b, skip_r, id, module);
} }
void * regdma_link_new_branch_write_default(void *backup, uint32_t value, uint32_t mask, regdma_entry_buf_t *next, bool skip_b, bool skip_r, int id, uint32_t module) void * regdma_link_new_branch_write_default(void *backup, uint32_t value, uint32_t mask, regdma_entry_buf_t *next, bool skip_b, bool skip_r, int id, int module)
{ {
return regdma_link_new_branch_write(backup, value, mask, next, skip_b, skip_r, id, module); return regdma_link_new_branch_write(backup, value, mask, next, skip_b, skip_r, id, module);
} }
void * regdma_link_new_branch_wait_default(void *backup, uint32_t value, uint32_t mask, regdma_entry_buf_t *next, bool skip_b, bool skip_r, int id, uint32_t module) void * regdma_link_new_branch_wait_default(void *backup, uint32_t value, uint32_t mask, regdma_entry_buf_t *next, bool skip_b, bool skip_r, int id, int module)
{ {
return regdma_link_new_branch_wait(backup, value, mask, next, skip_b, skip_r, id, module); return regdma_link_new_branch_wait(backup, value, mask, next, skip_b, skip_r, id, module);
} }
static void * regdma_link_init_continuous_wrapper(const regdma_link_config_t *config, uint32_t module, int n, va_list args) static void * regdma_link_init_continuous_wrapper(const regdma_link_config_t *config, int module, int n, va_list args)
{ {
regdma_entry_buf_t next; regdma_entry_buf_t next;
@@ -187,7 +187,7 @@ static void * regdma_link_init_continuous_wrapper(const regdma_link_config_t *co
config->head.skip_r, config->id, module); config->head.skip_r, config->id, module);
} }
static void * regdma_link_init_addr_map_wrapper(const regdma_link_config_t *config, uint32_t module, int n, va_list args) static void * regdma_link_init_addr_map_wrapper(const regdma_link_config_t *config, int module, int n, va_list args)
{ {
regdma_entry_buf_t next; regdma_entry_buf_t next;
@@ -200,7 +200,7 @@ static void * regdma_link_init_addr_map_wrapper(const regdma_link_config_t *conf
config->head.skip_r, config->id, module); config->head.skip_r, config->id, module);
} }
static void * regdma_link_init_write_wrapper(const regdma_link_config_t *config, uint32_t module, int n, va_list args) static void * regdma_link_init_write_wrapper(const regdma_link_config_t *config, int module, int n, va_list args)
{ {
regdma_entry_buf_t next; regdma_entry_buf_t next;
@@ -213,7 +213,7 @@ static void * regdma_link_init_write_wrapper(const regdma_link_config_t *config,
config->id, module); config->id, module);
} }
static void * regdma_link_init_wait_wrapper(const regdma_link_config_t *config, uint32_t module, int n, va_list args) static void * regdma_link_init_wait_wrapper(const regdma_link_config_t *config, int module, int n, va_list args)
{ {
regdma_entry_buf_t next; regdma_entry_buf_t next;
@@ -226,7 +226,7 @@ static void * regdma_link_init_wait_wrapper(const regdma_link_config_t *config,
config->id, module); config->id, module);
} }
static void * regdma_link_init_branch_continuous_wrapper(const regdma_link_config_t *config, uint32_t module, int n, va_list args) static void * regdma_link_init_branch_continuous_wrapper(const regdma_link_config_t *config, int module, int n, va_list args)
{ {
regdma_entry_buf_t next; regdma_entry_buf_t next;
@@ -239,7 +239,7 @@ static void * regdma_link_init_branch_continuous_wrapper(const regdma_link_confi
config->head.skip_b, config->head.skip_r, config->id, module); config->head.skip_b, config->head.skip_r, config->id, module);
} }
static void * regdma_link_init_branch_addr_map_wrapper(const regdma_link_config_t *config, uint32_t module, int n, va_list args) static void * regdma_link_init_branch_addr_map_wrapper(const regdma_link_config_t *config, int module, int n, va_list args)
{ {
regdma_entry_buf_t next; regdma_entry_buf_t next;
@@ -252,7 +252,7 @@ static void * regdma_link_init_branch_addr_map_wrapper(const regdma_link_config_
&next, config->head.skip_b, config->head.skip_r, config->id, module); &next, config->head.skip_b, config->head.skip_r, config->id, module);
} }
static void * regdma_link_init_branch_write_wrapper(const regdma_link_config_t *config, uint32_t module, int n, va_list args) static void * regdma_link_init_branch_write_wrapper(const regdma_link_config_t *config, int module, int n, va_list args)
{ {
regdma_entry_buf_t next; regdma_entry_buf_t next;
@@ -265,7 +265,7 @@ static void * regdma_link_init_branch_write_wrapper(const regdma_link_config_t *
config->head.skip_r, config->id, module); config->head.skip_r, config->id, module);
} }
static void * regdma_link_init_branch_wait_wrapper(const regdma_link_config_t *config, uint32_t module, int n, va_list args) static void * regdma_link_init_branch_wait_wrapper(const regdma_link_config_t *config, int module, int n, va_list args)
{ {
regdma_entry_buf_t next; regdma_entry_buf_t next;
@@ -278,7 +278,7 @@ static void * regdma_link_init_branch_wait_wrapper(const regdma_link_config_t *c
config->head.skip_r, config->id, module); config->head.skip_r, config->id, module);
} }
static void * regdma_link_init_wrapper(const regdma_link_config_t *config, bool branch, uint32_t module, int nentry, va_list args) static void * regdma_link_init_wrapper(const regdma_link_config_t *config, bool branch, int module, int nentry, va_list args)
{ {
typedef void * (*init_fn_t)(const void *, uint32_t, int, va_list); typedef void * (*init_fn_t)(const void *, uint32_t, int, va_list);
@@ -301,7 +301,7 @@ static void * regdma_link_init_wrapper(const regdma_link_config_t *config, bool
return (*pfn)(config, module, nentry, args); return (*pfn)(config, module, nentry, args);
} }
void * regdma_link_init(const regdma_link_config_t *config, bool branch, uint32_t module, int nentry, ...) void * regdma_link_init(const regdma_link_config_t *config, bool branch, int module, int nentry, ...)
{ {
assert(config != NULL); assert(config != NULL);
@@ -640,7 +640,7 @@ uint32_t regdma_link_get_owner_bitmap(void *link, void *tail, int entry)
return owner; return owner;
} }
void * regdma_find_module_link_head(void *link, void *tail, int entry, uint32_t module) void * regdma_find_module_link_head(void *link, void *tail, int entry, int module)
{ {
assert(entry < REGDMA_LINK_ENTRY_NUM); assert(entry < REGDMA_LINK_ENTRY_NUM);
@@ -648,7 +648,7 @@ void * regdma_find_module_link_head(void *link, void *tail, int entry, uint32_t
void *next = link; void *next = link;
if (link) { if (link) {
do { do {
if (regdma_link_get_stats(next)->module & module) { if (regdma_link_get_stats(next)->module == module) {
find_link = next; find_link = next;
break; break;
} }
@@ -660,7 +660,7 @@ void * regdma_find_module_link_head(void *link, void *tail, int entry, uint32_t
return find_link; return find_link;
} }
void * regdma_find_module_link_tail(void *link, void *tail, int entry, uint32_t module) void * regdma_find_module_link_tail(void *link, void *tail, int entry, int module)
{ {
assert(entry < REGDMA_LINK_ENTRY_NUM); assert(entry < REGDMA_LINK_ENTRY_NUM);
@@ -670,13 +670,13 @@ void * regdma_find_module_link_tail(void *link, void *tail, int entry, uint32_t
do { do {
if (next != tail) { if (next != tail) {
void *temp = regdma_link_get_next(next, entry); void *temp = regdma_link_get_next(next, entry);
if ((regdma_link_get_stats(next)->module & module) && if ((regdma_link_get_stats(next)->module == module) &&
!(regdma_link_get_stats(temp)->module & module)) { !(regdma_link_get_stats(temp)->module == module)) {
find_tail = next; find_tail = next;
break; break;
} }
} else { } else {
if (regdma_link_get_stats(next)->module & module) { if (regdma_link_get_stats(next)->module == module) {
find_tail = next; find_tail = next;
break; break;
} }
@@ -686,7 +686,7 @@ void * regdma_find_module_link_tail(void *link, void *tail, int entry, uint32_t
return find_tail; return find_tail;
} }
void * regdma_find_next_module_link_head(void *link, void *tail, int entry, uint32_t module) void * regdma_find_next_module_link_head(void *link, void *tail, int entry, int module)
{ {
assert(entry < REGDMA_LINK_ENTRY_NUM); assert(entry < REGDMA_LINK_ENTRY_NUM);
void *find_tail = regdma_find_module_link_tail(link, tail, entry, module); void *find_tail = regdma_find_module_link_tail(link, tail, entry, module);
@@ -696,7 +696,7 @@ void * regdma_find_next_module_link_head(void *link, void *tail, int entry, uint
return NULL; return NULL;
} }
void * regdma_find_prev_module_link_tail(void *link, void *tail, int entry, uint32_t module) void * regdma_find_prev_module_link_tail(void *link, void *tail, int entry, int module)
{ {
assert(entry < REGDMA_LINK_ENTRY_NUM); assert(entry < REGDMA_LINK_ENTRY_NUM);
void *find_head = regdma_find_module_link_head(link, tail, entry, module); void *find_head = regdma_find_module_link_head(link, tail, entry, module);

View File

@@ -8,36 +8,48 @@
bool clock_domain_pd_allowed(void) bool clock_domain_pd_allowed(void)
{ {
const uint32_t inited_modules = sleep_retention_get_inited_modules(); const sleep_retention_module_bitmap_t inited_modules = sleep_retention_get_inited_modules();
const uint32_t created_modules = sleep_retention_get_created_modules(); const sleep_retention_module_bitmap_t created_modules = sleep_retention_get_created_modules();
const uint32_t sys_clk_dep_modules = (const uint32_t) (BIT(SLEEP_RETENTION_MODULE_SYS_PERIPH)); const sleep_retention_module_bitmap_t sys_clk_dep_modules = (sleep_retention_module_bitmap_t){ .bitmap[SLEEP_RETENTION_MODULE_SYS_PERIPH >> 5] = BIT(SLEEP_RETENTION_MODULE_SYS_PERIPH % 32) };
/* The clock and reset of MODEM (WiFi, BLE and 15.4) modules are managed /* The clock and reset of MODEM (WiFi, BLE and 15.4) modules are managed
* through MODEM_SYSCON, when one or more MODEMs are initialized, it is * through MODEM_SYSCON, when one or more MODEMs are initialized, it is
* necessary to check the state of CLOCK_MODEM to determine MODEM domain on * necessary to check the state of CLOCK_MODEM to determine MODEM domain on
* or off. The clock and reset of digital peripherals are managed through * or off. The clock and reset of digital peripherals are managed through
* PCR, with TOP domain similar to MODEM domain. */ * PCR, with TOP domain similar to MODEM domain. */
uint32_t modem_clk_dep_modules = 0; #if SOC_WIFI_SUPPORTED || SOC_BT_SUPPORTED || SOC_IEEE802154_SUPPORTED
sleep_retention_module_bitmap_t modem_clk_dep_modules = (sleep_retention_module_bitmap_t){ .bitmap = { 0 } };
#endif
#if SOC_WIFI_SUPPORTED #if SOC_WIFI_SUPPORTED
modem_clk_dep_modules |= BIT(SLEEP_RETENTION_MODULE_WIFI_MAC) | BIT(SLEEP_RETENTION_MODULE_WIFI_BB); modem_clk_dep_modules.bitmap[SLEEP_RETENTION_MODULE_WIFI_MAC >> 5] |= BIT(SLEEP_RETENTION_MODULE_WIFI_MAC % 32);
modem_clk_dep_modules.bitmap[SLEEP_RETENTION_MODULE_WIFI_BB >> 5] |= BIT(SLEEP_RETENTION_MODULE_WIFI_BB % 32);
#endif #endif
#if SOC_BT_SUPPORTED #if SOC_BT_SUPPORTED
modem_clk_dep_modules |= BIT(SLEEP_RETENTION_MODULE_BLE_MAC) | BIT(SLEEP_RETENTION_MODULE_BT_BB); modem_clk_dep_modules.bitmap[SLEEP_RETENTION_MODULE_BLE_MAC >> 5] |= BIT(SLEEP_RETENTION_MODULE_BLE_MAC % 32);
modem_clk_dep_modules.bitmap[SLEEP_RETENTION_MODULE_BT_BB >> 5] |= BIT(SLEEP_RETENTION_MODULE_BT_BB % 32);
#endif #endif
#if SOC_IEEE802154_SUPPORTED #if SOC_IEEE802154_SUPPORTED
modem_clk_dep_modules |= BIT(SLEEP_RETENTION_MODULE_802154_MAC) | BIT(SLEEP_RETENTION_MODULE_BT_BB); modem_clk_dep_modules.bitmap[SLEEP_RETENTION_MODULE_802154_MAC >> 5] |= BIT(SLEEP_RETENTION_MODULE_802154_MAC % 32);
modem_clk_dep_modules.bitmap[SLEEP_RETENTION_MODULE_BT_BB >> 5] |= BIT(SLEEP_RETENTION_MODULE_BT_BB % 32);
#endif #endif
uint32_t mask = 0; const sleep_retention_module_bitmap_t null_module = (sleep_retention_module_bitmap_t){ .bitmap = { 0 } };
if (inited_modules & sys_clk_dep_modules) {
mask |= BIT(SLEEP_RETENTION_MODULE_CLOCK_SYSTEM); sleep_retention_module_bitmap_t mask = (sleep_retention_module_bitmap_t){ .bitmap = { 0 } };
const sleep_retention_module_bitmap_t system_modules = sleep_retention_module_bitmap_and(inited_modules, sys_clk_dep_modules);
if (!sleep_retention_module_bitmap_eq(system_modules, null_module)) {
mask.bitmap[SLEEP_RETENTION_MODULE_CLOCK_SYSTEM >> 5] |= BIT(SLEEP_RETENTION_MODULE_CLOCK_SYSTEM % 32);
} }
if (inited_modules & modem_clk_dep_modules) {
#if SOC_WIFI_SUPPORTED || SOC_BT_SUPPORTED || SOC_IEEE802154_SUPPORTED #if SOC_WIFI_SUPPORTED || SOC_BT_SUPPORTED || SOC_IEEE802154_SUPPORTED
mask |= BIT(SLEEP_RETENTION_MODULE_CLOCK_MODEM); const sleep_retention_module_bitmap_t modem_modules = sleep_retention_module_bitmap_and(inited_modules, modem_clk_dep_modules);
#endif if (!sleep_retention_module_bitmap_eq(modem_modules, null_module)) {
mask.bitmap[SLEEP_RETENTION_MODULE_CLOCK_MODEM >> 5] |= BIT(SLEEP_RETENTION_MODULE_CLOCK_MODEM % 32);
} }
return ((inited_modules & mask) == (created_modules & mask)); #endif
const sleep_retention_module_bitmap_t clock_domain_inited_modules = sleep_retention_module_bitmap_and(inited_modules, mask);
const sleep_retention_module_bitmap_t clock_domain_created_modules = sleep_retention_module_bitmap_and(created_modules, mask);
return sleep_retention_module_bitmap_eq(clock_domain_inited_modules, clock_domain_created_modules);
} }
ESP_SYSTEM_INIT_FN(sleep_clock_startup_init, SECONDARY, BIT(0), 106) ESP_SYSTEM_INIT_FN(sleep_clock_startup_init, SECONDARY, BIT(0), 106)

View File

@@ -285,21 +285,26 @@ inline __attribute__((always_inline)) bool sleep_modem_wifi_modem_link_done(void
bool modem_domain_pd_allowed(void) bool modem_domain_pd_allowed(void)
{ {
#if SOC_PM_MODEM_RETENTION_BY_REGDMA #if SOC_PM_MODEM_RETENTION_BY_REGDMA
const uint32_t inited_modules = sleep_retention_get_inited_modules(); const sleep_retention_module_bitmap_t inited_modules = sleep_retention_get_inited_modules();
const uint32_t created_modules = sleep_retention_get_created_modules(); const sleep_retention_module_bitmap_t created_modules = sleep_retention_get_created_modules();
uint32_t mask = 0; sleep_retention_module_bitmap_t mask = (sleep_retention_module_bitmap_t){ .bitmap = { 0 } };
#if SOC_WIFI_SUPPORTED #if SOC_WIFI_SUPPORTED
mask |= BIT(SLEEP_RETENTION_MODULE_WIFI_MAC) | BIT(SLEEP_RETENTION_MODULE_WIFI_BB); mask.bitmap[SLEEP_RETENTION_MODULE_WIFI_MAC >> 5] |= BIT(SLEEP_RETENTION_MODULE_WIFI_MAC % 32);
mask.bitmap[SLEEP_RETENTION_MODULE_WIFI_BB >> 5] |= BIT(SLEEP_RETENTION_MODULE_WIFI_BB % 32);
#endif #endif
#if SOC_BT_SUPPORTED #if SOC_BT_SUPPORTED
mask |= BIT(SLEEP_RETENTION_MODULE_BLE_MAC) | BIT(SLEEP_RETENTION_MODULE_BT_BB); mask.bitmap[SLEEP_RETENTION_MODULE_BLE_MAC >> 5] |= BIT(SLEEP_RETENTION_MODULE_BLE_MAC % 32);
mask.bitmap[SLEEP_RETENTION_MODULE_BT_BB >> 5] |= BIT(SLEEP_RETENTION_MODULE_BT_BB % 32);
#endif #endif
#if SOC_IEEE802154_SUPPORTED #if SOC_IEEE802154_SUPPORTED
mask |= BIT(SLEEP_RETENTION_MODULE_802154_MAC) | BIT(SLEEP_RETENTION_MODULE_BT_BB); mask.bitmap[SLEEP_RETENTION_MODULE_802154_MAC >> 5] |= BIT(SLEEP_RETENTION_MODULE_802154_MAC % 32);
mask.bitmap[SLEEP_RETENTION_MODULE_BT_BB >> 5] |= BIT(SLEEP_RETENTION_MODULE_BT_BB % 32);
#endif #endif
return ((inited_modules & mask) == (created_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);
return sleep_retention_module_bitmap_eq(modem_domain_inited_modules, modem_domain_created_modules);
#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

View File

@@ -38,8 +38,8 @@ struct sleep_retention_module_object {
static inline void sleep_retention_module_object_ctor(struct sleep_retention_module_object * const self, sleep_retention_module_callbacks_t *cbs) static inline void sleep_retention_module_object_ctor(struct sleep_retention_module_object * const self, sleep_retention_module_callbacks_t *cbs)
{ {
self->cbs = *cbs; self->cbs = *cbs;
self->dependents = 0; self->dependents = (sleep_retention_module_bitmap_t){ .bitmap = { 0 } };
self->references = 0; self->references = (sleep_retention_module_bitmap_t){ .bitmap = { 0 } };
self->attributes = 0; self->attributes = 0;
} }
@@ -55,7 +55,7 @@ static inline void set_dependencies(struct sleep_retention_module_object * const
static inline void clr_dependencies(struct sleep_retention_module_object * const self) static inline void clr_dependencies(struct sleep_retention_module_object * const self)
{ {
self->dependents = 0; self->dependents = (sleep_retention_module_bitmap_t){ .bitmap = { 0 } };
} }
static inline sleep_retention_module_bitmap_t get_dependencies(struct sleep_retention_module_object * const self) static inline sleep_retention_module_bitmap_t get_dependencies(struct sleep_retention_module_object * const self)
@@ -65,12 +65,12 @@ static inline sleep_retention_module_bitmap_t get_dependencies(struct sleep_rete
static inline void set_reference(struct sleep_retention_module_object * const self, sleep_retention_module_t module) static inline void set_reference(struct sleep_retention_module_object * const self, sleep_retention_module_t module)
{ {
self->references |= BIT(module); self->references.bitmap[module >> 5] |= BIT(module % 32);
} }
static inline void clr_reference(struct sleep_retention_module_object * const self, sleep_retention_module_t module) static inline void clr_reference(struct sleep_retention_module_object * const self, sleep_retention_module_t module)
{ {
self->references &= ~BIT(module); self->references.bitmap[module >> 5] &= ~BIT(module % 32);
} }
static inline sleep_retention_module_bitmap_t get_references(struct sleep_retention_module_object * const self) static inline sleep_retention_module_bitmap_t get_references(struct sleep_retention_module_object * const self)
@@ -80,7 +80,12 @@ static inline sleep_retention_module_bitmap_t get_references(struct sleep_retent
static inline bool references_exist(struct sleep_retention_module_object * const self) static inline bool references_exist(struct sleep_retention_module_object * const self)
{ {
return (get_references(self) != 0); uint32_t references = 0;
sleep_retention_module_bitmap_t map = get_references(self);
for (int i = 0; i < SLEEP_RETENTION_MODULE_BITMAP_SZ; i++) {
references |= map.bitmap[i];
}
return (references != 0);
} }
static inline void set_attributes(struct sleep_retention_module_object * const self, sleep_retention_module_attribute_t attributes) static inline void set_attributes(struct sleep_retention_module_object * const self, sleep_retention_module_attribute_t attributes)
@@ -105,12 +110,14 @@ static inline bool module_is_passive(struct sleep_retention_module_object * cons
static inline bool module_is_inited(sleep_retention_module_t module) static inline bool module_is_inited(sleep_retention_module_t module)
{ {
return (sleep_retention_get_inited_modules() & BIT(module)) ? true : false; sleep_retention_module_bitmap_t inited_modules = sleep_retention_get_inited_modules();
return (inited_modules.bitmap[module >> 5] & BIT(module % 32)) ? true : false;
} }
static inline bool module_is_created(sleep_retention_module_t module) static inline bool module_is_created(sleep_retention_module_t module)
{ {
return (sleep_retention_get_created_modules() & BIT(module)) ? true : false; sleep_retention_module_bitmap_t created_modules = sleep_retention_get_created_modules();
return (created_modules.bitmap[module >> 5] & BIT(module % 32)) ? true : false;
} }
/** /**
@@ -182,10 +189,10 @@ typedef struct {
} lists[SLEEP_RETENTION_REGDMA_LINK_NR_PRIORITIES]; } lists[SLEEP_RETENTION_REGDMA_LINK_NR_PRIORITIES];
_lock_t lock; _lock_t lock;
regdma_link_priority_t highpri; regdma_link_priority_t highpri;
uint32_t inited_modules; sleep_retention_module_bitmap_t inited_modules;
uint32_t created_modules; sleep_retention_module_bitmap_t created_modules;
struct sleep_retention_module_object instance[32]; struct sleep_retention_module_object instance[SLEEP_RETENTION_MODULE_MAX + 1];
#if SOC_PM_RETENTION_HAS_CLOCK_BUG #if SOC_PM_RETENTION_HAS_CLOCK_BUG
#define EXTRA_LINK_NUM (REGDMA_LINK_ENTRY_NUM - 1) #define EXTRA_LINK_NUM (REGDMA_LINK_ENTRY_NUM - 1)
@@ -193,7 +200,9 @@ typedef struct {
} sleep_retention_t; } sleep_retention_t;
static DRAM_ATTR __attribute__((unused)) sleep_retention_t s_retention = { static DRAM_ATTR __attribute__((unused)) sleep_retention_t s_retention = {
.highpri = (uint8_t)-1, .inited_modules = 0, .created_modules = 0 .highpri = (uint8_t)-1,
.inited_modules = (sleep_retention_module_bitmap_t){ .bitmap = { 0 } },
.created_modules = (sleep_retention_module_bitmap_t){ .bitmap = { 0 } }
}; };
#define SLEEP_RETENTION_ENTRY_BITMAP_MASK (BIT(REGDMA_LINK_ENTRY_NUM) - 1) #define SLEEP_RETENTION_ENTRY_BITMAP_MASK (BIT(REGDMA_LINK_ENTRY_NUM) - 1)
@@ -202,11 +211,6 @@ static DRAM_ATTR __attribute__((unused)) sleep_retention_t s_retention = {
static esp_err_t sleep_retention_entries_create_impl(const sleep_retention_entries_config_t retent[], int num, regdma_link_priority_t priority, sleep_retention_module_t module); static esp_err_t sleep_retention_entries_create_impl(const sleep_retention_entries_config_t retent[], int num, regdma_link_priority_t priority, sleep_retention_module_t module);
static void sleep_retention_entries_join(void); static void sleep_retention_entries_join(void);
static inline sleep_retention_module_bitmap_t module_num2map(sleep_retention_module_t module)
{
return (module == SLEEP_RETENTION_MODULE_INVALID) ? 0 : BIT(module);
}
static inline bool sleep_retention_entries_require_branch(uint32_t owner, uint32_t runtime_bitmap) static inline bool sleep_retention_entries_require_branch(uint32_t owner, uint32_t runtime_bitmap)
{ {
bool use_new_entry = SLEEP_RETENTION_ENTRY_BITMAP(owner & ~runtime_bitmap) ? true : false; bool use_new_entry = SLEEP_RETENTION_ENTRY_BITMAP(owner & ~runtime_bitmap) ? true : false;
@@ -265,9 +269,8 @@ static void * sleep_retention_entries_try_create(const regdma_link_config_t *con
_lock_acquire_recursive(&s_retention.lock); _lock_acquire_recursive(&s_retention.lock);
if (sleep_retention_entries_require_branch(owner, s_retention.lists[priority].runtime_bitmap)) { if (sleep_retention_entries_require_branch(owner, s_retention.lists[priority].runtime_bitmap)) {
if (sleep_retention_entries_check_and_create_default(owner, s_retention.lists[priority].runtime_bitmap, if (sleep_retention_entries_check_and_create_default(owner, s_retention.lists[priority].runtime_bitmap,
s_retention.lists[priority].entries_bitmap, priority, module_num2map(module)) == ESP_OK) { /* branch node can't as tail node */ s_retention.lists[priority].entries_bitmap, priority, module) == ESP_OK) { /* branch node can't as tail node */
link = regdma_link_init_safe( link = regdma_link_init_safe(config, true, module,
config, true, module_num2map(module),
(owner & BIT(0)) ? s_retention.lists[priority].entries[0] : NULL, (owner & BIT(0)) ? s_retention.lists[priority].entries[0] : NULL,
(owner & BIT(1)) ? s_retention.lists[priority].entries[1] : NULL, (owner & BIT(1)) ? s_retention.lists[priority].entries[1] : NULL,
(owner & BIT(2)) ? s_retention.lists[priority].entries[2] : NULL, (owner & BIT(2)) ? s_retention.lists[priority].entries[2] : NULL,
@@ -275,7 +278,7 @@ static void * sleep_retention_entries_try_create(const regdma_link_config_t *con
); );
} }
} else { } else {
link = regdma_link_init_safe(config, false, module_num2map(module), s_retention.lists[priority].entries[__builtin_ffs(owner) - 1]); link = regdma_link_init_safe(config, false, module, s_retention.lists[priority].entries[__builtin_ffs(owner) - 1]);
} }
_lock_release_recursive(&s_retention.lock); _lock_release_recursive(&s_retention.lock);
return link; return link;
@@ -285,8 +288,7 @@ static void * sleep_retention_entries_try_create_bonding(const regdma_link_confi
{ {
assert(owner > 0 && owner < BIT(REGDMA_LINK_ENTRY_NUM)); assert(owner > 0 && owner < BIT(REGDMA_LINK_ENTRY_NUM));
_lock_acquire_recursive(&s_retention.lock); _lock_acquire_recursive(&s_retention.lock);
void *link = regdma_link_init_safe( void *link = regdma_link_init_safe(config, true, module,
config, true, module_num2map(module),
(owner & BIT(0)) ? s_retention.lists[priority].entries[0] : NULL, (owner & BIT(0)) ? s_retention.lists[priority].entries[0] : NULL,
(owner & BIT(1)) ? s_retention.lists[priority].entries[1] : NULL, (owner & BIT(1)) ? s_retention.lists[priority].entries[1] : NULL,
(owner & BIT(2)) ? s_retention.lists[priority].entries[2] : NULL, (owner & BIT(2)) ? s_retention.lists[priority].entries[2] : NULL,
@@ -355,13 +357,13 @@ static bool sleep_retention_entries_get_destroy_context(regdma_link_priority_t p
_lock_acquire_recursive(&s_retention.lock); _lock_acquire_recursive(&s_retention.lock);
for (int entry = 0; entry < ARRAY_SIZE(s_retention.lists[priority].entries); entry++) { for (int entry = 0; entry < ARRAY_SIZE(s_retention.lists[priority].entries); entry++) {
(*destroy_entries)[entry] = regdma_find_module_link_head( (*destroy_entries)[entry] = regdma_find_module_link_head(
s_retention.lists[priority].entries[entry], s_retention.lists[priority].entries_tail, entry, module_num2map(module)); s_retention.lists[priority].entries[entry], s_retention.lists[priority].entries_tail, entry, module);
destroy_tails [entry] = regdma_find_module_link_tail( destroy_tails [entry] = regdma_find_module_link_tail(
s_retention.lists[priority].entries[entry], s_retention.lists[priority].entries_tail, entry, module_num2map(module)); s_retention.lists[priority].entries[entry], s_retention.lists[priority].entries_tail, entry, module);
(*next_entries) [entry] = regdma_find_next_module_link_head( (*next_entries) [entry] = regdma_find_next_module_link_head(
s_retention.lists[priority].entries[entry], s_retention.lists[priority].entries_tail, entry, module_num2map(module)); s_retention.lists[priority].entries[entry], s_retention.lists[priority].entries_tail, entry, module);
prev_tails [entry] = regdma_find_prev_module_link_tail( prev_tails [entry] = regdma_find_prev_module_link_tail(
s_retention.lists[priority].entries[entry], s_retention.lists[priority].entries_tail, entry, module_num2map(module)); s_retention.lists[priority].entries[entry], s_retention.lists[priority].entries_tail, entry, module);
if ((*destroy_entries)[entry] && destroy_tails[entry]) { if ((*destroy_entries)[entry] && destroy_tails[entry]) {
exist = true; exist = true;
} }
@@ -420,7 +422,11 @@ static void sleep_retention_entries_check_and_distroy_final_default(void)
{ {
_lock_acquire_recursive(&s_retention.lock); _lock_acquire_recursive(&s_retention.lock);
assert(s_retention.highpri == SLEEP_RETENTION_REGDMA_LINK_LOWEST_PRIORITY); assert(s_retention.highpri == SLEEP_RETENTION_REGDMA_LINK_LOWEST_PRIORITY);
assert(s_retention.created_modules == 0); uint32_t created_modules = 0;
for (int i = 0; i < SLEEP_RETENTION_MODULE_BITMAP_SZ; i++) {
created_modules |= s_retention.created_modules.bitmap[i];
}
assert(created_modules == 0);
sleep_retention_entries_destroy_wrapper(&s_retention.lists[SLEEP_RETENTION_REGDMA_LINK_LOWEST_PRIORITY].entries); sleep_retention_entries_destroy_wrapper(&s_retention.lists[SLEEP_RETENTION_REGDMA_LINK_LOWEST_PRIORITY].entries);
_lock_release_recursive(&s_retention.lock); _lock_release_recursive(&s_retention.lock);
} }
@@ -446,7 +452,7 @@ static void sleep_retention_entries_all_destroy_wrapper(sleep_retention_module_t
priority++; priority++;
} }
} while (priority < SLEEP_RETENTION_REGDMA_LINK_NR_PRIORITIES); } while (priority < SLEEP_RETENTION_REGDMA_LINK_NR_PRIORITIES);
s_retention.created_modules &= ~module_num2map(module); s_retention.created_modules.bitmap[module >> 5] &= ~BIT(module % 32);
_lock_release_recursive(&s_retention.lock); _lock_release_recursive(&s_retention.lock);
} }
@@ -465,7 +471,11 @@ static void sleep_retention_entries_destroy(sleep_retention_module_t module)
assert(SLEEP_RETENTION_MODULE_MIN <= module && module <= SLEEP_RETENTION_MODULE_MAX); assert(SLEEP_RETENTION_MODULE_MIN <= module && module <= SLEEP_RETENTION_MODULE_MAX);
_lock_acquire_recursive(&s_retention.lock); _lock_acquire_recursive(&s_retention.lock);
sleep_retention_entries_do_destroy(module); sleep_retention_entries_do_destroy(module);
if (s_retention.created_modules == 0) { uint32_t created_modules = 0;
for (int i = 0; i < SLEEP_RETENTION_MODULE_BITMAP_SZ; i++) {
created_modules |= s_retention.created_modules.bitmap[i];
}
if (created_modules == 0) {
sleep_retention_entries_check_and_distroy_final_default(); sleep_retention_entries_check_and_distroy_final_default();
pmu_sleep_disable_regdma_backup(); pmu_sleep_disable_regdma_backup();
memset((void *)s_retention.lists, 0, sizeof(s_retention.lists)); memset((void *)s_retention.lists, 0, sizeof(s_retention.lists));
@@ -570,7 +580,7 @@ static esp_err_t sleep_retention_entries_create_wrapper(const sleep_retention_en
if(err) goto error; if(err) goto error;
err = sleep_retention_entries_create_bonding(priority, module); err = sleep_retention_entries_create_bonding(priority, module);
if(err) goto error; if(err) goto error;
s_retention.created_modules |= module_num2map(module); s_retention.created_modules.bitmap[module >> 5] |= BIT(module % 32);
sleep_retention_entries_join(); sleep_retention_entries_join();
error: error:
@@ -611,16 +621,72 @@ void sleep_retention_entries_get(sleep_retention_entries_t *entries)
_lock_release_recursive(&s_retention.lock); _lock_release_recursive(&s_retention.lock);
} }
uint32_t IRAM_ATTR sleep_retention_get_inited_modules(void) sleep_retention_module_bitmap_t IRAM_ATTR sleep_retention_get_inited_modules(void)
{ {
return s_retention.inited_modules; return s_retention.inited_modules;
} }
uint32_t IRAM_ATTR sleep_retention_get_created_modules(void) sleep_retention_module_bitmap_t IRAM_ATTR sleep_retention_get_created_modules(void)
{ {
return s_retention.created_modules; return s_retention.created_modules;
} }
bool sleep_retention_is_module_inited(sleep_retention_module_t module)
{
if (module < SLEEP_RETENTION_MODULE_MIN || module > SLEEP_RETENTION_MODULE_MAX) {
return false;
}
_lock_acquire_recursive(&s_retention.lock);
bool inited = module_is_inited(module);
_lock_release_recursive(&s_retention.lock);
return inited;
}
bool sleep_retention_is_module_created(sleep_retention_module_t module)
{
if (module < SLEEP_RETENTION_MODULE_MIN || module > SLEEP_RETENTION_MODULE_MAX) {
return false;
}
_lock_acquire_recursive(&s_retention.lock);
bool created = module_is_created(module);
_lock_release_recursive(&s_retention.lock);
return created;
}
sleep_retention_module_bitmap_t IRAM_ATTR sleep_retention_module_bitmap_and(sleep_retention_module_bitmap_t op0, sleep_retention_module_bitmap_t op1)
{
sleep_retention_module_bitmap_t and;
for (int i = 0; i < ARRAY_SIZE(and.bitmap); i++) {
and.bitmap[i] = op0.bitmap[i] & op1.bitmap[i];
}
return and;
}
sleep_retention_module_bitmap_t IRAM_ATTR sleep_retention_module_bitmap_or(sleep_retention_module_bitmap_t op0, sleep_retention_module_bitmap_t op1)
{
sleep_retention_module_bitmap_t or;
for (int i = 0; i < ARRAY_SIZE(or.bitmap); i++) {
or.bitmap[i] = op0.bitmap[i] | op1.bitmap[i];
}
return or;
}
sleep_retention_module_bitmap_t IRAM_ATTR sleep_retention_module_bitmap_not(sleep_retention_module_bitmap_t op)
{
sleep_retention_module_bitmap_t not;
for (int i = 0; i < ARRAY_SIZE(not.bitmap); i++) {
not.bitmap[i] = ~op.bitmap[i];
}
return not;
}
bool IRAM_ATTR sleep_retention_module_bitmap_eq(sleep_retention_module_bitmap_t op0, sleep_retention_module_bitmap_t op1)
{
for (int i = 0; i < ARRAY_SIZE(op0.bitmap); i++) {
if (op0.bitmap[i] != op1.bitmap[i]) {
return false;
}
}
return true;
}
esp_err_t sleep_retention_module_init(sleep_retention_module_t module, sleep_retention_module_init_param_t *param) esp_err_t sleep_retention_module_init(sleep_retention_module_t module, sleep_retention_module_init_param_t *param)
{ {
if (module < SLEEP_RETENTION_MODULE_MIN || module > SLEEP_RETENTION_MODULE_MAX) { if (module < SLEEP_RETENTION_MODULE_MIN || module > SLEEP_RETENTION_MODULE_MAX) {
@@ -648,7 +714,7 @@ esp_err_t sleep_retention_module_init(sleep_retention_module_t module, sleep_ret
sleep_retention_module_object_ctor(&s_retention.instance[module], &param->cbs); sleep_retention_module_object_ctor(&s_retention.instance[module], &param->cbs);
set_dependencies(&s_retention.instance[module], param->depends); set_dependencies(&s_retention.instance[module], param->depends);
set_attributes(&s_retention.instance[module], param->attribute); set_attributes(&s_retention.instance[module], param->attribute);
s_retention.inited_modules |= module_num2map(module); s_retention.inited_modules.bitmap[module >> 5] |= BIT(module % 32);
} }
_lock_release_recursive(&s_retention.lock); _lock_release_recursive(&s_retention.lock);
return err; return err;
@@ -669,8 +735,12 @@ esp_err_t sleep_retention_module_deinit(sleep_retention_module_t module)
clr_attributes(&s_retention.instance[module]); clr_attributes(&s_retention.instance[module]);
clr_dependencies(&s_retention.instance[module]); clr_dependencies(&s_retention.instance[module]);
sleep_retention_module_object_dtor(&s_retention.instance[module]); sleep_retention_module_object_dtor(&s_retention.instance[module]);
s_retention.inited_modules &= ~module_num2map(module); s_retention.inited_modules.bitmap[module >> 5] &= ~BIT(module % 32);
do_lock_release = (sleep_retention_get_inited_modules() == 0); uint32_t inited_modules = 0;
for (int i = 0; i < SLEEP_RETENTION_MODULE_BITMAP_SZ; i++) {
inited_modules |= s_retention.inited_modules.bitmap[i];
}
do_lock_release = (inited_modules == 0);
} }
_lock_release_recursive(&s_retention.lock); _lock_release_recursive(&s_retention.lock);
@@ -691,10 +761,13 @@ static esp_err_t sleep_retention_passive_module_allocate(sleep_retention_module_
assert(module_is_inited(module) && "All passive module must be inited first!"); assert(module_is_inited(module) && "All passive module must be inited first!");
if (!module_is_created(module)) { if (!module_is_created(module)) {
sleep_retention_module_bitmap_t depends = get_dependencies(&s_retention.instance[module]); sleep_retention_module_bitmap_t depends = get_dependencies(&s_retention.instance[module]);
for (int i = 0; (err == ESP_OK) && depends; depends >>= 1, i++) { for (int i = 0; ((err == ESP_OK) && (i < SLEEP_RETENTION_MODULE_BITMAP_SZ)); i++) {
if (depends & BIT(0)) { uint32_t bitmap = depends.bitmap[i];
set_reference(&s_retention.instance[i], module); for (int j = 0; (err == ESP_OK) && bitmap; bitmap >>= 1, j++) {
err = sleep_retention_passive_module_allocate(i); if (bitmap & BIT(0)) {
set_reference(&s_retention.instance[(i << 5) + j], module);
err = sleep_retention_passive_module_allocate((i << 5) + j);
}
} }
} }
if (err == ESP_OK) { if (err == ESP_OK) {
@@ -719,11 +792,14 @@ esp_err_t sleep_retention_module_allocate(sleep_retention_module_t module)
if (!module_is_passive(&s_retention.instance[module])) { if (!module_is_passive(&s_retention.instance[module])) {
if (module_is_inited(module) && !module_is_created(module)) { if (module_is_inited(module) && !module_is_created(module)) {
sleep_retention_module_bitmap_t depends = get_dependencies(&s_retention.instance[module]); sleep_retention_module_bitmap_t depends = get_dependencies(&s_retention.instance[module]);
for (int i = 0; (err == ESP_OK) && depends; depends >>= 1, i++) { for (int i = 0; ((err == ESP_OK) && (i < SLEEP_RETENTION_MODULE_BITMAP_SZ)); i++) {
if (depends & BIT(0)) { uint32_t bitmap = depends.bitmap[i];
set_reference(&s_retention.instance[i], module); for (int j = 0; (err == ESP_OK) && bitmap; bitmap >>= 1, j++) {
if (module_is_passive(&s_retention.instance[i])) { /* the callee ensures this module is inited */ if (bitmap & BIT(0)) {
err = sleep_retention_passive_module_allocate(i); set_reference(&s_retention.instance[(i << 5) + j], module);
if (module_is_passive(&s_retention.instance[(i << 5) + j])) { /* the callee ensures this module is inited */
err = sleep_retention_passive_module_allocate((i << 5) + j);
}
} }
} }
} }
@@ -756,10 +832,13 @@ static esp_err_t sleep_retention_passive_module_free(sleep_retention_module_t mo
sleep_retention_entries_destroy(module); sleep_retention_entries_destroy(module);
sleep_retention_module_bitmap_t depends = get_dependencies(&s_retention.instance[module]); sleep_retention_module_bitmap_t depends = get_dependencies(&s_retention.instance[module]);
for (int i = 0; (err == ESP_OK) && depends; depends >>= 1, i++) { for (int i = 0; ((err == ESP_OK) && (i < SLEEP_RETENTION_MODULE_BITMAP_SZ)); i++) {
if (depends & BIT(0)) { uint32_t bitmap = depends.bitmap[i];
clr_reference(&s_retention.instance[i], module); for (int j = 0; (err == ESP_OK) && bitmap; bitmap >>= 1, j++) {
err = sleep_retention_passive_module_free(i); if (bitmap & BIT(0)) {
clr_reference(&s_retention.instance[(i << 5) + j], module);
err = sleep_retention_passive_module_free((i << 5) + j);
}
} }
} }
} }
@@ -781,11 +860,14 @@ esp_err_t sleep_retention_module_free(sleep_retention_module_t module)
sleep_retention_entries_destroy(module); sleep_retention_entries_destroy(module);
sleep_retention_module_bitmap_t depends = get_dependencies(&s_retention.instance[module]); sleep_retention_module_bitmap_t depends = get_dependencies(&s_retention.instance[module]);
for (int i = 0; (err == ESP_OK) && depends; depends >>= 1, i++) { for (int i = 0; ((err == ESP_OK) && (i < SLEEP_RETENTION_MODULE_BITMAP_SZ)); i++) {
if (depends & BIT(0)) { uint32_t bitmap = depends.bitmap[i];
clr_reference(&s_retention.instance[i], module); for (int j = 0; (err == ESP_OK) && bitmap; bitmap >>= 1, j++) {
if (module_is_passive(&s_retention.instance[i])) { if (bitmap & BIT(0)) {
err = sleep_retention_passive_module_free(i); clr_reference(&s_retention.instance[(i << 5) + j], module);
if (module_is_passive(&s_retention.instance[(i << 5) + j])) {
err = sleep_retention_passive_module_free((i << 5) + j);
}
} }
} }
} }

View File

@@ -159,9 +159,116 @@ error:
bool peripheral_domain_pd_allowed(void) bool peripheral_domain_pd_allowed(void)
{ {
#if CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP #if CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP
const uint32_t inited_modules = sleep_retention_get_inited_modules(); const sleep_retention_module_bitmap_t inited_modules = sleep_retention_get_inited_modules();
const uint32_t created_modules = sleep_retention_get_created_modules(); const sleep_retention_module_bitmap_t created_modules = sleep_retention_get_created_modules();
return (((inited_modules ^ created_modules) & TOP_DOMAIN_PERIPHERALS_BM) == 0);
sleep_retention_module_bitmap_t mask = (sleep_retention_module_bitmap_t){ .bitmap = { 0 } };
mask.bitmap[SLEEP_RETENTION_MODULE_SYS_PERIPH >> 5] |= BIT(SLEEP_RETENTION_MODULE_SYS_PERIPH % 32);
#if SOC_MWDT_SUPPORT_SLEEP_RETENTION
mask.bitmap[SLEEP_RETENTION_MODULE_TG0_WDT >> 5] |= BIT(SLEEP_RETENTION_MODULE_TG0_WDT % 32);
mask.bitmap[SLEEP_RETENTION_MODULE_TG1_WDT >> 5] |= BIT(SLEEP_RETENTION_MODULE_TG1_WDT % 32);
#endif
#if SOC_TIMER_SUPPORT_SLEEP_RETENTION
mask.bitmap[SLEEP_RETENTION_MODULE_TG0_TIMER0 >> 5] |= BIT(SLEEP_RETENTION_MODULE_TG0_TIMER0 % 32);
mask.bitmap[SLEEP_RETENTION_MODULE_TG1_TIMER0 >> 5] |= BIT(SLEEP_RETENTION_MODULE_TG1_TIMER0 % 32);
# if (SOC_TIMER_GROUP_TIMERS_PER_GROUP > 1)
mask.bitmap[SLEEP_RETENTION_MODULE_TG0_TIMER1 >> 5] |= BIT(SLEEP_RETENTION_MODULE_TG0_TIMER1 % 32);
mask.bitmap[SLEEP_RETENTION_MODULE_TG1_TIMER1 >> 5] |= BIT(SLEEP_RETENTION_MODULE_TG1_TIMER1 % 32);
# endif
#endif
#if SOC_ADC_SUPPORTED && !CONFIG_IDF_TARGET_ESP32P4 // TODO: IDF-11369
mask.bitmap[SLEEP_RETENTION_MODULE_ADC >> 5] |= BIT(SLEEP_RETENTION_MODULE_ADC % 32);
#endif
#if SOC_UART_SUPPORT_SLEEP_RETENTION
mask.bitmap[SLEEP_RETENTION_MODULE_UART0 >> 5] |= BIT(SLEEP_RETENTION_MODULE_UART0 % 32);
mask.bitmap[SLEEP_RETENTION_MODULE_UART1 >> 5] |= BIT(SLEEP_RETENTION_MODULE_UART1 % 32);
# if (SOC_UART_HP_NUM > 2) && !CONFIG_IDF_TARGET_ESP32C61 // TODO: IDF-11370
mask.bitmap[SLEEP_RETENTION_MODULE_UART2 >> 5] |= BIT(SLEEP_RETENTION_MODULE_UART2 % 32);
# endif
# if (SOC_UART_HP_NUM > 3)
mask.bitmap[SLEEP_RETENTION_MODULE_UART3 >> 5] |= BIT(SLEEP_RETENTION_MODULE_UART3 % 32);
# endif
# if (SOC_UART_HP_NUM > 4)
mask.bitmap[SLEEP_RETENTION_MODULE_UART4 >> 5] |= BIT(SLEEP_RETENTION_MODULE_UART4 % 32);
# endif
#endif /* SOC_UART_SUPPORT_SLEEP_RETENTION */
#if SOC_RMT_SUPPORT_SLEEP_RETENTION
mask.bitmap[SLEEP_RETENTION_MODULE_RMT0 >> 5] |= BIT(SLEEP_RETENTION_MODULE_RMT0 % 32);
#endif
#if SOC_GDMA_SUPPORT_SLEEP_RETENTION
# if SOC_GDMA_SUPPORTED && !CONFIG_IDF_TARGET_ESP32P4 // TODO: IDF-11371
mask.bitmap[SLEEP_RETENTION_MODULE_GDMA_CH0 >> 5] |= BIT(SLEEP_RETENTION_MODULE_GDMA_CH0 % 32);
mask.bitmap[SLEEP_RETENTION_MODULE_GDMA_CH1 >> 5] |= BIT(SLEEP_RETENTION_MODULE_GDMA_CH1 % 32);
# if (SOC_GDMA_PAIRS_PER_GROUP_MAX > 2)
mask.bitmap[SLEEP_RETENTION_MODULE_GDMA_CH2 >> 5] |= BIT(SLEEP_RETENTION_MODULE_GDMA_CH2 % 32);
# endif
# endif /* SOC_GDMA_SUPPORTED */
# if SOC_AHB_GDMA_SUPPORTED && CONFIG_IDF_TARGET_ESP32P4 // TODO: IDF-11372
mask.bitmap[SLEEP_RETENTION_MODULE_AHB_DMA_CH0 >> 5] |= BIT(SLEEP_RETENTION_MODULE_AHB_DMA_CH0 % 32);
mask.bitmap[SLEEP_RETENTION_MODULE_AHB_DMA_CH1 >> 5] |= BIT(SLEEP_RETENTION_MODULE_AHB_DMA_CH1 % 32);
mask.bitmap[SLEEP_RETENTION_MODULE_AHB_DMA_CH2 >> 5] |= BIT(SLEEP_RETENTION_MODULE_AHB_DMA_CH2 % 32);
# endif /* SOC_AHB_GDMA_SUPPORTED */
# if SOC_AXI_GDMA_SUPPORTED
mask.bitmap[SLEEP_RETENTION_MODULE_AXI_DMA_CH0 >> 5] |= BIT(SLEEP_RETENTION_MODULE_AXI_DMA_CH0 % 32);
mask.bitmap[SLEEP_RETENTION_MODULE_AXI_DMA_CH1 >> 5] |= BIT(SLEEP_RETENTION_MODULE_AXI_DMA_CH1 % 32);
mask.bitmap[SLEEP_RETENTION_MODULE_AXI_DMA_CH2 >> 5] |= BIT(SLEEP_RETENTION_MODULE_AXI_DMA_CH2 % 32);
# endif /* SOC_AXI_GDMA_SUPPORTED */
#endif /* SOC_GDMA_SUPPORT_SLEEP_RETENTION */
#if SOC_I2S_SUPPORT_SLEEP_RETENTION
mask.bitmap[SLEEP_RETENTION_MODULE_I2S0 >> 5] |= BIT(SLEEP_RETENTION_MODULE_I2S0 % 32);
# if (SOC_I2S_NUM > 1)
mask.bitmap[SLEEP_RETENTION_MODULE_I2S1 >> 5] |= BIT(SLEEP_RETENTION_MODULE_I2S1 % 32);
# endif
# if (SOC_I2S_NUM > 2)
mask.bitmap[SLEEP_RETENTION_MODULE_I2S2 >> 5] |= BIT(SLEEP_RETENTION_MODULE_I2S2 % 32);
# endif
#endif /* SOC_I2S_SUPPORT_SLEEP_RETENTION */
#if SOC_I2C_SUPPORT_SLEEP_RETENTION
mask.bitmap[SLEEP_RETENTION_MODULE_I2C0 >> 5] |= BIT(SLEEP_RETENTION_MODULE_I2C0 % 32);
# if (SOC_HP_I2C_NUM > 1)
mask.bitmap[SLEEP_RETENTION_MODULE_I2C1 >> 5] |= BIT(SLEEP_RETENTION_MODULE_I2C1 % 32);
# endif
#endif /* SOC_I2C_SUPPORT_SLEEP_RETENTION */
#if SOC_ETM_SUPPORT_SLEEP_RETENTION
mask.bitmap[SLEEP_RETENTION_MODULE_ETM0 >> 5] |= BIT(SLEEP_RETENTION_MODULE_ETM0 % 32);
#endif
#if SOC_TWAI_SUPPORT_SLEEP_RETENTION
mask.bitmap[SLEEP_RETENTION_MODULE_TWAI0 >> 5] |= BIT(SLEEP_RETENTION_MODULE_TWAI0 % 32);
# if (SOC_TWAI_CONTROLLER_NUM > 1)
mask.bitmap[SLEEP_RETENTION_MODULE_TWAI1 >> 5] |= BIT(SLEEP_RETENTION_MODULE_TWAI1 % 32);
# endif
# if (SOC_TWAI_CONTROLLER_NUM > 2)
mask.bitmap[SLEEP_RETENTION_MODULE_TWAI2 >> 5] |= BIT(SLEEP_RETENTION_MODULE_TWAI2 % 32);
# endif
#endif /* SOC_TWAI_SUPPORT_SLEEP_RETENTION */
#if SOC_PARLIO_SUPPORT_SLEEP_RETENTION
mask.bitmap[SLEEP_RETENTION_MODULE_PARLIO0 >> 5] |= BIT(SLEEP_RETENTION_MODULE_PARLIO0 % 32);
#endif
#if SOC_LEDC_SUPPORT_SLEEP_RETENTION
mask.bitmap[SLEEP_RETENTION_MODULE_LEDC >> 5] |= BIT(SLEEP_RETENTION_MODULE_LEDC % 32);
#endif
#if SOC_PCNT_SUPPORT_SLEEP_RETENTION
mask.bitmap[SLEEP_RETENTION_MODULE_PCNT0 >> 5] |= BIT(SLEEP_RETENTION_MODULE_PCNT0 % 32);
#endif
#if SOC_MCPWM_SUPPORT_SLEEP_RETENTION
mask.bitmap[SLEEP_RETENTION_MODULE_MCPWM0 >> 5] |= BIT(SLEEP_RETENTION_MODULE_MCPWM0 % 32);
#endif
const sleep_retention_module_bitmap_t peripheral_domain_inited_modules = sleep_retention_module_bitmap_and(inited_modules, mask);
const sleep_retention_module_bitmap_t peripheral_domain_created_modules = sleep_retention_module_bitmap_and(created_modules, mask);
return sleep_retention_module_bitmap_eq(peripheral_domain_inited_modules, peripheral_domain_created_modules);
#else #else
return false; return false;
#endif #endif
@@ -172,7 +279,7 @@ ESP_SYSTEM_INIT_FN(sleep_sys_periph_startup_init, SECONDARY, BIT(0), 107)
{ {
sleep_retention_module_init_param_t init_param = { sleep_retention_module_init_param_t init_param = {
.cbs = { .create = { .handle = sleep_sys_periph_retention_init, .arg = NULL } }, .cbs = { .create = { .handle = sleep_sys_periph_retention_init, .arg = NULL } },
.depends = BIT(SLEEP_RETENTION_MODULE_CLOCK_SYSTEM) .depends.bitmap[SLEEP_RETENTION_MODULE_CLOCK_SYSTEM >> 5] = BIT(SLEEP_RETENTION_MODULE_CLOCK_SYSTEM % 32)
}; };
esp_err_t err = sleep_retention_module_init(SLEEP_RETENTION_MODULE_SYS_PERIPH, &init_param); esp_err_t err = sleep_retention_module_init(SLEEP_RETENTION_MODULE_SYS_PERIPH, &init_param);
if (err == ESP_OK) { if (err == ESP_OK) {

View File

@@ -63,7 +63,7 @@ void esp_btbb_enable(void)
#if SOC_PM_MODEM_RETENTION_BY_REGDMA && CONFIG_FREERTOS_USE_TICKLESS_IDLE #if SOC_PM_MODEM_RETENTION_BY_REGDMA && CONFIG_FREERTOS_USE_TICKLESS_IDLE
sleep_retention_module_init_param_t init_param = { sleep_retention_module_init_param_t init_param = {
.cbs = { .create = { .handle = btbb_sleep_retention_init, .arg = NULL } }, .cbs = { .create = { .handle = btbb_sleep_retention_init, .arg = NULL } },
.depends = BIT(SLEEP_RETENTION_MODULE_CLOCK_MODEM) .depends = RETENTION_MODULE_BITMAP_INIT(CLOCK_MODEM)
}; };
esp_err_t err = sleep_retention_module_init(SLEEP_RETENTION_MODULE_BT_BB, &init_param); esp_err_t err = sleep_retention_module_init(SLEEP_RETENTION_MODULE_BT_BB, &init_param);
if (err == ESP_OK) { if (err == ESP_OK) {

View File

@@ -520,7 +520,7 @@ void esp_mac_bb_pd_mem_init(void)
#elif SOC_PM_MODEM_RETENTION_BY_REGDMA #elif 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 = sleep_retention_wifi_bb_init, .arg = NULL } }, .cbs = { .create = { .handle = sleep_retention_wifi_bb_init, .arg = NULL } },
.depends = BIT(SLEEP_RETENTION_MODULE_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);
if (err != ESP_OK) { if (err != ESP_OK) {

View File

@@ -72,7 +72,7 @@ static esp_err_t esp_int_wdt_retention_enable(uint32_t group_id)
{ {
sleep_retention_module_init_param_t init_param = { sleep_retention_module_init_param_t init_param = {
.cbs = { .create = { .handle = sleep_int_wdt_retention_init, .arg = &group_id } }, .cbs = { .create = { .handle = sleep_int_wdt_retention_init, .arg = &group_id } },
.depends = BIT(SLEEP_RETENTION_MODULE_CLOCK_SYSTEM) .depends = RETENTION_MODULE_BITMAP_INIT(CLOCK_SYSTEM)
}; };
esp_err_t err = sleep_retention_module_init((group_id == 0) ? SLEEP_RETENTION_MODULE_TG0_WDT : SLEEP_RETENTION_MODULE_TG1_WDT, &init_param); esp_err_t err = sleep_retention_module_init((group_id == 0) ? SLEEP_RETENTION_MODULE_TG0_WDT : SLEEP_RETENTION_MODULE_TG1_WDT, &init_param);
if (err == ESP_OK) { if (err == ESP_OK) {

View File

@@ -65,7 +65,7 @@ static esp_err_t esp_task_wdt_retention_enable(uint32_t group_id)
{ {
sleep_retention_module_init_param_t init_param = { sleep_retention_module_init_param_t init_param = {
.cbs = { .create = { .handle = sleep_task_wdt_retention_init, .arg = &group_id } }, .cbs = { .create = { .handle = sleep_task_wdt_retention_init, .arg = &group_id } },
.depends = BIT(SLEEP_RETENTION_MODULE_CLOCK_SYSTEM) .depends = RETENTION_MODULE_BITMAP_INIT(CLOCK_SYSTEM)
}; };
esp_err_t err = sleep_retention_module_init((group_id == 0) ? SLEEP_RETENTION_MODULE_TG0_WDT : SLEEP_RETENTION_MODULE_TG1_WDT, &init_param); esp_err_t err = sleep_retention_module_init((group_id == 0) ? SLEEP_RETENTION_MODULE_TG0_WDT : SLEEP_RETENTION_MODULE_TG1_WDT, &init_param);
if (err == ESP_OK) { if (err == ESP_OK) {

View File

@@ -352,8 +352,9 @@ 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 } },
.depends = BIT(SLEEP_RETENTION_MODULE_WIFI_BB) | BIT(SLEEP_RETENTION_MODULE_CLOCK_MODEM)
}; };
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);
esp_err_t err = sleep_retention_module_init(SLEEP_RETENTION_MODULE_WIFI_MAC, &init_param); esp_err_t err = sleep_retention_module_init(SLEEP_RETENTION_MODULE_WIFI_MAC, &init_param);
if (err != ESP_OK) { if (err != ESP_OK) {
ESP_LOGW(TAG, "WiFi MAC sleep retention init failed"); ESP_LOGW(TAG, "WiFi MAC sleep retention init failed");

View File

@@ -1009,10 +1009,9 @@ static esp_err_t ieee802154_sleep_init(void)
{ {
esp_err_t err = ESP_OK; esp_err_t err = ESP_OK;
#if CONFIG_PM_ENABLE #if CONFIG_PM_ENABLE
sleep_retention_module_init_param_t init_param = { sleep_retention_module_init_param_t init_param = { .cbs = { .create = { .handle = ieee802154_sleep_retention_init, .arg = NULL } } };
.cbs = { .create = { .handle = ieee802154_sleep_retention_init, .arg = NULL } }, init_param.depends.bitmap[SLEEP_RETENTION_MODULE_BT_BB >> 5] |= BIT(SLEEP_RETENTION_MODULE_BT_BB % 32);
.depends = BIT(SLEEP_RETENTION_MODULE_BT_BB) | BIT(SLEEP_RETENTION_MODULE_CLOCK_MODEM) init_param.depends.bitmap[SLEEP_RETENTION_MODULE_CLOCK_MODEM >> 5] |= BIT(SLEEP_RETENTION_MODULE_CLOCK_MODEM % 32);
};
err = sleep_retention_module_init(SLEEP_RETENTION_MODULE_802154_MAC, &init_param); err = sleep_retention_module_init(SLEEP_RETENTION_MODULE_802154_MAC, &init_param);
if (err == ESP_OK) { if (err == ESP_OK) {
err = sleep_retention_module_allocate(SLEEP_RETENTION_MODULE_802154_MAC); err = sleep_retention_module_allocate(SLEEP_RETENTION_MODULE_802154_MAC);

View File

@@ -707,6 +707,10 @@ config SOC_PM_PAU_LINK_NUM
int int
default 4 default 4
config SOC_PM_RETENTION_MODULE_NUM
int
default 32
config SOC_CLK_RC_FAST_SUPPORT_CALIBRATION config SOC_CLK_RC_FAST_SUPPORT_CALIBRATION
bool bool
default y default y

View File

@@ -7,7 +7,7 @@
#pragma once #pragma once
#include <stdint.h> #include <stdint.h>
#include "esp_bit_defs.h" #include "soc_caps.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@@ -41,49 +41,23 @@ typedef enum periph_retention_module {
SLEEP_RETENTION_MODULE_BLE_MAC = 28, SLEEP_RETENTION_MODULE_BLE_MAC = 28,
SLEEP_RETENTION_MODULE_BT_BB = 29, SLEEP_RETENTION_MODULE_BT_BB = 29,
SLEEP_RETENTION_MODULE_802154_MAC = 30, SLEEP_RETENTION_MODULE_802154_MAC = 30,
SLEEP_RETENTION_MODULE_MAX = 31 SLEEP_RETENTION_MODULE_MAX = SOC_PM_RETENTION_MODULE_NUM - 1
} periph_retention_module_t; } periph_retention_module_t;
typedef enum periph_retention_module_bitmap { #define is_top_domain_module(m) \
/* clock module, which includes system and modem */ ( ((m) == SLEEP_RETENTION_MODULE_CLOCK_SYSTEM) ? true \
SLEEP_RETENTION_MODULE_BM_CLOCK_SYSTEM = BIT(SLEEP_RETENTION_MODULE_CLOCK_SYSTEM), : ((m) == SLEEP_RETENTION_MODULE_SYS_PERIPH) ? true \
SLEEP_RETENTION_MODULE_BM_CLOCK_MODEM = BIT(SLEEP_RETENTION_MODULE_CLOCK_MODEM), : ((m) == SLEEP_RETENTION_MODULE_TG0_WDT) ? true \
/* digital peripheral module, which includes Interrupt Matrix, HP_SYSTEM, : ((m) == SLEEP_RETENTION_MODULE_TG1_WDT) ? true \
* TEE, APM, UART, IOMUX, SPIMEM, SysTimer, etc.. */ : ((m) == SLEEP_RETENTION_MODULE_TG0_TIMER0) ? true \
SLEEP_RETENTION_MODULE_BM_SYS_PERIPH = BIT(SLEEP_RETENTION_MODULE_SYS_PERIPH), : ((m) == SLEEP_RETENTION_MODULE_TG1_TIMER0) ? true \
/* Timer Group by target*/ : ((m) == SLEEP_RETENTION_MODULE_GDMA_CH0) ? true \
SLEEP_RETENTION_MODULE_BM_TASK_WDT = BIT(SLEEP_RETENTION_MODULE_TG0_WDT), : ((m) == SLEEP_RETENTION_MODULE_GDMA_CH1) ? true \
SLEEP_RETENTION_MODULE_BM_INT_WDT = BIT(SLEEP_RETENTION_MODULE_TG1_WDT), : ((m) == SLEEP_RETENTION_MODULE_GDMA_CH2) ? true \
SLEEP_RETENTION_MODULE_BM_TG0_TIMER0 = BIT(SLEEP_RETENTION_MODULE_TG0_TIMER0), : ((m) == SLEEP_RETENTION_MODULE_ADC) ? true \
SLEEP_RETENTION_MODULE_BM_TG1_TIMER0 = BIT(SLEEP_RETENTION_MODULE_TG1_TIMER0), : ((m) == SLEEP_RETENTION_MODULE_I2C0) ? true \
/* GDMA by channel */ : ((m) == SLEEP_RETENTION_MODULE_RMT0) ? true \
SLEEP_RETENTION_MODULE_BM_GDMA_CH0 = BIT(SLEEP_RETENTION_MODULE_GDMA_CH0), : false)
SLEEP_RETENTION_MODULE_BM_GDMA_CH1 = BIT(SLEEP_RETENTION_MODULE_GDMA_CH1),
SLEEP_RETENTION_MODULE_BM_GDMA_CH2 = BIT(SLEEP_RETENTION_MODULE_GDMA_CH2),
/* MISC Peripherals */
SLEEP_RETENTION_MODULE_BM_ADC = BIT(SLEEP_RETENTION_MODULE_ADC),
SLEEP_RETENTION_MODULE_BM_I2C0 = BIT(SLEEP_RETENTION_MODULE_I2C0),
SLEEP_RETENTION_MODULE_BM_RMT0 = BIT(SLEEP_RETENTION_MODULE_RMT0),
/* modem module, which includes WiFi, BLE and 802.15.4 */
SLEEP_RETENTION_MODULE_BM_WIFI_MAC = BIT(SLEEP_RETENTION_MODULE_WIFI_MAC),
SLEEP_RETENTION_MODULE_BM_WIFI_BB = BIT(SLEEP_RETENTION_MODULE_WIFI_BB),
SLEEP_RETENTION_MODULE_BM_BLE_MAC = BIT(SLEEP_RETENTION_MODULE_BLE_MAC),
SLEEP_RETENTION_MODULE_BM_BT_BB = BIT(SLEEP_RETENTION_MODULE_BT_BB),
SLEEP_RETENTION_MODULE_BM_802154_MAC = BIT(SLEEP_RETENTION_MODULE_802154_MAC),
SLEEP_RETENTION_MODULE_BM_ALL = (uint32_t)-1
} periph_retention_module_bitmap_t;
#define TOP_DOMAIN_PERIPHERALS_BM (SLEEP_RETENTION_MODULE_BM_SYS_PERIPH \
| SLEEP_RETENTION_MODULE_BM_TASK_WDT \
| SLEEP_RETENTION_MODULE_BM_INT_WDT \
| SLEEP_RETENTION_MODULE_BM_TG0_TIMER0 \
| SLEEP_RETENTION_MODULE_BM_TG1_TIMER0 \
| SLEEP_RETENTION_MODULE_BM_GDMA_CH0 \
| SLEEP_RETENTION_MODULE_BM_GDMA_CH1 \
| SLEEP_RETENTION_MODULE_BM_GDMA_CH2 \
| SLEEP_RETENTION_MODULE_BM_ADC \
| SLEEP_RETENTION_MODULE_BM_I2C0 \
| SLEEP_RETENTION_MODULE_BM_RMT0)
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@@ -543,6 +543,8 @@
#define SOC_PM_PAU_LINK_NUM (4) #define SOC_PM_PAU_LINK_NUM (4)
#define SOC_PM_RETENTION_MODULE_NUM (32)
/*-------------------------- CLOCK SUBSYSTEM CAPS ----------------------------------------*/ /*-------------------------- CLOCK SUBSYSTEM CAPS ----------------------------------------*/
#define SOC_CLK_RC_FAST_SUPPORT_CALIBRATION (1) #define SOC_CLK_RC_FAST_SUPPORT_CALIBRATION (1)
#define SOC_MODEM_CLOCK_IS_INDEPENDENT (1) #define SOC_MODEM_CLOCK_IS_INDEPENDENT (1)

View File

@@ -447,6 +447,10 @@ config SOC_PM_SUPPORT_RTC_PERIPH_PD
bool bool
default y default y
config SOC_PM_RETENTION_MODULE_NUM
int
default 32
config SOC_CLK_RC_FAST_SUPPORT_CALIBRATION config SOC_CLK_RC_FAST_SUPPORT_CALIBRATION
bool bool
default y default y

View File

@@ -7,7 +7,7 @@
#pragma once #pragma once
#include <stdint.h> #include <stdint.h>
#include "esp_bit_defs.h" #include "soc_caps.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@@ -18,50 +18,46 @@ typedef enum periph_retention_module {
/* clock module, which includes system and modem */ /* clock module, which includes system and modem */
SLEEP_RETENTION_MODULE_CLOCK_SYSTEM = 1, SLEEP_RETENTION_MODULE_CLOCK_SYSTEM = 1,
SLEEP_RETENTION_MODULE_CLOCK_MODEM = 2, SLEEP_RETENTION_MODULE_CLOCK_MODEM = 2,
/* modem module, which includes WiFi, BLE and 802.15.4 */
SLEEP_RETENTION_MODULE_WIFI_MAC = 10,
SLEEP_RETENTION_MODULE_WIFI_BB = 11,
SLEEP_RETENTION_MODULE_BLE_MAC = 12,
SLEEP_RETENTION_MODULE_BT_BB = 13,
SLEEP_RETENTION_MODULE_802154_MAC = 14,
/* digital peripheral module, which includes Interrupt Matrix, HP_SYSTEM, /* digital peripheral module, which includes Interrupt Matrix, HP_SYSTEM,
* TEE, APM, UART, Timer Group, IOMUX, SPIMEM, SysTimer, etc.. */ * TEE, APM, UART, IOMUX, SPIMEM, SysTimer, etc.. */
SLEEP_RETENTION_MODULE_SYS_PERIPH = 16, SLEEP_RETENTION_MODULE_SYS_PERIPH = 3,
/* Timer Group by target*/
SLEEP_RETENTION_MODULE_TG0_WDT = 4,
SLEEP_RETENTION_MODULE_TG1_WDT = 5,
SLEEP_RETENTION_MODULE_TG0_TIMER0 = 6,
SLEEP_RETENTION_MODULE_TG1_TIMER0 = 7,
/* GDMA by channel */
SLEEP_RETENTION_MODULE_GDMA_CH0 = 8,
SLEEP_RETENTION_MODULE_GDMA_CH1 = 9,
SLEEP_RETENTION_MODULE_GDMA_CH2 = 10,
/* MISC Peripherals */
SLEEP_RETENTION_MODULE_ADC = 11,
SLEEP_RETENTION_MODULE_I2C0 = 12,
SLEEP_RETENTION_MODULE_RMT0 = 13,
SLEEP_RETENTION_MODULE_ADC = 17, /* Modem module, which includes WiFi, BLE and 802.15.4 */
SLEEP_RETENTION_MODULE_WIFI_MAC = 26,
SLEEP_RETENTION_MODULE_GDMA_CH0 = 24, SLEEP_RETENTION_MODULE_WIFI_BB = 27,
SLEEP_RETENTION_MODULE_GDMA_CH1 = 25, SLEEP_RETENTION_MODULE_BLE_MAC = 28,
SLEEP_RETENTION_MODULE_GDMA_CH2 = 26, SLEEP_RETENTION_MODULE_BT_BB = 29,
SLEEP_RETENTION_MODULE_802154_MAC = 30,
SLEEP_RETENTION_MODULE_MAX = 31 SLEEP_RETENTION_MODULE_MAX = SOC_PM_RETENTION_MODULE_NUM - 1
} periph_retention_module_t; } periph_retention_module_t;
typedef enum periph_retention_module_bitmap { #define is_top_domain_module(m) \
/* clock module, which includes system and modem */ ( ((m) == SLEEP_RETENTION_MODULE_CLOCK_SYSTEM) ? true \
SLEEP_RETENTION_MODULE_BM_CLOCK_SYSTEM = BIT(SLEEP_RETENTION_MODULE_CLOCK_SYSTEM), : ((m) == SLEEP_RETENTION_MODULE_SYS_PERIPH) ? true \
SLEEP_RETENTION_MODULE_BM_CLOCK_MODEM = BIT(SLEEP_RETENTION_MODULE_CLOCK_MODEM), : ((m) == SLEEP_RETENTION_MODULE_TG0_WDT) ? true \
: ((m) == SLEEP_RETENTION_MODULE_TG1_WDT) ? true \
/* modem module, which includes WiFi, BLE and 802.15.4 */ : ((m) == SLEEP_RETENTION_MODULE_TG0_TIMER0) ? true \
SLEEP_RETENTION_MODULE_BM_WIFI_MAC = BIT(SLEEP_RETENTION_MODULE_WIFI_MAC), : ((m) == SLEEP_RETENTION_MODULE_TG1_TIMER0) ? true \
SLEEP_RETENTION_MODULE_BM_WIFI_BB = BIT(SLEEP_RETENTION_MODULE_WIFI_BB), : ((m) == SLEEP_RETENTION_MODULE_GDMA_CH0) ? true \
SLEEP_RETENTION_MODULE_BM_BLE_MAC = BIT(SLEEP_RETENTION_MODULE_BLE_MAC), : ((m) == SLEEP_RETENTION_MODULE_GDMA_CH1) ? true \
SLEEP_RETENTION_MODULE_BM_BT_BB = BIT(SLEEP_RETENTION_MODULE_BT_BB), : ((m) == SLEEP_RETENTION_MODULE_GDMA_CH2) ? true \
SLEEP_RETENTION_MODULE_BM_802154_MAC = BIT(SLEEP_RETENTION_MODULE_802154_MAC), : ((m) == SLEEP_RETENTION_MODULE_ADC) ? true \
: ((m) == SLEEP_RETENTION_MODULE_I2C0) ? true \
/* digital peripheral module, which includes Interrupt Matrix, HP_SYSTEM, : ((m) == SLEEP_RETENTION_MODULE_RMT0) ? true \
* TEE, APM, UART, Timer Group, IOMUX, SPIMEM, SysTimer, etc.. */ : false)
SLEEP_RETENTION_MODULE_BM_SYS_PERIPH = BIT(SLEEP_RETENTION_MODULE_SYS_PERIPH),
SLEEP_RETENTION_MODULE_BM_ADC = BIT(SLEEP_RETENTION_MODULE_ADC),
SLEEP_RETENTION_MODULE_BM_GDMA_CH0 = BIT(SLEEP_RETENTION_MODULE_GDMA_CH0),
SLEEP_RETENTION_MODULE_BM_GDMA_CH1 = BIT(SLEEP_RETENTION_MODULE_GDMA_CH1),
SLEEP_RETENTION_MODULE_BM_GDMA_CH2 = BIT(SLEEP_RETENTION_MODULE_GDMA_CH2),
SLEEP_RETENTION_MODULE_BM_ALL = (uint32_t)-1
} periph_retention_module_bitmap_t;
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@@ -537,6 +537,8 @@
// #define SOC_PM_PAU_LINK_NUM (4) // #define SOC_PM_PAU_LINK_NUM (4)
#define SOC_PM_RETENTION_MODULE_NUM (32)
/*-------------------------- CLOCK SUBSYSTEM CAPS ----------------------------------------*/ /*-------------------------- CLOCK SUBSYSTEM CAPS ----------------------------------------*/
#define SOC_CLK_RC_FAST_SUPPORT_CALIBRATION (1) #define SOC_CLK_RC_FAST_SUPPORT_CALIBRATION (1)
#define SOC_MODEM_CLOCK_IS_INDEPENDENT (1) #define SOC_MODEM_CLOCK_IS_INDEPENDENT (1)

View File

@@ -1379,6 +1379,10 @@ config SOC_PM_PAU_LINK_NUM
int int
default 4 default 4
config SOC_PM_RETENTION_MODULE_NUM
int
default 32
config SOC_PM_PAU_REGDMA_UPDATE_CACHE_BEFORE_WAIT_COMPARE config SOC_PM_PAU_REGDMA_UPDATE_CACHE_BEFORE_WAIT_COMPARE
bool bool
default y default y

View File

@@ -7,7 +7,7 @@
#pragma once #pragma once
#include <stdint.h> #include <stdint.h>
#include "esp_bit_defs.h" #include "soc_caps.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@@ -43,54 +43,26 @@ typedef enum periph_retention_module {
SLEEP_RETENTION_MODULE_BLE_MAC = 28, SLEEP_RETENTION_MODULE_BLE_MAC = 28,
SLEEP_RETENTION_MODULE_BT_BB = 29, SLEEP_RETENTION_MODULE_BT_BB = 29,
SLEEP_RETENTION_MODULE_802154_MAC = 30, SLEEP_RETENTION_MODULE_802154_MAC = 30,
SLEEP_RETENTION_MODULE_MAX = 31
SLEEP_RETENTION_MODULE_MAX = SOC_PM_RETENTION_MODULE_NUM - 1
} periph_retention_module_t; } periph_retention_module_t;
typedef enum periph_retention_module_bitmap { #define is_top_domain_module(m) \
/* clock module, which includes system and modem */ ( ((m) == SLEEP_RETENTION_MODULE_CLOCK_SYSTEM) ? true \
SLEEP_RETENTION_MODULE_BM_CLOCK_SYSTEM = BIT(SLEEP_RETENTION_MODULE_CLOCK_SYSTEM), : ((m) == SLEEP_RETENTION_MODULE_SYS_PERIPH) ? true \
SLEEP_RETENTION_MODULE_BM_CLOCK_MODEM = BIT(SLEEP_RETENTION_MODULE_CLOCK_MODEM), : ((m) == SLEEP_RETENTION_MODULE_TG0_WDT) ? true \
/* digital peripheral module, which includes Interrupt Matrix, HP_SYSTEM, : ((m) == SLEEP_RETENTION_MODULE_TG1_WDT) ? true \
* TEE, APM, UART, IOMUX, SPIMEM, SysTimer, etc.. */ : ((m) == SLEEP_RETENTION_MODULE_TG0_TIMER0) ? true \
SLEEP_RETENTION_MODULE_BM_SYS_PERIPH = BIT(SLEEP_RETENTION_MODULE_SYS_PERIPH), : ((m) == SLEEP_RETENTION_MODULE_TG1_TIMER0) ? true \
/* Timer Group by target*/ : ((m) == SLEEP_RETENTION_MODULE_GDMA_CH0) ? true \
SLEEP_RETENTION_MODULE_BM_TASK_WDT = BIT(SLEEP_RETENTION_MODULE_TG0_WDT), : ((m) == SLEEP_RETENTION_MODULE_GDMA_CH1) ? true \
SLEEP_RETENTION_MODULE_BM_INT_WDT = BIT(SLEEP_RETENTION_MODULE_TG1_WDT), : ((m) == SLEEP_RETENTION_MODULE_GDMA_CH2) ? true \
SLEEP_RETENTION_MODULE_BM_TG0_TIMER0 = BIT(SLEEP_RETENTION_MODULE_TG0_TIMER0), : ((m) == SLEEP_RETENTION_MODULE_ADC) ? true \
SLEEP_RETENTION_MODULE_BM_TG1_TIMER0 = BIT(SLEEP_RETENTION_MODULE_TG1_TIMER0), : ((m) == SLEEP_RETENTION_MODULE_I2C0) ? true \
/* GDMA by channel */ : ((m) == SLEEP_RETENTION_MODULE_RMT0) ? true \
SLEEP_RETENTION_MODULE_BM_GDMA_CH0 = BIT(SLEEP_RETENTION_MODULE_GDMA_CH0), : ((m) == SLEEP_RETENTION_MODULE_UART0) ? true \
SLEEP_RETENTION_MODULE_BM_GDMA_CH1 = BIT(SLEEP_RETENTION_MODULE_GDMA_CH1), : ((m) == SLEEP_RETENTION_MODULE_UART1) ? true \
SLEEP_RETENTION_MODULE_BM_GDMA_CH2 = BIT(SLEEP_RETENTION_MODULE_GDMA_CH2), : false)
/* MISC Peripherals */
SLEEP_RETENTION_MODULE_BM_ADC = BIT(SLEEP_RETENTION_MODULE_ADC),
SLEEP_RETENTION_MODULE_BM_I2C0 = BIT(SLEEP_RETENTION_MODULE_I2C0),
SLEEP_RETENTION_MODULE_BM_RMT0 = BIT(SLEEP_RETENTION_MODULE_RMT0),
SLEEP_RETENTION_MODULE_BM_UART0 = BIT(SLEEP_RETENTION_MODULE_UART0),
SLEEP_RETENTION_MODULE_BM_UART1 = BIT(SLEEP_RETENTION_MODULE_UART1),
/* modem module, which includes WiFi, BLE and 802.15.4 */
SLEEP_RETENTION_MODULE_BM_WIFI_MAC = BIT(SLEEP_RETENTION_MODULE_WIFI_MAC),
SLEEP_RETENTION_MODULE_BM_WIFI_BB = BIT(SLEEP_RETENTION_MODULE_WIFI_BB),
SLEEP_RETENTION_MODULE_BM_BLE_MAC = BIT(SLEEP_RETENTION_MODULE_BLE_MAC),
SLEEP_RETENTION_MODULE_BM_BT_BB = BIT(SLEEP_RETENTION_MODULE_BT_BB),
SLEEP_RETENTION_MODULE_BM_802154_MAC = BIT(SLEEP_RETENTION_MODULE_802154_MAC),
SLEEP_RETENTION_MODULE_BM_ALL = (uint32_t)-1
} periph_retention_module_bitmap_t;
#define TOP_DOMAIN_PERIPHERALS_BM (SLEEP_RETENTION_MODULE_BM_SYS_PERIPH \
| SLEEP_RETENTION_MODULE_BM_TASK_WDT \
| SLEEP_RETENTION_MODULE_BM_INT_WDT \
| SLEEP_RETENTION_MODULE_BM_TG0_TIMER0 \
| SLEEP_RETENTION_MODULE_BM_TG1_TIMER0 \
| SLEEP_RETENTION_MODULE_BM_GDMA_CH0 \
| SLEEP_RETENTION_MODULE_BM_GDMA_CH1 \
| SLEEP_RETENTION_MODULE_BM_GDMA_CH2 \
| SLEEP_RETENTION_MODULE_BM_ADC \
| SLEEP_RETENTION_MODULE_BM_I2C0 \
| SLEEP_RETENTION_MODULE_BM_RMT0 \
| SLEEP_RETENTION_MODULE_BM_UART0 \
| SLEEP_RETENTION_MODULE_BM_UART1 \
)
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@@ -544,7 +544,8 @@
#define SOC_PM_MODEM_RETENTION_BY_REGDMA (1) #define SOC_PM_MODEM_RETENTION_BY_REGDMA (1)
#define SOC_PM_RETENTION_HAS_CLOCK_BUG (1) #define SOC_PM_RETENTION_HAS_CLOCK_BUG (1)
#define SOC_PM_PAU_LINK_NUM (4) #define SOC_PM_PAU_LINK_NUM (4)
#define SOC_PM_RETENTION_MODULE_NUM (32)
#define SOC_PM_PAU_REGDMA_UPDATE_CACHE_BEFORE_WAIT_COMPARE (1) #define SOC_PM_PAU_REGDMA_UPDATE_CACHE_BEFORE_WAIT_COMPARE (1)

View File

@@ -971,6 +971,10 @@ config SOC_PM_PAU_LINK_NUM
int int
default 4 default 4
config SOC_PM_RETENTION_MODULE_NUM
int
default 32
config SOC_CLK_RC_FAST_SUPPORT_CALIBRATION config SOC_CLK_RC_FAST_SUPPORT_CALIBRATION
bool bool
default y default y

View File

@@ -7,7 +7,7 @@
#pragma once #pragma once
#include <stdint.h> #include <stdint.h>
#include "esp_bit_defs.h" #include "soc_caps.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@@ -35,32 +35,17 @@ typedef enum periph_retention_module {
SLEEP_RETENTION_MODULE_GDMA_CH2 = 26, SLEEP_RETENTION_MODULE_GDMA_CH2 = 26,
SLEEP_RETENTION_MODULE_I2C0 = 27, SLEEP_RETENTION_MODULE_I2C0 = 27,
SLEEP_RETENTION_MODULE_MAX = 31 SLEEP_RETENTION_MODULE_MAX = SOC_PM_RETENTION_MODULE_NUM - 1
} periph_retention_module_t; } periph_retention_module_t;
typedef enum periph_retention_module_bitmap { #define is_top_domain_module(m) \
/* clock module, which includes system and modem */ ( ((m) == SLEEP_RETENTION_MODULE_CLOCK_SYSTEM) ? true \
SLEEP_RETENTION_MODULE_BM_CLOCK_SYSTEM = BIT(SLEEP_RETENTION_MODULE_CLOCK_SYSTEM), : ((m) == SLEEP_RETENTION_MODULE_SYS_PERIPH) ? true \
SLEEP_RETENTION_MODULE_BM_CLOCK_MODEM = BIT(SLEEP_RETENTION_MODULE_CLOCK_MODEM), : ((m) == SLEEP_RETENTION_MODULE_GDMA_CH0) ? true \
: ((m) == SLEEP_RETENTION_MODULE_GDMA_CH1) ? true \
/* modem module, which includes WiFi, BLE and 802.15.4 */ : ((m) == SLEEP_RETENTION_MODULE_GDMA_CH2) ? true \
SLEEP_RETENTION_MODULE_BM_WIFI_MAC = BIT(SLEEP_RETENTION_MODULE_WIFI_MAC), : ((m) == SLEEP_RETENTION_MODULE_I2C0) ? true \
SLEEP_RETENTION_MODULE_BM_WIFI_BB = BIT(SLEEP_RETENTION_MODULE_WIFI_BB), : false)
SLEEP_RETENTION_MODULE_BM_BLE_MAC = BIT(SLEEP_RETENTION_MODULE_BLE_MAC),
SLEEP_RETENTION_MODULE_BM_BT_BB = BIT(SLEEP_RETENTION_MODULE_BT_BB),
SLEEP_RETENTION_MODULE_BM_802154_MAC = BIT(SLEEP_RETENTION_MODULE_802154_MAC),
/* digital peripheral module, which includes Interrupt Matrix, HP_SYSTEM,
* TEE, APM, UART, Timer Group, IOMUX, SPIMEM, SysTimer, etc.. */
SLEEP_RETENTION_MODULE_BM_SYS_PERIPH = BIT(SLEEP_RETENTION_MODULE_SYS_PERIPH),
SLEEP_RETENTION_MODULE_BM_GDMA_CH0 = BIT(SLEEP_RETENTION_MODULE_GDMA_CH0),
SLEEP_RETENTION_MODULE_BM_GDMA_CH1 = BIT(SLEEP_RETENTION_MODULE_GDMA_CH1),
SLEEP_RETENTION_MODULE_BM_GDMA_CH2 = BIT(SLEEP_RETENTION_MODULE_GDMA_CH2),
SLEEP_RETENTION_MODULE_BM_I2C0 = BIT(SLEEP_RETENTION_MODULE_I2C0),
SLEEP_RETENTION_MODULE_BM_ALL = (uint32_t)-1
} periph_retention_module_bitmap_t;
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@@ -533,6 +533,8 @@
#define SOC_PM_PAU_LINK_NUM (4) #define SOC_PM_PAU_LINK_NUM (4)
#define SOC_PM_RETENTION_MODULE_NUM (32)
/*-------------------------- CLOCK SUBSYSTEM CAPS ----------------------------------------*/ /*-------------------------- CLOCK SUBSYSTEM CAPS ----------------------------------------*/
#define SOC_CLK_RC_FAST_SUPPORT_CALIBRATION (1) #define SOC_CLK_RC_FAST_SUPPORT_CALIBRATION (1)
#define SOC_MODEM_CLOCK_IS_INDEPENDENT (1) #define SOC_MODEM_CLOCK_IS_INDEPENDENT (1)

View File

@@ -1359,6 +1359,10 @@ config SOC_PM_RETENTION_SW_TRIGGER_REGDMA
bool bool
default y default y
config SOC_PM_RETENTION_MODULE_NUM
int
default 32
config SOC_CLK_RC_FAST_SUPPORT_CALIBRATION config SOC_CLK_RC_FAST_SUPPORT_CALIBRATION
bool bool
default y default y

View File

@@ -7,7 +7,7 @@
#pragma once #pragma once
#include <stdint.h> #include <stdint.h>
#include "esp_bit_defs.h" #include "soc_caps.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@@ -42,54 +42,27 @@ typedef enum periph_retention_module {
SLEEP_RETENTION_MODULE_BLE_MAC = 28, SLEEP_RETENTION_MODULE_BLE_MAC = 28,
SLEEP_RETENTION_MODULE_BT_BB = 29, SLEEP_RETENTION_MODULE_BT_BB = 29,
SLEEP_RETENTION_MODULE_802154_MAC = 30, SLEEP_RETENTION_MODULE_802154_MAC = 30,
SLEEP_RETENTION_MODULE_MAX = 31
SLEEP_RETENTION_MODULE_MAX = SOC_PM_RETENTION_MODULE_NUM - 1
} periph_retention_module_t; } periph_retention_module_t;
typedef enum periph_retention_module_bitmap { #define is_top_domain_module(m) \
/* clock module, which includes system and modem */ ( ((m) == SLEEP_RETENTION_MODULE_CLOCK_SYSTEM) ? true \
SLEEP_RETENTION_MODULE_BM_CLOCK_SYSTEM = BIT(SLEEP_RETENTION_MODULE_CLOCK_SYSTEM), : ((m) == SLEEP_RETENTION_MODULE_SYS_PERIPH) ? true \
SLEEP_RETENTION_MODULE_BM_CLOCK_MODEM = BIT(SLEEP_RETENTION_MODULE_CLOCK_MODEM), : ((m) == SLEEP_RETENTION_MODULE_TG0_WDT) ? true \
/* digital peripheral module, which includes Interrupt Matrix, HP_SYSTEM, : ((m) == SLEEP_RETENTION_MODULE_TG1_WDT) ? true \
* TEE, APM, UART, Timer Group, IOMUX, SPIMEM, SysTimer, etc.. */ : ((m) == SLEEP_RETENTION_MODULE_TG0_TIMER0) ? true \
SLEEP_RETENTION_MODULE_BM_SYS_PERIPH = BIT(SLEEP_RETENTION_MODULE_SYS_PERIPH), : ((m) == SLEEP_RETENTION_MODULE_TG1_TIMER0) ? true \
/* Timer Group by target*/ : ((m) == SLEEP_RETENTION_MODULE_GDMA_CH0) ? true \
SLEEP_RETENTION_MODULE_BM_TASK_WDT = BIT(SLEEP_RETENTION_MODULE_TG0_WDT), : ((m) == SLEEP_RETENTION_MODULE_GDMA_CH1) ? true \
SLEEP_RETENTION_MODULE_BM_INT_WDT = BIT(SLEEP_RETENTION_MODULE_TG1_WDT), : ((m) == SLEEP_RETENTION_MODULE_GDMA_CH2) ? true \
SLEEP_RETENTION_MODULE_BM_TG0_TIMER0 = BIT(SLEEP_RETENTION_MODULE_TG0_TIMER0), : ((m) == SLEEP_RETENTION_MODULE_ADC) ? true \
SLEEP_RETENTION_MODULE_BM_TG1_TIMER0 = BIT(SLEEP_RETENTION_MODULE_TG1_TIMER0), : ((m) == SLEEP_RETENTION_MODULE_I2C0) ? true \
/* GDMA by channel */ : ((m) == SLEEP_RETENTION_MODULE_I2C1) ? true \
SLEEP_RETENTION_MODULE_BM_GDMA_CH0 = BIT(SLEEP_RETENTION_MODULE_GDMA_CH0), : ((m) == SLEEP_RETENTION_MODULE_RMT0) ? true \
SLEEP_RETENTION_MODULE_BM_GDMA_CH1 = BIT(SLEEP_RETENTION_MODULE_GDMA_CH1), : ((m) == SLEEP_RETENTION_MODULE_UART0) ? true \
SLEEP_RETENTION_MODULE_BM_GDMA_CH2 = BIT(SLEEP_RETENTION_MODULE_GDMA_CH2), : ((m) == SLEEP_RETENTION_MODULE_UART1) ? true \
/* MISC Peripherals */ : false)
SLEEP_RETENTION_MODULE_BM_ADC = BIT(SLEEP_RETENTION_MODULE_ADC),
SLEEP_RETENTION_MODULE_BM_I2C0 = BIT(SLEEP_RETENTION_MODULE_I2C0),
SLEEP_RETENTION_MODULE_BM_I2C1 = BIT(SLEEP_RETENTION_MODULE_I2C1),
SLEEP_RETENTION_MODULE_BM_RMT0 = BIT(SLEEP_RETENTION_MODULE_RMT0),
SLEEP_RETENTION_MODULE_BM_UART0 = BIT(SLEEP_RETENTION_MODULE_UART0),
SLEEP_RETENTION_MODULE_BM_UART1 = BIT(SLEEP_RETENTION_MODULE_UART1),
/* modem module, which includes BLE and 802.15.4 */
SLEEP_RETENTION_MODULE_BM_BLE_MAC = BIT(SLEEP_RETENTION_MODULE_BLE_MAC),
SLEEP_RETENTION_MODULE_BM_BT_BB = BIT(SLEEP_RETENTION_MODULE_BT_BB),
SLEEP_RETENTION_MODULE_BM_802154_MAC = BIT(SLEEP_RETENTION_MODULE_802154_MAC),
SLEEP_RETENTION_MODULE_BM_ALL = (uint32_t) -1
} periph_retention_module_bitmap_t;
#define TOP_DOMAIN_PERIPHERALS_BM (SLEEP_RETENTION_MODULE_BM_SYS_PERIPH \
| SLEEP_RETENTION_MODULE_BM_TASK_WDT \
| SLEEP_RETENTION_MODULE_BM_INT_WDT \
| SLEEP_RETENTION_MODULE_BM_TG0_TIMER0 \
| SLEEP_RETENTION_MODULE_BM_TG1_TIMER0 \
| SLEEP_RETENTION_MODULE_BM_GDMA_CH0 \
| SLEEP_RETENTION_MODULE_BM_GDMA_CH1 \
| SLEEP_RETENTION_MODULE_BM_GDMA_CH2 \
| SLEEP_RETENTION_MODULE_BM_ADC \
| SLEEP_RETENTION_MODULE_BM_I2C0 \
| SLEEP_RETENTION_MODULE_BM_I2C1 \
| SLEEP_RETENTION_MODULE_BM_RMT0 \
| SLEEP_RETENTION_MODULE_BM_UART0 \
| SLEEP_RETENTION_MODULE_BM_UART1 \
)
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@@ -553,6 +553,8 @@
#define SOC_PM_SUPPORT_DEEPSLEEP_CHECK_STUB_ONLY (1) /*!<Supports CRC only the stub code in RTC memory */ #define SOC_PM_SUPPORT_DEEPSLEEP_CHECK_STUB_ONLY (1) /*!<Supports CRC only the stub code in RTC memory */
#define SOC_PM_RETENTION_SW_TRIGGER_REGDMA (1) /*!< In esp32H2, regdma will power off when entering sleep */ #define SOC_PM_RETENTION_SW_TRIGGER_REGDMA (1) /*!< In esp32H2, regdma will power off when entering sleep */
#define SOC_PM_RETENTION_MODULE_NUM (32)
/*-------------------------- CLOCK SUBSYSTEM CAPS ----------------------------------------*/ /*-------------------------- CLOCK SUBSYSTEM CAPS ----------------------------------------*/
#define SOC_CLK_RC_FAST_SUPPORT_CALIBRATION (1) #define SOC_CLK_RC_FAST_SUPPORT_CALIBRATION (1)

View File

@@ -1715,6 +1715,10 @@ config SOC_CPU_IN_TOP_DOMAIN
bool bool
default y default y
config SOC_PM_RETENTION_MODULE_NUM
int
default 64
config SOC_PM_PAU_REGDMA_UPDATE_CACHE_BEFORE_WAIT_COMPARE config SOC_PM_PAU_REGDMA_UPDATE_CACHE_BEFORE_WAIT_COMPARE
bool bool
default y default y

View File

@@ -7,7 +7,7 @@
#pragma once #pragma once
#include <stdint.h> #include <stdint.h>
#include "esp_bit_defs.h" #include "soc_caps.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@@ -34,45 +34,24 @@ typedef enum periph_retention_module {
SLEEP_RETENTION_MODULE_UART3 = 12, SLEEP_RETENTION_MODULE_UART3 = 12,
SLEEP_RETENTION_MODULE_UART4 = 13, SLEEP_RETENTION_MODULE_UART4 = 13,
SLEEP_RETENTION_MODULE_MAX = 31 SLEEP_RETENTION_MODULE_MAX = SOC_PM_RETENTION_MODULE_NUM - 1
} periph_retention_module_t; } periph_retention_module_t;
typedef enum periph_retention_module_bitmap { #define is_top_domain_module(m) \
/* clock module, which includes system and modem */ ( ((m) == SLEEP_RETENTION_MODULE_CLOCK_SYSTEM) ? true \
SLEEP_RETENTION_MODULE_BM_CLOCK_SYSTEM = BIT(SLEEP_RETENTION_MODULE_CLOCK_SYSTEM), : ((m) == SLEEP_RETENTION_MODULE_SYS_PERIPH) ? true \
/* digital peripheral module, which includes Interrupt Matrix, HP_SYSTEM, : ((m) == SLEEP_RETENTION_MODULE_TG0_WDT) ? true \
* TEE, APM, UART, Timer Group, IOMUX, SPIMEM, SysTimer, etc.. */ : ((m) == SLEEP_RETENTION_MODULE_TG1_WDT) ? true \
SLEEP_RETENTION_MODULE_BM_SYS_PERIPH = BIT(SLEEP_RETENTION_MODULE_SYS_PERIPH), : ((m) == SLEEP_RETENTION_MODULE_TG0_TIMER0) ? true \
/* Timer Group by target*/ : ((m) == SLEEP_RETENTION_MODULE_TG0_TIMER1) ? true \
SLEEP_RETENTION_MODULE_BM_TG0_WDT = BIT(SLEEP_RETENTION_MODULE_TG0_WDT), : ((m) == SLEEP_RETENTION_MODULE_TG1_TIMER0) ? true \
SLEEP_RETENTION_MODULE_BM_TG1_WDT = BIT(SLEEP_RETENTION_MODULE_TG1_WDT), : ((m) == SLEEP_RETENTION_MODULE_TG1_TIMER1) ? true \
SLEEP_RETENTION_MODULE_BM_TG0_TIMER0 = BIT(SLEEP_RETENTION_MODULE_TG0_TIMER0), : ((m) == SLEEP_RETENTION_MODULE_UART0) ? true \
SLEEP_RETENTION_MODULE_BM_TG0_TIMER1 = BIT(SLEEP_RETENTION_MODULE_TG0_TIMER1), : ((m) == SLEEP_RETENTION_MODULE_UART1) ? true \
SLEEP_RETENTION_MODULE_BM_TG1_TIMER0 = BIT(SLEEP_RETENTION_MODULE_TG1_TIMER0), : ((m) == SLEEP_RETENTION_MODULE_UART2) ? true \
SLEEP_RETENTION_MODULE_BM_TG1_TIMER1 = BIT(SLEEP_RETENTION_MODULE_TG1_TIMER1), : ((m) == SLEEP_RETENTION_MODULE_UART3) ? true \
/* MISC Peripherals */ : ((m) == SLEEP_RETENTION_MODULE_UART4) ? true \
SLEEP_RETENTION_MODULE_BM_UART0 = BIT(SLEEP_RETENTION_MODULE_UART0), : false)
SLEEP_RETENTION_MODULE_BM_UART1 = BIT(SLEEP_RETENTION_MODULE_UART1),
SLEEP_RETENTION_MODULE_BM_UART2 = BIT(SLEEP_RETENTION_MODULE_UART2),
SLEEP_RETENTION_MODULE_BM_UART3 = BIT(SLEEP_RETENTION_MODULE_UART3),
SLEEP_RETENTION_MODULE_BM_UART4 = BIT(SLEEP_RETENTION_MODULE_UART4),
SLEEP_RETENTION_MODULE_BM_ALL = (uint32_t)-1
} periph_retention_module_bitmap_t;
#define TOP_DOMAIN_PERIPHERALS_BM (SLEEP_RETENTION_MODULE_BM_SYS_PERIPH \
| SLEEP_RETENTION_MODULE_BM_TG0_WDT \
| SLEEP_RETENTION_MODULE_BM_TG1_WDT \
| SLEEP_RETENTION_MODULE_BM_TG0_TIMER0 \
| SLEEP_RETENTION_MODULE_BM_TG0_TIMER1 \
| SLEEP_RETENTION_MODULE_BM_TG1_TIMER0 \
| SLEEP_RETENTION_MODULE_BM_TG1_TIMER1 \
| SLEEP_RETENTION_MODULE_BM_UART0 \
| SLEEP_RETENTION_MODULE_BM_UART1 \
| SLEEP_RETENTION_MODULE_BM_UART2 \
| SLEEP_RETENTION_MODULE_BM_UART3 \
| SLEEP_RETENTION_MODULE_BM_UART4 \
)
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@@ -670,6 +670,8 @@
#define SOC_PAU_IN_TOP_DOMAIN (1) #define SOC_PAU_IN_TOP_DOMAIN (1)
#define SOC_CPU_IN_TOP_DOMAIN (1) #define SOC_CPU_IN_TOP_DOMAIN (1)
#define SOC_PM_RETENTION_MODULE_NUM (64)
#define SOC_PM_PAU_REGDMA_UPDATE_CACHE_BEFORE_WAIT_COMPARE (1) #define SOC_PM_PAU_REGDMA_UPDATE_CACHE_BEFORE_WAIT_COMPARE (1)
/*-------------------------- PSRAM CAPS ----------------------------*/ /*-------------------------- PSRAM CAPS ----------------------------*/

View File

@@ -156,7 +156,7 @@ typedef struct regdma_link_stats {
volatile uint32_t ref: REGDMA_LINK_ENTRY_NUM, /* a bitmap, identifies which entry has referenced the current link */ volatile uint32_t ref: REGDMA_LINK_ENTRY_NUM, /* a bitmap, identifies which entry has referenced the current link */
reserve: 16-REGDMA_LINK_ENTRY_NUM, reserve: 16-REGDMA_LINK_ENTRY_NUM,
id: 16; /* REGDMA linked list node unique identifier */ id: 16; /* REGDMA linked list node unique identifier */
volatile uint32_t module; /* a bitmap used to identify the module to which the current node belongs */ volatile int module; /* a number used to identify the module to which the current node belongs */
} regdma_link_stats_t; } regdma_link_stats_t;
typedef struct regdma_link_continuous { typedef struct regdma_link_continuous {