mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
change(esp_hw_support): modify the style of module argument from bitmap to number
This commit is contained in:
parent
f5c8cc2bef
commit
f66e3f031d
@ -23,34 +23,63 @@ extern "C" {
|
|||||||
* includes sleep retention list creation, destruction and debugging interfaces.
|
* includes sleep retention list creation, destruction and debugging interfaces.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef enum sleep_retention_module_bitmap {
|
typedef enum sleep_retention_module {
|
||||||
|
SLEEP_RETENTION_MODULE_MIN = 0,
|
||||||
/* clock module, which includes system and modem */
|
/* clock module, which includes system and modem */
|
||||||
SLEEP_RETENTION_MODULE_CLOCK_SYSTEM = BIT(1),
|
SLEEP_RETENTION_MODULE_CLOCK_SYSTEM = 1,
|
||||||
SLEEP_RETENTION_MODULE_CLOCK_MODEM = BIT(2),
|
SLEEP_RETENTION_MODULE_CLOCK_MODEM = 2,
|
||||||
|
|
||||||
/* modem module, which includes WiFi, BLE and 802.15.4 */
|
/* modem module, which includes WiFi, BLE and 802.15.4 */
|
||||||
SLEEP_RETENTION_MODULE_WIFI_MAC = BIT(10),
|
SLEEP_RETENTION_MODULE_WIFI_MAC = 10,
|
||||||
SLEEP_RETENTION_MODULE_WIFI_BB = BIT(11),
|
SLEEP_RETENTION_MODULE_WIFI_BB = 11,
|
||||||
SLEEP_RETENTION_MODULE_BLE_MAC = BIT(12),
|
SLEEP_RETENTION_MODULE_BLE_MAC = 12,
|
||||||
SLEEP_RETENTION_MODULE_BT_BB = BIT(13),
|
SLEEP_RETENTION_MODULE_BT_BB = 13,
|
||||||
SLEEP_RETENTION_MODULE_802154_MAC = BIT(14),
|
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, Timer Group, IOMUX, SPIMEM, SysTimer, etc.. */
|
||||||
SLEEP_RETENTION_MODULE_INTR_MATRIX = BIT(16),
|
SLEEP_RETENTION_MODULE_INTR_MATRIX = 16,
|
||||||
SLEEP_RETENTION_MODULE_HP_SYSTEM = BIT(17),
|
SLEEP_RETENTION_MODULE_HP_SYSTEM = 17,
|
||||||
SLEEP_RETENTION_MODULE_TEE_APM = BIT(18),
|
SLEEP_RETENTION_MODULE_TEE_APM = 18,
|
||||||
SLEEP_RETENTION_MODULE_UART0 = BIT(19),
|
SLEEP_RETENTION_MODULE_UART0 = 19,
|
||||||
SLEEP_RETENTION_MODULE_TG0 = BIT(20),
|
SLEEP_RETENTION_MODULE_TG0 = 20,
|
||||||
SLEEP_RETENTION_MODULE_IOMUX = BIT(21),
|
SLEEP_RETENTION_MODULE_IOMUX = 21,
|
||||||
SLEEP_RETENTION_MODULE_SPIMEM = BIT(22),
|
SLEEP_RETENTION_MODULE_SPIMEM = 22,
|
||||||
SLEEP_RETENTION_MODULE_SYSTIMER = BIT(23),
|
SLEEP_RETENTION_MODULE_SYSTIMER = 23,
|
||||||
SLEEP_RETENTION_MODULE_GDMA_CH0 = BIT(24),
|
SLEEP_RETENTION_MODULE_GDMA_CH0 = 24,
|
||||||
SLEEP_RETENTION_MODULE_GDMA_CH1 = BIT(25),
|
SLEEP_RETENTION_MODULE_GDMA_CH1 = 25,
|
||||||
SLEEP_RETENTION_MODULE_GDMA_CH2 = BIT(26),
|
SLEEP_RETENTION_MODULE_GDMA_CH2 = 26,
|
||||||
|
|
||||||
|
SLEEP_RETENTION_MODULE_MAX = 31
|
||||||
|
} sleep_retention_module_t;
|
||||||
|
|
||||||
SLEEP_RETENTION_MODULE_ALL = (uint32_t)-1
|
typedef enum sleep_retention_module_bitmap {
|
||||||
|
/* clock module, which includes system and modem */
|
||||||
|
SLEEP_RETENTION_MODULE_BM_CLOCK_SYSTEM = BIT(SLEEP_RETENTION_MODULE_CLOCK_SYSTEM),
|
||||||
|
SLEEP_RETENTION_MODULE_BM_CLOCK_MODEM = BIT(SLEEP_RETENTION_MODULE_CLOCK_MODEM),
|
||||||
|
|
||||||
|
/* 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),
|
||||||
|
|
||||||
|
/* digital peripheral module, which includes Interrupt Matrix, HP_SYSTEM,
|
||||||
|
* TEE, APM, UART, Timer Group, IOMUX, SPIMEM, SysTimer, etc.. */
|
||||||
|
SLEEP_RETENTION_MODULE_BM_INTR_MATRIX = BIT(SLEEP_RETENTION_MODULE_INTR_MATRIX),
|
||||||
|
SLEEP_RETENTION_MODULE_BM_HP_SYSTEM = BIT(SLEEP_RETENTION_MODULE_HP_SYSTEM),
|
||||||
|
SLEEP_RETENTION_MODULE_BM_TEE_APM = BIT(SLEEP_RETENTION_MODULE_TEE_APM),
|
||||||
|
SLEEP_RETENTION_MODULE_BM_UART0 = BIT(SLEEP_RETENTION_MODULE_UART0),
|
||||||
|
SLEEP_RETENTION_MODULE_BM_TG0 = BIT(SLEEP_RETENTION_MODULE_TG0),
|
||||||
|
SLEEP_RETENTION_MODULE_BM_IOMUX = BIT(SLEEP_RETENTION_MODULE_IOMUX),
|
||||||
|
SLEEP_RETENTION_MODULE_BM_SPIMEM = BIT(SLEEP_RETENTION_MODULE_SPIMEM),
|
||||||
|
SLEEP_RETENTION_MODULE_BM_SYSTIMER = BIT(SLEEP_RETENTION_MODULE_SYSTIMER),
|
||||||
|
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
|
||||||
} sleep_retention_module_bitmap_t;
|
} sleep_retention_module_bitmap_t;
|
||||||
|
|
||||||
typedef regdma_entry_buf_t sleep_retention_entries_t;
|
typedef regdma_entry_buf_t sleep_retention_entries_t;
|
||||||
@ -67,21 +96,21 @@ typedef struct {
|
|||||||
* @param num the total number of sleep retention linked list configuration
|
* @param num the total number of sleep retention linked list configuration
|
||||||
* items
|
* items
|
||||||
* @param priority the priority of the created sleep retention linked list
|
* @param priority the priority of the created sleep retention linked list
|
||||||
* @param module the bitmap of the module to which the created sleep retention
|
* @param module the number of the module to which the created sleep retention
|
||||||
* linked list belongs
|
* linked list belongs
|
||||||
* @return
|
* @return
|
||||||
* - ESP_OK on success
|
* - ESP_OK on success
|
||||||
* - ESP_ERR_NO_MEM not enough memory for sleep retention
|
* - ESP_ERR_NO_MEM not enough memory for sleep retention
|
||||||
* - ESP_ERR_INVALID_ARG if either of the arguments is out of range
|
* - ESP_ERR_INVALID_ARG if either of the arguments is out of range
|
||||||
*/
|
*/
|
||||||
esp_err_t sleep_retention_entries_create(const sleep_retention_entries_config_t retent[], int num, regdma_link_priority_t priority, int module);
|
esp_err_t sleep_retention_entries_create(const sleep_retention_entries_config_t retent[], int num, regdma_link_priority_t priority, sleep_retention_module_t module);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Destroy a runtime sleep retention linked list
|
* @brief Destroy a runtime sleep retention linked list
|
||||||
*
|
*
|
||||||
* @param module the bitmap of the module to be destroyed
|
* @param module the bitmap of the module to be destroyed
|
||||||
*/
|
*/
|
||||||
void sleep_retention_entries_destroy(int module);
|
void sleep_retention_entries_destroy(sleep_retention_module_t module);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Print all runtime sleep retention linked lists
|
* @brief Print all runtime sleep retention linked lists
|
||||||
|
@ -80,9 +80,9 @@ bool clock_domain_pd_allowed(void)
|
|||||||
{
|
{
|
||||||
const uint32_t created_modules = sleep_retention_get_created_modules();
|
const uint32_t created_modules = sleep_retention_get_created_modules();
|
||||||
const uint32_t mask = (const uint32_t) (
|
const uint32_t mask = (const uint32_t) (
|
||||||
SLEEP_RETENTION_MODULE_CLOCK_SYSTEM
|
BIT(SLEEP_RETENTION_MODULE_CLOCK_SYSTEM)
|
||||||
#if CONFIG_MAC_BB_PD || CONFIG_BT_LE_SLEEP_ENABLE || CONFIG_IEEE802154_SLEEP_ENABLE
|
#if CONFIG_MAC_BB_PD || CONFIG_BT_LE_SLEEP_ENABLE || CONFIG_IEEE802154_SLEEP_ENABLE
|
||||||
| SLEEP_RETENTION_MODULE_CLOCK_MODEM
|
| BIT(SLEEP_RETENTION_MODULE_CLOCK_MODEM)
|
||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
return ((created_modules & mask) == mask);
|
return ((created_modules & mask) == mask);
|
||||||
|
@ -286,12 +286,15 @@ bool modem_domain_pd_allowed(void)
|
|||||||
{
|
{
|
||||||
#if SOC_PM_MODEM_RETENTION_BY_REGDMA
|
#if SOC_PM_MODEM_RETENTION_BY_REGDMA
|
||||||
const uint32_t created_modules = sleep_retention_get_created_modules();
|
const uint32_t created_modules = sleep_retention_get_created_modules();
|
||||||
const uint32_t mask_wifi = (const uint32_t) (SLEEP_RETENTION_MODULE_WIFI_MAC |
|
const uint32_t mask_wifi = (const uint32_t) ( \
|
||||||
SLEEP_RETENTION_MODULE_WIFI_BB);
|
BIT(SLEEP_RETENTION_MODULE_WIFI_MAC) | \
|
||||||
const uint32_t mask_ble = (const uint32_t) (SLEEP_RETENTION_MODULE_BLE_MAC |
|
BIT(SLEEP_RETENTION_MODULE_WIFI_BB));
|
||||||
SLEEP_RETENTION_MODULE_BT_BB);
|
const uint32_t mask_ble = (const uint32_t) ( \
|
||||||
const uint32_t mask_154 = (const uint32_t) (SLEEP_RETENTION_MODULE_802154_MAC |
|
BIT(SLEEP_RETENTION_MODULE_BLE_MAC) | \
|
||||||
SLEEP_RETENTION_MODULE_BT_BB);
|
BIT(SLEEP_RETENTION_MODULE_BT_BB));
|
||||||
|
const uint32_t mask_154 = (const uint32_t) ( \
|
||||||
|
BIT(SLEEP_RETENTION_MODULE_802154_MAC) | \
|
||||||
|
BIT(SLEEP_RETENTION_MODULE_BT_BB));
|
||||||
return (((created_modules & mask_wifi) == mask_wifi) ||
|
return (((created_modules & mask_wifi) == mask_wifi) ||
|
||||||
((created_modules & mask_ble) == mask_ble) ||
|
((created_modules & mask_ble) == mask_ble) ||
|
||||||
((created_modules & mask_154) == mask_154));
|
((created_modules & mask_154) == mask_154));
|
||||||
|
@ -82,6 +82,7 @@ typedef struct {
|
|||||||
#define SLEEP_RETENTION_REGDMA_LINK_NR_PRIORITIES (8u)
|
#define SLEEP_RETENTION_REGDMA_LINK_NR_PRIORITIES (8u)
|
||||||
#define SLEEP_RETENTION_REGDMA_LINK_HIGHEST_PRIORITY (0)
|
#define SLEEP_RETENTION_REGDMA_LINK_HIGHEST_PRIORITY (0)
|
||||||
#define SLEEP_RETENTION_REGDMA_LINK_LOWEST_PRIORITY (SLEEP_RETENTION_REGDMA_LINK_NR_PRIORITIES - 1)
|
#define SLEEP_RETENTION_REGDMA_LINK_LOWEST_PRIORITY (SLEEP_RETENTION_REGDMA_LINK_NR_PRIORITIES - 1)
|
||||||
|
#define SLEEP_RETENTION_MODULE_INVALID ((sleep_retention_module_t)(-1)) /* the final node does not belong to any module */
|
||||||
struct {
|
struct {
|
||||||
sleep_retention_entries_t entries;
|
sleep_retention_entries_t entries;
|
||||||
uint32_t entries_bitmap: REGDMA_LINK_ENTRY_NUM,
|
uint32_t entries_bitmap: REGDMA_LINK_ENTRY_NUM,
|
||||||
@ -104,9 +105,14 @@ static DRAM_ATTR __attribute__((unused)) sleep_retention_t s_retention = {
|
|||||||
#define SLEEP_RETENTION_ENTRY_BITMAP_MASK (BIT(REGDMA_LINK_ENTRY_NUM) - 1)
|
#define SLEEP_RETENTION_ENTRY_BITMAP_MASK (BIT(REGDMA_LINK_ENTRY_NUM) - 1)
|
||||||
#define SLEEP_RETENTION_ENTRY_BITMAP(bitmap) ((bitmap) & SLEEP_RETENTION_ENTRY_BITMAP_MASK)
|
#define SLEEP_RETENTION_ENTRY_BITMAP(bitmap) ((bitmap) & SLEEP_RETENTION_ENTRY_BITMAP_MASK)
|
||||||
|
|
||||||
static esp_err_t sleep_retention_entries_create_impl(const sleep_retention_entries_config_t retent[], int num, regdma_link_priority_t priority, int 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;
|
||||||
@ -114,7 +120,7 @@ static inline bool sleep_retention_entries_require_branch(uint32_t owner, uint32
|
|||||||
return use_new_entry && intersection_exist;
|
return use_new_entry && intersection_exist;
|
||||||
}
|
}
|
||||||
|
|
||||||
static esp_err_t sleep_retention_entries_check_and_create_default(uint32_t owner, uint32_t runtime_bitmap, uint32_t entries_bitmap, regdma_link_priority_t priority, uint32_t module)
|
static esp_err_t sleep_retention_entries_check_and_create_default(uint32_t owner, uint32_t runtime_bitmap, uint32_t entries_bitmap, regdma_link_priority_t priority, sleep_retention_module_t module)
|
||||||
{
|
{
|
||||||
assert(sleep_retention_entries_require_branch(owner, runtime_bitmap));
|
assert(sleep_retention_entries_require_branch(owner, runtime_bitmap));
|
||||||
|
|
||||||
@ -133,7 +139,7 @@ static esp_err_t sleep_retention_entries_check_and_create_final_default(void)
|
|||||||
esp_err_t err = ESP_OK;
|
esp_err_t err = ESP_OK;
|
||||||
_lock_acquire_recursive(&s_retention.lock);
|
_lock_acquire_recursive(&s_retention.lock);
|
||||||
if (s_retention.lists[SLEEP_RETENTION_REGDMA_LINK_LOWEST_PRIORITY].entries_bitmap == 0) {
|
if (s_retention.lists[SLEEP_RETENTION_REGDMA_LINK_LOWEST_PRIORITY].entries_bitmap == 0) {
|
||||||
err = sleep_retention_entries_create_impl(&final_dummy, 1, SLEEP_RETENTION_REGDMA_LINK_LOWEST_PRIORITY, 0);
|
err = sleep_retention_entries_create_impl(&final_dummy, 1, SLEEP_RETENTION_REGDMA_LINK_LOWEST_PRIORITY, SLEEP_RETENTION_MODULE_INVALID);
|
||||||
}
|
}
|
||||||
_lock_release_recursive(&s_retention.lock);
|
_lock_release_recursive(&s_retention.lock);
|
||||||
return err;
|
return err;
|
||||||
@ -157,7 +163,7 @@ static void sleep_retention_entries_update(uint32_t owner, void *new_link, regdm
|
|||||||
_lock_release_recursive(&s_retention.lock);
|
_lock_release_recursive(&s_retention.lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void * sleep_retention_entries_try_create(const regdma_link_config_t *config, uint32_t owner, regdma_link_priority_t priority, uint32_t module)
|
static void * sleep_retention_entries_try_create(const regdma_link_config_t *config, uint32_t owner, regdma_link_priority_t priority, sleep_retention_module_t module)
|
||||||
{
|
{
|
||||||
void *link = NULL;
|
void *link = NULL;
|
||||||
assert(owner > 0 && owner < BIT(REGDMA_LINK_ENTRY_NUM));
|
assert(owner > 0 && owner < BIT(REGDMA_LINK_ENTRY_NUM));
|
||||||
@ -165,9 +171,9 @@ 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) == ESP_OK) { /* branch node can't as tail node */
|
s_retention.lists[priority].entries_bitmap, priority, module_num2map(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,
|
||||||
@ -175,18 +181,18 @@ static void * sleep_retention_entries_try_create(const regdma_link_config_t *con
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
link = regdma_link_init_safe(config, false, module, s_retention.lists[priority].entries[__builtin_ffs(owner) - 1]);
|
link = regdma_link_init_safe(config, false, module_num2map(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;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void * sleep_retention_entries_try_create_bonding(const regdma_link_config_t *config, uint32_t owner, regdma_link_priority_t priority, uint32_t module)
|
static void * sleep_retention_entries_try_create_bonding(const regdma_link_config_t *config, uint32_t owner, regdma_link_priority_t priority, sleep_retention_module_t module)
|
||||||
{
|
{
|
||||||
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,
|
||||||
@ -246,7 +252,7 @@ static uint32_t sleep_retention_entries_owner_bitmap(sleep_retention_entries_t *
|
|||||||
return owner;
|
return owner;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool sleep_retention_entries_get_destroy_context(regdma_link_priority_t priority, uint32_t module, sleep_retention_entries_t *destroy_entries, void **destroy_tail, sleep_retention_entries_t *next_entries, void **prev_tail)
|
static bool sleep_retention_entries_get_destroy_context(regdma_link_priority_t priority, sleep_retention_module_t module, sleep_retention_entries_t *destroy_entries, void **destroy_tail, sleep_retention_entries_t *next_entries, void **prev_tail)
|
||||||
{
|
{
|
||||||
bool exist = false;
|
bool exist = false;
|
||||||
sleep_retention_entries_t destroy_tails, prev_tails;
|
sleep_retention_entries_t destroy_tails, prev_tails;
|
||||||
@ -257,13 +263,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);
|
s_retention.lists[priority].entries[entry], s_retention.lists[priority].entries_tail, entry, module_num2map(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);
|
s_retention.lists[priority].entries[entry], s_retention.lists[priority].entries_tail, entry, module_num2map(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);
|
s_retention.lists[priority].entries[entry], s_retention.lists[priority].entries_tail, entry, module_num2map(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);
|
s_retention.lists[priority].entries[entry], s_retention.lists[priority].entries_tail, entry, module_num2map(module));
|
||||||
if ((*destroy_entries)[entry] && destroy_tails[entry]) {
|
if ((*destroy_entries)[entry] && destroy_tails[entry]) {
|
||||||
exist = true;
|
exist = true;
|
||||||
}
|
}
|
||||||
@ -327,7 +333,7 @@ static void sleep_retention_entries_check_and_distroy_final_default(void)
|
|||||||
_lock_release_recursive(&s_retention.lock);
|
_lock_release_recursive(&s_retention.lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sleep_retention_entries_all_destroy_wrapper(uint32_t module)
|
static void sleep_retention_entries_all_destroy_wrapper(sleep_retention_module_t module)
|
||||||
{
|
{
|
||||||
void *destroy_tail = NULL, *prev_tail = NULL;
|
void *destroy_tail = NULL, *prev_tail = NULL;
|
||||||
sleep_retention_entries_t destroy_entries, next_entries;
|
sleep_retention_entries_t destroy_entries, next_entries;
|
||||||
@ -348,13 +354,13 @@ static void sleep_retention_entries_all_destroy_wrapper(uint32_t module)
|
|||||||
priority++;
|
priority++;
|
||||||
}
|
}
|
||||||
} while (priority < SLEEP_RETENTION_REGDMA_LINK_NR_PRIORITIES);
|
} while (priority < SLEEP_RETENTION_REGDMA_LINK_NR_PRIORITIES);
|
||||||
s_retention.created_modules &= ~module;
|
s_retention.created_modules &= ~module_num2map(module);
|
||||||
_lock_release_recursive(&s_retention.lock);
|
_lock_release_recursive(&s_retention.lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sleep_retention_entries_do_destroy(int module)
|
static void sleep_retention_entries_do_destroy(sleep_retention_module_t module)
|
||||||
{
|
{
|
||||||
assert(module != 0);
|
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_join();
|
sleep_retention_entries_join();
|
||||||
sleep_retention_entries_stats();
|
sleep_retention_entries_stats();
|
||||||
@ -362,9 +368,9 @@ static void sleep_retention_entries_do_destroy(int module)
|
|||||||
_lock_release_recursive(&s_retention.lock);
|
_lock_release_recursive(&s_retention.lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
void sleep_retention_entries_destroy(int module)
|
void sleep_retention_entries_destroy(sleep_retention_module_t module)
|
||||||
{
|
{
|
||||||
assert(module != 0);
|
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) {
|
if (s_retention.created_modules == 0) {
|
||||||
@ -380,7 +386,7 @@ void sleep_retention_entries_destroy(int module)
|
|||||||
_lock_release_recursive(&s_retention.lock);
|
_lock_release_recursive(&s_retention.lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
static esp_err_t sleep_retention_entries_create_impl(const sleep_retention_entries_config_t retent[], int num, regdma_link_priority_t priority, int 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)
|
||||||
{
|
{
|
||||||
_lock_acquire_recursive(&s_retention.lock);
|
_lock_acquire_recursive(&s_retention.lock);
|
||||||
for (int i = num - 1; i >= 0; i--) {
|
for (int i = num - 1; i >= 0; i--) {
|
||||||
@ -403,7 +409,7 @@ static esp_err_t sleep_retention_entries_create_impl(const sleep_retention_entri
|
|||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static esp_err_t sleep_retention_entries_create_bonding(regdma_link_priority_t priority, uint32_t module)
|
static esp_err_t sleep_retention_entries_create_bonding(regdma_link_priority_t priority, sleep_retention_module_t module)
|
||||||
{
|
{
|
||||||
static const sleep_retention_entries_config_t bonding_dummy = { REGDMA_LINK_WAIT_INIT(0xffff, 0, 0, 0, 1, 1), SLEEP_RETENTION_ENTRY_BITMAP_MASK };
|
static const sleep_retention_entries_config_t bonding_dummy = { REGDMA_LINK_WAIT_INIT(0xffff, 0, 0, 0, 1, 1), SLEEP_RETENTION_ENTRY_BITMAP_MASK };
|
||||||
|
|
||||||
@ -442,7 +448,7 @@ static void sleep_retention_entries_join(void)
|
|||||||
_lock_release_recursive(&s_retention.lock);
|
_lock_release_recursive(&s_retention.lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
static esp_err_t sleep_retention_entries_create_wrapper(const sleep_retention_entries_config_t retent[], int num, regdma_link_priority_t priority, uint32_t module)
|
static esp_err_t sleep_retention_entries_create_wrapper(const sleep_retention_entries_config_t retent[], int num, regdma_link_priority_t priority, sleep_retention_module_t module)
|
||||||
{
|
{
|
||||||
_lock_acquire_recursive(&s_retention.lock);
|
_lock_acquire_recursive(&s_retention.lock);
|
||||||
esp_err_t err = sleep_retention_entries_create_bonding(priority, module);
|
esp_err_t err = sleep_retention_entries_create_bonding(priority, module);
|
||||||
@ -451,7 +457,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;
|
s_retention.created_modules |= module_num2map(module);
|
||||||
sleep_retention_entries_join();
|
sleep_retention_entries_join();
|
||||||
|
|
||||||
error:
|
error:
|
||||||
@ -459,9 +465,15 @@ error:
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
esp_err_t sleep_retention_entries_create(const sleep_retention_entries_config_t retent[], int num, regdma_link_priority_t priority, int module)
|
esp_err_t sleep_retention_entries_create(const sleep_retention_entries_config_t retent[], int num, regdma_link_priority_t priority, sleep_retention_module_t module)
|
||||||
{
|
{
|
||||||
if (!(retent && num > 0 && (priority < SLEEP_RETENTION_REGDMA_LINK_NR_PRIORITIES) && (module != 0))) {
|
if (retent == NULL || num <= 0) {
|
||||||
|
return ESP_ERR_INVALID_ARG;
|
||||||
|
}
|
||||||
|
if (priority >= SLEEP_RETENTION_REGDMA_LINK_NR_PRIORITIES) {
|
||||||
|
return ESP_ERR_INVALID_ARG;
|
||||||
|
}
|
||||||
|
if (module < SLEEP_RETENTION_MODULE_MIN || module > SLEEP_RETENTION_MODULE_MAX) {
|
||||||
return ESP_ERR_INVALID_ARG;
|
return ESP_ERR_INVALID_ARG;
|
||||||
}
|
}
|
||||||
if (s_retention.lock == NULL) {
|
if (s_retention.lock == NULL) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@ -247,14 +247,14 @@ bool peripheral_domain_pd_allowed(void)
|
|||||||
{
|
{
|
||||||
const uint32_t created_modules = sleep_retention_get_created_modules();
|
const uint32_t created_modules = sleep_retention_get_created_modules();
|
||||||
const uint32_t mask = (const uint32_t) (
|
const uint32_t mask = (const uint32_t) (
|
||||||
SLEEP_RETENTION_MODULE_INTR_MATRIX | \
|
BIT(SLEEP_RETENTION_MODULE_INTR_MATRIX) | \
|
||||||
SLEEP_RETENTION_MODULE_HP_SYSTEM | \
|
BIT(SLEEP_RETENTION_MODULE_HP_SYSTEM) | \
|
||||||
SLEEP_RETENTION_MODULE_TEE_APM | \
|
BIT(SLEEP_RETENTION_MODULE_TEE_APM) | \
|
||||||
SLEEP_RETENTION_MODULE_UART0 | \
|
BIT(SLEEP_RETENTION_MODULE_UART0) | \
|
||||||
SLEEP_RETENTION_MODULE_TG0 | \
|
BIT(SLEEP_RETENTION_MODULE_TG0) | \
|
||||||
SLEEP_RETENTION_MODULE_IOMUX | \
|
BIT(SLEEP_RETENTION_MODULE_IOMUX) | \
|
||||||
SLEEP_RETENTION_MODULE_SPIMEM | \
|
BIT(SLEEP_RETENTION_MODULE_SPIMEM) | \
|
||||||
SLEEP_RETENTION_MODULE_SYSTIMER);
|
BIT(SLEEP_RETENTION_MODULE_SYSTIMER));
|
||||||
return ((created_modules & mask) == mask);
|
return ((created_modules & mask) == mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user