From 25bb163dc20184d0950b18e3cd1f78082e03ae61 Mon Sep 17 00:00:00 2001 From: Gerard Marull-Paretas Date: Thu, 29 Apr 2021 13:32:28 +0200 Subject: [PATCH] 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 --- CODEOWNERS | 2 +- MAINTAINERS.yml | 2 +- include/device.h | 210 +------------------- include/pm/device.h | 129 ++++++++++++ include/pm/device_runtime.h | 130 ++++++++++++ include/pm/pm.h | 209 +++++++++++++++++++ include/{power/power_state.h => pm/state.h} | 4 +- include/power/power.h | 201 +------------------ subsys/power/device_pm.c | 1 + subsys/power/pm_ctrl.c | 2 +- subsys/power/policy/policy_dummy.c | 2 +- subsys/power/power.c | 4 +- 12 files changed, 481 insertions(+), 415 deletions(-) create mode 100644 include/pm/device.h create mode 100644 include/pm/device_runtime.h create mode 100644 include/pm/pm.h rename include/{power/power_state.h => pm/state.h} (99%) diff --git a/CODEOWNERS b/CODEOWNERS index 98d2dd516dd..b691a8c27b4 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -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 diff --git a/MAINTAINERS.yml b/MAINTAINERS.yml index d30504e9c6f..152d284357d 100644 --- a/MAINTAINERS.yml +++ b/MAINTAINERS.yml @@ -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/ diff --git a/include/device.h b/include/device.h index 7499da5149c..9d5a6860754 100644 --- a/include/device.h +++ b/include/device.h @@ -27,6 +27,7 @@ */ #include +#include #include #include @@ -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 /** * @} diff --git a/include/pm/device.h b/include/pm/device.h new file mode 100644 index 00000000000..2886d3db586 --- /dev/null +++ b/include/pm/device.h @@ -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 +#include + +#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 diff --git a/include/pm/device_runtime.h b/include/pm/device_runtime.h new file mode 100644 index 00000000000..4b8bc776fae --- /dev/null +++ b/include/pm/device_runtime.h @@ -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 +#include + +#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_ */ diff --git a/include/pm/pm.h b/include/pm/pm.h new file mode 100644 index 00000000000..af7cc163129 --- /dev/null +++ b/include/pm/pm.h @@ -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 +#include +#include +#include +#include + +#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_ */ diff --git a/include/power/power_state.h b/include/pm/state.h similarity index 99% rename from include/power/power_state.h rename to include/pm/state.h index 9341b79c683..0b44b1baf78 100644 --- a/include/power/power_state.h +++ b/include/pm/state.h @@ -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 #include diff --git a/include/power/power.h b/include/power/power.h index f206e8b2a15..7dcd87f463a 100644 --- a/include/power/power.h +++ b/include/power/power.h @@ -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 -#include -#include -#include -#include +/* 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 #endif /* ZEPHYR_INCLUDE_POWER_POWER_H_ */ diff --git a/subsys/power/device_pm.c b/subsys/power/device_pm.c index 83f69fa94e2..4bd382dcf9e 100644 --- a/subsys/power/device_pm.c +++ b/subsys/power/device_pm.c @@ -8,6 +8,7 @@ #include #include #include +#include #define LOG_LEVEL CONFIG_PM_LOG_LEVEL /* From power module Kconfig */ #include diff --git a/subsys/power/pm_ctrl.c b/subsys/power/pm_ctrl.c index 390c5d17258..0ec8f31088f 100644 --- a/subsys/power/pm_ctrl.c +++ b/subsys/power/pm_ctrl.c @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include "policy/pm_policy.h" #define LOG_LEVEL CONFIG_PM_LOG_LEVEL /* From power module Kconfig */ diff --git a/subsys/power/policy/policy_dummy.c b/subsys/power/policy/policy_dummy.c index a9b91d1ec81..3efbcdbc6a4 100644 --- a/subsys/power/policy/policy_dummy.c +++ b/subsys/power/policy/policy_dummy.c @@ -6,7 +6,7 @@ #include #include -#include +#include #include "pm_policy.h" #include diff --git a/subsys/power/power.c b/subsys/power/power.c index aa958da91ea..1be4095c478 100644 --- a/subsys/power/power.c +++ b/subsys/power/power.c @@ -9,8 +9,8 @@ #include #include #include -#include -#include +#include +#include #include "policy/pm_policy.h" #define PM_STATES_LEN (1 + PM_STATE_SOFT_OFF - PM_STATE_ACTIVE)