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	default y if SHELL
29
30choice CLOCK_CONTROL_NRF_SOURCE
31	prompt "32KHz clock source"
32	default CLOCK_CONTROL_NRF_K32SRC_XTAL
33
34config CLOCK_CONTROL_NRF_K32SRC_RC
35	bool "RC Oscillator"
36
37config CLOCK_CONTROL_NRF_K32SRC_XTAL
38	select NRFX_CLOCK_LFXO_TWO_STAGE_ENABLED if (!SOC_SERIES_BSIM_NRFXX && \
39						   !CLOCK_CONTROL_NRF_FORCE_ALT)
40	bool "Crystal Oscillator"
41
42config CLOCK_CONTROL_NRF_K32SRC_SYNTH
43	depends on !SOC_SERIES_NRF91X
44	bool "Synthesized from HFCLK"
45
46config CLOCK_CONTROL_NRF_K32SRC_EXT_LOW_SWING
47	depends on SOC_SERIES_NRF52X
48	select NRFX_CLOCK_LFXO_TWO_STAGE_ENABLED if !CLOCK_CONTROL_NRF_FORCE_ALT
49	bool "External low swing"
50
51config CLOCK_CONTROL_NRF_K32SRC_EXT_FULL_SWING
52	depends on SOC_SERIES_NRF52X
53	select NRFX_CLOCK_LFXO_TWO_STAGE_ENABLED if !CLOCK_CONTROL_NRF_FORCE_ALT
54	bool "External full swing"
55
56endchoice
57
58config CLOCK_CONTROL_NRF_K32SRC_RC_CALIBRATION
59	bool "LF clock calibration"
60	depends on !SOC_SERIES_NRF91X && CLOCK_CONTROL_NRF_K32SRC_RC
61	default y if !BOARD_ENABLE_CPUNET
62	help
63	  If calibration is disabled when RC is used for low frequency clock then
64	  accuracy of the low frequency clock will degrade. Disable on your own
65	  risk.
66
67if CLOCK_CONTROL_NRF_K32SRC_RC_CALIBRATION
68
69config CLOCK_CONTROL_NRF_DRIVER_CALIBRATION
70	bool
71	depends on !CLOCK_CONTROL_NRF_FORCE_ALT
72	depends on MULTITHREADING
73	default y
74	help
75	  Enabling indicates that calibration is performed by the clock control driver.
76
77config CLOCK_CONTROL_NRF_CALIBRATION_LF_ALWAYS_ON
78	bool "LF clock is always on"
79	default y if NRF_RTC_TIMER
80	help
81	  If RTC is used as system timer then LF clock is always on and handling
82	  can be simplified.
83
84config CLOCK_CONTROL_NRF_CALIBRATION_PERIOD
85	int "Calibration opportunity period in milliseconds"
86	default 4000
87	help
88	  Periodically, calibration action is performed. Action includes
89	  temperature measurement followed by clock calibration. Calibration may
90	  be skipped if temperature change (compared to measurement of previous
91	  calibration) did not exceeded CLOCK_CONTROL_NRF_CALIBRATION_TEMP_DIFF
92	  and number of consecutive skips did not exceeded
93	  CLOCK_CONTROL_NRF_CALIBRATION_MAX_SKIP.
94
95config CLOCK_CONTROL_NRF_CALIBRATION_MAX_SKIP
96	int "Maximum number of calibration skips"
97	default 1
98	range 0 255
99	help
100	  Calibration is skipped when temperature change since last calibration
101	  was less than configured threshold. If number of consecutive skips
102	  reaches configured value then calibration is performed
103	  unconditionally. Set to 0 to perform calibration periodically
104	  regardless of temperature change.
105
106config CLOCK_CONTROL_NRF_CALIBRATION_TEMP_DIFF
107	int "Temperature change triggering calibration (in 0.25 degree units)"
108	default 2
109	help
110	  Calibration is triggered if the temperature has changed by at least
111	  this amount since the last calibration.
112
113if CLOCK_CONTROL_NRF_DRIVER_CALIBRATION
114
115config CLOCK_CONTROL_NRF_CALIBRATION_DEBUG
116	bool "Calibration instrumentation"
117	help
118	  Enables retrieving debug information like number of performed or
119	  skipped calibrations.
120
121config CLOCK_CONTROL_NRF_USES_TEMP_SENSOR
122	bool
123	depends on HAS_HW_NRF_TEMP
124	default y if CLOCK_CONTROL_NRF_CALIBRATION_MAX_SKIP > 0 && \
125		CLOCK_CONTROL_NRF_CALIBRATION_TEMP_DIFF > 0
126	select TEMP_NRF5
127	select SENSOR
128
129endif # CLOCK_CONTROL_NRF_DRIVER_CALIBRATION
130endif # CLOCK_CONTROL_NRF_K32SRC_RC_CALIBRATION
131
132choice CLOCK_CONTROL_NRF_ACCURACY_PPM
133	prompt "32KHz clock accuracy"
134	default CLOCK_CONTROL_NRF_K32SRC_500PPM 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