Skip to content

Commit ee7f15d

Browse files
committed
change(esp_hw_support): remove DCDC-to-LDO power switch support in ESP32P4 lightsleep
1 parent 072bca4 commit ee7f15d

File tree

5 files changed

+10
-65
lines changed

5 files changed

+10
-65
lines changed

components/esp_hw_support/port/esp32p4/Kconfig.dcdc

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,10 @@
11
menu "DCDC Regulator Configurations"
2-
depends on SOC_GP_LDO_SUPPORTED
3-
4-
config ESP_SLEEP_KEEP_DCDC_ALWAYS_ON
5-
bool "Keep DC-DC power always on during light-sleep"
6-
default y
7-
help
8-
ESP32P4 will switch the power supply to LDO before sleeping, and switch to DCDC after waking up.
9-
These two processes take a long time and may bring some risks for some short duration
10-
light sleep. (DCDC -> LDO: 2.5ms (max), LDO -> DCDC: 1.2 ms)
11-
Enabling this option will make chip powered by DCDC during light sleep to reduce some power switch
12-
risks, this will also increase the power consumption during the light sleep.
13-
14-
DO NOT DISABLE UNLESS YOU KNOW WHAT YOU ARE DOING.
2+
depends on SOC_DCDC_SUPPORTED
153

164
config ESP_SLEEP_DCM_VSET_VAL_IN_SLEEP
175
int "DCDC voltage parameter during sleep"
186
default 14
197
range 0 31
20-
depends on ESP_SLEEP_KEEP_DCDC_ALWAYS_ON
218
help
229
This value determines the voltage of the DCDC chip during sleep. The same parameter value may
2310
correspond to different voltage values on different models of DCDC chips. Please update this

