Zephyr API Documentation 4.0.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
devicetree.h
Go to the documentation of this file.
1/*
2 * SPDX-License-Identifier: Apache-2.0
3 * Copyright (c) 2020 Nordic Semiconductor
4 * Copyright (c) 2020, Linaro Ltd.
5 *
6 * Not a generated file. Feel free to modify.
7 */
8
16#ifndef ZEPHYR_INCLUDE_DEVICETREE_H_
17#define ZEPHYR_INCLUDE_DEVICETREE_H_
18
19#include <zephyr/devicetree_generated.h>
21
22#if !defined(_LINKER) && !defined(_ASMLANGUAGE)
23#include <stdint.h>
24#endif
25
26#include <zephyr/sys/util.h>
27
37/*
38 * Property suffixes
39 * -----------------
40 *
41 * These are the optional parts that come after the _P_<property>
42 * part in DT_N_<path-id>_P_<property-id> macros, or the "prop-suf"
43 * nonterminal in the DT guide's macros.bnf file.
44 *
45 * Before adding new ones, check this list to avoid conflicts. If any
46 * are missing from this list, please add them. It should be complete.
47 *
48 * _ENUM_IDX: property's value as an index into bindings enum
49 * _ENUM_VAL_<val>_EXISTS property's value as a token exists
50 * _EXISTS: property is defined
51 * _FOREACH_PROP_ELEM: helper for "iterating" over values in the property
52 * _FOREACH_PROP_ELEM_VARGS: foreach functions with variable number of arguments
53 * _IDX_<i>: logical index into property
54 * _IDX_<i>_EXISTS: logical index into property is defined
55 * _IDX_<i>_PH: phandle array's phandle by index (or phandle, phandles)
56 * _IDX_<i>_STRING_TOKEN: string array element value as a token
57 * _IDX_<i>_STRING_UPPER_TOKEN: string array element value as a uppercased token
58 * _IDX <i>_STRING_UNQUOTED: string array element value as a sequence of tokens, with no quotes
59 * _IDX_<i>_VAL_<val>: phandle array's specifier value by index
60 * _IDX_<i>_VAL_<val>_EXISTS: cell value exists, by index
61 * _LEN: property logical length
62 * _NAME_<name>_PH: phandle array's phandle by name
63 * _NAME_<name>_VAL_<val>: phandle array's property specifier by name
64 * _NAME_<name>_VAL_<val>_EXISTS: cell value exists, by name
65 * _STRING_TOKEN: string property's value as a token
66 * _STRING_UPPER_TOKEN: like _STRING_TOKEN, but uppercased
67 * _STRING_UNQUOTED: string property's value as a sequence of tokens, with no quotes
68 */
69
83#define DT_INVALID_NODE _
84
88#define DT_ROOT DT_N
89
140#define DT_PATH(...) DT_PATH_INTERNAL(__VA_ARGS__)
141
196#define DT_NODELABEL(label) DT_CAT(DT_N_NODELABEL_, label)
197
236#define DT_ALIAS(alias) DT_CAT(DT_N_ALIAS_, alias)
237
243#define DT_HAS_ALIAS(alias_name) DT_NODE_EXISTS(DT_ALIAS(alias_name))
244
339#define DT_INST(inst, compat) UTIL_CAT(DT_N_INST, DT_DASH(inst, compat))
340
364#define DT_PARENT(node_id) DT_CAT(node_id, _PARENT)
365
389#define DT_GPARENT(node_id) DT_PARENT(DT_PARENT(node_id))
390
426#define DT_CHILD(node_id, child) UTIL_CAT(node_id, DT_S_PREFIX(child))
427
469#define DT_COMPAT_GET_ANY_STATUS_OKAY(compat) \
470 COND_CODE_1(DT_HAS_COMPAT_STATUS_OKAY(compat), \
471 (DT_INST(0, compat)), \
472 (DT_INVALID_NODE))
473
501#define DT_NODE_PATH(node_id) DT_CAT(node_id, _PATH)
502
527#define DT_NODE_FULL_NAME(node_id) DT_CAT(node_id, _FULL_NAME)
528
555#define DT_NODE_FULL_NAME_UNQUOTED(node_id) DT_CAT(node_id, _FULL_NAME_UNQUOTED)
556
583#define DT_NODE_FULL_NAME_TOKEN(node_id) DT_CAT(node_id, _FULL_NAME_TOKEN)
584
613#define DT_NODE_FULL_NAME_UPPER_TOKEN(node_id) DT_CAT(node_id, _FULL_NAME_UPPER_TOKEN)
614
641#define DT_NODE_CHILD_IDX(node_id) DT_CAT(node_id, _CHILD_IDX)
642
649#define DT_CHILD_NUM(node_id) DT_CAT(node_id, _CHILD_NUM)
650
651
659#define DT_CHILD_NUM_STATUS_OKAY(node_id) \
660 DT_CAT(node_id, _CHILD_NUM_STATUS_OKAY)
661
682#define DT_SAME_NODE(node_id1, node_id2) \
683 (DT_DEP_ORD(node_id1) == (DT_DEP_ORD(node_id2)))
684
709#define DT_NODELABEL_STRING_ARRAY(node_id) \
710 { DT_FOREACH_NODELABEL(node_id, DT_NODELABEL_STRING_ARRAY_ENTRY_INTERNAL) }
711
752#define DT_PROP(node_id, prop) DT_CAT3(node_id, _P_, prop)
753
786#define DT_PROP_LEN(node_id, prop) DT_CAT4(node_id, _P_, prop, _LEN)
787
802#define DT_PROP_LEN_OR(node_id, prop, default_value) \
803 COND_CODE_1(DT_NODE_HAS_PROP(node_id, prop), \
804 (DT_PROP_LEN(node_id, prop)), (default_value))
805
826#define DT_PROP_HAS_IDX(node_id, prop, idx) \
827 IS_ENABLED(DT_CAT6(node_id, _P_, prop, _IDX_, idx, _EXISTS))
828
861#define DT_PROP_HAS_NAME(node_id, prop, name) \
862 IS_ENABLED(DT_CAT6(node_id, _P_, prop, _NAME_, name, _EXISTS))
863
898#define DT_PROP_BY_IDX(node_id, prop, idx) \
899 DT_CAT5(node_id, _P_, prop, _IDX_, idx)
900
909#define DT_PROP_LAST(node_id, prop) \
910 DT_PROP_BY_IDX(node_id, prop, UTIL_DEC(DT_PROP_LEN(node_id, prop)))
911
925#define DT_PROP_OR(node_id, prop, default_value) \
926 COND_CODE_1(DT_NODE_HAS_PROP(node_id, prop), \
927 (DT_PROP(node_id, prop)), (default_value))
928
984#define DT_ENUM_IDX_BY_IDX(node_id, prop, idx) \
985 DT_CAT6(node_id, _P_, prop, _IDX_, idx, _ENUM_IDX)
986
993#define DT_ENUM_IDX(node_id, prop) DT_ENUM_IDX_BY_IDX(node_id, prop, 0)
994
1010#define DT_ENUM_IDX_BY_IDX_OR(node_id, prop, idx, default_idx_value) \
1011 COND_CODE_1(DT_PROP_HAS_IDX(node_id, prop, idx), \
1012 (DT_ENUM_IDX_BY_IDX(node_id, prop, idx)), (default_idx_value))
1013
1022#define DT_ENUM_IDX_OR(node_id, prop, default_idx_value) \
1023 DT_ENUM_IDX_BY_IDX_OR(node_id, prop, 0, default_idx_value)
1024
1034#define DT_ENUM_HAS_VALUE_BY_IDX(node_id, prop, idx, value) \
1035 IS_ENABLED(DT_CAT8(node_id, _P_, prop, _IDX_, idx, _ENUM_VAL_, value, _EXISTS))
1036
1044#define DT_ENUM_HAS_VALUE(node_id, prop, value) \
1045 DT_ENUM_HAS_VALUE_BY_IDX(node_id, prop, 0, value)
1046
1106#define DT_STRING_TOKEN(node_id, prop) \
1107 DT_CAT4(node_id, _P_, prop, _STRING_TOKEN)
1108
1122#define DT_STRING_TOKEN_OR(node_id, prop, default_value) \
1123 COND_CODE_1(DT_NODE_HAS_PROP(node_id, prop), \
1124 (DT_STRING_TOKEN(node_id, prop)), (default_value))
1125
1183#define DT_STRING_UPPER_TOKEN(node_id, prop) \
1184 DT_CAT4(node_id, _P_, prop, _STRING_UPPER_TOKEN)
1185
1200#define DT_STRING_UPPER_TOKEN_OR(node_id, prop, default_value) \
1201 COND_CODE_1(DT_NODE_HAS_PROP(node_id, prop), \
1202 (DT_STRING_UPPER_TOKEN(node_id, prop)), (default_value))
1203
1244#define DT_STRING_UNQUOTED(node_id, prop) \
1245 DT_CAT4(node_id, _P_, prop, _STRING_UNQUOTED)
1246
1261#define DT_STRING_UNQUOTED_OR(node_id, prop, default_value) \
1262 COND_CODE_1(DT_NODE_HAS_PROP(node_id, prop), \
1263 (DT_STRING_UNQUOTED(node_id, prop)), (default_value))
1264
1312#define DT_STRING_TOKEN_BY_IDX(node_id, prop, idx) \
1313 DT_CAT6(node_id, _P_, prop, _IDX_, idx, _STRING_TOKEN)
1314
1362#define DT_STRING_UPPER_TOKEN_BY_IDX(node_id, prop, idx) \
1363 DT_CAT6(node_id, _P_, prop, _IDX_, idx, _STRING_UPPER_TOKEN)
1364
1405#define DT_STRING_UNQUOTED_BY_IDX(node_id, prop, idx) \
1406 DT_CAT6(node_id, _P_, prop, _IDX_, idx, _STRING_UNQUOTED)
1407
1408/*
1409 * phandle properties
1410 *
1411 * These are special-cased to manage the impedance mismatch between
1412 * phandles, which are just uint32_t node properties that only make sense
1413 * within the tree itself, and C values.
1414 */
1415
1461#define DT_PROP_BY_PHANDLE_IDX(node_id, phs, idx, prop) \
1462 DT_PROP(DT_PHANDLE_BY_IDX(node_id, phs, idx), prop)
1463
1483#define DT_PROP_BY_PHANDLE_IDX_OR(node_id, phs, idx, prop, default_value) \
1484 DT_PROP_OR(DT_PHANDLE_BY_IDX(node_id, phs, idx), prop, default_value)
1485
1497#define DT_PROP_BY_PHANDLE(node_id, ph, prop) \
1498 DT_PROP_BY_PHANDLE_IDX(node_id, ph, 0, prop)
1499
1554#define DT_PHA_BY_IDX(node_id, pha, idx, cell) \
1555 DT_CAT7(node_id, _P_, pha, _IDX_, idx, _VAL_, cell)
1556
1580#define DT_PHA_BY_IDX_OR(node_id, pha, idx, cell, default_value) \
1581 DT_PROP_OR(node_id, DT_CAT5(pha, _IDX_, idx, _VAL_, cell), default_value)
1582
1590#define DT_PHA(node_id, pha, cell) DT_PHA_BY_IDX(node_id, pha, 0, cell)
1591
1606#define DT_PHA_OR(node_id, pha, cell, default_value) \
1607 DT_PHA_BY_IDX_OR(node_id, pha, 0, cell, default_value)
1608
1649#define DT_PHA_BY_NAME(node_id, pha, name, cell) \
1650 DT_CAT7(node_id, _P_, pha, _NAME_, name, _VAL_, cell)
1651
1673#define DT_PHA_BY_NAME_OR(node_id, pha, name, cell, default_value) \
1674 DT_PROP_OR(node_id, DT_CAT5(pha, _NAME_, name, _VAL_, cell), default_value)
1675
1723#define DT_PHANDLE_BY_NAME(node_id, pha, name) \
1724 DT_CAT6(node_id, _P_, pha, _NAME_, name, _PH)
1725
1775#define DT_PHANDLE_BY_IDX(node_id, prop, idx) \
1776 DT_CAT6(node_id, _P_, prop, _IDX_, idx, _PH)
1777
1789#define DT_PHANDLE(node_id, prop) DT_PHANDLE_BY_IDX(node_id, prop, 0)
1790
1837#define DT_NUM_RANGES(node_id) DT_CAT(node_id, _RANGES_NUM)
1838
1891#define DT_RANGES_HAS_IDX(node_id, idx) \
1892 IS_ENABLED(DT_CAT4(node_id, _RANGES_IDX_, idx, _EXISTS))
1893
1946#define DT_RANGES_HAS_CHILD_BUS_FLAGS_AT_IDX(node_id, idx) \
1947 IS_ENABLED(DT_CAT4(node_id, _RANGES_IDX_, idx, _VAL_CHILD_BUS_FLAGS_EXISTS))
1948
1986#define DT_RANGES_CHILD_BUS_FLAGS_BY_IDX(node_id, idx) \
1987 DT_CAT4(node_id, _RANGES_IDX_, idx, _VAL_CHILD_BUS_FLAGS)
1988
2035#define DT_RANGES_CHILD_BUS_ADDRESS_BY_IDX(node_id, idx) \
2036 DT_CAT4(node_id, _RANGES_IDX_, idx, _VAL_CHILD_BUS_ADDRESS)
2037
2084#define DT_RANGES_PARENT_BUS_ADDRESS_BY_IDX(node_id, idx) \
2085 DT_CAT4(node_id, _RANGES_IDX_, idx, _VAL_PARENT_BUS_ADDRESS)
2086
2133#define DT_RANGES_LENGTH_BY_IDX(node_id, idx) \
2134 DT_CAT4(node_id, _RANGES_IDX_, idx, _VAL_LENGTH)
2135
2175#define DT_FOREACH_RANGE(node_id, fn) \
2176 DT_CAT(node_id, _FOREACH_RANGE)(fn)
2177
2223#define DT_NODE_VENDOR_BY_IDX(node_id, idx) \
2224 DT_CAT3(node_id, _COMPAT_VENDOR_IDX_, idx)
2225
2238#define DT_NODE_VENDOR_HAS_IDX(node_id, idx) \
2239 IS_ENABLED(DT_CAT4(node_id, _COMPAT_VENDOR_IDX_, idx, _EXISTS))
2240
2255#define DT_NODE_VENDOR_BY_IDX_OR(node_id, idx, default_value) \
2256 COND_CODE_1(DT_NODE_VENDOR_HAS_IDX(node_id, idx), \
2257 (DT_NODE_VENDOR_BY_IDX(node_id, idx)), (default_value))
2258
2267#define DT_NODE_VENDOR_OR(node_id, default_value) \
2268 DT_NODE_VENDOR_BY_IDX_OR(node_id, 0, default_value)
2269
2299#define DT_NODE_MODEL_BY_IDX(node_id, idx) \
2300 DT_CAT3(node_id, _COMPAT_MODEL_IDX_, idx)
2301
2314#define DT_NODE_MODEL_HAS_IDX(node_id, idx) \
2315 IS_ENABLED(DT_CAT4(node_id, _COMPAT_MODEL_IDX_, idx, _EXISTS))
2316
2331#define DT_NODE_MODEL_BY_IDX_OR(node_id, idx, default_value) \
2332 COND_CODE_1(DT_NODE_MODEL_HAS_IDX(node_id, idx), \
2333 (DT_NODE_MODEL_BY_IDX(node_id, idx)), (default_value))
2334
2343#define DT_NODE_MODEL_OR(node_id, default_value) \
2344 DT_NODE_MODEL_BY_IDX_OR(node_id, 0, default_value)
2345
2363#define DT_NUM_REGS(node_id) DT_CAT(node_id, _REG_NUM)
2364
2376#define DT_REG_HAS_IDX(node_id, idx) \
2377 IS_ENABLED(DT_CAT4(node_id, _REG_IDX_, idx, _EXISTS))
2378
2390#define DT_REG_HAS_NAME(node_id, name) \
2391 IS_ENABLED(DT_CAT4(node_id, _REG_NAME_, name, _EXISTS))
2392
2404#define DT_REG_ADDR_BY_IDX_RAW(node_id, idx) \
2405 DT_CAT4(node_id, _REG_IDX_, idx, _VAL_ADDRESS)
2406
2418#define DT_REG_ADDR_RAW(node_id) \
2419 DT_REG_ADDR_BY_IDX_RAW(node_id, 0)
2420
2427#define DT_REG_ADDR_BY_IDX(node_id, idx) \
2428 DT_U32_C(DT_REG_ADDR_BY_IDX_RAW(node_id, idx))
2429
2441#define DT_REG_SIZE_BY_IDX(node_id, idx) \
2442 DT_U32_C(DT_CAT4(node_id, _REG_IDX_, idx, _VAL_SIZE))
2443
2451#define DT_REG_ADDR(node_id) DT_REG_ADDR_BY_IDX(node_id, 0)
2452
2463#define DT_REG_ADDR_U64(node_id) DT_U64_C(DT_REG_ADDR_BY_IDX_RAW(node_id, 0))
2464
2472#define DT_REG_SIZE(node_id) DT_REG_SIZE_BY_IDX(node_id, 0)
2473
2480#define DT_REG_ADDR_BY_NAME(node_id, name) \
2481 DT_U32_C(DT_CAT4(node_id, _REG_NAME_, name, _VAL_ADDRESS))
2482
2491#define DT_REG_ADDR_BY_NAME_OR(node_id, name, default_value) \
2492 COND_CODE_1(DT_REG_HAS_NAME(node_id, name), \
2493 (DT_REG_ADDR_BY_NAME(node_id, name)), (default_value))
2494
2507#define DT_REG_ADDR_BY_NAME_U64(node_id, name) \
2508 DT_U64_C(DT_CAT4(node_id, _REG_NAME_, name, _VAL_ADDRESS))
2509
2516#define DT_REG_SIZE_BY_NAME(node_id, name) \
2517 DT_U32_C(DT_CAT4(node_id, _REG_NAME_, name, _VAL_SIZE))
2518
2527#define DT_REG_SIZE_BY_NAME_OR(node_id, name, default_value) \
2528 COND_CODE_1(DT_REG_HAS_NAME(node_id, name), \
2529 (DT_REG_SIZE_BY_NAME(node_id, name)), (default_value))
2530
2531
2550#define DT_NUM_IRQS(node_id) DT_CAT(node_id, _IRQ_NUM)
2551
2576#define DT_NUM_NODELABELS(node_id) DT_CAT(node_id, _NODELABEL_NUM)
2577
2584#define DT_IRQ_LEVEL(node_id) DT_CAT(node_id, _IRQ_LEVEL)
2585
2596#define DT_IRQ_HAS_IDX(node_id, idx) \
2597 IS_ENABLED(DT_CAT4(node_id, _IRQ_IDX_, idx, _EXISTS))
2598
2609#define DT_IRQ_HAS_CELL_AT_IDX(node_id, idx, cell) \
2610 IS_ENABLED(DT_CAT6(node_id, _IRQ_IDX_, idx, _VAL_, cell, _EXISTS))
2611
2619#define DT_IRQ_HAS_CELL(node_id, cell) DT_IRQ_HAS_CELL_AT_IDX(node_id, 0, cell)
2620
2630#define DT_IRQ_HAS_NAME(node_id, name) \
2631 IS_ENABLED(DT_CAT4(node_id, _IRQ_NAME_, name, _VAL_irq_EXISTS))
2632
2668#define DT_IRQ_BY_IDX(node_id, idx, cell) \
2669 DT_CAT5(node_id, _IRQ_IDX_, idx, _VAL_, cell)
2670
2686#define DT_IRQ_BY_NAME(node_id, name, cell) \
2687 DT_CAT5(node_id, _IRQ_NAME_, name, _VAL_, cell)
2688
2696#define DT_IRQ(node_id, cell) DT_IRQ_BY_IDX(node_id, 0, cell)
2697
2740#define DT_IRQ_INTC_BY_IDX(node_id, idx) \
2741 DT_CAT4(node_id, _IRQ_IDX_, idx, _CONTROLLER)
2742
2787#define DT_IRQ_INTC_BY_NAME(node_id, name) \
2788 DT_CAT4(node_id, _IRQ_NAME_, name, _CONTROLLER)
2789
2829#define DT_IRQ_INTC(node_id) \
2830 DT_IRQ_INTC_BY_IDX(node_id, 0)
2831
2836/* DT helper macro to encode a node's IRQN to level 1 according to the multi-level scheme */
2837#define DT_IRQN_L1_INTERNAL(node_id, idx) DT_IRQ_BY_IDX(node_id, idx, irq)
2838/* DT helper macro to encode a node's IRQN to level 2 according to the multi-level scheme */
2839#define DT_IRQN_L2_INTERNAL(node_id, idx) \
2840 (IRQ_TO_L2(DT_IRQN_L1_INTERNAL(node_id, idx)) | \
2841 DT_IRQ(DT_IRQ_INTC_BY_IDX(node_id, idx), irq))
2842/* DT helper macro to encode a node's IRQN to level 3 according to the multi-level scheme */
2843#define DT_IRQN_L3_INTERNAL(node_id, idx) \
2844 (IRQ_TO_L3(DT_IRQN_L1_INTERNAL(node_id, idx)) | \
2845 IRQ_TO_L2(DT_IRQ(DT_IRQ_INTC_BY_IDX(node_id, idx), irq)) | \
2846 DT_IRQ(DT_IRQ_INTC(DT_IRQ_INTC_BY_IDX(node_id, idx)), irq))
2847/* DT helper macro for the macros above */
2848#define DT_IRQN_LVL_INTERNAL(node_id, idx, level) DT_CAT3(DT_IRQN_L, level, _INTERNAL)(node_id, idx)
2849
2854#define DT_MULTI_LEVEL_IRQN_INTERNAL(node_id, idx) \
2855 DT_IRQN_LVL_INTERNAL(node_id, idx, DT_IRQ_LEVEL(node_id))
2856
2869#define DT_IRQN_BY_IDX(node_id, idx) \
2870 COND_CODE_1(IS_ENABLED(CONFIG_MULTI_LEVEL_INTERRUPTS), \
2871 (DT_MULTI_LEVEL_IRQN_INTERNAL(node_id, idx)), \
2872 (DT_IRQ_BY_IDX(node_id, idx, irq)))
2873
2884#define DT_IRQN(node_id) DT_IRQN_BY_IDX(node_id, 0)
2885
2904#define DT_CHOSEN(prop) DT_CAT(DT_CHOSEN_, prop)
2905
2912#define DT_HAS_CHOSEN(prop) IS_ENABLED(DT_CAT3(DT_CHOSEN_, prop, _EXISTS))
2913
2933#define DT_FOREACH_NODE(fn) DT_FOREACH_HELPER(fn)
2934
2947#define DT_FOREACH_NODE_VARGS(fn, ...) DT_FOREACH_VARGS_HELPER(fn, __VA_ARGS__)
2948
2960#define DT_FOREACH_STATUS_OKAY_NODE(fn) DT_FOREACH_OKAY_HELPER(fn)
2961
2976#define DT_FOREACH_STATUS_OKAY_NODE_VARGS(fn, ...) DT_FOREACH_OKAY_VARGS_HELPER(fn, __VA_ARGS__)
2977
3024#define DT_FOREACH_ANCESTOR(node_id, fn) \
3025 DT_CAT(node_id, _FOREACH_ANCESTOR)(fn)
3026
3070#define DT_FOREACH_CHILD(node_id, fn) \
3071 DT_CAT(node_id, _FOREACH_CHILD)(fn)
3072
3113#define DT_FOREACH_CHILD_SEP(node_id, fn, sep) \
3114 DT_CAT(node_id, _FOREACH_CHILD_SEP)(fn, sep)
3115
3131#define DT_FOREACH_CHILD_VARGS(node_id, fn, ...) \
3132 DT_CAT(node_id, _FOREACH_CHILD_VARGS)(fn, __VA_ARGS__)
3133
3149#define DT_FOREACH_CHILD_SEP_VARGS(node_id, fn, sep, ...) \
3150 DT_CAT(node_id, _FOREACH_CHILD_SEP_VARGS)(fn, sep, __VA_ARGS__)
3151
3167#define DT_FOREACH_CHILD_STATUS_OKAY(node_id, fn) \
3168 DT_CAT(node_id, _FOREACH_CHILD_STATUS_OKAY)(fn)
3169
3186#define DT_FOREACH_CHILD_STATUS_OKAY_SEP(node_id, fn, sep) \
3187 DT_CAT(node_id, _FOREACH_CHILD_STATUS_OKAY_SEP)(fn, sep)
3188
3208#define DT_FOREACH_CHILD_STATUS_OKAY_VARGS(node_id, fn, ...) \
3209 DT_CAT(node_id, _FOREACH_CHILD_STATUS_OKAY_VARGS)(fn, __VA_ARGS__)
3210
3229#define DT_FOREACH_CHILD_STATUS_OKAY_SEP_VARGS(node_id, fn, sep, ...) \
3230 DT_CAT(node_id, _FOREACH_CHILD_STATUS_OKAY_SEP_VARGS)(fn, sep, __VA_ARGS__)
3231
3282#define DT_FOREACH_PROP_ELEM(node_id, prop, fn) \
3283 DT_CAT4(node_id, _P_, prop, _FOREACH_PROP_ELEM)(fn)
3284
3327#define DT_FOREACH_PROP_ELEM_SEP(node_id, prop, fn, sep) \
3328 DT_CAT4(node_id, _P_, prop, _FOREACH_PROP_ELEM_SEP)(fn, sep)
3329
3350#define DT_FOREACH_PROP_ELEM_VARGS(node_id, prop, fn, ...) \
3351 DT_CAT4(node_id, _P_, prop, _FOREACH_PROP_ELEM_VARGS)(fn, __VA_ARGS__)
3352
3369#define DT_FOREACH_PROP_ELEM_SEP_VARGS(node_id, prop, fn, sep, ...) \
3370 DT_CAT4(node_id, _P_, prop, _FOREACH_PROP_ELEM_SEP_VARGS)( \
3371 fn, sep, __VA_ARGS__)
3372
3426#define DT_FOREACH_STATUS_OKAY(compat, fn) \
3427 COND_CODE_1(DT_HAS_COMPAT_STATUS_OKAY(compat), \
3428 (UTIL_CAT(DT_FOREACH_OKAY_, compat)(fn)), \
3429 ())
3430
3475#define DT_FOREACH_STATUS_OKAY_VARGS(compat, fn, ...) \
3476 COND_CODE_1(DT_HAS_COMPAT_STATUS_OKAY(compat), \
3477 (DT_CAT(DT_FOREACH_OKAY_VARGS_, \
3478 compat)(fn, __VA_ARGS__)), \
3479 ())
3480
3493#define DT_COMPAT_FOREACH_STATUS_OKAY_VARGS(compat, fn, ...) \
3494 COND_CODE_1(DT_HAS_COMPAT_STATUS_OKAY(compat), \
3495 (UTIL_CAT(DT_FOREACH_OKAY_INST_VARGS_, \
3496 compat)(fn, compat, __VA_ARGS__)), \
3497 ())
3498
3499
3538#define DT_FOREACH_NODELABEL(node_id, fn) DT_CAT(node_id, _FOREACH_NODELABEL)(fn)
3539
3577#define DT_FOREACH_NODELABEL_VARGS(node_id, fn, ...) \
3578 DT_CAT(node_id, _FOREACH_NODELABEL_VARGS)(fn, __VA_ARGS__)
3579
3604#define DT_NODE_EXISTS(node_id) IS_ENABLED(DT_CAT(node_id, _EXISTS))
3605
3627#define DT_NODE_HAS_STATUS(node_id, status) \
3628 DT_NODE_HAS_STATUS_INTERNAL(node_id, status)
3629
3650#define DT_NODE_HAS_STATUS_OKAY(node_id) DT_NODE_HAS_STATUS(node_id, okay)
3651
3671#define DT_HAS_COMPAT_STATUS_OKAY(compat) \
3672 IS_ENABLED(DT_CAT(DT_COMPAT_HAS_OKAY_, compat))
3673
3680#define DT_NUM_INST_STATUS_OKAY(compat) \
3681 UTIL_AND(DT_HAS_COMPAT_STATUS_OKAY(compat), \
3682 UTIL_CAT(DT_N_INST, DT_DASH(compat, NUM_OKAY)))
3683
3711#define DT_NODE_HAS_COMPAT(node_id, compat) \
3712 IS_ENABLED(DT_CAT3(node_id, _COMPAT_MATCHES_, compat))
3713
3728#define DT_NODE_HAS_COMPAT_STATUS(node_id, compat, status) \
3729 UTIL_AND(DT_NODE_HAS_COMPAT(node_id, compat), DT_NODE_HAS_STATUS(node_id, status))
3730
3744#define DT_NODE_HAS_PROP(node_id, prop) \
3745 IS_ENABLED(DT_CAT4(node_id, _P_, prop, _EXISTS))
3746
3747
3764#define DT_PHA_HAS_CELL_AT_IDX(node_id, pha, idx, cell) \
3765 IS_ENABLED(DT_CAT8(node_id, _P_, pha, \
3766 _IDX_, idx, _VAL_, cell, _EXISTS))
3767
3777#define DT_PHA_HAS_CELL(node_id, pha, cell) \
3778 DT_PHA_HAS_CELL_AT_IDX(node_id, pha, 0, cell)
3779
3821#define DT_BUS(node_id) DT_CAT(node_id, _BUS)
3822
3851#define DT_ON_BUS(node_id, bus) IS_ENABLED(DT_CAT3(node_id, _BUS_, bus))
3852
3869#define DT_DRV_INST(inst) DT_INST(inst, DT_DRV_COMPAT)
3870
3878#define DT_INST_PARENT(inst) DT_PARENT(DT_DRV_INST(inst))
3879
3887#define DT_INST_GPARENT(inst) DT_GPARENT(DT_DRV_INST(inst))
3888
3898#define DT_INST_CHILD(inst, child) \
3899 DT_CHILD(DT_DRV_INST(inst), child)
3900
3910#define DT_INST_CHILD_NUM(inst) DT_CHILD_NUM(DT_DRV_INST(inst))
3911
3921#define DT_INST_CHILD_NUM_STATUS_OKAY(inst) \
3922 DT_CHILD_NUM_STATUS_OKAY(DT_DRV_INST(inst))
3923
3932#define DT_INST_NODELABEL_STRING_ARRAY(inst) DT_NODELABEL_STRING_ARRAY(DT_DRV_INST(inst))
3933
3942#define DT_INST_NUM_NODELABELS(inst) DT_NUM_NODELABELS(DT_DRV_INST(inst))
3943
3958#define DT_INST_FOREACH_CHILD(inst, fn) \
3959 DT_FOREACH_CHILD(DT_DRV_INST(inst), fn)
3960
3974#define DT_INST_FOREACH_CHILD_SEP(inst, fn, sep) \
3975 DT_FOREACH_CHILD_SEP(DT_DRV_INST(inst), fn, sep)
3976
3992#define DT_INST_FOREACH_CHILD_VARGS(inst, fn, ...) \
3993 DT_FOREACH_CHILD_VARGS(DT_DRV_INST(inst), fn, __VA_ARGS__)
3994
4009#define DT_INST_FOREACH_CHILD_SEP_VARGS(inst, fn, sep, ...) \
4010 DT_FOREACH_CHILD_SEP_VARGS(DT_DRV_INST(inst), fn, sep, __VA_ARGS__)
4011
4023#define DT_INST_FOREACH_CHILD_STATUS_OKAY(inst, fn) \
4024 DT_FOREACH_CHILD_STATUS_OKAY(DT_DRV_INST(inst), fn)
4025
4040#define DT_INST_FOREACH_CHILD_STATUS_OKAY_SEP(inst, fn, sep) \
4041 DT_FOREACH_CHILD_STATUS_OKAY_SEP(DT_DRV_INST(inst), fn, sep)
4042
4056#define DT_INST_FOREACH_CHILD_STATUS_OKAY_VARGS(inst, fn, ...) \
4057 DT_FOREACH_CHILD_STATUS_OKAY_VARGS(DT_DRV_INST(inst), fn, __VA_ARGS__)
4058
4074#define DT_INST_FOREACH_CHILD_STATUS_OKAY_SEP_VARGS(inst, fn, sep, ...) \
4075 DT_FOREACH_CHILD_STATUS_OKAY_SEP_VARGS(DT_DRV_INST(inst), fn, sep, __VA_ARGS__)
4076
4084#define DT_INST_ENUM_IDX_BY_IDX(inst, prop, idx) \
4085 DT_ENUM_IDX_BY_IDX(DT_DRV_INST(inst), prop, idx)
4086
4093#define DT_INST_ENUM_IDX(inst, prop) \
4094 DT_ENUM_IDX(DT_DRV_INST(inst), prop)
4095
4105#define DT_INST_ENUM_IDX_BY_IDX_OR(inst, prop, idx, default_idx_value) \
4106 DT_ENUM_IDX_BY_IDX_OR(DT_DRV_INST(inst), prop, idx, default_idx_value)
4107
4116#define DT_INST_ENUM_IDX_OR(inst, prop, default_idx_value) \
4117 DT_ENUM_IDX_OR(DT_DRV_INST(inst), prop, default_idx_value)
4118
4127#define DT_INST_ENUM_HAS_VALUE_BY_IDX(inst, prop, idx, value) \
4128 DT_ENUM_HAS_VALUE_BY_IDX(DT_DRV_INST(inst), prop, idx, value)
4129
4138#define DT_INST_ENUM_HAS_VALUE(inst, prop, value) \
4139 DT_ENUM_HAS_VALUE(DT_DRV_INST(inst), prop, value)
4140
4147#define DT_INST_PROP(inst, prop) DT_PROP(DT_DRV_INST(inst), prop)
4148
4155#define DT_INST_PROP_LEN(inst, prop) DT_PROP_LEN(DT_DRV_INST(inst), prop)
4156
4166#define DT_INST_PROP_HAS_IDX(inst, prop, idx) \
4167 DT_PROP_HAS_IDX(DT_DRV_INST(inst), prop, idx)
4168
4177#define DT_INST_PROP_HAS_NAME(inst, prop, name) \
4178 DT_PROP_HAS_NAME(DT_DRV_INST(inst), prop, name)
4179
4187#define DT_INST_PROP_BY_IDX(inst, prop, idx) \
4188 DT_PROP_BY_IDX(DT_DRV_INST(inst), prop, idx)
4189
4197#define DT_INST_PROP_OR(inst, prop, default_value) \
4198 DT_PROP_OR(DT_DRV_INST(inst), prop, default_value)
4199
4207#define DT_INST_PROP_LEN_OR(inst, prop, default_value) \
4208 DT_PROP_LEN_OR(DT_DRV_INST(inst), prop, default_value)
4209
4219#define DT_INST_STRING_TOKEN(inst, prop) \
4220 DT_STRING_TOKEN(DT_DRV_INST(inst), prop)
4221
4229#define DT_INST_STRING_UPPER_TOKEN(inst, prop) \
4230 DT_STRING_UPPER_TOKEN(DT_DRV_INST(inst), prop)
4231
4240#define DT_INST_STRING_UNQUOTED(inst, prop) \
4241 DT_STRING_UNQUOTED(DT_DRV_INST(inst), prop)
4242
4250#define DT_INST_STRING_TOKEN_BY_IDX(inst, prop, idx) \
4251 DT_STRING_TOKEN_BY_IDX(DT_DRV_INST(inst), prop, idx)
4252
4260#define DT_INST_STRING_UPPER_TOKEN_BY_IDX(inst, prop, idx) \
4261 DT_STRING_UPPER_TOKEN_BY_IDX(DT_DRV_INST(inst), prop, idx)
4262
4270#define DT_INST_STRING_UNQUOTED_BY_IDX(inst, prop, idx) \
4271 DT_STRING_UNQUOTED_BY_IDX(DT_DRV_INST(inst), prop, idx)
4272
4281#define DT_INST_PROP_BY_PHANDLE(inst, ph, prop) \
4282 DT_INST_PROP_BY_PHANDLE_IDX(inst, ph, 0, prop)
4283
4295#define DT_INST_PROP_BY_PHANDLE_IDX(inst, phs, idx, prop) \
4296 DT_PROP_BY_PHANDLE_IDX(DT_DRV_INST(inst), phs, idx, prop)
4297
4306#define DT_INST_PHA_BY_IDX(inst, pha, idx, cell) \
4307 DT_PHA_BY_IDX(DT_DRV_INST(inst), pha, idx, cell)
4308
4318#define DT_INST_PHA_BY_IDX_OR(inst, pha, idx, cell, default_value) \
4319 DT_PHA_BY_IDX_OR(DT_DRV_INST(inst), pha, idx, cell, default_value)
4320
4329#define DT_INST_PHA(inst, pha, cell) DT_INST_PHA_BY_IDX(inst, pha, 0, cell)
4330
4339#define DT_INST_PHA_OR(inst, pha, cell, default_value) \
4340 DT_INST_PHA_BY_IDX_OR(inst, pha, 0, cell, default_value)
4341
4351#define DT_INST_PHA_BY_NAME(inst, pha, name, cell) \
4352 DT_PHA_BY_NAME(DT_DRV_INST(inst), pha, name, cell)
4353
4363#define DT_INST_PHA_BY_NAME_OR(inst, pha, name, cell, default_value) \
4364 DT_PHA_BY_NAME_OR(DT_DRV_INST(inst), pha, name, cell, default_value)
4365
4374#define DT_INST_PHANDLE_BY_NAME(inst, pha, name) \
4375 DT_PHANDLE_BY_NAME(DT_DRV_INST(inst), pha, name) \
4376
4386#define DT_INST_PHANDLE_BY_IDX(inst, prop, idx) \
4387 DT_PHANDLE_BY_IDX(DT_DRV_INST(inst), prop, idx)
4388
4397#define DT_INST_PHANDLE(inst, prop) DT_INST_PHANDLE_BY_IDX(inst, prop, 0)
4398
4406#define DT_INST_REG_HAS_IDX(inst, idx) DT_REG_HAS_IDX(DT_DRV_INST(inst), idx)
4407
4415#define DT_INST_REG_HAS_NAME(inst, name) DT_REG_HAS_NAME(DT_DRV_INST(inst), name)
4416
4423#define DT_INST_REG_ADDR_BY_IDX_RAW(inst, idx) DT_REG_ADDR_BY_IDX_RAW(DT_DRV_INST(inst), idx)
4424
4431#define DT_INST_REG_ADDR_BY_IDX(inst, idx) DT_REG_ADDR_BY_IDX(DT_DRV_INST(inst), idx)
4432
4439#define DT_INST_REG_SIZE_BY_IDX(inst, idx) \
4440 DT_REG_SIZE_BY_IDX(DT_DRV_INST(inst), idx)
4441
4448#define DT_INST_REG_ADDR_BY_NAME(inst, name) \
4449 DT_REG_ADDR_BY_NAME(DT_DRV_INST(inst), name)
4450
4459#define DT_INST_REG_ADDR_BY_NAME_OR(inst, name, default_value) \
4460 DT_REG_ADDR_BY_NAME_OR(DT_DRV_INST(inst), name, default_value)
4461
4474#define DT_INST_REG_ADDR_BY_NAME_U64(inst, name) \
4475 DT_REG_ADDR_BY_NAME_U64(DT_DRV_INST(inst), name)
4476
4483#define DT_INST_REG_SIZE_BY_NAME(inst, name) \
4484 DT_REG_SIZE_BY_NAME(DT_DRV_INST(inst), name)
4485
4494#define DT_INST_REG_SIZE_BY_NAME_OR(inst, name, default_value) \
4495 DT_REG_SIZE_BY_NAME_OR(DT_DRV_INST(inst), name, default_value)
4496
4502#define DT_INST_REG_ADDR_RAW(inst) DT_INST_REG_ADDR_BY_IDX_RAW(inst, 0)
4503
4509#define DT_INST_REG_ADDR(inst) DT_INST_REG_ADDR_BY_IDX(inst, 0)
4510
4522#define DT_INST_REG_ADDR_U64(inst) DT_REG_ADDR_U64(DT_DRV_INST(inst))
4523
4529#define DT_INST_REG_SIZE(inst) DT_INST_REG_SIZE_BY_IDX(inst, 0)
4530
4537#define DT_INST_NUM_IRQS(inst) DT_NUM_IRQS(DT_DRV_INST(inst))
4538
4545#define DT_INST_IRQ_LEVEL(inst) DT_IRQ_LEVEL(DT_DRV_INST(inst))
4546
4554#define DT_INST_IRQ_BY_IDX(inst, idx, cell) \
4555 DT_IRQ_BY_IDX(DT_DRV_INST(inst), idx, cell)
4556
4563#define DT_INST_IRQ_INTC_BY_IDX(inst, idx) \
4564 DT_IRQ_INTC_BY_IDX(DT_DRV_INST(inst), idx)
4565
4572#define DT_INST_IRQ_INTC_BY_NAME(inst, name) \
4573 DT_IRQ_INTC_BY_NAME(DT_DRV_INST(inst), name)
4574
4582#define DT_INST_IRQ_INTC(inst) \
4583 DT_INST_IRQ_INTC_BY_IDX(inst, 0)
4584
4592#define DT_INST_IRQ_BY_NAME(inst, name, cell) \
4593 DT_IRQ_BY_NAME(DT_DRV_INST(inst), name, cell)
4594
4601#define DT_INST_IRQ(inst, cell) DT_INST_IRQ_BY_IDX(inst, 0, cell)
4602
4608#define DT_INST_IRQN(inst) DT_IRQN(DT_DRV_INST(inst))
4609
4616#define DT_INST_IRQN_BY_IDX(inst, idx) DT_IRQN_BY_IDX(DT_DRV_INST(inst), idx)
4617
4623#define DT_INST_BUS(inst) DT_BUS(DT_DRV_INST(inst))
4624
4632#define DT_INST_ON_BUS(inst, bus) DT_ON_BUS(DT_DRV_INST(inst), bus)
4633
4643#define DT_INST_STRING_TOKEN_OR(inst, name, default_value) \
4644 DT_STRING_TOKEN_OR(DT_DRV_INST(inst), name, default_value)
4645
4654#define DT_INST_STRING_UPPER_TOKEN_OR(inst, name, default_value) \
4655 DT_STRING_UPPER_TOKEN_OR(DT_DRV_INST(inst), name, default_value)
4656
4665#define DT_INST_STRING_UNQUOTED_OR(inst, name, default_value) \
4666 DT_STRING_UNQUOTED_OR(DT_DRV_INST(inst), name, default_value)
4667
4668/*
4669 * @brief Test if any enabled node with the given compatible is on
4670 * the given bus type
4671 *
4672 * This is like DT_ANY_INST_ON_BUS_STATUS_OKAY(), except it can also
4673 * be useful for handling multiple compatibles in single source file.
4674 *
4675 * Example devicetree overlay:
4676 *
4677 * @code{.dts}
4678 * &i2c0 {
4679 * temp: temperature-sensor@76 {
4680 * compatible = "vnd,some-sensor";
4681 * reg = <0x76>;
4682 * };
4683 * };
4684 * @endcode
4685 *
4686 * Example usage, assuming `i2c0` is an I2C bus controller node, and
4687 * therefore `temp` is on an I2C bus:
4688 *
4689 * @code{.c}
4690 * DT_HAS_COMPAT_ON_BUS_STATUS_OKAY(vnd_some_sensor, i2c) // 1
4691 * @endcode
4692 *
4693 * @param compat lowercase-and-underscores compatible, without quotes
4694 * @param bus a binding's bus type as a C token, lowercased and without quotes
4695 * @return 1 if any enabled node with that compatible is on that bus type,
4696 * 0 otherwise
4697 */
4698#define DT_HAS_COMPAT_ON_BUS_STATUS_OKAY(compat, bus) \
4699 IS_ENABLED(DT_CAT4(DT_COMPAT_, compat, _BUS_, bus))
4700
4733#define DT_ANY_INST_ON_BUS_STATUS_OKAY(bus) \
4734 DT_HAS_COMPAT_ON_BUS_STATUS_OKAY(DT_DRV_COMPAT, bus)
4735
4780#define DT_ANY_INST_HAS_PROP_STATUS_OKAY(prop) \
4781 COND_CODE_1(IS_EMPTY(DT_ANY_INST_HAS_PROP_STATUS_OKAY_(prop)), (0), (1))
4782
4827#define DT_ANY_COMPAT_HAS_PROP_STATUS_OKAY(compat, prop) \
4828 (DT_COMPAT_FOREACH_STATUS_OKAY_VARGS(compat, DT_COMPAT_NODE_HAS_PROP_AND_OR, prop) 0)
4829
4877#define DT_ANY_INST_HAS_BOOL_STATUS_OKAY(prop) \
4878 COND_CODE_1(IS_EMPTY(DT_ANY_INST_HAS_BOOL_STATUS_OKAY_(prop)), (0), (1))
4879
4945#define DT_INST_FOREACH_STATUS_OKAY(fn) \
4946 COND_CODE_1(DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT), \
4947 (UTIL_CAT(DT_FOREACH_OKAY_INST_, \
4948 DT_DRV_COMPAT)(fn)), \
4949 ())
4950
4963#define DT_INST_FOREACH_STATUS_OKAY_VARGS(fn, ...) \
4964 COND_CODE_1(DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT), \
4965 (UTIL_CAT(DT_FOREACH_OKAY_INST_VARGS_, \
4966 DT_DRV_COMPAT)(fn, __VA_ARGS__)), \
4967 ())
4968
4978#define DT_INST_FOREACH_NODELABEL(inst, fn) \
4979 DT_FOREACH_NODELABEL(DT_DRV_INST(inst), fn)
4980
4992#define DT_INST_FOREACH_NODELABEL_VARGS(inst, fn, ...) \
4993 DT_FOREACH_NODELABEL_VARGS(DT_DRV_INST(inst), fn, __VA_ARGS__)
4994
5005#define DT_INST_FOREACH_PROP_ELEM(inst, prop, fn) \
5006 DT_FOREACH_PROP_ELEM(DT_DRV_INST(inst), prop, fn)
5007
5020#define DT_INST_FOREACH_PROP_ELEM_SEP(inst, prop, fn, sep) \
5021 DT_FOREACH_PROP_ELEM_SEP(DT_DRV_INST(inst), prop, fn, sep)
5022
5037#define DT_INST_FOREACH_PROP_ELEM_VARGS(inst, prop, fn, ...) \
5038 DT_FOREACH_PROP_ELEM_VARGS(DT_DRV_INST(inst), prop, fn, __VA_ARGS__)
5039
5057#define DT_INST_FOREACH_PROP_ELEM_SEP_VARGS(inst, prop, fn, sep, ...) \
5058 DT_FOREACH_PROP_ELEM_SEP_VARGS(DT_DRV_INST(inst), prop, fn, sep, \
5059 __VA_ARGS__)
5060
5067#define DT_INST_NODE_HAS_PROP(inst, prop) \
5068 DT_NODE_HAS_PROP(DT_DRV_INST(inst), prop)
5069
5076#define DT_INST_NODE_HAS_COMPAT(inst, compat) \
5077 DT_NODE_HAS_COMPAT(DT_DRV_INST(inst), compat)
5078
5089#define DT_INST_PHA_HAS_CELL_AT_IDX(inst, pha, idx, cell) \
5090 DT_PHA_HAS_CELL_AT_IDX(DT_DRV_INST(inst), pha, idx, cell)
5091
5101#define DT_INST_PHA_HAS_CELL(inst, pha, cell) \
5102 DT_INST_PHA_HAS_CELL_AT_IDX(inst, pha, 0, cell)
5103
5111#define DT_INST_IRQ_HAS_IDX(inst, idx) DT_IRQ_HAS_IDX(DT_DRV_INST(inst), idx)
5112
5121#define DT_INST_IRQ_HAS_CELL_AT_IDX(inst, idx, cell) \
5122 DT_IRQ_HAS_CELL_AT_IDX(DT_DRV_INST(inst), idx, cell)
5123
5131#define DT_INST_IRQ_HAS_CELL(inst, cell) \
5132 DT_INST_IRQ_HAS_CELL_AT_IDX(inst, 0, cell)
5133
5140#define DT_INST_IRQ_HAS_NAME(inst, name) \
5141 DT_IRQ_HAS_NAME(DT_DRV_INST(inst), name)
5142
5160#define DT_ANY_INST_HAS_PROP_STATUS_OKAY__(idx, prop) \
5161 COND_CODE_1(DT_INST_NODE_HAS_PROP(idx, prop), (1,), ())
5174#define DT_ANY_INST_HAS_PROP_STATUS_OKAY_(prop) \
5175 DT_INST_FOREACH_STATUS_OKAY_VARGS(DT_ANY_INST_HAS_PROP_STATUS_OKAY__, prop)
5176
5189#define DT_ANY_INST_HAS_BOOL_STATUS_OKAY__(idx, prop) \
5190 COND_CODE_1(DT_INST_PROP(idx, prop), (1,), ())
5203#define DT_ANY_INST_HAS_BOOL_STATUS_OKAY_(prop) \
5204 DT_INST_FOREACH_STATUS_OKAY_VARGS(DT_ANY_INST_HAS_BOOL_STATUS_OKAY__, prop)
5205
5206#define DT_PATH_INTERNAL(...) \
5207 UTIL_CAT(DT_ROOT, MACRO_MAP_CAT(DT_S_PREFIX, __VA_ARGS__))
5213#define DT_S_PREFIX(name) _S_##name
5214
5229#define DT_CAT(a1, a2) a1 ## a2
5231#define DT_CAT3(a1, a2, a3) a1 ## a2 ## a3
5233#define DT_CAT4(a1, a2, a3, a4) a1 ## a2 ## a3 ## a4
5235#define DT_CAT5(a1, a2, a3, a4, a5) a1 ## a2 ## a3 ## a4 ## a5
5237#define DT_CAT6(a1, a2, a3, a4, a5, a6) a1 ## a2 ## a3 ## a4 ## a5 ## a6
5239#define DT_CAT7(a1, a2, a3, a4, a5, a6, a7) \
5240 a1 ## a2 ## a3 ## a4 ## a5 ## a6 ## a7
5242#define DT_CAT8(a1, a2, a3, a4, a5, a6, a7, a8) \
5243 a1 ## a2 ## a3 ## a4 ## a5 ## a6 ## a7 ## a8
5244/*
5245 * If you need to define a bigger DT_CATN(), do so here. Don't leave
5246 * any "holes" of undefined macros, please.
5247 */
5248
5250#define DT_DASH(...) MACRO_MAP_CAT(DT_DASH_PREFIX, __VA_ARGS__)
5252#define DT_DASH_PREFIX(name) _##name
5254#define DT_NODE_HAS_STATUS_INTERNAL(node_id, status) \
5255 IS_ENABLED(DT_CAT3(node_id, _STATUS_, status))
5256
5260#define DT_COMPAT_NODE_HAS_PROP_AND_OR(inst, compat, prop) \
5261 DT_NODE_HAS_PROP(DT_INST(inst, compat), prop) ||
5262
5267#if defined(_LINKER) || defined(_ASMLANGUAGE)
5268#define DT_U32_C(_v) (_v)
5269#else
5270#define DT_U32_C(_v) UINT32_C(_v)
5271#endif
5272
5277#if defined(_LINKER) || defined(_ASMLANGUAGE)
5278#define DT_U64_C(_v) (_v)
5279#else
5280#define DT_U64_C(_v) UINT64_C(_v)
5281#endif
5282
5283/* Helpers for DT_NODELABEL_STRING_ARRAY. We define our own stringify
5284 * in order to avoid adding a dependency on toolchain.h..
5285 */
5286#define DT_NODELABEL_STRING_ARRAY_ENTRY_INTERNAL(nodelabel) DT_STRINGIFY_INTERNAL(nodelabel),
5287#define DT_STRINGIFY_INTERNAL(arg) DT_STRINGIFY_INTERNAL_HELPER(arg)
5288#define DT_STRINGIFY_INTERNAL_HELPER(arg) #arg
5289
5292/* have these last so they have access to all previously defined macros */
5295#include <zephyr/devicetree/gpio.h>
5296#include <zephyr/devicetree/spi.h>
5297#include <zephyr/devicetree/dma.h>
5298#include <zephyr/devicetree/pwms.h>
5302#include <zephyr/devicetree/can.h>
5304#include <zephyr/devicetree/mbox.h>
5306
5307#endif /* ZEPHYR_INCLUDE_DEVICETREE_H_ */
Clocks Devicetree macro public API header file.
CAN devicetree macro public API header file.
DMA Devicetree macro public API header file.
GPIO Devicetree macro public API header file.
MBOX Devicetree macro public API header file.
Devicetree pin control helpers.
Reset Controller Devicetree macro public API header file.
SPI Devicetree macro public API header file.
Flash Devicetree macro public API header file.
IO channels devicetree macro public API header file.
Public interface for multi-level interrupts.
Devicetree node dependency ordinals.
Port / Endpoint Devicetree macro public API header file.
PWMs Devicetree macro public API header file.
Misc utilities.