From 04ebe9e24fb36cc2a1181b66cbffae5c851815d9 Mon Sep 17 00:00:00 2001 From: wuzhenghui Date: Mon, 22 Dec 2025 16:03:27 +0800 Subject: [PATCH] feat(esp_hal_pmu): move pau_hal driver into esp_hal_pmu component --- components/esp_hal_pmu/CMakeLists.txt | 5 +++++ components/esp_hal_pmu/README.md | 16 +++++++++++++--- .../esp32c5/include/hal/pau_ll.h | 1 - .../{hal => esp_hal_pmu}/esp32c5/pau_hal.c | 0 .../esp32c6/include/hal/pau_ll.h | 0 .../{hal => esp_hal_pmu}/esp32c6/pau_hal.c | 0 .../esp32c61/include/hal/pau_ll.h | 0 .../{hal => esp_hal_pmu}/esp32c61/pau_hal.c | 0 .../esp32h2/include/hal/pau_ll.h | 0 .../{hal => esp_hal_pmu}/esp32h2/pau_hal.c | 0 .../esp32h21/include/hal/pau_ll.h | 0 .../{hal => esp_hal_pmu}/esp32h21/pau_hal.c | 0 .../esp32h4/include/hal/pau_ll.h | 0 .../{hal => esp_hal_pmu}/esp32h4/pau_hal.c | 0 .../esp32p4/include/hal/pau_ll.h | 0 .../{hal => esp_hal_pmu}/esp32p4/pau_hal.c | 0 .../{hal => esp_hal_pmu}/include/hal/pau_hal.h | 1 - .../{hal => esp_hal_pmu}/include/hal/pau_types.h | 0 components/hal/CMakeLists.txt | 4 ---- 19 files changed, 18 insertions(+), 9 deletions(-) rename components/{hal => esp_hal_pmu}/esp32c5/include/hal/pau_ll.h (99%) rename components/{hal => esp_hal_pmu}/esp32c5/pau_hal.c (100%) rename components/{hal => esp_hal_pmu}/esp32c6/include/hal/pau_ll.h (100%) rename components/{hal => esp_hal_pmu}/esp32c6/pau_hal.c (100%) rename components/{hal => esp_hal_pmu}/esp32c61/include/hal/pau_ll.h (100%) rename components/{hal => esp_hal_pmu}/esp32c61/pau_hal.c (100%) rename components/{hal => esp_hal_pmu}/esp32h2/include/hal/pau_ll.h (100%) rename components/{hal => esp_hal_pmu}/esp32h2/pau_hal.c (100%) rename components/{hal => esp_hal_pmu}/esp32h21/include/hal/pau_ll.h (100%) rename components/{hal => esp_hal_pmu}/esp32h21/pau_hal.c (100%) rename components/{hal => esp_hal_pmu}/esp32h4/include/hal/pau_ll.h (100%) rename components/{hal => esp_hal_pmu}/esp32h4/pau_hal.c (100%) rename components/{hal => esp_hal_pmu}/esp32p4/include/hal/pau_ll.h (100%) rename components/{hal => esp_hal_pmu}/esp32p4/pau_hal.c (100%) rename components/{hal => esp_hal_pmu}/include/hal/pau_hal.h (99%) rename components/{hal => esp_hal_pmu}/include/hal/pau_types.h (100%) diff --git a/components/esp_hal_pmu/CMakeLists.txt b/components/esp_hal_pmu/CMakeLists.txt index 875d338cf9..75f9e18bb9 100644 --- a/components/esp_hal_pmu/CMakeLists.txt +++ b/components/esp_hal_pmu/CMakeLists.txt @@ -16,6 +16,11 @@ if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/${target}/rtc_cntl_hal.c") list(APPEND srcs "${target}/rtc_cntl_hal.c") endif() +# Chips with PAU (Power Assist Unit) peripheral +if(CONFIG_SOC_PAU_SUPPORTED) + list(APPEND srcs "${target}/pau_hal.c") +endif() + idf_component_register(SRCS ${srcs} INCLUDE_DIRS ${public_include} REQUIRES soc hal esp_rom diff --git a/components/esp_hal_pmu/README.md b/components/esp_hal_pmu/README.md index 090030970d..b9912eda53 100644 --- a/components/esp_hal_pmu/README.md +++ b/components/esp_hal_pmu/README.md @@ -7,21 +7,23 @@ The `esp_hal_pmu` component provides a **Hardware Abstraction Layer** for Power Management Unit (PMU) and legacy RTC Control (RTC_CNTL) peripherals across ESP-IDF supported targets. This HAL enables unified power management operations including sleep mode control, power domain management, wakeup configuration, and retention control across different ESP chip families. -The component consolidates power management functionality from two different peripheral implementations: +The component consolidates power management functionality from three different peripheral implementations: - **PMU**: Modern power management unit in newer ESP chips - **RTC_CNTL**: Legacy RTC control peripheral in older ESP chips +- **PAU**: Power Assist Unit for register retention and backup/restore operations ## Architecture The HAL architecture consists of two primary layers: -1. **HAL Layer (Upper)**: Defines the operational sequences and data structures required to interact with PMU/RTC_CNTL peripherals, including: +1. **HAL Layer (Upper)**: Defines the operational sequences and data structures required to interact with PMU/RTC_CNTL/PAU peripherals, including: - Power domain configuration and control - Sleep mode management - Wakeup source configuration - Retention control (CPU, tagmem) - Power-up/down wait cycle configuration - Backup enable/disable operations + - REGDMA link configuration and control 2. **Low-Level Layer (Bottom)**: Acts as a translation layer between the HAL and the register definitions in the `soc` component, handling: - Register access abstractions @@ -53,10 +55,18 @@ The HAL architecture consists of two primary layers: - Sleep-to-modem backup enable/disable - Modem-to-active backup enable/disable +### REGDMA (Register DMA) Support +- REGDMA entry link address configuration +- REGDMA modem link control (backup/restore) +- REGDMA system link control +- REGDMA extra link control +- REGDMA timeout configuration +- REGDMA clock configuration + ## Usage This component is primarily used by ESP-IDF system services such as: - **esp_pm**: Power management framework -- **esp_hw_support**: Hardware support layer for sleep modes and power management +- **esp_hw_support**: Hardware support layer for sleep modes, power management, and register retention - **ulp**: Ultra-low-power coprocessor support For advanced developers implementing custom power management solutions, the HAL functions can be used directly. However, please note that the interfaces provided by this component are internal to ESP-IDF and are subject to change. diff --git a/components/hal/esp32c5/include/hal/pau_ll.h b/components/esp_hal_pmu/esp32c5/include/hal/pau_ll.h similarity index 99% rename from components/hal/esp32c5/include/hal/pau_ll.h rename to components/esp_hal_pmu/esp32c5/include/hal/pau_ll.h index 8235ddf0fd..877bb992b4 100644 --- a/components/hal/esp32c5/include/hal/pau_ll.h +++ b/components/esp_hal_pmu/esp32c5/include/hal/pau_ll.h @@ -104,7 +104,6 @@ static inline void pau_ll_clear_regdma_backup_error_intr_state(pau_dev_t *dev) dev->int_clr.val = 0x2; } - /** * @brief Set the maximum number of linked lists supported by REGDMA * @param count: the maximum number of regdma link diff --git a/components/hal/esp32c5/pau_hal.c b/components/esp_hal_pmu/esp32c5/pau_hal.c similarity index 100% rename from components/hal/esp32c5/pau_hal.c rename to components/esp_hal_pmu/esp32c5/pau_hal.c diff --git a/components/hal/esp32c6/include/hal/pau_ll.h b/components/esp_hal_pmu/esp32c6/include/hal/pau_ll.h similarity index 100% rename from components/hal/esp32c6/include/hal/pau_ll.h rename to components/esp_hal_pmu/esp32c6/include/hal/pau_ll.h diff --git a/components/hal/esp32c6/pau_hal.c b/components/esp_hal_pmu/esp32c6/pau_hal.c similarity index 100% rename from components/hal/esp32c6/pau_hal.c rename to components/esp_hal_pmu/esp32c6/pau_hal.c diff --git a/components/hal/esp32c61/include/hal/pau_ll.h b/components/esp_hal_pmu/esp32c61/include/hal/pau_ll.h similarity index 100% rename from components/hal/esp32c61/include/hal/pau_ll.h rename to components/esp_hal_pmu/esp32c61/include/hal/pau_ll.h diff --git a/components/hal/esp32c61/pau_hal.c b/components/esp_hal_pmu/esp32c61/pau_hal.c similarity index 100% rename from components/hal/esp32c61/pau_hal.c rename to components/esp_hal_pmu/esp32c61/pau_hal.c diff --git a/components/hal/esp32h2/include/hal/pau_ll.h b/components/esp_hal_pmu/esp32h2/include/hal/pau_ll.h similarity index 100% rename from components/hal/esp32h2/include/hal/pau_ll.h rename to components/esp_hal_pmu/esp32h2/include/hal/pau_ll.h diff --git a/components/hal/esp32h2/pau_hal.c b/components/esp_hal_pmu/esp32h2/pau_hal.c similarity index 100% rename from components/hal/esp32h2/pau_hal.c rename to components/esp_hal_pmu/esp32h2/pau_hal.c diff --git a/components/hal/esp32h21/include/hal/pau_ll.h b/components/esp_hal_pmu/esp32h21/include/hal/pau_ll.h similarity index 100% rename from components/hal/esp32h21/include/hal/pau_ll.h rename to components/esp_hal_pmu/esp32h21/include/hal/pau_ll.h diff --git a/components/hal/esp32h21/pau_hal.c b/components/esp_hal_pmu/esp32h21/pau_hal.c similarity index 100% rename from components/hal/esp32h21/pau_hal.c rename to components/esp_hal_pmu/esp32h21/pau_hal.c diff --git a/components/hal/esp32h4/include/hal/pau_ll.h b/components/esp_hal_pmu/esp32h4/include/hal/pau_ll.h similarity index 100% rename from components/hal/esp32h4/include/hal/pau_ll.h rename to components/esp_hal_pmu/esp32h4/include/hal/pau_ll.h diff --git a/components/hal/esp32h4/pau_hal.c b/components/esp_hal_pmu/esp32h4/pau_hal.c similarity index 100% rename from components/hal/esp32h4/pau_hal.c rename to components/esp_hal_pmu/esp32h4/pau_hal.c diff --git a/components/hal/esp32p4/include/hal/pau_ll.h b/components/esp_hal_pmu/esp32p4/include/hal/pau_ll.h similarity index 100% rename from components/hal/esp32p4/include/hal/pau_ll.h rename to components/esp_hal_pmu/esp32p4/include/hal/pau_ll.h diff --git a/components/hal/esp32p4/pau_hal.c b/components/esp_hal_pmu/esp32p4/pau_hal.c similarity index 100% rename from components/hal/esp32p4/pau_hal.c rename to components/esp_hal_pmu/esp32p4/pau_hal.c diff --git a/components/hal/include/hal/pau_hal.h b/components/esp_hal_pmu/include/hal/pau_hal.h similarity index 99% rename from components/hal/include/hal/pau_hal.h rename to components/esp_hal_pmu/include/hal/pau_hal.h index 5311e6bc61..522889a85b 100644 --- a/components/hal/include/hal/pau_hal.h +++ b/components/esp_hal_pmu/include/hal/pau_hal.h @@ -17,7 +17,6 @@ extern "C" { #include "hal/pau_ll.h" #include "hal/pau_types.h" - typedef struct { pau_dev_t *dev; } pau_hal_context_t; diff --git a/components/hal/include/hal/pau_types.h b/components/esp_hal_pmu/include/hal/pau_types.h similarity index 100% rename from components/hal/include/hal/pau_types.h rename to components/esp_hal_pmu/include/hal/pau_types.h diff --git a/components/hal/CMakeLists.txt b/components/hal/CMakeLists.txt index aea2cf0a5b..c2ff23868e 100644 --- a/components/hal/CMakeLists.txt +++ b/components/hal/CMakeLists.txt @@ -124,10 +124,6 @@ elseif(NOT BOOTLOADER_BUILD) list(APPEND srcs "${target}/modem_clock_hal.c") endif() - if(CONFIG_SOC_PAU_SUPPORTED) - list(APPEND srcs "${target}/pau_hal.c") - endif() - if(CONFIG_SOC_BOD_SUPPORTED) list(APPEND srcs "brownout_hal.c") endif()