Zephyr API Documentation  2.7.0-rc2
A Scalable Open Source RTOS
Device Power Management API

Device Power Management API. More...

Data Structures

struct  pm_device
 Device PM info. More...
 

Macros

#define device_pm_control_nop   __DEPRECATED_MACRO NULL
 

Typedefs

typedef int(* pm_device_control_callback_t) (const struct device *dev, enum pm_device_action action)
 Device power management control function callback. More...
 

Enumerations

enum  pm_device_state { PM_DEVICE_STATE_ACTIVE , PM_DEVICE_STATE_LOW_POWER , PM_DEVICE_STATE_SUSPENDED , PM_DEVICE_STATE_OFF }
 Device power states. More...
 
enum  pm_device_flag {
  PM_DEVICE_FLAG_BUSY , PM_DEVICE_FLAGS_WS_CAPABLE , PM_DEVICE_FLAGS_WS_ENABLED , PM_DEVICE_FLAG_TRANSITIONING ,
  PM_DEVICE_FLAG_COUNT
}
 Device PM flags. More...
 
enum  pm_device_action {
  PM_DEVICE_ACTION_SUSPEND , PM_DEVICE_ACTION_RESUME , PM_DEVICE_ACTION_TURN_OFF , PM_DEVICE_ACTION_FORCE_SUSPEND ,
  PM_DEVICE_ACTION_LOW_POWER
}
 Device PM actions. More...
 

Functions

const char * pm_device_state_str (enum pm_device_state state)
 Get name of device PM state. More...
 
int pm_device_state_set (const struct device *dev, enum pm_device_state state)
 Set the power state of a device. More...
 
int pm_device_state_get (const struct device *dev, enum pm_device_state *state)
 Obtain the power state of a device. More...
 
static void pm_device_busy_set (const struct device *dev)
 
static void pm_device_busy_clear (const struct device *dev)
 
static bool pm_device_is_any_busy (void)
 
static bool pm_device_is_busy (const struct device *dev)
 
static void device_busy_set (const struct device *dev)
 
static void device_busy_clear (const struct device *dev)
 
static int device_any_busy_check (void)
 
static int device_busy_check (const struct device *dev)
 
bool pm_device_wakeup_enable (struct device *dev, bool enable)
 Enable a power management wakeup source. More...
 
bool pm_device_wakeup_is_enabled (const struct device *dev)
 Check if a power management wakeup source is enabled. More...
 
bool pm_device_wakeup_is_capable (const struct device *dev)
 Check if a device is wake up capable. More...
 

Detailed Description

Device Power Management API.

Macro Definition Documentation

◆ device_pm_control_nop

#define device_pm_control_nop   __DEPRECATED_MACRO NULL

#include <include/pm/device.h>

Alias for legacy use of device_pm_control_nop

Typedef Documentation

◆ pm_device_control_callback_t

typedef int(* pm_device_control_callback_t) (const struct device *dev, enum pm_device_action action)

#include <include/pm/device.h>

Device power management control function callback.

Parameters
devDevice instance.
actionRequested action.
Return values
0If successful.
-ENOTSUPIf the requested action is not supported.
ErrnoOther negative errno on failure.

Enumeration Type Documentation

◆ pm_device_action

#include <include/pm/device.h>

Device PM actions.

Enumerator
PM_DEVICE_ACTION_SUSPEND 

Suspend.

PM_DEVICE_ACTION_RESUME 

Resume.

PM_DEVICE_ACTION_TURN_OFF 

Turn off.

PM_DEVICE_ACTION_FORCE_SUSPEND 

Force suspend.

PM_DEVICE_ACTION_LOW_POWER 

Low power.

◆ pm_device_flag

#include <include/pm/device.h>

Device PM flags.

Enumerator
PM_DEVICE_FLAG_BUSY 

Indicate if the device is busy or not.

PM_DEVICE_FLAGS_WS_CAPABLE 

Indicates whether or not the device is capable of waking the system up.

PM_DEVICE_FLAGS_WS_ENABLED 

