Skip to content

Commit bc7a5b6

Browse files
adamkondraciukcarlescufi
authored andcommitted
drivers: timer: nrf_grtc_timer: Align Zephyr to new AUTOEN read manner
The new GRTC reading manner of the SYSCOUNTER uses hardware mechanism which allows to keep it alive when any of CPUs is not sleeping. Otherwise the SYSCOUNTER goes into sleep mode. Thus there is no longer need to maintain the `CONFIG_NRF_GRTC_SLEEP_ALLOWED` symbol, however if the user wants to have the SYSCOUNTER enabled all the time the `CONFIG_NRF_GRTC_ALWAYS_ON` can be used instead. The nrfx_grtc driver no longer provides the `wakeup-read-sleep` reading manner. Also setting the GRTC clock source is performed by the nrfx_grtc driver so it has been removed from the `sys_clock_driver_init()` function. Signed-off-by: Adam Kondraciuk <[email protected]>
1 parent b2031aa commit bc7a5b6

9 files changed

+10
-62
lines changed

drivers/timer/Kconfig.nrf_grtc

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@ menuconfig NRF_GRTC_TIMER
1515

1616
if NRF_GRTC_TIMER
1717

18-
config NRF_GRTC_SLEEP_ALLOWED
19-
def_bool y
20-
depends on POWEROFF
18+
config NRF_GRTC_ALWAYS_ON
19+
bool
2120
help
22-
This feature allows GRTC SYSCOUNTER to go to sleep state.
21+
Always keep the SYSCOUNTER active even if the CPU is in sleep mode.
2322

2423
config NRF_GRTC_TIMER_APP_DEFINED_INIT
2524
bool "Application defines GRTC initialization"
@@ -44,7 +43,7 @@ config NRF_GRTC_TIMER_CLOCK_MANAGEMENT
4443
config NRF_GRTC_SYSCOUNTER_SLEEP_MINIMUM_LATENCY
4544
int
4645
default 1000
47-
depends on NRF_GRTC_SLEEP_ALLOWED
46+
depends on POWEROFF
4847
help
4948
The value (in us) ensures that the wakeup event will not fire
5049
too early. In other words, applying SYSCOUNTER sleep state for less than

drivers/timer/nrf_grtc_timer.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ int z_nrf_grtc_timer_capture_read(int32_t chan, uint64_t *captured_time)
367367
return 0;
368368
}
369369

370-
#if defined(CONFIG_NRF_GRTC_SLEEP_ALLOWED) && defined(CONFIG_NRF_GRTC_START_SYSCOUNTER)
370+
#if defined(CONFIG_POWEROFF) && defined(CONFIG_NRF_GRTC_START_SYSCOUNTER)
371371
int z_nrf_grtc_wakeup_prepare(uint64_t wake_time_us)
372372
{
373373
nrfx_err_t err_code;
@@ -432,7 +432,7 @@ int z_nrf_grtc_wakeup_prepare(uint64_t wake_time_us)
432432
k_spin_unlock(&lock, key);
433433
return 0;
434434
}
435-
#endif /* CONFIG_NRF_GRTC_SLEEP_ALLOWED */
435+
#endif /* CONFIG_POWEROFF */
436436

