1# STM32 MCU clock control driver config
2
3# Copyright (c) 2017 Linaro
4# Copyright (c) 2017 RnDity Sp. z o.o.
5# SPDX-License-Identifier: Apache-2.0
6
7menuconfig CLOCK_CONTROL_STM32_CUBE
8	bool "STM32 Reset & Clock Control"
9	depends on SOC_FAMILY_STM32
10	default y
11	select USE_STM32_LL_UTILS
12	select USE_STM32_LL_RCC if (SOC_SERIES_STM32MP1X || SOC_SERIES_STM32H7X || \
13		SOC_SERIES_STM32H7RSX || SOC_SERIES_STM32F4X || SOC_SERIES_STM32F7X)
14	select RUNTIME_NMI if ($(dt_nodelabel_enabled,clk_hse) && \
15		$(dt_nodelabel_has_prop,clk_hse,css-enabled))
16	help
17	  Enable driver for Reset & Clock Control subsystem found
18	  in STM32 family of MCUs
19
20if CLOCK_CONTROL_STM32_CUBE
21
22DT_STM32_HSE_CLOCK := $(dt_nodelabel_path,clk_hse)
23DT_STM32_HSE_CLOCK_FREQ := $(dt_node_int_prop_int,$(DT_STM32_HSE_CLOCK),clock-frequency)
24
25config CLOCK_STM32_HSE_CLOCK
26	int "HSE clock value"
27	default "$(DT_STM32_HSE_CLOCK_FREQ)" if "$(dt_nodelabel_enabled,clk_hse)"
28	default 8000000
29	help
30	  Value of external high-speed clock (HSE). This symbol could be optionally
31	  configured using device tree by setting "clock-frequency" value of clk_hse
32	  node. For instance:
33	  &clk_hse{
34	  status = "okay";
35	  clock-frequency = <DT_FREQ_M(25)>;
36	  };
37	  Note: Device tree configuration is overridden when current symbol is set:
38	  CONFIG_CLOCK_STM32_HSE_CLOCK=32000000
39
40config CLOCK_STM32_MUX
41	bool "STM32 clock mux driver"
42	default y
43	depends on DT_HAS_ST_STM32_CLOCK_MUX_ENABLED
44	help
45	  Enable driver for STM32 clock mux which don't match an
46	  existing clock hardware block but allows to select a clock
47	  for a specific domain. For instance per_ck clock on STM32H7 or
48	  CLK48 clock
49
50menu "STM32WB0 LSI options"
51	depends on DT_HAS_ST_STM32WB0_LSI_CLOCK_ENABLED
52
53config STM32WB0_LSI_MEASUREMENT_WINDOW
54	int "Size of LSI measurement window (in periods)"
55	default 32
56	range 23 256
57	help
58	  Size of the LSI measurement window (# of LSI periods)
59
60	  The measurement process involves waiting for a certain amount of LSI periods
61	  to occur, in order to determine precisely the LSI period, and thus frequency.
62
63	  This property controls how much LSI periods are required for each measure.
64	  Bigger window sizes increase accuracy of the measure, but increase the time
65	  needed to complete it. Since fLSI >= 24kHz, increasing the measurement window
66	  size makes each measure roughly 42µs slower in the worst case.
67
68	  Minimal value is a recommendation from RM0505 Rev.1 §25.8.2, and maximum
69	  value is a hardware limitation.
70
71config STM32WB0_LSI_RUNTIME_MEASUREMENT_INTERVAL
72	int "LSI run-time measurement interval (ms)"
73	default 0
74	help
75	  Interval at which runtime measurements should be performed, in milliseconds
76
77	  Since the LSI RC frequency is affected by temperature, which is not stable
78	  across time, it is recommended to perform measurements of the LSI frequency
79	  at regular intervals to obtain better accuracy.
80
81	  This property enables runtime LSI measurement if present. In this case,
82	  a background thread is created and performs LSI measurements, sleeping
83	  the amount of time specified in this property between each measure. This
84	  thread is also tasked with updating the control registers of peripherals
85	  affected by slow clock drift such as RTC or IWDG, in collaboration with
86	  the peripherals' drivers. Note that this increases the memory footprint
87	  of the clock control driver, and may increase power consumption.
88
89	  Setting this option to the default value of "0" disables runtime frequency
90	  measurements - the result of a single measure performed at boot will be
91	  treated as LSI frequency for the lifetime of the application.
92
93endmenu # DT_HAS_ST_STM32WB0_LSI_CLOCK_ENABLED
94
95# Micro-controller Clock Output (MCO) configuration options
96config CLOCK_STM32_MCO
97	bool
98	default y
99	depends on DT_HAS_ST_STM32_CLOCK_MCO_ENABLED || DT_HAS_ST_STM32F1_CLOCK_MCO_ENABLED
100	help
101	  Allows to output various different clock sources onto the MCO pin
102	  using a configurable prescaler.
103
104endif # CLOCK_CONTROL_STM32_CUBE
105