2017-05-29 20:52:19 +08:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Copyright (c) 2017 Linaro Limited.
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include <soc.h>
|
2020-11-21 03:28:06 +08:00
|
|
|
#include <stm32_ll_bus.h>
|
|
|
|
#include <stm32_ll_rcc.h>
|
|
|
|
#include <stm32_ll_utils.h>
|
2019-06-26 03:53:47 +08:00
|
|
|
#include <drivers/clock_control.h>
|
2019-06-26 22:33:55 +08:00
|
|
|
#include <sys/util.h>
|
2020-01-25 19:34:53 +08:00
|
|
|
#include <drivers/clock_control/stm32_clock_control.h>
|
2019-04-12 00:20:15 +08:00
|
|
|
#include "clock_stm32_ll_common.h"
|
2017-05-29 20:52:19 +08:00
|
|
|
|
|
|
|
|
2021-03-31 21:46:10 +08:00
|
|
|
#if STM32_SYSCLK_SRC_PLL
|
2017-05-29 20:52:19 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Select PLL source for STM32F1 Connectivity line devices (STM32F105xx and
|
|
|
|
* STM32F107xx).
|
|
|
|
* Both flags are defined in STM32Cube LL API. Keep only the selected one.
|
|
|
|
*/
|
2021-03-31 21:46:10 +08:00
|
|
|
#if STM32_PLL_SRC_PLL2
|
2017-05-29 20:52:19 +08:00
|
|
|
#undef RCC_PREDIV1_SOURCE_HSE
|
|
|
|
#else
|
|
|
|
#undef RCC_PREDIV1_SOURCE_PLL2
|
2021-03-31 21:46:10 +08:00
|
|
|
#endif /* STM32_PLL_SRC_PLL2 */
|
2017-05-29 20:52:19 +08:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief fill in pll configuration structure
|
|
|
|
*/
|
|
|
|
void config_pll_init(LL_UTILS_PLLInitTypeDef *pllinit)
|
|
|
|
{
|
|
|
|
/*
|
2021-02-17 19:23:09 +08:00
|
|
|
* PLLMUL on SOC_STM32F10X_DENSITY_DEVICE
|
2017-05-29 20:52:19 +08:00
|
|
|
* 2 -> LL_RCC_PLL_MUL_2 -> 0x00000000
|
|
|
|
* 3 -> LL_RCC_PLL_MUL_3 -> 0x00040000
|
|
|
|
* 4 -> LL_RCC_PLL_MUL_4 -> 0x00080000
|
|
|
|
* ...
|
|
|
|
* 16 -> LL_RCC_PLL_MUL_16 -> 0x00380000
|
|
|
|
*
|
2021-02-17 19:23:09 +08:00
|
|
|
* PLLMUL on SOC_STM32F10X_CONNECTIVITY_LINE_DEVICE
|
|
|
|
* 4 -> LL_RCC_PLL_MUL_4 -> 0x00080000
|
|
|
|
* ...
|
|
|
|
* 9 -> LL_RCC_PLL_MUL_9 -> 0x001C0000
|
|
|
|
* 13 -> LL_RCC_PLL_MUL_6_5 -> 0x00340000
|
2017-05-29 20:52:19 +08:00
|
|
|
*/
|
2021-04-13 21:51:32 +08:00
|
|
|
pllinit->PLLMul = ((STM32_PLL_MULTIPLIER - 2)
|
2017-05-29 20:52:19 +08:00
|
|
|
<< RCC_CFGR_PLLMULL_Pos);
|
|
|
|
|
2021-02-17 19:23:09 +08:00
|
|
|
#ifdef CONFIG_SOC_STM32F10X_DENSITY_DEVICE
|
|
|
|
/* PLL prediv */
|
2021-04-13 21:51:32 +08:00
|
|
|
#ifdef STM32_PLL_XTPRE
|
2021-02-17 19:23:09 +08:00
|
|
|
/*
|
|
|
|
* SOC_STM32F10X_DENSITY_DEVICE:
|
|
|
|
* PLLXPTRE (depends on PLL source HSE)
|
|
|
|
* HSE/2 used as PLL source
|
|
|
|
*/
|
|
|
|
pllinit->Prediv = LL_RCC_PREDIV_DIV_2;
|
|
|
|
#else
|
|
|
|
/*
|
|
|
|
* SOC_STM32F10X_DENSITY_DEVICE:
|
|
|
|
* PLLXPTRE (depends on PLL source HSE)
|
|
|
|
* HSE used as direct PLL source
|
|
|
|
*/
|
|
|
|
pllinit->Prediv = LL_RCC_PREDIV_DIV_1;
|
2021-04-13 21:51:32 +08:00
|
|
|
#endif /* STM32_PLL_XTPRE */
|
2021-02-17 19:23:09 +08:00
|
|
|
#else
|
2017-05-29 20:52:19 +08:00
|
|
|
/*
|
|
|
|
* SOC_STM32F10X_CONNECTIVITY_LINE_DEVICE
|
|
|
|
* 1 -> LL_RCC_PREDIV_DIV_1 -> 0x00000000
|
|
|
|
* 2 -> LL_RCC_PREDIV_DIV_2 -> 0x00000001
|
|
|
|
* 3 -> LL_RCC_PREDIV_DIV_3 -> 0x00000002
|
|
|
|
* ...
|
|
|
|
* 16 -> LL_RCC_PREDIV_DIV_16 -> 0x0000000F
|
|
|
|
*/
|
2021-04-13 21:51:32 +08:00
|
|
|
pllinit->Prediv = STM32_PLL_PREDIV1 - 1;
|
2021-02-17 19:23:09 +08:00
|
|
|
#endif /* CONFIG_SOC_STM32F10X_DENSITY_DEVICE */
|
2017-05-29 20:52:19 +08:00
|
|
|
}
|
|
|
|
|
2021-03-31 21:46:10 +08:00
|
|
|
#endif /* STM32_SYSCLK_SRC_PLL */
|
2017-05-29 20:52:19 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Activate default clocks
|
|
|
|
*/
|
|
|
|
void config_enable_default_clocks(void)
|
|
|
|
{
|
|
|
|
/* Nothing for now */
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Function kept for driver genericity
|
|
|
|
*/
|
|
|
|
void LL_RCC_MSI_Disable(void)
|
|
|
|
{
|
|
|
|
/* Do nothing */
|
|
|
|
}
|