1# ST Microelectronics STM32 all MCU lines
2
3# Copyright (c) 2017, I-SENSE group of ICCS
4# SPDX-License-Identifier: Apache-2.0
5
6# Here are set all the Kconfig symbols common to the whole STM32 family
7
8if SOC_FAMILY_STM32
9
10config CORTEX_M_SYSTICK
11	default n if STM32_LPTIM_TIMER
12
13DT_STM32_RCC_PATH := $(dt_nodelabel_path,rcc)
14DT_STM32_RCC_CLOCK_FREQ := $(dt_node_int_prop_int,$(DT_STM32_RCC_PATH),clock-frequency)
15
16DT_ST_PRESCALER := st,prescaler
17DT_STM32_LPTIM_PATH := $(dt_nodelabel_path,stm32_lp_tick_source)
18
19config SYS_CLOCK_HW_CYCLES_PER_SEC
20	default "$(DT_STM32_RCC_CLOCK_FREQ)" if "$(dt_nodelabel_enabled,rcc)"
21
22if LOG_BACKEND_SWO
23
24config LOG_BACKEND_SWO_REF_FREQ_HZ
25	default "$(DT_STM32_RCC_CLOCK_FREQ)" if "$(dt_nodelabel_enabled,rcc)"
26
27endif # LOG_BACKEND_SWO
28
29# set the tick per sec as a divider of the LPTIM clock source
30# with a minimum value of 4096 for SYS_CLOCK_TICKS_PER_SEC to keep
31# SYS_CLOCK_TICKS_PER_SEC not too high compared to the LPTIM counter clock
32config SYS_CLOCK_TICKS_PER_SEC
33	default 4096 if "$(dt_node_int_prop_int,$(DT_STM32_LPTIM_PATH),$(DT_ST_PRESCALER))" < 16
34	default 2048 if "$(dt_node_int_prop_int,$(DT_STM32_LPTIM_PATH),$(DT_ST_PRESCALER))" = 16
35	default 1024 if "$(dt_node_int_prop_int,$(DT_STM32_LPTIM_PATH),$(DT_ST_PRESCALER))" = 32
36	default  512 if "$(dt_node_int_prop_int,$(DT_STM32_LPTIM_PATH),$(DT_ST_PRESCALER))" = 64
37	default  256 if "$(dt_node_int_prop_int,$(DT_STM32_LPTIM_PATH),$(DT_ST_PRESCALER))" = 128
38	depends on STM32_LPTIM_TIMER && STM32_LPTIM_CLOCK_LSE
39
40config SYS_CLOCK_TICKS_PER_SEC
41	default 4000 if "$(dt_node_int_prop_int,$(DT_STM32_LPTIM_PATH),$(DT_ST_PRESCALER))" < 16
42	default 2000 if "$(dt_node_int_prop_int,$(DT_STM32_LPTIM_PATH),$(DT_ST_PRESCALER))" = 16
43	default 1000 if "$(dt_node_int_prop_int,$(DT_STM32_LPTIM_PATH),$(DT_ST_PRESCALER))" = 32
44	default  500 if "$(dt_node_int_prop_int,$(DT_STM32_LPTIM_PATH),$(DT_ST_PRESCALER))" = 64
45	default  250 if "$(dt_node_int_prop_int,$(DT_STM32_LPTIM_PATH),$(DT_ST_PRESCALER))" = 128
46	depends on STM32_LPTIM_TIMER && STM32_LPTIM_CLOCK_LSI
47
48choice STM32_LPTIM_CLOCK
49	default STM32_LPTIM_CLOCK_LSE if "$(dt_node_ph_array_prop_int,$(DT_STM32_LPTIM_PATH),clocks,1,bus)" = 2
50	default STM32_LPTIM_CLOCK_LSI if "$(dt_node_ph_array_prop_int,$(DT_STM32_LPTIM_PATH),clocks,1,bus)" = 3
51endchoice
52
53config CLOCK_CONTROL_STM32_CUBE
54	default y
55	depends on CLOCK_CONTROL
56
57config CLOCK_CONTROL_INIT_PRIORITY
58	default 1
59	depends on CLOCK_CONTROL
60
61config MEMC_STM32
62	default y
63	depends on MEMC
64
65endif # SOC_FAMILY_STM32
66