-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
feat(ext-power): Cut power when PM is sleeping #417
Conversation
a13ba95
to
07a550c
Compare
07a550c
to
19729e8
Compare
ea24617
to
d9cda27
Compare
d9cda27
to
49503eb
Compare
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.
This looks OK on the face of it, but I don't know this part of the system yet (and I can't test it), so I'm going to assign it to @petejohanson.
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.
Just one comment. Probably not needed yet, but when we get to turning devices to low power state due to user idle, we'll want the ability to switch power back on again.
switch (ctrl_command) { | ||
case DEVICE_PM_SET_POWER_STATE: | ||
if (*((uint32_t *)context) == DEVICE_PM_ACTIVE_STATE) { | ||
data->pm_state = DEVICE_PM_ACTIVE_STATE; |
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.
Shouldn't this also be calling ext_power_generic_enable
?
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.
Not in this case. When the device turns back on from sleep, the ext_power device is restarted and will automatically turn ext power back to its last saved state from settings. When we disable before going to sleep, that off state isn't saved in settings, so we'll properly retrieve the last state.
If we explicitly enabled here, people's power cut offs would turn back on whenever they wake up and get saved that way.
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.
My point is, when we add per-device power state management, we will want to cut/restore power state based on idle/active.
So we'll need an API for "on/off" that isn't state persisting. So we can call that from here.
Doesn't need to be this PR, so I'm going to approve for now.
We also need to consider that other devices may say "no, don't sleep now!" and abort the sleep state change, I believe.
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.
Approved, with the knowledge that this is a first step.
Thanks @Nicell!
static int ext_power_generic_pm_control(const struct device *dev, uint32_t ctrl_command, | ||
void *context, device_pm_cb cb, void *arg) { | ||
int rc; | ||
struct ext_power_generic_data *data = dev->driver_data; |
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.
This looks like the Zephyr 2.3.0 API. Was this tested with 2.4.0?
This adds support for cutting ext-power when the power management policy is set to low power using the central Zephyr device power management system.