Skip to content

Commit 5899701

Browse files
committed
feat(esp_pm): fix esp32p4 cpu powerdown kconfig dependency error
1 parent 4ec0065 commit 5899701

File tree

15 files changed

+46
-38
lines changed

15 files changed

+46
-38
lines changed

components/esp_hw_support/include/esp_private/sleep_cpu.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <stdbool.h>
1010
#include "sdkconfig.h"
1111
#include "esp_err.h"
12+
#include "esp_sleep.h"
1213
#include "soc/soc_caps.h"
1314

1415
#ifdef __cplusplus
@@ -21,7 +22,7 @@ extern "C" {
2122
* This file contains declarations of cpu retention related functions in light sleep mode.
2223
*/
2324

24-
#if CONFIG_PM_POWER_DOWN_CPU_IN_LIGHT_SLEEP || SOC_PM_SUPPORT_CPU_PD
25+
#if ESP_SLEEP_POWER_DOWN_CPU || SOC_PM_SUPPORT_CPU_PD
2526
/**
2627
* @brief Whether to allow the cpu power domain to be powered off.
2728
*
@@ -31,7 +32,7 @@ extern "C" {
3132
bool cpu_domain_pd_allowed(void);
3233
#endif
3334

34-
#if CONFIG_PM_POWER_DOWN_CPU_IN_LIGHT_SLEEP
35+
#if ESP_SLEEP_POWER_DOWN_CPU
3536
/**
3637
* @brief Configure the parameters of the CPU domain during the sleep process
3738
*
@@ -64,9 +65,9 @@ void sleep_disable_cpu_retention(void);
6465
esp_err_t esp_sleep_cpu_retention(uint32_t (*goto_sleep)(uint32_t, uint32_t, uint32_t, bool),
6566
uint32_t wakeup_opt, uint32_t reject_opt, uint32_t lslp_mem_inf_fpu, bool dslp);
6667
#endif // SOC_PM_CPU_RETENTION_BY_SW
67-
#endif // CONFIG_PM_POWER_DOWN_CPU_IN_LIGHT_SLEEP
68+
#endif // ESP_SLEEP_POWER_DOWN_CPU
6869

69-
#if !CONFIG_FREERTOS_UNICORE && CONFIG_PM_POWER_DOWN_CPU_IN_LIGHT_SLEEP
70+
#if !CONFIG_FREERTOS_UNICORE && ESP_SLEEP_POWER_DOWN_CPU
7071
/**
7172
* Do sleep prepare for other smp cores
7273
*/
@@ -77,13 +78,11 @@ void sleep_smp_cpu_sleep_prepare(void);
7778
*/
7879
void sleep_smp_cpu_wakeup_prepare(void);
7980

80-
#if CONFIG_PM_POWER_DOWN_CPU_IN_LIGHT_SLEEP
8181
/**
8282
* Notify the other core that this sleep does not require retention.
8383
*/
8484
void esp_sleep_cpu_skip_retention(void);
85-
#endif // CONFIG_PM_POWER_DOWN_CPU_IN_LIGHT_SLEEP
86-
#endif // !CONFIG_FREERTOS_UNICORE && CONFIG_PM_POWER_DOWN_CPU_IN_LIGHT_SLEEP
85+
#endif // !CONFIG_FREERTOS_UNICORE && ESP_SLEEP_POWER_DOWN_CPU
8786

8887
#ifdef __cplusplus
8988
}

components/esp_hw_support/include/esp_sleep.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -133,6 +133,8 @@ enum {
133133
ESP_ERR_SLEEP_TOO_SHORT_SLEEP_DURATION = ESP_ERR_INVALID_ARG,
134134
};
135135

136+
#define ESP_SLEEP_POWER_DOWN_CPU (CONFIG_PM_POWER_DOWN_CPU_IN_LIGHT_SLEEP || (SOC_CPU_IN_TOP_DOMAIN && CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP))
137+
136138
/**
137139
* @brief Disable wakeup source
138140
*
@@ -713,7 +715,7 @@ void esp_default_wake_deep_sleep(void);
713715
*/
714716
void esp_deep_sleep_disable_rom_logging(void);
715717

716-
#if CONFIG_PM_POWER_DOWN_CPU_IN_LIGHT_SLEEP
718+
#if ESP_SLEEP_POWER_DOWN_CPU
717719

