[RFC] Power Management Infrastructure

Rahamim, Hezi

Hi all,

Current state

In the current Zephyr implementation the driver power hooks distinguish only
between two driver states (suspend and resume). Drivers may have more than two
states (i.e. D-states) and can traverse between those states. The state change
today is limited only from active to suspend while there can be cases of other
transitions requested by the application.
Please look at the below suggested device power states E.g. transition between

Moreover, the current device state cannot be queried by an application or
a Power Manager service.

Below is the current Zephyr PM hooks:

struct device_pm_ops {
int (*suspend)(struct device *device, int pm_policy);
int (*resume)(struct device *device, int pm_policy);

Proposed changes

First proposed change is to have a set state and get state driver functions
instead of the suspend resume functions:

struct device_pm_ops {
int (*set_state)(struct device *device, int device_pm_policy);
int (*get_state)(struct device *device, int device_pm_policy);

The set_state function will behave according to the state transition of a specific
driver. E.g. transition from active state to suspend state in a UART device will
save device states and gate the clock.
The get_state function will enable the Power Manager service to know the state
of each driver thus enable it to configure the SoC power behavior.

Second proposed change is to add the below device power states:

Note: Many devices do not have all four power states defined.

Normal operation of the device. All device context is retained.

Device context is preserved by the HW and need not be restored by the driver.
The device do not allow the Power Manager service to power it down.

Most device context is lost by the hardware.
Device drivers must save and restore or reinitialize any context lost
by the hardware.
The device can be powered down.
The device is allowing a wake signal to send them to active state.

Power has been fully removed from the device. The device context is lost
when this state is entered, so the OS software will reinitialize the device
when powering it back on.
Device may not wake itself as the SoC need to reinitialize the device.

Comments/concerns welcome.

A member of the Intel Corporation group of companies

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.

Join devel@lists.zephyrproject.org to automatically receive all group messages.