Skip to content

Commit 81e8b75

Browse files
committed
Merge branch 'feat/support_esp32h21_pau' into 'master'
feat(esp_hw_support): support esp32h21 PAU Closes PM-347 See merge request espressif/esp-idf!37065
2 parents 79ee092 + 93cdad7 commit 81e8b75

File tree

14 files changed

+510
-25
lines changed

14 files changed

+510
-25
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:
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
// The LL layer for ESP32-H21 LP_AON register operations
8+
9+
#pragma once
10+
11+
#include <stdlib.h>
12+
#include "soc/soc.h"
13+
#include "soc/lp_aon_struct.h"
14+
#include "hal/misc.h"
15+
#include "esp32h21/rom/rtc.h"
16+
17+
18+
#ifdef __cplusplus
19+
extern "C" {
20+
#endif
21+
22+
/**
23+
* @brief Get ext1 wakeup source status
24+
* @return The lower 8 bits of the returned value are the bitmap of
25+
* the wakeup source status, bit 0~7 corresponds to LP_IO 0~7
26+
*/
27+
static inline uint32_t lp_aon_ll_ext1_get_wakeup_status(void)
28+
{
29+
return HAL_FORCE_READ_U32_REG_FIELD(LP_AON.ext_wakeup_cntl, aon_ext_wakeup_status);
30+
}
31+
32+
/**
33+
* @brief Clear the ext1 wakeup source status
34+
*/
35+
static inline void lp_aon_ll_ext1_clear_wakeup_status(void)
36+
{
37+
HAL_FORCE_MODIFY_U32_REG_FIELD(LP_AON.ext_wakeup_cntl, aon_ext_wakeup_status_clr, 1);
38+
}
39+
40+
/**
41+
* @brief Set the wake-up LP_IO of the ext1 wake-up source
42+
* @param io_mask wakeup LP_IO bitmap, bit 0~7 corresponds to LP_IO 0~7
43+
* @param level_mask LP_IO wakeup level bitmap, bit 0~7 corresponds to LP_IO 0~7 wakeup level
44+
* each bit's corresponding position is set to 0, the wakeup level will be low
45+
* on the contrary, each bit's corresponding position is set to 1, the wakeup
46+
* level will be high
47+
*/
48+
static inline void lp_aon_ll_ext1_set_wakeup_pins(uint32_t io_mask, uint32_t level_mask)
49+
{
50+
HAL_FORCE_MODIFY_U32_REG_FIELD(LP_AON.ext_wakeup_cntl, aon_ext_wakeup_sel, io_mask);
51+
HAL_FORCE_MODIFY_U32_REG_FIELD(LP_AON.ext_wakeup_cntl, aon_ext_wakeup_lv, level_mask);
52+
}
53+
54+
/**
55+
* @brief Clear all ext1 wakup-source setting
56+
*/
57+
static inline void lp_aon_ll_ext1_clear_wakeup_pins(void)
58+
{
59+
HAL_FORCE_MODIFY_U32_REG_FIELD(LP_AON.ext_wakeup_cntl, aon_ext_wakeup_sel, 0);
60+
}
61+
62+
/**
63+
* @brief Get ext1 wakeup source setting
64+
* @return The lower 8 bits of the returned value are the bitmap of
65+
* the wakeup source status, bit 0~7 corresponds to LP_IO 0~7
66+
*/
67+
static inline uint32_t lp_aon_ll_ext1_get_wakeup_pins(void)
68+
{
69+
return HAL_FORCE_READ_U32_REG_FIELD(LP_AON.ext_wakeup_cntl, aon_ext_wakeup_sel);
70+
}
71+
72+
73+
/**
74+
* @brief ROM obtains the wake-up type through LP_AON_STORE9_REG[0].
75+
* Set the flag to inform
76+
* @param true: deepsleep false: lightsleep
77+
*/
78+
static inline void lp_aon_ll_inform_wakeup_type(bool dslp)
79+
{
80+
if (dslp) {
81+
REG_SET_BIT(RTC_SLEEP_MODE_REG, BIT(0)); /* Tell rom to run deep sleep wake stub */
82+
83+
} else {
84+
REG_CLR_BIT(RTC_SLEEP_MODE_REG, BIT(0)); /* Tell rom to run light sleep wake stub */
85+
}
86+
}
87+
88+
/**
89+
* @brief Set the maximum number of linked lists supported by REGDMA
90+
* @param count: the maximum number of regdma link
91+
*/
92+
static inline void lp_aon_ll_set_regdma_link_count(int count)
93+
{
94+
HAL_FORCE_MODIFY_U32_REG_FIELD(LP_AON.backup_dma_cfg0, aon_branch_link_length_aon, count);
95+
}
96+
97+
/**
98+
* @brief Set the maximum number of times a single linked list can run for REGDMA. If a linked list continuously reads in a loop
99+
* for some reason and the execution count exceeds this configured number, a timeout will be triggered.
100+
* @param count: the maximum number of loop
101+
*/
102+
static inline void lp_aon_ll_set_regdma_link_loop_threshold(int count)
103+
{
104+
HAL_FORCE_MODIFY_U32_REG_FIELD(LP_AON.backup_dma_cfg1, aon_link_work_tout_thres_aon, count);
105+
}
106+
107+
/**
108+
* @brief Set the timeout duration for accessing registers. If REGDMA encounters bus-related issues while accessing
109+
* registers and gets stuck on the bus, a timeout will be triggered.
110+
* @param count: the maximum number of time
111+
*/
112+
static inline void lp_aon_ll_set_regdma_link_reg_access_tout_threshold(int count)
113+
{
114+
HAL_FORCE_MODIFY_U32_REG_FIELD(LP_AON.backup_dma_cfg1, aon_link_backup_tout_thres_aon, count);
115+
}
116+
117+
/**
118+
* @brief Set the regdma_link_addr
119+
* @param addr: the addr of regdma_link
120+
*/
121+
static inline void lp_aon_ll_set_regdma_link_addr(uint32_t addr)
122+
{
123+
HAL_FORCE_MODIFY_U32_REG_FIELD(LP_AON.backup_dma_cfg2, aon_link_addr_aon, addr);
124+
}
125+
126+
static inline void lp_aon_ll_set_regdma_link_wait_retry_count(int count)
127+
{
128+
HAL_FORCE_MODIFY_U32_REG_FIELD(LP_AON.backup_dma_cfg1, aon_link_wait_tout_thres_aon, count);
129+
}
130+
131+
static inline void lp_aon_ll_set_regdma_link_wait_read_interval(int interval)
132+
{
133+
HAL_FORCE_MODIFY_U32_REG_FIELD(LP_AON.backup_dma_cfg0, aon_read_interval_aon, interval);
134+
}
135+
136+
#ifdef __cplusplus
137+
}
138+
#endif
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
// The LL layer for ESP32-H21 PAU(Power Assist Unit) register operations
8+
9+
#pragma once
10+
11+
#include <stdlib.h>
12+
#include <stdbool.h>
13+
#include "soc/soc.h"
14+
#include "soc/pau_reg.h"
15+
#include "soc/pau_struct.h"
16+
#include "soc/pcr_struct.h"
17+
#include "hal/pau_types.h"
18+
#include "hal/assert.h"
19+
20+
#ifdef __cplusplus
21+
extern "C" {
22+
#endif
23+
24+
static inline void pau_ll_enable_bus_clock(bool enable)
25+
{
26+
if (enable) {
27+
PCR.regdma_conf.regdma_clk_en = 1;
28+
PCR.regdma_conf.regdma_rst_en = 0;
29+
} else {
30+
PCR.regdma_conf.regdma_clk_en = 0;
31+
PCR.regdma_conf.regdma_rst_en = 1;
32+
}
33+
}
34+
35+
static inline uint32_t pau_ll_get_regdma_backup_flow_error(pau_dev_t *dev)
36+
{
37+
return dev->regdma_conf.flow_err;
38+
}
39+
40+
static inline void pau_ll_select_regdma_entry_link(pau_dev_t *dev, int link)
41+
{
42+
dev->regdma_conf.link_sel = link;
43+
}
44+
45+
static inline void pau_ll_set_regdma_entry_link_backup_direction(pau_dev_t *dev, bool to_mem)
46+
{
47+
dev->regdma_conf.to_mem = to_mem ? 1 : 0;
48+
}
49+
50+
static inline void pau_ll_set_regdma_entry_link_backup_start_enable(pau_dev_t *dev)
51+
{
52+
dev->regdma_conf.start = 1;
53+
}
54+
55+
static inline void pau_ll_set_regdma_entry_link_backup_start_disable(pau_dev_t *dev)
56+
{
57+
dev->regdma_conf.start = 0;
58+
}
59+
60+
static inline void pau_ll_set_regdma_select_wifimac_link(pau_dev_t *dev)
61+
{
62+
dev->regdma_conf.sel_mac = 1;
63+
}
64+
65+
static inline void pau_ll_set_regdma_deselect_wifimac_link(pau_dev_t *dev)
66+
{
67+
dev->regdma_conf.sel_mac = 0;
68+
}
69+
70+
static inline void pau_ll_set_regdma_wifimac_link_backup_direction(pau_dev_t *dev, bool to_mem)
71+
{
72+
dev->regdma_conf.to_mem_mac = to_mem ? 1 : 0;
73+
}
74+
75+
static inline void pau_ll_set_regdma_wifimac_link_backup_start_enable(pau_dev_t *dev)
76+
{
77+
dev->regdma_conf.start_mac = 1;
78+
}
79+
80+
static inline void pau_ll_set_regdma_wifimac_link_backup_start_disable(pau_dev_t *dev)
81+
{
82+
dev->regdma_conf.start_mac = 0;
83+
}
84+
85+
static inline uint32_t pau_ll_get_regdma_current_link_addr(pau_dev_t *dev)
86+
{
87+
return dev->regdma_current_link_addr.val;
88+
}
89+
90+
static inline uint32_t pau_ll_get_regdma_backup_addr(pau_dev_t *dev)
91+
{
92+
return dev->regdma_peri_addr.val;
93+
}
94+
95+
static inline uint32_t pau_ll_get_regdma_memory_addr(pau_dev_t *dev)
96+
{
97+
return dev->regdma_mem_addr.val;
98+
}
99+
100+
static inline uint32_t pau_ll_get_regdma_intr_raw_signal(pau_dev_t *dev)
101+
{
102+
return dev->int_raw.val;
103+
}
104+
105+
static inline uint32_t pau_ll_get_regdma_intr_status(pau_dev_t *dev)
106+
{
107+
return dev->int_st.val;
108+
}
109+
110+
static inline void pau_ll_set_regdma_backup_done_intr_enable(pau_dev_t *dev)
111+
{
112+
dev->int_ena.done_int_ena = 1;
113+
}
114+
115+
static inline void pau_ll_set_regdma_backup_done_intr_disable(pau_dev_t *dev)
116+
{
117+
dev->int_ena.done_int_ena = 0;
118+
}
119+
120+
static inline void pau_ll_set_regdma_backup_error_intr_enable(pau_dev_t *dev)
121+
{
122+
dev->int_ena.error_int_ena = 1;
123+
}
124+
125+
static inline void pau_ll_set_regdma_backup_error_intr_disable(pau_dev_t *dev)
126+
{
127+
dev->int_ena.error_int_ena = 0;
128+
}
129+
130+
static inline void pau_ll_clear_regdma_backup_done_intr_state(pau_dev_t *dev)
131+
{
132+
dev->int_clr.done_int_clr = 1;
133+
}
134+
135+
static inline void pau_ll_clear_regdma_backup_error_intr_state(pau_dev_t *dev)
136+
{
137+
dev->int_clr.error_int_clr = 1;
138+
}
139+
140+
#ifdef __cplusplus
141+
}
142+
#endif

0 commit comments

Comments
 (0)