Zephyr API Documentation 4.4.0-rc1
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
wuc.h
Go to the documentation of this file.
1/*
2 * Copyright 2026 NXP
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
12
13#ifndef ZEPHYR_INCLUDE_DRIVERS_WUC_H_
14#define ZEPHYR_INCLUDE_DRIVERS_WUC_H_
15
24
25#include <errno.h>
26#include <stddef.h>
27
28#include <zephyr/device.h>
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
37 const struct device *dev;
40};
41
72#define WUC_DT_SPEC_GET_BY_IDX(node_id, idx) \
73 {.dev = DEVICE_DT_GET(DT_WUC_BY_IDX(node_id, idx)), .id = DT_WUC_ID_BY_IDX(node_id, idx)}
74
91#define WUC_DT_SPEC_GET_BY_IDX_OR(node_id, idx, default_value) \
92 COND_CODE_1(DT_NODE_HAS_PROP(node_id, wakeup_ctrls), \
93 (WUC_DT_SPEC_GET_BY_IDX(node_id, idx)), \
94 (default_value))
95
103#define WUC_DT_SPEC_GET(node_id) WUC_DT_SPEC_GET_BY_IDX(node_id, 0)
104
114#define WUC_DT_SPEC_GET_OR(node_id, default_value) \
115 WUC_DT_SPEC_GET_BY_IDX_OR(node_id, 0, default_value)
116
126#define WUC_DT_SPEC_INST_GET_BY_IDX(inst, idx) WUC_DT_SPEC_GET_BY_IDX(DT_DRV_INST(inst), idx)
127
138#define WUC_DT_SPEC_INST_GET_BY_IDX_OR(inst, idx, default_value) \
139 COND_CODE_1(DT_PROP_HAS_IDX(DT_DRV_INST(inst), wakeup_ctrls, idx), \
140 (WUC_DT_SPEC_GET_BY_IDX(DT_DRV_INST(inst), idx)), \
141 (default_value))
142
150#define WUC_DT_SPEC_INST_GET(inst) WUC_DT_SPEC_INST_GET_BY_IDX(inst, 0)
151
161#define WUC_DT_SPEC_INST_GET_OR(inst, default_value) \
162 WUC_DT_SPEC_INST_GET_BY_IDX_OR(inst, 0, default_value)
163
168
173typedef int (*wuc_api_enable_wakeup_source)(const struct device *dev, uint32_t id);
174
179typedef int (*wuc_api_disable_wakeup_source)(const struct device *dev, uint32_t id);
180
185typedef int (*wuc_api_check_wakeup_source_triggered)(const struct device *dev, uint32_t id);
186
191typedef int (*wuc_api_clear_wakeup_source_triggered)(const struct device *dev, uint32_t id);
192
214
217
227static inline int wuc_enable_wakeup_source(const struct device *dev, uint32_t id)
228{
229 return DEVICE_API_GET(wuc, dev)->enable(dev, id);
230}
231
240static inline int wuc_enable_wakeup_source_dt(const struct wuc_dt_spec *spec)
241{
242 return wuc_enable_wakeup_source(spec->dev, spec->id);
243}
244
254static inline int wuc_disable_wakeup_source(const struct device *dev, uint32_t id)
255{
256 return DEVICE_API_GET(wuc, dev)->disable(dev, id);
257}
258
267static inline int wuc_disable_wakeup_source_dt(const struct wuc_dt_spec *spec)
268{
269 return wuc_disable_wakeup_source(spec->dev, spec->id);
270}
271
283static inline int wuc_check_wakeup_source_triggered(const struct device *dev, uint32_t id)
284{
285 if (DEVICE_API_GET(wuc, dev)->triggered == NULL) {
286 return -ENOSYS;
287 }
288 return DEVICE_API_GET(wuc, dev)->triggered(dev, id);
289}
290
301static inline int wuc_check_wakeup_source_triggered_dt(const struct wuc_dt_spec *spec)
302{
303 return wuc_check_wakeup_source_triggered(spec->dev, spec->id);
304}
305
316static inline int wuc_clear_wakeup_source_triggered(const struct device *dev, uint32_t id)
317{
318 if (DEVICE_API_GET(wuc, dev)->clear == NULL) {
319 return -ENOSYS;
320 }
321 return DEVICE_API_GET(wuc, dev)->clear(dev, id);
322}
323
333static inline int wuc_clear_wakeup_source_triggered_dt(const struct wuc_dt_spec *spec)
334{
335 return wuc_clear_wakeup_source_triggered(spec->dev, spec->id);
336}
337
338#ifdef __cplusplus
339}
340#endif
341
343
344#endif /* ZEPHYR_INCLUDE_DRIVERS_WUC_H_ */
#define DEVICE_API_GET(_class, _dev)
Expands to the pointer of a device's API for a given class.
Definition device.h:1375
System error numbers.
#define ENOSYS
Function not implemented.
Definition errno.h:82
int(* wuc_api_clear_wakeup_source_triggered)(const struct device *dev, uint32_t id)
Callback API to clear a wakeup source triggered status.
Definition wuc.h:191
int(* wuc_api_check_wakeup_source_triggered)(const struct device *dev, uint32_t id)
Callback API to check if a wakeup source triggered.
Definition wuc.h:185
int(* wuc_api_enable_wakeup_source)(const struct device *dev, uint32_t id)
Callback API to enable a wakeup source.
Definition wuc.h:173
int(* wuc_api_disable_wakeup_source)(const struct device *dev, uint32_t id)
Callback API to disable a wakeup source.
Definition wuc.h:179
static int wuc_enable_wakeup_source(const struct device *dev, uint32_t id)
Enable a wakeup source.
Definition wuc.h:227
static int wuc_clear_wakeup_source_triggered(const struct device *dev, uint32_t id)
Clear a wakeup source triggered status.
Definition wuc.h:316
static int wuc_disable_wakeup_source_dt(const struct wuc_dt_spec *spec)
Disable a wakeup source using a wuc_dt_spec.
Definition wuc.h:267
static int wuc_check_wakeup_source_triggered_dt(const struct wuc_dt_spec *spec)
Check if a wakeup source triggered using a wuc_dt_spec.
Definition wuc.h:301
static int wuc_check_wakeup_source_triggered(const struct device *dev, uint32_t id)
Check if a wakeup source triggered.
Definition wuc.h:283
static int wuc_enable_wakeup_source_dt(const struct wuc_dt_spec *spec)
Enable a wakeup source using a wuc_dt_spec.
Definition wuc.h:240
static int wuc_disable_wakeup_source(const struct device *dev, uint32_t id)
Disable a wakeup source.
Definition wuc.h:254
static int wuc_clear_wakeup_source_triggered_dt(const struct wuc_dt_spec *spec)
Clear a wakeup source triggered status using a wuc_dt_spec.
Definition wuc.h:333
#define NULL
Definition iar_missing_defs.h:20
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
Runtime device structure (in ROM) per driver instance.
Definition device.h:513
<span class="mlabel">Driver Operations</span> WUC driver operations
Definition wuc.h:196
wuc_api_check_wakeup_source_triggered triggered
<span class="op-badge op-opt" title="This operation MAY optionally be implemented by the driver....
Definition wuc.h:208
wuc_api_disable_wakeup_source disable
<span class="op-badge op-req" title="This operation MUST be implemented by the driver....
Definition wuc.h:204
wuc_api_enable_wakeup_source enable
<span class="op-badge op-req" title="This operation MUST be implemented by the driver....
Definition wuc.h:200
wuc_api_clear_wakeup_source_triggered clear
<span class="op-badge op-opt" title="This operation MAY optionally be implemented by the driver....
Definition wuc.h:212
Wakeup controller device configuration.
Definition wuc.h:35
const struct device * dev
Wakeup controller device.
Definition wuc.h:37
uint32_t id
Wakeup source identifier.
Definition wuc.h:39