Zephyr API Documentation  3.0.0
A Scalable Open Source RTOS
3.0.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
device_runtime.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2015 Intel Corporation.
3 * Copyright (c) 2021 Nordic Semiconductor ASA
4 *
5 * SPDX-License-Identifier: Apache-2.0
6 */
7
8#ifndef ZEPHYR_INCLUDE_PM_DEVICE_RUNTIME_H_
9#define ZEPHYR_INCLUDE_PM_DEVICE_RUNTIME_H_
10
11#include <device.h>
12
13#ifdef __cplusplus
14extern "C" {
15#endif
16
24#if defined(CONFIG_PM_DEVICE_RUNTIME) || defined(__DOXYGEN__)
42int pm_device_runtime_enable(const struct device *dev);
43
57int pm_device_runtime_disable(const struct device *dev);
58
78int pm_device_runtime_get(const struct device *dev);
79
100int pm_device_runtime_put(const struct device *dev);
101
124int pm_device_runtime_put_async(const struct device *dev);
125
138bool pm_device_runtime_is_enabled(const struct device *dev);
139
152static inline void pm_device_runtime_init_suspended(const struct device *dev)
153{
154 struct pm_device *pm = dev->pm;
155
157}
158
170static inline void pm_device_runtime_init_off(const struct device *dev)
171{
172 struct pm_device *pm = dev->pm;
173
175}
176
177#else
178static inline int pm_device_runtime_enable(const struct device *dev) { return -ENOSYS; }
179static inline int pm_device_runtime_disable(const struct device *dev) { return -ENOSYS; }
180static inline int pm_device_runtime_get(const struct device *dev) { return 0; }
181static inline int pm_device_runtime_put(const struct device *dev) { return 0; }
182static inline int pm_device_runtime_put_async(const struct device *dev) { return 0; }
183static inline bool pm_device_runtime_is_enabled(const struct device *dev) { return false; }
184static inline void pm_device_runtime_init_suspended(const struct device *dev) { }
185static inline void pm_device_runtime_init_off(const struct device *dev) { }
186#endif
187
190#ifdef __cplusplus
191}
192#endif
193
194#endif /* ZEPHYR_INCLUDE_PM_DEVICE_RUNTIME_H_ */
int pm_device_runtime_get(const struct device *dev)
Resume a device based on usage count.
bool pm_device_runtime_is_enabled(const struct device *dev)
Check if device runtime is enabled for a given device.
static void pm_device_runtime_init_off(const struct device *dev)
Initialize a device state to PM_DEVICE_STATE_OFF.
Definition: device_runtime.h:170
int pm_device_runtime_put(const struct device *dev)
Suspend a device based on usage count.
int pm_device_runtime_disable(const struct device *dev)
Disable device runtime PM.
int pm_device_runtime_enable(const struct device *dev)
Enable device runtime PM.
int pm_device_runtime_put_async(const struct device *dev)
Suspend a device based on usage count (asynchronously).
static void pm_device_runtime_init_suspended(const struct device *dev)
Initialize a device state to PM_DEVICE_STATE_SUSPENDED.
Definition: device_runtime.h:152
@ PM_DEVICE_STATE_SUSPENDED
Definition: device.h:58
@ PM_DEVICE_STATE_OFF
Definition: device.h:67
#define ENOSYS
Definition: errno.h:83
Runtime device structure (in ROM) per driver instance.
Definition: device.h:450
struct device_state *const state
Definition: device.h:458