Linux Audio

Check our new training course

Loading...
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
# STM32 MCU clock control driver config

# Copyright (c) 2017 Linaro
# Copyright (c) 2017 RnDity Sp. z o.o.
# SPDX-License-Identifier: Apache-2.0

menuconfig CLOCK_CONTROL_STM32_CUBE
	bool "STM32 Reset & Clock Control"
	depends on SOC_FAMILY_STM32
	default y
	select USE_STM32_LL_UTILS
	select USE_STM32_LL_RCC if (SOC_SERIES_STM32MP1X || SOC_SERIES_STM32H7X || \
		SOC_SERIES_STM32H7RSX || SOC_SERIES_STM32F4X || SOC_SERIES_STM32F7X)
	select RUNTIME_NMI if ($(dt_nodelabel_enabled,clk_hse) && \
		$(dt_nodelabel_has_prop,clk_hse,css-enabled))
	help
	  Enable driver for Reset & Clock Control subsystem found
	  in STM32 family of MCUs

if CLOCK_CONTROL_STM32_CUBE

DT_STM32_HSE_CLOCK := $(dt_nodelabel_path,clk_hse)
DT_STM32_HSE_CLOCK_FREQ := $(dt_node_int_prop_int,$(DT_STM32_HSE_CLOCK),clock-frequency)

config CLOCK_STM32_HSE_CLOCK
	int "HSE clock value"
	default "$(DT_STM32_HSE_CLOCK_FREQ)" if "$(dt_nodelabel_enabled,clk_hse)"
	default 8000000
	help
	  Value of external high-speed clock (HSE). This symbol could be optionally
	  configured using device tree by setting "clock-frequency" value of clk_hse
	  node. For instance:
	  &clk_hse{
	  status = "okay";
	  clock-frequency = <DT_FREQ_M(25)>;
	  };
	  Note: Device tree configuration is overridden when current symbol is set:
	  CONFIG_CLOCK_STM32_HSE_CLOCK=32000000

config CLOCK_STM32_MUX
	bool "STM32 clock mux driver"
	default y
	depends on DT_HAS_ST_STM32_CLOCK_MUX_ENABLED
	help
	  Enable driver for STM32 clock mux which don't match an
	  existing clock hardware block but allows to select a clock
	  for a specific domain. For instance per_ck clock on STM32H7 or
	  CLK48 clock

menu "STM32WB0 LSI options"
	depends on DT_HAS_ST_STM32WB0_LSI_CLOCK_ENABLED

