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

Cortex-M SysTick: extend support for low-power mode features #84102

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

mathieuchopstm
Copy link
Collaborator

This PR aims to improve several aspects of the Cortex-M SysTick driver related to low-power mode/PM, mainly for support of Deepstop LPM on STM32WB0 series.

The existing implementation supports a companion "IDLE timer", but it must implement the Counter API, which can be a poor fit depending on the hardware. However, the only things the SysTick drivers requests from the companion time is:

  1. to wake up the SoC after at most a specified timeout elapses
  2. measuring how much time elapsed while SysTick was inactive

This PR implements a simple ("hook-based") API that the SysTick driver can use to perform these two functions in place of the Counter API timer, which is useful when the platform-specific timer is a poor fit for the Counter API.

Another limitation of the driver is that it expects SysTick to remain powered in low-power modes, which is not true on some SoCs. This PR creates a new Kconfig symbol which, if selected, modifies the SysTick driver such that it stops the counter cleanly before low-power mode entry, and restarts it after low-power mode exit.

This PR is a proposal, hence the DNM label - I don't think the changes are large enough to warrant the RFC label. Comments are nonetheless welcome and highly appreciated 😄

@mathieuchopstm mathieuchopstm added the DNM This PR should not be merged (Do Not Merge) label Jan 16, 2025
@zephyrbot zephyrbot added the area: Timer Timer label Jan 16, 2025
@zephyrbot zephyrbot requested review from andyross and teburd January 16, 2025 15:53
The Cortex-M SysTick supported collaboration with a so-called "IDLE timer"
to work even in low-power modes, when the SoC may disable its clock.

Rename "IDLE timer" to "low-power mode timer" to better reflect what this
timer is used for, and transform the single option into a Kconfig choice
to allow other behaviors to be implemented and chosen.

Signed-off-by: Mathieu Choplain <[email protected]>
Add support for a hook-based low-power mode timer to the Cortex-M SysTick
driver, in addition to the existing Counter API-based timer. This is useful
on platforms such as the STM32WB0 where the wake-up timer is too limited
for a Counter API driver to be implemented on top of it.

Signed-off-by: Mathieu Choplain <[email protected]>
…mode

Modify the Cortex-M SysTick driver to work when the SoC resets SysTick
in low-power mode. This adds an invisible Kconfig symbol that must be
selected by SoCs with such behavior.

Signed-off-by: Mathieu Choplain <[email protected]>
@mathieuchopstm mathieuchopstm force-pushed the systick_lpm_improvements branch from b398cdf to e080448 Compare January 17, 2025 09:54
Copy link
Collaborator

Choose a reason for hiding this comment

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

LPTIM is an STM32-specific name, should be replaced by Low Power Timer.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

As defined in the comment, LPTIM is used here as an acronym, not as reference to the STM32-specific hardware (WB0 doesn't even have it). I'm fine with changing to LPtim / LPMTIM / <your proposal here> to avoid confusion though.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes I think it should be changed in order to avoid confusion.

@mathieuchopstm
Copy link
Collaborator Author

For the record, the commits of this PR are used on https://github.com/mathieuchopstm/zephyr/tree/wb0_deepstop_poc to implement Deepstop suspend-to-RAM low-power mode on STM32WB0 series.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Timer Timer DNM This PR should not be merged (Do Not Merge)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants