Linux Audio

Check our new training course

Embedded Linux Audio

Check our new training course
with Creative Commons CC-BY-SA
lecture materials

Bootlin logo

Elixir Cross Referencer

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
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
# Kconfig - STM32 MCU clock control driver config
#
# Copyright (c) 2017 Linaro
# Copyright (c) 2017 RnDity Sp. z o.o.
#
#  SPDX-License-Identifier: Apache-2.0
#

if SOC_FAMILY_STM32

menuconfig CLOCK_CONTROL_STM32_CUBE
	bool "STM32 Reset & Clock Control"
	select USE_STM32_LL_UTILS
	help
	  Enable driver for Reset & Clock Control subsystem found
	  in STM32 family of MCUs


if CLOCK_CONTROL_STM32_CUBE

config CLOCK_CONTROL_STM32_DEVICE_INIT_PRIORITY
	int "Clock Control Device Priority"
	default 1
	help
	  This option controls the priority of clock control
	  device initialization. Higher priority ensures that the device
	  is initialized earlier in the startup cycle. If unsure, leave
	  at default value 1

choice CLOCK_STM32_SYSCLK_SRC
prompt "STM32 System Clock Source"

config CLOCK_STM32_SYSCLK_SRC_HSE
	bool "HSE"
	help
	  Use HSE as source of SYSCLK

config CLOCK_STM32_SYSCLK_SRC_HSI
	bool "HSI"
	help
	  Use HSI as source of SYSCLK

config CLOCK_STM32_SYSCLK_SRC_MSI
	bool "MSI"
	depends on SOC_SERIES_STM32L0X || SOC_SERIES_STM32L4X
	help
	  Use MSI as source of SYSCLK

config CLOCK_STM32_SYSCLK_SRC_PLL
	bool "PLL"
	help
	  Use PLL as source of SYSCLK

endchoice #CLOCK_STM32_SYSCLK_SRC

config CLOCK_STM32_HSE_BYPASS
	bool "HSE bypass"
	depends on CLOCK_STM32_SYSCLK_SRC_HSE || CLOCK_STM32_PLL_SRC_HSE
	help
	  Enable this option to bypass external high-speed clock (HSE).

config CLOCK_STM32_HSE_CLOCK
	int "HSE clock value"
	depends on CLOCK_STM32_SYSCLK_SRC_HSE || CLOCK_STM32_PLL_SRC_HSE
	default 8000000
	help
	  Value of external high-speed clock (HSE).

config CLOCK_STM32_MSI_RANGE
	int "MSI frequency range"
	depends on CLOCK_STM32_SYSCLK_SRC_MSI
	default 8
	help
	  Frequency range of MSI when MSI range is provided in RCC_CR register
	  Range 0: 100kHz
	  Range 1: 200kHz
	  Range 2 around 400 kHz
	  Range 3 around 800 kHz
	  Range 4: 1 MHz
	  Range 5: 2 MHz
	  Range 6: 4 MHz (reset value)
	  Range 7: 8 MHz
	  Range 8: 16 MHz
	  Range 9: 24 MHz
	  Range 10: 32 MHz
	  Range 11: 48 MHz

choice
prompt "STM32 PLL Clock Source"
depends on CLOCK_STM32_SYSCLK_SRC_PLL
default CLOCK_STM32_PLL_SRC_HSI

config CLOCK_STM32_PLL_SRC_MSI
	bool "MSI"
	depends on SOC_SERIES_STM32L0X || SOC_SERIES_STM32L4X
	help
	  Use MSI as source of PLL

config CLOCK_STM32_PLL_SRC_HSI
	bool "HSI"
	help
	  Use HSI as source of PLL

config CLOCK_STM32_PLL_SRC_HSE
	bool "HSE"
	help
	  Use HSE as source of PLL

config CLOCK_STM32_PLL_SRC_PLL2
	bool "PLL2"
	depends on SOC_STM32F10X_CONNECTIVITY_LINE_DEVICE
	help
	 Use PLL2 as source of main PLL. This is equivalent of defining
	 PLL2 as source PREDIV1SCR. If not selected, default source is HSE.

endchoice

if SOC_SERIES_STM32F0X

config CLOCK_STM32_PLL_PREDIV
	int "PREDIV Prescaler"
	default 1
	range 1 16
	help
	 PREDIV is PLLSCR clock signal prescaler, allowed values: 1 - 16.

