-
Notifications
You must be signed in to change notification settings - Fork 7.6k
drivers: clock_control: stm32h7: disable PLLs before configuration and guard for XIP #75655
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
Conversation
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>
f7e8301
to
fe0fcf5
Compare
@@ -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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it is worth introducing a more generic config? Something agnostic, like CONFIG_CHAINLOADED that could be y by default for BOOTLOADER_MCUBOOT
Indeed, I wonder why this isn't already available
This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time. |
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.