Skip to content

Commit 9a73b9c

Browse files
nordic-krchcarlescufi
authored andcommitted
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 <[email protected]>
1 parent d25b031 commit 9a73b9c

File tree

8 files changed

+14
-29
lines changed

8 files changed

+14
-29
lines changed

drivers/timer/Kconfig.nrf_rtc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ config NRF_RTC_TIMER
88
depends on CLOCK_CONTROL
99
depends on SOC_COMPATIBLE_NRF
1010
select TICKLESS_CAPABLE
11-
select NRF_HW_RTC1_RESERVED
1211
help
1312
This module implements a kernel device driver for the nRF Real Time
1413
Counter NRF_RTC1 and provides the standard "system clock driver"

drivers/timer/nrf_rtc_timer.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
#define RTC_CH_COUNT RTC1_CC_NUM
2626

2727
BUILD_ASSERT(CHAN_COUNT <= RTC_CH_COUNT, "Not enough compare channels");
28+
/* Ensure that counter driver for RTC1 is not enabled. */
29+
BUILD_ASSERT(DT_NODE_HAS_STATUS(DT_NODELABEL(RTC_LABEL), disabled),
30+
"Counter for RTC1 must be disabled");
2831

2932
#define COUNTER_BIT_WIDTH 24U
3033
#define COUNTER_SPAN BIT(COUNTER_BIT_WIDTH)

modules/hal_nordic/Kconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ menuconfig NRF_802154_RADIO_DRIVER
2323
depends on HAS_HW_NRF_RADIO_IEEE802154
2424
select DYNAMIC_INTERRUPTS
2525
select ENTROPY_GENERATOR
26-
select NRF_HW_TIMER1_RESERVED
2726
help
2827
This option enables nRF IEEE 802.15.4 radio driver in Zephyr. Note,
2928
that beside the radio peripheral itself, this drivers occupies several

modules/hal_nordic/nrf_802154/radio/platform/nrf_802154_random_zephyr.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
#include <platform/nrf_802154_temperature.h>
99
#include <zephyr/drivers/entropy.h>
1010

11+
/* Ensure that counter driver for TIMER1 is not enabled. */
12+
BUILD_ASSERT(DT_NODE_HAS_STATUS(DT_NODELABEL(timer1), disabled),
13+
"Counter for TIMER1 must be disabled");
14+
1115
static uint32_t state;
1216

1317
static uint32_t next(void)

soc/arm/nordic_nrf/Kconfig.peripherals

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -299,28 +299,3 @@ config HAS_HW_NRF_WDT0
299299

300300
config HAS_HW_NRF_WDT1
301301
def_bool $(dt_nodelabel_enabled_with_compat,wdt1,$(DT_COMPAT_NORDIC_NRF_WDT))
302-
303-
# Reserved HW peripherals
304-
config NRF_HW_TIMER0_RESERVED
305-
bool
306-
307-
config NRF_HW_TIMER1_RESERVED
308-
bool
309-
310-
config NRF_HW_TIMER2_RESERVED
311-
bool
312-
313-
config NRF_HW_TIMER3_RESERVED
314-
bool
315-
316-
config NRF_HW_TIMER4_RESERVED
317-
bool
318-
319-
config NRF_HW_RTC0_RESERVED
320-
bool
321-
322-
config NRF_HW_RTC1_RESERVED
323-
bool
324-
325-
config NRF_HW_RTC2_RESERVED
326-
bool

subsys/bluetooth/controller/Kconfig

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,6 @@ choice BT_LL_CHOICE
108108
config BT_LL_SW_SPLIT
109109
bool "Software-based BLE Link Layer"
110110
select ENTROPY_GENERATOR
111-
select NRF_HW_TIMER0_RESERVED
112-
select NRF_HW_RTC0_RESERVED
113111
help
114112
Use Zephyr software BLE Link Layer ULL LLL split implementation.
115113

subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@
2929

3030
#include "radio_internal.h"
3131

32+
/* Ensure that counter driver for RTC0 is not enabled. */
33+
BUILD_ASSERT(DT_NODE_HAS_STATUS(DT_NODELABEL(rtc0), disabled),
34+
"Counter for RTC0 must be disabled");
35+
3236
/* Converts the GPIO controller in a FEM property's GPIO specification
3337
* to its nRF register map pointer.
3438
*

subsys/bluetooth/controller/ll_sw/nordic/hal/nrf5/radio/radio_sim_nrfxx.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,9 @@
187187
#if defined(CONFIG_BT_CTLR_SW_SWITCH_SINGLE_TIMER)
188188
#undef EVENT_TIMER
189189
#define EVENT_TIMER NRF_TIMER0
190+
/* Ensure that counter driver for TIMER0 is not enabled. */
191+
BUILD_ASSERT(DT_NODE_HAS_STATUS(DT_NODELABEL(timer0), disabled),
192+
"Counter for TIMER0 must be disabled");
190193
#define SW_SWITCH_TIMER EVENT_TIMER
191194
#define SW_SWITCH_TIMER_EVTS_COMP_BASE 0
192195
#else /* !CONFIG_BT_CTLR_SW_SWITCH_SINGLE_TIMER */

0 commit comments

Comments
 (0)