config CLOCK_STM32_PLL_PREDIV1
	int "PREDIV1 Prescaler"
	depends on CLOCK_STM32_PLL_SRC_HSE
	default 1
	range 1 16
	help
	 PREDIV is PLLSCR clock signal prescaler, present on STM32F0 SoC having
	 an HSE Oscillator available like the stm32f04xx, stm32f07xx,
	 stm32f09xx and stm32f030xc parts. If configured on a non supported
	 part, the HSI oscillator will be used a default PLL source and this
	 config will be ignored.
	 Allowed values: 1 - 16.

config CLOCK_STM32_PLL_MULTIPLIER
	int "PLL multiplier"
	depends on CLOCK_STM32_SYSCLK_SRC_PLL
	default 6
	range 2 16
	help
	 PLL multiplier, allowed values: 2-16. PLL output must not exceed 48MHz.

endif # SOC_SERIES_STM32F0X

if SOC_SERIES_STM32F1X

config CLOCK_STM32_PLL_XTPRE
	bool "HSE to PLL /2 prescaler"
	depends on SOC_STM32F10X_DENSITY_DEVICE && CLOCK_STM32_PLL_SRC_HSE
	help
	 Enable this option to enable /2 prescaler on HSE to PLL clock signal

config CLOCK_STM32_PLL_MULTIPLIER
	int "PLL multiplier"
	depends on CLOCK_STM32_SYSCLK_SRC_PLL
	default 9
	range 2 16 if SOC_STM32F10X_DENSITY_DEVICE
	range 4 9 if SOC_STM32F10X_CONNECTIVITY_LINE_DEVICE
	help
	 PLL multiplier, PLL output must not exceed 72MHz. Allowed values:
	 Density devices: 2-16
	 Connectivity devices:  4 - 9 and 13 ( used for multiplication factor 6.5).

config CLOCK_STM32_PLL_PREDIV1
	int "PREDIV1 Prescaler"
	depends on SOC_STM32F10X_CONNECTIVITY_LINE_DEVICE && CLOCK_STM32_SYSCLK_SRC_PLL
	default 1
	range 1 16
	help
	 PREDIV1 is PLL clock signal prescaler, allowed values: 1 - 16.

config CLOCK_STM32_PLL2_MULTIPLIER
	int "PLL2 multiplier"
	depends on SOC_STM32F10X_CONNECTIVITY_LINE_DEVICE && CLOCK_STM32_PLL_SRC_PLL2
	default 8
	range 8 20
	help
	 PLL2 multiplier, allowed values: 8 - 20. 15-17-18-19 reserved

config CLOCK_STM32_PLL2_PREDIV2
	int "PREDIV2 Prescaler"
	depends on SOC_STM32F10X_CONNECTIVITY_LINE_DEVICE && CLOCK_STM32_PLL_SRC_PLL2
	default 1
	range 1 16
	help
	 PREDIV2 is PLL2 prescaler, allowed values: 1 - 16.

endif # SOC_SERIES_STM32F1X

if SOC_SERIES_STM32F2X

config CLOCK_STM32_PLL_M_DIVISOR
	int "Division factor for PLL VCO input clock"
	depends on CLOCK_STM32_SYSCLK_SRC_PLL
	default 20
	range 2 63
	help
	 PLLM division factor needs to be set correctly to ensure that the VCO
	 input frequency ranges from 1 to 2 MHz. It is recommended to select a
	 frequency of 2 MHz to limit PLL jitter.
	 Allowed values: 2-63

config CLOCK_STM32_PLL_N_MULTIPLIER
	int "Multiplier factor for PLL VCO output clock"
	depends on CLOCK_STM32_SYSCLK_SRC_PLL
	default 192
	range 192 432
	help
	 PLLN multiplier factor needs to be set correctly to ensure that the
	 VCO output frequency is between 192 and 432 MHz.

config CLOCK_STM32_PLL_P_DIVISOR
	int "PLL division factor for main system clock"
	depends on CLOCK_STM32_SYSCLK_SRC_PLL
	default 2
	range 2 8
	help
	 PLLP division factor needs to be set correctly to not exceed 120MHz.
	 Allowed values: 2, 4, 6, 8

