drivers: stm32: fix MSI PLL mode enabling

1. clock: move the call for MSI hardware auto calibration enabling
    before the control of MSI enable to ensure its execution in all
    cases.
 2. counter: add call for MSI hardware auto calibration enabling after
    the LSE enabling and after possible backup domain reset that may
    clear MSIPLLEN.

Signed-off-by: Giancarlo Stasi <giancarlo.stasi.co@gmail.com>
This commit is contained in:
Giancarlo Stasi 2020-09-30 21:57:27 +02:00 committed by Carles Cufí
commit ba7ef854d8
2 changed files with 10 additions and 4 deletions

View file

@ -485,6 +485,11 @@ static int stm32_clock_control_init(const struct device *dev)
LL_RCC_MSI_EnableRangeSelection();
LL_RCC_MSI_SetRange(CONFIG_CLOCK_STM32_MSI_RANGE << RCC_CR_MSIRANGE_Pos);
#if defined(CONFIG_CLOCK_STM32_MSI_PLL_MODE)
/* Enable MSI hardware auto calibration */
LL_RCC_MSI_EnablePLLMode();
#endif
/* Enable MSI if not enabled */
if (LL_RCC_MSI_IsReady() != 1) {
/* Enable MSI */
@ -492,10 +497,6 @@ static int stm32_clock_control_init(const struct device *dev)
while (LL_RCC_MSI_IsReady() != 1) {
/* Wait for HSI ready */
}
#ifdef CONFIG_CLOCK_STM32_MSI_PLL_MODE
/* Enable MSI hardware auto calibration */
LL_RCC_MSI_EnablePLLMode();
#endif
}
/* Set MSI as SYSCLCK source */