Zephyr API Documentation 4.5.0-rc1
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
12
13#ifndef ZEPHYR_INCLUDE_PM_POLICY_H_
14#define ZEPHYR_INCLUDE_PM_POLICY_H_
15
16#include <stdbool.h>
17#include <stdint.h>
18
19#include <zephyr/device.h>
20#include <zephyr/pm/state.h>
21#include <zephyr/sys/slist.h>
22#include <zephyr/toolchain.h>
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
36
44typedef void (*pm_policy_latency_changed_cb_t)(int32_t latency);
45
57
65 sys_snode_t node;
66 uint32_t value_us;
68};
69
77 sys_snode_t node;
78 int64_t uptime_ticks;
80};
81
83
101const struct pm_state_info *pm_policy_next_state(uint8_t cpu, int32_t ticks);
102
104
106#define PM_ALL_SUBSTATES (UINT8_MAX)
107
108#if defined(CONFIG_PM) || defined(__DOXYGEN__)
128
139
146
151
166
181
193
207
218
242void pm_policy_event_register(struct pm_policy_event *evt, int64_t uptime_ticks);
243
257void pm_policy_event_update(struct pm_policy_event *evt, int64_t uptime_ticks);
258
269
293
294#if defined(CONFIG_PM_CUSTOM_TICKS_HOOK) || defined(__DOXYGEN__)
313#endif /* CONFIG_PM_CUSTOM_TICKS_HOOK */
314
315#else
317{
318 ARG_UNUSED(state);
319 ARG_UNUSED(substate_id);
320}
321
323{
324 ARG_UNUSED(state);
325 ARG_UNUSED(substate_id);
326}
327
328static inline void pm_policy_state_all_lock_get(void)
329{
330}
331
332static inline void pm_policy_state_all_lock_put(void)
333{
334}
335
337{
338 ARG_UNUSED(state);
339 ARG_UNUSED(substate_id);
340
341 return false;
342}
343
344static inline void pm_policy_event_register(struct pm_policy_event *evt, int64_t uptime_ticks)
345{
346 ARG_UNUSED(evt);
347 ARG_UNUSED(uptime_ticks);
348}
349
350static inline void pm_policy_event_update(struct pm_policy_event *evt, int64_t uptime_ticks)
351{
352 ARG_UNUSED(evt);
353 ARG_UNUSED(uptime_ticks);
354}
355
356static inline void pm_policy_event_unregister(struct pm_policy_event *evt)
357{
358 ARG_UNUSED(evt);
359}
360
361static inline int64_t pm_policy_next_event_ticks(void)
362{
363 return -1;
364}
365#ifdef CONFIG_PM_CUSTOM_TICKS_HOOK
366
367static inline int64_t pm_policy_next_custom_ticks(void)
368{
369 return -1;
370}
371#endif /* CONFIG_PM_CUSTOM_TICKS_HOOK */
372
373#endif /* CONFIG_PM */
374
375#if defined(CONFIG_PM_POLICY_DEVICE_CONSTRAINTS) || defined(__DOXYGEN__)
388
401
416
417#else
418
419static inline void pm_policy_device_power_lock_get(const struct device *dev)
420{
421 ARG_UNUSED(dev);
422}
423
424static inline void pm_policy_device_power_lock_put(const struct device *dev)
425{
426 ARG_UNUSED(dev);
427}
428
429static inline bool pm_policy_device_is_disabling_state(const struct device *dev,
430 enum pm_state state,
432{
433 ARG_UNUSED(dev);
434 ARG_UNUSED(state);
435 ARG_UNUSED(substate_id);
436
437 return false;
438}
439#endif /* CONFIG_PM_POLICY_DEVICE_CONSTRAINTS */
440
441#if defined(CONFIG_PM) || defined(CONFIG_PM_POLICY_LATENCY_STANDALONE) || defined(__DOXYGEN__)
452 uint32_t value_us);
453
461 uint32_t value_us);
462
469
478
485#else
486static inline void pm_policy_latency_request_add(
487 struct pm_policy_latency_request *req, uint32_t value_us)
488{
489 ARG_UNUSED(req);
490 ARG_UNUSED(value_us);
491}
492
493static inline void pm_policy_latency_request_update(
494 struct pm_policy_latency_request *req, uint32_t value_us)
495{
496 ARG_UNUSED(req);
497 ARG_UNUSED(value_us);
498}
499
500static inline void pm_policy_latency_request_remove(
501 struct pm_policy_latency_request *req)
502{
503 ARG_UNUSED(req);
504}
505#endif /* CONFIG_PM CONFIG_PM_POLICY_LATENCY_STANDALONE */
506
510
511#ifdef __cplusplus
512}
513#endif
514
515#endif /* ZEPHYR_INCLUDE_PM_POLICY_H_ */
APIs and macros for the Zephyr device model.
struct _snode sys_snode_t
Single-linked list node structure.
Definition slist.h:44
pm_state
Power management state.
Definition state.h:34
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:44
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
Header file for the single-linked list API.
Header file for System Power Management state definitions.
__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:543
Event.
Definition policy.h:75
Latency request.
Definition policy.h:63
Latency change subscription.
Definition policy.h:51
Collection of multiple power state constraints.
Definition state.h:199
Information about a power management state.
Definition state.h:121
uint8_t substate_id
Some platforms have multiple states that map to one Zephyr power state.
Definition state.h:150
Macros to abstract toolchain specific capabilities.