Skip to content

Commit c326bf6

Browse files
bjarki-andreasenjhedberg
authored andcommitted
drivers: counter: counter_nrfx_timer: fix fast instance clock ctrl
Update handling of fast instances to take into account whether CONFIG_CLOCK_CONTROL is enabled or not. Signed-off-by: Bjarki Arge Andreasen <[email protected]>
1 parent 13a6dc5 commit c326bf6

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

drivers/counter/counter_nrfx_timer.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,11 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME, LOG_LEVEL);
3535
#define MAYBE_CONST_CONFIG const
3636
#endif
3737

38-
#if NRF_DT_INST_ANY_IS_FAST
39-
#define COUNTER_ANY_FAST 1
38+
#if NRF_DT_INST_ANY_IS_FAST && CONFIG_CLOCK_CONTROL
39+
#define COUNTER_IS_FAST(idx) NRF_DT_INST_IS_FAST(idx)
40+
#define COUNTER_ANY_FAST
41+
#else
42+
#define COUNTER_IS_FAST(idx) 0
4043
#endif
4144

4245
struct counter_nrfx_data {
@@ -460,13 +463,13 @@ static DEVICE_API(counter, counter_nrfx_driver_api) = {
460463
* which is using nrfs (IPC) are initialized later.
461464
*/
462465
#define TIMER_INIT_LEVEL(idx) \
463-
COND_CODE_1(NRF_DT_INST_IS_FAST(idx), (POST_KERNEL), (PRE_KERNEL_1))
466+
COND_CODE_1(COUNTER_IS_FAST(idx), (POST_KERNEL), (PRE_KERNEL_1))
464467

465468
/* Get initialization priority of an instance. Instances that requires clock control
466469
* which is using nrfs (IPC) are initialized later.
467470
*/
468471
#define TIMER_INIT_PRIO(idx) \
469-
COND_CODE_1(NRF_DT_INST_IS_FAST(idx), \
472+
COND_CODE_1(COUNTER_IS_FAST(idx), \
470473
(UTIL_INC(CONFIG_CLOCK_CONTROL_NRF_HSFLL_GLOBAL_INIT_PRIORITY)), \
471474
(CONFIG_COUNTER_INIT_PRIORITY))
472475

@@ -522,8 +525,8 @@ static DEVICE_API(counter, counter_nrfx_driver_api) = {
522525
}, \
523526
.ch_data = counter##idx##_ch_data, \
524527
.timer = (NRF_TIMER_Type *)DT_INST_REG_ADDR(idx), \
525-
IF_ENABLED(NRF_DT_INST_IS_FAST(idx), \
526-
(.clk_dev = DEVICE_DT_GET(DT_CLOCKS_CTLR(DT_DRV_INST(idx))), \
528+
IF_ENABLED(COUNTER_IS_FAST(idx), \
529+
(.clk_dev = DEVICE_DT_GET_OR_NULL(DT_CLOCKS_CTLR(DT_DRV_INST(idx))), \
527530
.clk_spec = { \
528531
.frequency = NRF_PERIPH_GET_FREQUENCY(DT_DRV_INST(idx)), \
529532
.accuracy = 0, \

0 commit comments

Comments
 (0)