File tree Expand file tree Collapse file tree 6 files changed +89
-0
lines changed
drivers/interrupt_controller
dts/bindings/interrupt-controller Expand file tree Collapse file tree 6 files changed +89
-0
lines changed Original file line number Diff line number Diff line change @@ -43,6 +43,7 @@ zephyr_library_sources_ifdef(CONFIG_NXP_PINT intc_nxp_pint.c)
4343zephyr_library_sources_ifdef(CONFIG_RENESAS_RA_ICU intc_renesas_ra_icu.c)
4444zephyr_library_sources_ifdef(CONFIG_NXP_IRQSTEER intc_nxp_irqsteer.c)
4545zephyr_library_sources_ifdef(CONFIG_INTC_MTK_ADSP intc_mtk_adsp.c)
46+ zephyr_library_sources_ifdef(CONFIG_WCH_PFIC intc_wch_pfic.c)
4647
4748if (CONFIG_INTEL_VTD_ICTL)
4849 zephyr_library_include_directories(${ZEPHYR_BASE} /arch/x86/include )
Original file line number Diff line number Diff line change @@ -108,4 +108,6 @@ source "drivers/interrupt_controller/Kconfig.nxp_irqsteer"
108108
109109source "drivers/interrupt_controller/Kconfig.mtk_adsp"
110110
111+ source "drivers/interrupt_controller/Kconfig.wch_pfic"
112+
111113endmenu
Original file line number Diff line number Diff line change 1+ # Copyright (c) 2024 Michael Hope
2+ # SPDX-License-Identifier: Apache-2.0
3+
4+ config WCH_PFIC
5+ bool "WCH Programmable Fast Interrupt Controller (PFIC)"
6+ default y
7+ depends on DT_HAS_WCH_PFIC_ENABLED
8+ help
9+ Interrupt controller for WCH PFIC.
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright (c) 2024 Michael Hope
3+ *
4+ * SPDX-License-Identifier: Apache-2.0
5+ */
6+
7+ #define DT_DRV_COMPAT wch_pfic
8+
9+ #include <ch32_pfic.h>
10+
11+ #include <zephyr/arch/cpu.h>
12+ #include <zephyr/init.h>
13+ #include <zephyr/irq.h>
14+ #include <zephyr/kernel.h>
15+
16+ #define SEVONPEND (1 << 4)
17+ #define WFITOWFE (1 << 3)
18+
19+ void arch_irq_enable (unsigned int irq )
20+ {
21+ PFIC -> IENR [irq / 32 ] = 1 << (irq % 32 );
22+ }
23+
24+ void arch_irq_disable (unsigned int irq )
25+ {
26+ PFIC -> IRER [irq / 32 ] |= 1 << (irq % 32 );
27+ }
28+
29+ int arch_irq_is_enabled (unsigned int irq )
30+ {
31+ return ((PFIC -> ISR [irq >> 5 ] & (1 << (irq & 0x1F ))) != 0 );
32+ }
33+
34+ static int pfic_init (void )
35+ {
36+ /* `wfi` is called with interrupts disabled. Configure the PFIC to wake up on any event,
37+ * including any interrupt.
38+ */
39+ PFIC -> SCTLR = SEVONPEND | WFITOWFE ;
40+ return 0 ;
41+ }
42+
43+ SYS_INIT (pfic_init , PRE_KERNEL_1 , CONFIG_INTC_INIT_PRIORITY );
Original file line number Diff line number Diff line change 1+ # Copyright (c) 2024 Michael Hope
2+ # SPDX-License-Identifier: Apache-2.0
3+
4+ description : WCH CH32V00x Programmable Fast Interrupt Controller (PFIC)
5+
6+ compatible : " wch,pfic"
7+
8+ include : [interrupt-controller.yaml, base.yaml]
9+
10+ properties :
11+ reg :
12+ required : true
13+
14+ " #interrupt-cells " :
15+ const : 1
16+
17+ interrupt-cells :
18+ - irq
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright (c) 2024 Dhiru Kholia
3+ *
4+ * SPDX-License-Identifier: Apache-2.0
5+ */
6+
7+ #ifndef _CH32_PFIC_H
8+ #define _CH32_PFIC_H
9+
10+ #ifdef CONFIG_SOC_CH32V003
11+ #include <ch32v003fun.h>
12+ #else
13+ #error "SoC not supported!"
14+ #endif
15+
16+ #endif
You can’t perform that action at this time.
0 commit comments