718720
#if SOC_PM_CPU_RETENTION_BY_RTCCNTL
719721
/**
@@ -752,7 +754,7 @@ esp_err_t esp_sleep_cpu_retention_init(void);
752754
* Release system retention memory.
753755
*/
754756
esp_err_t esp_sleep_cpu_retention_deinit(void);
755-
#endif // CONFIG_PM_POWER_DOWN_CPU_IN_LIGHT_SLEEP
757+
#endif // ESP_SLEEP_POWER_DOWN_CPU
756758

757759
/**
758760
* @brief Configure to isolate all GPIO pins in sleep state

components/esp_hw_support/lowpower/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ endif()
44

55
set(srcs)
66

7-
if(CONFIG_PM_POWER_DOWN_CPU_IN_LIGHT_SLEEP)
7+
if(CONFIG_PM_POWER_DOWN_CPU_IN_LIGHT_SLEEP OR
8+
(CONFIG_SOC_CPU_IN_TOP_DOMAIN AND CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP))
89
list(APPEND srcs "cpu_retention/port/${target}/sleep_cpu.c")
910
if(CONFIG_SOC_PM_CPU_RETENTION_BY_SW)
1011
list(APPEND srcs "cpu_retention/port/${target}/sleep_cpu_asm.S")

components/esp_hw_support/lowpower/cpu_retention/port/esp32c3/sleep_cpu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ bool cpu_domain_pd_allowed(void)
102102

103103
esp_err_t sleep_cpu_configure(bool light_sleep_enable)
104104
{
105-
#if CONFIG_PM_POWER_DOWN_CPU_IN_LIGHT_SLEEP
105+
#if ESP_SLEEP_POWER_DOWN_CPU
106106
if (light_sleep_enable) {
107107
ESP_RETURN_ON_ERROR(esp_sleep_cpu_retention_init(), TAG, "Failed to enable CPU power down during light sleep.");
108108
} else {

components/esp_hw_support/lowpower/cpu_retention/port/esp32c5/sleep_cpu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ bool cpu_domain_pd_allowed(void)
489489

490490
esp_err_t sleep_cpu_configure(bool light_sleep_enable)
491491
{
492-
#if CONFIG_PM_POWER_DOWN_CPU_IN_LIGHT_SLEEP
492+
#if ESP_SLEEP_POWER_DOWN_CPU
493493
if (light_sleep_enable) {
494494
ESP_RETURN_ON_ERROR(esp_sleep_cpu_retention_init(), TAG, "Failed to enable CPU power down during light sleep.");
495495
} else {

components/esp_hw_support/lowpower/cpu_retention/port/esp32c6/sleep_cpu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ bool cpu_domain_pd_allowed(void)
532532

533533
esp_err_t sleep_cpu_configure(bool light_sleep_enable)
534534
{
535-
#if CONFIG_PM_POWER_DOWN_CPU_IN_LIGHT_SLEEP
535+
#if ESP_SLEEP_POWER_DOWN_CPU
536536
if (light_sleep_enable) {
537537
ESP_RETURN_ON_ERROR(esp_sleep_cpu_retention_init(), TAG, "Failed to enable CPU power down during light sleep.");
538538
} else {

components/esp_hw_support/lowpower/cpu_retention/port/esp32h2/sleep_cpu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ bool cpu_domain_pd_allowed(void)
532532

533533
esp_err_t sleep_cpu_configure(bool light_sleep_enable)
534534
{
535-
#if CONFIG_PM_POWER_DOWN_CPU_IN_LIGHT_SLEEP
535+
#if ESP_SLEEP_POWER_DOWN_CPU
536536
if (light_sleep_enable) {
537537
ESP_RETURN_ON_ERROR(esp_sleep_cpu_retention_init(), TAG, "Failed to enable CPU power down during light sleep.");
538538
} else {

components/esp_hw_support/lowpower/cpu_retention/port/esp32p4/sleep_cpu.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
#endif
4242

4343

44-
#if CONFIG_PM_POWER_DOWN_CPU_IN_LIGHT_SLEEP && !CONFIG_FREERTOS_UNICORE
44+
#if ESP_SLEEP_POWER_DOWN_CPU && !CONFIG_FREERTOS_UNICORE
4545
#include <stdatomic.h>
4646
#include "soc/hp_system_reg.h"
4747
typedef enum {
@@ -162,7 +162,7 @@ static esp_err_t esp_sleep_cpu_retention_init_impl(void)
162162
s_cpu_retention.retent.clic_frame[core_id] = (cpu_domain_dev_sleep_frame_t *)frame;
163163
}
164164
}
165-
#if CONFIG_PM_POWER_DOWN_CPU_IN_LIGHT_SLEEP && !CONFIG_FREERTOS_UNICORE
165+
#if ESP_SLEEP_POWER_DOWN_CPU && !CONFIG_FREERTOS_UNICORE
166166
for (uint8_t core_id = 0; core_id < portNUM_PROCESSORS; ++core_id) {
167167
atomic_init(&s_smp_retention_state[core_id], SMP_IDLE);
168168
}
@@ -414,7 +414,7 @@ static IRAM_ATTR esp_err_t do_cpu_retention(sleep_cpu_entry_cb_t goto_sleep,
414414
#endif
415415
REG_WRITE(RTC_SLEEP_WAKE_STUB_ADDR_REG, (uint32_t)rv_core_critical_regs_restore);
416416

417-
#if CONFIG_PM_POWER_DOWN_CPU_IN_LIGHT_SLEEP && !CONFIG_FREERTOS_UNICORE
417+
#if ESP_SLEEP_POWER_DOWN_CPU && !CONFIG_FREERTOS_UNICORE
418418
atomic_store(&s_smp_retention_state[core_id], SMP_BACKUP_DONE);
419419
while (atomic_load(&s_smp_retention_state[!core_id]) != SMP_BACKUP_DONE) {
420420
;
@@ -438,7 +438,7 @@ esp_err_t IRAM_ATTR esp_sleep_cpu_retention(uint32_t (*goto_sleep)(uint32_t, uin
438438
esp_sleep_execute_event_callbacks(SLEEP_EVENT_SW_CPU_TO_MEM_START, (void *)0);
439439
uint32_t mstatus = save_mstatus_and_disable_global_int();
440440
uint8_t core_id = esp_cpu_get_core_id();
441-
#if CONFIG_PM_POWER_DOWN_CPU_IN_LIGHT_SLEEP && !CONFIG_FREERTOS_UNICORE
441+
#if ESP_SLEEP_POWER_DOWN_CPU && !CONFIG_FREERTOS_UNICORE
442442
atomic_store(&s_smp_retention_state[core_id], SMP_BACKUP_START);
443443
#endif
444444
cpu_domain_dev_regs_save(s_cpu_retention.retent.clic_frame[core_id]);
@@ -457,7 +457,7 @@ esp_err_t IRAM_ATTR esp_sleep_cpu_retention(uint32_t (*goto_sleep)(uint32_t, uin
457457
validate_retention_frame_crc((uint32_t*)frame, sizeof(RvCoreNonCriticalSleepFrame) - sizeof(long), (uint32_t *)(&frame->frame_crc));
458458
#endif
459459

460-
#if CONFIG_PM_POWER_DOWN_CPU_IN_LIGHT_SLEEP && !CONFIG_FREERTOS_UNICORE
460+
#if ESP_SLEEP_POWER_DOWN_CPU && !CONFIG_FREERTOS_UNICORE
461461
// Start core1
462462
if (core_id == 0) {
463463
REG_SET_BIT(HP_SYS_CLKRST_SOC_CLK_CTRL0_REG, HP_SYS_CLKRST_REG_CORE1_CPU_CLK_EN);
@@ -472,7 +472,7 @@ esp_err_t IRAM_ATTR esp_sleep_cpu_retention(uint32_t (*goto_sleep)(uint32_t, uin
472472
cpu_domain_dev_regs_restore(s_cpu_retention.retent.clic_frame[core_id]);
473473
restore_mstatus(mstatus);
474474

475-
#if CONFIG_PM_POWER_DOWN_CPU_IN_LIGHT_SLEEP && !CONFIG_FREERTOS_UNICORE
475+
#if ESP_SLEEP_POWER_DOWN_CPU && !CONFIG_FREERTOS_UNICORE
476476
atomic_store(&s_smp_retention_state[core_id], SMP_RESTORE_DONE);
477477
#endif
478478
return err;
@@ -504,7 +504,7 @@ bool cpu_domain_pd_allowed(void)
504504

505505
esp_err_t sleep_cpu_configure(bool light_sleep_enable)
506506
{
507-
#if CONFIG_PM_POWER_DOWN_CPU_IN_LIGHT_SLEEP
507+
#if ESP_SLEEP_POWER_DOWN_CPU
508508
if (light_sleep_enable) {
509509
ESP_RETURN_ON_ERROR(esp_sleep_cpu_retention_init(), TAG, "Failed to enable CPU power down during light sleep.");
510510
} else {
@@ -515,7 +515,7 @@ esp_err_t sleep_cpu_configure(bool light_sleep_enable)
515515
}
516516

517517
#if !CONFIG_FREERTOS_UNICORE
518-
#if CONFIG_PM_POWER_DOWN_CPU_IN_LIGHT_SLEEP
518+
#if ESP_SLEEP_POWER_DOWN_CPU
519519
static TCM_IRAM_ATTR void smp_core_do_retention(void)
520520
{
521521
uint8_t core_id = esp_cpu_get_core_id();
@@ -579,7 +579,7 @@ IRAM_ATTR void esp_sleep_cpu_skip_retention(void) {
579579

580580
void sleep_smp_cpu_sleep_prepare(void)
581581
{
582-
#if CONFIG_PM_POWER_DOWN_CPU_IN_LIGHT_SLEEP
582+
#if ESP_SLEEP_POWER_DOWN_CPU
583583
while (atomic_load(&s_smp_retention_state[!esp_cpu_get_core_id()]) != SMP_IDLE) {
584584
;
585585
}
@@ -591,7 +591,7 @@ void sleep_smp_cpu_sleep_prepare(void)
591591

592592
void sleep_smp_cpu_wakeup_prepare(void)
593593
{
594-
#if CONFIG_PM_POWER_DOWN_CPU_IN_LIGHT_SLEEP
594+
#if ESP_SLEEP_POWER_DOWN_CPU
595595
uint8_t core_id = esp_cpu_get_core_id();
596596
if (atomic_load(&s_smp_retention_state[core_id]) == SMP_RESTORE_DONE) {
597597
while (atomic_load(&s_smp_retention_state[!core_id]) != SMP_RESTORE_DONE) {

components/esp_hw_support/lowpower/cpu_retention/port/esp32s3/sleep_cpu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ bool cpu_domain_pd_allowed(void)
232232

233233
esp_err_t sleep_cpu_configure(bool light_sleep_enable)
234234
{
235-
#if CONFIG_PM_POWER_DOWN_CPU_IN_LIGHT_SLEEP
235+
#if ESP_SLEEP_POWER_DOWN_CPU
236236
if (light_sleep_enable) {
237237
ESP_RETURN_ON_ERROR(esp_sleep_cpu_retention_init(), TAG, "Failed to enable CPU power down during light sleep.");
238238
} else {

components/esp_hw_support/sleep_modes.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,7 @@ static esp_err_t IRAM_ATTR esp_sleep_start(uint32_t pd_flags, esp_sleep_mode_t m
878878

879879
if (should_skip_sleep) {
880880
result = ESP_ERR_SLEEP_REJECT;
881-
#if CONFIG_PM_POWER_DOWN_CPU_IN_LIGHT_SLEEP && !CONFIG_FREERTOS_UNICORE && SOC_PM_CPU_RETENTION_BY_SW
881+
#if ESP_SLEEP_POWER_DOWN_CPU && !CONFIG_FREERTOS_UNICORE && SOC_PM_CPU_RETENTION_BY_SW
882882
esp_sleep_cpu_skip_retention();
883883
#endif
884884
} else {
@@ -942,14 +942,14 @@ static esp_err_t IRAM_ATTR esp_sleep_start(uint32_t pd_flags, esp_sleep_mode_t m
942942
#endif
943943

944944
#if SOC_PMU_SUPPORTED
945-
#if SOC_PM_CPU_RETENTION_BY_SW && CONFIG_PM_POWER_DOWN_CPU_IN_LIGHT_SLEEP
945+
#if SOC_PM_CPU_RETENTION_BY_SW && ESP_SLEEP_POWER_DOWN_CPU
946946
esp_sleep_execute_event_callbacks(SLEEP_EVENT_HW_GOTO_SLEEP, (void *)0);
947947
if (pd_flags & (PMU_SLEEP_PD_CPU | PMU_SLEEP_PD_TOP)) {
948948
result = esp_sleep_cpu_retention(pmu_sleep_start, s_config.wakeup_triggers, reject_triggers, config.power.hp_sys.dig_power.mem_dslp, deep_sleep);
949949
} else
950950
#endif
951951
{
952-
#if !CONFIG_FREERTOS_UNICORE && CONFIG_PM_POWER_DOWN_CPU_IN_LIGHT_SLEEP && SOC_PM_CPU_RETENTION_BY_SW
952+
#if !CONFIG_FREERTOS_UNICORE && ESP_SLEEP_POWER_DOWN_CPU && SOC_PM_CPU_RETENTION_BY_SW
953953
// Skip smp retention if CPU power domain power-down is not allowed
954954
esp_sleep_cpu_skip_retention();
955955
#endif
@@ -1256,7 +1256,7 @@ esp_err_t esp_light_sleep_start(void)
12561256
#endif
12571257

12581258
#if !CONFIG_FREERTOS_UNICORE
1259-
#if CONFIG_PM_POWER_DOWN_CPU_IN_LIGHT_SLEEP && SOC_PM_CPU_RETENTION_BY_SW
1259+
#if ESP_SLEEP_POWER_DOWN_CPU && SOC_PM_CPU_RETENTION_BY_SW
12601260
sleep_smp_cpu_sleep_prepare();
12611261
#else
12621262
esp_ipc_isr_stall_other_cpu();
@@ -1374,7 +1374,7 @@ esp_err_t esp_light_sleep_start(void)
13741374
// Enter sleep, then wait for flash to be ready on wakeup
13751375
err = esp_light_sleep_inner(pd_flags, flash_enable_time_us);
13761376
}
1377-
#if !CONFIG_FREERTOS_UNICORE && CONFIG_PM_POWER_DOWN_CPU_IN_LIGHT_SLEEP && SOC_PM_CPU_RETENTION_BY_SW
1377+
#if !CONFIG_FREERTOS_UNICORE && ESP_SLEEP_POWER_DOWN_CPU && SOC_PM_CPU_RETENTION_BY_SW
13781378
if (err != ESP_OK) {
13791379
esp_sleep_cpu_skip_retention();
13801380
}
@@ -1412,7 +1412,7 @@ esp_err_t esp_light_sleep_start(void)
14121412

14131413
#if !CONFIG_FREERTOS_UNICORE
14141414
esp_ipc_isr_stall_resume();
1415-
#if CONFIG_PM_POWER_DOWN_CPU_IN_LIGHT_SLEEP && SOC_PM_CPU_RETENTION_BY_SW
1415+
#if ESP_SLEEP_POWER_DOWN_CPU && SOC_PM_CPU_RETENTION_BY_SW
14161416
sleep_smp_cpu_wakeup_prepare();
14171417
#else
14181418
esp_ipc_isr_release_other_cpu();
@@ -2063,7 +2063,7 @@ esp_err_t esp_sleep_pd_config(esp_sleep_pd_domain_t domain, esp_sleep_pd_option_
20632063
#if SOC_PM_SUPPORT_TOP_PD
20642064
FORCE_INLINE_ATTR bool top_domain_pd_allowed(void) {
20652065
bool top_pd_allowed = true;
2066-
#if CONFIG_PM_POWER_DOWN_CPU_IN_LIGHT_SLEEP
2066+
#if ESP_SLEEP_POWER_DOWN_CPU
20672067
top_pd_allowed &= cpu_domain_pd_allowed();
20682068
#else
20692069
top_pd_allowed = false;
@@ -2179,7 +2179,7 @@ static uint32_t get_power_down_flags(void)
21792179
}
21802180
#endif
21812181

2182-
#if SOC_PM_SUPPORT_CPU_PD
2182+
#if SOC_PM_SUPPORT_CPU_PD && ESP_SLEEP_POWER_DOWN_CPU
21832183
if ((s_config.domain[ESP_PD_DOMAIN_CPU].pd_option != ESP_PD_OPTION_ON) && cpu_domain_pd_allowed()) {
21842184
pd_flags |= RTC_SLEEP_PD_CPU;
21852185
}

0 commit comments

Comments
 (0)