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
7
8menuconfig STM32_LPTIM_TIMER
9	bool "STM32 Low Power Timer [EXPERIMENTAL]"
10	default y
11	depends on DT_HAS_ST_STM32_LPTIM_ENABLED
12	depends on CLOCK_CONTROL && PM
13	select TICKLESS_CAPABLE
14	select EXPERIMENTAL
15	help
16	  This module implements a kernel device driver for the LowPower Timer
17	  and provides the standard "system clock driver" interfaces.
18
19if STM32_LPTIM_TIMER
20
21choice STM32_LPTIM_CLOCK
22	prompt "LPTIM clock value configuration"
23	help
24	  This option is deprecated and configuration of LPTIM domain clock
25	  using devicetree should be preferred.
26
27config STM32_LPTIM_CLOCK_LSI
28	bool "LSI"
29	help
30	  Use LSI as LPTIM clock
31
32config STM32_LPTIM_CLOCK_LSE
33	bool "LSE"
34	help
35	  Use LSE as LPTIM clock
36
37endchoice
38
39config STM32_LPTIM_CLOCK
40	int
41	default 32768 if STM32_LPTIM_CLOCK_LSE
42	default 32000 if STM32_LPTIM_CLOCK_LSI
43
44config STM32_LPTIM_TIMEBASE
45	hex "LPTIM AutoReload value"
46	default 0xFFFF if STM32_LPTIM_CLOCK_LSE
47	default 0xF9FF if STM32_LPTIM_CLOCK_LSI
48
49config STM32_LPTIM_TICK_FREQ_RATIO_OVERRIDE
50	bool "Override tick to freq ratio check"
51	default y if ZTEST
52	help
53	  For LPTIM configuration, a specific tick freq is advised
54	  depending on LPTIM input clock:
55	  - LSI(32KHz): 4000 ticks/sec
56	  - LSE(32678): 4096 ticks/sec
57	  To prevent misconfigurations, a dedicated check is implemented
58	  in the driver.
59	  This options allows to override this check
60
61config STM32_LPTIM_STDBY_TIMER
62	bool
63	default $(dt_chosen_enabled,$(DT_CHOSEN_STDBY_TIMER))
64	depends on COUNTER
65	depends on TICKLESS_KERNEL
66	select EXPERIMENTAL
67	help
68	  Use an additional timer while entering Standby mode.
69	  There are chips e.g. STM32WBAX family that use LPTIM as a system timer,
70	  but LPTIM is not clocked in standby mode. These chips usually have
71	  another timer that is not stopped, but it has lower frequency e.g.
72	  RTC, thus it can't be used as a main system timer.
73	  Same approach is used on STM32U5 and STOP3 mode.
74
75	  Use the Standby timer for timeout (wakeup) when the system is entering
76	  Standby state.
77
78	  The chosen Standby timer node has to support setting alarm from the
79	  counter API.
80
81endif # STM32_LPTIM_TIMER
82