mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-02 12:14:32 +02:00
change(esp_hw_support): use new retention api to implement gdma retention
This commit is contained in:
@@ -10,39 +10,75 @@
|
|||||||
#include "soc/soc_caps.h"
|
#include "soc/soc_caps.h"
|
||||||
|
|
||||||
#include "esp_err.h"
|
#include "esp_err.h"
|
||||||
#include "esp_check.h"
|
#if CONFIG_GDMA_ENABLE_DEBUG_LOG
|
||||||
|
// The local log level must be defined before including esp_log.h
|
||||||
|
// Set the maximum log level for this source file
|
||||||
|
#define LOG_LOCAL_LEVEL ESP_LOG_DEBUG
|
||||||
|
#endif
|
||||||
#include "esp_log.h"
|
#include "esp_log.h"
|
||||||
|
#include "esp_check.h"
|
||||||
#include "esp_private/sleep_retention.h"
|
#include "esp_private/sleep_retention.h"
|
||||||
#include "esp_private/esp_regdma.h"
|
#include "esp_private/esp_regdma.h"
|
||||||
|
|
||||||
#include "sleep_gdma_retention_context.inc"
|
#include "hal/gdma_ll.h"
|
||||||
|
|
||||||
static const char *TAG = "gdma";
|
static const char *TAG = "gdma";
|
||||||
|
|
||||||
#define SLEEP_RETENTION_MODULE_GDMA_CH(group_id, pair_id) (SLEEP_RETENTION_MODULE_GDMA_CH0 << (SOC_GDMA_PAIRS_PER_GROUP_MAX * group_id) << pair_id)
|
typedef struct {
|
||||||
|
int group_id;
|
||||||
|
int pair_id;
|
||||||
|
} gdma_channel_retention_arg_t;
|
||||||
|
|
||||||
static esp_err_t sleep_modem_gdma_channel_retention_init(sleep_retention_module_bitmap_t module)
|
typedef struct gdma_chx_reg_ctx_link {
|
||||||
|
const sleep_retention_entries_config_t *link_list;
|
||||||
|
uint32_t link_num;
|
||||||
|
} gdma_chx_reg_ctx_link_t;
|
||||||
|
|
||||||
|
#include "sleep_gdma_retention_context.inc"
|
||||||
|
|
||||||
|
static esp_err_t sleep_gdma_channel_retention_init(void *arg)
|
||||||
{
|
{
|
||||||
uint32_t id = __builtin_ctz(module / SLEEP_RETENTION_MODULE_GDMA_CH0);
|
gdma_channel_retention_arg_t *parg = (gdma_channel_retention_arg_t *)arg;
|
||||||
esp_err_t err = sleep_retention_entries_create(gdma_chx_regs_retention[id].link_list, gdma_chx_regs_retention[id].link_num, REGDMA_LINK_PRI_7, module);
|
int group_id = parg->group_id;
|
||||||
|
int pair_id = parg->pair_id;
|
||||||
|
|
||||||
|
sleep_retention_module_bitmap_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_7, module);
|
||||||
if (err == ESP_OK) {
|
if (err == ESP_OK) {
|
||||||
int group_id = id / SOC_GDMA_PAIRS_PER_GROUP_MAX;
|
ESP_LOGD(TAG, "GDMA pair (%d, %d) retention initialization", group_id, pair_id);
|
||||||
int pair_id = id % SOC_GDMA_PAIRS_PER_GROUP_MAX;
|
|
||||||
ESP_LOGI(TAG, "GDMA pair (%d, %d) retention initialization", group_id, pair_id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ESP_RETURN_ON_ERROR(err, TAG, "Failed to create sleep retention linked list for GDMA pair (%d, %d) retention", group_id, pair_id);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
esp_err_t gdma_sleep_retention_init(int group_id, int pair_id)
|
esp_err_t gdma_sleep_retention_init(int group_id, int pair_id)
|
||||||
{
|
{
|
||||||
esp_err_t err = ESP_OK;
|
gdma_channel_retention_arg_t arg = { .group_id = group_id, .pair_id = pair_id };
|
||||||
err = sleep_modem_gdma_channel_retention_init(SLEEP_RETENTION_MODULE_GDMA_CH(group_id, pair_id));
|
sleep_retention_module_init_param_t init_param = {
|
||||||
ESP_RETURN_ON_ERROR(err, TAG, "Failed to create sleep retention linked list for GDMA pair (%d, %d) retention", group_id, pair_id);
|
.cbs = { .create = { .handle = sleep_gdma_channel_retention_init, .arg = &arg } },
|
||||||
|
.depends = BIT(SLEEP_RETENTION_MODULE_CLOCK_SYSTEM)
|
||||||
|
};
|
||||||
|
sleep_retention_module_bitmap_t module = GDMA_CH_RETENTION_GET_MODULE_ID(group_id, pair_id);
|
||||||
|
esp_err_t err = sleep_retention_module_init(module, &init_param);
|
||||||
|
if (err == ESP_OK) {
|
||||||
|
err = sleep_retention_module_allocate(module);
|
||||||
|
if (err != ESP_OK) {
|
||||||
|
ESP_LOGW(TAG, "Failed to allocate sleep retention linked list for GDMA retention");
|
||||||
|
}
|
||||||
|
}
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
esp_err_t gdma_sleep_retention_deinit(int group_id, int pair_id)
|
esp_err_t gdma_sleep_retention_deinit(int group_id, int pair_id)
|
||||||
{
|
{
|
||||||
sleep_retention_entries_destroy(SLEEP_RETENTION_MODULE_GDMA_CH(group_id, pair_id));
|
esp_err_t err = sleep_retention_module_free(GDMA_CH_RETENTION_GET_MODULE_ID(group_id, pair_id));
|
||||||
return ESP_OK;;
|
if (err != ESP_OK) {
|
||||||
|
ESP_LOGW(TAG, "GDMA pair (%d, %d) retention destroy failed", group_id, pair_id);
|
||||||
|
}
|
||||||
|
err = sleep_retention_module_deinit(GDMA_CH_RETENTION_GET_MODULE_ID(group_id, pair_id));
|
||||||
|
if (err != ESP_OK) {
|
||||||
|
ESP_LOGW(TAG, "GDMA pair (%d, %d) retention deinit failed", group_id, pair_id);
|
||||||
|
}
|
||||||
|
return err;
|
||||||
}
|
}
|
||||||
|
@@ -50,32 +50,31 @@ static const sleep_retention_entries_config_t gdma_g0p1_regs_retention[] = {
|
|||||||
GDMA_IN_CONF0_CH2_REG / GDMA_IN_CONF1_CH2_REG / GDMA_IN_LINK_CH2_REG / GDMA_IN_PRI_CH2_REG
|
GDMA_IN_CONF0_CH2_REG / GDMA_IN_CONF1_CH2_REG / GDMA_IN_LINK_CH2_REG / GDMA_IN_PRI_CH2_REG
|
||||||
GDMA_OUT_CONF0_CH2_REG / GDMA_OUT_CONF1_CH2_REG / GDMA_OUT_LINK_CH2_REG /GDMA_OUT_PRI_CH2_REG
|
GDMA_OUT_CONF0_CH2_REG / GDMA_OUT_CONF1_CH2_REG / GDMA_OUT_LINK_CH2_REG /GDMA_OUT_PRI_CH2_REG
|
||||||
*/
|
*/
|
||||||
#define G0P1_RETENTION_REGS_CNT_0 6
|
#define G0P2_RETENTION_REGS_CNT_0 6
|
||||||
#define G0P2_RETENTION_MAP_BASE_0 GDMA_IN_INT_ENA_CH2_REG
|
#define G0P2_RETENTION_MAP_BASE_0 GDMA_IN_INT_ENA_CH2_REG
|
||||||
#define G0P1_RETENTION_REGS_CNT_1 7
|
#define G0P2_RETENTION_REGS_CNT_1 7
|
||||||
#define G0P2_RETENTION_MAP_BASE_1 GDMA_IN_PRI_CH2_REG
|
#define G0P2_RETENTION_MAP_BASE_1 GDMA_IN_PRI_CH2_REG
|
||||||
static const uint32_t g0p2_regs_map0[4] = {0x9001, 0, 0, 0x4C0000};
|
static const uint32_t g0p2_regs_map0[4] = {0x9001, 0, 0, 0x4C0000};
|
||||||
static const uint32_t g0p2_regs_map1[4] = {0x3026003, 0, 0, 0};
|
static const uint32_t g0p2_regs_map1[4] = {0x3026003, 0, 0, 0};
|
||||||
static const sleep_retention_entries_config_t gdma_g0p2_regs_retention[] = {
|
static const sleep_retention_entries_config_t gdma_g0p2_regs_retention[] = {
|
||||||
[0] = { .config = REGDMA_LINK_ADDR_MAP_INIT(REGDMA_MODEM_GDMA_LINK(0x00), \
|
[0] = { .config = REGDMA_LINK_ADDR_MAP_INIT(REGDMA_MODEM_GDMA_LINK(0x00), \
|
||||||
G0P2_RETENTION_MAP_BASE_0, G0P2_RETENTION_MAP_BASE_0, \
|
G0P2_RETENTION_MAP_BASE_0, G0P2_RETENTION_MAP_BASE_0, \
|
||||||
G0P1_RETENTION_REGS_CNT_0, 0, 0, \
|
G0P2_RETENTION_REGS_CNT_0, 0, 0, \
|
||||||
g0p2_regs_map0[0], g0p2_regs_map0[1], \
|
g0p2_regs_map0[0], g0p2_regs_map0[1], \
|
||||||
g0p2_regs_map0[2], g0p2_regs_map0[3]), \
|
g0p2_regs_map0[2], g0p2_regs_map0[3]), \
|
||||||
.owner = ENTRY(0) | ENTRY(2) },
|
.owner = ENTRY(0) | ENTRY(2) },
|
||||||
[1] = { .config = REGDMA_LINK_ADDR_MAP_INIT(REGDMA_MODEM_GDMA_LINK(0x00), \
|
[1] = { .config = REGDMA_LINK_ADDR_MAP_INIT(REGDMA_MODEM_GDMA_LINK(0x00), \
|
||||||
G0P2_RETENTION_MAP_BASE_1, G0P2_RETENTION_MAP_BASE_1, \
|
G0P2_RETENTION_MAP_BASE_1, G0P2_RETENTION_MAP_BASE_1, \
|
||||||
G0P1_RETENTION_REGS_CNT_1, 0, 0, \
|
G0P2_RETENTION_REGS_CNT_1, 0, 0, \
|
||||||
g0p2_regs_map1[0], g0p2_regs_map1[1], \
|
g0p2_regs_map1[0], g0p2_regs_map1[1], \
|
||||||
g0p2_regs_map1[2], g0p2_regs_map1[3]), \
|
g0p2_regs_map1[2], g0p2_regs_map1[3]), \
|
||||||
.owner = ENTRY(0) | ENTRY(2) },
|
.owner = ENTRY(0) | ENTRY(2) },
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct {
|
const gdma_chx_reg_ctx_link_t gdma_chx_regs_retention[SOC_GDMA_NUM_GROUPS_MAX][SOC_GDMA_PAIRS_PER_GROUP_MAX] = {
|
||||||
const sleep_retention_entries_config_t *link_list;
|
[0] = {
|
||||||
uint32_t link_num;
|
|
||||||
} gdma_chx_regs_retention[SOC_GDMA_PAIRS_PER_GROUP_MAX*SOC_GDMA_PAIRS_PER_GROUP_MAX] = {
|
|
||||||
[0] = {gdma_g0p0_regs_retention, ARRAY_SIZE(gdma_g0p0_regs_retention)},
|
[0] = {gdma_g0p0_regs_retention, ARRAY_SIZE(gdma_g0p0_regs_retention)},
|
||||||
[1] = {gdma_g0p1_regs_retention, ARRAY_SIZE(gdma_g0p1_regs_retention)},
|
[1] = {gdma_g0p1_regs_retention, ARRAY_SIZE(gdma_g0p1_regs_retention)},
|
||||||
[2] = {gdma_g0p2_regs_retention, ARRAY_SIZE(gdma_g0p2_regs_retention)}
|
[2] = {gdma_g0p2_regs_retention, ARRAY_SIZE(gdma_g0p2_regs_retention)}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
@@ -50,32 +50,31 @@ static const sleep_retention_entries_config_t gdma_g0p1_regs_retention[] = {
|
|||||||
GDMA_IN_CONF0_CH2_REG / GDMA_IN_CONF1_CH2_REG / GDMA_IN_LINK_CH2_REG / GDMA_IN_PRI_CH2_REG
|
GDMA_IN_CONF0_CH2_REG / GDMA_IN_CONF1_CH2_REG / GDMA_IN_LINK_CH2_REG / GDMA_IN_PRI_CH2_REG
|
||||||
GDMA_OUT_CONF0_CH2_REG / GDMA_OUT_CONF1_CH2_REG / GDMA_OUT_LINK_CH2_REG /GDMA_OUT_PRI_CH2_REG
|
GDMA_OUT_CONF0_CH2_REG / GDMA_OUT_CONF1_CH2_REG / GDMA_OUT_LINK_CH2_REG /GDMA_OUT_PRI_CH2_REG
|
||||||
*/
|
*/
|
||||||
#define G0P1_RETENTION_REGS_CNT_0 6
|
#define G0P2_RETENTION_REGS_CNT_0 6
|
||||||
#define G0P2_RETENTION_MAP_BASE_0 GDMA_IN_INT_ENA_CH2_REG
|
#define G0P2_RETENTION_MAP_BASE_0 GDMA_IN_INT_ENA_CH2_REG
|
||||||
#define G0P1_RETENTION_REGS_CNT_1 7
|
#define G0P2_RETENTION_REGS_CNT_1 7
|
||||||
#define G0P2_RETENTION_MAP_BASE_1 GDMA_IN_PRI_CH2_REG
|
#define G0P2_RETENTION_MAP_BASE_1 GDMA_IN_PRI_CH2_REG
|
||||||
static const uint32_t g0p2_regs_map0[4] = {0x9001, 0, 0, 0x4C0000};
|
static const uint32_t g0p2_regs_map0[4] = {0x9001, 0, 0, 0x4C0000};
|
||||||
static const uint32_t g0p2_regs_map1[4] = {0x3026003, 0, 0, 0};
|
static const uint32_t g0p2_regs_map1[4] = {0x3026003, 0, 0, 0};
|
||||||
static const sleep_retention_entries_config_t gdma_g0p2_regs_retention[] = {
|
static const sleep_retention_entries_config_t gdma_g0p2_regs_retention[] = {
|
||||||
[0] = { .config = REGDMA_LINK_ADDR_MAP_INIT(REGDMA_MODEM_GDMA_LINK(0x00), \
|
[0] = { .config = REGDMA_LINK_ADDR_MAP_INIT(REGDMA_MODEM_GDMA_LINK(0x00), \
|
||||||
G0P2_RETENTION_MAP_BASE_0, G0P2_RETENTION_MAP_BASE_0, \
|
G0P2_RETENTION_MAP_BASE_0, G0P2_RETENTION_MAP_BASE_0, \
|
||||||
G0P1_RETENTION_REGS_CNT_0, 0, 0, \
|
G0P2_RETENTION_REGS_CNT_0, 0, 0, \
|
||||||
g0p2_regs_map0[0], g0p2_regs_map0[1], \
|
g0p2_regs_map0[0], g0p2_regs_map0[1], \
|
||||||
g0p2_regs_map0[2], g0p2_regs_map0[3]), \
|
g0p2_regs_map0[2], g0p2_regs_map0[3]), \
|
||||||
.owner = ENTRY(0) | ENTRY(2) },
|
.owner = ENTRY(0) | ENTRY(2) },
|
||||||
[1] = { .config = REGDMA_LINK_ADDR_MAP_INIT(REGDMA_MODEM_GDMA_LINK(0x00), \
|
[1] = { .config = REGDMA_LINK_ADDR_MAP_INIT(REGDMA_MODEM_GDMA_LINK(0x00), \
|
||||||
G0P2_RETENTION_MAP_BASE_1, G0P2_RETENTION_MAP_BASE_1, \
|
G0P2_RETENTION_MAP_BASE_1, G0P2_RETENTION_MAP_BASE_1, \
|
||||||
G0P1_RETENTION_REGS_CNT_1, 0, 0, \
|
G0P2_RETENTION_REGS_CNT_1, 0, 0, \
|
||||||
g0p2_regs_map1[0], g0p2_regs_map1[1], \
|
g0p2_regs_map1[0], g0p2_regs_map1[1], \
|
||||||
g0p2_regs_map1[2], g0p2_regs_map1[3]), \
|
g0p2_regs_map1[2], g0p2_regs_map1[3]), \
|
||||||
.owner = ENTRY(0) | ENTRY(2) },
|
.owner = ENTRY(0) | ENTRY(2) },
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct {
|
const gdma_chx_reg_ctx_link_t gdma_chx_regs_retention[SOC_GDMA_NUM_GROUPS_MAX][SOC_GDMA_PAIRS_PER_GROUP_MAX] = {
|
||||||
const sleep_retention_entries_config_t *link_list;
|
[0] = {
|
||||||
uint32_t link_num;
|
|
||||||
} gdma_chx_regs_retention[SOC_GDMA_PAIRS_PER_GROUP_MAX*SOC_GDMA_PAIRS_PER_GROUP_MAX] = {
|
|
||||||
[0] = {gdma_g0p0_regs_retention, ARRAY_SIZE(gdma_g0p0_regs_retention)},
|
[0] = {gdma_g0p0_regs_retention, ARRAY_SIZE(gdma_g0p0_regs_retention)},
|
||||||
[1] = {gdma_g0p1_regs_retention, ARRAY_SIZE(gdma_g0p1_regs_retention)},
|
[1] = {gdma_g0p1_regs_retention, ARRAY_SIZE(gdma_g0p1_regs_retention)},
|
||||||
[2] = {gdma_g0p2_regs_retention, ARRAY_SIZE(gdma_g0p2_regs_retention)}
|
[2] = {gdma_g0p2_regs_retention, ARRAY_SIZE(gdma_g0p2_regs_retention)}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
@@ -18,6 +18,8 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define GDMA_CH_RETENTION_GET_MODULE_ID(group_id, pair_id) (SLEEP_RETENTION_MODULE_GDMA_CH0 + (SOC_GDMA_PAIRS_PER_GROUP_MAX * group_id) + pair_id)
|
||||||
|
|
||||||
#define GDMA_LL_GET_HW(id) (((id) == 0) ? (&GDMA) : NULL)
|
#define GDMA_LL_GET_HW(id) (((id) == 0) ? (&GDMA) : NULL)
|
||||||
|
|
||||||
#define GDMA_LL_CHANNEL_MAX_PRIORITY 5 // supported priority levels: [0,5]
|
#define GDMA_LL_CHANNEL_MAX_PRIORITY 5 // supported priority levels: [0,5]
|
||||||
|
@@ -18,6 +18,8 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define GDMA_CH_RETENTION_GET_MODULE_ID(group_id, pair_id) (SLEEP_RETENTION_MODULE_GDMA_CH0 + (SOC_GDMA_PAIRS_PER_GROUP_MAX * group_id) + pair_id)
|
||||||
|
|
||||||
#define GDMA_LL_GET_HW(id) (((id) == 0) ? (&GDMA) : NULL)
|
#define GDMA_LL_GET_HW(id) (((id) == 0) ? (&GDMA) : NULL)
|
||||||
|
|
||||||
#define GDMA_LL_CHANNEL_MAX_PRIORITY 5 // supported priority levels: [0,5]
|
#define GDMA_LL_CHANNEL_MAX_PRIORITY 5 // supported priority levels: [0,5]
|
||||||
|
Reference in New Issue
Block a user