pm: reorganize headers

- Move PM related APIs to `include/pm` so that it follows API `pm_`
  prefix namespace. In order to make transition easier
  `include/power/power.h` is kept pointing to `include/pm/pm.h`.
- Move most of device PM related content from `include/device.h` to
  `include/pm/device.h` and `include/pm/runtime.h`.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This commit is contained in:
Gerard Marull-Paretas 2021-04-29 13:32:28 +02:00 committed by Anas Nashif
parent 14a1145324
commit 25bb163dc2
12 changed files with 481 additions and 415 deletions

View File

@ -478,7 +478,7 @@
/include/net/lwm2m*.h @jukkar @rlubos
/include/net/mqtt.h @jukkar @rlubos
/include/posix/ @pfalcon
/include/power/power.h @nashif @ceolin
/include/pm/pm.h @nashif @ceolin
/include/drivers/ptp_clock.h @jukkar
/include/shared_irq.h @dcpleung @nashif @andyross
/include/shell/ @jakub-uC @nordic-krch

View File

@ -1166,7 +1166,7 @@ Power management:
- nashif
- mengxianglinx
files:
- include/power/power.h
- include/pm/pm.h
- samples/subsys/power/
- subsys/power/
- tests/subsys/power/

View File

@ -27,6 +27,7 @@
*/
#include <init.h>
#include <pm/device.h>
#include <sys/device_mmio.h>
#include <sys/util.h>
@ -332,39 +333,6 @@ typedef int16_t device_handle_t;
*/
#define DEVICE_DECLARE(name) static const struct device DEVICE_NAME_GET(name)
typedef void (*device_pm_cb)(const struct device *dev,
int status, void *context, void *arg);
/**
* @brief Device PM info
*/
struct device_pm {
/** Pointer to the device */
const struct device *dev;
/** Lock to synchronize the get/put operations */
struct k_sem lock;
/* Following are packed fields protected by #lock. */
/** Device pm enable flag */
bool enable : 1;
/* Following are packed fields accessed with atomic bit operations. */
atomic_t atomic_flags;
/** Device usage count */
atomic_t usage;
/** Device idle internal power state */
atomic_t fsm_state;
/** Work object for asynchronous calls */
struct k_work work;
/** Event object to listen to the sync request events */
struct k_poll_event event;
/** Signal to notify the Async API callers */
struct k_poll_signal signal;
};
/** Bit position in device_pm::atomic_flags that records whether the
* device is busy.
*/
#define DEVICE_PM_ATOMIC_FLAGS_BUSY_BIT 0
/**
* @brief Runtime device dynamic structure (in RAM) per driver instance
*
@ -649,77 +617,6 @@ static inline bool device_is_ready(const struct device *dev)
* @}
*/
/**
* @brief Device Power Management APIs
* @defgroup device_power_management_api Device Power Management APIs
* @ingroup power_management_api
* @{
*/
#ifdef CONFIG_PM_DEVICE
/** @def DEVICE_PM_ACTIVE_STATE
*
* @brief device is in ACTIVE power state
*
* @details Normal operation of the device. All device context is retained.
*/
#define DEVICE_PM_ACTIVE_STATE 1
/** @def DEVICE_PM_LOW_POWER_STATE
*
* @brief device is in LOW power state
*
* @details Device context is preserved by the HW and need not be
* restored by the driver.
*/
#define DEVICE_PM_LOW_POWER_STATE 2
/** @def DEVICE_PM_SUSPEND_STATE
*
* @brief device is in SUSPEND power state
*
* @details Most device context is lost by the hardware.
* Device drivers must save and restore or reinitialize any context
* lost by the hardware
*/
#define DEVICE_PM_SUSPEND_STATE 3
/** @def DEVICE_PM_FORCE_SUSPEND_STATE
*
* @brief device is in force SUSPEND power state
*
* @details Driver puts the device in suspended state after
* completing the ongoing transactions and will not process any
* queued work or will not take any new requests for processing.
* Most device context is lost by the hardware. Device drivers must
* save and restore or reinitialize any context lost by the hardware.
*/
#define DEVICE_PM_FORCE_SUSPEND_STATE 4
/** @def DEVICE_PM_OFF_STATE
*
* @brief device is in OFF power state
*
* @details - Power has been fully removed from the device.
* The device context is lost when this state is entered, so the OS
* software will reinitialize the device when powering it back on
*/
#define DEVICE_PM_OFF_STATE 5
/* Constants defining support device power commands */
#define DEVICE_PM_SET_POWER_STATE 1
#define DEVICE_PM_GET_POWER_STATE 2
#endif /* CONFIG_PM_DEVICE */
/**
* @brief Get name of device PM state
*
* @param state State id which name should be returned
*/
const char *device_pm_state_str(uint32_t state);
/**
* @brief Indicate that the device is in the middle of a transaction
*
@ -818,112 +715,7 @@ int device_any_busy_check(void);
*/
int device_busy_check(const struct device *chk_dev);
#ifdef CONFIG_PM_DEVICE_IDLE
/* Device PM states */
enum device_pm_state {
DEVICE_PM_STATE_ACTIVE = 1,
DEVICE_PM_STATE_SUSPENDED,
DEVICE_PM_STATE_SUSPENDING,
DEVICE_PM_STATE_RESUMING,
};
/**
* @brief Enable device idle PM
*
* Called by a device driver to enable device idle power management.
* The device might be asynchronously suspended if Idle PM is enabled
* when the device is not use.
*
* @param dev Pointer to device structure of the specific device driver
* the caller is interested in.
*/
void device_pm_enable(const struct device *dev);
/**
* @brief Disable device idle PM
*
* Called by a device driver to disable device idle power management.
* The device might be asynchronously resumed if Idle PM is disabled
*
* @param dev Pointer to device structure of the specific device driver
* the caller is interested in.
*/
void device_pm_disable(const struct device *dev);
/**
* @brief Call device resume asynchronously based on usage count
*
* Called by a device driver to mark the device as being used.
* This API will asynchronously bring the device to resume state
* if it not already in active state.
*
* @param dev Pointer to device structure of the specific device driver
* the caller is interested in.
* @retval 0 If successfully queued the Async request. If queued,
* the caller need to wait on the poll event linked to device
* pm signal mechanism to know the completion of resume operation.
* @retval Errno Negative errno code if failure.
*/
int device_pm_get(const struct device *dev);
/**
* @brief Call device resume synchronously based on usage count
*
* Called by a device driver to mark the device as being used. It
* will bring up or resume the device if it is in suspended state
* based on the device usage count. This call is blocked until the
* device PM state is changed to resume.
*
* @param dev Pointer to device structure of the specific device driver
* the caller is interested in.
* @retval 0 If successful.
* @retval Errno Negative errno code if failure.
*/
int device_pm_get_sync(const struct device *dev);
/**
* @brief Call device suspend asynchronously based on usage count
*
* Called by a device driver to mark the device as being released.
* This API asynchronously put the device to suspend state if
* it not already in suspended state.
*
* @param dev Pointer to device structure of the specific device driver
* the caller is interested in.
* @retval 0 If successfully queued the Async request. If queued,
* the caller need to wait on the poll event linked to device pm
* signal mechanism to know the completion of suspend operation.
* @retval Errno Negative errno code if failure.
*/
int device_pm_put(const struct device *dev);
/**
* @brief Call device suspend synchronously based on usage count
*
* Called by a device driver to mark the device as being released. It
* will put the device to suspended state if is is in active state
* based on the device usage count. This call is blocked until the
* device PM state is changed to resume.
*
* @param dev Pointer to device structure of the specific device driver
* the caller is interested in.
* @retval 0 If successful.
* @retval Errno Negative errno code if failure.
*/
int device_pm_put_sync(const struct device *dev);
#else
static inline void device_pm_enable(const struct device *dev) { }
static inline void device_pm_disable(const struct device *dev) { }
static inline int device_pm_get(const struct device *dev) { return -ENOTSUP; }
static inline int device_pm_get_sync(const struct device *dev) { return -ENOTSUP; }
static inline int device_pm_put(const struct device *dev) { return -ENOTSUP; }
static inline int device_pm_put_sync(const struct device *dev) { return -ENOTSUP; }
#endif
#endif
/** Alias for legacy use of device_pm_control_nop */
#define device_pm_control_nop __DEPRECATED_MACRO NULL
/**
* @}

129
include/pm/device.h Normal file
View File

@ -0,0 +1,129 @@
/*
* 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
*
* @defgroup device_power_management_api Device Power Management API
* @ingroup power_management_api
* @{
*/
struct device;
/** @def DEVICE_PM_ACTIVE_STATE
*
* @brief device is in ACTIVE power state
*
* @details Normal operation of the device. All device context is retained.
*/
#define DEVICE_PM_ACTIVE_STATE 1
/** @def DEVICE_PM_LOW_POWER_STATE
*
* @brief device is in LOW power state
*
* @details Device context is preserved by the HW and need not be
* restored by the driver.
*/
#define DEVICE_PM_LOW_POWER_STATE 2
/** @def DEVICE_PM_SUSPEND_STATE
*
* @brief device is in SUSPEND power state
*
* @details Most device context is lost by the hardware.
* Device drivers must save and restore or reinitialize any context
* lost by the hardware
*/
#define DEVICE_PM_SUSPEND_STATE 3
/** @def DEVICE_PM_FORCE_SUSPEND_STATE
*
* @brief device is in force SUSPEND power state
*
* @details Driver puts the device in suspended state after
* completing the ongoing transactions and will not process any
* queued work or will not take any new requests for processing.
* Most device context is lost by the hardware. Device drivers must
* save and restore or reinitialize any context lost by the hardware.
*/
#define DEVICE_PM_FORCE_SUSPEND_STATE 4
/** @def DEVICE_PM_OFF_STATE
*
* @brief device is in OFF power state
*
* @details - Power has been fully removed from the device.
* The device context is lost when this state is entered, so the OS
* software will reinitialize the device when powering it back on
*/
#define DEVICE_PM_OFF_STATE 5
/* Constants defining support device power commands */
#define DEVICE_PM_SET_POWER_STATE 1
#define DEVICE_PM_GET_POWER_STATE 2
typedef void (*device_pm_cb)(const struct device *dev,
int status, void *context, void *arg);
/**
* @brief Device PM info
*/
struct device_pm {
/** Pointer to the device */
const struct device *dev;
/** Lock to synchronize the get/put operations */
struct k_sem lock;
/* Following are packed fields protected by #lock. */
/** Device pm enable flag */
bool enable : 1;
/* Following are packed fields accessed with atomic bit operations. */
atomic_t atomic_flags;
/** Device usage count */
atomic_t usage;
/** Device idle internal power state */
atomic_t fsm_state;
/** Work object for asynchronous calls */
struct k_work work;
/** Event object to listen to the sync request events */
struct k_poll_event event;
/** Signal to notify the Async API callers */
struct k_poll_signal signal;
};
/** Bit position in device_pm::atomic_flags that records whether the
* device is busy.
*/
#define DEVICE_PM_ATOMIC_FLAGS_BUSY_BIT 0
/**
* @brief Get name of device PM state
*
* @param state State id which name should be returned
*/
const char *device_pm_state_str(uint32_t state);
/** Alias for legacy use of device_pm_control_nop */
#define device_pm_control_nop __DEPRECATED_MACRO NULL
/** @} */
#ifdef __cplusplus
}
#endif
#endif

