Zephyr API Documentation 4.4.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches

Device Runtime Power Management API. More...

Functions

int pm_device_runtime_auto_enable (const struct device *dev)
 Automatically enable device runtime based on devicetree properties.
int pm_device_runtime_enable (const struct device *dev)
 Enable device runtime PM.
int pm_device_runtime_disable (const struct device *dev)
 Disable device runtime PM.
int pm_device_runtime_get (const struct device *dev)
 Resume a device based on usage count.
int pm_device_runtime_put (const struct device *dev)
 Suspend a device based on usage count.
int pm_device_runtime_put_async (const struct device *dev, k_timeout_t delay)
 Suspend a device based on usage count (asynchronously).
bool pm_device_runtime_is_enabled (const struct device *dev)
 Check if device runtime is enabled for a given device.
int pm_device_runtime_usage (const struct device *dev)
 Return the current device usage counter.

Detailed Description

Device Runtime Power Management API.

Function Documentation

◆ pm_device_runtime_auto_enable()

int pm_device_runtime_auto_enable ( const struct device * dev)

#include <zephyr/pm/device_runtime.h>

Automatically enable device runtime based on devicetree properties.

Note
Must not be called from application code. See the zephyr,pm-device-runtime-auto property in pm.yaml and z_sys_init_run_level.
Parameters
devDevice instance.
Returns
0 if the device runtime PM is enabled successfully or it has not been requested for this device in devicetree, negative errno value on failure.

◆ pm_device_runtime_disable()

int pm_device_runtime_disable ( const struct device * dev)
pre-kernel-ok

#include <zephyr/pm/device_runtime.h>

Disable device runtime PM.

If the device is currently suspended it will be resumed.

Parameters
devDevice instance.
Returns
0 on success, negative errno value on failure.
Return values
-ENOTSUPDevice does not support PM.

◆ pm_device_runtime_enable()

int pm_device_runtime_enable ( const struct device * dev)
pre-kernel-ok

#include <zephyr/pm/device_runtime.h>

Enable device runtime PM.

This function will enable runtime PM on the given device. If the device is in PM_DEVICE_STATE_ACTIVE state, the device will be suspended.

Parameters
devDevice instance.
Returns
0 on success, negative errno value on failure.
Return values
-EBUSYDevice is busy.
-ENOTSUPDevice does not support PM.
See also
pm_device_init_suspended()

◆ pm_device_runtime_get()

int pm_device_runtime_get ( const struct device * dev)
pre-kernel-ok

#include <zephyr/pm/device_runtime.h>

Resume a device based on usage count.

This function will resume the device if the device is suspended (usage count equal to 0). In case of a resume failure, usage count and device state will be left unchanged. In all other cases, usage count will be incremented.

If the device is still being suspended as a result of calling pm_device_runtime_put_async(), this function will wait for the operation to finish to then resume the device.

Note
It is safe to use this function in contexts where blocking is not allowed, e.g. ISR, provided the device PM implementation does not block.
Parameters
devDevice instance.
Returns
0 on success (including when runtime PM is not enabled or not available), negative errno value on failure.
Return values
-EWOULDBLOCKCall would block but it is not allowed (e.g. in ISR).

◆ pm_device_runtime_is_enabled()

bool pm_device_runtime_is_enabled ( const struct device * dev)
pre-kernel-ok

#include <zephyr/pm/device_runtime.h>

Check if device runtime is enabled for a given device.

Parameters
devDevice instance.
Return values
trueDevice has device runtime PM enabled.
falseDevice has device runtime PM disabled.
See also
pm_device_runtime_enable()

◆ pm_device_runtime_put()

int pm_device_runtime_put ( const struct device * dev)
pre-kernel-ok

#include <zephyr/pm/device_runtime.h>

Suspend a device based on usage count.

This function will suspend the device if the device is no longer required (usage count equal to 0). In case of suspend failure, usage count and device state will be left unchanged. In all other cases, usage count will be decremented (down to 0).

Parameters
devDevice instance.
Returns
0 on success (including when runtime PM is not enabled or not available), negative errno value on failure.
Return values
-EALREADYDevice is already suspended (can only happen if get/put calls are unbalanced).
See also
pm_device_runtime_put_async()

◆ pm_device_runtime_put_async()

int pm_device_runtime_put_async ( const struct device * dev,
k_timeout_t delay )
pre-kernel-okasyncisr-ok

#include <zephyr/pm/device_runtime.h>

Suspend a device based on usage count (asynchronously).

This function will schedule the device suspension if the device is no longer required (usage count equal to 0). In all other cases, usage count will be decremented (down to 0).

Note
Asynchronous operations are not supported when in pre-kernel mode. In this case, the function will be blocking (equivalent to pm_device_runtime_put()).
Parameters
devDevice instance.
delayMinimum amount of time before triggering the action.
Returns
0 on success (including when runtime PM is not enabled or not available), negative errno value on failure.
Return values
-EBUSYDevice is busy.
-EALREADYDevice is already suspended (can only happen if get/put calls are unbalanced).
See also
pm_device_runtime_put()

◆ pm_device_runtime_usage()

int pm_device_runtime_usage ( const struct device * dev)

#include <zephyr/pm/device_runtime.h>

Return the current device usage counter.

Parameters
devDevice instance.
Returns
The current usage counter.
Return values
-ENOTSUPDevice is not using runtime PM.
-ENOSYSRuntime PM is not enabled in this build (CONFIG_PM_DEVICE_RUNTIME is disabled).