File tree Expand file tree Collapse file tree 8 files changed +50
-3
lines changed Expand file tree Collapse file tree 8 files changed +50
-3
lines changed Original file line number Diff line number Diff line change 11/*
2- * SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD
2+ * SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD
33 *
44 * SPDX-License-Identifier: Apache-2.0
55 */
@@ -269,6 +269,16 @@ FORCE_INLINE_ATTR void esp_cpu_intr_set_mtvt_addr(const void *mtvt_addr)
269269}
270270#endif //#if SOC_INT_CLIC_SUPPORTED
271271
272+ #if SOC_CPU_SUPPORT_WFE
273+ /**
274+ * @brief Disable the WFE (wait for event) feature for CPU.
275+ */
276+ FORCE_INLINE_ATTR void rv_utils_disable_wfe_mode (void )
277+ {
278+ rv_utils_wfe_mode_enable (false);
279+ }
280+ #endif
281+
272282#if SOC_CPU_HAS_FLEXIBLE_INTC
273283/**
274284 * @brief Set the interrupt type of a particular interrupt
Original file line number Diff line number Diff line change @@ -212,7 +212,9 @@ void IRAM_ATTR call_start_cpu1(void)
212212 */
213213 esp_cpu_intr_set_mtvt_addr (& _mtvt_table );
214214#endif
215-
215+ #if SOC_CPU_SUPPORT_WFE
216+ rv_utils_disable_wfe_mode ();
217+ #endif
216218 ets_set_appcpu_boot_addr (0 );
217219
218220 bootloader_init_mem ();
@@ -413,6 +415,9 @@ void IRAM_ATTR call_start_cpu0(void)
413415 */
414416 esp_cpu_intr_set_mtvt_addr (& _mtvt_table );
415417#endif
418+ #if SOC_CPU_SUPPORT_WFE
419+ rv_utils_disable_wfe_mode ();
420+ #endif
416421
417422 /* NOTE: When ESP-TEE is enabled, this sets up the callback function
418423 * which redirects all the interrupt management for the REE (user app)
Original file line number Diff line number Diff line change 11/*
2- * SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD
2+ * SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD
33 *
44 * SPDX-License-Identifier: Apache-2.0
55 */
@@ -148,6 +148,20 @@ FORCE_INLINE_ATTR void rv_utils_set_mtvt(uint32_t mtvt_val)
148148 RV_WRITE_CSR (MTVT_CSR , mtvt_val );
149149}
150150
151+ #if SOC_CPU_SUPPORT_WFE
152+ /**
153+ * @brief Set the MEXSTATUS_WFFEN value, used to enable/disable wait for event mode.
154+ */
155+ FORCE_INLINE_ATTR void rv_utils_wfe_mode_enable (bool en )
156+ {
157+ if (en ) {
158+ RV_SET_CSR (MEXSTATUS , MEXSTATUS_WFFEN );
159+ } else {
160+ RV_CLEAR_CSR (MEXSTATUS , MEXSTATUS_WFFEN );
161+ }
162+ }
163+ #endif
164+
151165/**
152166 * @brief Get the current CPU raw interrupt level
153167 */
Original file line number Diff line number Diff line change 5353#define MSTATUS_SXL 0x0000000C00000000
5454#define MSTATUS64_SD 0x8000000000000000
5555
56+ #define MEXSTATUS_SOFT_RST 0x00000003
57+ #define MEXSTATUS_LPMD 0x0000000C
58+ #define MEXSTATUS_WFFEN 0x00000010
59+ #define MEXSTATUS_EXPT_VLD 0x00000020
60+ #define MEXSTATUS_LOCKUP 0x00000040
61+ #define MEXSTATUS_NMISTS 0x00000080
62+ #define MEXSTATUS_BUSEER 0x00000100
63+
5664#define SSTATUS_UIE 0x00000001
5765#define SSTATUS_SIE 0x00000002
5866#define SSTATUS_UPIE 0x00000010
Original file line number Diff line number Diff line change @@ -399,6 +399,10 @@ config SOC_CPU_HAS_FLEXIBLE_INTC
399399 bool
400400 default y
401401
402+ config SOC_CPU_SUPPORT_WFE
403+ bool
404+ default y
405+
402406config SOC_INT_CLIC_SUPPORTED
403407 bool
404408 default y
Original file line number Diff line number Diff line change 155155#define SOC_CPU_CORES_NUM (1U)
156156#define SOC_CPU_INTR_NUM 32
157157#define SOC_CPU_HAS_FLEXIBLE_INTC 1
158+ #define SOC_CPU_SUPPORT_WFE 1
158159#define SOC_INT_CLIC_SUPPORTED 1
159160#define SOC_INT_HW_NESTED_SUPPORTED 1 // Support for hardware interrupts nesting
160161#define SOC_BRANCH_PREDICTOR_SUPPORTED 1
Original file line number Diff line number Diff line change @@ -303,6 +303,10 @@ config SOC_CPU_HAS_FLEXIBLE_INTC
303303 bool
304304 default y
305305
306+ config SOC_CPU_SUPPORT_WFE
307+ bool
308+ default y
309+
306310config SOC_INT_PLIC_SUPPORTED
307311 bool
308312 default n
Original file line number Diff line number Diff line change 126126#define SOC_CPU_CORES_NUM (1U)
127127#define SOC_CPU_INTR_NUM 32
128128#define SOC_CPU_HAS_FLEXIBLE_INTC 1
129+ #define SOC_CPU_SUPPORT_WFE 1
129130#define SOC_INT_PLIC_SUPPORTED 0 //riscv platform-level interrupt controller
130131#define SOC_INT_CLIC_SUPPORTED 1
131132#define SOC_INT_HW_NESTED_SUPPORTED 1 // Support for hardware interrupts nesting
You can’t perform that action at this time.
0 commit comments