16#ifndef ZEPHYR_INCLUDE_DEVICETREE_H_
17#define ZEPHYR_INCLUDE_DEVICETREE_H_
19#include <zephyr/devicetree_generated.h>
22#if !defined(_LINKER) && !defined(_ASMLANGUAGE)
83#define DT_INVALID_NODE _
140#define DT_PATH(...) DT_PATH_INTERNAL(__VA_ARGS__)
196#define DT_NODELABEL(label) DT_CAT(DT_N_NODELABEL_, label)
236#define DT_ALIAS(alias) DT_CAT(DT_N_ALIAS_, alias)
243#define DT_HAS_ALIAS(alias_name) DT_NODE_EXISTS(DT_ALIAS(alias_name))
339#define DT_INST(inst, compat) UTIL_CAT(DT_N_INST, DT_DASH(inst, compat))
364#define DT_PARENT(node_id) DT_CAT(node_id, _PARENT)
389#define DT_GPARENT(node_id) DT_PARENT(DT_PARENT(node_id))
426#define DT_CHILD(node_id, child) UTIL_CAT(node_id, DT_S_PREFIX(child))
469#define DT_COMPAT_GET_ANY_STATUS_OKAY(compat) \
470 COND_CODE_1(DT_HAS_COMPAT_STATUS_OKAY(compat), \
471 (DT_INST(0, compat)), \
501#define DT_NODE_PATH(node_id) DT_CAT(node_id, _PATH)
527#define DT_NODE_FULL_NAME(node_id) DT_CAT(node_id, _FULL_NAME)
555#define DT_NODE_FULL_NAME_UNQUOTED(node_id) DT_CAT(node_id, _FULL_NAME_UNQUOTED)
583#define DT_NODE_FULL_NAME_TOKEN(node_id) DT_CAT(node_id, _FULL_NAME_TOKEN)
613#define DT_NODE_FULL_NAME_UPPER_TOKEN(node_id) DT_CAT(node_id, _FULL_NAME_UPPER_TOKEN)
641#define DT_NODE_CHILD_IDX(node_id) DT_CAT(node_id, _CHILD_IDX)
649#define DT_CHILD_NUM(node_id) DT_CAT(node_id, _CHILD_NUM)
659#define DT_CHILD_NUM_STATUS_OKAY(node_id) \
660 DT_CAT(node_id, _CHILD_NUM_STATUS_OKAY)
682#define DT_SAME_NODE(node_id1, node_id2) \
683 (DT_DEP_ORD(node_id1) == (DT_DEP_ORD(node_id2)))
709#define DT_NODELABEL_STRING_ARRAY(node_id) \
710 { DT_FOREACH_NODELABEL(node_id, DT_NODELABEL_STRING_ARRAY_ENTRY_INTERNAL) }
752#define DT_PROP(node_id, prop) DT_CAT3(node_id, _P_, prop)
786#define DT_PROP_LEN(node_id, prop) DT_CAT4(node_id, _P_, prop, _LEN)
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))
826#define DT_PROP_HAS_IDX(node_id, prop, idx) \
827 IS_ENABLED(DT_CAT6(node_id, _P_, prop, _IDX_, idx, _EXISTS))
861#define DT_PROP_HAS_NAME(node_id, prop, name) \
862 IS_ENABLED(DT_CAT6(node_id, _P_, prop, _NAME_, name, _EXISTS))
898#define DT_PROP_BY_IDX(node_id, prop, idx) \
899 DT_CAT5(node_id, _P_, prop, _IDX_, idx)
909#define DT_PROP_LAST(node_id, prop) \
910 DT_PROP_BY_IDX(node_id, prop, UTIL_DEC(DT_PROP_LEN(node_id, prop)))
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))
984#define DT_ENUM_IDX_BY_IDX(node_id, prop, idx) \
985 DT_CAT6(node_id, _P_, prop, _IDX_, idx, _ENUM_IDX)
993#define DT_ENUM_IDX(node_id, prop) DT_ENUM_IDX_BY_IDX(node_id, prop, 0)
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))
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)
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))
1044#define DT_ENUM_HAS_VALUE(node_id, prop, value) \
1045 DT_ENUM_HAS_VALUE_BY_IDX(node_id, prop, 0, value)
1106#define DT_STRING_TOKEN(node_id, prop) \
1107 DT_CAT4(node_id, _P_, prop, _STRING_TOKEN)
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))
1183#define DT_STRING_UPPER_TOKEN(node_id, prop) \
1184 DT_CAT4(node_id, _P_, prop, _STRING_UPPER_TOKEN)
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))
1244#define DT_STRING_UNQUOTED(node_id, prop) \
1245 DT_CAT4(node_id, _P_, prop, _STRING_UNQUOTED)
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))
1312#define DT_STRING_TOKEN_BY_IDX(node_id, prop, idx) \
1313 DT_CAT6(node_id, _P_, prop, _IDX_, idx, _STRING_TOKEN)
1362#define DT_STRING_UPPER_TOKEN_BY_IDX(node_id, prop, idx) \
1363 DT_CAT6(node_id, _P_, prop, _IDX_, idx, _STRING_UPPER_TOKEN)
1405#define DT_STRING_UNQUOTED_BY_IDX(node_id, prop, idx) \
1406 DT_CAT6(node_id, _P_, prop, _IDX_, idx, _STRING_UNQUOTED)
1461#define DT_PROP_BY_PHANDLE_IDX(node_id, phs, idx, prop) \
1462 DT_PROP(DT_PHANDLE_BY_IDX(node_id, phs, idx), prop)
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)
1497#define DT_PROP_BY_PHANDLE(node_id, ph, prop) \
1498 DT_PROP_BY_PHANDLE_IDX(node_id, ph, 0, prop)
1554#define DT_PHA_BY_IDX(node_id, pha, idx, cell) \
1555 DT_CAT7(node_id, _P_, pha, _IDX_, idx, _VAL_, cell)
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)
1590#define DT_PHA(node_id, pha, cell) DT_PHA_BY_IDX(node_id, pha, 0, cell)
1606#define DT_PHA_OR(node_id, pha, cell, default_value) \
1607 DT_PHA_BY_IDX_OR(node_id, pha, 0, cell, default_value)
1649#define DT_PHA_BY_NAME(node_id, pha, name, cell) \
1650 DT_CAT7(node_id, _P_, pha, _NAME_, name, _VAL_, cell)
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)
1723#define DT_PHANDLE_BY_NAME(node_id, pha, name) \
1724 DT_CAT6(node_id, _P_, pha, _NAME_, name, _PH)
1775#define DT_PHANDLE_BY_IDX(node_id, prop, idx) \
1776 DT_CAT6(node_id, _P_, prop, _IDX_, idx, _PH)
1789#define DT_PHANDLE(node_id, prop) DT_PHANDLE_BY_IDX(node_id, prop, 0)
1837#define DT_NUM_RANGES(node_id) DT_CAT(node_id, _RANGES_NUM)
1891#define DT_RANGES_HAS_IDX(node_id, idx) \
1892 IS_ENABLED(DT_CAT4(node_id, _RANGES_IDX_, idx, _EXISTS))
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))
1986#define DT_RANGES_CHILD_BUS_FLAGS_BY_IDX(node_id, idx) \
1987 DT_CAT4(node_id, _RANGES_IDX_, idx, _VAL_CHILD_BUS_FLAGS)
2035#define DT_RANGES_CHILD_BUS_ADDRESS_BY_IDX(node_id, idx) \
2036 DT_CAT4(node_id, _RANGES_IDX_, idx, _VAL_CHILD_BUS_ADDRESS)
2084#define DT_RANGES_PARENT_BUS_ADDRESS_BY_IDX(node_id, idx) \
2085 DT_CAT4(node_id, _RANGES_IDX_, idx, _VAL_PARENT_BUS_ADDRESS)
2133#define DT_RANGES_LENGTH_BY_IDX(node_id, idx) \
2134 DT_CAT4(node_id, _RANGES_IDX_, idx, _VAL_LENGTH)
2175#define DT_FOREACH_RANGE(node_id, fn) \
2176 DT_CAT(node_id, _FOREACH_RANGE)(fn)
2223#define DT_NODE_VENDOR_BY_IDX(node_id, idx) \
2224 DT_CAT3(node_id, _COMPAT_VENDOR_IDX_, idx)
2238#define DT_NODE_VENDOR_HAS_IDX(node_id, idx) \
2239 IS_ENABLED(DT_CAT4(node_id, _COMPAT_VENDOR_IDX_, idx, _EXISTS))
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))
2267#define DT_NODE_VENDOR_OR(node_id, default_value) \
2268 DT_NODE_VENDOR_BY_IDX_OR(node_id, 0, default_value)
2299#define DT_NODE_MODEL_BY_IDX(node_id, idx) \
2300 DT_CAT3(node_id, _COMPAT_MODEL_IDX_, idx)
2314#define DT_NODE_MODEL_HAS_IDX(node_id, idx) \
2315 IS_ENABLED(DT_CAT4(node_id, _COMPAT_MODEL_IDX_, idx, _EXISTS))
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))
2343#define DT_NODE_MODEL_OR(node_id, default_value) \
2344 DT_NODE_MODEL_BY_IDX_OR(node_id, 0, default_value)
2363#define DT_NUM_REGS(node_id) DT_CAT(node_id, _REG_NUM)
2376#define DT_REG_HAS_IDX(node_id, idx) \
2377 IS_ENABLED(DT_CAT4(node_id, _REG_IDX_, idx, _EXISTS))
2390#define DT_REG_HAS_NAME(node_id, name) \
2391 IS_ENABLED(DT_CAT4(node_id, _REG_NAME_, name, _EXISTS))
2404#define DT_REG_ADDR_BY_IDX_RAW(node_id, idx) \
2405 DT_CAT4(node_id, _REG_IDX_, idx, _VAL_ADDRESS)
2418#define DT_REG_ADDR_RAW(node_id) \
2419 DT_REG_ADDR_BY_IDX_RAW(node_id, 0)
2427#define DT_REG_ADDR_BY_IDX(node_id, idx) \
2428 DT_U32_C(DT_REG_ADDR_BY_IDX_RAW(node_id, idx))
2441#define DT_REG_SIZE_BY_IDX(node_id, idx) \
2442 DT_U32_C(DT_CAT4(node_id, _REG_IDX_, idx, _VAL_SIZE))
2451#define DT_REG_ADDR(node_id) DT_REG_ADDR_BY_IDX(node_id, 0)
2463#define DT_REG_ADDR_U64(node_id) DT_U64_C(DT_REG_ADDR_BY_IDX_RAW(node_id, 0))
2472#define DT_REG_SIZE(node_id) DT_REG_SIZE_BY_IDX(node_id, 0)
2480#define DT_REG_ADDR_BY_NAME(node_id, name) \
2481 DT_U32_C(DT_CAT4(node_id, _REG_NAME_, name, _VAL_ADDRESS))
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))
2507#define DT_REG_ADDR_BY_NAME_U64(node_id, name) \
2508 DT_U64_C(DT_CAT4(node_id, _REG_NAME_, name, _VAL_ADDRESS))
2516#define DT_REG_SIZE_BY_NAME(node_id, name) \
2517 DT_U32_C(DT_CAT4(node_id, _REG_NAME_, name, _VAL_SIZE))
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))
2550#define DT_NUM_IRQS(node_id) DT_CAT(node_id, _IRQ_NUM)
2576#define DT_NUM_NODELABELS(node_id) DT_CAT(node_id, _NODELABEL_NUM)
2584#define DT_IRQ_LEVEL(node_id) DT_CAT(node_id, _IRQ_LEVEL)
2596#define DT_IRQ_HAS_IDX(node_id, idx) \
2597 IS_ENABLED(DT_CAT4(node_id, _IRQ_IDX_, idx, _EXISTS))
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))
2619#define DT_IRQ_HAS_CELL(node_id, cell) DT_IRQ_HAS_CELL_AT_IDX(node_id, 0, cell)
2630#define DT_IRQ_HAS_NAME(node_id, name) \
2631 IS_ENABLED(DT_CAT4(node_id, _IRQ_NAME_, name, _VAL_irq_EXISTS))
2668#define DT_IRQ_BY_IDX(node_id, idx, cell) \
2669 DT_CAT5(node_id, _IRQ_IDX_, idx, _VAL_, cell)
2686#define DT_IRQ_BY_NAME(node_id, name, cell) \
2687 DT_CAT5(node_id, _IRQ_NAME_, name, _VAL_, cell)
2696#define DT_IRQ(node_id, cell) DT_IRQ_BY_IDX(node_id, 0, cell)
2740#define DT_IRQ_INTC_BY_IDX(node_id, idx) \
2741 DT_CAT4(node_id, _IRQ_IDX_, idx, _CONTROLLER)
2787#define DT_IRQ_INTC_BY_NAME(node_id, name) \
2788 DT_CAT4(node_id, _IRQ_NAME_, name, _CONTROLLER)
2829#define DT_IRQ_INTC(node_id) \
2830 DT_IRQ_INTC_BY_IDX(node_id, 0)
2837#define DT_IRQN_L1_INTERNAL(node_id, idx) DT_IRQ_BY_IDX(node_id, idx, irq)
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))
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))
2848#define DT_IRQN_LVL_INTERNAL(node_id, idx, level) DT_CAT3(DT_IRQN_L, level, _INTERNAL)(node_id, idx)
2854#define DT_MULTI_LEVEL_IRQN_INTERNAL(node_id, idx) \
2855 DT_IRQN_LVL_INTERNAL(node_id, idx, DT_IRQ_LEVEL(node_id))
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)))
2884#define DT_IRQN(node_id) DT_IRQN_BY_IDX(node_id, 0)
2904#define DT_CHOSEN(prop) DT_CAT(DT_CHOSEN_, prop)
2912#define DT_HAS_CHOSEN(prop) IS_ENABLED(DT_CAT3(DT_CHOSEN_, prop, _EXISTS))
2933#define DT_FOREACH_NODE(fn) DT_FOREACH_HELPER(fn)
2947#define DT_FOREACH_NODE_VARGS(fn, ...) DT_FOREACH_VARGS_HELPER(fn, __VA_ARGS__)
2960#define DT_FOREACH_STATUS_OKAY_NODE(fn) DT_FOREACH_OKAY_HELPER(fn)
2976#define DT_FOREACH_STATUS_OKAY_NODE_VARGS(fn, ...) DT_FOREACH_OKAY_VARGS_HELPER(fn, __VA_ARGS__)
3024#define DT_FOREACH_ANCESTOR(node_id, fn) \
3025 DT_CAT(node_id, _FOREACH_ANCESTOR)(fn)
3070#define DT_FOREACH_CHILD(node_id, fn) \
3071 DT_CAT(node_id, _FOREACH_CHILD)(fn)
3113#define DT_FOREACH_CHILD_SEP(node_id, fn, sep) \
3114 DT_CAT(node_id, _FOREACH_CHILD_SEP)(fn, sep)
3131#define DT_FOREACH_CHILD_VARGS(node_id, fn, ...) \
3132 DT_CAT(node_id, _FOREACH_CHILD_VARGS)(fn, __VA_ARGS__)
3149#define DT_FOREACH_CHILD_SEP_VARGS(node_id, fn, sep, ...) \
3150 DT_CAT(node_id, _FOREACH_CHILD_SEP_VARGS)(fn, sep, __VA_ARGS__)
3167#define DT_FOREACH_CHILD_STATUS_OKAY(node_id, fn) \
3168 DT_CAT(node_id, _FOREACH_CHILD_STATUS_OKAY)(fn)
3186#define DT_FOREACH_CHILD_STATUS_OKAY_SEP(node_id, fn, sep) \
3187 DT_CAT(node_id, _FOREACH_CHILD_STATUS_OKAY_SEP)(fn, sep)
3208#define DT_FOREACH_CHILD_STATUS_OKAY_VARGS(node_id, fn, ...) \
3209 DT_CAT(node_id, _FOREACH_CHILD_STATUS_OKAY_VARGS)(fn, __VA_ARGS__)
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__)
3282#define DT_FOREACH_PROP_ELEM(node_id, prop, fn) \
3283 DT_CAT4(node_id, _P_, prop, _FOREACH_PROP_ELEM)(fn)
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)
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__)
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__)
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)), \
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__)), \
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__)), \
3538#define DT_FOREACH_NODELABEL(node_id, fn) DT_CAT(node_id, _FOREACH_NODELABEL)(fn)
3577#define DT_FOREACH_NODELABEL_VARGS(node_id, fn, ...) \
3578 DT_CAT(node_id, _FOREACH_NODELABEL_VARGS)(fn, __VA_ARGS__)
3604#define DT_NODE_EXISTS(node_id) IS_ENABLED(DT_CAT(node_id, _EXISTS))
3627#define DT_NODE_HAS_STATUS(node_id, status) \
3628 DT_NODE_HAS_STATUS_INTERNAL(node_id, status)
3650#define DT_NODE_HAS_STATUS_OKAY(node_id) DT_NODE_HAS_STATUS(node_id, okay)
3671#define DT_HAS_COMPAT_STATUS_OKAY(compat) \
3672 IS_ENABLED(DT_CAT(DT_COMPAT_HAS_OKAY_, compat))
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)))
3711#define DT_NODE_HAS_COMPAT(node_id, compat) \
3712 IS_ENABLED(DT_CAT3(node_id, _COMPAT_MATCHES_, compat))
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))
3744#define DT_NODE_HAS_PROP(node_id, prop) \
3745 IS_ENABLED(DT_CAT4(node_id, _P_, prop, _EXISTS))
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))
3777#define DT_PHA_HAS_CELL(node_id, pha, cell) \
3778 DT_PHA_HAS_CELL_AT_IDX(node_id, pha, 0, cell)
3821#define DT_BUS(node_id) DT_CAT(node_id, _BUS)
3851#define DT_ON_BUS(node_id, bus) IS_ENABLED(DT_CAT3(node_id, _BUS_, bus))
3869#define DT_DRV_INST(inst) DT_INST(inst, DT_DRV_COMPAT)
3878#define DT_INST_PARENT(inst) DT_PARENT(DT_DRV_INST(inst))
3887#define DT_INST_GPARENT(inst) DT_GPARENT(DT_DRV_INST(inst))
3898#define DT_INST_CHILD(inst, child) \
3899 DT_CHILD(DT_DRV_INST(inst), child)
3910#define DT_INST_CHILD_NUM(inst) DT_CHILD_NUM(DT_DRV_INST(inst))
3921#define DT_INST_CHILD_NUM_STATUS_OKAY(inst) \
3922 DT_CHILD_NUM_STATUS_OKAY(DT_DRV_INST(inst))
3932#define DT_INST_NODELABEL_STRING_ARRAY(inst) DT_NODELABEL_STRING_ARRAY(DT_DRV_INST(inst))
3942#define DT_INST_NUM_NODELABELS(inst) DT_NUM_NODELABELS(DT_DRV_INST(inst))
3958#define DT_INST_FOREACH_CHILD(inst, fn) \
3959 DT_FOREACH_CHILD(DT_DRV_INST(inst), fn)
3974#define DT_INST_FOREACH_CHILD_SEP(inst, fn, sep) \
3975 DT_FOREACH_CHILD_SEP(DT_DRV_INST(inst), fn, sep)
3992#define DT_INST_FOREACH_CHILD_VARGS(inst, fn, ...) \
3993 DT_FOREACH_CHILD_VARGS(DT_DRV_INST(inst), fn, __VA_ARGS__)
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__)
4023#define DT_INST_FOREACH_CHILD_STATUS_OKAY(inst, fn) \
4024 DT_FOREACH_CHILD_STATUS_OKAY(DT_DRV_INST(inst), fn)
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)
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__)
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__)
4084#define DT_INST_ENUM_IDX_BY_IDX(inst, prop, idx) \
4085 DT_ENUM_IDX_BY_IDX(DT_DRV_INST(inst), prop, idx)
4093#define DT_INST_ENUM_IDX(inst, prop) \
4094 DT_ENUM_IDX(DT_DRV_INST(inst), prop)
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)
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)
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)
4138#define DT_INST_ENUM_HAS_VALUE(inst, prop, value) \
4139 DT_ENUM_HAS_VALUE(DT_DRV_INST(inst), prop, value)
4147#define DT_INST_PROP(inst, prop) DT_PROP(DT_DRV_INST(inst), prop)
4155#define DT_INST_PROP_LEN(inst, prop) DT_PROP_LEN(DT_DRV_INST(inst), prop)
4166#define DT_INST_PROP_HAS_IDX(inst, prop, idx) \
4167 DT_PROP_HAS_IDX(DT_DRV_INST(inst), prop, idx)
4177#define DT_INST_PROP_HAS_NAME(inst, prop, name) \
4178 DT_PROP_HAS_NAME(DT_DRV_INST(inst), prop, name)
4187#define DT_INST_PROP_BY_IDX(inst, prop, idx) \
4188 DT_PROP_BY_IDX(DT_DRV_INST(inst), prop, idx)
4197#define DT_INST_PROP_OR(inst, prop, default_value) \
4198 DT_PROP_OR(DT_DRV_INST(inst), prop, default_value)
4207#define DT_INST_PROP_LEN_OR(inst, prop, default_value) \
4208 DT_PROP_LEN_OR(DT_DRV_INST(inst), prop, default_value)
4219#define DT_INST_STRING_TOKEN(inst, prop) \
4220 DT_STRING_TOKEN(DT_DRV_INST(inst), prop)
4229#define DT_INST_STRING_UPPER_TOKEN(inst, prop) \
4230 DT_STRING_UPPER_TOKEN(DT_DRV_INST(inst), prop)
4240#define DT_INST_STRING_UNQUOTED(inst, prop) \
4241 DT_STRING_UNQUOTED(DT_DRV_INST(inst), prop)
4250#define DT_INST_STRING_TOKEN_BY_IDX(inst, prop, idx) \
4251 DT_STRING_TOKEN_BY_IDX(DT_DRV_INST(inst), prop, idx)
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)
4270#define DT_INST_STRING_UNQUOTED_BY_IDX(inst, prop, idx) \
4271 DT_STRING_UNQUOTED_BY_IDX(DT_DRV_INST(inst), prop, idx)
4281#define DT_INST_PROP_BY_PHANDLE(inst, ph, prop) \
4282 DT_INST_PROP_BY_PHANDLE_IDX(inst, ph, 0, prop)
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)
4306#define DT_INST_PHA_BY_IDX(inst, pha, idx, cell) \
4307 DT_PHA_BY_IDX(DT_DRV_INST(inst), pha, idx, cell)
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)
4329#define DT_INST_PHA(inst, pha, cell) DT_INST_PHA_BY_IDX(inst, pha, 0, cell)
4339#define DT_INST_PHA_OR(inst, pha, cell, default_value) \
4340 DT_INST_PHA_BY_IDX_OR(inst, pha, 0, cell, default_value)
4351#define DT_INST_PHA_BY_NAME(inst, pha, name, cell) \
4352 DT_PHA_BY_NAME(DT_DRV_INST(inst), pha, name, cell)
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)
4374#define DT_INST_PHANDLE_BY_NAME(inst, pha, name) \
4375 DT_PHANDLE_BY_NAME(DT_DRV_INST(inst), pha, name) \
4386#define DT_INST_PHANDLE_BY_IDX(inst, prop, idx) \
4387 DT_PHANDLE_BY_IDX(DT_DRV_INST(inst), prop, idx)
4397#define DT_INST_PHANDLE(inst, prop) DT_INST_PHANDLE_BY_IDX(inst, prop, 0)
4406#define DT_INST_REG_HAS_IDX(inst, idx) DT_REG_HAS_IDX(DT_DRV_INST(inst), idx)
4415#define DT_INST_REG_HAS_NAME(inst, name) DT_REG_HAS_NAME(DT_DRV_INST(inst), name)
4423#define DT_INST_REG_ADDR_BY_IDX_RAW(inst, idx) DT_REG_ADDR_BY_IDX_RAW(DT_DRV_INST(inst), idx)
4431#define DT_INST_REG_ADDR_BY_IDX(inst, idx) DT_REG_ADDR_BY_IDX(DT_DRV_INST(inst), idx)
4439#define DT_INST_REG_SIZE_BY_IDX(inst, idx) \
4440 DT_REG_SIZE_BY_IDX(DT_DRV_INST(inst), idx)
4448#define DT_INST_REG_ADDR_BY_NAME(inst, name) \
4449 DT_REG_ADDR_BY_NAME(DT_DRV_INST(inst), name)
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)
4474#define DT_INST_REG_ADDR_BY_NAME_U64(inst, name) \
4475 DT_REG_ADDR_BY_NAME_U64(DT_DRV_INST(inst), name)
4483#define DT_INST_REG_SIZE_BY_NAME(inst, name) \
4484 DT_REG_SIZE_BY_NAME(DT_DRV_INST(inst), name)
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)
4502#define DT_INST_REG_ADDR_RAW(inst) DT_INST_REG_ADDR_BY_IDX_RAW(inst, 0)
4509#define DT_INST_REG_ADDR(inst) DT_INST_REG_ADDR_BY_IDX(inst, 0)
4522#define DT_INST_REG_ADDR_U64(inst) DT_REG_ADDR_U64(DT_DRV_INST(inst))
4529#define DT_INST_REG_SIZE(inst) DT_INST_REG_SIZE_BY_IDX(inst, 0)
4537#define DT_INST_NUM_IRQS(inst) DT_NUM_IRQS(DT_DRV_INST(inst))
4545#define DT_INST_IRQ_LEVEL(inst) DT_IRQ_LEVEL(DT_DRV_INST(inst))
4554#define DT_INST_IRQ_BY_IDX(inst, idx, cell) \
4555 DT_IRQ_BY_IDX(DT_DRV_INST(inst), idx, cell)
4563#define DT_INST_IRQ_INTC_BY_IDX(inst, idx) \
4564 DT_IRQ_INTC_BY_IDX(DT_DRV_INST(inst), idx)
4572#define DT_INST_IRQ_INTC_BY_NAME(inst, name) \
4573 DT_IRQ_INTC_BY_NAME(DT_DRV_INST(inst), name)
4582#define DT_INST_IRQ_INTC(inst) \
4583 DT_INST_IRQ_INTC_BY_IDX(inst, 0)
4592#define DT_INST_IRQ_BY_NAME(inst, name, cell) \
4593 DT_IRQ_BY_NAME(DT_DRV_INST(inst), name, cell)
4601#define DT_INST_IRQ(inst, cell) DT_INST_IRQ_BY_IDX(inst, 0, cell)
4608#define DT_INST_IRQN(inst) DT_IRQN(DT_DRV_INST(inst))
4616#define DT_INST_IRQN_BY_IDX(inst, idx) DT_IRQN_BY_IDX(DT_DRV_INST(inst), idx)
4623#define DT_INST_BUS(inst) DT_BUS(DT_DRV_INST(inst))
4632#define DT_INST_ON_BUS(inst, bus) DT_ON_BUS(DT_DRV_INST(inst), bus)
4643#define DT_INST_STRING_TOKEN_OR(inst, name, default_value) \
4644 DT_STRING_TOKEN_OR(DT_DRV_INST(inst), name, default_value)
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)
4665#define DT_INST_STRING_UNQUOTED_OR(inst, name, default_value) \
4666 DT_STRING_UNQUOTED_OR(DT_DRV_INST(inst), name, default_value)
4698#define DT_HAS_COMPAT_ON_BUS_STATUS_OKAY(compat, bus) \
4699 IS_ENABLED(DT_CAT4(DT_COMPAT_, compat, _BUS_, bus))
4733#define DT_ANY_INST_ON_BUS_STATUS_OKAY(bus) \
4734 DT_HAS_COMPAT_ON_BUS_STATUS_OKAY(DT_DRV_COMPAT, bus)
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))
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)
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))
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)), \
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__)), \
4978#define DT_INST_FOREACH_NODELABEL(inst, fn) \
4979 DT_FOREACH_NODELABEL(DT_DRV_INST(inst), fn)
4992#define DT_INST_FOREACH_NODELABEL_VARGS(inst, fn, ...) \
4993 DT_FOREACH_NODELABEL_VARGS(DT_DRV_INST(inst), fn, __VA_ARGS__)
5005#define DT_INST_FOREACH_PROP_ELEM(inst, prop, fn) \
5006 DT_FOREACH_PROP_ELEM(DT_DRV_INST(inst), prop, fn)
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)
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__)
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, \
5067#define DT_INST_NODE_HAS_PROP(inst, prop) \
5068 DT_NODE_HAS_PROP(DT_DRV_INST(inst), prop)
5076#define DT_INST_NODE_HAS_COMPAT(inst, compat) \
5077 DT_NODE_HAS_COMPAT(DT_DRV_INST(inst), compat)
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)
5101#define DT_INST_PHA_HAS_CELL(inst, pha, cell) \
5102 DT_INST_PHA_HAS_CELL_AT_IDX(inst, pha, 0, cell)
5111#define DT_INST_IRQ_HAS_IDX(inst, idx) DT_IRQ_HAS_IDX(DT_DRV_INST(inst), idx)
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)
5131#define DT_INST_IRQ_HAS_CELL(inst, cell) \
5132 DT_INST_IRQ_HAS_CELL_AT_IDX(inst, 0, cell)
5140#define DT_INST_IRQ_HAS_NAME(inst, name) \
5141 DT_IRQ_HAS_NAME(DT_DRV_INST(inst), name)
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)
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)
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
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
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))
5260#define DT_COMPAT_NODE_HAS_PROP_AND_OR(inst, compat, prop) \
5261 DT_NODE_HAS_PROP(DT_INST(inst, compat), prop) ||
5267#if defined(_LINKER) || defined(_ASMLANGUAGE)
5268#define DT_U32_C(_v) (_v)
5270#define DT_U32_C(_v) UINT32_C(_v)
5277#if defined(_LINKER) || defined(_ASMLANGUAGE)
5278#define DT_U64_C(_v) (_v)
5280#define DT_U64_C(_v) UINT64_C(_v)
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
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.