2021-04-29 13:32:28 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2015 Intel Corporation.
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef ZEPHYR_INCLUDE_PM_DEVICE_H_
|
|
|
|
#define ZEPHYR_INCLUDE_PM_DEVICE_H_
|
|
|
|
|
|
|
|
#include <kernel.h>
|
|
|
|
#include <sys/atomic.h>
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Device Power Management API
|
2021-10-29 11:10:49 +02:00
|
|
|
* @defgroup subsys_pm_device Device
|
|
|
|
* @ingroup subsys_pm
|
2021-04-29 13:32:28 +02:00
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2021-10-29 11:48:33 +02:00
|
|
|
/** @cond INTERNAL_HIDDEN */
|
|
|
|
|
2021-04-29 13:32:28 +02:00
|
|
|
struct device;
|
|
|
|
|
2021-10-29 11:48:33 +02:00
|
|
|
/** @brief Device PM flags. */
|
|
|
|
enum pm_device_flag {
|
|
|
|
/** Indicate if the device is busy or not. */
|
|
|
|
PM_DEVICE_FLAG_BUSY,
|
|
|
|
/**
|
|
|
|
* Indicates whether or not the device is capable of waking the system
|
|
|
|
* up.
|
|
|
|
*/
|
|
|
|
PM_DEVICE_FLAG_WS_CAPABLE,
|
|
|
|
/** Indicates if the device is being used as wakeup source. */
|
|
|
|
PM_DEVICE_FLAG_WS_ENABLED,
|
|
|
|
};
|
|
|
|
|
|
|
|
/** @endcond */
|
|
|
|
|
2021-06-03 19:06:53 +02:00
|
|
|
/** @brief Device power states. */
|
|
|
|
enum pm_device_state {
|
|
|
|
/** Device is in active or regular state. */
|
|
|
|
PM_DEVICE_STATE_ACTIVE,
|
|
|
|
/**
|
|
|
|
* Device is suspended.
|
|
|
|
*
|
|
|
|
* @note
|
|
|
|
* Device context may be lost.
|
|
|
|
*/
|
2021-07-02 18:09:07 +02:00
|
|
|
PM_DEVICE_STATE_SUSPENDED,
|
2021-10-21 18:35:38 +02:00
|
|
|
/** Device is being suspended. */
|
|
|
|
PM_DEVICE_STATE_SUSPENDING,
|
2021-06-03 19:06:53 +02:00
|
|
|
/**
|
|
|
|
* Device is turned off (power removed).
|
|
|
|
*
|
|
|
|
* @note
|
|
|
|
* Device context is lost.
|
|
|
|
*/
|
2021-08-26 22:44:58 -07:00
|
|
|
PM_DEVICE_STATE_OFF
|
2021-06-03 19:06:53 +02:00
|
|
|
};
|
2021-04-28 09:48:52 -07:00
|
|
|
|
2021-07-05 15:13:40 +02:00
|
|
|
/** @brief Device PM actions. */
|
|
|
|
enum pm_device_action {
|
|
|
|
/** Suspend. */
|
|
|
|
PM_DEVICE_ACTION_SUSPEND,
|
|
|
|
/** Resume. */
|
|
|
|
PM_DEVICE_ACTION_RESUME,
|
|
|
|
/** Turn off. */
|
|
|
|
PM_DEVICE_ACTION_TURN_OFF,
|
2021-08-02 10:30:44 +02:00
|
|
|
/** Force suspend. */
|
|
|
|
PM_DEVICE_ACTION_FORCE_SUSPEND,
|
2021-07-05 15:13:40 +02:00
|
|
|
};
|
|
|
|
|
2021-10-29 16:07:22 +02:00
|
|
|
/** @cond INTERNAL_HIDDEN */
|
|
|
|
|
2021-10-13 16:18:47 +02:00
|
|
|
/**
|
2021-10-13 16:38:42 +02:00
|
|
|
* @brief Device PM action callback.
|
2021-10-13 16:18:47 +02:00
|
|
|
*
|
|
|
|
* @param dev Device instance.
|
|
|
|
* @param action Requested action.
|
|
|
|
*
|
|
|
|
* @retval 0 If successful.
|
|
|
|
* @retval -ENOTSUP If the requested action is not supported.
|
|
|
|
* @retval Errno Other negative errno on failure.
|
|
|
|
*/
|
2021-10-13 16:38:42 +02:00
|
|
|
typedef int (*pm_device_action_cb_t)(const struct device *dev,
|
|
|
|
enum pm_device_action action);
|
2021-10-13 16:18:47 +02:00
|
|
|
|
2021-04-29 13:32:28 +02:00
|
|
|
/**
|
|
|
|
* @brief Device PM info
|
|
|
|
*/
|
2021-05-03 17:42:31 +02:00
|
|
|
struct pm_device {
|
2021-10-29 11:10:49 +02:00
|
|
|
#if defined(CONFIG_PM_DEVICE_RUNTIME) || defined(__DOXYGEN__)
|
2021-04-29 13:32:28 +02:00
|
|
|
/** Pointer to the device */
|
|
|
|
const struct device *dev;
|
|
|
|
/** Lock to synchronize the get/put operations */
|
2021-05-20 14:47:04 -07:00
|
|
|
struct k_mutex lock;
|
2021-04-29 13:32:28 +02:00
|
|
|
/** Device pm enable flag */
|
|
|
|
bool enable : 1;
|
|
|
|
/** Device usage count */
|
2021-05-14 16:50:23 -07:00
|
|
|
uint32_t usage;
|
2021-04-29 13:32:28 +02:00
|
|
|
/** Work object for asynchronous calls */
|
2021-04-26 22:37:42 -07:00
|
|
|
struct k_work_delayable work;
|
|
|
|
/** Event conditional var to listen to the sync request events */
|
|
|
|
struct k_condvar condvar;
|
2021-10-06 23:56:37 -07:00
|
|
|
#endif /* CONFIG_PM_DEVICE_RUNTIME */
|
|
|
|
/* Device PM status flags. */
|
|
|
|
atomic_t flags;
|
|
|
|
/** Device power state */
|
|
|
|
enum pm_device_state state;
|
2021-10-13 16:38:42 +02:00
|
|
|
/** Device PM action callback */
|
|
|
|
pm_device_action_cb_t action_cb;
|
2021-04-29 13:32:28 +02:00
|
|
|
};
|
|
|
|
|
2021-10-06 23:56:37 -07:00
|
|
|
#ifdef CONFIG_PM_DEVICE_RUNTIME
|
2021-11-02 17:34:57 +01:00
|
|
|
#define Z_PM_DEVICE_RUNTIME_INIT(obj) \
|
2021-10-06 23:56:37 -07:00
|
|
|
.lock = Z_MUTEX_INITIALIZER(obj.lock), \
|
|
|
|
.condvar = Z_CONDVAR_INITIALIZER(obj.condvar),
|
|
|
|
#else
|
2021-11-02 17:34:57 +01:00
|
|
|
#define Z_PM_DEVICE_RUNTIME_INIT(obj)
|
2021-10-06 23:56:37 -07:00
|
|
|
#endif /* CONFIG_PM_DEVICE_RUNTIME */
|
|
|
|
|
2021-08-26 17:26:31 +02:00
|
|
|
/**
|
|
|
|
* @brief Utility macro to initialize #pm_device.
|
|
|
|
*
|
2021-10-29 16:07:22 +02:00
|
|
|
* @note #DT_PROP_OR is used to retrieve the wakeup_source property because
|
2021-08-26 17:26:31 +02:00
|
|
|
* it may not be defined on all devices.
|
|
|
|
*
|
|
|
|
* @param obj Name of the #pm_device structure being initialized.
|
|
|
|
* @param node_id Devicetree node for the initialized device (can be invalid).
|
2021-10-13 16:38:42 +02:00
|
|
|
* @param pm_action_cb Device PM control callback function.
|
2021-08-26 17:26:31 +02:00
|
|
|
*/
|
2021-10-13 16:38:42 +02:00
|
|
|
#define Z_PM_DEVICE_INIT(obj, node_id, pm_action_cb) \
|
2021-08-26 17:26:31 +02:00
|
|
|
{ \
|
2021-11-02 17:34:57 +01:00
|
|
|
Z_PM_DEVICE_RUNTIME_INIT(obj) \
|
2021-10-13 16:38:42 +02:00
|
|
|
.action_cb = pm_action_cb, \
|
2021-08-26 17:26:31 +02:00
|
|
|
.state = PM_DEVICE_STATE_ACTIVE, \
|
|
|
|
.flags = ATOMIC_INIT(COND_CODE_1( \
|
|
|
|
DT_NODE_EXISTS(node_id), \
|
|
|
|
(DT_PROP_OR(node_id, wakeup_source, 0)),\
|
2021-10-29 11:42:16 +02:00
|
|
|
(0)) << PM_DEVICE_FLAG_WS_CAPABLE), \
|
2021-08-26 17:26:31 +02:00
|
|
|
}
|
|
|
|
|
2021-10-13 12:11:40 +02:00
|
|
|
/**
|
|
|
|
* Get the name of device PM resources.
|
|
|
|
*
|
|
|
|
* @param dev_name Device name.
|
|
|
|
*/
|
|
|
|
#define Z_PM_DEVICE_NAME(dev_name) _CONCAT(__pm_device__, dev_name)
|
|
|
|
|
|
|
|
#ifdef CONFIG_PM_DEVICE
|
|
|
|
/**
|
|
|
|
* Define device PM resources for the given node identifier.
|
|
|
|
*
|
|
|
|
* @param node_id Node identifier (DT_NODE_INVALID if not a DT device).
|
|
|
|
* @param dev_name Device name.
|
|
|
|
* @param pm_action_cb PM control callback.
|
|
|
|
*/
|
|
|
|
#define Z_PM_DEVICE_DEFINE(node_id, dev_name, pm_action_cb) \
|
|
|
|
static struct pm_device Z_PM_DEVICE_NAME(dev_name) = \
|
|
|
|
Z_PM_DEVICE_INIT(Z_PM_DEVICE_NAME(dev_name), node_id, \
|
|
|
|
pm_action_cb)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get a reference to the device PM resources.
|
|
|
|
*
|
|
|
|
* @param dev_name Device name.
|
|
|
|
*/
|
|
|
|
#define Z_PM_DEVICE_REF(dev_name) &Z_PM_DEVICE_NAME(dev_name)
|
|
|
|
|
|
|
|
#else
|
|
|
|
#define Z_PM_DEVICE_DEFINE(node_id, dev_name, pm_action_cb)
|
|
|
|
#define Z_PM_DEVICE_REF(dev_name) NULL
|
|
|
|
#endif /* CONFIG_PM_DEVICE */
|
|
|
|
|
2021-10-29 16:07:22 +02:00
|
|
|
/** @endcond */
|
|
|
|
|
2021-10-13 12:11:40 +02:00
|
|
|
/**
|
|
|
|
* Define device PM resources for the given device name.
|
|
|
|
*
|
|
|
|
* @note This macro is a no-op if @kconfig{CONFIG_PM_DEVICE} is not enabled.
|
|
|
|
*
|
|
|
|
* @param dev_name Device name.
|
|
|
|
* @param pm_action_cb PM control callback.
|
|
|
|
*
|
|
|
|
* @see #PM_DEVICE_DT_DEFINE, #PM_DEVICE_DT_INST_DEFINE
|
|
|
|
*/
|
|
|
|
#define PM_DEVICE_DEFINE(dev_name, pm_action_cb) \
|
|
|
|
Z_PM_DEVICE_DEFINE(DT_INVALID_NODE, dev_name, pm_action_cb)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Define device PM resources for the given node identifier.
|
|
|
|
*
|
|
|
|
* @note This macro is a no-op if @kconfig{CONFIG_PM_DEVICE} is not enabled.
|
|
|
|
*
|
|
|
|
* @param node_id Node identifier.
|
|
|
|
* @param pm_action_cb PM control callback.
|
|
|
|
*
|
|
|
|
* @see #PM_DEVICE_DT_INST_DEFINE, #PM_DEVICE_DEFINE
|
|
|
|
*/
|
|
|
|
#define PM_DEVICE_DT_DEFINE(node_id, pm_action_cb) \
|
|
|
|
Z_PM_DEVICE_DEFINE(node_id, Z_DEVICE_DT_DEV_NAME(node_id), \
|
|
|
|
pm_action_cb)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Define device PM resources for the given instance.
|
|
|
|
*
|
|
|
|
* @note This macro is a no-op if @kconfig{CONFIG_PM_DEVICE} is not enabled.
|
|
|
|
*
|
|
|
|
* @param idx Instance index.
|
|
|
|
* @param pm_action_cb PM control callback.
|
|
|
|
*
|
|
|
|
* @see #PM_DEVICE_DT_DEFINE, #PM_DEVICE_DEFINE
|
|
|
|
*/
|
|
|
|
#define PM_DEVICE_DT_INST_DEFINE(idx, pm_action_cb) \
|
|
|
|
Z_PM_DEVICE_DEFINE(DT_DRV_INST(idx), \
|
|
|
|
Z_DEVICE_DT_DEV_NAME(DT_DRV_INST(idx)), \
|
|
|
|
pm_action_cb)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Obtain a reference to the device PM resources for the given device.
|
|
|
|
*
|
|
|
|
* @param dev_name Device name.
|
|
|
|
*
|
|
|
|
* @return Reference to the device PM resources (NULL if device
|
|
|
|
* @kconfig{CONFIG_PM_DEVICE} is disabled).
|
|
|
|
*/
|
|
|
|
#define PM_DEVICE_REF(dev_name) \
|
|
|
|
Z_PM_DEVICE_REF(dev_name)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Obtain a reference to the device PM resources for the given node.
|
|
|
|
*
|
|
|
|
* @param node_id Node identifier.
|
|
|
|
*
|
|
|
|
* @return Reference to the device PM resources (NULL if device
|
|
|
|
* @kconfig{CONFIG_PM_DEVICE} is disabled).
|
|
|
|
*/
|
|
|
|
#define PM_DEVICE_DT_REF(node_id) \
|
|
|
|
PM_DEVICE_REF(Z_DEVICE_DT_DEV_NAME(node_id))
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Obtain a reference to the device PM resources for the given instance.
|
|
|
|
*
|
|
|
|
* @param idx Instance index.
|
|
|
|
*
|
|
|
|
* @return Reference to the device PM resources (NULL if device
|
|
|
|
* @kconfig{CONFIG_PM_DEVICE} is disabled).
|
|
|
|
*/
|
|
|
|
#define PM_DEVICE_DT_INST_REF(idx) \
|
|
|
|
PM_DEVICE_DT_REF(DT_DRV_INST(idx))
|
|
|
|
|
2021-04-29 13:32:28 +02:00
|
|
|
/**
|
|
|
|
* @brief Get name of device PM state
|
|
|
|
*
|
|
|
|
* @param state State id which name should be returned
|
|
|
|
*/
|
2021-06-03 19:06:53 +02:00
|
|
|
const char *pm_device_state_str(enum pm_device_state state);
|
2021-04-29 13:32:28 +02:00
|
|
|
|
2021-05-03 18:12:17 +02:00
|
|
|
/**
|
2021-06-10 09:41:18 +02:00
|
|
|
* @brief Set the power state of a device.
|
2021-05-03 18:12:17 +02:00
|
|
|
*
|
2021-06-10 09:41:18 +02:00
|
|
|
* 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.
|
2021-05-03 18:12:17 +02:00
|
|
|
*
|
2021-06-10 09:41:18 +02:00
|
|
|
* @param dev Device instance.
|
|
|
|
* @param state Device power state to be set.
|
|
|
|
*
|
|
|
|
* @retval 0 If successful.
|
2021-07-02 12:52:18 +02:00
|
|
|
* @retval -ENOTSUP If requested state is not supported.
|
2021-08-26 22:44:58 -07:00
|
|
|
* @retval -EALREADY If device is already at the requested state.
|
|
|
|
* @retval -EBUSY If device is changing its state.
|
2021-10-29 16:09:18 +02:00
|
|
|
* @retval -ENOSYS If device does not support PM.
|
2021-08-05 09:10:29 -07:00
|
|
|
* @retval Errno Other negative errno on failure.
|
2021-05-03 18:12:17 +02:00
|
|
|
*/
|
2021-06-03 19:06:53 +02:00
|
|
|
int pm_device_state_set(const struct device *dev,
|
2021-06-10 09:41:18 +02:00
|
|
|
enum pm_device_state state);
|
2021-05-03 18:12:17 +02:00
|
|
|
|
|
|
|
/**
|
2021-06-04 17:41:39 +02:00
|
|
|
* @brief Obtain the power state of a device.
|
2021-05-03 18:12:17 +02:00
|
|
|
*
|
2021-06-04 17:41:39 +02:00
|
|
|
* @param dev Device instance.
|
|
|
|
* @param state Pointer where device power state will be stored.
|
2021-05-03 18:12:17 +02:00
|
|
|
*
|
|
|
|
* @retval 0 If successful.
|
2021-06-04 17:41:39 +02:00
|
|
|
* @retval -ENOSYS If device does not implement power management.
|
2021-05-03 18:12:17 +02:00
|
|
|
*/
|
2021-06-03 19:06:53 +02:00
|
|
|
int pm_device_state_get(const struct device *dev,
|
2021-06-04 17:41:39 +02:00
|
|
|
enum pm_device_state *state);
|
2021-05-03 18:12:17 +02:00
|
|
|
|
2021-10-29 11:10:49 +02:00
|
|
|
#if defined(CONFIG_PM_DEVICE) || defined(__DOXYGEN__)
|
2021-05-31 15:24:34 +02:00
|
|
|
/**
|
2021-10-29 11:59:41 +02:00
|
|
|
* @brief Mark a device as busy.
|
2021-05-31 15:24:34 +02:00
|
|
|
*
|
2021-10-29 11:59:41 +02:00
|
|
|
* Devices marked as busy will not be suspended when the system goes into
|
|
|
|
* low-power states. This can be useful if, for example, the device is in the
|
|
|
|
* middle of a transaction.
|
2021-05-31 15:24:34 +02:00
|
|
|
*
|
2021-10-29 11:59:41 +02:00
|
|
|
* @param dev Device instance.
|
|
|
|
*
|
|
|
|
* @see pm_device_busy_clear()
|
2021-05-31 15:24:34 +02:00
|
|
|
*/
|
|
|
|
void pm_device_busy_set(const struct device *dev);
|
|
|
|
|
|
|
|
/**
|
2021-10-29 11:59:41 +02:00
|
|
|
* @brief Clear a device busy status.
|
2021-05-31 15:24:34 +02:00
|
|
|
*
|
2021-10-29 11:59:41 +02:00
|
|
|
* @param dev Device instance.
|
2021-05-31 15:24:34 +02:00
|
|
|
*
|
2021-10-29 11:59:41 +02:00
|
|
|
* @see pm_device_busy_set()
|
2021-05-31 15:24:34 +02:00
|
|
|
*/
|
|
|
|
void pm_device_busy_clear(const struct device *dev);
|
|
|
|
|
|
|
|
/**
|
2021-10-29 11:59:41 +02:00
|
|
|
* @brief Check if any device is busy.
|
2021-05-31 15:24:34 +02:00
|
|
|
*
|
2021-10-29 11:59:41 +02:00
|
|
|
* @retval false If no device is busy
|
|
|
|
* @retval true If one or more devices are busy
|
2021-05-31 15:24:34 +02:00
|
|
|
*/
|
2021-07-29 11:07:27 +02:00
|
|
|
bool pm_device_is_any_busy(void);
|
2021-05-31 15:24:34 +02:00
|
|
|
|
|
|
|
/**
|
2021-10-29 11:59:41 +02:00
|
|
|
* @brief Check if a device is busy.
|
2021-05-31 15:24:34 +02:00
|
|
|
*
|
2021-10-29 11:59:41 +02:00
|
|
|
* @param dev Device instance.
|
2021-05-31 15:24:34 +02:00
|
|
|
*
|
2021-10-29 11:59:41 +02:00
|
|
|
* @retval false If the device is not busy
|
|
|
|
* @retval true If the device is busy
|
2021-05-31 15:24:34 +02:00
|
|
|
*/
|
2021-07-29 17:02:49 +02:00
|
|
|
bool pm_device_is_busy(const struct device *dev);
|
2021-05-31 15:24:34 +02:00
|
|
|
|
2021-06-30 14:32:56 -07:00
|
|
|
/**
|
2021-10-29 15:55:00 +02:00
|
|
|
* @brief Enable or disable a device as a wake up source.
|
2021-06-30 14:32:56 -07:00
|
|
|
*
|
2021-10-29 15:55:00 +02:00
|
|
|
* A device marked as a wake up source will not be suspended when the system
|
|
|
|
* goes into low-power modes, thus allowing to use it as a wake up source for
|
|
|
|
* the system.
|
2021-06-30 14:32:56 -07:00
|
|
|
*
|
2021-10-29 15:55:00 +02:00
|
|
|
* @param dev Device instance.
|
2021-06-30 14:32:56 -07:00
|
|
|
* @param enable @c true to enable or @c false to disable
|
|
|
|
*
|
2021-10-29 15:55:00 +02:00
|
|
|
* @retval true If the wakeup source was successfully enabled.
|
|
|
|
* @retval false If the wakeup source was not successfully enabled.
|
2021-06-30 14:32:56 -07:00
|
|
|
*/
|
|
|
|
bool pm_device_wakeup_enable(struct device *dev, bool enable);
|
|
|
|
|
|
|
|
/**
|
2021-10-29 15:55:00 +02:00
|
|
|
* @brief Check if a device is enabled as a wake up source.
|
2021-06-30 14:32:56 -07:00
|
|
|
*
|
2021-10-29 15:55:00 +02:00
|
|
|
* @param dev Device instance.
|
2021-06-30 14:32:56 -07:00
|
|
|
*
|
|
|
|
* @retval true if the wakeup source is enabled.
|
|
|
|
* @retval false if the wakeup source is not enabled.
|
|
|
|
*/
|
|
|
|
bool pm_device_wakeup_is_enabled(const struct device *dev);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Check if a device is wake up capable
|
|
|
|
*
|
2021-10-29 15:55:00 +02:00
|
|
|
* @param dev Device instance.
|
2021-06-30 14:32:56 -07:00
|
|
|
*
|
2021-10-29 15:55:00 +02:00
|
|
|
* @retval true If the device is wake up capable.
|
|
|
|
* @retval false If the device is not wake up capable.
|
2021-06-30 14:32:56 -07:00
|
|
|
*/
|
|
|
|
bool pm_device_wakeup_is_capable(const struct device *dev);
|
2021-10-29 12:04:39 +02:00
|
|
|
#else
|
|
|
|
static inline void pm_device_busy_set(const struct device *dev) {}
|
|
|
|
static inline void pm_device_busy_clear(const struct device *dev) {}
|
|
|
|
static inline bool pm_device_is_any_busy(void) { return false; }
|
|
|
|
static inline bool pm_device_is_busy(const struct device *dev) { return false; }
|
|
|
|
static inline bool pm_device_wakeup_enable(struct device *dev, bool enable)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
static inline bool pm_device_wakeup_is_enabled(const struct device *dev)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
static inline bool pm_device_wakeup_is_capable(const struct device *dev)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_PM_DEVICE */
|
2021-06-30 14:32:56 -07:00
|
|
|
|
2021-10-29 11:38:11 +02:00
|
|
|
/**
|
|
|
|
* Mark a device as busy.
|
|
|
|
*
|
|
|
|
* @deprecated Use pm_device_busy_set() instead
|
|
|
|
*
|
|
|
|
* @param dev Device instance.
|
|
|
|
*/
|
|
|
|
__deprecated static inline void device_busy_set(const struct device *dev)
|
|
|
|
{
|
|
|
|
pm_device_busy_set(dev);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Clear busy status of a device.
|
|
|
|
*
|
|
|
|
* @deprecated Use pm_device_busy_clear() instead
|
|
|
|
*
|
|
|
|
* @param dev Device instance.
|
|
|
|
*/
|
|
|
|
__deprecated static inline void device_busy_clear(const struct device *dev)
|
|
|
|
{
|
|
|
|
pm_device_busy_clear(dev);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Check if any device is busy.
|
|
|
|
*
|
|
|
|
* @deprecated Use pm_device_is_any_busy() instead
|
|
|
|
*
|
|
|
|
* @retval 0 No devices are busy.
|
|
|
|
* @retval -EBUSY One or more devices are busy.
|
|
|
|
*/
|
|
|
|
__deprecated static inline int device_any_busy_check(void)
|
|
|
|
{
|
|
|
|
return pm_device_is_any_busy() ? -EBUSY : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Check if a device is busy.
|
|
|
|
*
|
|
|
|
* @deprecated Use pm_device_is_busy() instead
|
|
|
|
*
|
|
|
|
* @param dev Device instance.
|
|
|
|
*
|
|
|
|
* @retval 0 Device is not busy.
|
|
|
|
* @retval -EBUSY Device is busy.
|
|
|
|
*/
|
|
|
|
__deprecated static inline int device_busy_check(const struct device *dev)
|
|
|
|
{
|
|
|
|
return pm_device_is_busy(dev) ? -EBUSY : 0;
|
|
|
|
}
|
|
|
|
|
2021-04-29 13:32:28 +02:00
|
|
|
/** @} */
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|