437437
uint32_t sys_clock_cycle_get_32(void)
438438
{
@@ -465,12 +465,6 @@ static int sys_clock_driver_init(void)
465465
{
466466
nrfx_err_t err_code;
467467

468-
#if defined(CONFIG_NRF_GRTC_TIMER_CLOCK_MANAGEMENT) && \
469-
(defined(NRF_GRTC_HAS_CLKSEL) && (NRF_GRTC_HAS_CLKSEL == 1))
470-
/* Use System LFCLK as the low-frequency clock source during initialization. */
471-
nrfx_grtc_clock_source_set(NRF_GRTC_CLKSEL_LFCLK);
472-
#endif
473-
474468
IRQ_CONNECT(DT_IRQN(GRTC_NODE), DT_IRQ(GRTC_NODE, priority), nrfx_isr,
475469
nrfx_grtc_irq_handler, 0);
476470

@@ -513,6 +507,9 @@ static int sys_clock_driver_init(void)
513507
nrfx_grtc_clock_source_set(NRF_GRTC_CLKSEL_LFXO);
514508
#endif
515509

510+
#if defined(CONFIG_NRF_GRTC_ALWAYS_ON)
511+
nrfx_grtc_active_request_set(true);
512+
#endif
516513
return 0;
517514
}
518515

modules/hal_nordic/nrfx/nrfx_config.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,6 @@
132132
#ifdef CONFIG_NRF_GRTC_TIMER_CLOCK_MANAGEMENT
133133
#define NRF_GRTC_HAS_EXTENDED 1
134134
#endif
135-
#ifdef CONFIG_NRF_GRTC_SLEEP_ALLOWED
136-
#define NRFX_GRTC_CONFIG_SLEEP_ALLOWED 1
137-
#endif
138135
#ifdef CONFIG_NRF_GRTC_TIMER_AUTO_KEEP_ALIVE
139136
#define NRFX_GRTC_CONFIG_AUTOEN 1
140137
#endif

modules/hal_nordic/nrfx/nrfx_config_nrf54l15_enga_application.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -283,15 +283,6 @@
283283
#define NRFX_GRTC_ENABLED 0
284284
#endif
285285

286-
/**
287-
* @brief NRFX_GRTC_CONFIG_SLEEP_ALLOWED
288-
*
289-
* Boolean. Accepted values: 0 and 1.
290-
*/
291-
#ifndef NRFX_GRTC_CONFIG_SLEEP_ALLOWED
292-
#define NRFX_GRTC_CONFIG_SLEEP_ALLOWED 0
293-
#endif
294-
295286
/**
296287
* @brief NRFX_GRTC_CONFIG_AUTOEN
297288
*

modules/hal_nordic/nrfx/nrfx_config_nrf54l15_enga_flpr.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -283,15 +283,6 @@
283283
#define NRFX_GRTC_ENABLED 0
284284
#endif
285285

286-
/**
287-
* @brief NRFX_GRTC_CONFIG_SLEEP_ALLOWED
288-
*
289-
* Boolean. Accepted values: 0 and 1.
290-
*/
291-
#ifndef NRFX_GRTC_CONFIG_SLEEP_ALLOWED
292-
#define NRFX_GRTC_CONFIG_SLEEP_ALLOWED 0
293-
#endif
294-
295286
/**
296287
* @brief NRFX_GRTC_CONFIG_AUTOEN
297288
*

modules/hal_nordic/nrfx/nrfx_config_nrf9230_engb_application.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -367,15 +367,6 @@
367367
#define NRFX_GRTC_ENABLED 0
368368
#endif
369369

370-
/**
371-
* @brief NRFX_GRTC_CONFIG_SLEEP_ALLOWED
372-
*
373-
* Boolean. Accepted values: 0 and 1.
374-
*/
375-
#ifndef NRFX_GRTC_CONFIG_SLEEP_ALLOWED
376-
#define NRFX_GRTC_CONFIG_SLEEP_ALLOWED 0
377-
#endif
378-
379370
/**
380371
* @brief NRFX_GRTC_CONFIG_AUTOEN
381372
*

modules/hal_nordic/nrfx/nrfx_config_nrf9230_engb_ppr.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -322,15 +322,6 @@
322322
#define NRFX_GRTC_ENABLED 0
323323
#endif
324324

325-
/**
326-
* @brief NRFX_GRTC_CONFIG_SLEEP_ALLOWED
327-
*
328-
* Boolean. Accepted values: 0 and 1.
329-
*/
330-
#ifndef NRFX_GRTC_CONFIG_SLEEP_ALLOWED
331-
#define NRFX_GRTC_CONFIG_SLEEP_ALLOWED 0
332-
#endif
333-
334325
/**
335326
* @brief NRFX_GRTC_CONFIG_AUTOEN
336327
*

modules/hal_nordic/nrfx/nrfx_config_nrf9230_engb_radiocore.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -407,15 +407,6 @@
407407
#define NRFX_GRTC_ENABLED 0
408408
#endif
409409

410-
/**
411-
* @brief NRFX_GRTC_CONFIG_SLEEP_ALLOWED
412-
*
413-
* Boolean. Accepted values: 0 and 1.
414-
*/
415-
#ifndef NRFX_GRTC_CONFIG_SLEEP_ALLOWED
416-
#define NRFX_GRTC_CONFIG_SLEEP_ALLOWED 0
417-
#endif
418-
419410
/**
420411
* @brief NRFX_GRTC_CONFIG_AUTOEN
421412
*

soc/nordic/nrf54l/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ if NRF_GRTC_TIMER
8686

8787
config ELV_GRTC_LFXO_ALLOWED
8888
bool
89-
depends on NRF_GRTC_SLEEP_ALLOWED
89+
depends on POWEROFF
9090
select EXPERIMENTAL
9191
help
9292
This feature allows using ELV mode when GRTC operates with the LFXO as

0 commit comments

Comments
 (0)