From 5bba170ea749526a58d62ab2c06c61a699bd71b8 Mon Sep 17 00:00:00 2001 From: Marcin Szymczyk Date: Thu, 4 Apr 2024 11:08:44 +0200 Subject: [PATCH] drivers: interrupt_controller: add intc_nrfx_clic Add interrupt controller driver for Nordic Semiconductor VPR CLIC. Signed-off-by: Marcin Szymczyk --- drivers/interrupt_controller/CMakeLists.txt | 2 ++ drivers/interrupt_controller/Kconfig.clic | 11 ++++++ drivers/interrupt_controller/intc_nrfx_clic.S | 15 ++++++++ drivers/interrupt_controller/intc_nrfx_clic.c | 34 +++++++++++++++++++ 4 files changed, 62 insertions(+) create mode 100644 drivers/interrupt_controller/intc_nrfx_clic.S create mode 100644 drivers/interrupt_controller/intc_nrfx_clic.c diff --git a/drivers/interrupt_controller/CMakeLists.txt b/drivers/interrupt_controller/CMakeLists.txt index 0df052e604..9e07386e59 100644 --- a/drivers/interrupt_controller/CMakeLists.txt +++ b/drivers/interrupt_controller/CMakeLists.txt @@ -33,6 +33,8 @@ zephyr_library_sources_ifdef(CONFIG_VEXRISCV_LITEX_IRQ intc_vexriscv_litex. zephyr_library_sources_ifdef(CONFIG_VIM intc_vim.c) zephyr_library_sources_ifdef(CONFIG_NUCLEI_ECLIC intc_nuclei_eclic.c) zephyr_library_sources_ifdef(CONFIG_NUCLEI_ECLIC intc_nuclei_eclic.S) +zephyr_library_sources_ifdef(CONFIG_NRFX_CLIC intc_nrfx_clic.c) +zephyr_library_sources_ifdef(CONFIG_NRFX_CLIC intc_nrfx_clic.S) zephyr_library_sources_ifdef(CONFIG_NXP_S32_EIRQ intc_eirq_nxp_s32.c) zephyr_library_sources_ifdef(CONFIG_NXP_S32_WKPU intc_wkpu_nxp_s32.c) zephyr_library_sources_ifdef(CONFIG_XMC4XXX_INTC intc_xmc4xxx.c) diff --git a/drivers/interrupt_controller/Kconfig.clic b/drivers/interrupt_controller/Kconfig.clic index a047a83233..fff8d1dffa 100644 --- a/drivers/interrupt_controller/Kconfig.clic +++ b/drivers/interrupt_controller/Kconfig.clic @@ -10,9 +10,20 @@ config NUCLEI_ECLIC help Interrupt controller for Nuclei SoC core. +config NRFX_CLIC + bool "VPR Core Local Interrpt Controller (CLIC)" + default y + depends on DT_HAS_NORDIC_NRF_CLIC_ENABLED + help + Interrupt controller for Nordic VPR cores. + +if NUCLEI_ECLIC + config LEGACY_CLIC bool "Use the legacy clic specification" depends on RISCV_HAS_CLIC help Enables legacy clic, where smclicshv extension is not supported and hardware vectoring is set via mode bits of mtvec. + +endif # NUCLEI_ECLIC diff --git a/drivers/interrupt_controller/intc_nrfx_clic.S b/drivers/interrupt_controller/intc_nrfx_clic.S new file mode 100644 index 0000000000..05b2d4a191 --- /dev/null +++ b/drivers/interrupt_controller/intc_nrfx_clic.S @@ -0,0 +1,15 @@ +/* + * Copyright (C) 2024 Nordic Semiconductor ASA + * SPDX-License-Identifier: Apache-2.0 + */ + +#include + +/* Exports */ +GTEXT(__soc_handle_irq) + +/* + * No need to clear anything, pending bit is cleared by HW. + */ +SECTION_FUNC(exception.other, __soc_handle_irq) + ret diff --git a/drivers/interrupt_controller/intc_nrfx_clic.c b/drivers/interrupt_controller/intc_nrfx_clic.c new file mode 100644 index 0000000000..7d6629e376 --- /dev/null +++ b/drivers/interrupt_controller/intc_nrfx_clic.c @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024, Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include + +void riscv_clic_irq_enable(uint32_t irq) +{ + nrf_vpr_clic_int_enable_set(NRF_VPRCLIC, irq, true); +} + +void riscv_clic_irq_disable(uint32_t irq) +{ + nrf_vpr_clic_int_enable_set(NRF_VPRCLIC, irq, false); +} + +int riscv_clic_irq_is_enabled(uint32_t irq) +{ + return nrf_vpr_clic_int_enable_check(NRF_VPRCLIC, irq); +} + +void riscv_clic_irq_priority_set(uint32_t irq, uint32_t pri, uint32_t flags) +{ + nrf_vpr_clic_int_priority_set(NRF_VPRCLIC, irq, NRF_VPR_CLIC_INT_TO_PRIO(pri)); +} + +void riscv_clic_irq_set_pending(uint32_t irq) +{ + nrf_vpr_clic_int_pending_set(NRF_VPRCLIC, irq); +}