Power Management APIs

Power Management Hook Interface

Device Power Management APIs

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