From 065dd70056012afe9e26b34f9e013f16a1de1c90 Mon Sep 17 00:00:00 2001 From: wuzhenghui Date: Tue, 14 Oct 2025 11:03:42 +0800 Subject: [PATCH] change(esp_hw_support): move ESP_SLEEP_POWER_DOWN_CPU to Kconfig --- .../legacy_twai/main/test_twai_loop_back.cpp | 4 ++-- .../gptimer/main/test_gptimer_sleep.c | 10 +++++----- .../main/test_i2c_sleep_retention.cpp | 8 ++++---- .../test_apps/i2s/main/test_i2s_sleep.c | 4 ++-- .../test_apps/ledc/main/test_ledc_sleep.cpp | 4 ++-- .../test_apps/mcpwm/main/test_mcpwm_sleep.c | 10 +++++----- .../test_apps/parlio/main/test_parlio_sleep.c | 4 ++-- .../pulse_cnt/main/test_pulse_cnt_sleep.c | 4 ++-- .../test_apps/rmt/main/test_rmt_sleep.c | 4 ++-- .../sigma_delta/main/test_sdm_sleep.cpp | 4 ++-- .../test_apps/master/main/test_spi_master.c | 4 ++-- .../master/main/test_spi_master_sct.c | 4 ++-- .../test_apps/slave/main/test_spi_slave.c | 4 ++-- .../slave_hd/main/test_spi_slave_hd.c | 8 ++++---- .../main/test_temperature_sensor.cpp | 4 ++-- .../main/test_emac_sleep_retention.c | 6 +++--- .../include/esp_private/sleep_cpu.h | 12 +++++------ components/esp_hw_support/include/esp_sleep.h | 10 ++-------- .../lowpower/port/esp32c3/sleep_cpu.c | 2 +- .../lowpower/port/esp32c5/sleep_cpu.c | 2 +- .../lowpower/port/esp32c6/sleep_cpu.c | 2 +- .../lowpower/port/esp32c61/sleep_cpu.c | 2 +- .../lowpower/port/esp32h2/sleep_cpu.c | 2 +- .../lowpower/port/esp32h21/sleep_cpu.c | 2 +- .../lowpower/port/esp32h4/sleep_cpu.c | 20 +++++++++---------- .../lowpower/port/esp32h4/sleep_cpu_dynamic.c | 2 +- .../port/esp32h4/sleep_cpu_retention.h | 4 ++-- .../lowpower/port/esp32h4/sleep_cpu_static.c | 2 +- .../lowpower/port/esp32p4/sleep_cpu.c | 20 +++++++++---------- .../lowpower/port/esp32p4/sleep_cpu_dynamic.c | 2 +- .../port/esp32p4/sleep_cpu_retention.h | 4 ++-- .../lowpower/port/esp32p4/sleep_cpu_static.c | 2 +- .../lowpower/port/esp32s3/sleep_cpu.c | 2 +- components/esp_hw_support/sleep_modes.c | 16 +++++++-------- components/esp_pm/Kconfig | 5 +++++ components/esp_pm/pm_impl.c | 2 +- 36 files changed, 100 insertions(+), 101 deletions(-) diff --git a/components/driver/test_apps/legacy_twai/main/test_twai_loop_back.cpp b/components/driver/test_apps/legacy_twai/main/test_twai_loop_back.cpp index b4192e5f3b..4a80486bdb 100644 --- a/components/driver/test_apps/legacy_twai/main/test_twai_loop_back.cpp +++ b/components/driver/test_apps/legacy_twai/main/test_twai_loop_back.cpp @@ -143,7 +143,7 @@ static void s_test_sleep_retention(bool allow_pd) { // Prepare a TOP PD sleep TEST_ESP_OK(esp_sleep_enable_timer_wakeup(1 * 1000 * 1000)); -#if ESP_SLEEP_POWER_DOWN_CPU +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU TEST_ESP_OK(sleep_cpu_configure(true)); #endif esp_sleep_context_t sleep_ctx; @@ -209,7 +209,7 @@ static void s_test_sleep_retention(bool allow_pd) } esp_sleep_set_sleep_context(NULL); -#if ESP_SLEEP_POWER_DOWN_CPU +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU TEST_ESP_OK(sleep_cpu_configure(false)); #endif } diff --git a/components/esp_driver_gptimer/test_apps/gptimer/main/test_gptimer_sleep.c b/components/esp_driver_gptimer/test_apps/gptimer/main/test_gptimer_sleep.c index 4ca9b36742..1a4a4b4b7d 100644 --- a/components/esp_driver_gptimer/test_apps/gptimer/main/test_gptimer_sleep.c +++ b/components/esp_driver_gptimer/test_apps/gptimer/main/test_gptimer_sleep.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -72,14 +72,14 @@ static void test_gptimer_sleep_retention(bool allow_pd) esp_sleep_context_t sleep_ctx; esp_sleep_set_sleep_context(&sleep_ctx); printf("go to light sleep for 2 seconds\r\n"); -#if ESP_SLEEP_POWER_DOWN_CPU +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU TEST_ESP_OK(sleep_cpu_configure(true)); #endif TEST_ESP_OK(esp_sleep_enable_timer_wakeup(2 * 1000 * 1000)); TEST_ESP_OK(esp_light_sleep_start()); printf("Waked up! Let's see if GPTimer driver can still work...\r\n"); -#if ESP_SLEEP_POWER_DOWN_CPU +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU TEST_ESP_OK(sleep_cpu_configure(false)); #endif @@ -189,14 +189,14 @@ static void test_gptimer_etm_sleep_retention(bool back_up_before_sleep) esp_sleep_context_t sleep_ctx; esp_sleep_set_sleep_context(&sleep_ctx); printf("go to light sleep for 2 seconds\r\n"); -#if ESP_SLEEP_POWER_DOWN_CPU +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU TEST_ESP_OK(sleep_cpu_configure(true)); #endif TEST_ESP_OK(esp_sleep_enable_timer_wakeup(2 * 1000 * 1000)); TEST_ESP_OK(esp_light_sleep_start()); printf("Waked up! Let's see if GPTimer and ETM can still work...\r\n"); -#if ESP_SLEEP_POWER_DOWN_CPU +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU TEST_ESP_OK(sleep_cpu_configure(false)); #endif diff --git a/components/esp_driver_i2c/test_apps/i2c_test_apps/main/test_i2c_sleep_retention.cpp b/components/esp_driver_i2c/test_apps/i2c_test_apps/main/test_i2c_sleep_retention.cpp index ced9c6fc65..b198e13e1f 100644 --- a/components/esp_driver_i2c/test_apps/i2c_test_apps/main/test_i2c_sleep_retention.cpp +++ b/components/esp_driver_i2c/test_apps/i2c_test_apps/main/test_i2c_sleep_retention.cpp @@ -81,7 +81,7 @@ static void i2c_master_write_sleep_retention_test(void) TEST_ESP_OK(i2c_master_transmit(dev_handle, data_wr, DATA_LENGTH, -1)); unity_wait_for_signal("i2c slave receive once, master to sleep"); -#if ESP_SLEEP_POWER_DOWN_CPU +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU TEST_ESP_OK(sleep_cpu_configure(true)); #endif TEST_ESP_OK(esp_sleep_enable_timer_wakeup(3 * 1000 * 1000)); @@ -99,7 +99,7 @@ static void i2c_master_write_sleep_retention_test(void) unity_send_signal("master write again"); unity_wait_for_signal("ready to delete"); -#if ESP_SLEEP_POWER_DOWN_CPU +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU TEST_ESP_OK(sleep_cpu_configure(false)); #endif TEST_ESP_OK(i2c_master_bus_rm_device(dev_handle)); @@ -149,7 +149,7 @@ static void i2c_slave_read_sleep_retention_test(void) unity_send_signal("i2c slave receive once, master to sleep"); // Slave sleep as well.. -#if ESP_SLEEP_POWER_DOWN_CPU +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU TEST_ESP_OK(sleep_cpu_configure(true)); #endif TEST_ESP_OK(esp_sleep_enable_timer_wakeup(1 * 1000 * 1000)); @@ -173,7 +173,7 @@ static void i2c_slave_read_sleep_retention_test(void) vQueueDelete(event_queue); unity_send_signal("ready to delete"); -#if ESP_SLEEP_POWER_DOWN_CPU +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU TEST_ESP_OK(sleep_cpu_configure(false)); #endif TEST_ESP_OK(i2c_del_slave_device(slave_handle)); diff --git a/components/esp_driver_i2s/test_apps/i2s/main/test_i2s_sleep.c b/components/esp_driver_i2s/test_apps/i2s/main/test_i2s_sleep.c index 0424a7c6d7..ac5792ce00 100644 --- a/components/esp_driver_i2s/test_apps/i2s/main/test_i2s_sleep.c +++ b/components/esp_driver_i2s/test_apps/i2s/main/test_i2s_sleep.c @@ -29,7 +29,7 @@ static void s_test_i2s_enter_light_sleep(int sec, bool allow_power_down) esp_sleep_context_t sleep_ctx; esp_sleep_set_sleep_context(&sleep_ctx); printf("Entering light sleep for %d seconds\n", sec); -#if ESP_SLEEP_POWER_DOWN_CPU +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU printf("Enable CPU power down\n"); TEST_ESP_OK(sleep_cpu_configure(true)); #endif @@ -37,7 +37,7 @@ static void s_test_i2s_enter_light_sleep(int sec, bool allow_power_down) TEST_ESP_OK(esp_sleep_enable_timer_wakeup(sec * 1000 * 1000)); TEST_ESP_OK(esp_light_sleep_start()); -#if ESP_SLEEP_POWER_DOWN_CPU +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU TEST_ESP_OK(sleep_cpu_configure(false)); #endif printf("Woke up from light sleep\n"); diff --git a/components/esp_driver_ledc/test_apps/ledc/main/test_ledc_sleep.cpp b/components/esp_driver_ledc/test_apps/ledc/main/test_ledc_sleep.cpp index 0ed3f50927..1a3ea5c882 100644 --- a/components/esp_driver_ledc/test_apps/ledc/main/test_ledc_sleep.cpp +++ b/components/esp_driver_ledc/test_apps/ledc/main/test_ledc_sleep.cpp @@ -44,7 +44,7 @@ static void test_ledc_sleep_retention(bool allow_pd) esp_sleep_context_t sleep_ctx; esp_sleep_set_sleep_context(&sleep_ctx); -#if ESP_SLEEP_POWER_DOWN_CPU +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU TEST_ESP_OK(sleep_cpu_configure(true)); #endif TEST_ESP_OK(esp_sleep_enable_timer_wakeup(2 * 1000 * 1000)); @@ -53,7 +53,7 @@ static void test_ledc_sleep_retention(bool allow_pd) TEST_ESP_OK(esp_light_sleep_start()); printf("Waked up! Let's see if LEDC peripheral can still work...\n"); -#if ESP_SLEEP_POWER_DOWN_CPU +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU TEST_ESP_OK(sleep_cpu_configure(false)); #endif diff --git a/components/esp_driver_mcpwm/test_apps/mcpwm/main/test_mcpwm_sleep.c b/components/esp_driver_mcpwm/test_apps/mcpwm/main/test_mcpwm_sleep.c index eb3d30ebb6..7e73f88854 100644 --- a/components/esp_driver_mcpwm/test_apps/mcpwm/main/test_mcpwm_sleep.c +++ b/components/esp_driver_mcpwm/test_apps/mcpwm/main/test_mcpwm_sleep.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -71,14 +71,14 @@ static void test_mcpwm_timer_sleep_retention(bool allow_pd) esp_sleep_context_t sleep_ctx; esp_sleep_set_sleep_context(&sleep_ctx); printf("go to light sleep for 1 seconds\r\n"); -#if ESP_SLEEP_POWER_DOWN_CPU +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU TEST_ESP_OK(sleep_cpu_configure(true)); #endif TEST_ESP_OK(esp_sleep_enable_timer_wakeup(1 * 1000 * 1000)); TEST_ESP_OK(esp_light_sleep_start()); printf("Waked up! Let's see if MCPWM driver can still work...\r\n"); -#if ESP_SLEEP_POWER_DOWN_CPU +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU TEST_ESP_OK(sleep_cpu_configure(false)); #endif @@ -176,14 +176,14 @@ static void test_mcpwm_capture_timer_sleep_retention(bool allow_pd) esp_sleep_context_t sleep_ctx; esp_sleep_set_sleep_context(&sleep_ctx); printf("go to light sleep for 1 seconds\r\n"); -#if ESP_SLEEP_POWER_DOWN_CPU +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU TEST_ESP_OK(sleep_cpu_configure(true)); #endif TEST_ESP_OK(esp_sleep_enable_timer_wakeup(1 * 1000 * 1000)); TEST_ESP_OK(esp_light_sleep_start()); printf("Waked up! Let's see if MCPWM driver can still work...\r\n"); -#if ESP_SLEEP_POWER_DOWN_CPU +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU TEST_ESP_OK(sleep_cpu_configure(false)); #endif diff --git a/components/esp_driver_parlio/test_apps/parlio/main/test_parlio_sleep.c b/components/esp_driver_parlio/test_apps/parlio/main/test_parlio_sleep.c index 8fc99cd40a..5631fa7076 100644 --- a/components/esp_driver_parlio/test_apps/parlio/main/test_parlio_sleep.c +++ b/components/esp_driver_parlio/test_apps/parlio/main/test_parlio_sleep.c @@ -120,14 +120,14 @@ static void test_parlio_sleep_retention(bool allow_pd) esp_sleep_context_t sleep_ctx; esp_sleep_set_sleep_context(&sleep_ctx); printf("go to light sleep for 2 seconds\r\n"); -#if ESP_SLEEP_POWER_DOWN_CPU +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU TEST_ESP_OK(sleep_cpu_configure(true)); #endif TEST_ESP_OK(esp_sleep_enable_timer_wakeup(2 * 1000 * 1000)); TEST_ESP_OK(esp_light_sleep_start()); printf("Waked up! Let's see if PARLIO driver can still work...\r\n"); -#if ESP_SLEEP_POWER_DOWN_CPU +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU TEST_ESP_OK(sleep_cpu_configure(false)); #endif diff --git a/components/esp_driver_pcnt/test_apps/pulse_cnt/main/test_pulse_cnt_sleep.c b/components/esp_driver_pcnt/test_apps/pulse_cnt/main/test_pulse_cnt_sleep.c index e6347a1cb8..2dc2d33478 100644 --- a/components/esp_driver_pcnt/test_apps/pulse_cnt/main/test_pulse_cnt_sleep.c +++ b/components/esp_driver_pcnt/test_apps/pulse_cnt/main/test_pulse_cnt_sleep.c @@ -85,14 +85,14 @@ static void test_pcnt_sleep_retention(void) esp_sleep_context_t sleep_ctx; esp_sleep_set_sleep_context(&sleep_ctx); printf("go to light sleep for 1 seconds\r\n"); -#if ESP_SLEEP_POWER_DOWN_CPU +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU TEST_ESP_OK(sleep_cpu_configure(true)); #endif TEST_ESP_OK(esp_sleep_enable_timer_wakeup(1 * 1000 * 1000)); TEST_ESP_OK(esp_light_sleep_start()); printf("Waked up! Let's see if PCNT driver can still work...\r\n"); -#if ESP_SLEEP_POWER_DOWN_CPU +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU TEST_ESP_OK(sleep_cpu_configure(false)); #endif diff --git a/components/esp_driver_rmt/test_apps/rmt/main/test_rmt_sleep.c b/components/esp_driver_rmt/test_apps/rmt/main/test_rmt_sleep.c index f53f4db335..cdcdd4dcd4 100644 --- a/components/esp_driver_rmt/test_apps/rmt/main/test_rmt_sleep.c +++ b/components/esp_driver_rmt/test_apps/rmt/main/test_rmt_sleep.c @@ -94,14 +94,14 @@ static void test_rmt_tx_rx_sleep_retention(bool allow_pd) esp_sleep_context_t sleep_ctx; esp_sleep_set_sleep_context(&sleep_ctx); printf("go to light sleep for 2 seconds\r\n"); -#if ESP_SLEEP_POWER_DOWN_CPU +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU TEST_ESP_OK(sleep_cpu_configure(true)); #endif TEST_ESP_OK(esp_sleep_enable_timer_wakeup(2 * 1000 * 1000)); TEST_ESP_OK(esp_light_sleep_start()); printf("Waked up! Let's see if RMT driver can still work...\r\n"); -#if ESP_SLEEP_POWER_DOWN_CPU +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU TEST_ESP_OK(sleep_cpu_configure(false)); #endif diff --git a/components/esp_driver_sdm/test_apps/sigma_delta/main/test_sdm_sleep.cpp b/components/esp_driver_sdm/test_apps/sigma_delta/main/test_sdm_sleep.cpp index e08b6e5549..1bb2b8fa18 100644 --- a/components/esp_driver_sdm/test_apps/sigma_delta/main/test_sdm_sleep.cpp +++ b/components/esp_driver_sdm/test_apps/sigma_delta/main/test_sdm_sleep.cpp @@ -51,14 +51,14 @@ static void test_sdm_sleep_retention(bool allow_pd) esp_sleep_context_t sleep_ctx; esp_sleep_set_sleep_context(&sleep_ctx); printf("go to light sleep for 2 seconds\r\n"); -#if ESP_SLEEP_POWER_DOWN_CPU +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU TEST_ESP_OK(sleep_cpu_configure(true)); #endif TEST_ESP_OK(esp_sleep_enable_timer_wakeup(2 * 1000 * 1000)); TEST_ESP_OK(esp_light_sleep_start()); printf("Waked up! Let's see if SDM driver can still work...\r\n"); -#if ESP_SLEEP_POWER_DOWN_CPU +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU TEST_ESP_OK(sleep_cpu_configure(false)); #endif diff --git a/components/esp_driver_spi/test_apps/master/main/test_spi_master.c b/components/esp_driver_spi/test_apps/master/main/test_spi_master.c index 3ff7588c0b..f3a4daedf8 100644 --- a/components/esp_driver_spi/test_apps/master/main/test_spi_master.c +++ b/components/esp_driver_spi/test_apps/master/main/test_spi_master.c @@ -1844,7 +1844,7 @@ TEST_CASE("test_spi_master_sleep_retention", "[spi]") { // Prepare a TOP PD sleep TEST_ESP_OK(esp_sleep_enable_timer_wakeup(1 * 1000 * 1000)); -#if ESP_SLEEP_POWER_DOWN_CPU +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU TEST_ESP_OK(sleep_cpu_configure(true)); #endif esp_sleep_context_t sleep_ctx; @@ -1898,7 +1898,7 @@ TEST_CASE("test_spi_master_sleep_retention", "[spi]") } esp_sleep_set_sleep_context(NULL); -#if ESP_SLEEP_POWER_DOWN_CPU +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU TEST_ESP_OK(sleep_cpu_configure(false)); #endif } diff --git a/components/esp_driver_spi/test_apps/master/main/test_spi_master_sct.c b/components/esp_driver_spi/test_apps/master/main/test_spi_master_sct.c index 63fa435429..f325751eb2 100644 --- a/components/esp_driver_spi/test_apps/master/main/test_spi_master_sct.c +++ b/components/esp_driver_spi/test_apps/master/main/test_spi_master_sct.c @@ -305,7 +305,7 @@ static void sleep_master(void) { // Prepare a TOP PD sleep TEST_ESP_OK(esp_sleep_enable_timer_wakeup(1 * 1000 * 1000)); -#if ESP_SLEEP_POWER_DOWN_CPU +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU sleep_cpu_configure(true); #endif esp_sleep_context_t sleep_ctx; @@ -378,7 +378,7 @@ static void sleep_master(void) TEST_ESP_OK(spi_bus_remove_device(handle)); TEST_ESP_OK(spi_bus_free(SPI2_HOST)); esp_sleep_set_sleep_context(NULL); -#if ESP_SLEEP_POWER_DOWN_CPU +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU TEST_ESP_OK(sleep_cpu_configure(false)); #endif } diff --git a/components/esp_driver_spi/test_apps/slave/main/test_spi_slave.c b/components/esp_driver_spi/test_apps/slave/main/test_spi_slave.c index 21266edd09..1674696771 100644 --- a/components/esp_driver_spi/test_apps/slave/main/test_spi_slave.c +++ b/components/esp_driver_spi/test_apps/slave/main/test_spi_slave.c @@ -657,7 +657,7 @@ TEST_CASE("test_spi_slave_sleep_retention", "[spi]") { // Prepare a TOP PD sleep TEST_ESP_OK(esp_sleep_enable_timer_wakeup(1 * 1000 * 1000)); -#if ESP_SLEEP_POWER_DOWN_CPU +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU sleep_cpu_configure(true); #endif esp_sleep_context_t sleep_ctx; @@ -708,7 +708,7 @@ TEST_CASE("test_spi_slave_sleep_retention", "[spi]") } esp_sleep_set_sleep_context(NULL); -#if ESP_SLEEP_POWER_DOWN_CPU +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU TEST_ESP_OK(sleep_cpu_configure(false)); #endif } diff --git a/components/esp_driver_spi/test_apps/slave_hd/main/test_spi_slave_hd.c b/components/esp_driver_spi/test_apps/slave_hd/main/test_spi_slave_hd.c index 635b4ab984..194ccaf7c8 100644 --- a/components/esp_driver_spi/test_apps/slave_hd/main/test_spi_slave_hd.c +++ b/components/esp_driver_spi/test_apps/slave_hd/main/test_spi_slave_hd.c @@ -930,7 +930,7 @@ TEST_CASE("test_spi_slave_hd_sleep_retention", "[spi]") { // Prepare a TOP PD sleep TEST_ESP_OK(esp_sleep_enable_timer_wakeup(1 * 1000 * 1000)); -#if ESP_SLEEP_POWER_DOWN_CPU +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU sleep_cpu_configure(true); #endif esp_sleep_context_t sleep_ctx; @@ -1002,7 +1002,7 @@ TEST_CASE("test_spi_slave_hd_sleep_retention", "[spi]") } esp_sleep_set_sleep_context(NULL); -#if ESP_SLEEP_POWER_DOWN_CPU +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU TEST_ESP_OK(sleep_cpu_configure(false)); #endif } @@ -1012,7 +1012,7 @@ TEST_CASE("test_spi_slave_hd_append_sleep_retention", "[spi]") { // Prepare a TOP PD sleep TEST_ESP_OK(esp_sleep_enable_timer_wakeup(1 * 1000 * 1000)); -#if ESP_SLEEP_POWER_DOWN_CPU +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU sleep_cpu_configure(true); #endif esp_sleep_context_t sleep_ctx; @@ -1080,7 +1080,7 @@ TEST_CASE("test_spi_slave_hd_append_sleep_retention", "[spi]") } spi_slave_hd_deinit(TEST_SLAVE_HOST); esp_sleep_set_sleep_context(NULL); -#if ESP_SLEEP_POWER_DOWN_CPU +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU TEST_ESP_OK(sleep_cpu_configure(false)); #endif } diff --git a/components/esp_driver_tsens/test_apps/temperature_sensor/main/test_temperature_sensor.cpp b/components/esp_driver_tsens/test_apps/temperature_sensor/main/test_temperature_sensor.cpp index b4b32864a8..49d6f02b4d 100644 --- a/components/esp_driver_tsens/test_apps/temperature_sensor/main/test_temperature_sensor.cpp +++ b/components/esp_driver_tsens/test_apps/temperature_sensor/main/test_temperature_sensor.cpp @@ -176,12 +176,12 @@ static void test_temperature_sensor_sleep_retention(bool allow_pd) esp_sleep_context_t sleep_ctx; esp_sleep_set_sleep_context(&sleep_ctx); -#if ESP_SLEEP_POWER_DOWN_CPU +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU TEST_ESP_OK(sleep_cpu_configure(true)); #endif TEST_ESP_OK(esp_sleep_enable_timer_wakeup(2 * 1000 * 1000)); TEST_ESP_OK(esp_light_sleep_start()); -#if ESP_SLEEP_POWER_DOWN_CPU +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU TEST_ESP_OK(sleep_cpu_configure(false)); #endif printf("check if the sleep happened as expected\r\n"); diff --git a/components/esp_eth/test_apps/main/test_emac_sleep_retention.c b/components/esp_eth/test_apps/main/test_emac_sleep_retention.c index 2743ca3c9e..ed947f5f56 100644 --- a/components/esp_eth/test_apps/main/test_emac_sleep_retention.c +++ b/components/esp_eth/test_apps/main/test_emac_sleep_retention.c @@ -52,7 +52,7 @@ static void eth_test_start_sleep(esp_eth_handle_t eth_handle, bool pd_top_down) esp_sleep_set_sleep_context(&sleep_ctx); // Configure sleep -#if ESP_SLEEP_POWER_DOWN_CPU +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU if (pd_top_down) { printf("Enable CPU power down\n"); TEST_ESP_OK(sleep_cpu_configure(true)); @@ -69,7 +69,7 @@ static void eth_test_start_sleep(esp_eth_handle_t eth_handle, bool pd_top_down) printf("\n ( -.-)Zzz\n\n"); TEST_ESP_OK(esp_light_sleep_start()); printf("\n ( o_o)!\n\n"); -#if ESP_SLEEP_POWER_DOWN_CPU +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU if (pd_top_down) { TEST_ESP_OK(sleep_cpu_configure(false)); } @@ -349,7 +349,7 @@ TEST_CASE("internal emac sleep retention", "[sleep_retention]") ESP_LOGI(TAG, "Testing with PD_TOP powered up"); test_emac_sleep_retention(false); -#if ESP_SLEEP_POWER_DOWN_CPU +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU ESP_LOGI(TAG, "Testing with PD_TOP powered down"); test_emac_sleep_retention(true); #endif diff --git a/components/esp_hw_support/include/esp_private/sleep_cpu.h b/components/esp_hw_support/include/esp_private/sleep_cpu.h index c65d01a619..76bb557910 100644 --- a/components/esp_hw_support/include/esp_private/sleep_cpu.h +++ b/components/esp_hw_support/include/esp_private/sleep_cpu.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -22,7 +22,7 @@ extern "C" { * This file contains declarations of cpu retention related functions in light sleep mode. */ -#if ESP_SLEEP_POWER_DOWN_CPU || (SOC_PM_SUPPORT_CPU_PD && !CONFIG_ESP32P4_SELECTS_REV_LESS_V3) +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU || (SOC_PM_SUPPORT_CPU_PD && !CONFIG_ESP32P4_SELECTS_REV_LESS_V3) /** * @brief Whether to allow the cpu power domain to be powered off. * @@ -32,7 +32,7 @@ extern "C" { bool cpu_domain_pd_allowed(void); #endif -#if ESP_SLEEP_POWER_DOWN_CPU +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU /** * @brief Configure the parameters of the CPU domain during the sleep process * @@ -65,9 +65,9 @@ void sleep_disable_cpu_retention(void); esp_err_t esp_sleep_cpu_retention(uint32_t (*goto_sleep)(uint32_t, uint32_t, uint32_t, bool), uint32_t wakeup_opt, uint32_t reject_opt, uint32_t lslp_mem_inf_fpu, bool dslp); #endif // SOC_PM_CPU_RETENTION_BY_SW -#endif // ESP_SLEEP_POWER_DOWN_CPU +#endif // CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU -#if !CONFIG_FREERTOS_UNICORE && ESP_SLEEP_POWER_DOWN_CPU +#if !CONFIG_FREERTOS_UNICORE && CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU /** * Do sleep prepare for other smp cores */ @@ -82,7 +82,7 @@ void sleep_smp_cpu_wakeup_prepare(void); * Notify the other core that this sleep does not require retention. */ void esp_sleep_cpu_skip_retention(void); -#endif // !CONFIG_FREERTOS_UNICORE && ESP_SLEEP_POWER_DOWN_CPU +#endif // !CONFIG_FREERTOS_UNICORE && CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU #ifdef __cplusplus } diff --git a/components/esp_hw_support/include/esp_sleep.h b/components/esp_hw_support/include/esp_sleep.h index cd07fdb4c5..df1ae18e4d 100644 --- a/components/esp_hw_support/include/esp_sleep.h +++ b/components/esp_hw_support/include/esp_sleep.h @@ -140,12 +140,6 @@ enum { ESP_ERR_SLEEP_TOO_SHORT_SLEEP_DURATION = ESP_ERR_INVALID_ARG, }; -#if CONFIG_ESP32P4_SELECTS_REV_LESS_V3 -#define ESP_SLEEP_POWER_DOWN_CPU CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP -#else -#define ESP_SLEEP_POWER_DOWN_CPU CONFIG_PM_POWER_DOWN_CPU_IN_LIGHT_SLEEP -#endif - /** * @brief Disable wakeup source * @@ -781,7 +775,7 @@ void esp_deep_sleep_disable_rom_logging(void); void esp_sleep_enable_lowpower_analog_mode(bool enable); #endif -#if ESP_SLEEP_POWER_DOWN_CPU +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU #if SOC_PM_CPU_RETENTION_BY_RTCCNTL /** @@ -820,7 +814,7 @@ esp_err_t esp_sleep_cpu_retention_init(void); * Release system retention memory. */ esp_err_t esp_sleep_cpu_retention_deinit(void); -#endif // ESP_SLEEP_POWER_DOWN_CPU +#endif // CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU /** * @brief Configure to isolate all GPIO pins in sleep state diff --git a/components/esp_hw_support/lowpower/port/esp32c3/sleep_cpu.c b/components/esp_hw_support/lowpower/port/esp32c3/sleep_cpu.c index ccae7a6628..16e6fa6074 100644 --- a/components/esp_hw_support/lowpower/port/esp32c3/sleep_cpu.c +++ b/components/esp_hw_support/lowpower/port/esp32c3/sleep_cpu.c @@ -101,7 +101,7 @@ bool cpu_domain_pd_allowed(void) esp_err_t sleep_cpu_configure(bool light_sleep_enable) { -#if ESP_SLEEP_POWER_DOWN_CPU +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU if (light_sleep_enable) { ESP_RETURN_ON_ERROR(esp_sleep_cpu_retention_init(), TAG, "Failed to enable CPU power down during light sleep."); } else { diff --git a/components/esp_hw_support/lowpower/port/esp32c5/sleep_cpu.c b/components/esp_hw_support/lowpower/port/esp32c5/sleep_cpu.c index 7185d5e3b6..8815cd3803 100644 --- a/components/esp_hw_support/lowpower/port/esp32c5/sleep_cpu.c +++ b/components/esp_hw_support/lowpower/port/esp32c5/sleep_cpu.c @@ -339,7 +339,7 @@ bool cpu_domain_pd_allowed(void) esp_err_t sleep_cpu_configure(bool light_sleep_enable) { -#if ESP_SLEEP_POWER_DOWN_CPU +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU if (light_sleep_enable) { ESP_RETURN_ON_ERROR(esp_sleep_cpu_retention_init(), TAG, "Failed to enable CPU power down during light sleep."); } else { diff --git a/components/esp_hw_support/lowpower/port/esp32c6/sleep_cpu.c b/components/esp_hw_support/lowpower/port/esp32c6/sleep_cpu.c index 58625074f7..ddecd997f0 100644 --- a/components/esp_hw_support/lowpower/port/esp32c6/sleep_cpu.c +++ b/components/esp_hw_support/lowpower/port/esp32c6/sleep_cpu.c @@ -363,7 +363,7 @@ bool cpu_domain_pd_allowed(void) esp_err_t sleep_cpu_configure(bool light_sleep_enable) { -#if ESP_SLEEP_POWER_DOWN_CPU +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU if (light_sleep_enable) { ESP_RETURN_ON_ERROR(esp_sleep_cpu_retention_init(), TAG, "Failed to enable CPU power down during light sleep."); } else { diff --git a/components/esp_hw_support/lowpower/port/esp32c61/sleep_cpu.c b/components/esp_hw_support/lowpower/port/esp32c61/sleep_cpu.c index dd228fd946..809034cfa3 100644 --- a/components/esp_hw_support/lowpower/port/esp32c61/sleep_cpu.c +++ b/components/esp_hw_support/lowpower/port/esp32c61/sleep_cpu.c @@ -339,7 +339,7 @@ bool cpu_domain_pd_allowed(void) esp_err_t sleep_cpu_configure(bool light_sleep_enable) { -#if ESP_SLEEP_POWER_DOWN_CPU +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU if (light_sleep_enable) { ESP_RETURN_ON_ERROR(esp_sleep_cpu_retention_init(), TAG, "Failed to enable CPU power down during light sleep."); } else { diff --git a/components/esp_hw_support/lowpower/port/esp32h2/sleep_cpu.c b/components/esp_hw_support/lowpower/port/esp32h2/sleep_cpu.c index bf673f4a69..fa24e9d959 100644 --- a/components/esp_hw_support/lowpower/port/esp32h2/sleep_cpu.c +++ b/components/esp_hw_support/lowpower/port/esp32h2/sleep_cpu.c @@ -363,7 +363,7 @@ bool cpu_domain_pd_allowed(void) esp_err_t sleep_cpu_configure(bool light_sleep_enable) { -#if ESP_SLEEP_POWER_DOWN_CPU +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU if (light_sleep_enable) { ESP_RETURN_ON_ERROR(esp_sleep_cpu_retention_init(), TAG, "Failed to enable CPU power down during light sleep."); } else { diff --git a/components/esp_hw_support/lowpower/port/esp32h21/sleep_cpu.c b/components/esp_hw_support/lowpower/port/esp32h21/sleep_cpu.c index e642cb2c1a..7467ecfd43 100644 --- a/components/esp_hw_support/lowpower/port/esp32h21/sleep_cpu.c +++ b/components/esp_hw_support/lowpower/port/esp32h21/sleep_cpu.c @@ -359,7 +359,7 @@ bool cpu_domain_pd_allowed(void) esp_err_t sleep_cpu_configure(bool light_sleep_enable) { -#if ESP_SLEEP_POWER_DOWN_CPU +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU if (light_sleep_enable) { ESP_RETURN_ON_ERROR(esp_sleep_cpu_retention_init(), TAG, "Failed to enable CPU power down during light sleep."); } else { diff --git a/components/esp_hw_support/lowpower/port/esp32h4/sleep_cpu.c b/components/esp_hw_support/lowpower/port/esp32h4/sleep_cpu.c index 0677559588..8f10c24e47 100644 --- a/components/esp_hw_support/lowpower/port/esp32h4/sleep_cpu.c +++ b/components/esp_hw_support/lowpower/port/esp32h4/sleep_cpu.c @@ -38,7 +38,7 @@ #include "hal/uart_hal.h" #endif -#if ESP_SLEEP_POWER_DOWN_CPU && !CONFIG_FREERTOS_UNICORE +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU && !CONFIG_FREERTOS_UNICORE static DRAM_ATTR smp_retention_state_t s_smp_retention_state[portNUM_PROCESSORS]; #endif @@ -344,7 +344,7 @@ static IRAM_ATTR esp_err_t do_cpu_retention(sleep_cpu_entry_cb_t goto_sleep, #endif REG_WRITE(RTC_SLEEP_WAKE_STUB_ADDR_REG, (uint32_t)rv_core_critical_regs_restore); -#if ESP_SLEEP_POWER_DOWN_CPU && !CONFIG_FREERTOS_UNICORE +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU && !CONFIG_FREERTOS_UNICORE atomic_store(&s_smp_retention_state[core_id], SMP_BACKUP_DONE); while (atomic_load(&s_smp_retention_state[!core_id]) != SMP_BACKUP_DONE) { ; @@ -367,7 +367,7 @@ esp_err_t IRAM_ATTR esp_sleep_cpu_retention(uint32_t (*goto_sleep)(uint32_t, uin { esp_sleep_execute_event_callbacks(SLEEP_EVENT_SW_CPU_TO_MEM_START, (void *)0); uint8_t core_id = esp_cpu_get_core_id(); -#if ESP_SLEEP_POWER_DOWN_CPU && !CONFIG_FREERTOS_UNICORE +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU && !CONFIG_FREERTOS_UNICORE atomic_store(&s_smp_retention_state[core_id], SMP_BACKUP_START); #endif @@ -388,7 +388,7 @@ esp_err_t IRAM_ATTR esp_sleep_cpu_retention(uint32_t (*goto_sleep)(uint32_t, uin validate_retention_frame_crc((uint32_t*)frame, sizeof(RvCoreNonCriticalSleepFrame) - sizeof(long), (uint32_t *)(&frame->frame_crc)); #endif -#if ESP_SLEEP_POWER_DOWN_CPU && !CONFIG_FREERTOS_UNICORE +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU && !CONFIG_FREERTOS_UNICORE // Start core1 if (core_id == 0) { REG_SET_BIT(PCR_CORE1_CONF_REG, PCR_CORE1_CLK_EN); @@ -403,7 +403,7 @@ esp_err_t IRAM_ATTR esp_sleep_cpu_retention(uint32_t (*goto_sleep)(uint32_t, uin cpu_domain_dev_regs_restore(s_cpu_retention.retent.clic_frame[core_id]); cpu_domain_dev_regs_restore(s_cpu_retention.retent.clint_frame[core_id]); -#if ESP_SLEEP_POWER_DOWN_CPU && !CONFIG_FREERTOS_UNICORE +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU && !CONFIG_FREERTOS_UNICORE atomic_store(&s_smp_retention_state[core_id], SMP_RESTORE_DONE); #endif return err; @@ -411,7 +411,7 @@ esp_err_t IRAM_ATTR esp_sleep_cpu_retention(uint32_t (*goto_sleep)(uint32_t, uin esp_err_t esp_sleep_cpu_retention_init(void) { -#if ESP_SLEEP_POWER_DOWN_CPU && !CONFIG_FREERTOS_UNICORE +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU && !CONFIG_FREERTOS_UNICORE return esp_sleep_cpu_retention_init_impl(& s_cpu_retention, s_smp_retention_state); #else return esp_sleep_cpu_retention_init_impl(& s_cpu_retention); @@ -440,7 +440,7 @@ bool cpu_domain_pd_allowed(void) esp_err_t sleep_cpu_configure(bool light_sleep_enable) { -#if ESP_SLEEP_POWER_DOWN_CPU +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU if (light_sleep_enable) { ESP_RETURN_ON_ERROR(esp_sleep_cpu_retention_init(), TAG, "Failed to enable CPU power down during light sleep."); } else { @@ -451,7 +451,7 @@ esp_err_t sleep_cpu_configure(bool light_sleep_enable) } #if !CONFIG_FREERTOS_UNICORE -#if ESP_SLEEP_POWER_DOWN_CPU +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU static IRAM_ATTR void smp_core_do_retention(void) { uint8_t core_id = esp_cpu_get_core_id(); @@ -527,7 +527,7 @@ IRAM_ATTR void esp_sleep_cpu_skip_retention(void) { void sleep_smp_cpu_sleep_prepare(void) { -#if ESP_SLEEP_POWER_DOWN_CPU +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU while (atomic_load(&s_smp_retention_state[!esp_cpu_get_core_id()]) != SMP_IDLE) { ; } @@ -539,7 +539,7 @@ void sleep_smp_cpu_sleep_prepare(void) void sleep_smp_cpu_wakeup_prepare(void) { -#if ESP_SLEEP_POWER_DOWN_CPU +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU uint8_t core_id = esp_cpu_get_core_id(); if (atomic_load(&s_smp_retention_state[core_id]) == SMP_RESTORE_DONE) { ESP_COMPILER_DIAGNOSTIC_PUSH_IGNORE("-Wanalyzer-infinite-loop") diff --git a/components/esp_hw_support/lowpower/port/esp32h4/sleep_cpu_dynamic.c b/components/esp_hw_support/lowpower/port/esp32h4/sleep_cpu_dynamic.c index e606633cc1..b5de6b4050 100644 --- a/components/esp_hw_support/lowpower/port/esp32h4/sleep_cpu_dynamic.c +++ b/components/esp_hw_support/lowpower/port/esp32h4/sleep_cpu_dynamic.c @@ -73,7 +73,7 @@ static inline void * cpu_domain_clic_sleep_frame_alloc_and_init(uint8_t core_id) return cpu_domain_dev_sleep_frame_alloc_and_init(regions[core_id], sizeof(regions[core_id]) / sizeof(regions[core_id][0])); } -#if ESP_SLEEP_POWER_DOWN_CPU && !CONFIG_FREERTOS_UNICORE +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU && !CONFIG_FREERTOS_UNICORE esp_err_t esp_sleep_cpu_retention_init_impl(sleep_cpu_retention_t *sleep_cpu_retention_ptr, smp_retention_state_t *s_smp_retention_state) { for (uint8_t core_id = 0; core_id < portNUM_PROCESSORS; ++core_id) { diff --git a/components/esp_hw_support/lowpower/port/esp32h4/sleep_cpu_retention.h b/components/esp_hw_support/lowpower/port/esp32h4/sleep_cpu_retention.h index 7d31580212..7b4e6bfaee 100644 --- a/components/esp_hw_support/lowpower/port/esp32h4/sleep_cpu_retention.h +++ b/components/esp_hw_support/lowpower/port/esp32h4/sleep_cpu_retention.h @@ -11,7 +11,7 @@ #include "freertos/FreeRTOS.h" #include "esp_err.h" -#if ESP_SLEEP_POWER_DOWN_CPU && !CONFIG_FREERTOS_UNICORE +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU && !CONFIG_FREERTOS_UNICORE #include #include "soc/hp_system_reg.h" typedef enum { @@ -48,7 +48,7 @@ typedef struct { } retent; } sleep_cpu_retention_t; -#if ESP_SLEEP_POWER_DOWN_CPU && !CONFIG_FREERTOS_UNICORE +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU && !CONFIG_FREERTOS_UNICORE esp_err_t esp_sleep_cpu_retention_init_impl(sleep_cpu_retention_t *sleep_cpu_retention_ptr, smp_retention_state_t *s_smp_retention_state); #else esp_err_t esp_sleep_cpu_retention_init_impl(sleep_cpu_retention_t *sleep_cpu_retention_ptr); diff --git a/components/esp_hw_support/lowpower/port/esp32h4/sleep_cpu_static.c b/components/esp_hw_support/lowpower/port/esp32h4/sleep_cpu_static.c index 2ee118750d..a07461ce7f 100644 --- a/components/esp_hw_support/lowpower/port/esp32h4/sleep_cpu_static.c +++ b/components/esp_hw_support/lowpower/port/esp32h4/sleep_cpu_static.c @@ -142,7 +142,7 @@ static inline void * cpu_domain_clic_sleep_frame_alloc_and_init(uint8_t core_id) return cpu_domain_dev_sleep_frame_alloc_and_init(regions[core_id], sizeof(regions[core_id]) / sizeof(regions[core_id][0]), sleep_frame[core_id]); } -#if ESP_SLEEP_POWER_DOWN_CPU && !CONFIG_FREERTOS_UNICORE +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU && !CONFIG_FREERTOS_UNICORE esp_err_t esp_sleep_cpu_retention_init_impl(sleep_cpu_retention_t *sleep_cpu_retention_ptr, smp_retention_state_t *s_smp_retention_state) { static DRAM_ATTR uint8_t rv_core_critical_regs[RV_SLEEP_CTX_FRMSZ * portNUM_PROCESSORS] __attribute__((aligned(4))); diff --git a/components/esp_hw_support/lowpower/port/esp32p4/sleep_cpu.c b/components/esp_hw_support/lowpower/port/esp32p4/sleep_cpu.c index cc0ca2c40c..7cb3d1f40e 100644 --- a/components/esp_hw_support/lowpower/port/esp32p4/sleep_cpu.c +++ b/components/esp_hw_support/lowpower/port/esp32p4/sleep_cpu.c @@ -39,7 +39,7 @@ #endif -#if ESP_SLEEP_POWER_DOWN_CPU && !CONFIG_FREERTOS_UNICORE +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU && !CONFIG_FREERTOS_UNICORE static TCM_DRAM_ATTR smp_retention_state_t s_smp_retention_state[portNUM_PROCESSORS]; #endif @@ -269,7 +269,7 @@ static TCM_IRAM_ATTR esp_err_t do_cpu_retention(sleep_cpu_entry_cb_t goto_sleep, #endif REG_WRITE(RTC_SLEEP_WAKE_STUB_ADDR_REG, (uint32_t)rv_core_critical_regs_restore); -#if ESP_SLEEP_POWER_DOWN_CPU && !CONFIG_FREERTOS_UNICORE +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU && !CONFIG_FREERTOS_UNICORE atomic_store(&s_smp_retention_state[core_id], SMP_BACKUP_DONE); while (atomic_load(&s_smp_retention_state[!core_id]) != SMP_BACKUP_DONE) { ; @@ -292,7 +292,7 @@ esp_err_t TCM_IRAM_ATTR esp_sleep_cpu_retention(uint32_t (*goto_sleep)(uint32_t, { esp_sleep_execute_event_callbacks(SLEEP_EVENT_SW_CPU_TO_MEM_START, (void *)0); uint8_t core_id = esp_cpu_get_core_id(); -#if ESP_SLEEP_POWER_DOWN_CPU && !CONFIG_FREERTOS_UNICORE +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU && !CONFIG_FREERTOS_UNICORE atomic_store(&s_smp_retention_state[core_id], SMP_BACKUP_START); #endif cpu_domain_dev_regs_save(s_cpu_retention.retent.clic_frame[core_id]); @@ -310,7 +310,7 @@ esp_err_t TCM_IRAM_ATTR esp_sleep_cpu_retention(uint32_t (*goto_sleep)(uint32_t, validate_retention_frame_crc((uint32_t*)frame, sizeof(RvCoreNonCriticalSleepFrame) - sizeof(long), (uint32_t *)(&frame->frame_crc)); #endif -#if ESP_SLEEP_POWER_DOWN_CPU && !CONFIG_FREERTOS_UNICORE +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU && !CONFIG_FREERTOS_UNICORE // Start core1 if (core_id == 0) { REG_SET_BIT(HP_SYS_CLKRST_SOC_CLK_CTRL0_REG, HP_SYS_CLKRST_REG_CORE1_CPU_CLK_EN); @@ -323,7 +323,7 @@ esp_err_t TCM_IRAM_ATTR esp_sleep_cpu_retention(uint32_t (*goto_sleep)(uint32_t, cpu_domain_dev_regs_restore(s_cpu_retention.retent.clic_frame[core_id]); rv_core_noncritical_regs_restore(); -#if ESP_SLEEP_POWER_DOWN_CPU && !CONFIG_FREERTOS_UNICORE +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU && !CONFIG_FREERTOS_UNICORE atomic_store(&s_smp_retention_state[core_id], SMP_RESTORE_DONE); #endif return err; @@ -331,7 +331,7 @@ esp_err_t TCM_IRAM_ATTR esp_sleep_cpu_retention(uint32_t (*goto_sleep)(uint32_t, esp_err_t esp_sleep_cpu_retention_init(void) { -#if ESP_SLEEP_POWER_DOWN_CPU && !CONFIG_FREERTOS_UNICORE +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU && !CONFIG_FREERTOS_UNICORE return esp_sleep_cpu_retention_init_impl(& s_cpu_retention, s_smp_retention_state); #else return esp_sleep_cpu_retention_init_impl(& s_cpu_retention); @@ -358,7 +358,7 @@ bool cpu_domain_pd_allowed(void) esp_err_t sleep_cpu_configure(bool light_sleep_enable) { -#if ESP_SLEEP_POWER_DOWN_CPU +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU if (light_sleep_enable) { ESP_RETURN_ON_ERROR(esp_sleep_cpu_retention_init(), TAG, "Failed to enable CPU power down during light sleep."); } else { @@ -369,7 +369,7 @@ esp_err_t sleep_cpu_configure(bool light_sleep_enable) } #if !CONFIG_FREERTOS_UNICORE -#if ESP_SLEEP_POWER_DOWN_CPU +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU static TCM_IRAM_ATTR void smp_core_do_retention(void) { uint8_t core_id = esp_cpu_get_core_id(); @@ -439,7 +439,7 @@ TCM_IRAM_ATTR void esp_sleep_cpu_skip_retention(void) { void sleep_smp_cpu_sleep_prepare(void) { -#if ESP_SLEEP_POWER_DOWN_CPU +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU while (atomic_load(&s_smp_retention_state[!esp_cpu_get_core_id()]) != SMP_IDLE) { ; } @@ -451,7 +451,7 @@ void sleep_smp_cpu_sleep_prepare(void) void sleep_smp_cpu_wakeup_prepare(void) { -#if ESP_SLEEP_POWER_DOWN_CPU +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU uint8_t core_id = esp_cpu_get_core_id(); if (atomic_load(&s_smp_retention_state[core_id]) == SMP_RESTORE_DONE) { while (atomic_load(&s_smp_retention_state[!core_id]) != SMP_RESTORE_DONE) { diff --git a/components/esp_hw_support/lowpower/port/esp32p4/sleep_cpu_dynamic.c b/components/esp_hw_support/lowpower/port/esp32p4/sleep_cpu_dynamic.c index ac62b8fb19..beff8bce7b 100644 --- a/components/esp_hw_support/lowpower/port/esp32p4/sleep_cpu_dynamic.c +++ b/components/esp_hw_support/lowpower/port/esp32p4/sleep_cpu_dynamic.c @@ -50,7 +50,7 @@ static inline void * cpu_domain_clic_sleep_frame_alloc_and_init(uint8_t core_id) return cpu_domain_dev_sleep_frame_alloc_and_init(regions[core_id], sizeof(regions[core_id]) / sizeof(cpu_domain_dev_regs_region_t)); } -#if ESP_SLEEP_POWER_DOWN_CPU && !CONFIG_FREERTOS_UNICORE +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU && !CONFIG_FREERTOS_UNICORE esp_err_t esp_sleep_cpu_retention_init_impl(sleep_cpu_retention_t *sleep_cpu_retention_ptr, smp_retention_state_t *s_smp_retention_state) { for (uint8_t core_id = 0; core_id < portNUM_PROCESSORS; ++core_id) { diff --git a/components/esp_hw_support/lowpower/port/esp32p4/sleep_cpu_retention.h b/components/esp_hw_support/lowpower/port/esp32p4/sleep_cpu_retention.h index 9c0f9d9651..78d3ae2cf7 100644 --- a/components/esp_hw_support/lowpower/port/esp32p4/sleep_cpu_retention.h +++ b/components/esp_hw_support/lowpower/port/esp32p4/sleep_cpu_retention.h @@ -11,7 +11,7 @@ #include "freertos/FreeRTOS.h" #include "esp_err.h" -#if ESP_SLEEP_POWER_DOWN_CPU && !CONFIG_FREERTOS_UNICORE +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU && !CONFIG_FREERTOS_UNICORE #include #include "soc/hp_system_reg.h" typedef enum { @@ -46,7 +46,7 @@ typedef struct { } retent; } sleep_cpu_retention_t; -#if ESP_SLEEP_POWER_DOWN_CPU && !CONFIG_FREERTOS_UNICORE +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU && !CONFIG_FREERTOS_UNICORE esp_err_t esp_sleep_cpu_retention_init_impl(sleep_cpu_retention_t *sleep_cpu_retention_ptr, smp_retention_state_t *s_smp_retention_state); #else esp_err_t esp_sleep_cpu_retention_init_impl(sleep_cpu_retention_t *sleep_cpu_retention_ptr); diff --git a/components/esp_hw_support/lowpower/port/esp32p4/sleep_cpu_static.c b/components/esp_hw_support/lowpower/port/esp32p4/sleep_cpu_static.c index fcd6a9953a..491ff21294 100644 --- a/components/esp_hw_support/lowpower/port/esp32p4/sleep_cpu_static.c +++ b/components/esp_hw_support/lowpower/port/esp32p4/sleep_cpu_static.c @@ -82,7 +82,7 @@ static inline void * cpu_domain_clic_sleep_frame_alloc_and_init(uint8_t core_id) return cpu_domain_dev_sleep_frame_alloc_and_init(regions[core_id], sizeof(regions[core_id]) / sizeof(regions[core_id][0]), sleep_frame[core_id]); } -#if ESP_SLEEP_POWER_DOWN_CPU && !CONFIG_FREERTOS_UNICORE +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU && !CONFIG_FREERTOS_UNICORE esp_err_t esp_sleep_cpu_retention_init_impl(sleep_cpu_retention_t *sleep_cpu_retention_ptr, smp_retention_state_t *s_smp_retention_state) { static DRAM_ATTR uint8_t rv_core_critical_regs[RV_SLEEP_CTX_FRMSZ * portNUM_PROCESSORS] __attribute__((aligned(4))); diff --git a/components/esp_hw_support/lowpower/port/esp32s3/sleep_cpu.c b/components/esp_hw_support/lowpower/port/esp32s3/sleep_cpu.c index efdab5f71a..a4f4570e7b 100644 --- a/components/esp_hw_support/lowpower/port/esp32s3/sleep_cpu.c +++ b/components/esp_hw_support/lowpower/port/esp32s3/sleep_cpu.c @@ -231,7 +231,7 @@ bool cpu_domain_pd_allowed(void) esp_err_t sleep_cpu_configure(bool light_sleep_enable) { -#if ESP_SLEEP_POWER_DOWN_CPU +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU if (light_sleep_enable) { ESP_RETURN_ON_ERROR(esp_sleep_cpu_retention_init(), TAG, "Failed to enable CPU power down during light sleep."); } else { diff --git a/components/esp_hw_support/sleep_modes.c b/components/esp_hw_support/sleep_modes.c index b31a820f06..c924bf11ec 100644 --- a/components/esp_hw_support/sleep_modes.c +++ b/components/esp_hw_support/sleep_modes.c @@ -932,14 +932,14 @@ static esp_err_t FORCE_IRAM_ATTR esp_sleep_start_safe(uint32_t sleep_flags, uint #endif #if SOC_PMU_SUPPORTED -#if SOC_PM_CPU_RETENTION_BY_SW && ESP_SLEEP_POWER_DOWN_CPU +#if SOC_PM_CPU_RETENTION_BY_SW && CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU esp_sleep_execute_event_callbacks(SLEEP_EVENT_HW_GOTO_SLEEP, (void *)0); if (sleep_flags & (PMU_SLEEP_PD_CPU | PMU_SLEEP_PD_TOP)) { result = esp_sleep_cpu_retention(pmu_sleep_start, s_config.wakeup_triggers, reject_triggers, config->power.hp_sys.dig_power.mem_dslp, deep_sleep); } else #endif { -#if !CONFIG_FREERTOS_UNICORE && ESP_SLEEP_POWER_DOWN_CPU && SOC_PM_CPU_RETENTION_BY_SW +#if !CONFIG_FREERTOS_UNICORE && CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU && SOC_PM_CPU_RETENTION_BY_SW // Skip smp retention if CPU power domain power-down is not allowed esp_sleep_cpu_skip_retention(); #endif @@ -1136,7 +1136,7 @@ static esp_err_t SLEEP_FN_ATTR esp_sleep_start(uint32_t sleep_flags, uint32_t cl if (should_skip_sleep) { result = ESP_ERR_SLEEP_REJECT; -#if ESP_SLEEP_POWER_DOWN_CPU && !CONFIG_FREERTOS_UNICORE && SOC_PM_CPU_RETENTION_BY_SW +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU && !CONFIG_FREERTOS_UNICORE && SOC_PM_CPU_RETENTION_BY_SW esp_sleep_cpu_skip_retention(); #endif } else { @@ -1438,7 +1438,7 @@ esp_err_t esp_light_sleep_start(void) #endif #if !CONFIG_FREERTOS_UNICORE -#if ESP_SLEEP_POWER_DOWN_CPU && SOC_PM_CPU_RETENTION_BY_SW +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU && SOC_PM_CPU_RETENTION_BY_SW sleep_smp_cpu_sleep_prepare(); #else esp_ipc_isr_stall_other_cpu(); @@ -1601,7 +1601,7 @@ esp_err_t esp_light_sleep_start(void) } esp_set_time_from_rtc(); } else { -#if !CONFIG_FREERTOS_UNICORE && ESP_SLEEP_POWER_DOWN_CPU && SOC_PM_CPU_RETENTION_BY_SW +#if !CONFIG_FREERTOS_UNICORE && CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU && SOC_PM_CPU_RETENTION_BY_SW esp_sleep_cpu_skip_retention(); #endif } @@ -1618,7 +1618,7 @@ esp_err_t esp_light_sleep_start(void) #if !CONFIG_FREERTOS_UNICORE esp_ipc_isr_stall_resume(); -#if ESP_SLEEP_POWER_DOWN_CPU && SOC_PM_CPU_RETENTION_BY_SW +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU && SOC_PM_CPU_RETENTION_BY_SW sleep_smp_cpu_wakeup_prepare(); #else esp_ipc_isr_release_other_cpu(); @@ -2558,7 +2558,7 @@ esp_err_t esp_sleep_clock_config(esp_sleep_clock_t clock, esp_sleep_clock_option #if SOC_PM_SUPPORT_TOP_PD && SOC_PAU_SUPPORTED FORCE_INLINE_ATTR bool top_domain_pd_allowed(void) { bool top_pd_allowed = true; -#if ESP_SLEEP_POWER_DOWN_CPU +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU top_pd_allowed &= cpu_domain_pd_allowed(); #else top_pd_allowed = false; @@ -2689,7 +2689,7 @@ static SLEEP_FN_ATTR uint32_t get_power_down_flags(void) } #endif -#if SOC_PM_SUPPORT_CPU_PD && ESP_SLEEP_POWER_DOWN_CPU && !CONFIG_ESP32P4_SELECTS_REV_LESS_V3 +#if SOC_PM_SUPPORT_CPU_PD && CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU && !CONFIG_ESP32P4_SELECTS_REV_LESS_V3 if ((s_config.domain[ESP_PD_DOMAIN_CPU].pd_option != ESP_PD_OPTION_ON) && cpu_domain_pd_allowed()) { pd_flags |= RTC_SLEEP_PD_CPU; } diff --git a/components/esp_pm/Kconfig b/components/esp_pm/Kconfig index 2a48106c80..fca3fae5b6 100644 --- a/components/esp_pm/Kconfig +++ b/components/esp_pm/Kconfig @@ -214,6 +214,11 @@ menu "Power Management" If any module belonging to the peripheral power domain chooses not to be powered down during sleep, then the peripheral power domain will not be powered off either. + config PM_ESP_SLEEP_POWER_DOWN_CPU + bool + default y if (PM_POWER_DOWN_CPU_IN_LIGHT_SLEEP && !ESP32P4_SELECTS_REV_LESS_V3) + default y if (PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP && ESP32P4_SELECTS_REV_LESS_V3) + config PM_UPDATE_CCOMPARE_HLI_WORKAROUND bool default y if PM_ENABLE && BTDM_CTRL_HLI diff --git a/components/esp_pm/pm_impl.c b/components/esp_pm/pm_impl.c index d5b488bc53..0f4852defe 100644 --- a/components/esp_pm/pm_impl.c +++ b/components/esp_pm/pm_impl.c @@ -380,7 +380,7 @@ static esp_err_t esp_pm_sleep_configure(const esp_pm_config_t *config) { esp_err_t err = ESP_OK; -#if ESP_SLEEP_POWER_DOWN_CPU && CONFIG_SOC_LIGHT_SLEEP_SUPPORTED +#if CONFIG_PM_ESP_SLEEP_POWER_DOWN_CPU && CONFIG_SOC_LIGHT_SLEEP_SUPPORTED err = sleep_cpu_configure(config->light_sleep_enable); if (err != ESP_OK) { return err;