Indicates if the device is being used as wakeup source.

PM_DEVICE_FLAG_TRANSITIONING 

Indicates that the device is changing its state

PM_DEVICE_FLAG_COUNT 

Number of flags (internal use only).

◆ pm_device_state

#include <include/pm/device.h>

Device power states.

Enumerator
PM_DEVICE_STATE_ACTIVE 

Device is in active or regular state.

PM_DEVICE_STATE_LOW_POWER 

Device is in low power state.

Note
Device context is preserved.
PM_DEVICE_STATE_SUSPENDED 

Device is suspended.

Note
Device context may be lost.
PM_DEVICE_STATE_OFF 

Device is turned off (power removed).

Note
Device context is lost.

Function Documentation

◆ device_any_busy_check()

static int device_any_busy_check ( void  )
inlinestatic

#include <include/pm/device.h>

◆ device_busy_check()

static int device_busy_check ( const struct device dev)
inlinestatic

#include <include/pm/device.h>

◆ device_busy_clear()

static void device_busy_clear ( const struct device dev)
inlinestatic

#include <include/pm/device.h>

◆ device_busy_set()

static void device_busy_set ( const struct device dev)
inlinestatic

#include <include/pm/device.h>

◆ pm_device_busy_clear()

static void pm_device_busy_clear ( const struct device dev)
inlinestatic

#include <include/pm/device.h>

◆ pm_device_busy_set()

static void pm_device_busy_set ( const struct device dev)
inlinestatic

#include <include/pm/device.h>

◆ pm_device_is_any_busy()

static bool pm_device_is_any_busy ( void  )
inlinestatic

#include <include/pm/device.h>

◆ pm_device_is_busy()

static bool pm_device_is_busy ( const struct device dev)
inlinestatic

#include <include/pm/device.h>

◆ pm_device_state_get()

int pm_device_state_get ( const struct device dev,
enum pm_device_state state 
)

#include <include/pm/device.h>

Obtain the power state of a device.

Parameters
devDevice instance.
statePointer where device power state will be stored.
Return values
0If successful.
-ENOSYSIf device does not implement power management.

◆ pm_device_state_set()

int pm_device_state_set ( const struct device dev,
enum pm_device_state  state 
)

#include <include/pm/device.h>

Set the power state of a device.

This function calls the device PM control callback so that the device does the necessary operations to put the device into the given state.

Note
Some devices may not support all device power states.
Parameters
devDevice instance.
stateDevice power state to be set.
Return values
0If successful.
-ENOTSUPIf requested state is not supported.
-EALREADYIf device is already at the requested state.
-EBUSYIf device is changing its state.
ErrnoOther negative errno on failure.

◆ pm_device_state_str()

const char * pm_device_state_str ( enum pm_device_state  state)

#include <include/pm/device.h>

Get name of device PM state.

Parameters
stateState id which name should be returned

◆ pm_device_wakeup_enable()

bool pm_device_wakeup_enable ( struct device dev,
bool  enable 
)

#include <include/pm/device.h>

Enable a power management wakeup source.

Enable a wakeup source. This will keep the current device active when the system is suspended, allowing it to be used to wake up the system.

Parameters
devdevice object to enable.
enabletrue to enable or false to disable
Return values
trueif the wakeup source was successfully enabled.
falseif the wakeup source was not successfully enabled.

◆ pm_device_wakeup_is_capable()

bool pm_device_wakeup_is_capable ( const struct device dev)

#include <include/pm/device.h>

Check if a device is wake up capable.

Parameters
devdevice object to check.
Return values
trueif the device is wake up capable.
falseif the device is not wake up capable.

◆ pm_device_wakeup_is_enabled()

bool pm_device_wakeup_is_enabled ( const struct device dev)

#include <include/pm/device.h>

Check if a power management wakeup source is enabled.

Checks if a wake up source is enabled.

Parameters
devdevice object to check.
Return values
trueif the wakeup source is enabled.
falseif the wakeup source is not enabled.