Zephyr API Documentation 4.3.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
168typedef int (*wuc_api_enable_wakeup_source)(const struct device *dev, uint32_t id);
169
170typedef int (*wuc_api_disable_wakeup_source)(const struct device *dev, uint32_t id);
171
172typedef int (*wuc_api_check_wakeup_source_triggered)(const struct device *dev, uint32_t id);
173
174typedef int (*wuc_api_clear_wakeup_source_triggered)(const struct device *dev, uint32_t id);
175
176__subsystem struct wuc_driver_api {
177 wuc_api_enable_wakeup_source enable;
178 wuc_api_disable_wakeup_source disable;
179 wuc_api_check_wakeup_source_triggered triggered;
180 wuc_api_clear_wakeup_source_triggered clear;
181};
183
193static inline int wuc_enable_wakeup_source(const struct device *dev, uint32_t id)
194{
195 return DEVICE_API_GET(wuc, dev)->enable(dev, id);
196}
197
206static inline int wuc_enable_wakeup_source_dt(const struct wuc_dt_spec *spec)
207{
208 return wuc_enable_wakeup_source(spec->dev, spec->id);
209}
210
220static inline int wuc_disable_wakeup_source(const struct device *dev, uint32_t id)
221{
222 return DEVICE_API_GET(wuc, dev)->disable(dev, id);
223}
224
233static inline int wuc_disable_wakeup_source_dt(const struct wuc_dt_spec *spec)
234{
235 return wuc_disable_wakeup_source(spec->dev, spec->id);
236}
237
249static inline int wuc_check_wakeup_source_triggered(const struct device *dev, uint32_t id)
250{
251 if (DEVICE_API_GET(wuc, dev)->triggered == NULL) {
252 return -ENOSYS;
253 }
254 return DEVICE_API_GET(wuc, dev)->triggered(dev, id);
255}
256
267static inline int wuc_check_wakeup_source_triggered_dt(const struct wuc_dt_spec *spec)
268{
269 return wuc_check_wakeup_source_triggered(spec->dev, spec->id);
270}
271
282static inline int wuc_clear_wakeup_source_triggered(const struct device *dev, uint32_t id)
283{
284 if (DEVICE_API_GET(wuc, dev)->clear == NULL) {
285 return -ENOSYS;
286 }
287 return DEVICE_API_GET(wuc, dev)->clear(dev, id);
288}
289
299static inline int wuc_clear_wakeup_source_triggered_dt(const struct wuc_dt_spec *spec)
300{
301 return wuc_clear_wakeup_source_triggered(spec->dev, spec->id);
302}
303
304#ifdef __cplusplus
305}
306#endif
307
309
310#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:1353
System error numbers.
#define ENOSYS
Function not implemented.
Definition errno.h:82
static int wuc_enable_wakeup_source(const struct device *dev, uint32_t id)
Enable a wakeup source.
Definition wuc.h:193
static int wuc_clear_wakeup_source_triggered(const struct device *dev, uint32_t id)
Clear a wakeup source triggered status.
Definition wuc.h:282
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:233
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:267
static int wuc_check_wakeup_source_triggered(const struct device *dev, uint32_t id)
Check if a wakeup source triggered.
Definition wuc.h:249
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:206
static int wuc_disable_wakeup_source(const struct device *dev, uint32_t id)
Disable a wakeup source.
Definition wuc.h:220
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:299
#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
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