2019-07-02 11:22:51 +02:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Copyright (c) 2019 Ilya Tagunov
|
|
|
|
* Copyright (c) 2019 STMicroelectronics
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include <soc.h>
|
2020-11-20 20:28:06 +01:00
|
|
|
#include <stm32_ll_bus.h>
|
|
|
|
#include <stm32_ll_rcc.h>
|
|
|
|
#include <stm32_ll_utils.h>
|
2020-01-25 05:34:53 -06:00
|
|
|
#include <drivers/clock_control.h>
|
2019-12-09 11:18:21 -06:00
|
|
|
#include <sys/util.h>
|
2020-01-25 05:34:53 -06:00
|
|
|
#include <drivers/clock_control/stm32_clock_control.h>
|
2019-07-02 11:22:51 +02:00
|
|
|
#include "clock_stm32_ll_common.h"
|
|
|
|
|
|
|
|
|
2021-03-31 15:46:10 +02:00
|
|
|
#if STM32_SYSCLK_SRC_PLL
|
2019-07-02 11:22:51 +02:00
|
|
|
|
|
|
|
/* Macros to fill up multiplication and division factors values */
|
|
|
|
#define z_pll_div(v) LL_RCC_PLLM_DIV_ ## v
|
|
|
|
#define pll_div(v) z_pll_div(v)
|
|
|
|
|
|
|
|
#define z_pllr(v) LL_RCC_PLLR_DIV_ ## v
|
|
|
|
#define pllr(v) z_pllr(v)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Fill PLL configuration structure
|
|
|
|
*/
|
|
|
|
void config_pll_init(LL_UTILS_PLLInitTypeDef *pllinit)
|
|
|
|
{
|
2021-03-31 15:46:10 +02:00
|
|
|
pllinit->PLLN = STM32_PLL_N_MULTIPLIER;
|
|
|
|
pllinit->PLLM = pll_div(STM32_PLL_M_DIVISOR);
|
|
|
|
pllinit->PLLR = pllr(STM32_PLL_R_DIVISOR);
|
2019-07-02 11:22:51 +02:00
|
|
|
}
|
2021-03-31 15:46:10 +02:00
|
|
|
#endif /* STM32_SYSCLK_SRC_PLL */
|
2019-07-02 11:22:51 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Activate default clocks
|
|
|
|
*/
|
|
|
|
void config_enable_default_clocks(void)
|
|
|
|
{
|
2021-01-05 16:13:24 +01:00
|
|
|
/* Enable the power interface clock */
|
|
|
|
LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_PWR);
|
2019-07-02 11:22:51 +02:00
|
|
|
}
|