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# Default configurations appplied tp the whole STM32 family
7
8if SOC_FAMILY_STM32
9
10# Source series Kconfig files first, so SoCs
11# can override the defaults given here
12rsource "*/Kconfig.defconfig"
13
14config CLOCK_CONTROL
15	default y
16
17config CORTEX_M_SYSTICK
18	default n if STM32_LPTIM_TIMER
19
20DT_STM32_RCC_PATH := $(dt_nodelabel_path,rcc)
21DT_STM32_RCC_CLOCK_FREQ := $(dt_node_int_prop_int,$(DT_STM32_RCC_PATH),clock-frequency)
22
23DT_ST_PRESCALER := st,prescaler
24DT_STM32_LPTIM_PATH := $(dt_nodelabel_path,stm32_lp_tick_source)
25
26config SYS_CLOCK_HW_CYCLES_PER_SEC
27	default "$(DT_STM32_RCC_CLOCK_FREQ)" if "$(dt_nodelabel_enabled,rcc)"
28
29config LOG_BACKEND_SWO_REF_FREQ_HZ
30	default "$(DT_STM32_RCC_CLOCK_FREQ)" if "$(dt_nodelabel_enabled,rcc)"
31	depends on LOG_BACKEND_SWO
32
33# If sysclock is not LPTIM, tick of 10000 is too high for a frequency lower than 32MHz
34config SYS_CLOCK_TICKS_PER_SEC
35	default 8000 if SYS_CLOCK_HW_CYCLES_PER_SEC <= 32000000
36	depends on !STM32_LPTIM_TIMER
37
38# set the tick per sec as a divider of the LPTIM clock source
39# with a minimum value of 4096 for SYS_CLOCK_TICKS_PER_SEC to keep
40# SYS_CLOCK_TICKS_PER_SEC not too high compared to the LPTIM counter clock
41config SYS_CLOCK_TICKS_PER_SEC
42	default 4096 if "$(dt_node_int_prop_int,$(DT_STM32_LPTIM_PATH),$(DT_ST_PRESCALER))" < 16
43	default 2048 if "$(dt_node_int_prop_int,$(DT_STM32_LPTIM_PATH),$(DT_ST_PRESCALER))" = 16
44	default 1024 if "$(dt_node_int_prop_int,$(DT_STM32_LPTIM_PATH),$(DT_ST_PRESCALER))" = 32
45	default  512 if "$(dt_node_int_prop_int,$(DT_STM32_LPTIM_PATH),$(DT_ST_PRESCALER))" = 64
46	default  256 if "$(dt_node_int_prop_int,$(DT_STM32_LPTIM_PATH),$(DT_ST_PRESCALER))" = 128
47	depends on STM32_LPTIM_TIMER && STM32_LPTIM_CLOCK_LSE
48
49config SYS_CLOCK_TICKS_PER_SEC
50	default 4000 if "$(dt_node_int_prop_int,$(DT_STM32_LPTIM_PATH),$(DT_ST_PRESCALER))" < 16
51	default 2000 if "$(dt_node_int_prop_int,$(DT_STM32_LPTIM_PATH),$(DT_ST_PRESCALER))" = 16
52	default 1000 if "$(dt_node_int_prop_int,$(DT_STM32_LPTIM_PATH),$(DT_ST_PRESCALER))" = 32
53	default  500 if "$(dt_node_int_prop_int,$(DT_STM32_LPTIM_PATH),$(DT_ST_PRESCALER))" = 64
54	default  250 if "$(dt_node_int_prop_int,$(DT_STM32_LPTIM_PATH),$(DT_ST_PRESCALER))" = 128
55	depends on STM32_LPTIM_TIMER && STM32_LPTIM_CLOCK_LSI
56
57choice STM32_LPTIM_CLOCK
58	default STM32_LPTIM_CLOCK_LSE if "$(dt_node_ph_array_prop_int,$(DT_STM32_LPTIM_PATH),clocks,1,bus)" = 2
59	default STM32_LPTIM_CLOCK_LSI if "$(dt_node_ph_array_prop_int,$(DT_STM32_LPTIM_PATH),clocks,1,bus)" = 3
60endchoice
61
62config CLOCK_CONTROL_INIT_PRIORITY
63	default 1
64	depends on CLOCK_CONTROL
65
66config PHY_INIT_PRIORITY
67	default 81
68	depends on NET_L2_ETHERNET && ETH_DRIVER
69
70# Get flash configuration for NS image from dts flash partition
71config USE_DT_CODE_PARTITION
72	default y if TRUSTED_EXECUTION_NONSECURE
73
74config BUILD_WITH_TFM
75	default y if TRUSTED_EXECUTION_NONSECURE
76
77endif # SOC_FAMILY_STM32
78