Skip to content

Commit 44a27d3

Browse files
author
Jiang Jiang Jian
committed
Merge branch 'fix/disable_wfe_feature_for_e906_chips' into 'master'
change(esp_hw_support): disable CPU wait-for-event mode on cpu start See merge request espressif/esp-idf!36388
2 parents 06aea27 + 121f56e commit 44a27d3

File tree

8 files changed

+49
-2
lines changed

8 files changed

+49
-2
lines changed

components/esp_hw_support/include/esp_cpu.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,16 @@ FORCE_INLINE_ATTR void esp_cpu_intr_set_mtvt_addr(const void *mtvt_addr)
273273
}
274274
#endif //#if SOC_INT_CLIC_SUPPORTED
275275

276+
#if SOC_CPU_SUPPORT_WFE
277+
/**
278+
* @brief Disable the WFE (wait for event) feature for CPU.
279+
*/
280+
FORCE_INLINE_ATTR void rv_utils_disable_wfe_mode(void)
281+
{
282+
rv_utils_wfe_mode_enable(false);
283+
}
284+
#endif
285+
276286
#if SOC_CPU_HAS_FLEXIBLE_INTC
277287
/**
278288
* @brief Set the interrupt type of a particular interrupt

components/esp_system/port/cpu_start.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,9 @@ void IRAM_ATTR call_start_cpu1(void)
211211
*/
212212
esp_cpu_intr_set_mtvt_addr(&_mtvt_table);
213213
#endif
214-
214+
#if SOC_CPU_SUPPORT_WFE
215+
rv_utils_disable_wfe_mode();
216+
#endif
215217
ets_set_appcpu_boot_addr(0);
216218

217219
bootloader_init_mem();
@@ -412,6 +414,9 @@ void IRAM_ATTR call_start_cpu0(void)
412414
*/
413415
esp_cpu_intr_set_mtvt_addr(&_mtvt_table);
414416
#endif
417+
#if SOC_CPU_SUPPORT_WFE
418+
rv_utils_disable_wfe_mode();
419+
#endif
415420

416421
/* NOTE: When ESP-TEE is enabled, this sets up the callback function
417422
* which redirects all the interrupt management for the REE (user app)

components/riscv/include/esp_private/interrupt_clic.h

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
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
*/

components/riscv/include/riscv/encoding.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,14 @@
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

components/soc/esp32c5/include/soc/Kconfig.soc_caps.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,10 @@ config SOC_CPU_HAS_FLEXIBLE_INTC
403403
bool
404404
default y
405405

406+
config SOC_CPU_SUPPORT_WFE
407+
bool
408+
default y
409+
406410
config SOC_INT_CLIC_SUPPORTED
407411
bool
408412
default y

components/soc/esp32c5/include/soc/soc_caps.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@
156156
#define SOC_CPU_CORES_NUM (1U)
157157
#define SOC_CPU_INTR_NUM 32
158158
#define SOC_CPU_HAS_FLEXIBLE_INTC 1
159+
#define SOC_CPU_SUPPORT_WFE 1
159160
#define SOC_INT_CLIC_SUPPORTED 1
160161
#define SOC_INT_HW_NESTED_SUPPORTED 1 // Support for hardware interrupts nesting
161162
#define SOC_BRANCH_PREDICTOR_SUPPORTED 1

components/soc/esp32c61/include/soc/Kconfig.soc_caps.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
306310
config SOC_INT_PLIC_SUPPORTED
307311
bool
308312
default n

components/soc/esp32c61/include/soc/soc_caps.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@
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

0 commit comments

Comments
 (0)