From bc7a5b6781a47da73b4f8f359e9cccd4a2412279 Mon Sep 17 00:00:00 2001 From: Adam Kondraciuk Date: Thu, 26 Sep 2024 12:40:07 +0200 Subject: [PATCH] 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 --- drivers/timer/Kconfig.nrf_grtc | 9 ++++----- drivers/timer/nrf_grtc_timer.c | 13 +++++-------- modules/hal_nordic/nrfx/nrfx_config.h | 3 --- .../nrfx/nrfx_config_nrf54l15_enga_application.h | 9 --------- .../nrfx/nrfx_config_nrf54l15_enga_flpr.h | 9 --------- .../nrfx/nrfx_config_nrf9230_engb_application.h | 9 --------- .../hal_nordic/nrfx/nrfx_config_nrf9230_engb_ppr.h | 9 --------- .../nrfx/nrfx_config_nrf9230_engb_radiocore.h | 9 --------- soc/nordic/nrf54l/Kconfig | 2 +- 9 files changed, 10 insertions(+), 62 deletions(-) diff --git a/drivers/timer/Kconfig.nrf_grtc b/drivers/timer/Kconfig.nrf_grtc index b136f654252..082c15333dc 100644 --- a/drivers/timer/Kconfig.nrf_grtc +++ b/drivers/timer/Kconfig.nrf_grtc @@ -15,11 +15,10 @@ menuconfig NRF_GRTC_TIMER if NRF_GRTC_TIMER -config NRF_GRTC_SLEEP_ALLOWED - def_bool y - depends on POWEROFF +config NRF_GRTC_ALWAYS_ON + bool help - This feature allows GRTC SYSCOUNTER to go to sleep state. + Always keep the SYSCOUNTER active even if the CPU is in sleep mode. config NRF_GRTC_TIMER_APP_DEFINED_INIT bool "Application defines GRTC initialization" @@ -44,7 +43,7 @@ config NRF_GRTC_TIMER_CLOCK_MANAGEMENT config NRF_GRTC_SYSCOUNTER_SLEEP_MINIMUM_LATENCY int default 1000 - depends on NRF_GRTC_SLEEP_ALLOWED + depends on POWEROFF help The value (in us) ensures that the wakeup event will not fire too early. In other words, applying SYSCOUNTER sleep state for less than diff --git a/drivers/timer/nrf_grtc_timer.c b/drivers/timer/nrf_grtc_timer.c index 401fdd26821..fb9c859caeb 100644 --- a/drivers/timer/nrf_grtc_timer.c +++ b/drivers/timer/nrf_grtc_timer.c @@ -367,7 +367,7 @@ int z_nrf_grtc_timer_capture_read(int32_t chan, uint64_t *captured_time) return 0; } -#if defined(CONFIG_NRF_GRTC_SLEEP_ALLOWED) && defined(CONFIG_NRF_GRTC_START_SYSCOUNTER) +#if defined(CONFIG_POWEROFF) && defined(CONFIG_NRF_GRTC_START_SYSCOUNTER) int z_nrf_grtc_wakeup_prepare(uint64_t wake_time_us) { nrfx_err_t err_code; @@ -432,7 +432,7 @@ int z_nrf_grtc_wakeup_prepare(uint64_t wake_time_us) k_spin_unlock(&lock, key); return 0; } -#endif /* CONFIG_NRF_GRTC_SLEEP_ALLOWED */ +#endif /* CONFIG_POWEROFF */ uint32_t sys_clock_cycle_get_32(void) { @@ -465,12 +465,6 @@ static int sys_clock_driver_init(void) { nrfx_err_t err_code; -#if defined(CONFIG_NRF_GRTC_TIMER_CLOCK_MANAGEMENT) && \ - (defined(NRF_GRTC_HAS_CLKSEL) && (NRF_GRTC_HAS_CLKSEL == 1)) - /* Use System LFCLK as the low-frequency clock source during initialization. */ - nrfx_grtc_clock_source_set(NRF_GRTC_CLKSEL_LFCLK); -#endif - IRQ_CONNECT(DT_IRQN(GRTC_NODE), DT_IRQ(GRTC_NODE, priority), nrfx_isr, nrfx_grtc_irq_handler, 0); @@ -513,6 +507,9 @@ static int sys_clock_driver_init(void) nrfx_grtc_clock_source_set(NRF_GRTC_CLKSEL_LFXO); #endif +#if defined(CONFIG_NRF_GRTC_ALWAYS_ON) + nrfx_grtc_active_request_set(true); +#endif return 0; } diff --git a/modules/hal_nordic/nrfx/nrfx_config.h b/modules/hal_nordic/nrfx/nrfx_config.h index d70db90a764..835b442d756 100644 --- a/modules/hal_nordic/nrfx/nrfx_config.h +++ b/modules/hal_nordic/nrfx/nrfx_config.h @@ -132,9 +132,6 @@ #ifdef CONFIG_NRF_GRTC_TIMER_CLOCK_MANAGEMENT #define NRF_GRTC_HAS_EXTENDED 1 #endif -#ifdef CONFIG_NRF_GRTC_SLEEP_ALLOWED -#define NRFX_GRTC_CONFIG_SLEEP_ALLOWED 1 -#endif #ifdef CONFIG_NRF_GRTC_TIMER_AUTO_KEEP_ALIVE #define NRFX_GRTC_CONFIG_AUTOEN 1 #endif diff --git a/modules/hal_nordic/nrfx/nrfx_config_nrf54l15_enga_application.h b/modules/hal_nordic/nrfx/nrfx_config_nrf54l15_enga_application.h index eeea811aeff..aa23f93c9e3 100644 --- a/modules/hal_nordic/nrfx/nrfx_config_nrf54l15_enga_application.h +++ b/modules/hal_nordic/nrfx/nrfx_config_nrf54l15_enga_application.h @@ -283,15 +283,6 @@ #define NRFX_GRTC_ENABLED 0 #endif -/** - * @brief NRFX_GRTC_CONFIG_SLEEP_ALLOWED - * - * Boolean. Accepted values: 0 and 1. - */ -#ifndef NRFX_GRTC_CONFIG_SLEEP_ALLOWED -#define NRFX_GRTC_CONFIG_SLEEP_ALLOWED 0 -#endif - /** * @brief NRFX_GRTC_CONFIG_AUTOEN * diff --git a/modules/hal_nordic/nrfx/nrfx_config_nrf54l15_enga_flpr.h b/modules/hal_nordic/nrfx/nrfx_config_nrf54l15_enga_flpr.h index 7f3c5a80c2c..568790051a3 100644 --- a/modules/hal_nordic/nrfx/nrfx_config_nrf54l15_enga_flpr.h +++ b/modules/hal_nordic/nrfx/nrfx_config_nrf54l15_enga_flpr.h @@ -283,15 +283,6 @@ #define NRFX_GRTC_ENABLED 0 #endif -/** - * @brief NRFX_GRTC_CONFIG_SLEEP_ALLOWED - * - * Boolean. Accepted values: 0 and 1. - */ -#ifndef NRFX_GRTC_CONFIG_SLEEP_ALLOWED -#define NRFX_GRTC_CONFIG_SLEEP_ALLOWED 0 -#endif - /** * @brief NRFX_GRTC_CONFIG_AUTOEN * diff --git a/modules/hal_nordic/nrfx/nrfx_config_nrf9230_engb_application.h b/modules/hal_nordic/nrfx/nrfx_config_nrf9230_engb_application.h index a7905c199d2..38ce6226468 100644 --- a/modules/hal_nordic/nrfx/nrfx_config_nrf9230_engb_application.h +++ b/modules/hal_nordic/nrfx/nrfx_config_nrf9230_engb_application.h @@ -367,15 +367,6 @@ #define NRFX_GRTC_ENABLED 0 #endif -/** - * @brief NRFX_GRTC_CONFIG_SLEEP_ALLOWED - * - * Boolean. Accepted values: 0 and 1. - */ -#ifndef NRFX_GRTC_CONFIG_SLEEP_ALLOWED -#define NRFX_GRTC_CONFIG_SLEEP_ALLOWED 0 -#endif - /** * @brief NRFX_GRTC_CONFIG_AUTOEN * diff --git a/modules/hal_nordic/nrfx/nrfx_config_nrf9230_engb_ppr.h b/modules/hal_nordic/nrfx/nrfx_config_nrf9230_engb_ppr.h index ae1f931e3da..9ae53d739e9 100644 --- a/modules/hal_nordic/nrfx/nrfx_config_nrf9230_engb_ppr.h +++ b/modules/hal_nordic/nrfx/nrfx_config_nrf9230_engb_ppr.h @@ -322,15 +322,6 @@ #define NRFX_GRTC_ENABLED 0 #endif -/** - * @brief NRFX_GRTC_CONFIG_SLEEP_ALLOWED - * - * Boolean. Accepted values: 0 and 1. - */ -#ifndef NRFX_GRTC_CONFIG_SLEEP_ALLOWED -#define NRFX_GRTC_CONFIG_SLEEP_ALLOWED 0 -#endif - /** * @brief NRFX_GRTC_CONFIG_AUTOEN * diff --git a/modules/hal_nordic/nrfx/nrfx_config_nrf9230_engb_radiocore.h b/modules/hal_nordic/nrfx/nrfx_config_nrf9230_engb_radiocore.h index 84a0a7558e6..98d71e6b385 100644 --- a/modules/hal_nordic/nrfx/nrfx_config_nrf9230_engb_radiocore.h +++ b/modules/hal_nordic/nrfx/nrfx_config_nrf9230_engb_radiocore.h @@ -407,15 +407,6 @@ #define NRFX_GRTC_ENABLED 0 #endif -/** - * @brief NRFX_GRTC_CONFIG_SLEEP_ALLOWED - * - * Boolean. Accepted values: 0 and 1. - */ -#ifndef NRFX_GRTC_CONFIG_SLEEP_ALLOWED -#define NRFX_GRTC_CONFIG_SLEEP_ALLOWED 0 -#endif - /** * @brief NRFX_GRTC_CONFIG_AUTOEN * diff --git a/soc/nordic/nrf54l/Kconfig b/soc/nordic/nrf54l/Kconfig index df17dc35d3e..eeb12fbfab0 100644 --- a/soc/nordic/nrf54l/Kconfig +++ b/soc/nordic/nrf54l/Kconfig @@ -86,7 +86,7 @@ if NRF_GRTC_TIMER config ELV_GRTC_LFXO_ALLOWED bool - depends on NRF_GRTC_SLEEP_ALLOWED + depends on POWEROFF select EXPERIMENTAL help This feature allows using ELV mode when GRTC operates with the LFXO as