Power Management APIs

Power Management Hook Interface

group power_management_hook_interface

Power Management Hook Interface.

Device Power Management APIs

group device_power_management_api

Device Power Management APIs.

Defines

DEVICE_PM_ACTIVE_STATE

device is in ACTIVE power state

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

DEVICE_PM_LOW_POWER_STATE

device is in LOW power state

Device context is preserved by the HW and need not be restored by the driver.

DEVICE_PM_SUSPEND_STATE

device is in SUSPEND power state

Most device context is lost by the hardware. Device drivers must save and restore or reinitialize any context lost by the hardware

DEVICE_PM_OFF_STATE

device is in OFF power 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_PM_SET_POWER_STATE
DEVICE_PM_GET_POWER_STATE

Functions

void device_busy_set(struct device *busy_dev)

Indicate that the device is in the middle of a transaction.

Called by a device driver to indicate that it is in the middle of a transaction.

Parameters
  • busy_dev: Pointer to device structure of the driver instance.

void device_busy_clear(struct device *busy_dev)

Indicate that the device has completed its transaction.

Called by a device driver to indicate the end of a transaction.

Parameters
  • busy_dev: Pointer to device structure of the driver instance.

int device_pm_control_nop(struct device *unused_device, u32_t unused_ctrl_command, void *unused_context)

No-op function to initialize unimplemented hook.

This function should be used to initialize device hook for which a device has no PM operations.

Parameters
  • unused_device: Unused
  • unused_ctrl_command: Unused
  • unused_context: Unused
Return Value
  • 0: Always returns 0

static int device_set_power_state(struct device *device, u32_t device_power_state)

Call the set power state function of a device.

Called by the application or power management service to let the device do required operations when moving to the required power state Note that devices may support just some of the device power states

Parameters
  • device: Pointer to device structure of the driver instance.
  • device_power_state: Device power state to be set
Return Value
  • 0: If successful.
  • Errno: Negative errno code if failure.

static int device_get_power_state(struct device *device, u32_t *device_power_state)

Call the get power state function of a device.

This function lets the caller know the current device power state at any time. This state will be one of the defined power states allowed for the devices in that system

Parameters
  • device: pointer to device structure of the driver instance.
  • device_power_state: Device power state to be filled by the device
Return Value
  • 0: If successful.
  • Errno: Negative errno code if failure.

void device_list_get(struct device **device_list, int *device_count)

Gets the device structure list array and device count.

Called by the Power Manager application to get the list of device structures associated with the devices in the system. The PM app would use this list to create its own sorted list based on the order it wishes to suspend or resume the devices.

Parameters
  • device_list: Pointer to receive the device list array
  • device_count: Pointer to receive the device count

int device_any_busy_check(void)

Check if any device is in the middle of a transaction.

Called by an application to see if any device is in the middle of a critical transaction that cannot be interrupted.

Return Value
  • 0: if no device is busy
  • -EBUSY: if any device is busy

int device_busy_check(struct device *chk_dev)

Check if a specific device is in the middle of a transaction.

Called by an application to see if a particular device is in the middle of a critical transaction that cannot be interrupted.

Parameters
  • chk_dev: Pointer to device structure of the specific device driver the caller is interested in.
Return Value
  • 0: if the device is not busy
  • -EBUSY: if the device is busy