config CLOCK_STM32_PLL_Q_DIVISOR
	int "PLL division factor for USB OTG FS, SDIO and RNG clocks"
	depends on CLOCK_STM32_SYSCLK_SRC_PLL
	default 5
	range 2 15
	help
	 The USB OTG FS requires a 48MHz clock to work correctly. SDIO and RNG
	 need a frequency lower than or equal to 48 MHz to work correctly.
	 Allowed values: 2-15

endif # SOC_SERIES_STM32F2X

if SOC_SERIES_STM32F3X

config CLOCK_STM32_PLL_PREDIV
	int "PREDIV Prescaler"
	default 1
	range 1 16
	help
	 PREDIV is PLLSCR clock signal prescaler, allowed values: 1 - 16.

config CLOCK_STM32_PLL_MULTIPLIER
	int "PLL multiplier"
	depends on CLOCK_STM32_SYSCLK_SRC_PLL
	default 9
	range 2 16
	help
	 PLL multiplier, allowed values: 2-16. PLL output must not exceed 72MHz.

endif # SOC_SERIES_STM32F3X

if SOC_SERIES_STM32F4X || SOC_SERIES_STM32F7X

config CLOCK_STM32_PLL_M_DIVISOR
	int "Division factor for PLL VCO input clock"
	depends on CLOCK_STM32_SYSCLK_SRC_PLL
	default 8
	range 2 63
	help
	 PLLM division factor needs to be set correctly to ensure that the VCO
	 input frequency ranges from 1 to 2 MHz. It is recommended to select a
	 frequency of 2 MHz to limit PLL jitter.
	 Allowed values: 2-63

config CLOCK_STM32_PLL_N_MULTIPLIER
	int "Multiplier factor for PLL VCO output clock"
	depends on CLOCK_STM32_SYSCLK_SRC_PLL
	default 336
	range 192 432 if SOC_STM32F401XE
	range 50 432
	help
	 PLLN multiplier factor needs to be set correctly to ensure that the
	 VCO output frequency is between 100 and 432 MHz, except on STM32F401
	 where the frequency must be between 192 and 432 MHz.
	 Allowed values: 50-432 (STM32F401: 192-432)

config CLOCK_STM32_PLL_P_DIVISOR
	int "PLL division factor for main system clock"
	depends on CLOCK_STM32_SYSCLK_SRC_PLL
	default 4
	range 2 8
	help
	 PLLP division factor needs to be set correctly to not exceed 84MHz.
	 Allowed values: 2, 4, 6, 8

config CLOCK_STM32_PLL_Q_DIVISOR
	int "Division factor for OTG FS, SDIO and RNG clocks"
	depends on CLOCK_STM32_SYSCLK_SRC_PLL
	default 7
	range 2 15
	help
	 The USB OTG FS requires a 48MHz clock to work correctly. SDIO and RNG
	 need a frequency lower than or equal to 48 MHz to work correctly.
	 Allowed values: 2-15

endif # SOC_SERIES_STM32F4X || SOC_SERIES_STM32F7X

if SOC_SERIES_STM32L0X

config CLOCK_STM32_PLL_MULTIPLIER
	int "PLL multiplier"
	depends on CLOCK_STM32_SYSCLK_SRC_PLL
	default 4
	range 3 48
	help
	 PLL multiplier, allowed values: 3, 4, 6, 8, 12, 16, 24, 32, 48.
	 PLL output must not exceed 96MHz(1.8V)/48MHz(1.5V)/24MHz(1.2V).

config CLOCK_STM32_PLL_DIVISOR
	int "PLL divisor"
	depends on CLOCK_STM32_SYSCLK_SRC_PLL
	default 2
	range 2 4
	help
	  PLL divisor, allowed values: 2-4.

endif # SOC_SERIES_STM32L0X

if SOC_SERIES_STM32L4X

config CLOCK_STM32_PLL_M_DIVISOR
	int "PLL divisor"
	depends on CLOCK_STM32_SYSCLK_SRC_PLL
	default 1
	range 1 8
	help
	  PLL divisor, allowed values: 1-8. With this ensure that the PLL
	  VCO input frequency ranges from 4 to 16MHz.

