From c4d9de1850dddad8afe806ffecf1fa512795d20b Mon Sep 17 00:00:00 2001 From: Erwan Gouriou Date: Mon, 16 Mar 2020 09:56:26 +0100 Subject: [PATCH] drivers/clock_control: stm32: msi: Enable MSI range config in PLL mode When MSI clock is used a source of PLL, it should be possible to select its frequency range. Fix this. Signed-off-by: Erwan Gouriou --- drivers/clock_control/Kconfig.stm32 | 2 +- drivers/clock_control/clock_stm32_ll_common.c | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/clock_control/Kconfig.stm32 b/drivers/clock_control/Kconfig.stm32 index 759cff710ee..45ee2150a21 100644 --- a/drivers/clock_control/Kconfig.stm32 +++ b/drivers/clock_control/Kconfig.stm32 @@ -65,7 +65,7 @@ config CLOCK_STM32_HSE_CLOCK config CLOCK_STM32_MSI_RANGE int "MSI frequency range" - depends on CLOCK_STM32_SYSCLK_SRC_MSI + depends on CLOCK_STM32_SYSCLK_SRC_MSI || CLOCK_STM32_PLL_SRC_MSI default 8 help Frequency range of MSI when MSI range is provided in RCC_CR register diff --git a/drivers/clock_control/clock_stm32_ll_common.c b/drivers/clock_control/clock_stm32_ll_common.c index 0817bff1cef..79bdf187368 100644 --- a/drivers/clock_control/clock_stm32_ll_common.c +++ b/drivers/clock_control/clock_stm32_ll_common.c @@ -329,6 +329,12 @@ static int stm32_clock_control_init(struct device *dev) #ifdef CONFIG_CLOCK_STM32_PLL_SRC_MSI + /* Set MSI Range */ + LL_RCC_MSI_EnableRangeSelection(); + LL_RCC_MSI_SetRange(CONFIG_CLOCK_STM32_MSI_RANGE + << RCC_CR_MSIRANGE_Pos); + LL_RCC_MSI_SetCalibTrimming(0); + #ifdef CONFIG_CLOCK_STM32_MSI_PLL_MODE /* Enable MSI hardware auto calibration */ LL_RCC_MSI_EnablePLLMode();