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

drivers: clock_control: stm32h7: disable PLLs before configuration and guard for XIP #75655

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

GeorgeCGV
Copy link
Collaborator

@GeorgeCGV GeorgeCGV commented Jul 9, 2024

Extends #57337 to disable every PLL before configuration.
That allows an application to reconfigure PLLs after being configured by a bootloader.
At the same time, always disable PLLs to allow the bootloader to configure them after a restart.

However, we don't want to disable the PLL clock if it is used by (Q|O)SPI when
executing from external memory.

Fixes #75653 in a non-invasive way.

Overall. it is possible to implement complete clock reconfiguration of the
(Q|O)SPI when it runs from PLL(1|2) in XIP.

The RM0468 states that RCC OCTOSPISEL can be modified on the fly/at runtime.
However, there are other open questions. Will (Q|O)SPI configured for PLL (by a bootloader)
work with external memory in all cases with reduced frequency (when switched to HCLK for some time)?

Moreover, the drivers will need to reconfigure the peripheral. For example, the prescaler requires
aborting memory map mode during execution from it. That and other aspects (sfdp read) will require
some refactoring.

Disable every PLL before configuration. That allows
an application to reconfigure PLLs after a bootloader
configuration.

Don't disable the PLL clock if it is used by (Q|O)SPI
when executing from external memory. That will lead
to a stall.

Note: when (Q|O)SPI runs from PLL, the bootloader
dictates the clock configuration. There is no clock
reconfiguration support for memory map mode in
(Q|O)SPI drivers.

Signed-off-by: Georgij Cernysiov <geo.cgv@gmail.com>
@@ -766,7 +766,36 @@ static int set_up_plls(void)
stm32_clock_switch_to_hsi();
LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_1);
}

#if defined(CONFIG_STM32_MEMMAP) && defined(CONFIG_BOOTLOADER_MCUBOOT)
Copy link
Member

Choose a reason for hiding this comment

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

Non blocking: I wonder about the use of CONFIG_BOOTLOADER_MCUBOOT which restricts usage of this code to MCUBoot while code should be compatible with any other bootloader.

Copy link
Collaborator Author

@GeorgeCGV GeorgeCGV Sep 4, 2024

Choose a reason for hiding this comment

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

Agree, using CONFIG_BOOTLOADER_MCUBOOT to differentiate if the app runs by a bootloader is not very clean. That seems to be the only differentiation way as of now. The CONFIG_STM32_MEMMAP is set for both (bootloader and the application). Currently, there is only one supported bootloader.

Maybe it is worth introducing a more generic config? Something agnostic, like CONFIG_CHAINLOADED that could be y by default for BOOTLOADER_MCUBOOT?

drivers/clock_control/clock_stm32_ll_h7.c Show resolved Hide resolved
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.

drivers: clock_control: stm32h7: disabling PLL when executing in memory map mode leads to a stall
3 participants