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