modules: hal_nordic: nrfx: Decouple clock control from nrfx_clock

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 <krzysztof.chruscinski@nordicsemi.no>
This commit is contained in:
Krzysztof Chruściński 2025-02-12 10:42:58 +01:00 committed by Benjamin Cabé
commit 1ca4b333b4
3 changed files with 41 additions and 11 deletions

View file

@ -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

View file

@ -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"

View file

@ -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