Skip to content

Commit f961441

Browse files
committed
dt-bindings: clock: add stm32l5_clock
This change introduces stm32l5xx clock definitions and separates it from L4xx series. This change comes because of CCIPR missmatch of SAI between L4xx and L5xx series. Signed-off-by: Mario Paja <[email protected]>
1 parent 9ae10ea commit f961441

File tree

3 files changed

+95
-2
lines changed

3 files changed

+95
-2
lines changed

dts/arm/st/l5/stm32l5.dtsi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
* Copyright (c) 2021 The Chromium OS Authors
33
* Copyright (c) 2020 Linaro Limited
44
* Copyright (c) 2024 STMicroelectronics
5+
* Copyright (c) 2025 Mario Paja
56
*
67
* SPDX-License-Identifier: Apache-2.0
78
*/
89

910
#include <arm/armv8-m.dtsi>
10-
#include <zephyr/dt-bindings/clock/stm32l4_clock.h>
11+
#include <zephyr/dt-bindings/clock/stm32l5_clock.h>
1112
#include <zephyr/dt-bindings/gpio/gpio.h>
1213
#include <zephyr/dt-bindings/i2c/i2c.h>
1314
#include <zephyr/dt-bindings/pwm/pwm.h>

include/zephyr/dt-bindings/clock/stm32l4_clock.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#define STM32_PERIPH_BUS_MAX STM32_CLOCK_BUS_APB2
2121

2222
/** Domain clocks */
23-
/* RM0351/RM0432/RM0438, § Clock configuration register (RCC_CCIPRx) */
23+
/* RM0351/RM0432, § Clock configuration register (RCC_CCIPRx) */
2424

