Skip to content

Commit

Permalink
drivers/clock_control: stm32f1: Reinstanciate CLOCK_STM32_PLL_XTPRE
Browse files Browse the repository at this point in the history
This reverts commit "drivers/clock_control: Remove useless
CLOCK_STM32_PLL_XTPRE config" 9be1f7e.

Fixes #32382

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
  • Loading branch information
erwango authored and nashif committed Feb 19, 2021
1 parent cb97dd1 commit 664df1e
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 1 deletion.
1 change: 1 addition & 0 deletions boards/arm/nucleo_f103rb/nucleo_f103rb_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ CONFIG_CLOCK_STM32_PLL_SRC_HSE=y
# the 8MHz clock signal coming from integrated STLink
CONFIG_CLOCK_STM32_HSE_BYPASS=y
# produce 72MHz clock at PLL output
CONFIG_CLOCK_STM32_PLL_XTPRE=n
CONFIG_CLOCK_STM32_PLL_MULTIPLIER=9
CONFIG_CLOCK_STM32_AHB_PRESCALER=1
# APB1 clock must not to exceed 36MHz limit
Expand Down
1 change: 1 addition & 0 deletions boards/arm/olimexino_stm32/olimexino_stm32_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ CONFIG_CLOCK_STM32_SYSCLK_SRC_PLL=y
# use HSE as PLL input
CONFIG_CLOCK_STM32_PLL_SRC_HSE=y
# produce 72MHz clock at PLL output
CONFIG_CLOCK_STM32_PLL_XTPRE=n
CONFIG_CLOCK_STM32_PLL_MULTIPLIER=9
CONFIG_CLOCK_STM32_AHB_PRESCALER=1
# APB1 clock must not to exceed 36MHz limit
Expand Down
1 change: 1 addition & 0 deletions boards/arm/stm32_min_dev/stm32_min_dev_black_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ CONFIG_CLOCK_STM32_SYSCLK_SRC_PLL=y
# use HSE as PLL input
CONFIG_CLOCK_STM32_PLL_SRC_HSE=y
# produce 72MHz clock at PLL output
CONFIG_CLOCK_STM32_PLL_XTPRE=n
CONFIG_CLOCK_STM32_PLL_MULTIPLIER=9
CONFIG_CLOCK_STM32_AHB_PRESCALER=1

Expand Down
1 change: 1 addition & 0 deletions boards/arm/stm32_min_dev/stm32_min_dev_blue_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ CONFIG_CLOCK_STM32_SYSCLK_SRC_PLL=y
# use HSE as PLL input
CONFIG_CLOCK_STM32_PLL_SRC_HSE=y
# produce 72MHz clock at PLL output
CONFIG_CLOCK_STM32_PLL_XTPRE=n
CONFIG_CLOCK_STM32_PLL_MULTIPLIER=9
CONFIG_CLOCK_STM32_AHB_PRESCALER=1

Expand Down
8 changes: 7 additions & 1 deletion drivers/clock_control/Kconfig.stm32f1
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@

if SOC_SERIES_STM32F1X

config CLOCK_STM32_PLL_XTPRE
bool "HSE to PLL /2 prescaler"
depends on SOC_STM32F10X_DENSITY_DEVICE && CLOCK_STM32_PLL_SRC_HSE
help
Enable this option to enable /2 prescaler on HSE to PLL clock signal

config CLOCK_STM32_PLL_MULTIPLIER
int "PLL multiplier"
depends on CLOCK_STM32_SYSCLK_SRC_PLL
Expand All @@ -18,7 +24,7 @@ config CLOCK_STM32_PLL_MULTIPLIER

config CLOCK_STM32_PLL_PREDIV1
int "PREDIV1 Prescaler"
depends on CLOCK_STM32_SYSCLK_SRC_PLL
depends on SOC_STM32F10X_CONNECTIVITY_LINE_DEVICE && CLOCK_STM32_SYSCLK_SRC_PLL
default 1
range 1 16
help
Expand Down
25 changes: 25 additions & 0 deletions drivers/clock_control/clock_stm32f1.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,40 @@
void config_pll_init(LL_UTILS_PLLInitTypeDef *pllinit)
{
/*
* PLLMUL on SOC_STM32F10X_DENSITY_DEVICE
* 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
*
* 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
*/
pllinit->PLLMul = ((CONFIG_CLOCK_STM32_PLL_MULTIPLIER - 2)
<< RCC_CFGR_PLLMULL_Pos);

#ifdef CONFIG_SOC_STM32F10X_DENSITY_DEVICE
/* PLL prediv */
#ifdef CONFIG_CLOCK_STM32_PLL_XTPRE
/*
* 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;
#endif /* CONFIG_CLOCK_STM32_PLL_XTPRE */
#else
/*
* SOC_STM32F10X_CONNECTIVITY_LINE_DEVICE
* 1 -> LL_RCC_PREDIV_DIV_1 -> 0x00000000
Expand All @@ -55,6 +79,7 @@ void config_pll_init(LL_UTILS_PLLInitTypeDef *pllinit)
* 16 -> LL_RCC_PREDIV_DIV_16 -> 0x0000000F
*/
pllinit->Prediv = CONFIG_CLOCK_STM32_PLL_PREDIV1 - 1;
#endif /* CONFIG_SOC_STM32F10X_DENSITY_DEVICE */
}

#endif /* CONFIG_CLOCK_STM32_SYSCLK_SRC_PLL */
Expand Down

0 comments on commit 664df1e

Please sign in to comment.