Skip to content

Commit 39d6f35

Browse files
committed
refactor(lp_core): unify LL functions of ETM wake up lp system
1 parent 06bd290 commit 39d6f35

File tree

10 files changed

+60
-91
lines changed

10 files changed

+60
-91
lines changed

components/hal/esp32c5/include/hal/etm_ll.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,6 @@ static inline void etm_ll_channel_set_task(soc_etm_dev_t *hw, uint32_t chan, uin
115115
HAL_FORCE_MODIFY_U32_REG_FIELD(hw->channel[chan].tid, chn_task_id, task);
116116
}
117117

118-
#define etm_ll_is_lpcore_wakeup_triggered() lp_aon_ll_get_lpcore_etm_wakeup_flag()
119-
120-
#define etm_ll_clear_lpcore_wakeup_status() lp_aon_ll_clear_lpcore_etm_wakeup_flag()
121-
122118
#ifdef __cplusplus
123119
}
124120
#endif

components/hal/esp32c5/include/hal/lp_aon_ll.h

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -92,24 +92,6 @@ static inline void lp_aon_ll_inform_wakeup_type(bool dslp)
9292
}
9393
}
9494

95-
/**
96-
* @brief Get the flag that marks whether LP CPU is awakened by ETM
97-
*
98-
* @return Return true if lpcore is woken up by soc_etm
99-
*/
100-
static inline bool lp_aon_ll_get_lpcore_etm_wakeup_flag(void)
101-
{
102-
return REG_GET_BIT(LP_AON_LPCORE_REG, LP_AON_LPCORE_ETM_WAKEUP_FLAG);
103-
}
104-
105-
/**
106-
* @brief Clear the flag that marks whether LP CPU is awakened by soc_etm
107-
*/
108-
static inline void lp_aon_ll_clear_lpcore_etm_wakeup_flag(void)
109-
{
110-
REG_SET_BIT(LP_AON_LPCORE_REG, LP_AON_LPCORE_ETM_WAKEUP_FLAG_CLR);
111-
}
112-
11395
/**
11496
* @brief Set the maximum number of linked lists supported by REGDMA
11597
* @param count: the maximum number of regdma link

components/hal/esp32c5/include/hal/lp_core_ll.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <stdbool.h>
1515
#include "soc/lpperi_struct.h"
1616
#include "soc/pmu_struct.h"
17+
#include "soc/lp_aon_struct.h"
1718

1819
#ifdef __cplusplus
1920
extern "C" {
@@ -130,6 +131,24 @@ static inline uint8_t lp_core_ll_get_triggered_interrupt_srcs(void)
130131
return LPPERI.interrupt_source.lp_interrupt_source;
131132
}
132133

134+
/**
135+
* @brief Get the flag that marks whether LP CPU is awakened by ETM
136+
*
137+
* @return Return true if lpcore is woken up by soc_etm
138+
*/
139+
static inline bool lp_core_ll_get_etm_wakeup_flag(void)
140+
{
141+
return LP_AON.lpcore.lpcore_etm_wakeup_flag;
142+
}
143+
144+
/**
145+
* @brief Clear the flag that marks whether LP CPU is awakened by soc_etm
146+
*/
147+
static inline void lp_core_ll_clear_etm_wakeup_flag(void)
148+
{
149+
LP_AON.lpcore.lpcore_etm_wakeup_flag_clr = 0x01;
150+
}
151+
133152
#ifdef __cplusplus
134153
}
135154
#endif

components/hal/esp32c6/include/hal/etm_ll.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,6 @@ static inline void etm_ll_channel_set_task(soc_etm_dev_t *hw, uint32_t chan, uin
113113
HAL_FORCE_MODIFY_U32_REG_FIELD(hw->channel[chan].tid, task_id, task);
114114
}
115115

116-
#define etm_ll_is_lpcore_wakeup_triggered() lp_aon_ll_get_lpcore_etm_wakeup_flag()
117-
118-
#define etm_ll_clear_lpcore_wakeup_status() lp_aon_ll_clear_lpcore_etm_wakeup_flag()
119-
120116
#ifdef __cplusplus
121117
}
122118
#endif

components/hal/esp32c6/include/hal/lp_aon_ll.h

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -85,24 +85,6 @@ static inline void lp_aon_ll_inform_wakeup_type(bool dslp)
8585
}
8686
}
8787

88-
/**
89-
* @brief Get the flag that marks whether LP CPU is awakened by ETM
90-
*
91-
* @return Return true if lpcore is woken up by soc_etm
92-
*/
93-
static inline bool lp_aon_ll_get_lpcore_etm_wakeup_flag(void)
94-
{
95-
return REG_GET_BIT(LP_AON_LPCORE_REG, LP_AON_LPCORE_ETM_WAKEUP_FLAG);
96-
}
97-
98-
/**
99-
* @brief Clear the flag that marks whether LP CPU is awakened by soc_etm
100-
*/
101-
static inline void lp_aon_ll_clear_lpcore_etm_wakeup_flag(void)
102-
{
103-
REG_SET_BIT(LP_AON_LPCORE_REG, LP_AON_LPCORE_ETM_WAKEUP_FLAG_CLR);
104-
}
105-
10688
#ifdef __cplusplus
10789
}
10890
#endif

components/hal/esp32c6/include/hal/lp_core_ll.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,24 @@ static inline uint8_t lp_core_ll_get_triggered_interrupt_srcs(void)
136136
return LPPERI.interrupt_source.lp_interrupt_source;
137137
}
138138

