10#ifndef ZEPHYR_INCLUDE_DRIVERS_CLOCK_CONTROL_STM32_CLOCK_CONTROL_H_
11#define ZEPHYR_INCLUDE_DRIVERS_CLOCK_CONTROL_STM32_CLOCK_CONTROL_H_
15#if defined(CONFIG_SOC_SERIES_STM32C0X)
17#elif defined(CONFIG_SOC_SERIES_STM32F0X)
19#elif defined(CONFIG_SOC_SERIES_STM32F1X)
21#elif defined(CONFIG_SOC_SERIES_STM32F3X)
23#elif defined(CONFIG_SOC_SERIES_STM32F2X) || \
24 defined(CONFIG_SOC_SERIES_STM32F4X)
26#elif defined(CONFIG_SOC_SERIES_STM32F7X)
28#elif defined(CONFIG_SOC_SERIES_STM32G0X)
30#elif defined(CONFIG_SOC_SERIES_STM32G4X)
32#elif defined(CONFIG_SOC_SERIES_STM32L0X)
34#elif defined(CONFIG_SOC_SERIES_STM32L1X)
36#elif defined(CONFIG_SOC_SERIES_STM32L4X) || \
37 defined(CONFIG_SOC_SERIES_STM32L5X)
39#elif defined(CONFIG_SOC_SERIES_STM32WBX)
41#elif defined(CONFIG_SOC_SERIES_STM32WLX)
43#elif defined(CONFIG_SOC_SERIES_STM32H5X)
45#elif defined(CONFIG_SOC_SERIES_STM32H7X)
47#elif defined(CONFIG_SOC_SERIES_STM32H7RSX)
49#elif defined(CONFIG_SOC_SERIES_STM32U5X)
51#elif defined(CONFIG_SOC_SERIES_STM32WBAX)
58#define STM32_CLOCK_CONTROL_NODE DT_NODELABEL(rcc)
62#define STM32_AHB_PRESCALER DT_PROP(DT_NODELABEL(rcc), ahb_prescaler)
63#define STM32_APB1_PRESCALER DT_PROP(DT_NODELABEL(rcc), apb1_prescaler)
64#define STM32_APB2_PRESCALER DT_PROP(DT_NODELABEL(rcc), apb2_prescaler)
65#define STM32_APB3_PRESCALER DT_PROP(DT_NODELABEL(rcc), apb3_prescaler)
66#define STM32_APB5_PRESCALER DT_PROP(DT_NODELABEL(rcc), apb5_prescaler)
67#define STM32_APB7_PRESCALER DT_PROP(DT_NODELABEL(rcc), apb7_prescaler)
68#define STM32_AHB3_PRESCALER DT_PROP(DT_NODELABEL(rcc), ahb3_prescaler)
69#define STM32_AHB4_PRESCALER DT_PROP(DT_NODELABEL(rcc), ahb4_prescaler)
70#define STM32_AHB5_PRESCALER DT_PROP_OR(DT_NODELABEL(rcc), ahb5_prescaler, 1)
71#define STM32_CPU1_PRESCALER DT_PROP(DT_NODELABEL(rcc), cpu1_prescaler)
72#define STM32_CPU2_PRESCALER DT_PROP(DT_NODELABEL(rcc), cpu2_prescaler)
74#if DT_NODE_HAS_PROP(DT_NODELABEL(rcc), ahb_prescaler)
75#define STM32_CORE_PRESCALER STM32_AHB_PRESCALER
76#elif DT_NODE_HAS_PROP(DT_NODELABEL(rcc), cpu1_prescaler)
77#define STM32_CORE_PRESCALER STM32_CPU1_PRESCALER
80#if DT_NODE_HAS_PROP(DT_NODELABEL(rcc), ahb3_prescaler)
81#define STM32_FLASH_PRESCALER STM32_AHB3_PRESCALER
82#elif DT_NODE_HAS_PROP(DT_NODELABEL(rcc), ahb4_prescaler)
83#define STM32_FLASH_PRESCALER STM32_AHB4_PRESCALER
85#define STM32_FLASH_PRESCALER STM32_CORE_PRESCALER
88#define STM32_ADC_PRESCALER DT_PROP(DT_NODELABEL(rcc), adc_prescaler)
89#define STM32_ADC12_PRESCALER DT_PROP(DT_NODELABEL(rcc), adc12_prescaler)
90#define STM32_ADC34_PRESCALER DT_PROP(DT_NODELABEL(rcc), adc34_prescaler)
93#if defined(CONFIG_SOC_SERIES_STM32H7RSX)
94#define STM32_D1CPRE DT_PROP(DT_NODELABEL(rcc), dcpre)
95#define STM32_HPRE DT_PROP(DT_NODELABEL(rcc), hpre)
96#define STM32_PPRE1 DT_PROP(DT_NODELABEL(rcc), ppre1)
97#define STM32_PPRE2 DT_PROP(DT_NODELABEL(rcc), ppre2)
98#define STM32_PPRE4 DT_PROP(DT_NODELABEL(rcc), ppre4)
99#define STM32_PPRE5 DT_PROP(DT_NODELABEL(rcc), ppre5)
101#define STM32_D1CPRE DT_PROP(DT_NODELABEL(rcc), d1cpre)
102#define STM32_HPRE DT_PROP(DT_NODELABEL(rcc), hpre)
103#define STM32_D2PPRE1 DT_PROP(DT_NODELABEL(rcc), d2ppre1)
104#define STM32_D2PPRE2 DT_PROP(DT_NODELABEL(rcc), d2ppre2)
105#define STM32_D1PPRE DT_PROP(DT_NODELABEL(rcc), d1ppre)
106#define STM32_D3PPRE DT_PROP(DT_NODELABEL(rcc), d3ppre)
110#define STM32_AHB5_DIV DT_PROP(DT_NODELABEL(rcc), ahb5_div)
112#define DT_RCC_CLOCKS_CTRL DT_CLOCKS_CTLR(DT_NODELABEL(rcc))
117#if DT_SAME_NODE(DT_RCC_CLOCKS_CTRL, DT_NODELABEL(pll))
118#define STM32_SYSCLK_SRC_PLL 1
120#if DT_SAME_NODE(DT_RCC_CLOCKS_CTRL, DT_NODELABEL(clk_hsi))
121#define STM32_SYSCLK_SRC_HSI 1
123#if DT_SAME_NODE(DT_RCC_CLOCKS_CTRL, DT_NODELABEL(clk_hse))
124#define STM32_SYSCLK_SRC_HSE 1
126#if DT_SAME_NODE(DT_RCC_CLOCKS_CTRL, DT_NODELABEL(clk_msi))
127#define STM32_SYSCLK_SRC_MSI 1
129#if DT_SAME_NODE(DT_RCC_CLOCKS_CTRL, DT_NODELABEL(clk_msis))
130#define STM32_SYSCLK_SRC_MSIS 1
132#if DT_SAME_NODE(DT_RCC_CLOCKS_CTRL, DT_NODELABEL(clk_csi))
133#define STM32_SYSCLK_SRC_CSI 1
139#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(pll), st_stm32f2_pll_clock, okay) || \
140 DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(pll), st_stm32f4_pll_clock, okay) || \
141 DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(pll), st_stm32f7_pll_clock, okay) || \
142 DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(pll), st_stm32g0_pll_clock, okay) || \
143 DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(pll), st_stm32g4_pll_clock, okay) || \
144 DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(pll), st_stm32l4_pll_clock, okay) || \
145 DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(pll), st_stm32u5_pll_clock, okay) || \
146 DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(pll), st_stm32wb_pll_clock, okay) || \
147 DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(pll), st_stm32wba_pll_clock, okay) || \
148 DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(pll), st_stm32h7_pll_clock, okay) || \
149 DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(pll), st_stm32h7rs_pll_clock, okay)
150#define STM32_PLL_ENABLED 1
151#define STM32_PLL_M_DIVISOR DT_PROP(DT_NODELABEL(pll), div_m)
152#define STM32_PLL_N_MULTIPLIER DT_PROP(DT_NODELABEL(pll), mul_n)
153#define STM32_PLL_P_ENABLED DT_NODE_HAS_PROP(DT_NODELABEL(pll), div_p)
154#define STM32_PLL_P_DIVISOR DT_PROP_OR(DT_NODELABEL(pll), div_p, 1)
155#define STM32_PLL_Q_ENABLED DT_NODE_HAS_PROP(DT_NODELABEL(pll), div_q)
156#define STM32_PLL_Q_DIVISOR DT_PROP_OR(DT_NODELABEL(pll), div_q, 1)
157#define STM32_PLL_R_ENABLED DT_NODE_HAS_PROP(DT_NODELABEL(pll), div_r)
158#define STM32_PLL_R_DIVISOR DT_PROP_OR(DT_NODELABEL(pll), div_r, 1)
159#define STM32_PLL_S_ENABLED DT_NODE_HAS_PROP(DT_NODELABEL(pll), div_s)
160#define STM32_PLL_S_DIVISOR DT_PROP_OR(DT_NODELABEL(pll), div_s, 1)
161#define STM32_PLL_FRACN_ENABLED DT_NODE_HAS_PROP(DT_NODELABEL(pll), fracn)
162#define STM32_PLL_FRACN_VALUE DT_PROP_OR(DT_NODELABEL(pll), fracn, 1)
165#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(plli2s), st_stm32f4_plli2s_clock, okay)
166#define STM32_PLLI2S_ENABLED 1
167#define STM32_PLLI2S_M_DIVISOR STM32_PLL_M_DIVISOR
168#define STM32_PLLI2S_N_MULTIPLIER DT_PROP(DT_NODELABEL(plli2s), mul_n)
169#define STM32_PLLI2S_R_ENABLED DT_NODE_HAS_PROP(DT_NODELABEL(plli2s), div_r)
170#define STM32_PLLI2S_R_DIVISOR DT_PROP_OR(DT_NODELABEL(plli2s), div_r, 1)
173#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(plli2s), st_stm32f412_plli2s_clock, okay)
174#define STM32_PLLI2S_ENABLED 1
175#define STM32_PLLI2S_M_DIVISOR DT_PROP(DT_NODELABEL(plli2s), div_m)
176#define STM32_PLLI2S_N_MULTIPLIER DT_PROP(DT_NODELABEL(plli2s), mul_n)
177#define STM32_PLLI2S_R_ENABLED DT_NODE_HAS_PROP(DT_NODELABEL(plli2s), div_r)
178#define STM32_PLLI2S_R_DIVISOR DT_PROP_OR(DT_NODELABEL(plli2s), div_r, 1)
181#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(pll2), st_stm32u5_pll_clock, okay) || \
182 DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(pll2), st_stm32h7_pll_clock, okay) || \
183 DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(pll2), st_stm32h7rs_pll_clock, okay)
184#define STM32_PLL2_ENABLED 1
185#define STM32_PLL2_M_DIVISOR DT_PROP(DT_NODELABEL(pll2), div_m)
186#define STM32_PLL2_N_MULTIPLIER DT_PROP(DT_NODELABEL(pll2), mul_n)
187#define STM32_PLL2_P_ENABLED DT_NODE_HAS_PROP(DT_NODELABEL(pll2), div_p)
188#define STM32_PLL2_P_DIVISOR DT_PROP_OR(DT_NODELABEL(pll2), div_p, 1)
189#define STM32_PLL2_Q_ENABLED DT_NODE_HAS_PROP(DT_NODELABEL(pll2), div_q)
190#define STM32_PLL2_Q_DIVISOR DT_PROP_OR(DT_NODELABEL(pll2), div_q, 1)
191#define STM32_PLL2_R_ENABLED DT_NODE_HAS_PROP(DT_NODELABEL(pll2), div_r)
192#define STM32_PLL2_R_DIVISOR DT_PROP_OR(DT_NODELABEL(pll2), div_r, 1)
193#define STM32_PLL2_S_ENABLED DT_NODE_HAS_PROP(DT_NODELABEL(pll2), div_s)
194#define STM32_PLL2_S_DIVISOR DT_PROP_OR(DT_NODELABEL(pll2), div_s, 1)
195#define STM32_PLL2_T_ENABLED DT_NODE_HAS_PROP(DT_NODELABEL(pll2), div_t)
196#define STM32_PLL2_T_DIVISOR DT_PROP_OR(DT_NODELABEL(pll2), div_t, 1)
197#define STM32_PLL2_FRACN_ENABLED DT_NODE_HAS_PROP(DT_NODELABEL(pll2), fracn)
198#define STM32_PLL2_FRACN_VALUE DT_PROP_OR(DT_NODELABEL(pll2), fracn, 1)
201#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(pll3), st_stm32h7_pll_clock, okay) || \
202 DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(pll3), st_stm32u5_pll_clock, okay) || \
203 DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(pll3), st_stm32h7rs_pll_clock, okay)
204#define STM32_PLL3_ENABLED 1
205#define STM32_PLL3_M_DIVISOR DT_PROP(DT_NODELABEL(pll3), div_m)
206#define STM32_PLL3_N_MULTIPLIER DT_PROP(DT_NODELABEL(pll3), mul_n)
207#define STM32_PLL3_P_ENABLED DT_NODE_HAS_PROP(DT_NODELABEL(pll3), div_p)
208#define STM32_PLL3_P_DIVISOR DT_PROP_OR(DT_NODELABEL(pll3), div_p, 1)
209#define STM32_PLL3_Q_ENABLED DT_NODE_HAS_PROP(DT_NODELABEL(pll3), div_q)
210#define STM32_PLL3_Q_DIVISOR DT_PROP_OR(DT_NODELABEL(pll3), div_q, 1)
211#define STM32_PLL3_R_ENABLED DT_NODE_HAS_PROP(DT_NODELABEL(pll3), div_r)
212#define STM32_PLL3_R_DIVISOR DT_PROP_OR(DT_NODELABEL(pll3), div_r, 1)
213#define STM32_PLL3_S_ENABLED DT_NODE_HAS_PROP(DT_NODELABEL(pll3), div_s)
214#define STM32_PLL3_S_DIVISOR DT_PROP_OR(DT_NODELABEL(pll3), div_s, 1)
215#define STM32_PLL3_FRACN_ENABLED DT_NODE_HAS_PROP(DT_NODELABEL(pll3), fracn)
216#define STM32_PLL3_FRACN_VALUE DT_PROP_OR(DT_NODELABEL(pll3), fracn, 1)
219#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(pll), st_stm32f1_pll_clock, okay)
220#define STM32_PLL_ENABLED 1
221#define STM32_PLL_XTPRE DT_PROP(DT_NODELABEL(pll), xtpre)
222#define STM32_PLL_MULTIPLIER DT_PROP(DT_NODELABEL(pll), mul)
223#define STM32_PLL_USBPRE DT_PROP(DT_NODELABEL(pll), usbpre)
224#elif DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(pll), st_stm32f0_pll_clock, okay) || \
225 DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(pll), st_stm32f100_pll_clock, okay) || \
226 DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(pll), st_stm32f105_pll_clock, okay)
227#define STM32_PLL_ENABLED 1
228#define STM32_PLL_MULTIPLIER DT_PROP(DT_NODELABEL(pll), mul)
229#define STM32_PLL_PREDIV DT_PROP(DT_NODELABEL(pll), prediv)
230#define STM32_PLL_USBPRE DT_PROP(DT_NODELABEL(pll), otgfspre)
231#elif DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(pll), st_stm32l0_pll_clock, okay)
232#define STM32_PLL_ENABLED 1
233#define STM32_PLL_DIVISOR DT_PROP(DT_NODELABEL(pll), div)
234#define STM32_PLL_MULTIPLIER DT_PROP(DT_NODELABEL(pll), mul)
237#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(pll2), st_stm32f105_pll2_clock, okay)
238#define STM32_PLL2_ENABLED 1
239#define STM32_PLL2_MULTIPLIER DT_PROP(DT_NODELABEL(pll2), mul)
240#define STM32_PLL2_PREDIV DT_PROP(DT_NODELABEL(pll2), prediv)
244#if DT_NODE_HAS_STATUS(DT_NODELABEL(pll), okay) && \
245 DT_NODE_HAS_PROP(DT_NODELABEL(pll), clocks)
246#define DT_PLL_CLOCKS_CTRL DT_CLOCKS_CTLR(DT_NODELABEL(pll))
247#if DT_SAME_NODE(DT_PLL_CLOCKS_CTRL, DT_NODELABEL(clk_msi))
248#define STM32_PLL_SRC_MSI 1
250#if DT_SAME_NODE(DT_PLL_CLOCKS_CTRL, DT_NODELABEL(clk_msis))
251#define STM32_PLL_SRC_MSIS 1
253#if DT_SAME_NODE(DT_PLL_CLOCKS_CTRL, DT_NODELABEL(clk_hsi))
254#define STM32_PLL_SRC_HSI 1
256#if DT_SAME_NODE(DT_PLL_CLOCKS_CTRL, DT_NODELABEL(clk_csi))
257#define STM32_PLL_SRC_CSI 1
259#if DT_SAME_NODE(DT_PLL_CLOCKS_CTRL, DT_NODELABEL(clk_hse))
260#define STM32_PLL_SRC_HSE 1
262#if DT_SAME_NODE(DT_PLL_CLOCKS_CTRL, DT_NODELABEL(pll2))
263#define STM32_PLL_SRC_PLL2 1
269#if DT_NODE_HAS_STATUS(DT_NODELABEL(pll2), okay) && \
270 DT_NODE_HAS_PROP(DT_NODELABEL(pll2), clocks)
271#define DT_PLL2_CLOCKS_CTRL DT_CLOCKS_CTLR(DT_NODELABEL(pll2))
272#if DT_SAME_NODE(DT_PLL2_CLOCKS_CTRL, DT_NODELABEL(clk_msis))
273#define STM32_PLL2_SRC_MSIS 1
275#if DT_SAME_NODE(DT_PLL2_CLOCKS_CTRL, DT_NODELABEL(clk_hsi))
276#define STM32_PLL2_SRC_HSI 1
278#if DT_SAME_NODE(DT_PLL2_CLOCKS_CTRL, DT_NODELABEL(clk_hse))
279#define STM32_PLL2_SRC_HSE 1
285#if DT_NODE_HAS_STATUS(DT_NODELABEL(pll3), okay) && \
286 DT_NODE_HAS_PROP(DT_NODELABEL(pll3), clocks)
287#define DT_PLL3_CLOCKS_CTRL DT_CLOCKS_CTLR(DT_NODELABEL(pll3))
288#if DT_SAME_NODE(DT_PLL3_CLOCKS_CTRL, DT_NODELABEL(clk_msis))
289#define STM32_PLL3_SRC_MSIS 1
291#if DT_SAME_NODE(DT_PLL3_CLOCKS_CTRL, DT_NODELABEL(clk_hsi))
292#define STM32_PLL3_SRC_HSI 1
294#if DT_SAME_NODE(DT_PLL3_CLOCKS_CTRL, DT_NODELABEL(clk_hse))
295#define STM32_PLL3_SRC_HSE 1
303#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(clk_lse), fixed_clock, okay)
304#define STM32_LSE_ENABLED 1
305#define STM32_LSE_FREQ DT_PROP(DT_NODELABEL(clk_lse), clock_frequency)
306#define STM32_LSE_DRIVING 0
307#define STM32_LSE_BYPASS DT_PROP(DT_NODELABEL(clk_lse), lse_bypass)
308#elif DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(clk_lse), st_stm32_lse_clock, okay)
309#define STM32_LSE_ENABLED 1
310#define STM32_LSE_FREQ DT_PROP(DT_NODELABEL(clk_lse), clock_frequency)
311#define STM32_LSE_DRIVING DT_PROP(DT_NODELABEL(clk_lse), driving_capability)
312#define STM32_LSE_BYPASS DT_PROP(DT_NODELABEL(clk_lse), lse_bypass)
314#define STM32_LSE_ENABLED 0
315#define STM32_LSE_FREQ 0
316#define STM32_LSE_DRIVING 0
317#define STM32_LSE_BYPASS 0
320#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(clk_msi), st_stm32_msi_clock, okay) || \
321 DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(clk_msi), st_stm32l0_msi_clock, okay)
322#define STM32_MSI_ENABLED 1
323#define STM32_MSI_RANGE DT_PROP(DT_NODELABEL(clk_msi), msi_range)
326#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(clk_msi), st_stm32_msi_clock, okay)
327#define STM32_MSI_ENABLED 1
328#define STM32_MSI_PLL_MODE DT_PROP(DT_NODELABEL(clk_msi), msi_pll_mode)
331#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(clk_msis), st_stm32u5_msi_clock, okay)
332#define STM32_MSIS_ENABLED 1
333#define STM32_MSIS_RANGE DT_PROP(DT_NODELABEL(clk_msis), msi_range)
334#define STM32_MSIS_PLL_MODE DT_PROP(DT_NODELABEL(clk_msis), msi_pll_mode)
336#define STM32_MSIS_ENABLED 0
337#define STM32_MSIS_RANGE 0
338#define STM32_MSIS_PLL_MODE 0
341#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(clk_msik), st_stm32u5_msi_clock, okay)
342#define STM32_MSIK_ENABLED 1
343#define STM32_MSIK_RANGE DT_PROP(DT_NODELABEL(clk_msik), msi_range)
344#define STM32_MSIK_PLL_MODE DT_PROP(DT_NODELABEL(clk_msik), msi_pll_mode)
346#define STM32_MSIK_ENABLED 0
347#define STM32_MSIK_RANGE 0
348#define STM32_MSIK_PLL_MODE 0
351#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(clk_csi), fixed_clock, okay)
352#define STM32_CSI_ENABLED 1
353#define STM32_CSI_FREQ DT_PROP(DT_NODELABEL(clk_csi), clock_frequency)
355#define STM32_CSI_FREQ 0
358#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(clk_lsi), fixed_clock, okay)
359#define STM32_LSI_ENABLED 1
360#define STM32_LSI_FREQ DT_PROP(DT_NODELABEL(clk_lsi), clock_frequency)
361#elif DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(clk_lsi1), fixed_clock, okay)
362#define STM32_LSI_ENABLED 1
363#define STM32_LSI_FREQ DT_PROP(DT_NODELABEL(clk_lsi1), clock_frequency)
364#elif DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(clk_lsi2), fixed_clock, okay)
365#define STM32_LSI_ENABLED 1
366#define STM32_LSI_FREQ DT_PROP(DT_NODELABEL(clk_lsi2), clock_frequency)
368#define STM32_LSI_FREQ 0
371#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(clk_hsi), fixed_clock, okay)
372#define STM32_HSI_DIV_ENABLED 0
373#define STM32_HSI_ENABLED 1
374#define STM32_HSI_FREQ DT_PROP(DT_NODELABEL(clk_hsi), clock_frequency)
375#elif DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(clk_hsi), st_stm32h7_hsi_clock, okay) \
376 || DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(clk_hsi), st_stm32g0_hsi_clock, okay) \
377 || DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(clk_hsi), st_stm32c0_hsi_clock, okay)
378#define STM32_HSI_DIV_ENABLED 1
379#define STM32_HSI_ENABLED 1
380#define STM32_HSI_DIVISOR DT_PROP(DT_NODELABEL(clk_hsi), hsi_div)
381#define STM32_HSI_FREQ DT_PROP(DT_NODELABEL(clk_hsi), clock_frequency)
383#define STM32_HSI_DIV_ENABLED 0
384#define STM32_HSI_DIVISOR 1
385#define STM32_HSI_FREQ 0
388#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(clk_hse), fixed_clock, okay)
389#define STM32_HSE_ENABLED 1
390#define STM32_HSE_FREQ DT_PROP(DT_NODELABEL(clk_hse), clock_frequency)
391#elif DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(clk_hse), st_stm32_hse_clock, okay)
392#define STM32_HSE_ENABLED 1
393#define STM32_HSE_BYPASS DT_PROP(DT_NODELABEL(clk_hse), hse_bypass)
394#define STM32_HSE_FREQ DT_PROP(DT_NODELABEL(clk_hse), clock_frequency)
395#define STM32_HSE_CSS DT_PROP(DT_NODELABEL(clk_hse), css_enabled)
396#elif DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(clk_hse), st_stm32wl_hse_clock, okay)
397#define STM32_HSE_ENABLED 1
398#define STM32_HSE_TCXO DT_PROP(DT_NODELABEL(clk_hse), hse_tcxo)
399#define STM32_HSE_DIV2 DT_PROP(DT_NODELABEL(clk_hse), hse_div2)
400#define STM32_HSE_FREQ DT_PROP(DT_NODELABEL(clk_hse), clock_frequency)
401#elif DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(clk_hse), st_stm32wba_hse_clock, okay)
402#define STM32_HSE_ENABLED 1
403#define STM32_HSE_DIV2 DT_PROP(DT_NODELABEL(clk_hse), hse_div2)
404#define STM32_HSE_FREQ DT_PROP(DT_NODELABEL(clk_hse), clock_frequency)
406#define STM32_HSE_FREQ 0
409#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(clk_hsi48), fixed_clock, okay)
410#define STM32_HSI48_ENABLED 1
411#define STM32_HSI48_FREQ DT_PROP(DT_NODELABEL(clk_hsi48), clock_frequency)
412#elif DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(clk_hsi48), st_stm32_hsi48_clock, okay)
413#define STM32_HSI48_ENABLED 1
414#define STM32_HSI48_FREQ DT_PROP(DT_NODELABEL(clk_hsi48), clock_frequency)
415#define STM32_HSI48_CRS_USB_SOF DT_PROP(DT_NODELABEL(clk_hsi48), crs_usb_sof)
418#if DT_NODE_HAS_COMPAT_STATUS(DT_NODELABEL(perck), st_stm32_clock_mux, okay)
419#define STM32_CKPER_ENABLED 1
431#define STM32_CLOCK_INFO(clk_index, node_id) \
433 .enr = DT_CLOCKS_CELL_BY_IDX(node_id, clk_index, bits), \
434 .bus = DT_CLOCKS_CELL_BY_IDX(node_id, clk_index, bus) \
436#define STM32_DT_CLOCKS(node_id) \
438 LISTIFY(DT_NUM_CLOCKS(node_id), \
439 STM32_CLOCK_INFO, (,), node_id) \
442#define STM32_DT_INST_CLOCKS(inst) \
443 STM32_DT_CLOCKS(DT_DRV_INST(inst))
445#define STM32_DOMAIN_CLOCK_INST_SUPPORT(inst) DT_INST_CLOCKS_HAS_IDX(inst, 1) ||
446#define STM32_DT_INST_DEV_DOMAIN_CLOCK_SUPPORT \
447 (DT_INST_FOREACH_STATUS_OKAY(STM32_DOMAIN_CLOCK_INST_SUPPORT) 0)
449#define STM32_DOMAIN_CLOCK_SUPPORT(id) DT_CLOCKS_HAS_IDX(DT_NODELABEL(id), 1) ||
450#define STM32_DT_DEV_DOMAIN_CLOCK_SUPPORT \
451 (DT_FOREACH_STATUS_OKAY(STM32_DOMAIN_CLOCK_SUPPORT) 0)
460#define STM32_CLOCK_REG_GET(clock) \
461 (((clock) >> STM32_CLOCK_REG_SHIFT) & STM32_CLOCK_REG_MASK)
468#define STM32_CLOCK_SHIFT_GET(clock) \
469 (((clock) >> STM32_CLOCK_SHIFT_SHIFT) & STM32_CLOCK_SHIFT_MASK)
476#define STM32_CLOCK_MASK_GET(clock) \
477 (((clock) >> STM32_CLOCK_MASK_SHIFT) & STM32_CLOCK_MASK_MASK)
484#define STM32_CLOCK_VAL_GET(clock) \
485 (((clock) >> STM32_CLOCK_VAL_SHIFT) & STM32_CLOCK_VAL_MASK)
487#if defined(STM32_HSE_CSS)
496void stm32_hse_css_callback(
void);
Public Clock Control APIs.
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
Driver structure definition.
Definition stm32_clock_control.h:424
uint32_t bus
Definition stm32_clock_control.h:425
uint32_t enr
Definition stm32_clock_control.h:426