change(esp_hw_support): set HP/LP mem in retention mode in sleep

This commit is contained in:
wuzhenghui
2025-10-17 20:20:40 +08:00
parent 5c10e4b719
commit a4ceeec72c
4 changed files with 52 additions and 6 deletions

View File

@@ -14,9 +14,11 @@
#include "soc/pmu_struct.h"
#include "hal/efuse_hal.h"
#include "hal/pmu_hal.h"
#include "hal/lp_sys_ll.h"
#include "pmu_param.h"
#include "esp_private/esp_pmu.h"
#include "soc/regi2c_dig_reg.h"
#include "soc/lp_system_reg.h"
#include "regi2c_ctrl.h"
#include "esp_rom_sys.h"
#include "soc/rtc.h"
@@ -175,6 +177,9 @@ static void pmu_hp_system_init_default(pmu_context_t *ctx)
pmu_hp_system_param_default(mode, &param);
pmu_hp_system_init(ctx, mode, &param);
}
#if CONFIG_ESP32P4_REV_MIN_FULL >= 300
lp_sys_ll_set_hp_mem_lowpower_mode(MEM_AUX_DEEPSLEEP);
#endif
}
static inline void pmu_lp_system_param_default(pmu_lp_mode_t mode, pmu_lp_system_param_t *param)
@@ -191,6 +196,9 @@ static void pmu_lp_system_init_default(pmu_context_t *ctx)
pmu_lp_system_param_default(mode, &param);
pmu_lp_system_init(ctx, mode, &param);
}
#if CONFIG_ESP32P4_REV_MIN_FULL >= 300
lp_sys_ll_set_lp_mem_lowpower_mode(MEM_AUX_DEEPSLEEP);
#endif
}
void pmu_init(void)

View File

@@ -20,6 +20,10 @@
extern "C" {
#endif
#define MEM_AUX_SHUTDOWN BIT(0)
#define MEM_AUX_LIGHTSLEEP BIT(1)
#define MEM_AUX_DEEPSLEEP BIT(2)
/**
* @brief ROM obtains the wake-up type through LP_SYS_STORE9_REG[0].
* Set the flag to inform
@@ -65,6 +69,17 @@ FORCE_INLINE_ATTR void lp_sys_ll_set_pau_link_addr(uint32_t addr)
LP_SYS.backup_dma_cfg2.link_addr_aon = addr;
}
#if HAL_CONFIG(CHIP_SUPPORT_MIN_REV) >= 300
FORCE_INLINE_ATTR void lp_sys_ll_set_hp_mem_lowpower_mode(uint32_t mode)
{
LP_SYS.hp_mem_aux_ctrl.hp_mem_lowpower_mode = mode;
}
FORCE_INLINE_ATTR void lp_sys_ll_set_lp_mem_lowpower_mode(uint32_t mode)
{
LP_SYS.lp_mem_aux_ctrl.lp_mem_lowpower_mode = mode;
}
#endif
#ifdef __cplusplus
}
#endif

View File

@@ -1083,7 +1083,15 @@ extern "C" {
* need_des
*/
#define LP_SYSTEM_REG_HP_MEM_AUX_CTRL_REG (DR_REG_LP_SYS_BASE + 0x180)
/** LP_SYSTEM_REG_HP_MEM_AUX_CTRL : R/W; bitpos: [31:0]; default: 8304;
/** LP_SYSTEM_REG_HP_MEM_LOWPOWER_MODE : R/W; bitpos: [2:0]; default: 0;
* need_des
*/
#define LP_SYSTEM_REG_HP_MEM_LOWPOWER_MODE 0x7U
#define LP_SYSTEM_REG_HP_MEM_LOWPOWER_MODE_M (LP_SYSTEM_REG_HP_MEM_LOWPOWER_MODE_V << LP_SYSTEM_REG_HP_MEM_LOWPOWER_MODE_S)
#define LP_SYSTEM_REG_HP_MEM_LOWPOWER_MODE_V 0x7U
#define LP_SYSTEM_REG_HP_MEM_LOWPOWER_MODE_S 0
/** LP_SYSTEM_REG_HP_MEM_AUX_CTRL : R/W; bitpos: [31:3]; default: 1038;
* need_des
*/
#define LP_SYSTEM_REG_HP_MEM_AUX_CTRL 0xFFFFFFFFU
@@ -1095,7 +1103,14 @@ extern "C" {
* need_des
*/
#define LP_SYSTEM_REG_LP_MEM_AUX_CTRL_REG (DR_REG_LP_SYS_BASE + 0x184)
/** LP_SYSTEM_REG_LP_MEM_AUX_CTRL : R/W; bitpos: [31:0]; default: 8304;
/** LP_SYSTEM_REG_LP_MEM_LOWPOWER_MODE : R/W; bitpos: [2:0]; default: 0;
* need_des
*/
#define LP_SYSTEM_REG_LP_MEM_LOWPOWER_MODE 0x7U
#define LP_SYSTEM_REG_LP_MEM_LOWPOWER_MODE_M (LP_SYSTEM_REG_LP_MEM_LOWPOWER_MODE_V << LP_SYSTEM_REG_LP_MEM_LOWPOWER_MODE_S)
#define LP_SYSTEM_REG_LP_MEM_LOWPOWER_MODE_V 0x7U
#define LP_SYSTEM_REG_LP_MEM_LOWPOWER_MODE_S 0
/** LP_SYSTEM_REG_LP_MEM_AUX_CTRL : R/W; bitpos: [31:3]; default: 1038;
* need_des
*/
#define LP_SYSTEM_REG_LP_MEM_AUX_CTRL 0xFFFFFFFFU

View File

@@ -768,10 +768,14 @@ typedef union {
*/
typedef union {
struct {
/** hp_mem_aux_ctrl : R/W; bitpos: [31:0]; default: 8304;
/** hp_mem_lowpower_mode : R/W; bitpos: [2:0]; default: 0;
* need_des
*/
uint32_t hp_mem_aux_ctrl:32;
uint32_t hp_mem_lowpower_mode:3;
/** hp_mem_aux_ctrl : R/W; bitpos: [31:3]; default: 1038;
* need_des
*/
uint32_t hp_mem_aux_ctrl:29;
};
uint32_t val;
} lp_system_reg_hp_mem_aux_ctrl_reg_t;
@@ -781,10 +785,14 @@ typedef union {
*/
typedef union {
struct {
/** lp_mem_aux_ctrl : R/W; bitpos: [31:0]; default: 8304;
/** lp_mem_lowpower_mode : R/W; bitpos: [2:0]; default: 0;
* need_des
*/
uint32_t lp_mem_aux_ctrl:32;
uint32_t lp_mem_lowpower_mode:3;
/** lp_mem_aux_ctrl : R/W; bitpos: [31:3]; default: 1038;
* need_des
*/
uint32_t lp_mem_aux_ctrl:29;
};
uint32_t val;
} lp_system_reg_lp_mem_aux_ctrl_reg_t;