Skip to content

clock_control: stm32: mp13: add plls / mco & clock source selection #89773

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

Merged

Conversation

avolmat-st
Copy link
Collaborator

This PR adds support for PLL2 / PLL3 / PLL4 of the stm32mp13 as well as MCO1 and MCO2.

Peripheral clock selection code is as well added.

This work is done in order to allow usage of the DCMIPP (camera pipeline) PR #89407 / ST-MIPID02 PR #89764 on the stm32mp135f-dk board.

@avolmat-st avolmat-st force-pushed the stm32mp13_clocks_mco_plls branch from 0009e12 to 01af9d7 Compare May 12, 2025 10:32
@erwango erwango requested a review from arnopo May 12, 2025 12:19
erwango
erwango previously approved these changes May 12, 2025
Copy link
Collaborator

@etienne-lms etienne-lms left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with a minor question.

Copy link
Collaborator

@arnopo arnopo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor comments else LGTM

@@ -49,6 +49,11 @@ static int stm32_mco_init(const struct device *dev)
STM32_DT_CLKSEL_VAL_GET(pclken->enr) <<
STM32_DT_CLKSEL_SHIFT_GET(pclken->enr));

#if defined(MCO_ENABLE_BIT)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpicking
what about naming it MCOX_ON as it is referenced as MCO1ON/MCO2ON in data sheet

@@ -28,6 +28,13 @@ description: |
than 1000 MHz or program the mpuss_ck mux to use the MPUDIV
(refer to the stm32mp13 reference manual for details)

div-m, div-p, div-q, div-r valid ranges are identicals for all 4 PLLs
mul-n valid range depends on the PLL
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would use here the Name defined in stm32mp13 reference manual but also in formula above

DIVM1, DIVP, DIVQ and DIVR have identical valid ranges for all 4 PLLs.
DIVN valid range depends on the PLL

or use aka as below

div-m (aka DIVM1) , div-p (aka DIVP), div-q (aka DIVQ), div-r (aka DIVR)  have identical valid ranges for all 4 PLLs.
mul-n (aka DIVN) valid range depends on the PLL

On STM32MP13, a dedicated MCO enable bit within the MCO clock control
register must be set in order to activate the MCO.

Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
arnopo
arnopo previously approved these changes May 13, 2025

ARG_UNUSED(dev);

if (IN_RANGE(pclken->bus, STM32_PERIPH_BUS_MIN, STM32_PERIPH_BUS_MAX) == true) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpicking; if (IN_RANGE(pclken->bus, STM32_PERIPH_BUS_MIN, STM32_PERIPH_BUS_MAX)) is enough.

Alain Volmat added 3 commits May 13, 2025 16:24
Depending on the PLL, all DIV-P / DIV-Q and DIV-R are available
on STM32MP13 PLLs.
Adjust valid range in order to be able to set for all 4 PLLs.
Clarify DT properties description.

Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
Rename the frac-v PLL binding into fracn in order to make it
consistent with other STM32 PLL bindings.
This commit also correct the range which should be 0 - 8191.

Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
Add enabled_clock, on / off and configure support for the clocks of
the stm32mp13. Describes the peripheral clock source selection.

Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
The stm32mp13 has 2 MCOs and 4 PLLs available.

Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
@avolmat-st avolmat-st force-pushed the stm32mp13_clocks_mco_plls branch from e7d38d9 to 0c15d85 Compare May 13, 2025 14:24
Copy link

@erwango erwango assigned erwango and unassigned nordic-krch May 14, 2025
@fabiobaltieri fabiobaltieri merged commit cc83728 into zephyrproject-rtos:main May 14, 2025
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants