Zephyr API Documentation 4.4.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
devicetree.h
Go to the documentation of this file.
1/*
2 * Copyright 2022 Intel Corporation
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#ifndef ZEPHYR_INCLUDE_DRIVERS_I3C_DEVICETREE_H_
8#define ZEPHYR_INCLUDE_DRIVERS_I3C_DEVICETREE_H_
9
16
17#include <stdint.h>
18
19#include <zephyr/device.h>
20#include <zephyr/devicetree.h>
21#include <zephyr/sys/util.h>
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
36#define I3C_DEVICE_ID_DT(node_id) \
37 { \
38 .pid = ((uint64_t)DT_PROP_BY_IDX(node_id, reg, 1) << 32)\
39 | DT_PROP_BY_IDX(node_id, reg, 2), \
40 }
41
52#define I3C_DEVICE_ID_DT_INST(inst) \
53 I3C_DEVICE_ID_DT(DT_DRV_INST(inst))
54
60
62#define I3C_SUPPORTS_SETAASA BIT(0)
64#define I3C_V1P0_SUPPORT BIT(1)
65
67
73
75#define I3C_CONTROLLER_FLAG_DISABLE_BUS_INIT BIT(0)
77#define I3C_CONTROLLER_FLAG_DISABLE_HJ_AT_INIT BIT(1)
78
80
85#define I3C_CONTROLLER_CONFIG_FLAGS_DT_INST(inst) \
86 (FIELD_PREP(I3C_CONTROLLER_FLAG_DISABLE_BUS_INIT, \
87 DT_INST_PROP(inst, disable_bus_init)) | \
88 FIELD_PREP(I3C_CONTROLLER_FLAG_DISABLE_HJ_AT_INIT, \
89 DT_INST_PROP(inst, disable_hj_at_init)))
90
101#define I3C_DEVICE_DESC_DT(node_id) \
102 { \
103 .bus = DEVICE_DT_GET(DT_BUS(node_id)), \
104 .dev = DEVICE_DT_GET(node_id), \
105 .static_addr = DT_PROP_BY_IDX(node_id, reg, 0), \
106 .pid = ((uint64_t)DT_PROP_BY_IDX(node_id, reg, 1) << 32) | \
107 DT_PROP_BY_IDX(node_id, reg, 2), \
108 .init_dynamic_addr = DT_PROP_OR(node_id, assigned_address, 0), \
109 .flags = FIELD_PREP(I3C_SUPPORTS_SETAASA, DT_PROP(node_id, supports_setaasa)) | \
110 FIELD_PREP(I3C_V1P0_SUPPORT, DT_PROP(node_id, v1p0_support)), \
111 },
112
124#define I3C_DEVICE_DESC_DT_INST(inst) \
125 I3C_DEVICE_DESC_DT(DT_DRV_INST(inst))
126
133#define I3C_DEVICE_DESC_DT_FILTERED(node_id) \
134 COND_CODE_0(DT_PROP_BY_IDX(node_id, reg, 1), \
135 (), (I3C_DEVICE_DESC_DT(node_id)))
136
145#define I3C_DEVICE_ARRAY_DT(node_id) \
146 { \
147 DT_FOREACH_CHILD_STATUS_OKAY( \
148 node_id, \
149 I3C_DEVICE_DESC_DT_FILTERED) \
150 }
151
162#define I3C_DEVICE_ARRAY_DT_INST(inst) \
163 I3C_DEVICE_ARRAY_DT(DT_DRV_INST(inst))
164
190#define I3C_DEVICE_DT_DEFINE(node_id, init_fn, pm, data, config, level, \
191 prio, api, ...) \
192 DEVICE_DT_DEFINE(node_id, init_fn, pm, data, config, level, \
193 prio, api, __VA_ARGS__)
194
203#define I3C_DEVICE_DT_INST_DEFINE(inst, ...) \
204 I3C_DEVICE_DT_DEFINE(DT_DRV_INST(inst), __VA_ARGS__)
205
215#define I3C_I2C_DEVICE_DESC_DT(node_id) \
216 { \
217 .bus = DEVICE_DT_GET(DT_BUS(node_id)), \
218 .addr = DT_PROP_BY_IDX(node_id, reg, 0), \
219 .lvr = DT_PROP_BY_IDX(node_id, reg, 2), \
220 },
221
232#define I3C_I2C_DEVICE_DESC_DT_INST(inst) \
233 I3C_I2C_DEVICE_DESC_DT(DT_DRV_INST(inst))
234
235
242#define I3C_I2C_DEVICE_DESC_DT_FILTERED(node_id) \
243 COND_CODE_0(DT_PROP_BY_IDX(node_id, reg, 1), \
244 (I3C_I2C_DEVICE_DESC_DT(node_id)), ())
245
254#define I3C_I2C_DEVICE_ARRAY_DT(node_id) \
255 { \
256 DT_FOREACH_CHILD_STATUS_OKAY( \
257 node_id, \
258 I3C_I2C_DEVICE_DESC_DT_FILTERED) \
259 }
260
271#define I3C_I2C_DEVICE_ARRAY_DT_INST(inst) \
272 I3C_I2C_DEVICE_ARRAY_DT(DT_DRV_INST(inst))
273
274#ifdef __cplusplus
275}
276#endif
277
281
282#endif /* ZEPHYR_INCLUDE_DRIVERS_I3C_DEVICETREE_H_ */
Devicetree main header.
Misc utilities.