Zephyr API Documentation 4.4.99
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
226static inline int wuc_enable_wakeup_source(const struct device *dev, uint32_t id)
227{
228 return DEVICE_API_GET(wuc, dev)->enable(dev, id);
229}
230
238static inline int wuc_enable_wakeup_source_dt(const struct wuc_dt_spec *spec)
239{
240 return wuc_enable_wakeup_source(spec->dev, spec->id);
241}
242
251static inline int wuc_disable_wakeup_source(const struct device *dev, uint32_t id)
252{
253 return DEVICE_API_GET(wuc, dev)->disable(dev, id);
254}
255
263static inline int wuc_disable_wakeup_source_dt(const struct wuc_dt_spec *spec)
264{
265 return wuc_disable_wakeup_source(spec->dev, spec->id);
266}
267
278static inline int wuc_check_wakeup_source_triggered(const struct device *dev, uint32_t id)
279{
280 if (DEVICE_API_GET(wuc, dev)->triggered == NULL) {
281 return -ENOSYS;
282 }
283 return DEVICE_API_GET(wuc, dev)->triggered(dev, id);
284}
285
295static inline int wuc_check_wakeup_source_triggered_dt(const struct wuc_dt_spec *spec)
296{
297 return wuc_check_wakeup_source_triggered(spec->dev, spec->id);
298}
299
309static inline int wuc_clear_wakeup_source_triggered(const struct device *dev, uint32_t id)
310{
311 if (DEVICE_API_GET(wuc, dev)->clear == NULL) {
312 return -ENOSYS;
313 }
314 return DEVICE_API_GET(wuc, dev)->clear(dev, id);
315}
316
325static inline int wuc_clear_wakeup_source_triggered_dt(const struct wuc_dt_spec *spec)
326{
327 return wuc_clear_wakeup_source_triggered(spec->dev, spec->id);
328}
329
330#ifdef __cplusplus
331}
332#endif
333
335
336#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:1425
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:226
static int wuc_clear_wakeup_source_triggered(const struct device *dev, uint32_t id)
Clear a wakeup source triggered status.
Definition wuc.h:309
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:263
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:295
static int wuc_check_wakeup_source_triggered(const struct device *dev, uint32_t id)
Check if a wakeup source triggered.
Definition wuc.h:278
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:238
static int wuc_disable_wakeup_source(const struct device *dev, uint32_t id)
Disable a wakeup source.
Definition wuc.h:251
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:325
__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