config STM32WB0_LSI_MEASUREMENT_WINDOW
	int "Size of LSI measurement window (in periods)"
	default 32
	range 23 256
	help
	  Size of the LSI measurement window (# of LSI periods)

	  The measurement process involves waiting for a certain amount of LSI periods
	  to occur, in order to determine precisely the LSI period, and thus frequency.

	  This property controls how much LSI periods are required for each measure.
	  Bigger window sizes increase accuracy of the measure, but increase the time
	  needed to complete it. Since fLSI >= 24kHz, increasing the measurement window
	  size makes each measure roughly 42µs slower in the worst case.

	  Minimal value is a recommendation from RM0505 Rev.1 §25.8.2, and maximum
	  value is a hardware limitation.

config STM32WB0_LSI_RUNTIME_MEASUREMENT_INTERVAL
	int "LSI run-time measurement interval (ms)"
	default 0
	help
	  Interval at which runtime measurements should be performed, in milliseconds

	  Since the LSI RC frequency is affected by temperature, which is not stable
	  across time, it is recommended to perform measurements of the LSI frequency
	  at regular intervals to obtain better accuracy.

	  This property enables runtime LSI measurement if present. In this case,
	  a background thread is created and performs LSI measurements, sleeping
	  the amount of time specified in this property between each measure. This
	  thread is also tasked with updating the control registers of peripherals
	  affected by slow clock drift such as RTC or IWDG, in collaboration with
	  the peripherals' drivers. Note that this increases the memory footprint
	  of the clock control driver, and may increase power consumption.

	  Setting this option to the default value of "0" disables runtime frequency
	  measurements - the result of a single measure performed at boot will be
	  treated as LSI frequency for the lifetime of the application.

endmenu # DT_HAS_ST_STM32WB0_LSI_CLOCK_ENABLED

# Micro-controller Clock Output (MCO) configuration options
config CLOCK_STM32_MCO
	bool
	default y
	depends on DT_HAS_ST_STM32_CLOCK_MCO_ENABLED || DT_HAS_ST_STM32F1_CLOCK_MCO_ENABLED
	# Although deprecated, MCO configuration via Kconfig takes priority over Device Tree.
	# Prevent DT-based MCO driver from compiling when Kconfig is used.
	depends on CLOCK_STM32_MCO1_SRC_NOCLOCK && CLOCK_STM32_MCO2_SRC_NOCLOCK

choice
	prompt "STM32 MCO1 Clock Source"
	default CLOCK_STM32_MCO1_SRC_NOCLOCK

config CLOCK_STM32_MCO1_SRC_NOCLOCK
	bool "NOCLOCK"
	help
	  MCO1 output disabled, no clock on MCO1

config CLOCK_STM32_MCO1_SRC_EXT_HSE
	bool "EXT_HSE"
	depends on SOC_STM32F10X_CONNECTIVITY_LINE_DEVICE
	select DEPRECATED
	help
	  Use EXT_HSE as source of MCO1
	  This option is deprecated, please use devicetree instead.

config CLOCK_STM32_MCO1_SRC_LSE
	bool "LSE"
	depends on SOC_SERIES_STM32F4X || \
	           SOC_SERIES_STM32F7X || \
	           SOC_SERIES_STM32L4X || \
	           SOC_SERIES_STM32H7X || \
	           SOC_SERIES_STM32H7RSX || \
	           SOC_SERIES_STM32H5X || \
	           SOC_SERIES_STM32U5X
	select DEPRECATED
	help
	  Use LSE as source of MCO1
	  This option is deprecated, please use devicetree instead.

config CLOCK_STM32_MCO1_SRC_HSE
	bool "HSE"
	depends on SOC_SERIES_STM32F1X || \
	           SOC_SERIES_STM32F4X || \
	           SOC_SERIES_STM32F7X || \
	           SOC_SERIES_STM32L4X || \
	           SOC_SERIES_STM32H7X || \
	           SOC_SERIES_STM32H7RSX || \
	           SOC_SERIES_STM32H5X || \
	           SOC_SERIES_STM32U5X
	select DEPRECATED
	help
	  Use HSE as source of MCO1
	  This option is deprecated, please use devicetree instead.

config CLOCK_STM32_MCO1_SRC_LSI
	bool "LSI"
	depends on SOC_SERIES_STM32L4X || \
	           SOC_SERIES_STM32U5X
	select DEPRECATED
	help
	  Use LSI as source of MCO1
	  This option is deprecated, please use devicetree instead.

config CLOCK_STM32_MCO1_SRC_MSI
	bool "MSI"
	depends on SOC_SERIES_STM32L4X
	select DEPRECATED
	help
	  Use MSI as source of MCO1
	  This option is deprecated, please use devicetree instead.

config CLOCK_STM32_MCO1_SRC_MSIK
	bool "MSIK"
	depends on SOC_SERIES_STM32U5X
	select DEPRECATED
	help
	  Use MSIK as source of MCO1
	  This option is deprecated, please use devicetree instead.

config CLOCK_STM32_MCO1_SRC_MSIS
	bool "MSIS"
	depends on SOC_SERIES_STM32U5X
	select DEPRECATED
	help
	  Use MSIS as source of MCO1
	  This option is deprecated, please use devicetree instead.

config CLOCK_STM32_MCO1_SRC_HSI
	bool "HSI"
	depends on SOC_SERIES_STM32F1X || \
	           SOC_SERIES_STM32F4X || \
	           SOC_SERIES_STM32F7X || \
	           SOC_SERIES_STM32H7X || \
	           SOC_SERIES_STM32H7RSX || \
	           SOC_SERIES_STM32H5X
	select DEPRECATED
	help
	  Use HSI as source of MCO1
	  This option is deprecated, please use devicetree instead.

config CLOCK_STM32_MCO1_SRC_HSI16
	bool "HSI16"
	depends on SOC_SERIES_STM32L4X || \
		   SOC_SERIES_STM32U5X
	select DEPRECATED
	help
	  Use HSI16 as source of MCO1
	  This option is deprecated, please use devicetree instead.

config CLOCK_STM32_MCO1_SRC_HSI48
	bool "HSI48"
	depends on SOC_SERIES_STM32L4X || \
	           SOC_SERIES_STM32H7X || \
	           SOC_SERIES_STM32H7RSX || \
	           SOC_SERIES_STM32H5X || \
	           SOC_SERIES_STM32U5X
	select DEPRECATED
	help
	  Use HSI48 as source of MCO1
	  This option is deprecated, please use devicetree instead.

config CLOCK_STM32_MCO1_SRC_PLLCLK
	bool "PLLCLK"
	depends on SOC_SERIES_STM32F4X || \
	           SOC_SERIES_STM32F7X || \
		   SOC_SERIES_STM32L4X || \
		   SOC_SERIES_STM32U5X
	select DEPRECATED
	help
	  Use PLLCLK as source of MCO1
	  This option is deprecated, please use devicetree instead.

config CLOCK_STM32_MCO1_SRC_PLLQCLK
	bool "PLLQ"
	depends on SOC_SERIES_STM32H7X || \
	           SOC_SERIES_STM32H7RSX || \
	           SOC_SERIES_STM32H5X
	select DEPRECATED
	help
	  Use PLLQ as source of MCO1
	  This option is deprecated, please use devicetree instead.

config CLOCK_STM32_MCO1_SRC_PLLCLK_DIV2
	bool "PLLCLK_DIV2"
	depends on SOC_SERIES_STM32F1X
	select DEPRECATED
	help
	  Use PLLCLK/2 as source of MCO1
	  This option is deprecated, please use devicetree instead.

config CLOCK_STM32_MCO1_SRC_PLL2CLK
	bool "PLL2CLK"
	depends on SOC_STM32F10X_CONNECTIVITY_LINE_DEVICE
	select DEPRECATED
	help
	  Use PLL2CLK as source of MCO1
	  This option is deprecated, please use devicetree instead.

config CLOCK_STM32_MCO1_SRC_PLLI2SCLK
	bool "PLLI2SCLK"
	depends on SOC_STM32F10X_CONNECTIVITY_LINE_DEVICE
	select DEPRECATED
	help
	  Use PLLI2SCLK as source of MCO1
	  This option is deprecated, please use devicetree instead.

config CLOCK_STM32_MCO1_SRC_PLLI2SCLK_DIV2
	bool "PLLI2SCLK_DIV2"
	depends on SOC_STM32F10X_CONNECTIVITY_LINE_DEVICE
	select DEPRECATED
	help
	  Use PLLI2SCLK/2 as source of MCO1
	  This option is deprecated, please use devicetree instead.

config CLOCK_STM32_MCO1_SRC_SYSCLK
	bool "SYSCLK"
	depends on SOC_SERIES_STM32F1X || \
	           SOC_SERIES_STM32L4X || \
	           SOC_SERIES_STM32U5X
	select DEPRECATED
	help
	  Use SYSCLK as source of MCO1
	  This option is deprecated, please use devicetree instead.

endchoice

config CLOCK_STM32_MCO1_DIV
	int "MCO1 prescaler"
	depends on !CLOCK_STM32_MCO1_SRC_NOCLOCK && (\
	             SOC_SERIES_STM32F4X || \
	             SOC_SERIES_STM32F7X || \
	             SOC_SERIES_STM32L4X || \
	             SOC_SERIES_STM32H7X || \
	             SOC_SERIES_STM32H7RSX || \
	             SOC_SERIES_STM32H5X || \
	             SOC_SERIES_STM32U5X \
	           )
	default 1
	range 1   5 if SOC_SERIES_STM32F4X || SOC_SERIES_STM32F7X
	range 1   15 if SOC_SERIES_STM32H7X || SOC_SERIES_STM32H7RSX || SOC_SERIES_STM32H5X
	range 1   16 if SOC_SERIES_STM32L4X || SOC_SERIES_STM32U5X
	help
	  Prescaler for MCO1 output clock
	  This option is deprecated, please use devicetree instead.

choice
	prompt "STM32 MCO2 Clock Source"
	default CLOCK_STM32_MCO2_SRC_NOCLOCK

config CLOCK_STM32_MCO2_SRC_NOCLOCK
	bool "NOCLOCK"
	help
	  MCO2 output disabled, no clock on MCO2

config CLOCK_STM32_MCO2_SRC_SYSCLK
	bool "SYSCLK"
	depends on SOC_SERIES_STM32F4X || \
	           SOC_SERIES_STM32F7X || \
	           SOC_SERIES_STM32H7X || \
	           SOC_SERIES_STM32H7RSX || \
	           SOC_SERIES_STM32H5X
	select DEPRECATED
	help
	  Use SYSCLK as source of MCO2
	  This option is deprecated, please use devicetree instead.

config CLOCK_STM32_MCO2_SRC_PLLI2S
	bool "PLLI2S"
	depends on SOC_SERIES_STM32F4X || SOC_SERIES_STM32F7X
	select DEPRECATED
	help
	  Use PLLI2S as source of MCO2
	  This option is deprecated, please use devicetree instead.

config CLOCK_STM32_MCO2_SRC_HSE
	bool "HSE"
	depends on SOC_SERIES_STM32F4X || \
	           SOC_SERIES_STM32F7X || \
	           SOC_SERIES_STM32H7X || \
	           SOC_SERIES_STM32H7RSX || \
	           SOC_SERIES_STM32H5X
	select DEPRECATED
	help
	  Use HSE as source of MCO2
	  This option is deprecated, please use devicetree instead.

config CLOCK_STM32_MCO2_SRC_LSI
	bool "LSI"
	depends on SOC_SERIES_STM32H7X || \
	           SOC_SERIES_STM32H7RSX || \
	           SOC_SERIES_STM32H5X
	help
	  Use LSI as source of MCO2
	  This option is deprecated, please use devicetree instead.

config CLOCK_STM32_MCO2_SRC_CSI
	bool "CSI"
	depends on SOC_SERIES_STM32H7X || \
	           SOC_SERIES_STM32H7RSX || \
	           SOC_SERIES_STM32H5X
	select DEPRECATED
	help
	  Use CSI as source of MCO2
	  This option is deprecated, please use devicetree instead.

config CLOCK_STM32_MCO2_SRC_PLLCLK
	bool "PLLCLK"
	depends on SOC_SERIES_STM32F4X || SOC_SERIES_STM32F7X
	select DEPRECATED
	help
	  Use PLLCLK as source of MCO2
	  This option is deprecated, please use devicetree instead.

config CLOCK_STM32_MCO2_SRC_PLLPCLK
	bool "PLLPCLK"
	depends on SOC_SERIES_STM32H7X || \
	           SOC_SERIES_STM32H7RSX || \
	           SOC_SERIES_STM32H5X
	select DEPRECATED
	help
	  Use PLLPCLK as source of MC02
	  This option is deprecated, please use devicetree instead.

config CLOCK_STM32_MCO2_SRC_PLL2PCLK
	bool "PLL2PCLK"
	depends on SOC_SERIES_STM32H7X || \
	           SOC_SERIES_STM32H7RSX || \
	           SOC_SERIES_STM32H5X
	select DEPRECATED
	help
	  Use PLL2PCLK as source of MC02
	  This option is deprecated, please use devicetree instead.

endchoice

config CLOCK_STM32_MCO2_DIV
	int "MCO2 prescaler"
	depends on !CLOCK_STM32_MCO2_SRC_NOCLOCK && (\
	             SOC_SERIES_STM32F4X || \
	             SOC_SERIES_STM32F7X || \
	             SOC_SERIES_STM32H5X || \
	             SOC_SERIES_STM32H7X || \
	             SOC_SERIES_STM32H7RSX \
	           )
	default 1
	range 1 5 if SOC_SERIES_STM32F4X || SOC_SERIES_STM32F7X
	range 1 15 if SOC_SERIES_STM32H7X || SOC_SERIES_STM32H7RSX || SOC_SERIES_STM32H5X
	help
	  Prescaler for MCO2 output clock

endif # CLOCK_CONTROL_STM32_CUBE