From 39d6f35594ff458e8871af5f9c5fa16bab768e21 Mon Sep 17 00:00:00 2001 From: morris Date: Tue, 24 Sep 2024 22:21:17 +0800 Subject: [PATCH] refactor(lp_core): unify LL functions of ETM wake up lp system --- components/hal/esp32c5/include/hal/etm_ll.h | 4 ---- .../hal/esp32c5/include/hal/lp_aon_ll.h | 18 ----------------- .../hal/esp32c5/include/hal/lp_core_ll.h | 19 ++++++++++++++++++ components/hal/esp32c6/include/hal/etm_ll.h | 4 ---- .../hal/esp32c6/include/hal/lp_aon_ll.h | 20 +------------------ .../hal/esp32c6/include/hal/lp_core_ll.h | 18 +++++++++++++++++ .../hal/esp32c61/include/hal/lp_aon_ll.h | 17 ---------------- components/hal/esp32p4/include/hal/etm_ll.h | 20 +------------------ .../hal/esp32p4/include/hal/lp_core_ll.h | 19 ++++++++++++++++++ .../ulp/lp_core/lp_core/lp_core_utils.c | 12 ++--------- 10 files changed, 60 insertions(+), 91 deletions(-) diff --git a/components/hal/esp32c5/include/hal/etm_ll.h b/components/hal/esp32c5/include/hal/etm_ll.h index ee1707cd71..fa76af9f99 100644 --- a/components/hal/esp32c5/include/hal/etm_ll.h +++ b/components/hal/esp32c5/include/hal/etm_ll.h @@ -115,10 +115,6 @@ static inline void etm_ll_channel_set_task(soc_etm_dev_t *hw, uint32_t chan, uin HAL_FORCE_MODIFY_U32_REG_FIELD(hw->channel[chan].tid, chn_task_id, task); } -#define etm_ll_is_lpcore_wakeup_triggered() lp_aon_ll_get_lpcore_etm_wakeup_flag() - -#define etm_ll_clear_lpcore_wakeup_status() lp_aon_ll_clear_lpcore_etm_wakeup_flag() - #ifdef __cplusplus } #endif diff --git a/components/hal/esp32c5/include/hal/lp_aon_ll.h b/components/hal/esp32c5/include/hal/lp_aon_ll.h index eb8967c1b1..1e0eae5861 100644 --- a/components/hal/esp32c5/include/hal/lp_aon_ll.h +++ b/components/hal/esp32c5/include/hal/lp_aon_ll.h @@ -92,24 +92,6 @@ static inline void lp_aon_ll_inform_wakeup_type(bool dslp) } } -/** - * @brief Get the flag that marks whether LP CPU is awakened by ETM - * - * @return Return true if lpcore is woken up by soc_etm - */ -static inline bool lp_aon_ll_get_lpcore_etm_wakeup_flag(void) -{ - return REG_GET_BIT(LP_AON_LPCORE_REG, LP_AON_LPCORE_ETM_WAKEUP_FLAG); -} - -/** - * @brief Clear the flag that marks whether LP CPU is awakened by soc_etm - */ -static inline void lp_aon_ll_clear_lpcore_etm_wakeup_flag(void) -{ - REG_SET_BIT(LP_AON_LPCORE_REG, LP_AON_LPCORE_ETM_WAKEUP_FLAG_CLR); -} - /** * @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/include/hal/lp_core_ll.h b/components/hal/esp32c5/include/hal/lp_core_ll.h index 59cb13c441..77937944ae 100644 --- a/components/hal/esp32c5/include/hal/lp_core_ll.h +++ b/components/hal/esp32c5/include/hal/lp_core_ll.h @@ -14,6 +14,7 @@ #include #include "soc/lpperi_struct.h" #include "soc/pmu_struct.h" +#include "soc/lp_aon_struct.h" #ifdef __cplusplus extern "C" { @@ -130,6 +131,24 @@ static inline uint8_t lp_core_ll_get_triggered_interrupt_srcs(void) return LPPERI.interrupt_source.lp_interrupt_source; } +/** + * @brief Get the flag that marks whether LP CPU is awakened by ETM + * + * @return Return true if lpcore is woken up by soc_etm + */ +static inline bool lp_core_ll_get_etm_wakeup_flag(void) +{ + return LP_AON.lpcore.lpcore_etm_wakeup_flag; +} + +/** + * @brief Clear the flag that marks whether LP CPU is awakened by soc_etm + */ +static inline void lp_core_ll_clear_etm_wakeup_flag(void) +{ + LP_AON.lpcore.lpcore_etm_wakeup_flag_clr = 0x01; +} + #ifdef __cplusplus } #endif diff --git a/components/hal/esp32c6/include/hal/etm_ll.h b/components/hal/esp32c6/include/hal/etm_ll.h index 9a46f46a1d..9d7079619d 100644 --- a/components/hal/esp32c6/include/hal/etm_ll.h +++ b/components/hal/esp32c6/include/hal/etm_ll.h @@ -113,10 +113,6 @@ static inline void etm_ll_channel_set_task(soc_etm_dev_t *hw, uint32_t chan, uin HAL_FORCE_MODIFY_U32_REG_FIELD(hw->channel[chan].tid, task_id, task); } -#define etm_ll_is_lpcore_wakeup_triggered() lp_aon_ll_get_lpcore_etm_wakeup_flag() - -#define etm_ll_clear_lpcore_wakeup_status() lp_aon_ll_clear_lpcore_etm_wakeup_flag() - #ifdef __cplusplus } #endif diff --git a/components/hal/esp32c6/include/hal/lp_aon_ll.h b/components/hal/esp32c6/include/hal/lp_aon_ll.h index 93de998fd1..87c73b489e 100644 --- a/components/hal/esp32c6/include/hal/lp_aon_ll.h +++ b/components/hal/esp32c6/include/hal/lp_aon_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -85,24 +85,6 @@ static inline void lp_aon_ll_inform_wakeup_type(bool dslp) } } -/** - * @brief Get the flag that marks whether LP CPU is awakened by ETM - * - * @return Return true if lpcore is woken up by soc_etm - */ -static inline bool lp_aon_ll_get_lpcore_etm_wakeup_flag(void) -{ - return REG_GET_BIT(LP_AON_LPCORE_REG, LP_AON_LPCORE_ETM_WAKEUP_FLAG); -} - -/** - * @brief Clear the flag that marks whether LP CPU is awakened by soc_etm - */ -static inline void lp_aon_ll_clear_lpcore_etm_wakeup_flag(void) -{ - REG_SET_BIT(LP_AON_LPCORE_REG, LP_AON_LPCORE_ETM_WAKEUP_FLAG_CLR); -} - #ifdef __cplusplus } #endif diff --git a/components/hal/esp32c6/include/hal/lp_core_ll.h b/components/hal/esp32c6/include/hal/lp_core_ll.h index 7ac68a9632..8f3446d389 100644 --- a/components/hal/esp32c6/include/hal/lp_core_ll.h +++ b/components/hal/esp32c6/include/hal/lp_core_ll.h @@ -136,6 +136,24 @@ static inline uint8_t lp_core_ll_get_triggered_interrupt_srcs(void) return LPPERI.interrupt_source.lp_interrupt_source; } +/** + * @brief Get the flag that marks whether LP CPU is awakened by ETM + * + * @return Return true if lpcore is woken up by soc_etm + */ +static inline bool lp_core_ll_get_etm_wakeup_flag(void) +{ + return LP_AON.lpcore.lpcore_etm_wakeup_flag; +} + +/** + * @brief Clear the flag that marks whether LP CPU is awakened by soc_etm + */ +static inline void lp_core_ll_clear_etm_wakeup_flag(void) +{ + LP_AON.lpcore.lpcore_etm_wakeup_flag_clr = 0x01; +} + #ifdef __cplusplus } #endif diff --git a/components/hal/esp32c61/include/hal/lp_aon_ll.h b/components/hal/esp32c61/include/hal/lp_aon_ll.h index fea02e9da2..cebe837a57 100644 --- a/components/hal/esp32c61/include/hal/lp_aon_ll.h +++ b/components/hal/esp32c61/include/hal/lp_aon_ll.h @@ -92,23 +92,6 @@ static inline void lp_aon_ll_inform_wakeup_type(bool dslp) } } -/** - * @brief Get the flag that marks whether LP CPU is awakened by ETM - * - * @return Return true if lpcore is woken up by soc_etm - */ -static inline bool lp_aon_ll_get_lpcore_etm_wakeup_flag(void) -{ - return REG_GET_BIT(LP_AON_LPCORE_REG, LP_AON_LPCORE_ETM_WAKEUP_FLAG); -} - -/** - * @brief Clear the flag that marks whether LP CPU is awakened by soc_etm - */ -static inline void lp_aon_ll_clear_lpcore_etm_wakeup_flag(void) -{ - REG_SET_BIT(LP_AON_LPCORE_REG, LP_AON_LPCORE_ETM_WAKEUP_FLAG_CLR); -} #ifdef __cplusplus } #endif diff --git a/components/hal/esp32p4/include/hal/etm_ll.h b/components/hal/esp32p4/include/hal/etm_ll.h index d4f1293475..24c25776b5 100644 --- a/components/hal/esp32p4/include/hal/etm_ll.h +++ b/components/hal/esp32p4/include/hal/etm_ll.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -123,24 +123,6 @@ static inline void etm_ll_channel_set_task(soc_etm_dev_t *hw, uint32_t chan, uin HAL_FORCE_MODIFY_U32_REG_FIELD(hw->channel[chan].tid, task_id, task); } -/** - * @brief Get the flag that marks whether LP CPU is awakened by ETM - * - * @return Return true if lpcore is woken up by soc etm flag - */ -static inline bool etm_ll_is_lpcore_wakeup_triggered(void) -{ - return SOC_ETM.task_st5.ulp_task_wakeup_cpu_st; -} - -/** - * @brief Clear the flag that marks whether LP CPU is awakened by ETM - */ -static inline void etm_ll_clear_lpcore_wakeup_status(void) -{ - SOC_ETM.task_st5_clr.ulp_task_wakeup_cpu_st_clr = 1; -} - #ifdef __cplusplus } #endif diff --git a/components/hal/esp32p4/include/hal/lp_core_ll.h b/components/hal/esp32p4/include/hal/lp_core_ll.h index b045f4703c..27a9a0997f 100644 --- a/components/hal/esp32p4/include/hal/lp_core_ll.h +++ b/components/hal/esp32p4/include/hal/lp_core_ll.h @@ -15,6 +15,7 @@ #include "soc/lpperi_struct.h" #include "soc/pmu_struct.h" #include "soc/lp_system_struct.h" +#include "soc/soc_etm_struct.h" #ifdef __cplusplus extern "C" { @@ -157,6 +158,24 @@ static inline void lp_core_ll_clear_etm_wakeup_status(void) LP_SYS.sys_ctrl.lp_core_etm_wakeup_flag_clr = 1; } +/** + * @brief Get the flag that marks whether LP CPU is awakened by ETM + * + * @return Return true if lpcore is woken up by soc etm flag + */ +static inline bool lp_core_ll_get_etm_wakeup_flag(void) +{ + return SOC_ETM.task_st5.ulp_task_wakeup_cpu_st; +} + +/** + * @brief Clear the flag that marks whether LP CPU is awakened by ETM + */ +static inline void lp_core_ll_clear_etm_wakeup_flag(void) +{ + SOC_ETM.task_st5_clr.ulp_task_wakeup_cpu_st_clr = 1; +} + #ifdef __cplusplus } #endif diff --git a/components/ulp/lp_core/lp_core/lp_core_utils.c b/components/ulp/lp_core/lp_core/lp_core_utils.c index e3628cf076..8b358741fb 100644 --- a/components/ulp/lp_core/lp_core/lp_core_utils.c +++ b/components/ulp/lp_core/lp_core/lp_core_utils.c @@ -15,14 +15,6 @@ #include "hal/uart_ll.h" #include "hal/rtc_io_ll.h" -#if !CONFIG_IDF_TARGET_ESP32P4 -#include "hal/lp_aon_ll.h" -#endif - -#if SOC_ETM_SUPPORTED -#include "hal/etm_ll.h" -#endif - #if SOC_LP_TIMER_SUPPORTED #include "hal/lp_timer_ll.h" #endif @@ -66,12 +58,12 @@ void ulp_lp_core_update_wakeup_cause(void) #if SOC_ETM_SUPPORTED if ((lp_core_ll_get_wakeup_source() & LP_CORE_LL_WAKEUP_SOURCE_ETM) \ - && etm_ll_is_lpcore_wakeup_triggered()) { + && lp_core_ll_get_etm_wakeup_flag()) { lp_wakeup_cause |= LP_CORE_LL_WAKEUP_SOURCE_ETM; #if CONFIG_IDF_TARGET_ESP32P4 lp_core_ll_clear_etm_wakeup_status(); #else - lp_aon_ll_clear_lpcore_etm_wakeup_flag(); + lp_core_ll_clear_etm_wakeup_flag(); #endif } #endif /* SOC_ETM_SUPPORTED */