From 39ea6efc7c4896d5c47b75f19df75edaa1a637d5 Mon Sep 17 00:00:00 2001 From: "C.S.M" Date: Wed, 24 Dec 2025 11:43:14 +0800 Subject: [PATCH] refactor(bod): Move bod hal to pmu hal component --- components/esp_hal_pmu/CMakeLists.txt | 8 ++++++++ components/{hal => esp_hal_pmu}/brownout_hal.c | 0 .../esp32/include/hal/brownout_ll.h | 1 - .../esp32c2}/include/hal/brownout_ll.h | 0 .../esp32c3/include/hal/brownout_ll.h | 0 .../esp32c5/include/hal/brownout_ll.h | 0 .../esp32c6/include/hal/brownout_ll.h | 0 .../esp32c61/include/hal/brownout_ll.h | 0 .../esp32h2/include/hal/brownout_ll.h | 0 .../esp32h2/include/hal/vbat_ll.h | 1 - .../esp32p4/include/hal/brownout_ll.h | 0 .../esp32p4/include/hal/ldo_ll.h | 0 .../esp32p4/include/hal/vbat_ll.h | 5 ++--- .../esp32s2/include/hal/brownout_ll.h | 1 - .../esp32s3}/include/hal/brownout_ll.h | 1 - .../include/hal/brownout_hal.h | 1 - .../{hal => esp_hal_pmu}/include/hal/vbat_hal.h | 0 components/{hal => esp_hal_pmu}/vbat_hal.c | 0 components/hal/CMakeLists.txt | 14 +------------- 19 files changed, 11 insertions(+), 21 deletions(-) rename components/{hal => esp_hal_pmu}/brownout_hal.c (100%) rename components/{hal => esp_hal_pmu}/esp32/include/hal/brownout_ll.h (99%) rename components/{hal/esp32s3 => esp_hal_pmu/esp32c2}/include/hal/brownout_ll.h (100%) rename components/{hal => esp_hal_pmu}/esp32c3/include/hal/brownout_ll.h (100%) rename components/{hal => esp_hal_pmu}/esp32c5/include/hal/brownout_ll.h (100%) rename components/{hal => esp_hal_pmu}/esp32c6/include/hal/brownout_ll.h (100%) rename components/{hal => esp_hal_pmu}/esp32c61/include/hal/brownout_ll.h (100%) rename components/{hal => esp_hal_pmu}/esp32h2/include/hal/brownout_ll.h (100%) rename components/{hal => esp_hal_pmu}/esp32h2/include/hal/vbat_ll.h (99%) rename components/{hal => esp_hal_pmu}/esp32p4/include/hal/brownout_ll.h (100%) rename components/{hal => esp_hal_pmu}/esp32p4/include/hal/ldo_ll.h (100%) rename components/{hal => esp_hal_pmu}/esp32p4/include/hal/vbat_ll.h (98%) rename components/{hal => esp_hal_pmu}/esp32s2/include/hal/brownout_ll.h (99%) rename components/{hal/esp32c2 => esp_hal_pmu/esp32s3}/include/hal/brownout_ll.h (99%) rename components/{hal => esp_hal_pmu}/include/hal/brownout_hal.h (99%) rename components/{hal => esp_hal_pmu}/include/hal/vbat_hal.h (100%) rename components/{hal => esp_hal_pmu}/vbat_hal.c (100%) diff --git a/components/esp_hal_pmu/CMakeLists.txt b/components/esp_hal_pmu/CMakeLists.txt index 75f9e18bb9..0e517d68cc 100644 --- a/components/esp_hal_pmu/CMakeLists.txt +++ b/components/esp_hal_pmu/CMakeLists.txt @@ -21,6 +21,14 @@ 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() + +if(CONFIG_SOC_VBAT_SUPPORTED) + list(APPEND srcs "vbat_hal.c") +endif() + idf_component_register(SRCS ${srcs} INCLUDE_DIRS ${public_include} REQUIRES soc hal esp_rom diff --git a/components/hal/brownout_hal.c b/components/esp_hal_pmu/brownout_hal.c similarity index 100% rename from components/hal/brownout_hal.c rename to components/esp_hal_pmu/brownout_hal.c diff --git a/components/hal/esp32/include/hal/brownout_ll.h b/components/esp_hal_pmu/esp32/include/hal/brownout_ll.h similarity index 99% rename from components/hal/esp32/include/hal/brownout_ll.h rename to components/esp_hal_pmu/esp32/include/hal/brownout_ll.h index 174d3387d8..1c42cf498d 100644 --- a/components/hal/esp32/include/hal/brownout_ll.h +++ b/components/esp_hal_pmu/esp32/include/hal/brownout_ll.h @@ -123,7 +123,6 @@ static inline void brownout_ll_clear_count(void) // Not supported on esp32 } - #ifdef __cplusplus } #endif diff --git a/components/hal/esp32s3/include/hal/brownout_ll.h b/components/esp_hal_pmu/esp32c2/include/hal/brownout_ll.h similarity index 100% rename from components/hal/esp32s3/include/hal/brownout_ll.h rename to components/esp_hal_pmu/esp32c2/include/hal/brownout_ll.h diff --git a/components/hal/esp32c3/include/hal/brownout_ll.h b/components/esp_hal_pmu/esp32c3/include/hal/brownout_ll.h similarity index 100% rename from components/hal/esp32c3/include/hal/brownout_ll.h rename to components/esp_hal_pmu/esp32c3/include/hal/brownout_ll.h diff --git a/components/hal/esp32c5/include/hal/brownout_ll.h b/components/esp_hal_pmu/esp32c5/include/hal/brownout_ll.h similarity index 100% rename from components/hal/esp32c5/include/hal/brownout_ll.h rename to components/esp_hal_pmu/esp32c5/include/hal/brownout_ll.h diff --git a/components/hal/esp32c6/include/hal/brownout_ll.h b/components/esp_hal_pmu/esp32c6/include/hal/brownout_ll.h similarity index 100% rename from components/hal/esp32c6/include/hal/brownout_ll.h rename to components/esp_hal_pmu/esp32c6/include/hal/brownout_ll.h diff --git a/components/hal/esp32c61/include/hal/brownout_ll.h b/components/esp_hal_pmu/esp32c61/include/hal/brownout_ll.h similarity index 100% rename from components/hal/esp32c61/include/hal/brownout_ll.h rename to components/esp_hal_pmu/esp32c61/include/hal/brownout_ll.h diff --git a/components/hal/esp32h2/include/hal/brownout_ll.h b/components/esp_hal_pmu/esp32h2/include/hal/brownout_ll.h similarity index 100% rename from components/hal/esp32h2/include/hal/brownout_ll.h rename to components/esp_hal_pmu/esp32h2/include/hal/brownout_ll.h diff --git a/components/hal/esp32h2/include/hal/vbat_ll.h b/components/esp_hal_pmu/esp32h2/include/hal/vbat_ll.h similarity index 99% rename from components/hal/esp32h2/include/hal/vbat_ll.h rename to components/esp_hal_pmu/esp32h2/include/hal/vbat_ll.h index ec68f2b224..8f9c7150e9 100644 --- a/components/hal/esp32h2/include/hal/vbat_ll.h +++ b/components/esp_hal_pmu/esp32h2/include/hal/vbat_ll.h @@ -18,7 +18,6 @@ #include "hal/regi2c_ctrl.h" #include "soc/regi2c_brownout.h" - typedef enum { VBAT_LL_CHARGER_UPVOLTAGE_INTR = BIT(27), VBAT_LL_CHARGER_UNDERVOLTAGE_INTR = BIT(28), diff --git a/components/hal/esp32p4/include/hal/brownout_ll.h b/components/esp_hal_pmu/esp32p4/include/hal/brownout_ll.h similarity index 100% rename from components/hal/esp32p4/include/hal/brownout_ll.h rename to components/esp_hal_pmu/esp32p4/include/hal/brownout_ll.h diff --git a/components/hal/esp32p4/include/hal/ldo_ll.h b/components/esp_hal_pmu/esp32p4/include/hal/ldo_ll.h similarity index 100% rename from components/hal/esp32p4/include/hal/ldo_ll.h rename to components/esp_hal_pmu/esp32p4/include/hal/ldo_ll.h diff --git a/components/hal/esp32p4/include/hal/vbat_ll.h b/components/esp_hal_pmu/esp32p4/include/hal/vbat_ll.h similarity index 98% rename from components/hal/esp32p4/include/hal/vbat_ll.h rename to components/esp_hal_pmu/esp32p4/include/hal/vbat_ll.h index 3747f83ff3..283505ec7e 100644 --- a/components/hal/esp32p4/include/hal/vbat_ll.h +++ b/components/esp_hal_pmu/esp32p4/include/hal/vbat_ll.h @@ -19,7 +19,6 @@ #include "hal/regi2c_ctrl.h" #include "soc/regi2c_brownout.h" - typedef enum { VBAT_LL_CHARGER_UPVOLTAGE_INTR = BIT(27), VBAT_LL_CHARGER_UNDERVOLTAGE_INTR = BIT(28), @@ -73,7 +72,7 @@ static inline void vbat_ll_enable_charger_comparator(bool enable) */ static inline void vbat_ll_set_undervoltage_filter_time(uint32_t time_tick) { - HAL_ASSERT(time_tick < (2<<10)); + HAL_ASSERT(time_tick < (2 << 10)); LP_ANA_PERI.vddbat_charge_cntl.vddbat_charge_undervoltage_target = time_tick; } @@ -84,7 +83,7 @@ static inline void vbat_ll_set_undervoltage_filter_time(uint32_t time_tick) */ static inline void vbat_ll_set_upvoltage_filter_time(uint32_t time_tick) { - HAL_ASSERT(time_tick < (2<<10)); + HAL_ASSERT(time_tick < (2 << 10)); LP_ANA_PERI.vddbat_charge_cntl.vddbat_charge_upvoltage_target = time_tick; } diff --git a/components/hal/esp32s2/include/hal/brownout_ll.h b/components/esp_hal_pmu/esp32s2/include/hal/brownout_ll.h similarity index 99% rename from components/hal/esp32s2/include/hal/brownout_ll.h rename to components/esp_hal_pmu/esp32s2/include/hal/brownout_ll.h index 54cc10a673..da742c2a2e 100644 --- a/components/hal/esp32s2/include/hal/brownout_ll.h +++ b/components/esp_hal_pmu/esp32s2/include/hal/brownout_ll.h @@ -127,7 +127,6 @@ static inline void brownout_ll_clear_count(void) RTCCNTL.brown_out.cnt_clr = 0; } - #ifdef __cplusplus } #endif diff --git a/components/hal/esp32c2/include/hal/brownout_ll.h b/components/esp_hal_pmu/esp32s3/include/hal/brownout_ll.h similarity index 99% rename from components/hal/esp32c2/include/hal/brownout_ll.h rename to components/esp_hal_pmu/esp32s3/include/hal/brownout_ll.h index 6d41a0aac0..aab4b8afe7 100644 --- a/components/hal/esp32c2/include/hal/brownout_ll.h +++ b/components/esp_hal_pmu/esp32s3/include/hal/brownout_ll.h @@ -132,7 +132,6 @@ static inline void brownout_ll_clear_count(void) RTCCNTL.brown_out.cnt_clr = 0; } - #ifdef __cplusplus } #endif diff --git a/components/hal/include/hal/brownout_hal.h b/components/esp_hal_pmu/include/hal/brownout_hal.h similarity index 99% rename from components/hal/include/hal/brownout_hal.h rename to components/esp_hal_pmu/include/hal/brownout_hal.h index 84ea785a79..a56ad68a22 100644 --- a/components/hal/include/hal/brownout_hal.h +++ b/components/esp_hal_pmu/include/hal/brownout_hal.h @@ -36,7 +36,6 @@ typedef struct { */ void brownout_hal_config(const brownout_hal_config_t *cfg); - #ifdef __cplusplus } #endif diff --git a/components/hal/include/hal/vbat_hal.h b/components/esp_hal_pmu/include/hal/vbat_hal.h similarity index 100% rename from components/hal/include/hal/vbat_hal.h rename to components/esp_hal_pmu/include/hal/vbat_hal.h diff --git a/components/hal/vbat_hal.c b/components/esp_hal_pmu/vbat_hal.c similarity index 100% rename from components/hal/vbat_hal.c rename to components/esp_hal_pmu/vbat_hal.c diff --git a/components/hal/CMakeLists.txt b/components/hal/CMakeLists.txt index f447844668..3106301008 100644 --- a/components/hal/CMakeLists.txt +++ b/components/hal/CMakeLists.txt @@ -33,11 +33,7 @@ else() endif() endif() -if(esp_tee_build) - if(CONFIG_SOC_BOD_SUPPORTED) - list(APPEND srcs "brownout_hal.c") - endif() -elseif(NOT BOOTLOADER_BUILD) +if(NOT esp_tee_build AND NOT BOOTLOADER_BUILD) list(APPEND srcs "color_hal.c") if(CONFIG_SOC_SYSTIMER_SUPPORTED AND NOT CONFIG_HAL_SYSTIMER_USE_ROM_IMPL) @@ -60,14 +56,6 @@ elseif(NOT BOOTLOADER_BUILD) list(APPEND srcs "${target}/modem_clock_hal.c") endif() - if(CONFIG_SOC_BOD_SUPPORTED) - list(APPEND srcs "brownout_hal.c") - endif() - - if(CONFIG_SOC_VBAT_SUPPORTED) - list(APPEND srcs "vbat_hal.c") - endif() - endif() idf_component_register(SRCS ${srcs}