Zephyr API Documentation  3.7.0
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
13#ifdef __cplusplus
14extern "C" {
15#endif
16
109};
110
116
143
152
160
167};
168
185};
186
196#define Z_DT_PHANDLE_01(node_id, prop, idx) \
197 COND_CODE_1(DT_NODE_HAS_STATUS(DT_PHANDLE_BY_IDX(node_id, prop, idx), okay), \
198 (1), (0))
199
209#define Z_PM_STATE_INFO_FROM_DT_CPU(i, node_id) \
210 COND_CODE_1(DT_NODE_HAS_STATUS(DT_PHANDLE_BY_IDX(node_id, cpu_power_states, i), okay), \
211 (PM_STATE_INFO_DT_INIT(DT_PHANDLE_BY_IDX(node_id, cpu_power_states, i)),), ())
212
222#define Z_PM_STATE_FROM_DT_CPU(i, node_id) \
223 COND_CODE_1(DT_NODE_HAS_STATUS(DT_PHANDLE_BY_IDX(node_id, cpu_power_states, i), okay), \
224 (PM_STATE_DT_INIT(DT_PHANDLE_BY_IDX(node_id, cpu_power_states, i)),), ())
225
234#define PM_STATE_INFO_DT_INIT(node_id) \
235 { \
236 .state = PM_STATE_DT_INIT(node_id), \
237 .substate_id = DT_PROP_OR(node_id, substate_id, 0), \
238 .min_residency_us = DT_PROP_OR(node_id, min_residency_us, 0), \
239 .exit_latency_us = DT_PROP_OR(node_id, exit_latency_us, 0), \
240 .pm_device_disabled = DT_PROP(node_id, zephyr_pm_device_disabled), \
241 }
242
249#define PM_STATE_DT_INIT(node_id) \
250 DT_ENUM_IDX(node_id, power_state_name)
251
259#define DT_NUM_CPU_POWER_STATES(node_id) \
260 COND_CODE_1(DT_NODE_HAS_PROP(node_id, cpu_power_states), \
261 (DT_FOREACH_PROP_ELEM_SEP(node_id, cpu_power_states, Z_DT_PHANDLE_01, (+))), \
262 (0))
263
308#define PM_STATE_INFO_LIST_FROM_DT_CPU(node_id) \
309 { \
310 LISTIFY(DT_PROP_LEN_OR(node_id, cpu_power_states, 0), \
311 Z_PM_STATE_INFO_FROM_DT_CPU, (), node_id) \
312 }
313
355#define PM_STATE_LIST_FROM_DT_CPU(node_id) \
356 { \
357 LISTIFY(DT_PROP_LEN_OR(node_id, cpu_power_states, 0), \
358 Z_PM_STATE_FROM_DT_CPU, (), node_id) \
359 }
360
361
362#if defined(CONFIG_PM) || defined(__DOXYGEN__)
372
377#else /* CONFIG_PM */
378
379static inline uint8_t pm_state_cpu_get_all(uint8_t cpu, const struct pm_state_info **states)
380{
381 ARG_UNUSED(cpu);
382 ARG_UNUSED(states);
383
384 return 0;
385}
386
387#endif /* CONFIG_PM */
388
389#ifdef __cplusplus
390}
391#endif
392
393#endif
Devicetree main header.
pm_state
Power management state.
Definition: state.h:27
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.
@ PM_STATE_SOFT_OFF
Soft off state.
Definition: state.h:106
@ PM_STATE_STANDBY
Standby state.
Definition: state.h:70
@ PM_STATE_SUSPEND_TO_RAM
Suspend to ram state.
Definition: state.h:82
@ PM_STATE_ACTIVE
Runtime active state.
Definition: state.h:35
@ PM_STATE_RUNTIME_IDLE
Runtime idle state.
Definition: state.h:46
@ PM_STATE_SUSPEND_TO_IDLE
Suspend to idle state.
Definition: state.h:58
@ PM_STATE_COUNT
Number of power management states (internal use)
Definition: state.h:108
@ PM_STATE_SUSPEND_TO_DISK
Suspend to disk state.
Definition: state.h:95
__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:172
uint8_t substate_id
Power management sub-state.
Definition: state.h:184
enum pm_state state
Power management state.
Definition: state.h:178
Information about a power management state.
Definition: state.h:114
uint8_t substate_id
Some platforms have multiple states that map to one Zephyr power state.
Definition: state.h:142
uint32_t min_residency_us
Minimum residency duration in microseconds.
Definition: state.h:159
uint32_t exit_latency_us
Worst case latency in microseconds required to exit the idle state.
Definition: state.h:166
bool pm_device_disabled
Whether or not this state triggers device power management.
Definition: state.h:151
enum pm_state state
Definition: state.h:115
Misc utilities.