130
include/pm/device_runtime.h Normal file
View File

@ -0,0 +1,130 @@
/*
* Copyright (c) 2015 Intel Corporation.
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef ZEPHYR_INCLUDE_PM_DEVICE_RUNTIME_H_
#define ZEPHYR_INCLUDE_PM_DEVICE_RUNTIME_H_
#include <kernel.h>
#include <sys/atomic.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Runtime Power Management API
*
* @defgroup runtime_power_management_api Runtime Power Management API
* @ingroup power_management_api
* @{
*/
#ifdef CONFIG_PM_DEVICE_IDLE
/* Device PM states */
enum device_pm_state {
DEVICE_PM_STATE_ACTIVE = 1,
DEVICE_PM_STATE_SUSPENDED,
DEVICE_PM_STATE_SUSPENDING,
DEVICE_PM_STATE_RESUMING,
};
/**
* @brief Enable device idle PM
*
* Called by a device driver to enable device idle power management.
* The device might be asynchronously suspended if Idle PM is enabled
* when the device is not use.
*
* @param dev Pointer to device structure of the specific device driver
* the caller is interested in.
*/
void device_pm_enable(const struct device *dev);
/**
* @brief Disable device idle PM
*
* Called by a device driver to disable device idle power management.
* The device might be asynchronously resumed if Idle PM is disabled
*
* @param dev Pointer to device structure of the specific device driver
* the caller is interested in.
*/
void device_pm_disable(const struct device *dev);
/**
* @brief Call device resume asynchronously based on usage count
*
* Called by a device driver to mark the device as being used.
* This API will asynchronously bring the device to resume state
* if it not already in active state.
*
* @param dev Pointer to device structure of the specific device driver
* the caller is interested in.
* @retval 0 If successfully queued the Async request. If queued,
* the caller need to wait on the poll event linked to device
* pm signal mechanism to know the completion of resume operation.
* @retval Errno Negative errno code if failure.
*/
int device_pm_get(const struct device *dev);
/**
* @brief Call device resume synchronously based on usage count
*
* Called by a device driver to mark the device as being used. It
* will bring up or resume the device if it is in suspended state
* based on the device usage count. This call is blocked until the
* device PM state is changed to resume.
*
* @param dev Pointer to device structure of the specific device driver
* the caller is interested in.
* @retval 0 If successful.
* @retval Errno Negative errno code if failure.
*/
int device_pm_get_sync(const struct device *dev);
/**
* @brief Call device suspend asynchronously based on usage count
*
* Called by a device driver to mark the device as being released.
* This API asynchronously put the device to suspend state if
* it not already in suspended state.
*
* @param dev Pointer to device structure of the specific device driver
* the caller is interested in.
* @retval 0 If successfully queued the Async request. If queued,
* the caller need to wait on the poll event linked to device pm
* signal mechanism to know the completion of suspend operation.
* @retval Errno Negative errno code if failure.
*/
int device_pm_put(const struct device *dev);
/**
* @brief Call device suspend synchronously based on usage count
*
* Called by a device driver to mark the device as being released. It
* will put the device to suspended state if is is in active state
* based on the device usage count. This call is blocked until the
* device PM state is changed to resume.
*
* @param dev Pointer to device structure of the specific device driver
* the caller is interested in.
* @retval 0 If successful.
* @retval Errno Negative errno code if failure.
*/
int device_pm_put_sync(const struct device *dev);
#else
static inline void device_pm_enable(const struct device *dev) { }
static inline void device_pm_disable(const struct device *dev) { }
static inline int device_pm_get(const struct device *dev) { return -ENOTSUP; }
static inline int device_pm_get_sync(const struct device *dev) { return -ENOTSUP; }
static inline int device_pm_put(const struct device *dev) { return -ENOTSUP; }
static inline int device_pm_put_sync(const struct device *dev) { return -ENOTSUP; }
#endif
/** @} */
#endif /* ZEPHYR_INCLUDE_PM_DEVICE_RUNTIME_H_ */

