Skip to content

Commit 7f23ce2

Browse files
youssefz24kartben
authored andcommitted
dts: clock_control: add mp2 rcc binding
Introduce DeviceTree binding for the STM32MP2 RCC clock controller, enabling support for STM32MP2-specific clock configuration in Zephyr. Update Kconfig.stm32 to add a dependency on STM32MP2 configuration, allowing the use of STM32 LL RCC features when targeting STM32MP2 devices. Add header for STM32MP2 per peripheral clock definitions. Signed-off-by: Youssef Zini <youssef.zini@savoirfairelinux.com>
1 parent 0c58344 commit 7f23ce2

File tree

4 files changed

+82
-4
lines changed

4 files changed

+82
-4
lines changed

boards/st/stm32mp257f_ev1/stm32mp257f_ev1_stm32mp257fxx_m33_defconfig

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,5 @@
44
# Enable MPU
55
CONFIG_ARM_MPU=y
66

7-
CONFIG_CLOCK_CONTROL=n
8-
97
# Enable HW stack protection
108
CONFIG_HW_STACK_PROTECTION=y

drivers/clock_control/Kconfig.stm32

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,17 @@
22

33
# Copyright (c) 2017 Linaro
44
# Copyright (c) 2017 RnDity Sp. z o.o.
5+
# Copyright (C) 2025 Savoir-faire Linux, Inc.
56
# SPDX-License-Identifier: Apache-2.0
67

78
menuconfig CLOCK_CONTROL_STM32_CUBE
89
bool "STM32 Reset & Clock Control"
910
depends on SOC_FAMILY_STM32
1011
default y
1112
select USE_STM32_LL_UTILS
12-
select USE_STM32_LL_RCC if (SOC_SERIES_STM32MP1X || SOC_SERIES_STM32MP13X || SOC_SERIES_STM32H7X || \
13-
SOC_SERIES_STM32H7RSX || SOC_SERIES_STM32F4X || SOC_SERIES_STM32F7X || \
13+
select USE_STM32_LL_RCC if (SOC_SERIES_STM32MP1X || SOC_SERIES_STM32MP13X || \
14+
SOC_SERIES_STM32MP2X || SOC_SERIES_STM32H7X || SOC_SERIES_STM32H7RSX || \
15+
SOC_SERIES_STM32F4X || SOC_SERIES_STM32F7X || \
1416
SOC_SERIES_STM32N6X)
1517
select RUNTIME_NMI if ($(dt_nodelabel_enabled,clk_hse) && \
1618
$(dt_nodelabel_bool_prop,clk_hse,css-enabled))
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Copyright (C) 2025 Savoir-faire Linux, Inc.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
description: |
5+
STM32MP2 RCC (Reset and Clock controller).
6+
7+
On STM32MP2 platforms, the clock tree is configured by the Cortex-A35 core.
8+
As a consequence, the only property to be set in devicetree node is the
9+
clock-frequency.
10+
11+
As for the peripherals, the clocks are configured per peripheral in the
12+
corresponding device tree node. The clock controller is responsible for
13+
enabling/disabling the clocks for the peripherals, when allowed by the
14+
Resource Isolation Framework(RIF) peripheral, configured by the cortex-A35
15+
core.
16+
17+
To declare a peripheral "PERx" clock in the dtsi, you can follow the example
18+
below:
19+
PERx {
20+
...
21+
clocks = <&rcc STM32_CLOCK(PERx, STM32_CLK)>;
22+
...
23+
};
24+
25+
compatible: "st,stm32mp2-rcc"
26+
27+
include:
28+
- name: st,stm32-rcc.yaml
29+
property-blocklist:
30+
- ahb-prescaler
31+
- apb1-prescaler
32+
- apb2-prescaler
33+
- undershoot-prevention
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright (C) 2025 Savoir-faire Linux, Inc.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#ifndef ZEPHYR_INCLUDE_DT_BINDINGS_CLOCK_STM32MP2_CLOCK_H_
8+
#define ZEPHYR_INCLUDE_DT_BINDINGS_CLOCK_STM32MP2_CLOCK_H_
9+
10+
#include "stm32_common_clocks.h"
11+
12+
/* Undefine the common clocks macro */
13+
#undef STM32_CLOCK
14+
15+
/**
16+
* Pack RCC clock register offset and bit in two 32-bit values
17+
* as expected for the Device Tree `clocks` property on STM32.
18+
*
19+
* @param per STM32 Peripheral name (expands to STM32_CLOCK_PERIPH_{PER})
20+
* @param bit Clock bit
21+
*/
22+
#define STM32_CLOCK(per, bit) (STM32_CLOCK_PERIPH_##per) (1 << bit)
23+
24+
/* Clock reg */
25+
#define STM32_CLK 1U
26+
#define STM32_LP_CLK 2U
27+
28+
/* GPIO Peripheral */
29+
#define STM32_CLOCK_PERIPH_GPIOA 0x52C
30+
#define STM32_CLOCK_PERIPH_GPIOB 0x530
31+
#define STM32_CLOCK_PERIPH_GPIOC 0x534
32+
#define STM32_CLOCK_PERIPH_GPIOD 0x538
33+
#define STM32_CLOCK_PERIPH_GPIOE 0x53C
34+
#define STM32_CLOCK_PERIPH_GPIOF 0x540
35+
#define STM32_CLOCK_PERIPH_GPIOG 0x544
36+
#define STM32_CLOCK_PERIPH_GPIOH 0x548
37+
#define STM32_CLOCK_PERIPH_GPIOI 0x54C
38+
#define STM32_CLOCK_PERIPH_GPIOJ 0x550
39+
#define STM32_CLOCK_PERIPH_GPIOK 0x554
40+
#define STM32_CLOCK_PERIPH_GPIOZ 0x558
41+
42+
#define STM32_CLOCK_PERIPH_MIN STM32_CLOCK_PERIPH_GPIOA
43+
#define STM32_CLOCK_PERIPH_MAX STM32_CLOCK_PERIPH_GPIOZ
44+
45+
#endif /* ZEPHYR_INCLUDE_DT_BINDINGS_CLOCK_STM32MP2_CLOCK_H_ */

0 commit comments

Comments
 (0)