From d3c5129050867df340aa4881546ae7e2fab74a0b Mon Sep 17 00:00:00 2001 From: wuzhenghui Date: Wed, 15 Apr 2026 18:20:55 +0800 Subject: [PATCH] fix(driver): fix retention unsupported mouldes TOP pd test --- components/esp_driver_dma/src/gdma.c | 25 ++++++++++++++++--- components/esp_driver_gptimer/src/gptimer.c | 5 ++++ components/esp_driver_i2c/i2c_master.c | 4 +++ .../test_apps/i2s/main/test_i2s_sleep.c | 4 +-- .../main/test_jpeg_sleep_retention.c | 4 ++- components/esp_driver_ledc/src/ledc.c | 4 +++ components/esp_driver_mcpwm/src/mcpwm_cap.c | 4 +++ components/esp_driver_mcpwm/src/mcpwm_timer.c | 4 +++ components/esp_driver_parlio/src/parlio_rx.c | 4 +++ components/esp_driver_parlio/src/parlio_tx.c | 4 +++ .../pulse_cnt/main/test_pulse_cnt_sleep.c | 2 +- components/esp_driver_rmt/src/rmt_rx.c | 4 +++ components/esp_driver_rmt/src/rmt_tx.c | 4 +++ components/esp_driver_sdm/src/sdm.c | 4 +++ .../slave_hd/main/test_spi_slave_hd.c | 4 +-- .../esp_driver_tsens/src/temperature_sensor.c | 3 +++ components/esp_driver_twai/esp_twai_onchip.c | 4 +++ components/esp_driver_uart/src/uart.c | 4 +++ .../test_apps/uart/main/test_uart_retention.c | 3 ++- components/esp_hw_support/etm/esp_etm.c | 4 +++ components/esp_lcd/i80/esp_lcd_panel_io_i80.c | 4 +++ examples/system/ulp/.build-test-rules.yml | 2 +- 22 files changed, 92 insertions(+), 12 deletions(-) diff --git a/components/esp_driver_dma/src/gdma.c b/components/esp_driver_dma/src/gdma.c index b248ba2bad0..b4d5be044ca 100644 --- a/components/esp_driver_dma/src/gdma.c +++ b/components/esp_driver_dma/src/gdma.c @@ -28,6 +28,7 @@ #include "gdma_priv.h" #include "esp_memory_utils.h" +#include "esp_sleep.h" #define GDMA_INVALID_PERIPH_TRIG (0x3F) #define SEARCH_REQUEST_RX_CHANNEL (1 << 0) @@ -87,11 +88,15 @@ static esp_err_t do_allocate_gdma_channel(const gdma_channel_search_info_t *sear TAG, "invalid interrupt priority:%d", config->intr_priority); } -#if CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP && SOC_GDMA_SUPPORT_SLEEP_RETENTION +#if CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP +#if SOC_GDMA_SUPPORT_SLEEP_RETENTION // retention module is per GDMA pair, before we allocate the pair object, some common registers are already configured in "hal_init" // if a light sleep happens and powers off the gdma module, those registers will get lost // to work around it, we can acquire a power lock first, before any register configuration sleep_retention_power_lock_acquire(); +#else + esp_sleep_pd_config(ESP_PD_DOMAIN_TOP, ESP_PD_OPTION_ON); //IDF-15640 +#endif #endif // Determine search code based on which channels are requested @@ -237,8 +242,12 @@ err: free(alloc_rx_channel); } -#if CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP && SOC_GDMA_SUPPORT_SLEEP_RETENTION +#if CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP +#if SOC_GDMA_SUPPORT_SLEEP_RETENTION sleep_retention_power_lock_release(); +#else + esp_sleep_pd_config(ESP_PD_DOMAIN_TOP, ESP_PD_OPTION_AUTO); //IDF-15640 +#endif #endif return ret; } @@ -874,9 +883,13 @@ static esp_err_t gdma_del_tx_channel(gdma_channel_t *dma_channel) free(tx_chan); ESP_LOGV(TAG, "del tx channel (%d,%d)", group_id, pair_id); -#if CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP && SOC_GDMA_SUPPORT_SLEEP_RETENTION +#if CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP +#if SOC_GDMA_SUPPORT_SLEEP_RETENTION // release sleep retention lock gdma_release_sleep_retention(pair); +#else + esp_sleep_pd_config(ESP_PD_DOMAIN_TOP, ESP_PD_OPTION_AUTO); //IDF-15640 +#endif #endif // release pair handle (will free pair if both channels are deleted) gdma_try_free_pair_handle(pair); @@ -909,9 +922,13 @@ static esp_err_t gdma_del_rx_channel(gdma_channel_t *dma_channel) free(rx_chan); ESP_LOGV(TAG, "del rx channel (%d,%d)", group_id, pair_id); -#if CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP && SOC_GDMA_SUPPORT_SLEEP_RETENTION +#if CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP +#if SOC_GDMA_SUPPORT_SLEEP_RETENTION // release sleep retention lock gdma_release_sleep_retention(pair); +#else + esp_sleep_pd_config(ESP_PD_DOMAIN_TOP, ESP_PD_OPTION_AUTO); //IDF-15640 +#endif #endif // release pair handle (will free pair if both channels are deleted) gdma_try_free_pair_handle(pair); diff --git a/components/esp_driver_gptimer/src/gptimer.c b/components/esp_driver_gptimer/src/gptimer.c index cabbecf78de..c1695f181b1 100644 --- a/components/esp_driver_gptimer/src/gptimer.c +++ b/components/esp_driver_gptimer/src/gptimer.c @@ -9,6 +9,7 @@ #include "driver/gptimer.h" #include "gptimer_priv.h" #include "esp_memory_utils.h" +#include "esp_sleep.h" static void gptimer_default_isr(void *args); @@ -155,6 +156,10 @@ esp_err_t gptimer_new_timer(const gptimer_config_t *config, gptimer_handle_t *re #if GPTIMER_USE_RETENTION_LINK gptimer_create_retention_module(timer); #endif // GPTIMER_USE_RETENTION_LINK + } else { +#if !SOC_TIMER_SUPPORT_SLEEP_RETENTION && CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP + esp_sleep_pd_config(ESP_PD_DOMAIN_TOP, ESP_PD_OPTION_ON); //IDF-15641 +#endif } // initialize HAL layer diff --git a/components/esp_driver_i2c/i2c_master.c b/components/esp_driver_i2c/i2c_master.c index 972f9ba5c02..8998ecb463a 100644 --- a/components/esp_driver_i2c/i2c_master.c +++ b/components/esp_driver_i2c/i2c_master.c @@ -28,6 +28,7 @@ #include "hal/i2c_ll.h" #include "hal/i2c_periph.h" #include "driver/i2c_master.h" +#include "esp_sleep.h" #include "i2c_private.h" static const char *TAG = "i2c.master"; @@ -1045,6 +1046,9 @@ esp_err_t i2c_new_master_bus(const i2c_master_bus_config_t *bus_config, i2c_mast #if !SOC_I2C_SUPPORT_SLEEP_RETENTION ESP_RETURN_ON_FALSE(bus_config->flags.allow_pd == 0, ESP_ERR_NOT_SUPPORTED, TAG, "not able to power down in light sleep"); +#if SOC_PM_SUPPORT_TOP_PD + esp_sleep_pd_config(ESP_PD_DOMAIN_TOP, ESP_PD_OPTION_ON); //IDF-15642 +#endif #endif // SOC_I2C_SUPPORT_SLEEP_RETENTION i2c_master = heap_caps_calloc(1, sizeof(i2c_master_bus_t) + 20 * sizeof(i2c_transaction_t), I2C_MEM_ALLOC_CAPS); 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 2d33535f773..f04fc11c6f5 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 @@ -43,8 +43,8 @@ static void s_test_i2s_enter_light_sleep(int sec, bool allow_power_down) printf("Woke up from light sleep\n"); TEST_ASSERT_EQUAL(0, sleep_ctx.sleep_request_result); -#if SOC_HAS(PAU) - // check if the power domain also is powered down +#if SOC_HAS(PAU) && SOC_GDMA_SUPPORT_SLEEP_RETENTION + // check if the power domain also is powered down (if GDMA retention is not supported, TOP pd will be rejected) TEST_ASSERT_EQUAL(allow_power_down ? PMU_SLEEP_PD_TOP : 0, (sleep_ctx.sleep_flags) & PMU_SLEEP_PD_TOP); #endif esp_sleep_set_sleep_context(NULL); diff --git a/components/esp_driver_jpeg/test_apps/jpeg_test_apps/main/test_jpeg_sleep_retention.c b/components/esp_driver_jpeg/test_apps/jpeg_test_apps/main/test_jpeg_sleep_retention.c index 80ab5db79bd..286f8be0450 100644 --- a/components/esp_driver_jpeg/test_apps/jpeg_test_apps/main/test_jpeg_sleep_retention.c +++ b/components/esp_driver_jpeg/test_apps/jpeg_test_apps/main/test_jpeg_sleep_retention.c @@ -26,6 +26,8 @@ extern const uint8_t image_esp1080_jpg_start[] asm("_binary_esp1080_jpg_start"); extern const uint8_t image_esp1080_jpg_end[] asm("_binary_esp1080_jpg_end"); +#define JPEG_SLEEP_RETENTION_TIMEOUT_MS 50 + #if SOC_LIGHT_SLEEP_SUPPORTED && CONFIG_PM_ENABLE static void test_jpeg_sleep_retention(bool allow_pd) { @@ -33,7 +35,7 @@ static void test_jpeg_sleep_retention(bool allow_pd) jpeg_decode_engine_cfg_t decode_eng_cfg = { .intr_priority = 0, - .timeout_ms = 40, + .timeout_ms = JPEG_SLEEP_RETENTION_TIMEOUT_MS, .flags = { .allow_pd = allow_pd, }, diff --git a/components/esp_driver_ledc/src/ledc.c b/components/esp_driver_ledc/src/ledc.c index ddd62a5a69b..4430a18384f 100644 --- a/components/esp_driver_ledc/src/ledc.c +++ b/components/esp_driver_ledc/src/ledc.c @@ -18,6 +18,7 @@ #include "hal/ledc_hal.h" #include "driver/ledc.h" #include "esp_private/esp_sleep_internal.h" +#include "esp_sleep.h" #include "esp_private/periph_ctrl.h" #include "driver/gpio.h" #include "esp_private/gpio.h" @@ -877,6 +878,9 @@ esp_err_t ledc_channel_config(const ledc_channel_config_t *ledc_conf) LEDC_ARG_CHECK(ledc_conf->sleep_mode < LEDC_SLEEP_MODE_INVALID, "sleep_mode"); #if !SOC_LEDC_SUPPORT_SLEEP_RETENTION ESP_RETURN_ON_FALSE(ledc_conf->sleep_mode != LEDC_SLEEP_MODE_NO_ALIVE_ALLOW_PD, ESP_ERR_NOT_SUPPORTED, LEDC_TAG, "register back up is not supported"); +#if SOC_PM_SUPPORT_TOP_PD + esp_sleep_pd_config(ESP_PD_DOMAIN_TOP, ESP_PD_OPTION_ON); //IDF-15643 +#endif #endif esp_err_t ret = ESP_OK; diff --git a/components/esp_driver_mcpwm/src/mcpwm_cap.c b/components/esp_driver_mcpwm/src/mcpwm_cap.c index e85ec9b4119..413ef0477cd 100644 --- a/components/esp_driver_mcpwm/src/mcpwm_cap.c +++ b/components/esp_driver_mcpwm/src/mcpwm_cap.c @@ -10,6 +10,7 @@ #include "esp_memory_utils.h" #include "driver/mcpwm_cap.h" #include "driver/gpio.h" +#include "esp_sleep.h" #include "esp_private/gpio.h" static void mcpwm_capture_default_isr(void *args); @@ -73,6 +74,9 @@ esp_err_t mcpwm_new_capture_timer(const mcpwm_capture_timer_config_t *config, mc #if !SOC_MCPWM_SUPPORT_SLEEP_RETENTION ESP_RETURN_ON_FALSE(config->flags.allow_pd == 0, ESP_ERR_NOT_SUPPORTED, TAG, "register back up is not supported"); +#if SOC_PM_SUPPORT_TOP_PD + esp_sleep_pd_config(ESP_PD_DOMAIN_TOP, ESP_PD_OPTION_ON); //IDF-15644 +#endif #endif // SOC_MCPWM_SUPPORT_SLEEP_RETENTION cap_timer = heap_caps_calloc(1, sizeof(mcpwm_cap_timer_t), MCPWM_MEM_ALLOC_CAPS); diff --git a/components/esp_driver_mcpwm/src/mcpwm_timer.c b/components/esp_driver_mcpwm/src/mcpwm_timer.c index 4ca9c68ebd6..56b8905753b 100644 --- a/components/esp_driver_mcpwm/src/mcpwm_timer.c +++ b/components/esp_driver_mcpwm/src/mcpwm_timer.c @@ -8,6 +8,7 @@ #include "esp_memory_utils.h" #include "hal/mcpwm_ll.h" #include "driver/mcpwm_timer.h" +#include "esp_sleep.h" #include "esp_private/mcpwm.h" static void mcpwm_timer_default_isr(void *args); @@ -83,6 +84,9 @@ esp_err_t mcpwm_new_timer(const mcpwm_timer_config_t *config, mcpwm_timer_handle #if !SOC_MCPWM_SUPPORT_SLEEP_RETENTION ESP_RETURN_ON_FALSE(config->flags.allow_pd == 0, ESP_ERR_NOT_SUPPORTED, TAG, "register back up is not supported"); +#if SOC_PM_SUPPORT_TOP_PD + esp_sleep_pd_config(ESP_PD_DOMAIN_TOP, ESP_PD_OPTION_ON); //IDF-15644 +#endif #endif // SOC_MCPWM_SUPPORT_SLEEP_RETENTION timer = heap_caps_calloc(1, sizeof(mcpwm_timer_t), MCPWM_MEM_ALLOC_CAPS); diff --git a/components/esp_driver_parlio/src/parlio_rx.c b/components/esp_driver_parlio/src/parlio_rx.c index 4bc92783a37..30723a7456e 100644 --- a/components/esp_driver_parlio/src/parlio_rx.c +++ b/components/esp_driver_parlio/src/parlio_rx.c @@ -10,6 +10,7 @@ #include "driver/gpio.h" #include "driver/parlio_rx.h" #include "parlio_priv.h" +#include "esp_sleep.h" #define ALIGN_UP(num, align) (((num) + ((align) - 1)) & ~((align) - 1)) @@ -614,6 +615,9 @@ esp_err_t parlio_new_rx_unit(const parlio_rx_unit_config_t *config, parlio_rx_un #if !SOC_PARLIO_SUPPORT_SLEEP_RETENTION ESP_RETURN_ON_FALSE(config->flags.allow_pd == 0, ESP_ERR_NOT_SUPPORTED, TAG, "register back up is not supported"); +#if SOC_PM_SUPPORT_TOP_PD + esp_sleep_pd_config(ESP_PD_DOMAIN_TOP, ESP_PD_OPTION_ON); //IDF-15645 +#endif #endif // SOC_PARLIO_SUPPORT_SLEEP_RETENTION /* Allocate unit memory */ diff --git a/components/esp_driver_parlio/src/parlio_tx.c b/components/esp_driver_parlio/src/parlio_tx.c index f8f37672b3a..f7cdb133695 100644 --- a/components/esp_driver_parlio/src/parlio_tx.c +++ b/components/esp_driver_parlio/src/parlio_tx.c @@ -9,6 +9,7 @@ #include "driver/gpio.h" #include "driver/parlio_tx.h" #include "parlio_priv.h" +#include "esp_sleep.h" #if SOC_PARLIO_TX_SUPPORT_LOOP_TRANSMISSION static bool parlio_tx_gdma_eof_callback(gdma_channel_handle_t dma_chan, gdma_event_data_t *event_data, void *user_data); @@ -273,6 +274,9 @@ esp_err_t parlio_new_tx_unit(const parlio_tx_unit_config_t *config, parlio_tx_un #if !SOC_PARLIO_SUPPORT_SLEEP_RETENTION ESP_RETURN_ON_FALSE(config->flags.allow_pd == 0, ESP_ERR_NOT_SUPPORTED, TAG, "register back up is not supported"); +#if SOC_PM_SUPPORT_TOP_PD + esp_sleep_pd_config(ESP_PD_DOMAIN_TOP, ESP_PD_OPTION_ON); //IDF-15645 +#endif #endif // SOC_PARLIO_SUPPORT_SLEEP_RETENTION // allocate unit from internal memory because it contains atomic member 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 fb89c70f795..423e49b68d0 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 @@ -125,7 +125,7 @@ static void test_pcnt_sleep_retention(void) TEST_ESP_OK(pcnt_unit_get_count(units[i], &count_value)); TEST_ASSERT_EQUAL(20, count_value); // check the register value - reg_value = pcnt_ll_get_count(&PCNT, i); + reg_value = pcnt_ll_get_count(PCNT_LL_GET_HW(unit_config.group_id), i); TEST_ASSERT_EQUAL(20, reg_value); } diff --git a/components/esp_driver_rmt/src/rmt_rx.c b/components/esp_driver_rmt/src/rmt_rx.c index 51af2291c21..8efa545d167 100644 --- a/components/esp_driver_rmt/src/rmt_rx.c +++ b/components/esp_driver_rmt/src/rmt_rx.c @@ -10,6 +10,7 @@ #include "driver/gpio.h" #include "driver/rmt_rx.h" #include "rmt_private.h" +#include "esp_sleep.h" static esp_err_t rmt_del_rx_channel(rmt_channel_handle_t channel); static esp_err_t rmt_rx_demodulate_carrier(rmt_channel_handle_t channel, const rmt_carrier_config_t *config); @@ -206,6 +207,9 @@ esp_err_t rmt_new_rx_channel(const rmt_rx_channel_config_t *config, rmt_channel_ #if !SOC_RMT_SUPPORT_SLEEP_RETENTION ESP_RETURN_ON_FALSE(config->flags.allow_pd == 0, ESP_ERR_NOT_SUPPORTED, TAG, "not able to power down in light sleep"); +#if SOC_PM_SUPPORT_TOP_PD + esp_sleep_pd_config(ESP_PD_DOMAIN_TOP, ESP_PD_OPTION_ON); //IDF-15646 +#endif #endif // SOC_RMT_SUPPORT_SLEEP_RETENTION // allocate channel memory from internal memory because it contains atomic variable diff --git a/components/esp_driver_rmt/src/rmt_tx.c b/components/esp_driver_rmt/src/rmt_tx.c index b1a70e5a580..67054a0613d 100644 --- a/components/esp_driver_rmt/src/rmt_tx.c +++ b/components/esp_driver_rmt/src/rmt_tx.c @@ -11,6 +11,7 @@ #include "driver/gpio.h" #include "driver/rmt_tx.h" #include "rmt_private.h" +#include "esp_sleep.h" struct rmt_sync_manager_t { rmt_group_t *group; // which group the synchro belongs to @@ -273,6 +274,9 @@ esp_err_t rmt_new_tx_channel(const rmt_tx_channel_config_t *config, rmt_channel_ #if !SOC_RMT_SUPPORT_SLEEP_RETENTION ESP_RETURN_ON_FALSE(config->flags.allow_pd == 0, ESP_ERR_NOT_SUPPORTED, TAG, "not able to power down in light sleep"); +#if SOC_PM_SUPPORT_TOP_PD + esp_sleep_pd_config(ESP_PD_DOMAIN_TOP, ESP_PD_OPTION_ON); //IDF-15646 +#endif #endif // SOC_RMT_SUPPORT_SLEEP_RETENTION // allocate channel memory from internal memory because it contains atomic variable diff --git a/components/esp_driver_sdm/src/sdm.c b/components/esp_driver_sdm/src/sdm.c index 57d352301e3..430c984cc65 100644 --- a/components/esp_driver_sdm/src/sdm.c +++ b/components/esp_driver_sdm/src/sdm.c @@ -18,6 +18,7 @@ #include "esp_err.h" #include "esp_heap_caps.h" #include "esp_log.h" +#include "esp_sleep.h" #include "esp_check.h" #include "esp_pm.h" #include "esp_clk_tree.h" @@ -276,6 +277,9 @@ esp_err_t sdm_new_channel(const sdm_config_t *config, sdm_channel_handle_t *ret_ [[maybe_unused]] bool allow_pd = config->flags.allow_pd == 1; #if !SOC_SDM_SUPPORT_SLEEP_RETENTION ESP_RETURN_ON_FALSE(allow_pd == false, ESP_ERR_NOT_SUPPORTED, TAG, "not able to power down in light sleep"); +#if SOC_PM_SUPPORT_TOP_PD + esp_sleep_pd_config(ESP_PD_DOMAIN_TOP, ESP_PD_OPTION_ON); //IDF-15647 +#endif #endif // SOC_SDM_SUPPORT_SLEEP_RETENTION // allocate channel memory from internal memory because it contains atomic variable 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 9bf1b7061ed..97e04ed1638 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 @@ -966,7 +966,7 @@ TEST_CASE("test_spi_slave_hd_sleep_retention", "[spi]") printf("Waked up!\n"); // check if the sleep happened as expected TEST_ASSERT_EQUAL(0, sleep_ctx.sleep_request_result); -#if SOC_SPI_SUPPORT_SLEEP_RETENTION && CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP +#if SOC_SPI_SUPPORT_SLEEP_RETENTION && SOC_GDMA_SUPPORT_SLEEP_RETENTION && CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP // check if the power domain also is powered down TEST_ASSERT_EQUAL((bus_cfg.flags & SPICOMMON_BUSFLAG_SLP_ALLOW_PD) ? PMU_SLEEP_PD_TOP : 0, (sleep_ctx.sleep_flags) & PMU_SLEEP_PD_TOP); #endif @@ -1044,7 +1044,7 @@ TEST_CASE("test_spi_slave_hd_append_sleep_retention", "[spi]") printf("Waked up!\n"); // check if the sleep happened as expected TEST_ASSERT_EQUAL(0, sleep_ctx.sleep_request_result); -#if SOC_SPI_SUPPORT_SLEEP_RETENTION && CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP +#if SOC_SPI_SUPPORT_SLEEP_RETENTION && SOC_GDMA_SUPPORT_SLEEP_RETENTION && CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP // check if the power domain also is powered down TEST_ASSERT_EQUAL((bus_cfg.flags & SPICOMMON_BUSFLAG_SLP_ALLOW_PD) ? PMU_SLEEP_PD_TOP : 0, (sleep_ctx.sleep_flags) & PMU_SLEEP_PD_TOP); #endif diff --git a/components/esp_driver_tsens/src/temperature_sensor.c b/components/esp_driver_tsens/src/temperature_sensor.c index cdbbb22f46d..7a11d7d06a9 100644 --- a/components/esp_driver_tsens/src/temperature_sensor.c +++ b/components/esp_driver_tsens/src/temperature_sensor.c @@ -145,6 +145,9 @@ esp_err_t temperature_sensor_install(const temperature_sensor_config_t *tsens_co #if !SOC_TEMPERATURE_SENSOR_SUPPORT_SLEEP_RETENTION ESP_RETURN_ON_FALSE(tsens_config->flags.allow_pd == 0, ESP_ERR_NOT_SUPPORTED, TAG, "not able to power down in light sleep"); +#if SOC_PM_SUPPORT_TOP_PD + esp_sleep_pd_config(ESP_PD_DOMAIN_TOP, ESP_PD_OPTION_ON); //IDF-15648 +#endif #endif // SOC_TEMPERATURE_SENSOR_SUPPORT_SLEEP_RETENTION #if SOC_TEMPERATURE_SENSOR_SUPPORT_SLEEP_RETENTION && !SOC_TEMPERATURE_SENSOR_UNDER_PD_TOP_DOMAIN diff --git a/components/esp_driver_twai/esp_twai_onchip.c b/components/esp_driver_twai/esp_twai_onchip.c index 0495fc66565..4b939934a8c 100644 --- a/components/esp_driver_twai/esp_twai_onchip.c +++ b/components/esp_driver_twai/esp_twai_onchip.c @@ -12,6 +12,7 @@ #include "twai_private.h" #include "hal/twai_periph.h" #include "hal/twai_hal.h" +#include "esp_sleep.h" #if SOC_HAS(TWAI_FD) #include "hal/twaifd_ll.h" #endif @@ -664,6 +665,9 @@ esp_err_t twai_new_node_onchip(const twai_onchip_node_config_t *node_config, twa ESP_RETURN_ON_FALSE(!node_config->intr_priority || (BIT(node_config->intr_priority) & ESP_INTR_FLAG_LOWMED), ESP_ERR_INVALID_ARG, TAG, "Invalid intr_priority level"); #if !SOC_TWAI_SUPPORT_SLEEP_RETENTION ESP_RETURN_ON_FALSE(!node_config->flags.sleep_allow_pd, ESP_ERR_NOT_SUPPORTED, TAG, "sleep retention is not supported on this target"); +#if SOC_PM_SUPPORT_TOP_PD + esp_sleep_pd_config(ESP_PD_DOMAIN_TOP, ESP_PD_OPTION_ON); //IDF-15649 +#endif #endif // Allocate TWAI node from internal memory because it contains atomic variable twai_onchip_ctx_t *node = heap_caps_calloc(1, sizeof(twai_onchip_ctx_t) + twai_hal_get_mem_requirment(), MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT); diff --git a/components/esp_driver_uart/src/uart.c b/components/esp_driver_uart/src/uart.c index 3b7a097e5f5..c7eb9b2721b 100644 --- a/components/esp_driver_uart/src/uart.c +++ b/components/esp_driver_uart/src/uart.c @@ -28,6 +28,7 @@ #include "esp_private/gpio.h" #include "esp_private/esp_gpio_reserve.h" #include "esp_private/periph_ctrl.h" +#include "esp_sleep.h" #include "esp_private/sleep_retention.h" #include "esp_clk_tree.h" #include "esp_rom_gpio.h" @@ -1067,6 +1068,9 @@ esp_err_t uart_param_config(uart_port_t uart_num, const uart_config_t *uart_conf bool allow_pd __attribute__((unused)) = (uart_config->flags.allow_pd || uart_config->flags.backup_before_sleep); #if !SOC_UART_SUPPORT_SLEEP_RETENTION ESP_RETURN_ON_FALSE(allow_pd == 0, ESP_ERR_NOT_SUPPORTED, UART_TAG, "not able to power down in light sleep"); +#if SOC_PM_SUPPORT_TOP_PD + esp_sleep_pd_config(ESP_PD_DOMAIN_TOP, ESP_PD_OPTION_ON); //IDF-15650 +#endif #endif uart_module_enable(uart_num); diff --git a/components/esp_driver_uart/test_apps/uart/main/test_uart_retention.c b/components/esp_driver_uart/test_apps/uart/main/test_uart_retention.c index d230a84987a..0da28358b04 100644 --- a/components/esp_driver_uart/test_apps/uart/main/test_uart_retention.c +++ b/components/esp_driver_uart/test_apps/uart/main/test_uart_retention.c @@ -55,11 +55,11 @@ TEST_CASE("uart restored correctly after auto light sleep", "[uart][hp-uart-only // Ensure UART is fully idle before starting loopback RX/TX test TEST_ESP_OK(uart_wait_tx_done(uart_num, portMAX_DELAY)); vTaskDelay(pdMS_TO_TICKS(20)); // make sure last byte has flushed from TX FIFO - TEST_ESP_OK(uart_flush_input(uart_num)); for (int i = 0; i < 5; i++) { char tx_data[20] = {0}; char rx_data[20] = {0}; + TEST_ESP_OK(uart_flush_input(uart_num)); int len = sprintf(tx_data, "Hello World %d!\n", i); uart_write_bytes(uart_num, tx_data, len); int size = 0; @@ -97,6 +97,7 @@ TEST_CASE("uart restored correctly after manually enter light sleep", "[uart][hp for (int i = 0; i < 5; i++) { char tx_data[20] = {0}; char rx_data[20] = {0}; + TEST_ESP_OK(uart_flush_input(uart_num)); int len = sprintf(tx_data, "Hello World %d!\n", i); uart_write_bytes(uart_num, tx_data, len); int size = uart_read_bytes(uart_num, rx_data, len, pdMS_TO_TICKS(20)); diff --git a/components/esp_hw_support/etm/esp_etm.c b/components/esp_hw_support/etm/esp_etm.c index dc2a8c7c577..7060ccaea1f 100644 --- a/components/esp_hw_support/etm/esp_etm.c +++ b/components/esp_hw_support/etm/esp_etm.c @@ -18,6 +18,7 @@ #include "freertos/task.h" #include "hal/etm_periph.h" #include "esp_log.h" +#include "esp_sleep.h" #include "esp_check.h" #include "esp_heap_caps.h" #include "esp_etm.h" @@ -246,6 +247,9 @@ esp_err_t esp_etm_new_channel(const esp_etm_channel_config_t *config, esp_etm_ch [[maybe_unused]] bool allow_pd = config->flags.allow_pd == 1; #if !SOC_ETM_SUPPORT_SLEEP_RETENTION ESP_RETURN_ON_FALSE(allow_pd == 0, ESP_ERR_NOT_SUPPORTED, TAG, "not able to power down in light sleep"); +#if SOC_PM_SUPPORT_TOP_PD + esp_sleep_pd_config(ESP_PD_DOMAIN_TOP, ESP_PD_OPTION_ON); //IDF-15651 +#endif #endif // SOC_ETM_SUPPORT_SLEEP_RETENTION // allocate channel memory from internal memory because it contains atomic variable diff --git a/components/esp_lcd/i80/esp_lcd_panel_io_i80.c b/components/esp_lcd/i80/esp_lcd_panel_io_i80.c index 8de7b915976..d6d82583f73 100644 --- a/components/esp_lcd/i80/esp_lcd_panel_io_i80.c +++ b/components/esp_lcd/i80/esp_lcd_panel_io_i80.c @@ -11,6 +11,7 @@ #include "hal/cache_ll.h" #include "hal/cache_hal.h" #include "esp_private/sleep_retention.h" +#include "esp_sleep.h" // Use retention link only when the target supports sleep retention is enabled #define I80_USE_RETENTION_LINK (SOC_LCDCAM_LCD_SUPPORT_SLEEP_RETENTION && CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP) @@ -128,6 +129,9 @@ esp_err_t esp_lcd_new_i80_bus(const esp_lcd_i80_bus_config_t *bus_config, esp_lc TAG, "invalid bus width:%d", bus_config->bus_width); #if !SOC_LCDCAM_LCD_SUPPORT_SLEEP_RETENTION ESP_RETURN_ON_FALSE(bus_config->flags.allow_pd == 0, ESP_ERR_NOT_SUPPORTED, TAG, "register back up is not supported"); +#if SOC_PM_SUPPORT_TOP_PD + esp_sleep_pd_config(ESP_PD_DOMAIN_TOP, ESP_PD_OPTION_ON); //IDF-15652 +#endif #endif // SOC_LCDCAM_LCD_SUPPORT_SLEEP_RETENTION // allocate i80 bus memory diff --git a/examples/system/ulp/.build-test-rules.yml b/examples/system/ulp/.build-test-rules.yml index e5f68895551..9adcf69329b 100644 --- a/examples/system/ulp/.build-test-rules.yml +++ b/examples/system/ulp/.build-test-rules.yml @@ -61,7 +61,7 @@ examples/system/ulp/lp_core/lp_adc: examples/system/ulp/lp_core/lp_i2c: enable: - - if: SOC_LP_CORE_SUPPORT_I2C == 1 and SOC_DEEP_SLEEP_SUPPORTED == 1 + - if: SOC_LP_CORE_SUPPORT_I2C == 1 and (SOC_DEEP_SLEEP_SUPPORTED == 1 and SOC_LP_CORE_SUPPORTED == 1) <<: *ulp_default_depends depends_components+: - esp_hal_i2c