209
include/pm/pm.h Normal file
View File

@ -0,0 +1,209 @@
/*
* Copyright (c) 2012-2014 Wind River Systems, Inc.
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef ZEPHYR_INCLUDE_PM_PM_H_
#define ZEPHYR_INCLUDE_PM_PM_H_
#include <zephyr/types.h>
#include <sys/slist.h>
#include <pm/state.h>
#include <toolchain.h>
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @defgroup power_management_api Power Management
* @{
* @}
*/
#ifdef CONFIG_PM
/**
* @brief System Power Management API
*
* @defgroup system_power_management_api System Power Management API
* @ingroup power_management_api
* @{
*/
/**
* Power management notifier struct
*
* This struct contains callbacks that are called when the target enters and
* exits power states.
*
* As currently implemented the entry callback is invoked when
* transitioning from PM_STATE_ACTIVE to another state, and the exit
* callback is invoked when transitioning from a non-active state to
* PM_STATE_ACTIVE. This behavior may change in the future.
*
* @note These callbacks can be called from the ISR of the event
* that caused the kernel exit from idling.
*
* @note It is not allowed to call @ref pm_notifier_unregister or
* @ref pm_notifier_register from these callbacks because they are called
* with the spin locked in those functions.
*/
struct pm_notifier {
sys_snode_t _node;
/**
* Application defined function for doing any target specific operations
* for power state entry.
*/
void (*state_entry)(enum pm_state state);
/**
* Application defined function for doing any target specific operations
* for power state exit.
*/
void (*state_exit)(enum pm_state state);
};
/**
* @brief Force usage of given power state.
*
* This function overrides decision made by PM policy forcing
* usage of given power state immediately.
*
* @note This function can only run in thread context
*
* @param info Power state which should be used in the ongoing
* suspend operation.
*/
void pm_power_state_force(struct pm_state_info info);
#ifdef CONFIG_PM_DEBUG
/**
* @brief Dump Low Power states related debug info
*
* Dump Low Power states debug info like LPS entry count and residencies.
*/
void pm_dump_debug_info(void);
#endif /* CONFIG_PM_DEBUG */
/**
* @brief Register a power management notifier
*
* Register the given notifier from the power management notification
* list.
*
* @param notifier pm_notifier object to be registered.
*/
void pm_notifier_register(struct pm_notifier *notifier);
/**
* @brief Unregister a power management notifier
*
* Remove the given notifier from the power management notification
* list. After that this object callbacks will not be called.
*
* @param notifier pm_notifier object to be unregistered.
*
* @return 0 if the notifier was successfully removed, a negative value
* otherwise.
*/
int pm_notifier_unregister(struct pm_notifier *notifier);
/**
* @}
*/
/**
* @brief System Power Management Constraint API
*
* @defgroup system_power_management_constraint_api Constraint API
* @ingroup power_management_api
* @{
*/
/**
* @brief Set a constraint for a power state
*
* @details Disabled state cannot be selected by the Zephyr power
* management policies. Application defined policy should
* use the @ref pm_constraint_get function to
* check if given state is enabled and could be used.
*
* @note This API is refcount
*
* @param [in] state Power state to be disabled.
*/
void pm_constraint_set(enum pm_state state);
/**
* @brief Release a constraint for a power state
*
* @details Enabled state can be selected by the Zephyr power
* management policies. Application defined policy should
* use the @ref pm_constraint_get function to
* check if given state is enabled and could be used.
* By default all power states are enabled.
*
* @note This API is refcount
*
* @param [in] state Power state to be enabled.
*/
void pm_constraint_release(enum pm_state state);
/**
* @brief Check if particular power state is enabled
*
* This function returns true if given power state is enabled.
*
* @param [in] state Power state.
*/
bool pm_constraint_get(enum pm_state state);
/**
* @}
*/
/**
* @brief Power Management Hooks
*
* @defgroup power_management_hook_interface Power Management Hooks
* @ingroup power_management_api
* @{
*/
/**
* @brief Put processor into a power state.
*
* This function implements the SoC specific details necessary
* to put the processor into available power states.
*
* @param info Power state which should be used in the ongoing
* suspend operation.
*/
void pm_power_state_set(struct pm_state_info info);
/**
* @brief Do any SoC or architecture specific post ops after sleep state exits.
*
* This function is a place holder to do any operations that may
* be needed to be done after sleep state exits. Currently it enables
* interrupts after resuming from sleep state. In future, the enabling
* of interrupts may be moved into the kernel.
*/
void pm_power_state_exit_post_ops(struct pm_state_info info);
/**
* @}
*/
void z_pm_save_idle_exit(int32_t ticks);
#endif /* CONFIG_PM */
#ifdef __cplusplus
}
#endif
#endif /* ZEPHYR_INCLUDE_PM_PM_H_ */

