drivers: clock_control: stm32 mco driver get define from DTS

Rely on the DTS to get the MCO input source clock and prescaler.
DTS configuration has been introduced and Kconfig method
deprecated two releases before and can be then safely removed.

Signed-off-by: Francois Ramu <francois.ramu@st.com>
This commit is contained in:
Francois Ramu 2024-11-15 15:48:07 +01:00 committed by Anas Nashif
commit f0ba72e210
6 changed files with 3 additions and 432 deletions

View file

@ -97,310 +97,8 @@ config CLOCK_STM32_MCO
bool
default y
depends on DT_HAS_ST_STM32_CLOCK_MCO_ENABLED || DT_HAS_ST_STM32F1_CLOCK_MCO_ENABLED
# Although deprecated, MCO configuration via Kconfig takes priority over Device Tree.
# Prevent DT-based MCO driver from compiling when Kconfig is used.
depends on CLOCK_STM32_MCO1_SRC_NOCLOCK && CLOCK_STM32_MCO2_SRC_NOCLOCK
choice
prompt "STM32 MCO1 Clock Source"
default CLOCK_STM32_MCO1_SRC_NOCLOCK
config CLOCK_STM32_MCO1_SRC_NOCLOCK
bool "NOCLOCK"
help
MCO1 output disabled, no clock on MCO1
config CLOCK_STM32_MCO1_SRC_EXT_HSE
bool "EXT_HSE"
depends on SOC_STM32F10X_CONNECTIVITY_LINE_DEVICE
select DEPRECATED
help
Use EXT_HSE as source of MCO1
This option is deprecated, please use devicetree instead.
config CLOCK_STM32_MCO1_SRC_LSE
bool "LSE"
depends on SOC_SERIES_STM32F4X || \
SOC_SERIES_STM32F7X || \
SOC_SERIES_STM32L4X || \
SOC_SERIES_STM32H7X || \
SOC_SERIES_STM32H7RSX || \
SOC_SERIES_STM32H5X || \
SOC_SERIES_STM32U5X
select DEPRECATED
help
Use LSE as source of MCO1
This option is deprecated, please use devicetree instead.
config CLOCK_STM32_MCO1_SRC_HSE
bool "HSE"
depends on SOC_SERIES_STM32F1X || \
SOC_SERIES_STM32F4X || \
SOC_SERIES_STM32F7X || \
SOC_SERIES_STM32L4X || \
SOC_SERIES_STM32H7X || \
SOC_SERIES_STM32H7RSX || \
SOC_SERIES_STM32H5X || \
SOC_SERIES_STM32U5X
select DEPRECATED
help
Use HSE as source of MCO1
This option is deprecated, please use devicetree instead.
config CLOCK_STM32_MCO1_SRC_LSI
bool "LSI"
depends on SOC_SERIES_STM32L4X || \
SOC_SERIES_STM32U5X
select DEPRECATED
help
Use LSI as source of MCO1
This option is deprecated, please use devicetree instead.
config CLOCK_STM32_MCO1_SRC_MSI
bool "MSI"
depends on SOC_SERIES_STM32L4X
select DEPRECATED
help
Use MSI as source of MCO1
This option is deprecated, please use devicetree instead.
config CLOCK_STM32_MCO1_SRC_MSIK
bool "MSIK"
depends on SOC_SERIES_STM32U5X
select DEPRECATED
help
Use MSIK as source of MCO1
This option is deprecated, please use devicetree instead.
config CLOCK_STM32_MCO1_SRC_MSIS
bool "MSIS"
depends on SOC_SERIES_STM32U5X
select DEPRECATED
help
Use MSIS as source of MCO1
This option is deprecated, please use devicetree instead.
config CLOCK_STM32_MCO1_SRC_HSI
bool "HSI"
depends on SOC_SERIES_STM32F1X || \
SOC_SERIES_STM32F4X || \
SOC_SERIES_STM32F7X || \
SOC_SERIES_STM32H7X || \
SOC_SERIES_STM32H7RSX || \
SOC_SERIES_STM32H5X
select DEPRECATED
help
Use HSI as source of MCO1
This option is deprecated, please use devicetree instead.
config CLOCK_STM32_MCO1_SRC_HSI16
bool "HSI16"
depends on SOC_SERIES_STM32L4X || \
SOC_SERIES_STM32U5X
select DEPRECATED
help
Use HSI16 as source of MCO1
This option is deprecated, please use devicetree instead.
config CLOCK_STM32_MCO1_SRC_HSI48
bool "HSI48"
depends on SOC_SERIES_STM32L4X || \
SOC_SERIES_STM32H7X || \
SOC_SERIES_STM32H7RSX || \
SOC_SERIES_STM32H5X || \
SOC_SERIES_STM32U5X
select DEPRECATED
help
Use HSI48 as source of MCO1
This option is deprecated, please use devicetree instead.
config CLOCK_STM32_MCO1_SRC_PLLCLK
bool "PLLCLK"
depends on SOC_SERIES_STM32F4X || \
SOC_SERIES_STM32F7X || \
SOC_SERIES_STM32L4X || \
SOC_SERIES_STM32U5X
select DEPRECATED
help
Use PLLCLK as source of MCO1
This option is deprecated, please use devicetree instead.
config CLOCK_STM32_MCO1_SRC_PLLQCLK
bool "PLLQ"
depends on SOC_SERIES_STM32H7X || \
SOC_SERIES_STM32H7RSX || \
SOC_SERIES_STM32H5X
select DEPRECATED
help
Use PLLQ as source of MCO1
This option is deprecated, please use devicetree instead.
config CLOCK_STM32_MCO1_SRC_PLLCLK_DIV2
bool "PLLCLK_DIV2"
depends on SOC_SERIES_STM32F1X
select DEPRECATED
help
Use PLLCLK/2 as source of MCO1
This option is deprecated, please use devicetree instead.
config CLOCK_STM32_MCO1_SRC_PLL2CLK
bool "PLL2CLK"
depends on SOC_STM32F10X_CONNECTIVITY_LINE_DEVICE
select DEPRECATED
help
Use PLL2CLK as source of MCO1
This option is deprecated, please use devicetree instead.
config CLOCK_STM32_MCO1_SRC_PLLI2SCLK
bool "PLLI2SCLK"
depends on SOC_STM32F10X_CONNECTIVITY_LINE_DEVICE
select DEPRECATED
help
Use PLLI2SCLK as source of MCO1
This option is deprecated, please use devicetree instead.
config CLOCK_STM32_MCO1_SRC_PLLI2SCLK_DIV2
bool "PLLI2SCLK_DIV2"
depends on SOC_STM32F10X_CONNECTIVITY_LINE_DEVICE
select DEPRECATED
help
Use PLLI2SCLK/2 as source of MCO1
This option is deprecated, please use devicetree instead.
config CLOCK_STM32_MCO1_SRC_SYSCLK
bool "SYSCLK"
depends on SOC_SERIES_STM32F1X || \
SOC_SERIES_STM32L4X || \
SOC_SERIES_STM32U5X
select DEPRECATED
help
Use SYSCLK as source of MCO1
This option is deprecated, please use devicetree instead.
endchoice
config CLOCK_STM32_MCO1_DIV
int "MCO1 prescaler"
depends on !CLOCK_STM32_MCO1_SRC_NOCLOCK && (\
SOC_SERIES_STM32F4X || \
SOC_SERIES_STM32F7X || \
SOC_SERIES_STM32L4X || \
SOC_SERIES_STM32H7X || \
SOC_SERIES_STM32H7RSX || \
SOC_SERIES_STM32H5X || \
SOC_SERIES_STM32U5X \
)
default 1
range 1 5 if SOC_SERIES_STM32F4X || SOC_SERIES_STM32F7X
range 1 15 if SOC_SERIES_STM32H7X || SOC_SERIES_STM32H7RSX || SOC_SERIES_STM32H5X
range 1 16 if SOC_SERIES_STM32L4X || SOC_SERIES_STM32U5X
help
Prescaler for MCO1 output clock
This option is deprecated, please use devicetree instead.
choice
prompt "STM32 MCO2 Clock Source"
default CLOCK_STM32_MCO2_SRC_NOCLOCK
config CLOCK_STM32_MCO2_SRC_NOCLOCK
bool "NOCLOCK"
help
MCO2 output disabled, no clock on MCO2
config CLOCK_STM32_MCO2_SRC_SYSCLK
bool "SYSCLK"
depends on SOC_SERIES_STM32F4X || \
SOC_SERIES_STM32F7X || \
SOC_SERIES_STM32H7X || \
SOC_SERIES_STM32H7RSX || \
SOC_SERIES_STM32H5X
select DEPRECATED
help
Use SYSCLK as source of MCO2
This option is deprecated, please use devicetree instead.
config CLOCK_STM32_MCO2_SRC_PLLI2S
bool "PLLI2S"
depends on SOC_SERIES_STM32F4X || SOC_SERIES_STM32F7X
select DEPRECATED
help
Use PLLI2S as source of MCO2
This option is deprecated, please use devicetree instead.
config CLOCK_STM32_MCO2_SRC_HSE
bool "HSE"
depends on SOC_SERIES_STM32F4X || \
SOC_SERIES_STM32F7X || \
SOC_SERIES_STM32H7X || \
SOC_SERIES_STM32H7RSX || \
SOC_SERIES_STM32H5X
select DEPRECATED
help
Use HSE as source of MCO2
This option is deprecated, please use devicetree instead.
config CLOCK_STM32_MCO2_SRC_LSI
bool "LSI"
depends on SOC_SERIES_STM32H7X || \
SOC_SERIES_STM32H7RSX || \
SOC_SERIES_STM32H5X
help
Use LSI as source of MCO2
This option is deprecated, please use devicetree instead.
config CLOCK_STM32_MCO2_SRC_CSI
bool "CSI"
depends on SOC_SERIES_STM32H7X || \
SOC_SERIES_STM32H7RSX || \
SOC_SERIES_STM32H5X
select DEPRECATED
help
Use CSI as source of MCO2
This option is deprecated, please use devicetree instead.
config CLOCK_STM32_MCO2_SRC_PLLCLK
bool "PLLCLK"
depends on SOC_SERIES_STM32F4X || SOC_SERIES_STM32F7X
select DEPRECATED
help
Use PLLCLK as source of MCO2
This option is deprecated, please use devicetree instead.
config CLOCK_STM32_MCO2_SRC_PLLPCLK
bool "PLLPCLK"
depends on SOC_SERIES_STM32H7X || \
SOC_SERIES_STM32H7RSX || \
SOC_SERIES_STM32H5X
select DEPRECATED
help
Use PLLPCLK as source of MC02
This option is deprecated, please use devicetree instead.
config CLOCK_STM32_MCO2_SRC_PLL2PCLK
bool "PLL2PCLK"
depends on SOC_SERIES_STM32H7X || \
SOC_SERIES_STM32H7RSX || \
SOC_SERIES_STM32H5X
select DEPRECATED
help
Use PLL2PCLK as source of MC02
This option is deprecated, please use devicetree instead.
endchoice
config CLOCK_STM32_MCO2_DIV
int "MCO2 prescaler"
depends on !CLOCK_STM32_MCO2_SRC_NOCLOCK && (\
SOC_SERIES_STM32F4X || \
SOC_SERIES_STM32F7X || \
SOC_SERIES_STM32H5X || \
SOC_SERIES_STM32H7X || \
SOC_SERIES_STM32H7RSX \
)
default 1
range 1 5 if SOC_SERIES_STM32F4X || SOC_SERIES_STM32F7X
range 1 15 if SOC_SERIES_STM32H7X || SOC_SERIES_STM32H7RSX || SOC_SERIES_STM32H5X
help
Prescaler for MCO2 output clock
Allows to output various different clock sources onto the MCO pin
using a configurable prescaler.
endif # CLOCK_CONTROL_STM32_CUBE

View file

@ -17,7 +17,6 @@
#include <zephyr/sys/__assert.h>
#include <zephyr/drivers/clock_control/stm32_clock_control.h>
#include "clock_stm32_ll_common.h"
#include "clock_stm32_ll_mco.h"
#include "stm32_hsem.h"
/* Macros to fill up prescaler values */
@ -870,9 +869,6 @@ int stm32_clock_control_init(const struct device *dev)
LL_RCC_SetADCClockSource(adc34_prescaler(STM32_ADC34_PRESCALER));
#endif
/* configure MCO1/MCO2 based on Kconfig */
stm32_clock_control_mco_init();
return 0;
}

View file

@ -18,7 +18,6 @@
#include <zephyr/drivers/clock_control.h>
#include <zephyr/sys/util.h>
#include <zephyr/drivers/clock_control/stm32_clock_control.h>
#include "clock_stm32_ll_mco.h"
/* Macros to fill up prescaler values */
#define z_hsi_divider(v) LL_RCC_HSI_DIV_ ## v
@ -769,9 +768,6 @@ int stm32_clock_control_init(const struct device *dev)
/* Update CMSIS variable */
SystemCoreClock = CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC;
/* configure MCO1/MCO2 based on Kconfig */
stm32_clock_control_mco_init();
return 0;
}

View file

@ -16,7 +16,6 @@
#include <zephyr/drivers/clock_control.h>
#include <zephyr/sys/util.h>
#include <zephyr/drivers/clock_control/stm32_clock_control.h>
#include "clock_stm32_ll_mco.h"
#include "stm32_hsem.h"
@ -1083,9 +1082,6 @@ int stm32_clock_control_init(const struct device *dev)
#endif
z_stm32_hsem_lock(CFG_HW_RCC_SEMID, HSEM_LOCK_DEFAULT_RETRY);
/* Configure MCO1/MCO2 based on Kconfig */
stm32_clock_control_mco_init();
/* Set up individual enabled clocks */
set_up_fixed_clock_sources();

View file

@ -1,112 +0,0 @@
/*
* Copyright (c) 2017-2022 Linaro Limited.
* Copyright (c) 2017 RnDity Sp. z o.o.
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef ZEPHYR_DRIVERS_CLOCK_CONTROL_CLOCK_STM32_LL_MCO_H_
#define ZEPHYR_DRIVERS_CLOCK_CONTROL_CLOCK_STM32_LL_MCO_H_
#include <stm32_ll_utils.h>
#if CONFIG_CLOCK_STM32_MCO1_SRC_NOCLOCK
#define MCO1_SOURCE LL_RCC_MCO1SOURCE_NOCLOCK
#elif CONFIG_CLOCK_STM32_MCO1_SRC_EXT_HSE
#define MCO1_SOURCE LL_RCC_MCO1SOURCE_EXT_HSE
#elif CONFIG_CLOCK_STM32_MCO1_SRC_LSE
#define MCO1_SOURCE LL_RCC_MCO1SOURCE_LSE
#elif CONFIG_CLOCK_STM32_MCO1_SRC_HSE
#define MCO1_SOURCE LL_RCC_MCO1SOURCE_HSE
#elif CONFIG_CLOCK_STM32_MCO1_SRC_LSI
#define MCO1_SOURCE LL_RCC_MCO1SOURCE_LSI
#elif CONFIG_CLOCK_STM32_MCO1_SRC_MSI
#define MCO1_SOURCE LL_RCC_MCO1SOURCE_MSI
#elif CONFIG_CLOCK_STM32_MCO1_SRC_MSIK
#define MCO1_SOURCE LL_RCC_MCO1SOURCE_MSIK
#elif CONFIG_CLOCK_STM32_MCO1_SRC_MSIS
#define MCO1_SOURCE LL_RCC_MCO1SOURCE_MSIS
#elif CONFIG_CLOCK_STM32_MCO1_SRC_HSI
#define MCO1_SOURCE LL_RCC_MCO1SOURCE_HSI
#elif CONFIG_CLOCK_STM32_MCO1_SRC_HSI16
#define MCO1_SOURCE LL_RCC_MCO1SOURCE_HSI
#elif CONFIG_CLOCK_STM32_MCO1_SRC_HSI48
#define MCO1_SOURCE LL_RCC_MCO1SOURCE_HSI48
#elif CONFIG_CLOCK_STM32_MCO1_SRC_PLLCLK
#define MCO1_SOURCE LL_RCC_MCO1SOURCE_PLLCLK
#elif CONFIG_CLOCK_STM32_MCO1_SRC_PLLQCLK
#if (CONFIG_SOC_SERIES_STM32G0X || CONFIG_SOC_SERIES_STM32WLX)
#define MCO1_SOURCE LL_RCC_MCO1SOURCE_PLLQCLK
#elif (CONFIG_SOC_SERIES_STM32H5X || \
CONFIG_SOC_SERIES_STM32H7X || CONFIG_SOC_SERIES_STM32H7RSX)
#define MCO1_SOURCE LL_RCC_MCO1SOURCE_PLL1QCLK
#else
#error "PLLQCLK is not a valid clock source on your SOC"
#endif
#elif CONFIG_CLOCK_STM32_MCO1_SRC_PLLCLK_DIV2
#define MCO1_SOURCE LL_RCC_MCO1SOURCE_PLLCLK_DIV_2
#elif CONFIG_CLOCK_STM32_MCO1_SRC_PLL2CLK
#define MCO1_SOURCE LL_RCC_MCO1SOURCE_PLL2CLK
#elif CONFIG_CLOCK_STM32_MCO1_SRC_PLLI2SCLK
#define MCO1_SOURCE LL_RCC_MCO1SOURCE_PLLI2SCLK
#elif CONFIG_CLOCK_STM32_MCO1_SRC_PLLI2SCLK_DIV2
#define MCO1_SOURCE LL_RCC_MCO1SOURCE_PLLI2SCLK_DIV2
#elif CONFIG_CLOCK_STM32_MCO1_SRC_SYSCLK
#define MCO1_SOURCE LL_RCC_MCO1SOURCE_SYSCLK
#endif
#if CONFIG_CLOCK_STM32_MCO2_SRC_SYSCLK
#define MCO2_SOURCE LL_RCC_MCO2SOURCE_SYSCLK
#elif CONFIG_CLOCK_STM32_MCO2_SRC_PLLI2S
#define MCO2_SOURCE LL_RCC_MCO2SOURCE_PLLI2S
#elif CONFIG_CLOCK_STM32_MCO2_SRC_HSE
#define MCO2_SOURCE LL_RCC_MCO2SOURCE_HSE
#elif CONFIG_CLOCK_STM32_MCO2_SRC_LSI
#define MCO2_SOURCE LL_RCC_MCO2SOURCE_LSI
#elif CONFIG_CLOCK_STM32_MCO2_SRC_CSI
#define MCO2_SOURCE LL_RCC_MCO2SOURCE_CSI
#elif CONFIG_CLOCK_STM32_MCO2_SRC_PLLCLK
#define MCO2_SOURCE LL_RCC_MCO2SOURCE_PLLCLK
#elif CONFIG_CLOCK_STM32_MCO2_SRC_PLLPCLK
#define MCO2_SOURCE LL_RCC_MCO2SOURCE_PLL1PCLK
#elif CONFIG_CLOCK_STM32_MCO2_SRC_PLL2PCLK
#define MCO2_SOURCE LL_RCC_MCO2SOURCE_PLL2PCLK
#endif
#define fn_mco1_prescaler(v) LL_RCC_MCO1_DIV_ ## v
#define mco1_prescaler(v) fn_mco1_prescaler(v)
#define fn_mco2_prescaler(v) LL_RCC_MCO2_DIV_ ## v
#define mco2_prescaler(v) fn_mco2_prescaler(v)
#ifdef __cplusplus
extern "C" {
#endif
/*
* MCO configure doesn't active requested clock source,
* so please make sure the clock source was enabled.
*/
__unused
static inline void stm32_clock_control_mco_init(void)
{
#ifndef CONFIG_CLOCK_STM32_MCO1_SRC_NOCLOCK
#ifdef CONFIG_SOC_SERIES_STM32F1X
LL_RCC_ConfigMCO(MCO1_SOURCE);
#else
LL_RCC_ConfigMCO(MCO1_SOURCE,
mco1_prescaler(CONFIG_CLOCK_STM32_MCO1_DIV));
#endif
#endif /* CONFIG_CLOCK_STM32_MCO1_SRC_NOCLOCK */
#ifndef CONFIG_CLOCK_STM32_MCO2_SRC_NOCLOCK
LL_RCC_ConfigMCO(MCO2_SOURCE,
mco2_prescaler(CONFIG_CLOCK_STM32_MCO2_DIV));
#endif /* CONFIG_CLOCK_STM32_MCO2_SRC_NOCLOCK */
}
#ifdef __cplusplus
}
#endif
#endif /* ZEPHYR_DRIVERS_CLOCK_CONTROL_CLOCK_STM32_LL_MCO_H_ */

View file

@ -17,7 +17,7 @@
#include <zephyr/drivers/clock_control.h>
#include <zephyr/sys/util.h>
#include <zephyr/drivers/clock_control/stm32_clock_control.h>
#include "clock_stm32_ll_mco.h"
/* Macros to fill up prescaler values */
#define z_ahb_prescaler(v) LL_RCC_SYSCLK_DIV_ ## v
@ -904,9 +904,6 @@ int stm32_clock_control_init(const struct device *dev)
/* Update CMSIS variable */
SystemCoreClock = CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC;
/* configure MCO1/MCO2 based on Kconfig */
stm32_clock_control_mco_init();
return 0;
}