From 1ca4b333b472aacb10ac247183fa189f38643073 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Chru=C5=9Bci=C5=84ski?= Date: Wed, 12 Feb 2025 10:42:58 +0100 Subject: [PATCH] modules: hal_nordic: nrfx: Decouple clock control from nrfx_clock MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Create Kconfig configuration for nrfx_clock driver and use that to export configuration to nrfx via nrfx_kconfig. So far nrfx_kconfig was using Kconfig flags from clock_control which created a fixed connection between nrfx_clock and clock_control and nrfx_clock could not be used without clock_control in Zephyr. Signed-off-by: Krzysztof Chruściński --- drivers/clock_control/Kconfig.nrf | 14 ++++++++++---- modules/hal_nordic/nrfx/Kconfig | 26 +++++++++++++++++++++++++- modules/hal_nordic/nrfx/nrfx_kconfig.h | 12 ++++++------ 3 files changed, 41 insertions(+), 11 deletions(-) diff --git a/drivers/clock_control/Kconfig.nrf b/drivers/clock_control/Kconfig.nrf index 5496957cda0..67185497d94 100644 --- a/drivers/clock_control/Kconfig.nrf +++ b/drivers/clock_control/Kconfig.nrf @@ -32,25 +32,30 @@ choice CLOCK_CONTROL_NRF_SOURCE config CLOCK_CONTROL_NRF_K32SRC_RC bool "RC Oscillator" + select NRFX_CLOCK_LF_SRC_RC if !CLOCK_CONTROL_NRF_FORCE_ALT config CLOCK_CONTROL_NRF_K32SRC_XTAL + bool "Crystal Oscillator" + select NRFX_CLOCK_LF_SRC_XTAL if !CLOCK_CONTROL_NRF_FORCE_ALT select NRFX_CLOCK_LFXO_TWO_STAGE_ENABLED if (!SOC_SERIES_BSIM_NRFXX && \ !CLOCK_CONTROL_NRF_FORCE_ALT) - bool "Crystal Oscillator" config CLOCK_CONTROL_NRF_K32SRC_SYNTH - depends on !SOC_SERIES_NRF91X bool "Synthesized from HFCLK" + depends on !SOC_SERIES_NRF91X + select NRFX_CLOCK_LF_SRC_SYNTH if !CLOCK_CONTROL_NRF_FORCE_ALT config CLOCK_CONTROL_NRF_K32SRC_EXT_LOW_SWING + bool "External low swing" depends on SOC_SERIES_NRF52X select NRFX_CLOCK_LFXO_TWO_STAGE_ENABLED if !CLOCK_CONTROL_NRF_FORCE_ALT - bool "External low swing" + select NRFX_CLOCK_LF_SRC_LOW_SWING if !CLOCK_CONTROL_NRF_FORCE_ALT config CLOCK_CONTROL_NRF_K32SRC_EXT_FULL_SWING + bool "External full swing" depends on SOC_SERIES_NRF52X select NRFX_CLOCK_LFXO_TWO_STAGE_ENABLED if !CLOCK_CONTROL_NRF_FORCE_ALT - bool "External full swing" + select NRFX_CLOCK_LF_SRC_FULL_SWING if !CLOCK_CONTROL_NRF_FORCE_ALT endchoice @@ -58,6 +63,7 @@ config CLOCK_CONTROL_NRF_K32SRC_RC_CALIBRATION bool "LF clock calibration" depends on !SOC_SERIES_NRF91X && CLOCK_CONTROL_NRF_K32SRC_RC default y if !SOC_NRF53_CPUNET_ENABLE + select NRFX_CLOCK_LF_CAL_ENABLED if !CLOCK_CONTROL_NRF_FORCE_ALT help If calibration is disabled when RC is used for low frequency clock then accuracy of the low frequency clock will degrade. Disable on your own diff --git a/modules/hal_nordic/nrfx/Kconfig b/modules/hal_nordic/nrfx/Kconfig index 1d9fa103de2..ceccf25997c 100644 --- a/modules/hal_nordic/nrfx/Kconfig +++ b/modules/hal_nordic/nrfx/Kconfig @@ -17,9 +17,33 @@ config NRFX_CLOCK bool "CLOCK driver" depends on $(dt_nodelabel_exists,clock) +if NRFX_CLOCK + config NRFX_CLOCK_LFXO_TWO_STAGE_ENABLED bool "Two stage start sequence of the low frequency clock" - depends on NRFX_CLOCK + +config NRFX_CLOCK_LF_CAL_ENABLED + bool "LFRC Calibration enabled" + +config NRFX_CLOCK_LF_SRC_RC + bool "RC Oscillator" + +config NRFX_CLOCK_LF_SRC_XTAL + bool "Crystal Oscillator" + +config NRFX_CLOCK_LF_SRC_SYNTH + depends on !SOC_SERIES_NRF91X + bool "Synthesized from HFCLK" + +config NRFX_CLOCK_LF_SRC_LOW_SWING + depends on SOC_SERIES_NRF52X + bool "External low swing" + +config NRFX_CLOCK_LF_SRC_FULL_SWING + depends on SOC_SERIES_NRF52X + bool "External full swing" + +endif # NRFX_CLOCK config NRFX_COMP bool "COMP driver" diff --git a/modules/hal_nordic/nrfx/nrfx_kconfig.h b/modules/hal_nordic/nrfx/nrfx_kconfig.h index ef870a568b2..73a26272d4d 100644 --- a/modules/hal_nordic/nrfx/nrfx_kconfig.h +++ b/modules/hal_nordic/nrfx/nrfx_kconfig.h @@ -28,7 +28,7 @@ #define NRFX_CLOCK_CONFIG_LOG_ENABLED 1 #endif -#ifdef CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC +#ifdef CONFIG_NRFX_CLOCK_LF_SRC_RC #if defined(CONFIG_SOC_SERIES_NRF91X) || defined(CONFIG_SOC_COMPATIBLE_NRF53X) #define NRFX_CLOCK_CONFIG_LF_SRC 1 #else @@ -36,7 +36,7 @@ #endif #endif -#ifdef CONFIG_CLOCK_CONTROL_NRF_K32SRC_XTAL +#ifdef CONFIG_NRFX_CLOCK_LF_SRC_XTAL #if defined(CONFIG_SOC_SERIES_NRF91X) || defined(CONFIG_SOC_COMPATIBLE_NRF53X) #define NRFX_CLOCK_CONFIG_LF_SRC 2 #else @@ -44,7 +44,7 @@ #endif #endif -#ifdef CONFIG_CLOCK_CONTROL_NRF_K32SRC_SYNTH +#ifdef CONFIG_NRFX_CLOCK_LF_SRC_SYNTH #ifdef CONFIG_SOC_COMPATIBLE_NRF53X #define NRFX_CLOCK_CONFIG_LF_SRC 3 #else @@ -52,15 +52,15 @@ #endif #endif -#ifdef CONFIG_CLOCK_CONTROL_NRF_K32SRC_EXT_LOW_SWING +#ifdef CONFIG_NRFX_CLOCK_LF_SRC_LOW_SWING #define NRFX_CLOCK_CONFIG_LF_SRC 131073 #endif -#ifdef CONFIG_CLOCK_CONTROL_NRF_K32SRC_EXT_FULL_SWING +#ifdef CONFIG_NRFX_CLOCK_LF_SRC_FULL_SWING #define NRFX_CLOCK_CONFIG_LF_SRC 196609 #endif -#ifdef CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC_CALIBRATION +#ifdef CONFIG_NRFX_CLOCK_LF_CAL_ENABLED #define NRFX_CLOCK_CONFIG_LF_CAL_ENABLED 1 #endif