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 !SOC_NRF53_CPUNET_ENABLE
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 $(UINT8_MAX)
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 && SOC_COMPATIBLE_NRF52X
134	default CLOCK_CONTROL_NRF_K32SRC_250PPM if CLOCK_CONTROL_NRF_K32SRC_RC
135	default CLOCK_CONTROL_NRF_K32SRC_50PPM
136
137config CLOCK_CONTROL_NRF_K32SRC_500PPM
138	bool "251 ppm to 500 ppm"
139
140config CLOCK_CONTROL_NRF_K32SRC_250PPM
141	bool "151 ppm to 250 ppm"
142
143config CLOCK_CONTROL_NRF_K32SRC_150PPM
144	bool "101 ppm to 150 ppm"
145
146config CLOCK_CONTROL_NRF_K32SRC_100PPM
147	bool "76 ppm to 100 ppm"
148
149config CLOCK_CONTROL_NRF_K32SRC_75PPM
150	bool "51 ppm to 75 ppm"
151
152config CLOCK_CONTROL_NRF_K32SRC_50PPM
153	bool "31 ppm to 50 ppm"
154
155config CLOCK_CONTROL_NRF_K32SRC_30PPM
156	bool "21 ppm to 30 ppm"
157
158config CLOCK_CONTROL_NRF_K32SRC_20PPM
159	bool "0 ppm to 20 ppm"
160
161endchoice
162
163config CLOCK_CONTROL_NRF_ACCURACY
164	int
165	default 500 if CLOCK_CONTROL_NRF_K32SRC_500PPM
166	default 250 if CLOCK_CONTROL_NRF_K32SRC_250PPM
167	default 150 if CLOCK_CONTROL_NRF_K32SRC_150PPM
168	default 100 if CLOCK_CONTROL_NRF_K32SRC_100PPM
169	default 75 if CLOCK_CONTROL_NRF_K32SRC_75PPM
170	default 50 if CLOCK_CONTROL_NRF_K32SRC_50PPM
171	default 30 if CLOCK_CONTROL_NRF_K32SRC_30PPM
172	default 20 if CLOCK_CONTROL_NRF_K32SRC_20PPM
173
174endif # CLOCK_CONTROL_NRF
175
176config CLOCK_CONTROL_NRF2
177	bool "nRF clock control support"
178	default y
179	depends on SOC_SERIES_NRF54HX && !RISCV_CORE_NORDIC_VPR
180	select ONOFF
181	select NRFS if HAS_NRFS
182	imply NRFS_LOCAL_DOMAIN_DVFS_SCALE_DOWN_AFTER_INIT if NRFS_DVFS_LOCAL_DOMAIN
183	help
184	  Support for nRF clock control devices.
185
186if CLOCK_CONTROL_NRF2
187
188config CLOCK_CONTROL_NRF2_NRFS_DVFS_TIMEOUT_MS
189	int "Timeout waiting for nrfs dvfs service callback in milliseconds"
190	default 2000
191
192config CLOCK_CONTROL_NRF2_NRFS_CLOCK_TIMEOUT_MS
193	int "Timeout waiting for nrfs clock service callback in milliseconds"
194	default 1000
195
196config CLOCK_CONTROL_NRF2_GLOBAL_HSFLL
197	bool "Clock control for global HSFLL"
198	depends on NRFS_GDFS_SERVICE_ENABLED
199	default y
200
201if CLOCK_CONTROL_NRF2_GLOBAL_HSFLL
202
203config CLOCK_CONTROL_NRF2_GLOBAL_HSFLL_TIMEOUT_MS
204	int "Frequency request timeout in milliseconds"
205	default 10000
206
207config CLOCK_CONTROL_NRF2_GLOBAL_HSFLL_REQ_LOW_FREQ
208	bool "Request LOW frequency on init"
209	default y
210	help
211	  The GDFS service will default to HIGH frequency until it receives
212	  a lower frequency request. The NRF2 clock controller drivers
213	  expect the clock to be initialized to their lowest frequency, so
214	  we need to send a request on init to align GDFS with the NRF2
215	  clock controller driver.
216
217	  This initial request can be disabled to prevent a potentially
218	  unnecessary HIGH -> LOW -> HIGH cycle given some module will
219	  request a HIGH frequency on init anyway.
220
221config CLOCK_CONTROL_NRF2_GLOBAL_HSFLL_INIT_PRIORITY
222	int "Init priority of global HSFLL device driver"
223	default 52
224	help
225	  Must be higher than NRFS backend
226
227endif # CLOCK_CONTROL_NRF2_GLOBAL_HSFLL
228
229endif # CLOCK_CONTROL_NRF2
230