Skip to content

Commit abc3fec

Browse files
FRASTMkartben
authored andcommitted
drivers: clock control: stm32H7 has the same clock source for all PLL
Select the PLL clock source for PLL2 or PLL3 as well as main PLL This choice is useful if main PLL is off (sysclock from fixed clock) but PLL2 or PLL3 are on for other peripherals All PLL must have the same source else this is an error. Signed-off-by: Francois Ramu <[email protected]>
1 parent 3956dff commit abc3fec

File tree

1 file changed

+28
-8
lines changed

1 file changed

+28
-8
lines changed

drivers/clock_control/clock_stm32_ll_h7.c

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,29 @@
5353
/* This check should only be performed for the M7 core code */
5454
#ifdef CONFIG_CPU_CORTEX_M7
5555

56-
/* Choose PLL SRC */
57-
#if defined(STM32_PLL_SRC_HSI)
56+
/* Choose PLL SRC : same source for all the PLL */
57+
#if defined(STM32_PLL_SRC_HSI) || defined(STM32_PLL2_SRC_HSI) || defined(STM32_PLL3_SRC_HSI)
5858
#define PLLSRC_FREQ ((STM32_HSI_FREQ)/(STM32_HSI_DIVISOR))
59-
#elif defined(STM32_PLL_SRC_CSI)
59+
#endif
60+
61+
#if defined(STM32_PLL_SRC_CSI) || defined(STM32_PLL2_SRC_CSI) || defined(STM32_PLL3_SRC_CSI)
62+
#if !defined(PLLSRC_FREQ)
6063
#define PLLSRC_FREQ STM32_CSI_FREQ
61-
#elif defined(STM32_PLL_SRC_HSE)
64+
#else
65+
#error "All PLLs must have the same clock source"
66+
#endif
67+
#endif
68+
69+
#if defined(STM32_PLL_SRC_HSE) || defined(STM32_PLL2_SRC_HSE) || defined(STM32_PLL3_SRC_HSE)
70+
#if !defined(PLLSRC_FREQ)
6271
#define PLLSRC_FREQ STM32_HSE_FREQ
6372
#else
64-
#define PLLSRC_FREQ 0
73+
#error "All PLLs must have the same clock source"
74+
#endif
75+
#endif
76+
77+
#if !defined(PLLSRC_FREQ)
78+
#define PLLSRC_FREQ 0
6579
#endif
6680

6781
/* Given source clock and dividers, computed the output frequency of PLLP */
@@ -782,13 +796,19 @@ static int set_up_plls(void)
782796
/* Configure PLL source */
783797

784798
/* Can be HSE , HSI 64Mhz/HSIDIV, CSI 4MHz*/
785-
if (IS_ENABLED(STM32_PLL_SRC_HSE)) {
799+
if (IS_ENABLED(STM32_PLL_SRC_HSE) ||
800+
IS_ENABLED(STM32_PLL2_SRC_HSE) ||
801+
IS_ENABLED(STM32_PLL3_SRC_HSE)) {
786802
/* Main PLL configuration and activation */
787803
LL_RCC_PLL_SetSource(LL_RCC_PLLSOURCE_HSE);
788-
} else if (IS_ENABLED(STM32_PLL_SRC_CSI)) {
804+
} else if (IS_ENABLED(STM32_PLL_SRC_CSI) ||
805+
IS_ENABLED(STM32_PLL2_SRC_CSI) ||
806+
IS_ENABLED(STM32_PLL3_SRC_CSI)) {
789807
/* Main PLL configuration and activation */
790808
LL_RCC_PLL_SetSource(LL_RCC_PLLSOURCE_CSI);
791-
} else if (IS_ENABLED(STM32_PLL_SRC_HSI)) {
809+
} else if (IS_ENABLED(STM32_PLL_SRC_HSI) ||
810+
IS_ENABLED(STM32_PLL2_SRC_HSI) ||
811+
IS_ENABLED(STM32_PLL3_SRC_HSI)) {
792812
/* Main PLL configuration and activation */
793813
LL_RCC_PLL_SetSource(LL_RCC_PLLSOURCE_HSI);
794814
} else {

0 commit comments

Comments
 (0)