Skip to content

Commit 93cdad7

Browse files
committed
feat(esp_hw_support): support esp32h21 retention link software trigger
1 parent 727d0a6 commit 93cdad7

File tree

9 files changed

+124
-17
lines changed

9 files changed

+124
-17
lines changed

components/esp_hw_support/CMakeLists.txt

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,6 @@ if(NOT non_os_build)
2828
"periph_ctrl.c"
2929
"revision.c"
3030
"rtc_module.c"
31-
"sleep_modem.c"
32-
"sleep_modes.c"
33-
"sleep_console.c"
34-
"sleep_usb.c"
35-
"sleep_gpio.c"
36-
"sleep_event.c"
3731
"regi2c_ctrl.c"
3832
"esp_gpio_reserve.c"
3933
"sar_periph_ctrl_common.c"
@@ -49,14 +43,23 @@ if(NOT non_os_build)
4943
if(CONFIG_SOC_ADC_SUPPORTED)
5044
list(APPEND srcs "adc_share_hw_ctrl.c")
5145
endif()
52-
5346
if(CONFIG_SOC_ISP_SHARE_CSI_BRG)
5447
list(APPEND srcs "mipi_csi_share_hw_ctrl.c")
5548
endif()
5649
if(CONFIG_SOC_PAU_SUPPORTED)
57-
list(APPEND srcs "sleep_retention.c"
58-
"sleep_system_peripheral.c"
59-
)
50+
list(APPEND srcs "sleep_retention.c")
51+
endif()
52+
if(CONFIG_SOC_LIGHT_SLEEP_SUPPORTED)
53+
list(APPEND srcs "sleep_modem.c"
54+
"sleep_modes.c"
55+
"sleep_console.c"
56+
"sleep_usb.c"
57+
"sleep_gpio.c"
58+
"sleep_event.c"
59+
)
60+
if(CONFIG_SOC_PAU_SUPPORTED)
61+
list(APPEND srcs "sleep_system_peripheral.c")
62+
endif()
6063
endif()
6164

6265
# [refactor-todo]

components/esp_hw_support/lowpower/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
idf_build_get_property(non_os_build NON_OS_BUILD)
22

3-
if(non_os_build)
3+
if(non_os_build OR NOT CONFIG_SOC_LIGHT_SLEEP_SUPPORTED)
44
return()
55
endif()
66