components/esp_hw_support/port/esp32p4/pmu_param.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ const pmu_hp_system_digital_param_t * pmu_hp_system_digital_param_default(pmu_hp
169169
#define PMU_HP_SLEEP_ANALOG_CONFIG_DEFAULT() { \
170170
.bias = { \
171171
.dcm_vset = 0, \
172-
.dcm_mode = 0, \
172+
.dcm_mode = 1, \
173173
.xpd_bias = 0, \
174174
.dbg_atten = 0x0, \
175175
.pd_cur = 1, \

components/esp_hw_support/port/esp32p4/pmu_sleep.c

Lines changed: 6 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -195,16 +195,9 @@ const pmu_sleep_config_t* pmu_sleep_config_default(
195195
analog_default.lp_sys[LP(SLEEP)].analog.pd_cur = PMU_PD_CUR_SLEEP_ON;
196196
analog_default.lp_sys[LP(SLEEP)].analog.bias_sleep = PMU_BIASSLP_SLEEP_ON;
197197
analog_default.lp_sys[LP(SLEEP)].analog.dbg_atten = PMU_DBG_ATTEN_ACTIVE_DEFAULT;
198-
#if !CONFIG_ESP_SLEEP_KEEP_DCDC_ALWAYS_ON
199-
analog_default.lp_sys[LP(SLEEP)].analog.dbias = LP_CALI_ACTIVE_DBIAS_DEFAULT;
200-
#endif
201198
}
202-
203-
#if CONFIG_ESP_SLEEP_KEEP_DCDC_ALWAYS_ON
204199
power_default.hp_sys.dig_power.dcdc_switch_pd_en = 0;
205200
analog_default.hp_sys.analog.dcm_vset = CONFIG_ESP_SLEEP_DCM_VSET_VAL_IN_SLEEP;
206-
analog_default.hp_sys.analog.dcm_mode = 1;
207-
#endif
208201
if (sleep_flags & PMU_SLEEP_PD_VDDSDIO) {
209202
analog_default.hp_sys.analog.xpd_0p1a = 0;
210203
} else {
@@ -276,6 +269,10 @@ static void pmu_sleep_digital_init(pmu_context_t *ctx, const pmu_sleep_digital_c
276269
static void pmu_sleep_analog_init(pmu_context_t *ctx, const pmu_sleep_analog_config_t *analog, bool dslp)
277270
{
278271
assert(ctx->hal);
272+
/* For deepsleep, DCDC_EN will be controlled by software to avoid DCDC working in a non-feedback state,
273+
which may cause input glitch voltage when waking up and switching to LDO. After chip wake up from deepsleep,
274+
set DCDC_EN in rtc_clk_init. */
275+
pmu_ll_hp_set_dcm_mode (ctx->hal->dev, HP(ACTIVE), dslp ? 0 : 1);
279276
pmu_ll_hp_set_dcm_mode (ctx->hal->dev, HP(SLEEP), analog->hp_sys.analog.dcm_mode);
280277
pmu_ll_hp_set_dcm_vset (ctx->hal->dev, HP(SLEEP), analog->hp_sys.analog.dcm_vset);
281278
pmu_ll_hp_set_current_power_off (ctx->hal->dev, HP(SLEEP), analog->hp_sys.analog.pd_cur);
@@ -291,24 +288,6 @@ static void pmu_sleep_analog_init(pmu_context_t *ctx, const pmu_sleep_analog_con
291288
pmu_ll_hp_set_regulator_dbias (ctx->hal->dev, HP(SLEEP), analog->hp_sys.analog.dbias);
292289
pmu_ll_hp_set_regulator_driver_bar (ctx->hal->dev, HP(SLEEP), analog->hp_sys.analog.drv_b);
293290

294-
#if CONFIG_ESP_SLEEP_KEEP_DCDC_ALWAYS_ON
295-
if (dslp)
296-
#endif
297-
{
298-
/**
299-
DCDC_EN will be controlled by software to avoid DCDC working in a non-feedback state, which may
300-
cause input glitch voltage when waking up and switching to LDO.
301-
1. Lightsleep:
302-
CONFIG_ESP_SLEEP_KEEP_DCDC_ALWAYS_ON = y: DCDC will not shutdown during sleep.
303-
CONFIG_ESP_SLEEP_KEEP_DCDC_ALWAYS_ON = n:
304-
PD_TOP: DCDC_EN DCDC_EN enabled by regdma after wake up.
305-
PU_TOP: DCDC_EN DCDC_EN enabled by pmu_sleep_finish after wakeup.
306-
2. Deepsleep
307-
After chip wake up from deepsleep, set DCDC_EN in rtc_clk_init.
308-
**/
309-
pmu_ll_hp_set_dcm_mode(ctx->hal->dev, HP(ACTIVE), 0);
310-
}
311-
312291
pmu_ll_lp_set_regulator_sleep_dbias(ctx->hal->dev, LP(ACTIVE), analog->lp_sys[LP(ACTIVE)].analog.slp_dbias);
313292
pmu_ll_lp_set_regulator_dbias (ctx->hal->dev, LP(ACTIVE), analog->lp_sys[LP(ACTIVE)].analog.dbias);
314293
pmu_ll_lp_set_regulator_driver_bar (ctx->hal->dev, LP(ACTIVE), analog->lp_sys[LP(ACTIVE)].analog.drv_b);
@@ -461,20 +440,13 @@ TCM_IRAM_ATTR uint32_t pmu_sleep_start(uint32_t wakeup_opt, uint32_t reject_opt,
461440

462441
TCM_IRAM_ATTR bool pmu_sleep_finish(bool dslp)
463442
{
464-
#if CONFIG_ESP_SLEEP_KEEP_DCDC_ALWAYS_ON
465-
if (!dslp) {
466-
// Keep DCDC always on during light sleep, no need to adjust LDO.
467-
} else
468-
#endif
469-
{
443+
if (dslp) {
470444
pmu_ll_hp_set_dcm_vset(&PMU, PMU_MODE_HP_ACTIVE, HP_CALI_ACTIVE_DCM_VSET_DEFAULT);
471445
pmu_sleep_enable_dcdc();
472-
if (pmu_ll_hp_is_sleep_reject(&PMU) || !s_pmu_sleep_regdma_backup_enabled) {
446+
if (pmu_ll_hp_is_sleep_reject(&PMU)) {
473447
// If sleep is rejected or regdma restore is skipped, the hardware wake-up process that
474448
// turns on DCDC is skipped, and wait DCDC volt rise up by software here.
475449
esp_rom_delay_us(DCDC_STARTUP_TIME_US);
476-
} else if (s_pmu_sleep_regdma_backup_enabled) {
477-
esp_rom_delay_us(DCDC_STARTUP_TIME_US - PMU_REGDMA_S2A_WORK_TIME_US);
478450
}
479451
pmu_sleep_shutdown_ldo();
480452
}

components/esp_hw_support/port/esp32p4/private_include/pmu_param.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ typedef struct {
351351
#define PMU_SLEEP_ANALOG_LSLP_CONFIG_DEFAULT(sleep_flags) { \
352352
.hp_sys = { \
353353
.analog = { \
354-
.dcm_mode = 0, \
354+
.dcm_mode = 1, \
355355
.drv_b = PMU_HP_DRVB_LIGHTSLEEP, \
356356
.pd_cur = PMU_PD_CUR_SLEEP_DEFAULT, \
357357
.bias_sleep = PMU_BIASSLP_SLEEP_DEFAULT, \

components/esp_hw_support/sleep_modes.c

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -945,14 +945,8 @@ static esp_err_t IRAM_ATTR esp_sleep_start(uint32_t sleep_flags, esp_sleep_mode_
945945
// Enter sleep
946946
esp_err_t result;
947947
#if SOC_PMU_SUPPORTED
948-
949948
#if SOC_DCDC_SUPPORTED
950-
#if CONFIG_ESP_SLEEP_KEEP_DCDC_ALWAYS_ON
951-
if (!deep_sleep) {
952-
// Keep DCDC always on during light sleep, no need to adjust LDO voltage.
953-
} else
954-
#endif
955-
{
949+
if (deep_sleep) {
956950
s_config.rtc_ticks_at_ldo_prepare = rtc_time_get();
957951
pmu_sleep_increase_ldo_volt();
958952
}
@@ -1051,14 +1045,6 @@ static esp_err_t IRAM_ATTR esp_sleep_start(uint32_t sleep_flags, esp_sleep_mode_
10511045
}
10521046
#endif
10531047

1054-
#if SOC_DCDC_SUPPORTED && !CONFIG_ESP_SLEEP_KEEP_DCDC_ALWAYS_ON
1055-
uint64_t ldo_increased_us = rtc_time_slowclk_to_us(rtc_time_get() - s_config.rtc_ticks_at_ldo_prepare, s_config.rtc_clk_cal_period);
1056-
if (ldo_increased_us < LDO_POWER_TAKEOVER_PREPARATION_TIME_US) {
1057-
esp_rom_delay_us(LDO_POWER_TAKEOVER_PREPARATION_TIME_US - ldo_increased_us);
1058-
}
1059-
pmu_sleep_shutdown_dcdc();
1060-
#endif
1061-
10621048
#if SOC_PMU_SUPPORTED
10631049
#if SOC_PM_CPU_RETENTION_BY_SW && ESP_SLEEP_POWER_DOWN_CPU
10641050
esp_sleep_execute_event_callbacks(SLEEP_EVENT_HW_GOTO_SLEEP, (void *)0);

0 commit comments

Comments
 (0)