drivers: add the pfic interrupt controller
This commit adds the pfic interrupt controller driver for WCH CH32V003. Signed-off-by: Michael Hope <michaelh@juju.nz> Signed-off-by: Dhiru Kholia <dhiru.kholia@gmail.com>
This commit is contained in:
committed by
Fabio Baltieri
parent
01a9061d67
commit
ef475cbf71
@@ -43,6 +43,7 @@ zephyr_library_sources_ifdef(CONFIG_NXP_PINT intc_nxp_pint.c)
|
||||
zephyr_library_sources_ifdef(CONFIG_RENESAS_RA_ICU intc_renesas_ra_icu.c)
|
||||
zephyr_library_sources_ifdef(CONFIG_NXP_IRQSTEER intc_nxp_irqsteer.c)
|
||||
zephyr_library_sources_ifdef(CONFIG_INTC_MTK_ADSP intc_mtk_adsp.c)
|
||||
zephyr_library_sources_ifdef(CONFIG_WCH_PFIC intc_wch_pfic.c)
|
||||
|
||||
if(CONFIG_INTEL_VTD_ICTL)
|
||||
zephyr_library_include_directories(${ZEPHYR_BASE}/arch/x86/include)
|
||||
|
||||
@@ -108,4 +108,6 @@ source "drivers/interrupt_controller/Kconfig.nxp_irqsteer"
|
||||
|
||||
source "drivers/interrupt_controller/Kconfig.mtk_adsp"
|
||||
|
||||
source "drivers/interrupt_controller/Kconfig.wch_pfic"
|
||||
|
||||
endmenu
|
||||
|
||||
9
drivers/interrupt_controller/Kconfig.wch_pfic
Normal file
9
drivers/interrupt_controller/Kconfig.wch_pfic
Normal file
@@ -0,0 +1,9 @@
|
||||
# Copyright (c) 2024 Michael Hope
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
config WCH_PFIC
|
||||
bool "WCH Programmable Fast Interrupt Controller (PFIC)"
|
||||
default y
|
||||
depends on DT_HAS_WCH_PFIC_ENABLED
|
||||
help
|
||||
Interrupt controller for WCH PFIC.
|
||||
43
drivers/interrupt_controller/intc_wch_pfic.c
Normal file
43
drivers/interrupt_controller/intc_wch_pfic.c
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Michael Hope
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#define DT_DRV_COMPAT wch_pfic
|
||||
|
||||
#include <ch32fun.h>
|
||||
|
||||
#include <zephyr/arch/cpu.h>
|
||||
#include <zephyr/init.h>
|
||||
#include <zephyr/irq.h>
|
||||
#include <zephyr/kernel.h>
|
||||
|
||||
#define SEVONPEND (1 << 4)
|
||||
#define WFITOWFE (1 << 3)
|
||||
|
||||
void arch_irq_enable(unsigned int irq)
|
||||
{
|
||||
PFIC->IENR[irq / 32] = 1 << (irq % 32);
|
||||
}
|
||||
|
||||
void arch_irq_disable(unsigned int irq)
|
||||
{
|
||||
PFIC->IRER[irq / 32] |= 1 << (irq % 32);
|
||||
}
|
||||
|
||||
int arch_irq_is_enabled(unsigned int irq)
|
||||
{
|
||||
return ((PFIC->ISR[irq >> 5] & (1 << (irq & 0x1F))) != 0);
|
||||
}
|
||||
|
||||
static int pfic_init(void)
|
||||
{
|
||||
/* `wfi` is called with interrupts disabled. Configure the PFIC to wake up on any event,
|
||||
* including any interrupt.
|
||||
*/
|
||||
PFIC->SCTLR = SEVONPEND | WFITOWFE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
SYS_INIT(pfic_init, PRE_KERNEL_1, CONFIG_INTC_INIT_PRIORITY);
|
||||
18
dts/bindings/interrupt-controller/wch,pfic.yaml
Normal file
18
dts/bindings/interrupt-controller/wch,pfic.yaml
Normal file
@@ -0,0 +1,18 @@
|
||||
# Copyright (c) 2024 Michael Hope
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
description: WCH CH32V00x Programmable Fast Interrupt Controller (PFIC)
|
||||
|
||||
compatible: "wch,pfic"
|
||||
|
||||
include: [interrupt-controller.yaml, base.yaml]
|
||||
|
||||
properties:
|
||||
reg:
|
||||
required: true
|
||||
|
||||
"#interrupt-cells":
|
||||
const: 1
|
||||
|
||||
interrupt-cells:
|
||||
- irq
|
||||
Reference in New Issue
Block a user