components/esp_hw_support/sleep_retention.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -514,7 +514,9 @@ static void sleep_retention_entries_destroy(sleep_retention_module_t module)
514514
}
515515
if (created_modules == 0) {
516516
sleep_retention_entries_check_and_distroy_final_default();
517+
#if SOC_LIGHT_SLEEP_SUPPORTED
517518
pmu_sleep_disable_regdma_backup();
519+
#endif
518520
memset((void *)s_retention.lists, 0, sizeof(s_retention.lists));
519521
s_retention.highpri = (uint8_t)-1;
520522
}
@@ -641,8 +643,12 @@ esp_err_t sleep_retention_entries_create(const sleep_retention_entries_config_t
641643
if (err) goto error;
642644
err = sleep_retention_entries_create_wrapper(retent, num, priority, module);
643645
if (err) goto error;
646+
#if SOC_LIGHT_SLEEP_SUPPORTED
644647
pmu_sleep_enable_regdma_backup();
648+
#endif
649+
#if SOC_LIGHT_SLEEP_SUPPORTED && SOC_DEEP_SLEEP_SUPPORTED
645650
ESP_ERROR_CHECK(esp_deep_sleep_register_hook(&pmu_sleep_disable_regdma_backup));
651+
#endif
646652

647653
error:
648654
return err;

components/esp_hw_support/test_apps/.build-test-rules.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ components/esp_hw_support/test_apps/rtc_power_modes:
4444

4545
components/esp_hw_support/test_apps/sleep_retention:
4646
enable:
47-
- if: SOC_PAU_SUPPORTED == 1 and CONFIG_NAME != "xip_psram"
48-
- if: SOC_PAU_SUPPORTED == 1 and (SOC_SPIRAM_XIP_SUPPORTED == 1 and CONFIG_NAME == "xip_psram")
47+
- if: SOC_PAU_SUPPORTED == 1 and SOC_LIGHT_SLEEP_SUPPORTED == 1 and CONFIG_NAME != "xip_psram"
48+
- if: SOC_PAU_SUPPORTED == 1 and SOC_LIGHT_SLEEP_SUPPORTED == 1 and (SOC_SPIRAM_XIP_SUPPORTED == 1 and CONFIG_NAME == "xip_psram")
4949

5050
components/esp_hw_support/test_apps/vad_wakeup:
5151
disable:

components/soc/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ if(CONFIG_SOC_SDIO_SLAVE_SUPPORTED)
165165
list(APPEND srcs "${target_folder}/sdio_slave_periph.c")
166166
endif()
167167

168-
if(CONFIG_SOC_PAU_SUPPORTED)
168+
if(CONFIG_SOC_PAU_SUPPORTED AND CONFIG_SOC_LIGHT_SLEEP_SUPPORTED)
169169
list(APPEND srcs "${target_folder}/system_retention_periph.c")
170170
endif()
171171

components/soc/esp32h21/include/soc/Kconfig.soc_caps.in

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ config SOC_SPI_FLASH_SUPPORTED
4343
bool
4444
default y
4545

46+
config SOC_PAU_SUPPORTED
47+
bool
48+
default y
49+
4650
config SOC_XTAL_SUPPORT_32M
4751
bool
4852
default y
@@ -671,6 +675,10 @@ config SOC_PM_PAU_LINK_NUM
671675
int
672676
default 5
673677

678+
config SOC_PM_RETENTION_MODULE_NUM
679+
int
680+
default 32
681+
674682
config SOC_PM_PAU_REGDMA_LINK_CONFIGURABLE
675683
bool
676684
default y
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#pragma once
8+
9+
#include <stdint.h>
10+
#include "soc_caps.h"
11+
12+
#ifdef __cplusplus
13+
extern "C" {
14+
#endif
15+
16+
typedef enum periph_retention_module {
17+
SLEEP_RETENTION_MODULE_MIN = 0,
18+
SLEEP_RETENTION_MODULE_NULL = SLEEP_RETENTION_MODULE_MIN, /* This module is for all peripherals that can't survive from PD_TOP to call init only. Shouldn't have any dependency. */
19+
/* clock module, which includes system and modem */
20+
SLEEP_RETENTION_MODULE_CLOCK_SYSTEM = 1,
21+
SLEEP_RETENTION_MODULE_CLOCK_MODEM = 2,
22+
/* digital peripheral module, which includes Interrupt Matrix, HP_SYSTEM,
23+
* TEE, APM, UART, IOMUX, SPIMEM, SysTimer, etc.. */
24+
SLEEP_RETENTION_MODULE_SYS_PERIPH = 3,
25+
/* Timer Group by target*/
26+
SLEEP_RETENTION_MODULE_TG0_WDT = 4,
27+
SLEEP_RETENTION_MODULE_TG1_WDT = 5,
28+
SLEEP_RETENTION_MODULE_TG0_TIMER0 = 6,
29+
SLEEP_RETENTION_MODULE_TG1_TIMER0 = 7,
30+
/* GDMA by channel */
31+
SLEEP_RETENTION_MODULE_GDMA_CH0 = 8,
32+
SLEEP_RETENTION_MODULE_GDMA_CH1 = 9,
33+
SLEEP_RETENTION_MODULE_GDMA_CH2 = 10,
34+
/* MISC Peripherals */
35+
SLEEP_RETENTION_MODULE_ADC = 11,
36+
SLEEP_RETENTION_MODULE_I2C0 = 12,
37+
SLEEP_RETENTION_MODULE_I2C1 = 13,
38+
SLEEP_RETENTION_MODULE_RMT0 = 14,
39+
SLEEP_RETENTION_MODULE_UART0 = 15,
40+
SLEEP_RETENTION_MODULE_UART1 = 16,
41+
SLEEP_RETENTION_MODULE_I2S0 = 17,
42+
SLEEP_RETENTION_MODULE_ETM0 = 18,
43+
SLEEP_RETENTION_MODULE_TEMP_SENSOR = 19,
44+
SLEEP_RETENTION_MODULE_TWAI0 = 20,
45+
SLEEP_RETENTION_MODULE_PARLIO0 = 21,
46+
SLEEP_RETENTION_MODULE_GPSPI2 = 22,
47+
SLEEP_RETENTION_MODULE_LEDC = 23,
48+
SLEEP_RETENTION_MODULE_PCNT0 = 24,
49+
SLEEP_RETENTION_MODULE_MCPWM0 = 25,
50+
51+
/* Modem module, which includes BLE and 802.15.4 */
52+
SLEEP_RETENTION_MODULE_BLE_MAC = 28,
53+
SLEEP_RETENTION_MODULE_BT_BB = 29,
54+
SLEEP_RETENTION_MODULE_802154_MAC = 30,
55+
56+
SLEEP_RETENTION_MODULE_MAX = SOC_PM_RETENTION_MODULE_NUM - 1
57+
} periph_retention_module_t;
58+
59+
#define is_top_domain_module(m) \
60+
( ((m) == SLEEP_RETENTION_MODULE_NULL) ? true \
61+
: ((m) == SLEEP_RETENTION_MODULE_CLOCK_SYSTEM) ? true \
62+
: ((m) == SLEEP_RETENTION_MODULE_SYS_PERIPH) ? true \
63+
: ((m) == SLEEP_RETENTION_MODULE_TG0_WDT) ? true \
64+
: ((m) == SLEEP_RETENTION_MODULE_TG1_WDT) ? true \
65+
: ((m) == SLEEP_RETENTION_MODULE_TG0_TIMER0) ? true \
66+
: ((m) == SLEEP_RETENTION_MODULE_TG1_TIMER0) ? true \
67+
: ((m) == SLEEP_RETENTION_MODULE_GDMA_CH0) ? true \
68+
: ((m) == SLEEP_RETENTION_MODULE_GDMA_CH1) ? true \
69+
: ((m) == SLEEP_RETENTION_MODULE_GDMA_CH2) ? true \
70+
: ((m) == SLEEP_RETENTION_MODULE_ADC) ? true \
71+
: ((m) == SLEEP_RETENTION_MODULE_I2C0) ? true \
72+
: ((m) == SLEEP_RETENTION_MODULE_I2C1) ? true \
73+
: ((m) == SLEEP_RETENTION_MODULE_RMT0) ? true \
74+
: ((m) == SLEEP_RETENTION_MODULE_UART0) ? true \
75+
: ((m) == SLEEP_RETENTION_MODULE_UART1) ? true \
76+
: ((m) == SLEEP_RETENTION_MODULE_I2S0) ? true \
77+
: ((m) == SLEEP_RETENTION_MODULE_ETM0) ? true \
78+
: ((m) == SLEEP_RETENTION_MODULE_TEMP_SENSOR) ? true \
79+
: ((m) == SLEEP_RETENTION_MODULE_TWAI0) ? true \
80+
: ((m) == SLEEP_RETENTION_MODULE_PARLIO0) ? true \
81+
: ((m) == SLEEP_RETENTION_MODULE_GPSPI2) ? true \
82+
: ((m) == SLEEP_RETENTION_MODULE_LEDC) ? true \
83+
: ((m) == SLEEP_RETENTION_MODULE_PCNT0) ? true \
84+
: ((m) == SLEEP_RETENTION_MODULE_MCPWM0) ? true \
85+
: false)
86+
87+
#ifdef __cplusplus
88+
}
89+
#endif

components/soc/esp32h21/include/soc/soc_caps.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
// #define SOC_RMT_SUPPORTED 1 //TODO: [ESP32H21] IDF-11622
7575
// #define SOC_AES_SUPPORTED 1 //TODO: [ESP32H21] IDF-11504
7676
// #define SOC_SDIO_SLAVE_SUPPORTED 1
77-
// #define SOC_PAU_SUPPORTED 1
77+
#define SOC_PAU_SUPPORTED 1
7878
// #define SOC_LIGHT_SLEEP_SUPPORTED 1 //TODO: [ESP32H21] IDF-11517, IDF-11520
7979
// #define SOC_DEEP_SLEEP_SUPPORTED 1 //TODO: [ESP32H21] IDF-11515
8080
// #define SOC_MODEM_CLOCK_SUPPORTED 1
@@ -529,6 +529,7 @@
529529
#define SOC_PM_SUPPORT_VDDSDIO_PD (1)
530530
#define SOC_PM_SUPPORT_TOP_PD (1)
531531
#define SOC_PM_PAU_LINK_NUM (5)
532+
#define SOC_PM_RETENTION_MODULE_NUM (32)
532533
#define SOC_PM_PAU_REGDMA_LINK_CONFIGURABLE (1)
533534
#define SOC_PM_CPU_RETENTION_BY_SW (1)
534535
#define SOC_PM_MODEM_RETENTION_BY_REGDMA (1)

components/soc/include/soc/ledc_periph.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ extern const ledc_signal_conn_t ledc_periph_signal[2];
3131
extern const ledc_signal_conn_t ledc_periph_signal[1];
3232
#endif
3333

34-
#if SOC_PAU_SUPPORTED
34+
#if SOC_PAU_SUPPORTED && SOC_LEDC_SUPPORT_SLEEP_RETENTION
3535

3636
#if SOC_LIGHT_SLEEP_SUPPORTED
3737
#if SOC_PHY_SUPPORTED

0 commit comments

Comments
 (0)