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	depends on SOC_COMPATIBLE_NRF
16	select NRFX_CLOCK if !CLOCK_CONTROL_NRF_FORCE_ALT
17	default y
18	help
19	  Enable support for the Nordic Semiconductor nRFxx series SoC clock
20	  driver.
21
22if CLOCK_CONTROL_NRF
23
24config CLOCK_CONTROL_NRF_SHELL
25	bool "Shell commands"
26	depends on SHELL
27	default y if 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 "Enable LF clock calibration"
59	depends on !SOC_SERIES_NRF91X && CLOCK_CONTROL_NRF_K32SRC_RC
60	default y
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_CALIBRATION_LF_ALWAYS_ON
69	bool "LF clock is always on"
70	default y if NRF_RTC_TIMER
71	help
72	  If RTC is used as system timer then LF clock is always on and handling
73	  can be simplified.
74
75config CLOCK_CONTROL_NRF_CALIBRATION_PERIOD
76	int "Calibration opportunity period in milliseconds"
77	default 4000
78	help
79	  Periodically, calibration action is performed. Action includes
80	  temperature measurement followed by clock calibration. Calibration may
81	  be skipped if temperature change (compared to measurement of previous
82	  calibration) did not exceeded CLOCK_CONTROL_NRF_CALIBRATION_TEMP_DIFF
83	  and number of consecutive skips did not exceeded
84	  CLOCK_CONTROL_NRF_CALIBRATION_MAX_SKIP.
85
86config CLOCK_CONTROL_NRF_CALIBRATION_MAX_SKIP
87	int "Maximum number of calibration skips"
88	default 1
89	range 0 255
90	help
91	  Calibration is skipped when temperature change since last calibration
92	  was less than configured threshold. If number of consecutive skips
93	  reaches configured value then calibration is performed
94	  unconditionally. Set to 0 to perform calibration periodically
95	  regardless of temperature change.
96
97config CLOCK_CONTROL_NRF_CALIBRATION_TEMP_DIFF
98	int "Temperature change triggering calibration (in 0.25 degree units)"
99	default 2
100	help
101	  Calibration is triggered if the temperature has changed by at least
102	  this amount since the last calibration.
103
104config CLOCK_CONTROL_NRF_CALIBRATION_DEBUG
105	bool "Calibration instrumentation"
106	help
107	  Enables retrieving debug information like number of performed or
108	  skipped calibrations.
109
110config CLOCK_CONTROL_NRF_USES_TEMP_SENSOR
111	bool
112	depends on HAS_HW_NRF_TEMP
113	default y if CLOCK_CONTROL_NRF_CALIBRATION_MAX_SKIP > 0 && \
114		CLOCK_CONTROL_NRF_CALIBRATION_TEMP_DIFF > 0
115	select TEMP_NRF5
116	select SENSOR
117
118endif # CLOCK_CONTROL_NRF_K32SRC_RC_CALIBRATION
119
120choice CLOCK_CONTROL_NRF_ACCURACY_PPM
121	prompt "32KHz clock accuracy"
122	default CLOCK_CONTROL_NRF_K32SRC_500PPM if CLOCK_CONTROL_NRF_K32SRC_RC
123	default CLOCK_CONTROL_NRF_K32SRC_50PPM
124
125config CLOCK_CONTROL_NRF_K32SRC_500PPM
126	bool "251 ppm to 500 ppm"
127
128config CLOCK_CONTROL_NRF_K32SRC_250PPM
129	bool "151 ppm to 250 ppm"
130
131config CLOCK_CONTROL_NRF_K32SRC_150PPM
132	bool "101 ppm to 150 ppm"
133
134config CLOCK_CONTROL_NRF_K32SRC_100PPM
135	bool "76 ppm to 100 ppm"
136
137config CLOCK_CONTROL_NRF_K32SRC_75PPM
138	bool "51 ppm to 75 ppm"
139
140config CLOCK_CONTROL_NRF_K32SRC_50PPM
141	bool "31 ppm to 50 ppm"
142
143config CLOCK_CONTROL_NRF_K32SRC_30PPM
144	bool "21 ppm to 30 ppm"
145
146config CLOCK_CONTROL_NRF_K32SRC_20PPM
147	bool "0 ppm to 20 ppm"
148
149endchoice
150
151config CLOCK_CONTROL_NRF_ACCURACY
152	int
153	default 500 if CLOCK_CONTROL_NRF_K32SRC_500PPM
154	default 250 if CLOCK_CONTROL_NRF_K32SRC_250PPM
155	default 150 if CLOCK_CONTROL_NRF_K32SRC_150PPM
156	default 100 if CLOCK_CONTROL_NRF_K32SRC_100PPM
157	default 75 if CLOCK_CONTROL_NRF_K32SRC_75PPM
158	default 50 if CLOCK_CONTROL_NRF_K32SRC_50PPM
159	default 30 if CLOCK_CONTROL_NRF_K32SRC_30PPM
160	default 20 if CLOCK_CONTROL_NRF_K32SRC_20PPM
161
162endif # CLOCK_CONTROL_NRF
163