From a4b0af2a4499ee9df1cdc6d7589bf184c7befd2b Mon Sep 17 00:00:00 2001 From: Aidan MacDonald Date: Fri, 26 Dec 2025 21:47:50 +0000 Subject: [PATCH] stm32h7: add function to get frequency of a clock Change-Id: Ice60bc0e443a134ebb8ec03015fef98991ef9b05 --- firmware/target/arm/stm32/clock-stm32h7.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/firmware/target/arm/stm32/clock-stm32h7.h b/firmware/target/arm/stm32/clock-stm32h7.h index c4cb52fa3a..b2fea160bd 100644 --- a/firmware/target/arm/stm32/clock-stm32h7.h +++ b/firmware/target/arm/stm32/clock-stm32h7.h @@ -23,6 +23,7 @@ #include "system.h" #include +#include enum stm_clock { @@ -54,6 +55,14 @@ void stm_target_clock_init(void) INIT_ATTR; */ void stm_target_clock_enable(enum stm_clock clock, bool enable); +/* + * Callback to return a specific clock's frequency. For most + * peripherals the frequency must be known at initialization + * and not change afterwards; see peripheral drivers for the + * details, as their exact requirements may vary. + */ +size_t stm_target_clock_get_frequency(enum stm_clock clock); + /* * Called from system_init(). Sets up internal book-keeping * and then calls stm_target_clock_init(). @@ -66,4 +75,12 @@ void stm_clock_init(void) INIT_ATTR; void stm_clock_enable(enum stm_clock clock); void stm_clock_disable(enum stm_clock clock); +/* + * Get a clock's frequency in Hz. + */ +static inline size_t stm_clock_get_frequency(enum stm_clock clock) +{ + return stm_target_clock_get_frequency(clock); +} + #endif /* __CLOCK_STM32H7_H__ */