mirror of
https://github.com/espressif/esp-idf.git
synced 2025-09-23 09:13:11 +00:00
feat(pcnt): add sleep retention init
Currently, due to the lack of sleep callback feature. We only init sleep module but don't allocate it. Thus the power domain will be kept during the light sleep. And temporarily disable pcnt sleep retention support on P4 due to the lack of retention module ID.
This commit is contained in:

committed by
Chen Ji Chang

parent
1805efb0b2
commit
ddf6fea6a2
@@ -767,6 +767,10 @@ config SOC_PCNT_SUPPORT_STEP_NOTIFY
|
||||
bool
|
||||
default y
|
||||
|
||||
config SOC_PCNT_SUPPORT_SLEEP_RETENTION
|
||||
bool
|
||||
default y
|
||||
|
||||
config SOC_RMT_GROUPS
|
||||
int
|
||||
default 1
|
||||
|
@@ -42,6 +42,7 @@ typedef enum periph_retention_module {
|
||||
SLEEP_RETENTION_MODULE_PARLIO0 = 19,
|
||||
SLEEP_RETENTION_MODULE_GPSPI2 = 20,
|
||||
SLEEP_RETENTION_MODULE_LEDC = 21,
|
||||
SLEEP_RETENTION_MODULE_PCNT0 = 22,
|
||||
|
||||
/* modem module, which includes WiFi, BLE and 802.15.4 */
|
||||
SLEEP_RETENTION_MODULE_WIFI_MAC = 26,
|
||||
@@ -86,6 +87,7 @@ typedef enum periph_retention_module_bitmap {
|
||||
SLEEP_RETENTION_MODULE_BM_PARLIO0 = BIT(SLEEP_RETENTION_MODULE_PARLIO0),
|
||||
SLEEP_RETENTION_MODULE_BM_GPSPI2 = BIT(SLEEP_RETENTION_MODULE_GPSPI2),
|
||||
SLEEP_RETENTION_MODULE_BM_LEDC = BIT(SLEEP_RETENTION_MODULE_LEDC),
|
||||
SLEEP_RETENTION_MODULE_BM_PCNT0 = BIT(SLEEP_RETENTION_MODULE_PCNT0),
|
||||
|
||||
SLEEP_RETENTION_MODULE_BM_GDMA_CH0 = BIT(SLEEP_RETENTION_MODULE_GDMA_CH0),
|
||||
SLEEP_RETENTION_MODULE_BM_GDMA_CH1 = BIT(SLEEP_RETENTION_MODULE_GDMA_CH1),
|
||||
@@ -112,6 +114,7 @@ typedef enum periph_retention_module_bitmap {
|
||||
| SLEEP_RETENTION_MODULE_BM_PARLIO0 \
|
||||
| SLEEP_RETENTION_MODULE_BM_GPSPI2 \
|
||||
| SLEEP_RETENTION_MODULE_BM_LEDC \
|
||||
| SLEEP_RETENTION_MODULE_BM_PCNT0 \
|
||||
)
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@@ -322,6 +322,7 @@
|
||||
#define SOC_PCNT_SUPPORT_RUNTIME_THRES_UPDATE 1
|
||||
#define SOC_PCNT_SUPPORT_CLEAR_SIGNAL 1
|
||||
#define SOC_PCNT_SUPPORT_STEP_NOTIFY 1
|
||||
#define SOC_PCNT_SUPPORT_SLEEP_RETENTION 1 /*!< The sleep retention feature can help back up PCNT registers before sleep */
|
||||
|
||||
/*--------------------------- RMT CAPS ---------------------------------------*/
|
||||
#define SOC_RMT_GROUPS 1U /*!< One RMT group */
|
||||
|
@@ -6,6 +6,7 @@
|
||||
|
||||
#include "soc/pcnt_periph.h"
|
||||
#include "soc/gpio_sig_map.h"
|
||||
#include "soc/pcnt_reg.h"
|
||||
|
||||
const pcnt_signal_conn_t pcnt_periph_signals = {
|
||||
.groups = {
|
||||
@@ -68,3 +69,31 @@ const pcnt_signal_conn_t pcnt_periph_signals = {
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* PCNT Registers to be saved during sleep retention
|
||||
* - Configuration registers, e.g.: PCNT_CTRL_REG, PCNT_U0_CONF0_REG, PCNT_U0_CONF1_REG, PCNT_U0_CONF2_REG, PCNT_U1_CONF0_REG...
|
||||
* - Step Configuration registers, e.g.: PCNT_U0_CHANGE_CONF_REG, PCNT_U1_CHANGE_CONF_REG, PCNT_U2_CHANGE_CONF_REG, PCNT_U3_CHANGE_CONF_REG
|
||||
* - Interrupt enable registers, e.g.: PCNT_INT_ENA_REG
|
||||
*/
|
||||
#define PCNT_RETENTION_REGS_CNT 18
|
||||
#define PCNT_RETENTION_REGS_BASE (DR_REG_PCNT_BASE + 0x0)
|
||||
static const uint32_t pcnt_regs_map[4] = {0x1f040fff, 0x0, 0x0, 0x0};
|
||||
static const regdma_entries_config_t pcnt_regs_retention[] = {
|
||||
// backup stage: save configuration registers
|
||||
// restore stage: restore the configuration registers
|
||||
[0] = { .config = REGDMA_LINK_ADDR_MAP_INIT(REGDMA_PCNT_LINK(0x00), \
|
||||
PCNT_RETENTION_REGS_BASE, PCNT_RETENTION_REGS_BASE, \
|
||||
PCNT_RETENTION_REGS_CNT, 0, 0, \
|
||||
pcnt_regs_map[0], pcnt_regs_map[1], \
|
||||
pcnt_regs_map[2], pcnt_regs_map[3]), \
|
||||
.owner = ENTRY(0) | ENTRY(2) }, \
|
||||
};
|
||||
|
||||
const pcnt_reg_retention_info_t pcnt_reg_retention_info[SOC_PCNT_GROUPS] = {
|
||||
[0] = {
|
||||
.regdma_entry_array = pcnt_regs_retention,
|
||||
.array_size = ARRAY_SIZE(pcnt_regs_retention),
|
||||
.retention_module = SLEEP_RETENTION_MODULE_PCNT0
|
||||
},
|
||||
};
|
||||
|
Reference in New Issue
Block a user