139+
/**
140+
* @brief Get the flag that marks whether LP CPU is awakened by ETM
141+
*
142+
* @return Return true if lpcore is woken up by soc_etm
143+
*/
144+
static inline bool lp_core_ll_get_etm_wakeup_flag(void)
145+
{
146+
return LP_AON.lpcore.lpcore_etm_wakeup_flag;
147+
}
148+
149+
/**
150+
* @brief Clear the flag that marks whether LP CPU is awakened by soc_etm
151+
*/
152+
static inline void lp_core_ll_clear_etm_wakeup_flag(void)
153+
{
154+
LP_AON.lpcore.lpcore_etm_wakeup_flag_clr = 0x01;
155+
}
156+
139157
#ifdef __cplusplus
140158
}
141159
#endif

components/hal/esp32c61/include/hal/lp_aon_ll.h

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -92,23 +92,6 @@ static inline void lp_aon_ll_inform_wakeup_type(bool dslp)
9292
}
9393
}
9494

95-
/**
96-
* @brief Get the flag that marks whether LP CPU is awakened by ETM
97-
*
98-
* @return Return true if lpcore is woken up by soc_etm
99-
*/
100-
static inline bool lp_aon_ll_get_lpcore_etm_wakeup_flag(void)
101-
{
102-
return REG_GET_BIT(LP_AON_LPCORE_REG, LP_AON_LPCORE_ETM_WAKEUP_FLAG);
103-
}
104-
105-
/**
106-
* @brief Clear the flag that marks whether LP CPU is awakened by soc_etm
107-
*/
108-
static inline void lp_aon_ll_clear_lpcore_etm_wakeup_flag(void)
109-
{
110-
REG_SET_BIT(LP_AON_LPCORE_REG, LP_AON_LPCORE_ETM_WAKEUP_FLAG_CLR);
111-
}
11295
#ifdef __cplusplus
11396
}
11497
#endif

components/hal/esp32p4/include/hal/etm_ll.h

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -123,24 +123,6 @@ static inline void etm_ll_channel_set_task(soc_etm_dev_t *hw, uint32_t chan, uin
123123
HAL_FORCE_MODIFY_U32_REG_FIELD(hw->channel[chan].tid, task_id, task);
124124
}
125125

126-
/**
127-
* @brief Get the flag that marks whether LP CPU is awakened by ETM
128-
*
129-
* @return Return true if lpcore is woken up by soc etm flag
130-
*/
131-
static inline bool etm_ll_is_lpcore_wakeup_triggered(void)
132-
{
133-
return SOC_ETM.task_st5.ulp_task_wakeup_cpu_st;
134-
}
135-
136-
/**
137-
* @brief Clear the flag that marks whether LP CPU is awakened by ETM
138-
*/
139-
static inline void etm_ll_clear_lpcore_wakeup_status(void)
140-
{
141-
SOC_ETM.task_st5_clr.ulp_task_wakeup_cpu_st_clr = 1;
142-
}
143-
144126
#ifdef __cplusplus
145127
}
146128
#endif

components/hal/esp32p4/include/hal/lp_core_ll.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "soc/lpperi_struct.h"
1616
#include "soc/pmu_struct.h"
1717
#include "soc/lp_system_struct.h"
18+
#include "soc/soc_etm_struct.h"
1819

1920
#ifdef __cplusplus
2021
extern "C" {
@@ -157,6 +158,24 @@ static inline void lp_core_ll_clear_etm_wakeup_status(void)
157158
LP_SYS.sys_ctrl.lp_core_etm_wakeup_flag_clr = 1;
158159
}
159160

161+
/**
162+
* @brief Get the flag that marks whether LP CPU is awakened by ETM
163+
*
164+
* @return Return true if lpcore is woken up by soc etm flag
165+
*/
166+
static inline bool lp_core_ll_get_etm_wakeup_flag(void)
167+
{
168+
return SOC_ETM.task_st5.ulp_task_wakeup_cpu_st;
169+
}
170+
171+
/**
172+
* @brief Clear the flag that marks whether LP CPU is awakened by ETM
173+
*/
174+
static inline void lp_core_ll_clear_etm_wakeup_flag(void)
175+
{
176+
SOC_ETM.task_st5_clr.ulp_task_wakeup_cpu_st_clr = 1;
177+
}
178+
160179
#ifdef __cplusplus
161180
}
162181
#endif

components/ulp/lp_core/lp_core/lp_core_utils.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,6 @@
1515
#include "hal/uart_ll.h"
1616
#include "hal/rtc_io_ll.h"
1717

18-
#if !CONFIG_IDF_TARGET_ESP32P4
19-
#include "hal/lp_aon_ll.h"
20-
#endif
21-
22-
#if SOC_ETM_SUPPORTED
23-
#include "hal/etm_ll.h"
24-
#endif
25-
2618
#if SOC_LP_TIMER_SUPPORTED
2719
#include "hal/lp_timer_ll.h"
2820
#endif
@@ -66,12 +58,12 @@ void ulp_lp_core_update_wakeup_cause(void)
6658

6759
#if SOC_ETM_SUPPORTED
6860
if ((lp_core_ll_get_wakeup_source() & LP_CORE_LL_WAKEUP_SOURCE_ETM) \
69-
&& etm_ll_is_lpcore_wakeup_triggered()) {
61+
&& lp_core_ll_get_etm_wakeup_flag()) {
7062
lp_wakeup_cause |= LP_CORE_LL_WAKEUP_SOURCE_ETM;
7163
#if CONFIG_IDF_TARGET_ESP32P4
7264
lp_core_ll_clear_etm_wakeup_status();
7365
#else
74-
lp_aon_ll_clear_lpcore_etm_wakeup_flag();
66+
lp_core_ll_clear_etm_wakeup_flag();
7567
#endif
7668
}
7769
#endif /* SOC_ETM_SUPPORTED */

0 commit comments

Comments
 (0)