drivers: timer: stm32: Adapt SYS_CLOCK_TICKS_PER_SEC
When using LPTIM as tick source, tick freq (SYS_CLOCK_TICKS_PER_SEC) needs to be adapted to get a precise tick to LPTIM freq ratio. This adaptation was done easily using Kconfig up to now (under soc/st_stm32/common/Kconfig.defconfig.series). Since driver is configured using device tree, this method should be adapted. For the LSI case (default Kconfig case), rely on the existing mecanism, which is also still used by OOT users. For the LSE case, force the value manually in boards forlder. Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
This commit is contained in:
parent
b247fa6d53
commit
16c11138d5
6 changed files with 28 additions and 0 deletions
|
@ -298,6 +298,15 @@ static int sys_clock_driver_init(const struct device *dev)
|
|||
LL_SRDAMR_GRP1_EnableAutonomousClock(LL_SRDAMR_GRP1_PERIPH_LPTIM1AMEN);
|
||||
#endif
|
||||
|
||||
/* For tick accuracy, a specific tick to freq ratio is expected */
|
||||
/* This check assumes LSI@32KHz or LSE@32768Hz */
|
||||
if (((lptim_clk[1].bus == STM32_SRC_LSI) &&
|
||||
(CONFIG_SYS_CLOCK_TICKS_PER_SEC == 4000)) ||
|
||||
((lptim_clk[1].bus == STM32_SRC_LSE) &&
|
||||
(CONFIG_SYS_CLOCK_TICKS_PER_SEC == 4096))) {
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
/* Enable LPTIM clock source */
|
||||
clock_control_configure(clk_ctrl, (clock_control_subsys_t *) &lptim_clk[1],
|
||||
NULL);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue