Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clock_control: stm32: Configure MCO through devicetree instead of Kconfig #76556

Merged
merged 14 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions doc/releases/release-notes-4.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ Boards & SoC Support
* :ref:`native_posix<native_posix>` has been deprecated in favour of
:ref:`native_sim<native_sim>`.
* Support for Google Kukui EC board (``google_kukui``) has been dropped.
* STM32: Deprecated MCO configuration via Kconfig in favour of setting it through devicetree.
See ``samples/boards/stm32/mco`` sample.

* Added support for the following shields:

Expand Down
1 change: 1 addition & 0 deletions drivers/clock_control/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ endif()

if(CONFIG_CLOCK_CONTROL_STM32_CUBE)
zephyr_library_sources_ifdef(CONFIG_CLOCK_STM32_MUX clock_stm32_mux.c)
zephyr_library_sources_ifdef(CONFIG_CLOCK_STM32_MCO clock_stm32_mco.c)
if(CONFIG_SOC_SERIES_STM32MP1X)
zephyr_library_sources(clock_stm32_ll_mp1.c)
elseif(CONFIG_SOC_SERIES_STM32H7X)
Expand Down
61 changes: 60 additions & 1 deletion drivers/clock_control/Kconfig.stm32
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,14 @@ config STM32WB0_LSI_RUNTIME_MEASUREMENT_INTERVAL

endmenu # DT_HAS_ST_STM32WB0_LSI_CLOCK_ENABLED

# Micro-controller Clock output configuration options
# Micro-controller Clock Output (MCO) configuration options
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"
Expand All @@ -106,8 +113,10 @@ config CLOCK_STM32_MCO1_SRC_NOCLOCK
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
erwango marked this conversation as resolved.
Show resolved Hide resolved
bool "LSE"
Expand All @@ -118,8 +127,10 @@ config CLOCK_STM32_MCO1_SRC_LSE
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"
Expand All @@ -131,33 +142,43 @@ config CLOCK_STM32_MCO1_SRC_HSE
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"
Expand All @@ -167,15 +188,19 @@ config CLOCK_STM32_MCO1_SRC_HSI
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"
Expand All @@ -184,57 +209,74 @@ config CLOCK_STM32_MCO1_SRC_HSI48
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
Expand All @@ -254,6 +296,7 @@ config CLOCK_STM32_MCO1_DIV
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"
Expand All @@ -271,14 +314,18 @@ config CLOCK_STM32_MCO2_SRC_SYSCLK
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"
Expand All @@ -287,8 +334,10 @@ config CLOCK_STM32_MCO2_SRC_HSE
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"
Expand All @@ -297,36 +346,46 @@ config CLOCK_STM32_MCO2_SRC_LSI
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
Expand Down
24 changes: 22 additions & 2 deletions drivers/clock_control/clock_stm32_ll_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,7 @@ static uint32_t get_msi_frequency(void)
}

/** @brief Verifies clock is part of active clock configuration */
__unused
static int enabled_clock(uint32_t src_clk)
int enabled_clock(uint32_t src_clk)
{
int r = 0;

Expand All @@ -134,6 +133,13 @@ static int enabled_clock(uint32_t src_clk)
}
break;
#endif /* STM32_SRC_HSE */
#if defined(STM32_SRC_EXT_HSE)
mathieuchopstm marked this conversation as resolved.
Show resolved Hide resolved
case STM32_SRC_EXT_HSE:
/* EXT_HSE is the raw OSC_IN signal, so it is always
* available, regardless of the clocks configuration.
*/
break;
#endif /* STM32_SRC_HSE */
#if defined(STM32_SRC_HSI)
case STM32_SRC_HSI:
if (!IS_ENABLED(STM32_HSI_ENABLED)) {
Expand Down Expand Up @@ -211,6 +217,20 @@ static int enabled_clock(uint32_t src_clk)
}
break;
#endif /* STM32_SRC_PLLI2S_R */
#if defined(STM32_SRC_PLL2CLK)
case STM32_SRC_PLL2CLK:
if (!IS_ENABLED(STM32_PLL2_ENABLED)) {
r = -ENOTSUP;
}
break;
#endif
#if defined(STM32_SRC_PLL3CLK)
case STM32_SRC_PLL3CLK:
if (!IS_ENABLED(STM32_PLL3_ENABLED)) {
r = -ENOTSUP;
}
break;
#endif
default:
return -ENOTSUP;
}
Expand Down
1 change: 1 addition & 0 deletions drivers/clock_control/clock_stm32_ll_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ void config_plli2s(void);
#endif
void config_enable_default_clocks(void);
void config_regulator_voltage(uint32_t hclk_freq);
int enabled_clock(uint32_t src_clk);

/* functions exported to the soc power.c */
int stm32_clock_control_init(const struct device *dev);
Expand Down
2 changes: 1 addition & 1 deletion drivers/clock_control/clock_stm32_ll_h5.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ static uint32_t get_sysclk_frequency(void)
}

/** @brief Verifies clock is part of active clock configuration */
static int enabled_clock(uint32_t src_clk)
int enabled_clock(uint32_t src_clk)
{
if ((src_clk == STM32_SRC_SYSCLK) ||
((src_clk == STM32_SRC_HSE) && IS_ENABLED(STM32_HSE_ENABLED)) ||
Expand Down
2 changes: 1 addition & 1 deletion drivers/clock_control/clock_stm32_ll_h7.c
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ static uint32_t get_vco_output_range(uint32_t vco_input_range)
#endif /* ! CONFIG_CPU_CORTEX_M4 */

/** @brief Verifies clock is part of active clock configuration */
static int enabled_clock(uint32_t src_clk)
int enabled_clock(uint32_t src_clk)
{

if ((src_clk == STM32_SRC_SYSCLK) ||
Expand Down
2 changes: 1 addition & 1 deletion drivers/clock_control/clock_stm32_ll_u5.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ static uint32_t get_sysclk_frequency(void)
}

/** @brief Verifies clock is part of active clock configuration */
static int enabled_clock(uint32_t src_clk)
int enabled_clock(uint32_t src_clk)
{
if ((src_clk == STM32_SRC_SYSCLK) ||
((src_clk == STM32_SRC_HSE) && IS_ENABLED(STM32_HSE_ENABLED)) ||
Expand Down
3 changes: 1 addition & 2 deletions drivers/clock_control/clock_stm32_ll_wba.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ static uint32_t get_bus_clock(uint32_t clock, uint32_t prescaler)
}

/** @brief Verifies clock is part of active clock configuration */
__unused
static int enabled_clock(uint32_t src_clk)
int enabled_clock(uint32_t src_clk)
{
if ((src_clk == STM32_SRC_SYSCLK) ||
((src_clk == STM32_SRC_HSE) && IS_ENABLED(STM32_HSE_ENABLED)) ||
Expand Down
Loading
Loading