Zephyr API Documentation 4.2.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
state.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020 Intel corporation
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#ifndef ZEPHYR_INCLUDE_PM_STATE_H_
8#define ZEPHYR_INCLUDE_PM_STATE_H_
9
10#include <zephyr/sys/util.h>
11#include <zephyr/devicetree.h>
12#include <errno.h>
13
14#ifdef __cplusplus
15extern "C" {
16#endif
17
24
111
169
187
189
197#define Z_DT_PHANDLE_01(node_id, prop, idx) \
198 COND_CODE_1(DT_NODE_HAS_STATUS_OKAY(DT_PHANDLE_BY_IDX(node_id, prop, idx)), \
199 (1), (0))
200
210#define Z_PM_STATE_INFO_FROM_DT_CPU(i, node_id) \
211 COND_CODE_1(DT_NODE_HAS_STATUS_OKAY(DT_PHANDLE_BY_IDX(node_id, cpu_power_states, i)), \
212 (PM_STATE_INFO_DT_INIT(DT_PHANDLE_BY_IDX(node_id, cpu_power_states, i)),), ())
213
223#define Z_PM_STATE_FROM_DT_CPU(i, node_id) \
224 COND_CODE_1(DT_NODE_HAS_STATUS_OKAY(DT_PHANDLE_BY_IDX(node_id, cpu_power_states, i)), \
225 (PM_STATE_DT_INIT(DT_PHANDLE_BY_IDX(node_id, cpu_power_states, i)),), ())
226
228
235#define PM_STATE_INFO_DT_INIT(node_id) \
236 { \
237 .state = PM_STATE_DT_INIT(node_id), \
238 .substate_id = DT_PROP_OR(node_id, substate_id, 0), \
239 .min_residency_us = DT_PROP_OR(node_id, min_residency_us, 0), \
240 .exit_latency_us = DT_PROP_OR(node_id, exit_latency_us, 0), \
241 .pm_device_disabled = DT_PROP(node_id, zephyr_pm_device_disabled), \
242 }
243
250#define PM_STATE_DT_INIT(node_id) \
251 DT_ENUM_IDX(node_id, power_state_name)
252
260#define DT_NUM_CPU_POWER_STATES(node_id) \
261 COND_CODE_1(DT_NODE_HAS_PROP(node_id, cpu_power_states), \
262 (DT_FOREACH_PROP_ELEM_SEP(node_id, cpu_power_states, Z_DT_PHANDLE_01, (+))), \
263 (0))
264
309#define PM_STATE_INFO_LIST_FROM_DT_CPU(node_id) \
310 { \
311 LISTIFY(DT_PROP_LEN_OR(node_id, cpu_power_states, 0), \
312 Z_PM_STATE_INFO_FROM_DT_CPU, (), node_id) \
313 }
314
356#define PM_STATE_LIST_FROM_DT_CPU(node_id) \
357 { \
358 LISTIFY(DT_PROP_LEN_OR(node_id, cpu_power_states, 0), \
359 Z_PM_STATE_FROM_DT_CPU, (), node_id) \
360 }
361
362
363#if defined(CONFIG_PM) || defined(__DOXYGEN__)
373
386
395
396
405int pm_state_from_str(const char *name, enum pm_state *out);
409
410#else /* CONFIG_PM */
411
412static inline uint8_t pm_state_cpu_get_all(uint8_t cpu, const struct pm_state_info **states)
413{
414 ARG_UNUSED(cpu);
415 ARG_UNUSED(states);
416
417 return 0;
418}
419
420static inline const struct pm_state_info *pm_state_get(uint8_t cpu,
421 enum pm_state state,
423{
424 ARG_UNUSED(cpu);
425 ARG_UNUSED(state);
426 ARG_UNUSED(substate_id);
427
428 return NULL;
429}
430
431#endif /* CONFIG_PM */
432
433#ifdef __cplusplus
434}
435#endif
436
437#endif
Devicetree main header.
System error numbers.
pm_state
Power management state.
Definition state.h:28
uint8_t pm_state_cpu_get_all(uint8_t cpu, const struct pm_state_info **states)
Obtain information about all supported states by a CPU.
const struct pm_state_info * pm_state_get(uint8_t cpu, enum pm_state state, uint8_t substate_id)
Get power state structure.
int pm_state_from_str(const char *name, enum pm_state *out)
Parse a string and convert it to a pm_state enum value.
const char * pm_state_to_str(enum pm_state state)
Convert a pm_state enum value to its string representation.
@ PM_STATE_SOFT_OFF
Soft off state.
Definition state.h:107
@ PM_STATE_STANDBY
Standby state.
Definition state.h:71
@ PM_STATE_SUSPEND_TO_RAM
Suspend to ram state.
Definition state.h:83
@ PM_STATE_ACTIVE
Runtime active state.
Definition state.h:36
@ PM_STATE_RUNTIME_IDLE
Runtime idle state.
Definition state.h:47
@ PM_STATE_SUSPEND_TO_IDLE
Suspend to idle state.
Definition state.h:59
@ PM_STATE_COUNT
Number of power management states (internal use)
Definition state.h:109
@ PM_STATE_SUSPEND_TO_DISK
Suspend to disk state.
Definition state.h:96
#define NULL
Definition iar_missing_defs.h:20
state
Definition parser_state.h:29
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
Power state information needed to lock a power state.
Definition state.h:173
uint8_t substate_id
Power management sub-state.
Definition state.h:185
enum pm_state state
Power management state.
Definition state.h:179
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
uint32_t min_residency_us
Minimum residency duration in microseconds.
Definition state.h:160
uint32_t exit_latency_us
Worst case latency in microseconds required to exit the idle state.
Definition state.h:167
bool pm_device_disabled
Whether or not this state triggers device power management.
Definition state.h:152
enum pm_state state
Definition state.h:116
Misc utilities.