1# STM32 LPTIM configuration options
2
3# Copyright (c) 2019 STMicroelectronics
4# SPDX-License-Identifier: Apache-2.0
5
6DT_CHOSEN_STDBY_TIMER := st,lptim-stdby-timer
7DT_STM32_LPTIM_PATH := $(dt_nodelabel_path,stm32_lp_tick_source)
8
9menuconfig STM32_LPTIM_TIMER
10	bool "STM32 Low Power Timer [EXPERIMENTAL]"
11	default y
12	depends on DT_HAS_ST_STM32_LPTIM_ENABLED
13	depends on CLOCK_CONTROL && PM
14	select TICKLESS_CAPABLE
15	select EXPERIMENTAL
16	help
17	  This module implements a kernel device driver for the LowPower Timer
18	  and provides the standard "system clock driver" interfaces.
19
20if STM32_LPTIM_TIMER
21
22# Invisible symbols exposing the selected LPTIM source to Kconfig
23# NOTE: the values 2/3 correspond too STM32_SRC_LSE/STM32_SRC_LSI
24# defined in include/zephyr/dt-bindings/clock/stm32_common_clocks.h
25config STM32_LPTIM_CLOCK_LSI
26	def_bool "$(dt_node_ph_array_prop_int,$(DT_STM32_LPTIM_PATH),clocks,1,bus)" = 3
27	help
28	  LSI used as LPTIM clock source
29
30config STM32_LPTIM_CLOCK_LSE
31	def_bool "$(dt_node_ph_array_prop_int,$(DT_STM32_LPTIM_PATH),clocks,1,bus)" = 2
32	help
33	  LSE used as LPTIM clock source
34
35config STM32_LPTIM_CLOCK
36	int
37	default 32768 if STM32_LPTIM_CLOCK_LSE
38	default 32000 if STM32_LPTIM_CLOCK_LSI
39
40config STM32_LPTIM_TIMEBASE
41	hex "LPTIM AutoReload value"
42	default 0xFFFF if STM32_LPTIM_CLOCK_LSE
43	default 0xF9FF if STM32_LPTIM_CLOCK_LSI
44
45config STM32_LPTIM_TICK_FREQ_RATIO_OVERRIDE
46	bool "Override tick to freq ratio check"
47	default y if ZTEST
48	help
49	  For LPTIM configuration, a specific tick freq is advised
50	  depending on LPTIM input clock:
51	  - LSI(32KHz): 4000 ticks/sec
52	  - LSE(32768): 4096 ticks/sec
53	  To prevent misconfigurations, a dedicated check is implemented
54	  in the driver.
55	  This options allows to override this check
56
57config STM32_LPTIM_STDBY_TIMER
58	bool
59	default $(dt_chosen_enabled,$(DT_CHOSEN_STDBY_TIMER))
60	depends on COUNTER
61	depends on TICKLESS_KERNEL
62	select EXPERIMENTAL
63	help
64	  Use an additional timer while entering Standby mode.
65	  There are chips e.g. STM32WBAX family that use LPTIM as a system timer,
66	  but LPTIM is not clocked in standby mode. These chips usually have
67	  another timer that is not stopped, but it has lower frequency e.g.
68	  RTC, thus it can't be used as a main system timer.
69	  Same approach is used on STM32U5 and STOP3 mode.
70
71	  Use the Standby timer for timeout (wakeup) when the system is entering
72	  Standby state.
73
74	  The chosen Standby timer node has to support setting alarm from the
75	  counter API.
76
77endif # STM32_LPTIM_TIMER
78