diff --git a/drivers/timer/nrf_rtc_timer.c b/drivers/timer/nrf_rtc_timer.c index e0584a3c8b395c..3ead7f303ee6df 100644 --- a/drivers/timer/nrf_rtc_timer.c +++ b/drivers/timer/nrf_rtc_timer.c @@ -15,7 +15,7 @@ #include #include #include -#include +#include #define RTC_PRETICK (IS_ENABLED(CONFIG_SOC_NRF53_RTC_PRETICK) && \ IS_ENABLED(CONFIG_SOC_NRF5340_CPUNET)) @@ -30,8 +30,8 @@ BUILD_ASSERT(CHAN_COUNT <= CHAN_COUNT_MAX, "Not enough compare channels"); /* Ensure that counter driver for RTC1 is not enabled. */ -BUILD_ASSERT(DT_NODE_HAS_STATUS(DT_NODELABEL(RTC_LABEL), disabled), - "Counter for RTC1 must be disabled"); +BUILD_ASSERT(DT_NODE_HAS_STATUS(DT_NODELABEL(RTC_LABEL), reserved), + "Counter for RTC1 must be reserved"); #define COUNTER_BIT_WIDTH 24U #define COUNTER_SPAN BIT(COUNTER_BIT_WIDTH) @@ -176,7 +176,7 @@ static void compare_int_unlock(int32_t chan, bool key) atomic_or(&int_mask, BIT(chan)); nrfy_rtc_int_enable(RTC, NRF_RTC_CHANNEL_INT_MASK(chan)); if (atomic_get(&force_isr_mask) & BIT(chan)) { - NVIC_SetPendingIRQ(RTC_IRQn); + sys_irq_trigger(SYS_DT_IRQN(DT_NODELABEL(RTC_LABEL))); } } } @@ -719,9 +719,9 @@ static void int_event_disable_rtc(void) void sys_clock_disable(void) { nrf_rtc_task_trigger(RTC, NRF_RTC_TASK_STOP); - irq_disable(RTC_IRQn); + sys_irq_disable(SYS_DT_IRQN(DT_NODELABEL(RTC_LABEL))); int_event_disable_rtc(); - NVIC_ClearPendingIRQ(RTC_IRQn); + sys_irq_clear(SYS_DT_IRQN(DT_NODELABEL(RTC_LABEL))); } static int sys_clock_driver_init(void) @@ -744,11 +744,9 @@ static int sys_clock_driver_init(void) nrfy_rtc_int_enable(RTC, NRF_RTC_INT_OVERFLOW_MASK); - NVIC_ClearPendingIRQ(RTC_IRQn); - - IRQ_CONNECT(RTC_IRQn, DT_IRQ(DT_NODELABEL(RTC_LABEL), priority), - rtc_nrf_isr, 0, 0); - irq_enable(RTC_IRQn); + sys_irq_configure(SYS_DT_IRQN(DT_NODELABEL(RTC_LABEL)), + SYS_DT_IRQ_FLAGS(DT_NODELABEL(RTC_LABEL))); + sys_irq_enable(SYS_DT_IRQN(DT_NODELABEL(RTC_LABEL))); nrfy_rtc_task_trigger(RTC, NRF_RTC_TASK_CLEAR); nrfy_rtc_task_trigger(RTC, NRF_RTC_TASK_START); diff --git a/tests/kernel/sys_irq/dynamic_irq/boards/b_u585i_iot02a.conf b/tests/kernel/sys_irq/dynamic_irq/boards/b_u585i_iot02a.conf new file mode 100644 index 00000000000000..2844d6967b9f57 --- /dev/null +++ b/tests/kernel/sys_irq/dynamic_irq/boards/b_u585i_iot02a.conf @@ -0,0 +1,6 @@ +# Copyright (c) 2024 Bjarki Arge Andreasen +# SPDX-License-Identifier: Apache-2.0 + +CONFIG_GEN_ISR_TABLES=n +CONFIG_GEN_IRQ_VECTOR_TABLE=n +CONFIG_LTO=y diff --git a/tests/kernel/sys_irq/dynamic_irq/boards/b_u585i_iot02a.overlay b/tests/kernel/sys_irq/dynamic_irq/boards/b_u585i_iot02a.overlay index 375c1c38ee9c4b..b3c9ff0538eb2f 100644 --- a/tests/kernel/sys_irq/dynamic_irq/boards/b_u585i_iot02a.overlay +++ b/tests/kernel/sys_irq/dynamic_irq/boards/b_u585i_iot02a.overlay @@ -9,8 +9,6 @@ test-intd0 = &spi1; test-intd1 = &spi2; }; - - soc }; &spi1 { @@ -24,3 +22,7 @@ &nvic { interrupt-lines = <128>; }; + +&exti { + interrupt-lines = <16>; +}; diff --git a/tests/kernel/sys_irq/dynamic_irq/boards/nrf9160dk_nrf9160.conf b/tests/kernel/sys_irq/dynamic_irq/boards/nrf9160dk_nrf9160.conf new file mode 100644 index 00000000000000..2844d6967b9f57 --- /dev/null +++ b/tests/kernel/sys_irq/dynamic_irq/boards/nrf9160dk_nrf9160.conf @@ -0,0 +1,6 @@ +# Copyright (c) 2024 Bjarki Arge Andreasen +# SPDX-License-Identifier: Apache-2.0 + +CONFIG_GEN_ISR_TABLES=n +CONFIG_GEN_IRQ_VECTOR_TABLE=n +CONFIG_LTO=y diff --git a/tests/kernel/sys_irq/dynamic_irq/boards/nrf9160dk_nrf9160.overlay b/tests/kernel/sys_irq/dynamic_irq/boards/nrf9160dk_nrf9160.overlay new file mode 100644 index 00000000000000..cad463b57660d1 --- /dev/null +++ b/tests/kernel/sys_irq/dynamic_irq/boards/nrf9160dk_nrf9160.overlay @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024 Bjarki Arge Andreasen + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/ { + aliases { + test-intd0 = &spi1; + test-intd1 = &spi2; + }; +}; + +&spi1 { + status = "reserved"; +}; + +&spi2 { + status = "reserved"; +}; + +&rtc1 { + status = "reserved"; +}; + +&nvic { + interrupt-lines = <65>; +}; diff --git a/tests/kernel/sys_irq/dynamic_irq/prj.conf b/tests/kernel/sys_irq/dynamic_irq/prj.conf index 84cb7fae321730..14f1cf187c3f57 100644 --- a/tests/kernel/sys_irq/dynamic_irq/prj.conf +++ b/tests/kernel/sys_irq/dynamic_irq/prj.conf @@ -4,8 +4,6 @@ CONFIG_ZTEST=y CONFIG_ZTEST_FAIL_FAST=y CONFIG_INTC=y -CONFIG_GEN_ISR_TABLES=n -CONFIG_GEN_IRQ_VECTOR_TABLE=n CONFIG_SYS_IRQ=y CONFIG_SYS_IRQ_DYNAMIC=y CONFIG_LOG=y diff --git a/tests/kernel/sys_irq/dynamic_irq/testcase.yaml b/tests/kernel/sys_irq/dynamic_irq/testcase.yaml new file mode 100644 index 00000000000000..0449de5fe9794e --- /dev/null +++ b/tests/kernel/sys_irq/dynamic_irq/testcase.yaml @@ -0,0 +1,5 @@ +tests: + kernel.sys_irq.dynamic_irq: + platform_allow: + - b_u585i_iot02a + - nrf9160dk/nrf9160 diff --git a/tests/kernel/sys_irq/irq/boards/b_u585i_iot02a.conf b/tests/kernel/sys_irq/irq/boards/b_u585i_iot02a.conf new file mode 100644 index 00000000000000..2844d6967b9f57 --- /dev/null +++ b/tests/kernel/sys_irq/irq/boards/b_u585i_iot02a.conf @@ -0,0 +1,6 @@ +# Copyright (c) 2024 Bjarki Arge Andreasen +# SPDX-License-Identifier: Apache-2.0 + +CONFIG_GEN_ISR_TABLES=n +CONFIG_GEN_IRQ_VECTOR_TABLE=n +CONFIG_LTO=y diff --git a/tests/kernel/sys_irq/irq/boards/b_u585i_iot02a.overlay b/tests/kernel/sys_irq/irq/boards/b_u585i_iot02a.overlay index 375c1c38ee9c4b..b3c9ff0538eb2f 100644 --- a/tests/kernel/sys_irq/irq/boards/b_u585i_iot02a.overlay +++ b/tests/kernel/sys_irq/irq/boards/b_u585i_iot02a.overlay @@ -9,8 +9,6 @@ test-intd0 = &spi1; test-intd1 = &spi2; }; - - soc }; &spi1 { @@ -24,3 +22,7 @@ &nvic { interrupt-lines = <128>; }; + +&exti { + interrupt-lines = <16>; +}; diff --git a/tests/kernel/sys_irq/irq/prj.conf b/tests/kernel/sys_irq/irq/prj.conf index 455b23108189ce..f3baedd3f4d6dc 100644 --- a/tests/kernel/sys_irq/irq/prj.conf +++ b/tests/kernel/sys_irq/irq/prj.conf @@ -2,9 +2,8 @@ # SPDX-License-Identifier: Apache-2.0 CONFIG_ZTEST=y +CONFIG_ZTEST_FAIL_FAST=y CONFIG_INTC=y -CONFIG_GEN_ISR_TABLES=n -CONFIG_GEN_IRQ_VECTOR_TABLE=n CONFIG_SYS_IRQ=y CONFIG_LOG=y CONFIG_SYS_IRQ_LOG_SPURIOUS=y diff --git a/tests/kernel/sys_irq/irq/testcase.yaml b/tests/kernel/sys_irq/irq/testcase.yaml new file mode 100644 index 00000000000000..95a5fab25413fa --- /dev/null +++ b/tests/kernel/sys_irq/irq/testcase.yaml @@ -0,0 +1,4 @@ +tests: + kernel.sys_irq.irq: + platform_allow: + - b_u585i_iot02a