config CLOCK_STM32_PLL_N_MULTIPLIER
	int "PLL multiplier"
	depends on CLOCK_STM32_SYSCLK_SRC_PLL
	default 20
	range 8 86
	help
	  PLL multiplier, allowed values: 2-16. PLL output must not
	  exceed 344MHz.

config CLOCK_STM32_PLL_P_DIVISOR
	int "PLL P Divisor"
	depends on CLOCK_STM32_SYSCLK_SRC_PLL
	default 7
	range 0 17
	help
	  PLL P Output divisor, allowed values: 0, 7, 17.

config CLOCK_STM32_PLL_Q_DIVISOR
	int "PLL Q Divisor"
	depends on CLOCK_STM32_SYSCLK_SRC_PLL
	default 2
	range 0 8
	help
	  PLL Q Output divisor, allowed values: 0, 2, 4, 6, 8.

config CLOCK_STM32_PLL_R_DIVISOR
	int "PLL R Divisor"
	depends on CLOCK_STM32_SYSCLK_SRC_PLL
	default 4
	range 0 8
	help
	  PLL R Output divisor, allowed values: 0, 2, 4, 6, 8.

config CLOCK_STM32_LSE
	bool "Low-speed external clock"
	help
	  Enable the low-speed external (LSE) clock supplied with a 32.768 kHz
	  crystal resonator oscillator.

config CLOCK_STM32_MSI_PLL_MODE
	bool "MSI PLL MODE"
	depends on CLOCK_STM32_LSE
	help
	  Enable hardware auto-calibration with LSE.

endif # SOC_SERIES_STM32L4X

config CLOCK_STM32_AHB_PRESCALER
	int "AHB prescaler"
	default 1
	range 1 512
	help
	  AHB prescaler, allowed values: 1, 2, 4, 8, 16, 64, 128,
	  256, 512.

config CLOCK_STM32_APB1_PRESCALER
	int "APB1 prescaler"
	default 1
	range 1 16
	help
	  APB1 Low speed clock (PCLK1) prescaler, allowed values:
	  1, 2, 4, 8, 16

if SOC_SERIES_STM32F0X!=y

config CLOCK_STM32_APB2_PRESCALER
	int "APB2 prescaler"
	default 1
	range 1 16
	help
	  APB2 High speed clock (PCLK2) prescaler, allowed values:
	  1, 2, 4, 8, 16

endif # SOC_SERIES_STM32F0X!=y

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_LSE
	bool "LSE"
	depends on SOC_SERIES_STM32F4X
	help
	  Use LSE as source of MCO1

config CLOCK_STM32_MCO1_SRC_HSE
	bool "HSE"
	depends on SOC_SERIES_STM32F4X
	help
	  Use HSE as source of MCO1

config CLOCK_STM32_MCO1_SRC_HSI
	bool "HSI"
	depends on SOC_SERIES_STM32F4X
	help
	  Use HSI as source of MCO1

config CLOCK_STM32_MCO1_SRC_PLLCLK
	bool "PLLCLK"
	depends on SOC_SERIES_STM32F4X
	help
	  Use PLLCLK as source of MCO1

endchoice

config CLOCK_STM32_MCO1_DIV
	int "MCO1 prescaler"
	depends on !CLOCK_STM32_MCO1_SRC_NOCLOCK
	default 1
	range 1   5
	help
	  allowed values: 1, 2, 3, 4, 5

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
	help
	  Use SYSCLK as source of MCO2

config CLOCK_STM32_MCO2_SRC_PLLI2S
	bool "PLLI2S"
	depends on SOC_SERIES_STM32F4X
	help
	  Use PLLI2S as source of MCO2

config CLOCK_STM32_MCO2_SRC_HSE
	bool "HSE"
	depends on SOC_SERIES_STM32F4X
	help
	  Use HSE as source of MCO2

config CLOCK_STM32_MCO2_SRC_PLLCLK
	bool "PLLCLK"
	depends on SOC_SERIES_STM32F4X
	help
	  Use PLLCLK as source of MCO2

endchoice

config CLOCK_STM32_MCO2_DIV
	int "MCO2 prescaler"
	depends on !CLOCK_STM32_MCO2_SRC_NOCLOCK
	default 1
	range 1 5
	help
	  allowed values: 1, 2, 3, 4, 5

endif # CLOCK_CONTROL_STM32_CUBE
endif # SOC_FAMILY_STM32