1# Clock controller driver configuration options
2
3# Copyright (c) 2016 Nordic Semiconductor ASA
4# SPDX-License-Identifier: Apache-2.0
5
6config CLOCK_CONTROL_NRF_FORCE_ALT
7	bool
8	depends on SOC_COMPATIBLE_NRF
9	help
10	  This option can be enabled to force an alternative implementation
11	  of the clock control driver.
12
13menuconfig CLOCK_CONTROL_NRF
14	bool "NRF Clock controller support"
15	default y
16	depends on DT_HAS_NORDIC_NRF_CLOCK_ENABLED
17	select NRFX_CLOCK if !CLOCK_CONTROL_NRF_FORCE_ALT
18	select ONOFF
19	help
20	  Enable support for the Nordic Semiconductor nRFxx series SoC clock
21	  driver.
22
23if CLOCK_CONTROL_NRF
24
25config CLOCK_CONTROL_NRF_SHELL
26	bool "Shell commands"
27	depends on SHELL
28
29choice CLOCK_CONTROL_NRF_SOURCE
30	prompt "32KHz clock source"
31	default CLOCK_CONTROL_NRF_K32SRC_XTAL
32
33config CLOCK_CONTROL_NRF_K32SRC_RC
34	bool "RC Oscillator"
35
36config CLOCK_CONTROL_NRF_K32SRC_XTAL
37	select NRFX_CLOCK_LFXO_TWO_STAGE_ENABLED if (!SOC_SERIES_BSIM_NRFXX && \
38						   !CLOCK_CONTROL_NRF_FORCE_ALT)
39	bool "Crystal Oscillator"
40
41config CLOCK_CONTROL_NRF_K32SRC_SYNTH
42	depends on !SOC_SERIES_NRF91X
43	bool "Synthesized from HFCLK"
44
45config CLOCK_CONTROL_NRF_K32SRC_EXT_LOW_SWING
46	depends on SOC_SERIES_NRF52X
47	select NRFX_CLOCK_LFXO_TWO_STAGE_ENABLED if !CLOCK_CONTROL_NRF_FORCE_ALT
48	bool "External low swing"
49
50config CLOCK_CONTROL_NRF_K32SRC_EXT_FULL_SWING
51	depends on SOC_SERIES_NRF52X
52	select NRFX_CLOCK_LFXO_TWO_STAGE_ENABLED if !CLOCK_CONTROL_NRF_FORCE_ALT
53	bool "External full swing"
54
55endchoice
56
57config CLOCK_CONTROL_NRF_K32SRC_RC_CALIBRATION
58	bool "LF clock calibration"
59	depends on !SOC_SERIES_NRF91X && CLOCK_CONTROL_NRF_K32SRC_RC
60	default y if !BOARD_ENABLE_CPUNET
61	help
62	  If calibration is disabled when RC is used for low frequency clock then
63	  accuracy of the low frequency clock will degrade. Disable on your own
64	  risk.
65
66if CLOCK_CONTROL_NRF_K32SRC_RC_CALIBRATION
67
68config CLOCK_CONTROL_NRF_DRIVER_CALIBRATION
69	bool
70	depends on !CLOCK_CONTROL_NRF_FORCE_ALT
71	depends on MULTITHREADING
72	default y
73	help
74	  Enabling indicates that calibration is performed by the clock control driver.
75
76config CLOCK_CONTROL_NRF_CALIBRATION_LF_ALWAYS_ON
77	bool "LF clock is always on"
78	default y if NRF_RTC_TIMER
79	help
80	  If RTC is used as system timer then LF clock is always on and handling
81	  can be simplified.
82
83config CLOCK_CONTROL_NRF_CALIBRATION_PERIOD
84	int "Calibration opportunity period in milliseconds"
85	default 4000
86	help
87	  Periodically, calibration action is performed. Action includes
88	  temperature measurement followed by clock calibration. Calibration may
89	  be skipped if temperature change (compared to measurement of previous
90	  calibration) did not exceeded CLOCK_CONTROL_NRF_CALIBRATION_TEMP_DIFF
91	  and number of consecutive skips did not exceeded
92	  CLOCK_CONTROL_NRF_CALIBRATION_MAX_SKIP.
93
94config CLOCK_CONTROL_NRF_CALIBRATION_MAX_SKIP
95	int "Maximum number of calibration skips"
96	default 1
97	range 0 255
98	help
99	  Calibration is skipped when temperature change since last calibration
100	  was less than configured threshold. If number of consecutive skips
101	  reaches configured value then calibration is performed
102	  unconditionally. Set to 0 to perform calibration periodically
103	  regardless of temperature change.
104
105config CLOCK_CONTROL_NRF_CALIBRATION_TEMP_DIFF
106	int "Temperature change triggering calibration (in 0.25 degree units)"
107	default 2
108	help
109	  Calibration is triggered if the temperature has changed by at least
110	  this amount since the last calibration.
111
112if CLOCK_CONTROL_NRF_DRIVER_CALIBRATION
113
114config CLOCK_CONTROL_NRF_CALIBRATION_DEBUG
115	bool "Calibration instrumentation"
116	help
117	  Enables retrieving debug information like number of performed or
118	  skipped calibrations.
119
120config CLOCK_CONTROL_NRF_USES_TEMP_SENSOR
121	bool
122	depends on HAS_HW_NRF_TEMP
123	default y if CLOCK_CONTROL_NRF_CALIBRATION_MAX_SKIP > 0 && \
124		CLOCK_CONTROL_NRF_CALIBRATION_TEMP_DIFF > 0
125	select TEMP_NRF5
126	select SENSOR
127
128endif # CLOCK_CONTROL_NRF_DRIVER_CALIBRATION
129endif # CLOCK_CONTROL_NRF_K32SRC_RC_CALIBRATION
130
131choice CLOCK_CONTROL_NRF_ACCURACY_PPM
132	prompt "32KHz clock accuracy"
133	default CLOCK_CONTROL_NRF_K32SRC_500PPM if CLOCK_CONTROL_NRF_K32SRC_RC
134	default CLOCK_CONTROL_NRF_K32SRC_50PPM
135
136config CLOCK_CONTROL_NRF_K32SRC_500PPM
137	bool "251 ppm to 500 ppm"
138
139config CLOCK_CONTROL_NRF_K32SRC_250PPM
140	bool "151 ppm to 250 ppm"
141
142config CLOCK_CONTROL_NRF_K32SRC_150PPM
143	bool "101 ppm to 150 ppm"
144
145config CLOCK_CONTROL_NRF_K32SRC_100PPM
146	bool "76 ppm to 100 ppm"
147
148config CLOCK_CONTROL_NRF_K32SRC_75PPM
149	bool "51 ppm to 75 ppm"
150
151config CLOCK_CONTROL_NRF_K32SRC_50PPM
152	bool "31 ppm to 50 ppm"
153
154config CLOCK_CONTROL_NRF_K32SRC_30PPM
155	bool "21 ppm to 30 ppm"
156
157config CLOCK_CONTROL_NRF_K32SRC_20PPM
158	bool "0 ppm to 20 ppm"
159
160endchoice
161
162config CLOCK_CONTROL_NRF_ACCURACY
163	int
164	default 500 if CLOCK_CONTROL_NRF_K32SRC_500PPM
165	default 250 if CLOCK_CONTROL_NRF_K32SRC_250PPM
166	default 150 if CLOCK_CONTROL_NRF_K32SRC_150PPM
167	default 100 if CLOCK_CONTROL_NRF_K32SRC_100PPM
168	default 75 if CLOCK_CONTROL_NRF_K32SRC_75PPM
169	default 50 if CLOCK_CONTROL_NRF_K32SRC_50PPM
170	default 30 if CLOCK_CONTROL_NRF_K32SRC_30PPM
171	default 20 if CLOCK_CONTROL_NRF_K32SRC_20PPM
172
173endif # CLOCK_CONTROL_NRF
174