2525
/** System clock */
2626
/* defined in stm32_common_clocks.h */
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
/*
2+
* Copyright (c) 2025 Mario Paja
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
#ifndef ZEPHYR_INCLUDE_DT_BINDINGS_CLOCK_STM32L5_CLOCK_H_
7+
#define ZEPHYR_INCLUDE_DT_BINDINGS_CLOCK_STM32L5_CLOCK_H_
8+
9+
#include "stm32_common_clocks.h"
10+
11+
/** Bus clocks */
12+
#define STM32_CLOCK_BUS_AHB1 0x048
13+
#define STM32_CLOCK_BUS_AHB2 0x04c
14+
#define STM32_CLOCK_BUS_AHB3 0x050
15+
#define STM32_CLOCK_BUS_APB1 0x058
16+
#define STM32_CLOCK_BUS_APB1_2 0x05c
17+
#define STM32_CLOCK_BUS_APB2 0x060
18+
19+
#define STM32_PERIPH_BUS_MIN STM32_CLOCK_BUS_AHB1
20+
#define STM32_PERIPH_BUS_MAX STM32_CLOCK_BUS_APB2
21+
22+
/** Domain clocks */
23+
/* RM0438, § Clock configuration register (RCC_CCIPRx) */
24+
25+
/** System clock */
26+
/* defined in stm32_common_clocks.h */
27+
/** Fixed clocks */
28+
/* Low speed clocks defined in stm32_common_clocks.h */
29+
#define STM32_SRC_HSI (STM32_SRC_LSI + 1)
30+
#define STM32_SRC_HSI48 (STM32_SRC_HSI + 1)
31+
#define STM32_SRC_MSI (STM32_SRC_HSI48 + 1)
32+
/** Bus clock */
33+
#define STM32_SRC_PCLK (STM32_SRC_MSI + 1)
34+
#define STM32_SRC_TIMPCLK1 (STM32_SRC_PCLK + 1)
35+
#define STM32_SRC_TIMPCLK2 (STM32_SRC_TIMPCLK1 + 1)
36+
/** PLL clock outputs */
37+
#define STM32_SRC_PLL_P (STM32_SRC_TIMPCLK2 + 1)
38+
#define STM32_SRC_PLL_Q (STM32_SRC_PLL_P + 1)
39+
#define STM32_SRC_PLL_R (STM32_SRC_PLL_Q + 1)
40+
/* PLLSAI1 clocks */
41+
#define STM32_SRC_PLLSAI1_P (STM32_SRC_PLL_R + 1)
42+
#define STM32_SRC_PLLSAI1_Q (STM32_SRC_PLLSAI1_P + 1)
43+
#define STM32_SRC_PLLSAI1_R (STM32_SRC_PLLSAI1_Q + 1)
44+
/* PLLSAI2 clocks */
45+
#define STM32_SRC_PLLSAI2_P (STM32_SRC_PLLSAI1_R + 1)
46+
#define STM32_SRC_PLLSAI2_Q (STM32_SRC_PLLSAI2_P + 1)
47+
#define STM32_SRC_PLLSAI2_R (STM32_SRC_PLLSAI2_Q + 1)
48+
#define STM32_SRC_PLLSAI2_DIVR (STM32_SRC_PLLSAI2_R + 1)
49+
50+
/** @brief RCC_CCIPR register offset */
51+
#define CCIPR_REG 0x88
52+
#define CCIPR2_REG 0x9C
53+
54+
/** @brief RCC_BDCR register offset */
55+
#define BDCR_REG 0x90
56+
57+
/** @brief RCC_CFGRx register offset */
58+
#define CFGR_REG 0x08
59+
60+
/** @brief Device domain clocks selection helpers */
61+
/** CCIPR devices */
62+
#define USART1_SEL(val) STM32_DT_CLOCK_SELECT((val), 3, 0, CCIPR_REG)
63+
#define USART2_SEL(val) STM32_DT_CLOCK_SELECT((val), 3, 2, CCIPR_REG)
64+
#define USART3_SEL(val) STM32_DT_CLOCK_SELECT((val), 3, 4, CCIPR_REG)
65+
#define UART4_SEL(val) STM32_DT_CLOCK_SELECT((val), 3, 6, CCIPR_REG)
66+
#define UART5_SEL(val) STM32_DT_CLOCK_SELECT((val), 3, 8, CCIPR_REG)
67+
#define LPUART1_SEL(val) STM32_DT_CLOCK_SELECT((val), 3, 10, CCIPR_REG)
68+
#define I2C1_SEL(val) STM32_DT_CLOCK_SELECT((val), 3, 12, CCIPR_REG)
69+
#define I2C2_SEL(val) STM32_DT_CLOCK_SELECT((val), 3, 14, CCIPR_REG)
70+
#define I2C3_SEL(val) STM32_DT_CLOCK_SELECT((val), 3, 16, CCIPR_REG)
71+
#define LPTIM1_SEL(val) STM32_DT_CLOCK_SELECT((val), 3, 18, CCIPR_REG)
72+
#define LPTIM2_SEL(val) STM32_DT_CLOCK_SELECT((val), 3, 20, CCIPR_REG)
73+
#define LPTIM3_SEL(val) STM32_DT_CLOCK_SELECT((val), 3, 22, CCIPR_REG)
74+
#define FDCAN_SEL(val) STM32_DT_CLOCK_SELECT((val), 3, 24, CCIPR_REG)
75+
#define CLK48_SEL(val) STM32_DT_CLOCK_SELECT((val), 3, 26, CCIPR_REG)
76+
#define ADC_SEL(val) STM32_DT_CLOCK_SELECT((val), 3, 28, CCIPR_REG)
77+
/** CCIPR2 devices */
78+
#define I2C4_SEL(val) STM32_DT_CLOCK_SELECT((val), 3, 0, CCIPR2_REG)
79+
#define DFSDM_SEL(val) STM32_DT_CLOCK_SELECT((val), 1, 2, CCIPR2_REG)
80+
#define ADFSDM_SEL(val) STM32_DT_CLOCK_SELECT((val), 3, 3, CCIPR2_REG)
81+
#define SAI1_SEL(val) STM32_DT_CLOCK_SELECT((val), 3, 5, CCIPR2_REG)
82+
#define SAI2_SEL(val) STM32_DT_CLOCK_SELECT((val), 3, 8, CCIPR2_REG)
83+
#define SDMMC_SEL(val) STM32_DT_CLOCK_SELECT((val), 1, 14, CCIPR2_REG)
84+
#define OSPI_SEL(val) STM32_DT_CLOCK_SELECT((val), 3, 20, CCIPR2_REG)
85+
86+
/** BDCR devices */
87+
#define RTC_SEL(val) STM32_DT_CLOCK_SELECT((val), 3, 8, BDCR_REG)
88+
/** CFGR devices */
89+
#define MCO1_SEL(val) STM32_DT_CLOCK_SELECT((val), 0xF, 24, CFGR_REG)
90+
#define MCO1_PRE(val) STM32_DT_CLOCK_SELECT((val), 0x7, 28, CFGR_REG)
91+
92+
#endif /* ZEPHYR_INCLUDE_DT_BINDINGS_CLOCK_STM32L5_CLOCK_H_ */

0 commit comments

Comments
 (0)