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

dts: bindings: Add st,reinit-power-states DT property #60369

Closed
wants to merge 3 commits into from

Conversation

knthm
Copy link
Collaborator

@knthm knthm commented Jul 13, 2023

Summary

This PR adds the st,reinit-power-states DT binding property.
Said property is intended to describe exceptional System PM (sub)states, after which the defining peripheral instance requires reinitialization logic to regain normal operation.

Note: all states below and including S2RAM are expected to require driver action to restore operation, and these are not the target of this PR, but rather exceptions to the rule such as the S2idle state STOP2 on STM32WL.

A helper macro for building a pm_state_info struct array of these power-states, for various handling of critical driver sections is also included.

Related

@knthm knthm removed area: I2C area: UART Universal Asynchronous Receiver-Transmitter area: Crypto / RNG labels Sep 7, 2023
@knthm knthm requested a review from erwango September 7, 2023 08:09
@knthm
Copy link
Collaborator Author

knthm commented Sep 7, 2023

@gmarull I've made this binding ST-specific. However the helper macros are still in state.h, I'm not sure it feels right to keep them there, even with a ST-specfic name. Do you have any suggestions for location where they can easily be used by the various different STM32 drivers?

include/zephyr/pm/state.h Outdated Show resolved Hide resolved
@gmarull gmarull dismissed their stale review September 19, 2023 07:56

no longer reviewing PM related code

Copy link
Member

@erwango erwango left a comment

Choose a reason for hiding this comment

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

LGTM aside from the file used for headers.

Add STM32-specific st,reinit-power-states property.

This property allows defining one or more special power-states phandles
in which a peripheral loses its configuration, and must be reinitialized.

States below and including S2RAM are inherently assumed to require
reinit, this property is intended to cover the exceptions outside
of this common use case.

It is intended to assist drivers in preventing the SoC from entering
these power states during critical code sections, as well as indicate
to power management services when a peripheral needs reinitialization.

Signed-off-by: Kenneth J. Miller <ken@miller.ec>
Add common STM32 power-management bindings to peripherals that require
the st,reinit-power-states property.

Signed-off-by: Kenneth J. Miller <ken@miller.ec>
Add helper macros for building a pm_state_info array from a device's
st,reinit-power-states.

These macros are intended to assist drivers in and around device
reinitializiation.

Signed-off-by: Kenneth J. Miller <ken@miller.ec>
@knthm
Copy link
Collaborator Author

knthm commented Sep 26, 2023

  • Rebase on main
  • Move now STM32-specific helper macros to include/zephyr/devicetree/pm_stm32.h

@knthm knthm requested a review from erwango September 26, 2023 12:30
Comment on lines +25 to +29
#define Z_PM_STATE_INFO_FROM_DT_REINIT(i, node_id) \
COND_CODE_1( \
DT_NODE_HAS_STATUS(DT_PHANDLE_BY_IDX(node_id, st_reinit_power_states, i), okay), \
(PM_STATE_INFO_DT_INIT(DT_PHANDLE_BY_IDX(node_id, st_reinit_power_states, i)),), \
())
Copy link
Member

Choose a reason for hiding this comment

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

I know this isn't exactly your current concern, but as we discussed, for 90-ish % of cases, reinit-power-state will be standby.
I wonder where we'll be able to get it taken into account:
I don't think this should be added in each peripheral driver since we'll just be duplicating information
Should/Could it be done directly in current macro ?

@tmleman
Copy link
Collaborator

tmleman commented Nov 14, 2023

Why can't you use in this case PM_DEVICE_RUNTIME?

@knthm
Copy link
Collaborator Author

knthm commented Nov 14, 2023

@tmleman
PM_DEVICE_RUNTIME actions aren't coupled to system PM events, except in very specific configurations. Also, on STM32 reinitialization needs to happen in a very specific point of SoC wakeup.
Please see the other linked PRs, they provide a clear case of why this is necessary and not covered by current PM functionality.

@knthm knthm removed area: I2C area: UART Universal Asynchronous Receiver-Transmitter area: Crypto / RNG labels Nov 14, 2023
Copy link

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.

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.

8 participants