Zephyr API Documentation 4.3.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
policy.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018 Intel Corporation.
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#ifndef ZEPHYR_INCLUDE_PM_POLICY_H_
8#define ZEPHYR_INCLUDE_PM_POLICY_H_
9
10#include <stdbool.h>
11#include <stdint.h>
12
13#include <zephyr/device.h>
14#include <zephyr/pm/state.h>
15#include <zephyr/sys/slist.h>
16#include <zephyr/toolchain.h>
17
18#ifdef __cplusplus
19extern "C" {
20#endif
21
28
36typedef void (*pm_policy_latency_changed_cb_t)(int32_t latency);
37
49
57 sys_snode_t node;
58 uint32_t value_us;
60};
61
69 sys_snode_t node;
70 int64_t uptime_ticks;
72};
73
75
89const struct pm_state_info *pm_policy_next_state(uint8_t cpu, int32_t ticks);
90
92
94#define PM_ALL_SUBSTATES (UINT8_MAX)
95
96#if defined(CONFIG_PM) || defined(__DOXYGEN__)
116
127
134
139
154
169
181
195
206
230void pm_policy_event_register(struct pm_policy_event *evt, int64_t uptime_ticks);
231
245void pm_policy_event_update(struct pm_policy_event *evt, int64_t uptime_ticks);
246
257
275
276#if defined(CONFIG_PM_CUSTOM_TICKS_HOOK) || defined(__DOXYGEN__)
291#endif /* CONFIG_PM_CUSTOM_TICKS_HOOK */
292
293#else
295{
296 ARG_UNUSED(state);
297 ARG_UNUSED(substate_id);
298}
299
301{
302 ARG_UNUSED(state);
303 ARG_UNUSED(substate_id);
304}
305
306static inline void pm_policy_state_all_lock_get(void)
307{
308}
309
310static inline void pm_policy_state_all_lock_put(void)
311{
312}
313
315{
316 ARG_UNUSED(state);
317 ARG_UNUSED(substate_id);
318
319 return false;
320}
321
322static inline void pm_policy_event_register(struct pm_policy_event *evt, int64_t uptime_ticks)
323{
324 ARG_UNUSED(evt);
325 ARG_UNUSED(uptime_ticks);
326}
327
328static inline void pm_policy_event_update(struct pm_policy_event *evt, int64_t uptime_ticks)
329{
330 ARG_UNUSED(evt);
331 ARG_UNUSED(uptime_ticks);
332}
333
334static inline void pm_policy_event_unregister(struct pm_policy_event *evt)
335{
336 ARG_UNUSED(evt);
337}
338
339static inline int64_t pm_policy_next_event_ticks(void)
340{
341 return -1;
342}
343#ifdef CONFIG_PM_CUSTOM_TICKS_HOOK
344
345static inline int64_t pm_policy_next_custom_ticks(void)
346{
347 return -1;
348}
349#endif /* CONFIG_PM_CUSTOM_TICKS_HOOK */
350
351#endif /* CONFIG_PM */
352
353#if defined(CONFIG_PM_POLICY_DEVICE_CONSTRAINTS) || defined(__DOXYGEN__)
366
379
394
395#else
396
397static inline void pm_policy_device_power_lock_get(const struct device *dev)
398{
399 ARG_UNUSED(dev);
400}
401
402static inline void pm_policy_device_power_lock_put(const struct device *dev)
403{
404 ARG_UNUSED(dev);
405}
406
407static inline bool pm_policy_device_is_disabling_state(const struct device *dev,
408 enum pm_state state,
410{
411 ARG_UNUSED(dev);
412 ARG_UNUSED(state);
413 ARG_UNUSED(substate_id);
414
415 return false;
416}
417#endif /* CONFIG_PM_POLICY_DEVICE_CONSTRAINTS */
418
419#if defined(CONFIG_PM) || defined(CONFIG_PM_POLICY_LATENCY_STANDALONE) || defined(__DOXYGEN__)
430 uint32_t value_us);
431
439 uint32_t value_us);
440
447
456
463#else
464static inline void pm_policy_latency_request_add(
465 struct pm_policy_latency_request *req, uint32_t value_us)
466{
467 ARG_UNUSED(req);
468 ARG_UNUSED(value_us);
469}
470
471static inline void pm_policy_latency_request_update(
472 struct pm_policy_latency_request *req, uint32_t value_us)
473{
474 ARG_UNUSED(req);
475 ARG_UNUSED(value_us);
476}
477
478static inline void pm_policy_latency_request_remove(
479 struct pm_policy_latency_request *req)
480{
481 ARG_UNUSED(req);
482}
483#endif /* CONFIG_PM CONFIG_PM_POLICY_LATENCY_STANDALONE */
484
488
489#ifdef __cplusplus
490}
491#endif
492
493#endif /* ZEPHYR_INCLUDE_PM_POLICY_H_ */
struct _snode sys_snode_t
Single-linked list node structure.
Definition slist.h:39
pm_state
Power management state.
Definition state.h:28
void pm_policy_event_update(struct pm_policy_event *evt, int64_t uptime_ticks)
Update an event.
bool pm_policy_state_any_active(void)
Check if any power state can be used.
void pm_policy_state_lock_put(enum pm_state state, uint8_t substate_id)
Decrease a power state lock counter.
bool pm_policy_state_is_available(enum pm_state state, uint8_t substate_id)
Check if a power state is available.
bool pm_policy_state_lock_is_active(enum pm_state state, uint8_t substate_id)
Check if a power state lock is active (not allowed).
void pm_policy_state_constraints_get(struct pm_state_constraints *constraints)
Apply power state constraints by locking the specified states.
bool pm_policy_device_is_disabling_state(const struct device *dev, enum pm_state state, uint8_t substate_id)
Check if a state will disable a device.
void pm_policy_event_register(struct pm_policy_event *evt, int64_t uptime_ticks)
Register an event.
void pm_policy_latency_request_update(struct pm_policy_latency_request *req, uint32_t value_us)
Update a latency requirement.
int64_t pm_policy_next_custom_ticks(void)
Get ticks to custom next event for PM policy.
void pm_policy_device_power_lock_get(const struct device *dev)
Increase power state locks.
void pm_policy_state_constraints_put(struct pm_state_constraints *constraints)
Remove power state constraints by unlocking the specified states.
void pm_policy_latency_request_add(struct pm_policy_latency_request *req, uint32_t value_us)
Add a new latency requirement.
void pm_policy_latency_changed_unsubscribe(struct pm_policy_latency_subscription *req)
Unsubscribe to maximum latency changes.
void pm_policy_event_unregister(struct pm_policy_event *evt)
Unregister an event.
void pm_policy_latency_request_remove(struct pm_policy_latency_request *req)
Remove a latency requirement.
void(* pm_policy_latency_changed_cb_t)(int32_t latency)
Callback to notify when maximum latency changes.
Definition policy.h:36
void pm_policy_state_lock_get(enum pm_state state, uint8_t substate_id)
Increase a power state lock counter.
void pm_policy_latency_changed_subscribe(struct pm_policy_latency_subscription *req, pm_policy_latency_changed_cb_t cb)
Subscribe to maximum latency changes.
void pm_policy_state_all_lock_put(void)
Release locking of all power states.
int64_t pm_policy_next_event_ticks(void)
Returns the ticks until the next event.
void pm_policy_state_all_lock_get(void)
Request to lock all power states.
void pm_policy_device_power_lock_put(const struct device *dev)
Decrease power state locks.
state
Definition parser_state.h:29
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__INT32_TYPE__ int32_t
Definition stdint.h:74
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
__INT64_TYPE__ int64_t
Definition stdint.h:75
Runtime device structure (in ROM) per driver instance.
Definition device.h:513
Event.
Definition policy.h:67
Latency request.
Definition policy.h:55
Latency change subscription.
Definition policy.h:43
Collection of multiple power state constraints.
Definition state.h:192
Information about a power management state.
Definition state.h:115
uint8_t substate_id
Some platforms have multiple states that map to one Zephyr power state.
Definition state.h:143
Macros to abstract toolchain specific capabilities.