View File

@ -4,8 +4,8 @@
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef ZEPHYR_INCLUDE_POWER_POWER_STATE_H_
#define ZEPHYR_INCLUDE_POWER_POWER_STATE_H_
#ifndef ZEPHYR_INCLUDE_PM_STATE_H_
#define ZEPHYR_INCLUDE_PM_STATE_H_
#include <sys/util.h>
#include <devicetree.h>

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012-2014 Wind River Systems, Inc.
* Copyright (c) 2021 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/
@ -7,203 +7,8 @@
#ifndef ZEPHYR_INCLUDE_POWER_POWER_H_
#define ZEPHYR_INCLUDE_POWER_POWER_H_
#include <zephyr/types.h>
#include <sys/slist.h>
#include <power/power_state.h>
#include <toolchain.h>
#include <stdbool.h>
/* NOTE: This header is kept for compatibility but will be deprecated soon */
#ifdef __cplusplus
extern "C" {
#endif
/**
* @defgroup power_management_api Power Management
* @{
* @}
*/
#ifdef CONFIG_PM
/**
* @brief System Power Management API
*
* @defgroup system_power_management_api System Power Management API
* @ingroup power_management_api
* @{
*/
/**
* Power management notifier struct
*
* This struct contains callbacks that are called when the target enters and
* exits power states.
*
* As currently implemented the entry callback is invoked when
* transitioning from PM_STATE_ACTIVE to another state, and the exit
* callback is invoked when transitioning from a non-active state to
* PM_STATE_ACTIVE. This behavior may change in the future.
*
* @note These callbacks can be called from the ISR of the event
* that caused the kernel exit from idling.
*
* @note It is not allowed to call @ref pm_notifier_unregister or
* @ref pm_notifier_register from these callbacks because they are called
* with the spin locked in those functions.
*/
struct pm_notifier {
sys_snode_t _node;
/**
* Application defined function for doing any target specific operations
* for power state entry.
*/
void (*state_entry)(enum pm_state state);
/**
* Application defined function for doing any target specific operations
* for power state exit.
*/
void (*state_exit)(enum pm_state state);
};
/**
* @brief Force usage of given power state.
*
* This function overrides decision made by PM policy forcing
* usage of given power state immediately.
*
* @note This function can only run in thread context
*
* @param info Power state which should be used in the ongoing
* suspend operation.
*/
void pm_power_state_force(struct pm_state_info info);
#ifdef CONFIG_PM_DEBUG
/**
* @brief Dump Low Power states related debug info
*
* Dump Low Power states debug info like LPS entry count and residencies.
*/
void pm_dump_debug_info(void);
#endif /* CONFIG_PM_DEBUG */
/**
* @brief Register a power management notifier
*
* Register the given notifier from the power management notification
* list.
*
* @param notifier pm_notifier object to be registered.
*/
void pm_notifier_register(struct pm_notifier *notifier);
/**
* @brief Unregister a power management notifier
*
* Remove the given notifier from the power management notification
* list. After that this object callbacks will not be called.
*
* @param notifier pm_notifier object to be unregistered.
*
* @return 0 if the notifier was successfully removed, a negative value
* otherwise.
*/
int pm_notifier_unregister(struct pm_notifier *notifier);
/**
* @}
*/
/**
* @brief System Power Management Constraint API
*
* @defgroup system_power_management_constraint_api Constraint API
* @ingroup power_management_api
* @{
*/
/**
* @brief Set a constraint for a power state
*
* @details Disabled state cannot be selected by the Zephyr power
* management policies. Application defined policy should
* use the @ref pm_constraint_get function to
* check if given state is enabled and could be used.
*
* @note This API is refcount
*
* @param [in] state Power state to be disabled.
*/
void pm_constraint_set(enum pm_state state);
/**
* @brief Release a constraint for a power state
*
* @details Enabled state can be selected by the Zephyr power
* management policies. Application defined policy should
* use the @ref pm_constraint_get function to
* check if given state is enabled and could be used.
* By default all power states are enabled.
*
* @note This API is refcount
*
* @param [in] state Power state to be enabled.
*/
void pm_constraint_release(enum pm_state state);
/**
* @brief Check if particular power state is enabled
*
* This function returns true if given power state is enabled.
*
* @param [in] state Power state.
*/
bool pm_constraint_get(enum pm_state state);
/**
* @}
*/
/**
* @brief Power Management Hooks
*
* @defgroup power_management_hook_interface Power Management Hooks
* @ingroup power_management_api
* @{
*/
/**
* @brief Put processor into a power state.
*
* This function implements the SoC specific details necessary
* to put the processor into available power states.
*
* @param info Power state which should be used in the ongoing
* suspend operation.
*/
void pm_power_state_set(struct pm_state_info info);
/**
* @brief Do any SoC or architecture specific post ops after sleep state exits.
*
* This function is a place holder to do any operations that may
* be needed to be done after sleep state exits. Currently it enables
* interrupts after resuming from sleep state. In future, the enabling
* of interrupts may be moved into the kernel.
*/
void pm_power_state_exit_post_ops(struct pm_state_info info);
/**
* @}
*/
void z_pm_save_idle_exit(int32_t ticks);
#endif /* CONFIG_PM */
#ifdef __cplusplus
}
#endif
#include <pm/pm.h>
#endif /* ZEPHYR_INCLUDE_POWER_POWER_H_ */

View File

@ -8,6 +8,7 @@
#include <kernel.h>
#include <device.h>
#include <sys/__assert.h>
#include <pm/device_runtime.h>
#define LOG_LEVEL CONFIG_PM_LOG_LEVEL /* From power module Kconfig */
#include <logging/log.h>

View File

@ -8,7 +8,7 @@
#include <string.h>
#include <device.h>
#include <sys/atomic.h>
#include <power/power_state.h>
#include <pm/state.h>
#include "policy/pm_policy.h"
#define LOG_LEVEL CONFIG_PM_LOG_LEVEL /* From power module Kconfig */

View File

@ -6,7 +6,7 @@
#include <zephyr.h>
#include <kernel.h>
#include <power/power_state.h>
#include <pm/state.h>
#include "pm_policy.h"
#include <logging/log.h>

View File

@ -9,8 +9,8 @@
#include <timeout_q.h>
#include <init.h>
#include <string.h>
#include <power/power.h>
#include <power/power_state.h>
#include <pm/pm.h>
#include <pm/state.h>
#include "policy/pm_policy.h"
#define PM_STATES_LEN (1 + PM_STATE_SOFT_OFF - PM_STATE_ACTIVE)