hal_nordic: Change scheme for RTC and TIMER reservation

In general, RTC and TIMER driver implements counter API but there
are exception when those peripherals are used in a custom way
(e.g. for system timer or bluetooth). In that case, system must
prevent using counter based on a reserved instance. Previously,
it was managed by Kconfig options but that cannot be maintained
when switching to devicetree configuration of the counter driver.

A new approach removes Kconfig options and instead adds static
asserts in the files which are using direct peripherals. Those
asserts check if given node is not enabled in the device tree.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
This commit is contained in:
Krzysztof Chruscinski 2023-03-17 11:20:33 +01:00 committed by Carles Cufí
commit 9a73b9c80d
8 changed files with 14 additions and 29 deletions

View file

@ -8,7 +8,6 @@ config NRF_RTC_TIMER
depends on CLOCK_CONTROL
depends on SOC_COMPATIBLE_NRF
select TICKLESS_CAPABLE
select NRF_HW_RTC1_RESERVED
help
This module implements a kernel device driver for the nRF Real Time
Counter NRF_RTC1 and provides the standard "system clock driver"

View file

@ -25,6 +25,9 @@
#define RTC_CH_COUNT RTC1_CC_NUM
BUILD_ASSERT(CHAN_COUNT <= RTC_CH_COUNT, "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");
#define COUNTER_BIT_WIDTH 24U
#define COUNTER_SPAN BIT(COUNTER_BIT_WIDTH)

View file

@ -23,7 +23,6 @@ menuconfig NRF_802154_RADIO_DRIVER
depends on HAS_HW_NRF_RADIO_IEEE802154
select DYNAMIC_INTERRUPTS
select ENTROPY_GENERATOR
select NRF_HW_TIMER1_RESERVED
help
This option enables nRF IEEE 802.15.4 radio driver in Zephyr. Note,
that beside the radio peripheral itself, this drivers occupies several

View file

@ -8,6 +8,10 @@
#include <platform/nrf_802154_temperature.h>
#include <zephyr/drivers/entropy.h>
/* Ensure that counter driver for TIMER1 is not enabled. */
BUILD_ASSERT(DT_NODE_HAS_STATUS(DT_NODELABEL(timer1), disabled),
"Counter for TIMER1 must be disabled");
static uint32_t state;
static uint32_t next(void)

View file

@ -299,28 +299,3 @@ config HAS_HW_NRF_WDT0
config HAS_HW_NRF_WDT1
def_bool $(dt_nodelabel_enabled_with_compat,wdt1,$(DT_COMPAT_NORDIC_NRF_WDT))
# Reserved HW peripherals
config NRF_HW_TIMER0_RESERVED
bool
config NRF_HW_TIMER1_RESERVED
bool
config NRF_HW_TIMER2_RESERVED
bool
config NRF_HW_TIMER3_RESERVED
bool
config NRF_HW_TIMER4_RESERVED
bool
config NRF_HW_RTC0_RESERVED
bool
config NRF_HW_RTC1_RESERVED
bool
config NRF_HW_RTC2_RESERVED
bool

View file

@ -108,8 +108,6 @@ choice BT_LL_CHOICE
config BT_LL_SW_SPLIT
bool "Software-based BLE Link Layer"
select ENTROPY_GENERATOR
select NRF_HW_TIMER0_RESERVED
select NRF_HW_RTC0_RESERVED
help
Use Zephyr software BLE Link Layer ULL LLL split implementation.

View file

@ -29,6 +29,10 @@
#include "radio_internal.h"
/* Ensure that counter driver for RTC0 is not enabled. */
BUILD_ASSERT(DT_NODE_HAS_STATUS(DT_NODELABEL(rtc0), disabled),
"Counter for RTC0 must be disabled");
/* Converts the GPIO controller in a FEM property's GPIO specification
* to its nRF register map pointer.
*

View file

@ -187,6 +187,9 @@
#if defined(CONFIG_BT_CTLR_SW_SWITCH_SINGLE_TIMER)
#undef EVENT_TIMER
#define EVENT_TIMER NRF_TIMER0
/* Ensure that counter driver for TIMER0 is not enabled. */
BUILD_ASSERT(DT_NODE_HAS_STATUS(DT_NODELABEL(timer0), disabled),
"Counter for TIMER0 must be disabled");
#define SW_SWITCH_TIMER EVENT_TIMER
#define SW_SWITCH_TIMER_EVTS_COMP_BASE 0
#else /* !CONFIG_BT_CTLR_SW_SWITCH_SINGLE_TIMER */