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_K32SRC_FREQUENCY
26	int "32k source clock frequency"
27	default 32768
28
29config CLOCK_CONTROL_NRF_SHELL
30	bool "Shell commands"
31	depends on SHELL
32
33choice CLOCK_CONTROL_NRF_SOURCE
34	prompt "32KHz clock source"
35	default CLOCK_CONTROL_NRF_K32SRC_XTAL
36
37config CLOCK_CONTROL_NRF_K32SRC_RC
38	bool "RC Oscillator"
39	select NRFX_CLOCK_LF_SRC_RC if !CLOCK_CONTROL_NRF_FORCE_ALT
40
41config CLOCK_CONTROL_NRF_K32SRC_XTAL
42	bool "Crystal Oscillator"
43	select NRFX_CLOCK_LF_SRC_XTAL if !CLOCK_CONTROL_NRF_FORCE_ALT
44	select NRFX_CLOCK_LFXO_TWO_STAGE_ENABLED if (!SOC_SERIES_BSIM_NRFXX && \
45						   !CLOCK_CONTROL_NRF_FORCE_ALT)
46
47config CLOCK_CONTROL_NRF_K32SRC_SYNTH
48	bool "Synthesized from HFCLK"
49	depends on !SOC_SERIES_NRF91X
50	select NRFX_CLOCK_LF_SRC_SYNTH if !CLOCK_CONTROL_NRF_FORCE_ALT
51
52config CLOCK_CONTROL_NRF_K32SRC_EXT_LOW_SWING
53	bool "External low swing"
54	depends on SOC_SERIES_NRF52X
55	select NRFX_CLOCK_LFXO_TWO_STAGE_ENABLED if !CLOCK_CONTROL_NRF_FORCE_ALT
56	select NRFX_CLOCK_LF_SRC_LOW_SWING if !CLOCK_CONTROL_NRF_FORCE_ALT
57
58config CLOCK_CONTROL_NRF_K32SRC_EXT_FULL_SWING
59	bool "External full swing"
60	depends on SOC_SERIES_NRF52X
61	select NRFX_CLOCK_LFXO_TWO_STAGE_ENABLED if !CLOCK_CONTROL_NRF_FORCE_ALT
62	select NRFX_CLOCK_LF_SRC_FULL_SWING if !CLOCK_CONTROL_NRF_FORCE_ALT
63
64endchoice
65
66config CLOCK_CONTROL_NRF_K32SRC_RC_CALIBRATION
67	bool "LF clock calibration"
68	depends on !SOC_SERIES_NRF91X && CLOCK_CONTROL_NRF_K32SRC_RC
69	default y if !SOC_NRF53_CPUNET_ENABLE
70	select NRFX_CLOCK_LF_CAL_ENABLED if !CLOCK_CONTROL_NRF_FORCE_ALT
71	help
72	  If calibration is disabled when RC is used for low frequency clock then
73	  accuracy of the low frequency clock will degrade. Disable on your own
74	  risk.
75
76if CLOCK_CONTROL_NRF_K32SRC_RC_CALIBRATION
77
78config CLOCK_CONTROL_NRF_DRIVER_CALIBRATION
79	bool
80	depends on !CLOCK_CONTROL_NRF_FORCE_ALT
81	depends on MULTITHREADING
82	default y
83	help
84	  Enabling indicates that calibration is performed by the clock control driver.
85
86config CLOCK_CONTROL_NRF_CALIBRATION_LF_ALWAYS_ON
87	bool "LF clock is always on"
88	default y if NRF_RTC_TIMER || NRF_GRTC_TIMER
89	help
90	  If RTC or GRTC is used as system timer then LF clock is always on and handling
91	  can be simplified.
92
93config CLOCK_CONTROL_NRF_CALIBRATION_PERIOD
94	int "Calibration opportunity period in milliseconds"
95	default 4000
96	help
97	  Periodically, calibration action is performed. Action includes
98	  temperature measurement followed by clock calibration. Calibration may
99	  be skipped if temperature change (compared to measurement of previous
100	  calibration) did not exceeded CLOCK_CONTROL_NRF_CALIBRATION_TEMP_DIFF
101	  and number of consecutive skips did not exceeded
102	  CLOCK_CONTROL_NRF_CALIBRATION_MAX_SKIP.
103
104config CLOCK_CONTROL_NRF_CALIBRATION_MAX_SKIP
105	int "Maximum number of calibration skips"
106	default 1
107	range 0 $(UINT8_MAX)
108	help
109	  Calibration is skipped when temperature change since last calibration
110	  was less than configured threshold. If number of consecutive skips
111	  reaches configured value then calibration is performed
112	  unconditionally. Set to 0 to perform calibration periodically
113	  regardless of temperature change.
114
115config CLOCK_CONTROL_NRF_CALIBRATION_TEMP_DIFF
116	int "Temperature change triggering calibration (in 0.25 degree units)"
117	default 2
118	help
119	  Calibration is triggered if the temperature has changed by at least
120	  this amount since the last calibration.
121
122if CLOCK_CONTROL_NRF_DRIVER_CALIBRATION
123
124config CLOCK_CONTROL_NRF_CALIBRATION_DEBUG
125	bool "Calibration instrumentation"
126	help
127	  Enables retrieving debug information like number of performed or
128	  skipped calibrations.
129
130config CLOCK_CONTROL_NRF_USES_TEMP_SENSOR
131	bool
132	depends on HAS_HW_NRF_TEMP
133	default y if CLOCK_CONTROL_NRF_CALIBRATION_MAX_SKIP > 0 && \
134		CLOCK_CONTROL_NRF_CALIBRATION_TEMP_DIFF > 0
135	select TEMP_NRF5
136	select SENSOR
137
138endif # CLOCK_CONTROL_NRF_DRIVER_CALIBRATION
139endif # CLOCK_CONTROL_NRF_K32SRC_RC_CALIBRATION
140
141config CLOCK_CONTROL_NRF_HFINT_CALIBRATION
142	bool "HFINT clock calibration"
143	depends on DT_HAS_NORDIC_NRF54L_HFXO_ENABLED
144	depends on !TRUSTED_EXECUTION_NONSECURE
145	select EXPERIMENTAL
146	help
147	  Enables calibration of HFINT clock on every start of HFXO clock.
148
149if CLOCK_CONTROL_NRF_HFINT_CALIBRATION
150
151config CLOCK_CONTROL_NRF_HFINT_CALIBRATION_PERIOD
152	int "HFINT clock calibration period in milliseconds"
153	default 60000
154	help
155	  Periodically, HFINT clock calibration is performed.
156	  This includes requesting HFXO clock and starting actual calibration.
157	  Once the calibration is finished, the HFXO clock is released.
158	  Set to 0 to disable periodic calibration - in such case calibration
159	  will be done only when HFXO is started by the application itself.
160
161endif # CLOCK_CONTROL_NRF_HFINT_CALIBRATION
162
163choice CLOCK_CONTROL_NRF_ACCURACY_PPM
164	prompt "32KHz clock accuracy"
165	default CLOCK_CONTROL_NRF_K32SRC_500PPM if CLOCK_CONTROL_NRF_K32SRC_RC && SOC_COMPATIBLE_NRF52X
166	default CLOCK_CONTROL_NRF_K32SRC_250PPM if CLOCK_CONTROL_NRF_K32SRC_RC
167	default CLOCK_CONTROL_NRF_K32SRC_50PPM
168
169config CLOCK_CONTROL_NRF_K32SRC_500PPM
170	bool "251 ppm to 500 ppm"
171
172config CLOCK_CONTROL_NRF_K32SRC_250PPM
173	bool "151 ppm to 250 ppm"
174
175config CLOCK_CONTROL_NRF_K32SRC_150PPM
176	bool "101 ppm to 150 ppm"
177
178config CLOCK_CONTROL_NRF_K32SRC_100PPM
179	bool "76 ppm to 100 ppm"
180
181config CLOCK_CONTROL_NRF_K32SRC_75PPM
182	bool "51 ppm to 75 ppm"
183
184config CLOCK_CONTROL_NRF_K32SRC_50PPM
185	bool "31 ppm to 50 ppm"
186
187config CLOCK_CONTROL_NRF_K32SRC_30PPM
188	bool "21 ppm to 30 ppm"
189
190config CLOCK_CONTROL_NRF_K32SRC_20PPM
191	bool "0 ppm to 20 ppm"
192
193endchoice
194
195config CLOCK_CONTROL_NRF_ACCURACY
196	int
197	default 500 if CLOCK_CONTROL_NRF_K32SRC_500PPM
198	default 250 if CLOCK_CONTROL_NRF_K32SRC_250PPM
199	default 150 if CLOCK_CONTROL_NRF_K32SRC_150PPM
200	default 100 if CLOCK_CONTROL_NRF_K32SRC_100PPM
201	default 75 if CLOCK_CONTROL_NRF_K32SRC_75PPM
202	default 50 if CLOCK_CONTROL_NRF_K32SRC_50PPM
203	default 30 if CLOCK_CONTROL_NRF_K32SRC_30PPM
204	default 20 if CLOCK_CONTROL_NRF_K32SRC_20PPM
205
206endif # CLOCK_CONTROL_NRF
207
208config CLOCK_CONTROL_NRF2_COMMON
209	bool
210	depends on HAS_NORDIC_DRIVERS
211	select ONOFF
212
213config CLOCK_CONTROL_NRF_HSFLL_GLOBAL
214	bool "Clock control for global HSFLL"
215	depends on DT_HAS_NORDIC_NRF_HSFLL_GLOBAL_ENABLED
216	select NRFS
217	select NRFS_GDFS_SERVICE_ENABLED
218	select CLOCK_CONTROL_NRF2_COMMON
219	default y
220
221if CLOCK_CONTROL_NRF_HSFLL_GLOBAL
222
223config CLOCK_CONTROL_NRF_HSFLL_GLOBAL_TIMEOUT_MS
224	int "Frequency request timeout in milliseconds"
225	default 10000
226
227config CLOCK_CONTROL_NRF_HSFLL_GLOBAL_REQ_LOW_FREQ
228	bool "Request LOW frequency on init"
229	default y
230	help
231	  The GDFS service will default to HIGH frequency until it receives
232	  a lower frequency request. The NRF2 clock controller drivers
233	  expect the clock to be initialized to their lowest frequency, so
234	  we need to send a request on init to align GDFS with the NRF2
235	  clock controller driver.
236
237	  This initial request can be disabled to prevent a potentially
238	  unnecessary HIGH -> LOW -> HIGH cycle given some module will
239	  request a HIGH frequency on init anyway.
240
241config CLOCK_CONTROL_NRF_HSFLL_GLOBAL_INIT_PRIORITY
242	int "Init priority of global HSFLL device driver"
243	default 52
244	help
245	  Must be higher than NRFS backend
246
247endif # CLOCK_CONTROL_NRF_HSFLL_GLOBAL
248
249config CLOCK_CONTROL_NRFS_AUDIOPLL
250	bool "NRFS AudioPLL driver support"
251	depends on DT_HAS_NORDIC_NRFS_AUDIOPLL_ENABLED
252	select NRFS
253	select NRFS_AUDIOPLL_SERVICE_ENABLED
254	select CLOCK_CONTROL_NRF2_COMMON
255	default y
256
257config CLOCK_CONTROL_NRF_FLL16M
258	bool "NRF FLL16M driver support"
259	depends on DT_HAS_NORDIC_NRF_FLL16M_ENABLED
260	select CLOCK_CONTROL_NRF2_COMMON
261	default y
262
263config CLOCK_CONTROL_NRF54H_HFXO
264	bool "NRF54H HFXO driver support"
265	depends on DT_HAS_NORDIC_NRF54H_HFXO_ENABLED
266	select CLOCK_CONTROL_NRF2_COMMON
267	default y
268
269config CLOCK_CONTROL_NRF_HSFLL_LOCAL
270	bool "NRF HSFLL LOCAL driver support"
271	depends on DT_HAS_NORDIC_NRF_HSFLL_LOCAL_ENABLED
272	select NRFS
273	select NRFS_DVFS_LOCAL_DOMAIN
274	select CLOCK_CONTROL_NRF2_COMMON
275	default y
276
277if CLOCK_CONTROL_NRF_HSFLL_LOCAL
278
279config CLOCK_CONTROL_NRF_HSFLL_LOCAL_REQ_LOW_FREQ
280	bool "Local domain scale down after init"
281	help
282	  Request the lowest operating point after DVFS initialization.
283
284config CLOCK_CONTROL_NRF_HSFLL_LOCAL_NRFS_DVFS_TIMEOUT_MS
285	int "Timeout waiting for nrfs dvfs service callback in milliseconds"
286	default 2000
287
288endif # CLOCK_CONTROL_NRF_HSFLL_LOCAL
289
290config CLOCK_CONTROL_NRF_IRON_HSFLL_LOCAL
291	bool "NRF IronSide HSFLL LOCAL driver support"
292	depends on DT_HAS_NORDIC_NRF_IRON_HSFLL_LOCAL_ENABLED
293	select NRF_IRONSIDE_DVFS_SERVICE
294	select CLOCK_CONTROL_NRF2_COMMON
295	default y
296
297if CLOCK_CONTROL_NRF_IRON_HSFLL_LOCAL
298
299config CLOCK_CONTROL_NRF_IRON_HSFLL_LOCAL_REQ_LOW_FREQ
300	bool "Local domain scale down after init"
301	help
302	  Request the lowest operating point after DVFS initialization.
303
304config CLOCK_CONTROL_NRF_IRON_HSFLL_LOCAL_DVFS_TIMEOUT_MS
305	int "Timeout waiting for dvfs request to complete"
306	default 2000
307
308endif # CLOCK_CONTROL_NRF_IRON_HSFLL_LOCAL
309
310config CLOCK_CONTROL_NRF_LFCLK
311	bool "NRF LFCLK driver support"
312	depends on DT_HAS_NORDIC_NRF_LFCLK_ENABLED
313	select NRFS
314	select NRFS_CLOCK_SERVICE_ENABLED
315	select CLOCK_CONTROL_NRF2_COMMON
316	default y
317
318if CLOCK_CONTROL_NRF_LFCLK
319
320config CLOCK_CONTROL_NRF_LFCLK_CLOCK_TIMEOUT_MS
321	int "Timeout waiting for nrfs clock service callback in milliseconds"
322	default 1000
323
324endif # CLOCK_CONTROL_NRF_LFCLK
325
326config CLOCK_CONTROL_NRF_AUXPLL
327	bool "nRF Auxiliary PLL driver"
328	default y
329	depends on DT_HAS_NORDIC_NRF_AUXPLL_ENABLED
330	select CLOCK_CONTROL_NRF2_COMMON
331