-
Notifications
You must be signed in to change notification settings - Fork 7.6k
dts: bindings: Add st,reinit-power-states
DT property
#60369
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
Closed
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Copyright (c) 2023 Kenneth J. Miller <ken@miller.ec> | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
properties: | ||
st,reinit-power-states: | ||
type: phandles | ||
description: | | ||
Specifies special power states where a peripheral requires | ||
reinitialization due to configuration loss. | ||
|
||
While states at or beyond S2RAM are naturally assumed to need | ||
reinitialization, this property highlights the exceptions to that rule. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/* | ||
* Copyright (c) 2023 Kenneth J. Miller | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#ifndef ZEPHYR_INCLUDE_DEVICETREE_PM_STM32_H_ | ||
#define ZEPHYR_INCLUDE_DEVICETREE_PM_STM32_H_ | ||
|
||
#include <zephyr/pm/state.h> | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
/** | ||
* @brief Helper macro to initialize an entry of a struct pm_state_info array | ||
* when using UTIL_LISTIFY in PM_STATE_INFO_LIST_FROM_DT_REINIT. | ||
* | ||
* @note Only enabled states are initialized. | ||
* | ||
* @param i UTIL_LISTIFY entry index. | ||
* @param node_id A node identifier with compatible zephyr,power-state | ||
*/ | ||
#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)),), \ | ||
()) | ||
|
||
/** | ||
* @brief Initialize an array of struct pm_state_info with information from all | ||
* the states present and enabled in the given device node identifier. | ||
* | ||
* Example devicetree fragment: | ||
* | ||
* @code{.dts} | ||
* | ||
* cpus { | ||
* cpu0: cpu@0 { | ||
* device_type = "cpu"; | ||
* ... | ||
* cpu-power-states = <&state0 &state1>; | ||
* }; | ||
* | ||
* power-states { | ||
stop1: state1 { | ||
compatible = "zephyr,power-state"; | ||
power-state-name = "suspend-to-idle"; | ||
substate-id = <2>; | ||
... | ||
}; | ||
stop2: state2 { | ||
compatible = "zephyr,power-state"; | ||
power-state-name = "suspend-to-idle"; | ||
substate-id = <3>; | ||
... | ||
}; | ||
* }; | ||
* }; | ||
* | ||
* soc { | ||
* i2c1: i2c@50000000 { | ||
* ... | ||
* compatible = "st,stm32-i2c-v2"; | ||
* st,reinit-power-states = <&stop2>; | ||
* }; | ||
* }; | ||
* | ||
* @endcode | ||
* | ||
* Example usage: | ||
* | ||
* @code{.c} | ||
* const struct pm_state_info states[] = | ||
* PM_STATE_INFO_LIST_FROM_DT_REINIT(DT_NODELABEL(i2c1)); | ||
* @endcode | ||
* | ||
* @param node_id A device node identifier. | ||
*/ | ||
#define PM_STATE_INFO_LIST_FROM_DT_REINIT(node_id) \ | ||
{ \ | ||
LISTIFY(DT_PROP_LEN_OR(node_id, st_reinit_power_states, 0), \ | ||
Z_PM_STATE_INFO_FROM_DT_REINIT, (), node_id) \ | ||
} | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* ZEPHYR_INCLUDE_DEVICETREE_PM_STM32_H_ */ |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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 ?