Skip to content

Commit 3de094a

Browse files
committed
include/dt-bindings: clocks: stm32h7: Use _C1_ registers offset
STM32H7 series offer alias addresses to access some registers that could be accessed by the M4 core on dual core variants. For instance RCC_AHB3ENR could be accessed at following offsets: - 0x0D4: Accessible from both cores - 0x134: Accessible from C1 (M7) core - 0x194: Accessible from C2 (M4) core (if any) For most single core H7 variants, the two first addresses were accessible, but for some others (stm32h7ax/stm32h7bx), only the 'C1 accessible' was available. This fact used to be hidden by the use of LL API to access these registers, providing the required abstraction (an mainly using the first alias when possible to simplify implementation). Signed-off-by: Erwan Gouriou <[email protected]>
1 parent d81918e commit 3de094a

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

drivers/clock_control/clock_stm32_ll_h7.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,14 @@
153153
#endif
154154
#endif /* CONFIG_CPU_CORTEX_M7 */
155155

156+
#if defined(CONFIG_CPU_CORTEX_M7)
157+
/* Offset to access bus clock registers from M7 (or only) core */
158+
#define STM32H7_BUS_CLK_REG DT_REG_ADDR(DT_NODELABEL(rcc))
159+
#elif defined(CONFIG_CPU_CORTEX_M4)
160+
/* Offset to access bus clock registers from M4 core */
161+
#define STM32H7_BUS_CLK_REG DT_REG_ADDR(DT_NODELABEL(rcc)) + 0x60
162+
#endif
163+
156164
static uint32_t get_bus_clock(uint32_t clock, uint32_t prescaler)
157165
{
158166
return clock / prescaler;
@@ -329,7 +337,7 @@ static inline int stm32_clock_control_on(const struct device *dev,
329337

330338
z_stm32_hsem_lock(CFG_HW_RCC_SEMID, HSEM_LOCK_DEFAULT_RETRY);
331339

332-
reg = (uint32_t *)(DT_REG_ADDR(DT_NODELABEL(rcc)) + pclken->bus);
340+
reg = (uint32_t *)(STM32H7_BUS_CLK_REG + pclken->bus);
333341
reg_val = *reg;
334342
reg_val |= pclken->enr;
335343
*reg = reg_val;
@@ -355,7 +363,7 @@ static inline int stm32_clock_control_off(const struct device *dev,
355363

356364
z_stm32_hsem_lock(CFG_HW_RCC_SEMID, HSEM_LOCK_DEFAULT_RETRY);
357365

358-
reg = (uint32_t *)(DT_REG_ADDR(DT_NODELABEL(rcc)) + pclken->bus);
366+
reg = (uint32_t *)(STM32H7_BUS_CLK_REG + pclken->bus);
359367
reg_val = *reg;
360368
reg_val &= ~pclken->enr;
361369
*reg = reg_val;

include/dt-bindings/clock/stm32h7_clock.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77
#define ZEPHYR_INCLUDE_DT_BINDINGS_CLOCK_STM32H7_CLOCK_H_
88

99
/* clock bus references */
10-
#define STM32_CLOCK_BUS_AHB3 0x0D4
11-
#define STM32_CLOCK_BUS_AHB1 0x0D8
12-
#define STM32_CLOCK_BUS_AHB2 0x0DC
13-
#define STM32_CLOCK_BUS_AHB4 0x0E0
14-
#define STM32_CLOCK_BUS_APB3 0x0E4
15-
#define STM32_CLOCK_BUS_APB1 0x0E8
16-
#define STM32_CLOCK_BUS_APB1_2 0x0EC
17-
#define STM32_CLOCK_BUS_APB2 0x0F0
18-
#define STM32_CLOCK_BUS_APB4 0x0F4
10+
#define STM32_CLOCK_BUS_AHB3 0x134
11+
#define STM32_CLOCK_BUS_AHB1 0x138
12+
#define STM32_CLOCK_BUS_AHB2 0x13c
13+
#define STM32_CLOCK_BUS_AHB4 0x140
14+
#define STM32_CLOCK_BUS_APB3 0x144
15+
#define STM32_CLOCK_BUS_APB1 0x148
16+
#define STM32_CLOCK_BUS_APB1_2 0x14c
17+
#define STM32_CLOCK_BUS_APB2 0x150
18+
#define STM32_CLOCK_BUS_APB4 0x154
1919

2020
#define STM32_PERIPH_BUS_MIN STM32_CLOCK_BUS_AHB3
2121
#define STM32_PERIPH_BUS_MAX STM32_CLOCK_BUS_APB4

0 commit comments

Comments
 (0)