Lines Matching +full:child +full:- +full:prop +full:- +full:1

2  * SPDX-License-Identifier: Apache-2.0
39 * -----------------
42 * part in DT_N_<path-id>_P_<property-id> macros, or the "prop-suf"
71 * @defgroup devicetree-generic-id Node identifiers and helpers
96 * The arguments to this macro are the names of non-root nodes in the
98 * Non-alphanumeric characters in each name must be converted to
108 * current-speed = <115200>;
119 * Example usage with DT_PROP() to get the `current-speed` property:
125 * (The `current-speed` property is also in `lowercase-and-underscores`
130 * - the first argument corresponds to a child node of the root (`soc` above)
131 * - a second argument corresponds to a child of the first argument
134 * - and so on for deeper nodes in the desired node's path
136 * @param ... lowercase-and-underscores node names along the node's path,
145 * Convert non-alphanumeric characters in the node label to
155 * current-speed = <115200>;
167 * current-speed property:
177 * L2_0: l2-cache {
178 * cache-level = <2>;
184 * Example usage to get the cache-level property:
193 * @param label lowercase-and-underscores node label name
203 * non-alphanumeric characters in the alias property to underscores to
211 * my-serial = &serial1;
217 * current-speed = <115200>;
225 * `serial@40001000` node. Notice how `my-serial` in the devicetree
227 * DT_PROP() to get the current-speed property:
233 * @param alias lowercase-and-underscores alias name.
240 * @param alias_name lowercase-and-underscores devicetree alias name
241 * @return 1 if the alias exists and refers to a node, 0 otherwise
249 * instance numbers, which are zero-based indexes specific to that
252 * lowercase-and-underscores version of the compatible, @p compat.
256 * - for each compatible, instance numbers start at 0 and are contiguous
257 * - exactly one instance number is assigned for each node with a compatible,
259 * - enabled nodes (status property is `okay` or missing) are assigned the
265 * - instance numbers **in no way reflect** any numbering scheme that
269 * - there **is no general guarantee** that the same node will have
277 * compatible = "vnd,soc-serial";
279 * current-speed = <9600>;
284 * compatible = "vnd,soc-serial";
286 * current-speed = <57600>;
291 * compatible = "vnd,soc-serial";
292 * current-speed = <115200>;
298 * `"vnd,soc-serial"`, that compatible has nodes with instance numbers
299 * 0, 1, and 2.
302 * their instance numbers are 0 and 1, but no guarantees are made
312 * // have instance number 0, so this could be the current-speed
318 * // this expands to 115200, and vice-versa.
319 * DT_PROP(DT_INST(1, vnd_soc_serial), current_speed)
327 * Notice how `"vnd,soc-serial"` in the devicetree becomes `vnd_soc_serial`
328 * (without quotes) in the DT_INST() arguments. (As usual, `current-speed`
335 * @param compat lowercase-and-underscores compatible, without quotes
347 * parent: parent-node {
348 * child: child-node {
358 * DT_PARENT(DT_NODELABEL(child))
372 * gparent: grandparent-node {
373 * parent: parent-node {
374 * child: child-node { ... }
382 * DT_GPARENT(DT_NODELABEL(child))
383 * DT_PARENT(DT_PARENT(DT_NODELABEL(child))
392 * @brief Get a node identifier for a child node
398 * soc-label: soc {
401 * current-speed = <115200>;
416 * Node labels like `serial1` cannot be used as the @p child argument
423 * @param child lowercase-and-underscores child node name
424 * @return node identifier for the node with the name referred to by 'child'
426 #define DT_CHILD(node_id, child) UTIL_CAT(node_id, DT_S_PREFIX(child)) argument
439 * node-a {
444 * node-b {
449 * node-c {
461 * This expands to a node identifier for either `node-a` or `node-b`.
462 * It will not expand to a node identifier for `node-c`, because that
465 * @param compat lowercase-and-underscores compatible, without quotes
485 * node: my-node@12345678 { ... };
493 * DT_NODE_PATH(DT_NODELABEL(node)) // "/soc/my-node@12345678"
504 * @brief Get a devicetree node's name with unit-address as a string literal
506 * This returns the node name and unit-address from a node identifier.
513 * node: my-node@12345678 { ... };
521 * DT_NODE_FULL_NAME(DT_NODELABEL(node)) // "my-node@12345678"
525 * @return the node's name with unit-address as a string in the devicetree
530 * @brief Get the node's full name, including the unit-address, as an unquoted
540 * node: my-node@12345678 { ... };
548 * DT_NODE_FULL_NAME_UNQUOTED(DT_NODELABEL(node)) // my-node@12345678
552 * @return the node's full name with unit-address as a sequence of tokens,
558 * @brief Get the node's full name, including the unit-address, as a token.
561 * converting any non-alphanumeric characters to underscores.
568 * node: my-node@12345678 { ... };
580 * @return the node's full name with unit-address as a token, i.e. without any quotes
589 * converting any non-alphanumeric characters to underscores, and
597 * node: my-node@12345678 { ... };
609 * @return the node's full name with unit-address as an uppercased token,
618 * Indexes are zero-based.
626 * c1: child-1 {};
627 * c2: child-2 {};
635 * DT_NODE_CHILD_IDX(DT_NODELABEL(c2)) // 1
644 * @brief Get the number of child nodes of a given node
647 * @return Number of child nodes
653 * @brief Get the number of child nodes of a given node
654 * which child nodes' status are okay
657 * @return Number of child nodes which status are okay
669 * The expansion evaluates to 0 or 1, but may not be a literal integer
670 * 0 or 1.
679 * @return an expression that evaluates to 1 if the node identifiers
717 * @defgroup devicetree-generic-prop Property accessors
728 * - string: a string literal
729 * - boolean: `0` if the property is false, or `1` if it is true
730 * - int: the property's value as an integer literal
731 * - array, uint8-array, string-array: an initializer expression in braces,
732 * whose elements are integer or string literals (like `{0, 1, 2}`,
734 * - phandle: a node identifier for the node with that phandle
739 * type string-array, `status` has type string, and
740 * `interrupt-controller` has type boolean.
749 * @param prop lowercase-and-underscores property name
752 #define DT_PROP(node_id, prop) DT_CAT3(node_id, _P_, prop) argument
762 * - for types array, string-array, and uint8-array, this expands
764 * - for type phandles, this expands to the number of phandles
765 * - for type phandle-array, this expands to the number of
767 * - for type phandle, this expands to 1 (so that a phandle
768 * can be treated as a degenerate case of phandles with length 1)
769 * - for type string, this expands to 1 (so that a string can be
770 * treated as a degenerate case of string-array with length 1)
774 * - reg property: use `DT_NUM_REGS(node_id)` instead
775 * - interrupts property: use `DT_NUM_IRQS(node_id)` instead
777 * It is an error to use this macro with the `ranges`, `dma-ranges`, `reg`
783 * @param prop a lowercase-and-underscores property with a logical length
786 #define DT_PROP_LEN(node_id, prop) DT_CAT4(node_id, _P_, prop, _LEN) argument
792 * this expands to DT_PROP_LEN(node_id, prop). The @p default_value
798 * @param prop a lowercase-and-underscores property with a logical length
802 #define DT_PROP_LEN_OR(node_id, prop, default_value) \ argument
803 COND_CODE_1(DT_NODE_HAS_PROP(node_id, prop), \
804 (DT_PROP_LEN(node_id, prop)), (default_value))
809 * If this returns 1, then DT_PROP_BY_IDX(node_id, prop, idx) or
810 * DT_PHA_BY_IDX(node_id, prop, idx, ...) are valid at index @p idx.
815 * - `reg` property: use DT_REG_HAS_IDX(node_id, idx) instead
816 * - `interrupts` property: use DT_IRQ_HAS_IDX(node_id, idx) instead
821 * @param prop a lowercase-and-underscores property with a logical length
823 * @return An expression which evaluates to 1 if @p idx is a valid index
826 #define DT_PROP_HAS_IDX(node_id, prop, idx) \ argument
827 IS_ENABLED(DT_CAT6(node_id, _P_, prop, _IDX_, idx, _EXISTS))
830 * @brief Is name @p name available in a `foo-names` property?
834 * - `interrupts` property: use DT_IRQ_HAS_NAME(node_id, idx) instead
841 * nx: node-x {
843 * foo-names = "event", "error";
851 * DT_PROP_HAS_NAME(DT_NODELABEL(nx), foos, event) // 1
856 * @param prop a lowercase-and-underscores `prop-names` type property
857 * @param name a lowercase-and-underscores name to check
858 * @return An expression which evaluates to 1 if "name" is an available
861 #define DT_PROP_HAS_NAME(node_id, prop, name) \ argument
862 IS_ENABLED(DT_CAT6(node_id, _P_, prop, _NAME_, name, _EXISTS))
868 * `node->property[index]`.
872 * - for types array, string-array, uint8-array, and phandles,
873 * this expands to the idx-th array element as an
877 * - for type phandle, idx must be 0 and the expansion is a node
878 * identifier (this treats phandle like a phandles of length 1)
880 * - for type string, idx must be 0 and the expansion is the
881 * entire string (this treats string like string-array of length 1)
885 * - `reg`: use DT_REG_ADDR_BY_IDX() or DT_REG_SIZE_BY_IDX() instead
886 * - `interrupts`: use DT_IRQ_BY_IDX()
887 * - `ranges`: use DT_NUM_RANGES()
888 * - `dma-ranges`: it is an error to use this property with
894 * @param prop lowercase-and-underscores property name
896 * @return a representation of the idx-th element of the property
898 #define DT_PROP_BY_IDX(node_id, prop, idx) \ argument
899 DT_CAT5(node_id, _P_, prop, _IDX_, idx)
905 * @param prop lowercase-and-underscores property name
909 #define DT_PROP_LAST(node_id, prop) \ argument
910 DT_PROP_BY_IDX(node_id, prop, UTIL_DEC(DT_PROP_LEN(node_id, prop)))
915 * If the value exists, this expands to DT_PROP(node_id, prop).
921 * @param prop lowercase-and-underscores property name
925 #define DT_PROP_OR(node_id, prop, default_value) \ argument
926 COND_CODE_1(DT_NODE_HAS_PROP(node_id, prop), \
927 (DT_PROP(node_id, prop)), (default_value))
937 * some_node: some-node {
938 * compat = "vend,enum-string-array";
943 * foo-names = "default", "option3", "option1";
950 * compatible: vend,enum-string-array
953 * type: phandle-array
955 * Explanation about what this phandle-array exactly is for.
957 * foo-names:
958 * type: string-array
966 * - default
967 * - option1
968 * - option2
969 * - option3
976 * DT_ENUM_IDX_BY_IDX(DT_NODELABEL(some_node), foo_names, 2) // 1
980 * @param prop lowercase-and-underscores property name
982 * @return zero-based index of the property's value in its enum: list
984 #define DT_ENUM_IDX_BY_IDX(node_id, prop, idx) \ argument
985 DT_CAT6(node_id, _P_, prop, _IDX_, idx, _ENUM_IDX)
988 * @brief Equivalent to @ref DT_ENUM_IDX_BY_IDX(node_id, prop, 0).
990 * @param prop lowercase-and-underscores property name
991 * @return zero-based index of the property's value in its enum: list
993 #define DT_ENUM_IDX(node_id, prop) DT_ENUM_IDX_BY_IDX(node_id, prop, 0) argument
999 * DT_ENUM_IDX_BY_IDX(node_id, prop, idx).
1004 * @param prop lowercase-and-underscores property name
1007 * @return zero-based index of the property's value in its enum if present,
1010 #define DT_ENUM_IDX_BY_IDX_OR(node_id, prop, idx, default_idx_value) \ argument
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))
1015 * @brief Equivalent to DT_ENUM_IDX_BY_IDX_OR(node_id, prop, 0, default_idx_value).
1017 * @param prop lowercase-and-underscores property name
1019 * @return zero-based index of the property's value in its enum if present,
1022 #define DT_ENUM_IDX_OR(node_id, prop, default_idx_value) \ argument
1023 DT_ENUM_IDX_BY_IDX_OR(node_id, prop, 0, default_idx_value)
1029 * @param prop lowercase-and-underscores property name
1031 * @param value lowercase-and-underscores enumeration value
1032 * @return 1 if the node property has the value @a value, 0 otherwise.
1034 #define DT_ENUM_HAS_VALUE_BY_IDX(node_id, prop, idx, value) \ argument
1035 IS_ENABLED(DT_CAT8(node_id, _P_, prop, _IDX_, idx, _ENUM_VAL_, value, _EXISTS))
1038 * @brief Equivalent to DT_ENUM_HAS_VALUE_BY_IDX(node_id, prop, 0, value).
1040 * @param prop lowercase-and-underscores property name
1041 * @param value lowercase-and-underscores enumeration value
1042 * @return 1 if the node property has the value @a value, 0 otherwise.
1044 #define DT_ENUM_HAS_VALUE(node_id, prop, value) \ argument
1045 DT_ENUM_HAS_VALUE_BY_IDX(node_id, prop, 0, value)
1051 * converting any non-alphanumeric characters to underscores. This can
1062 * n1: node-1 {
1063 * prop = "foo";
1065 * n2: node-2 {
1066 * prop = "FOO";
1068 * n3: node-3 {
1069 * prop = "123 foo";
1077 * prop:
1084 * DT_STRING_TOKEN(DT_NODELABEL(n1), prop) // foo
1085 * DT_STRING_TOKEN(DT_NODELABEL(n2), prop) // FOO
1086 * DT_STRING_TOKEN(DT_NODELABEL(n3), prop) // 123_foo
1091 * - Unlike C identifiers, the property values may begin with a
1095 * - The uppercased `"FOO"` in the DTS remains `FOO` as a token. It is
1098 * - The whitespace in the DTS `"123 foo"` string is converted to
1102 * @param prop lowercase-and-underscores property name
1103 * @return the value of @p prop as a token, i.e. without any quotes
1106 #define DT_STRING_TOKEN(node_id, prop) \ argument
1107 DT_CAT4(node_id, _P_, prop, _STRING_TOKEN)
1112 * If the value exists, this expands to DT_STRING_TOKEN(node_id, prop).
1118 * @param prop lowercase-and-underscores property name
1122 #define DT_STRING_TOKEN_OR(node_id, prop, default_value) \ argument
1123 COND_CODE_1(DT_NODE_HAS_PROP(node_id, prop), \
1124 (DT_STRING_TOKEN(node_id, prop)), (default_value))
1130 * converting any non-alphanumeric characters to underscores, and
1141 * n1: node-1 {
1142 * prop = "foo";
1144 * n2: node-2 {
1145 * prop = "123 foo";
1153 * prop:
1161 * DT_STRING_UPPER_TOKEN(DT_NODELABEL(n1), prop) // FOO
1162 * DT_STRING_UPPER_TOKEN(DT_NODELABEL(n2), prop) // 123_FOO
1167 * - Unlike C identifiers, the property values may begin with a
1171 * - The lowercased `"foo"` in the DTS becomes `FOO` as a token, i.e.
1174 * - The whitespace in the DTS `"123 foo"` string is converted to
1179 * @param prop lowercase-and-underscores property name
1180 * @return the value of @p prop as an uppercased token, i.e. without
1183 #define DT_STRING_UPPER_TOKEN(node_id, prop) \ argument
1184 DT_CAT4(node_id, _P_, prop, _STRING_UPPER_TOKEN)
1189 * If the value exists, this expands to DT_STRING_UPPER_TOKEN(node_id, prop).
1195 * @param prop lowercase-and-underscores property name
1200 #define DT_STRING_UPPER_TOKEN_OR(node_id, prop, default_value) \ argument
1201 COND_CODE_1(DT_NODE_HAS_PROP(node_id, prop), \
1202 (DT_STRING_UPPER_TOKEN(node_id, prop)), (default_value))
1207 * This removes "the quotes" from string-valued properties.
1218 * n1: node-1 {
1219 * prop = "12.7";
1221 * n2: node-2 {
1222 * prop = "0.5";
1224 * n3: node-3 {
1225 * prop = "A B C";
1231 * prop:
1236 * DT_STRING_UNQUOTED(DT_NODELABEL(n1), prop) // 12.7
1237 * DT_STRING_UNQUOTED(DT_NODELABEL(n2), prop) // 0.5
1238 * DT_STRING_UNQUOTED(DT_NODELABEL(n3), prop) // A B C
1241 * @param prop lowercase-and-underscores property name
1244 #define DT_STRING_UNQUOTED(node_id, prop) \ argument
1245 DT_CAT4(node_id, _P_, prop, _STRING_UNQUOTED)
1250 * If the value exists, this expands to DT_STRING_UNQUOTED(node_id, prop).
1256 * @param prop lowercase-and-underscores property name
1261 #define DT_STRING_UNQUOTED_OR(node_id, prop, default_value) \ argument
1262 COND_CODE_1(DT_NODE_HAS_PROP(node_id, prop), \
1263 (DT_STRING_UNQUOTED(node_id, prop)), (default_value))
1266 * @brief Get an element out of a string-array property as a token.
1269 * non-alphanumeric characters to underscores. That can be useful, for example,
1273 * string-array type.
1280 * n1: node-1 {
1281 * prop = "f1", "F2";
1283 * n2: node-2 {
1284 * prop = "123 foo", "456 FOO";
1292 * prop:
1293 * type: string-array
1299 * DT_STRING_TOKEN_BY_IDX(DT_NODELABEL(n1), prop, 0) // f1
1300 * DT_STRING_TOKEN_BY_IDX(DT_NODELABEL(n1), prop, 1) // F2
1301 * DT_STRING_TOKEN_BY_IDX(DT_NODELABEL(n2), prop, 0) // 123_foo
1302 * DT_STRING_TOKEN_BY_IDX(DT_NODELABEL(n2), prop, 1) // 456_FOO
1308 * @param prop lowercase-and-underscores property name
1310 * @return the element in @p prop at index @p idx as a token
1312 #define DT_STRING_TOKEN_BY_IDX(node_id, prop, idx) \ argument
1313 DT_CAT6(node_id, _P_, prop, _IDX_, idx, _STRING_TOKEN)
1319 * converts non-alphanumeric characters to underscores. That can be useful, for
1323 * string-array type.
1330 * n1: node-1 {
1331 * prop = "f1", "F2";
1333 * n2: node-2 {
1334 * prop = "123 foo", "456 FOO";
1342 * prop:
1343 * type: string-array
1349 * DT_STRING_UPPER_TOKEN_BY_IDX(DT_NODELABEL(n1), prop, 0) // F1
1350 * DT_STRING_UPPER_TOKEN_BY_IDX(DT_NODELABEL(n1), prop, 1) // F2
1351 * DT_STRING_UPPER_TOKEN_BY_IDX(DT_NODELABEL(n2), prop, 0) // 123_FOO
1352 * DT_STRING_UPPER_TOKEN_BY_IDX(DT_NODELABEL(n2), prop, 1) // 456_FOO
1358 * @param prop lowercase-and-underscores property name
1360 * @return the element in @p prop at index @p idx as an uppercased token
1362 #define DT_STRING_UPPER_TOKEN_BY_IDX(node_id, prop, idx) \ argument
1363 DT_CAT6(node_id, _P_, prop, _IDX_, idx, _STRING_UPPER_TOKEN)
1368 * This removes "the quotes" from string-valued item.
1374 * string-array type.
1380 * n1: node-1 {
1381 * prop = "12.7", "34.1";
1383 * n2: node-2 {
1384 * prop = "A B", "C D";
1390 * prop:
1391 * type: string-array
1395 * DT_STRING_UNQUOTED_BY_IDX(DT_NODELABEL(n1), prop, 0) // 12.7
1396 * DT_STRING_UNQUOTED_BY_IDX(DT_NODELABEL(n1), prop, 1) // 34.1
1397 * DT_STRING_UNQUOTED_BY_IDX(DT_NODELABEL(n2), prop, 0) // A B
1398 * DT_STRING_UNQUOTED_BY_IDX(DT_NODELABEL(n2), prop, 1) // C D
1401 * @param prop lowercase-and-underscores property name
1405 #define DT_STRING_UNQUOTED_BY_IDX(node_id, prop, idx) \ argument
1406 DT_CAT6(node_id, _P_, prop, _IDX_, idx, _STRING_UNQUOTED)
1411 * These are special-cased to manage the impedance mismatch between
1422 * DT_PROP(DT_PHANDLE_BY_IDX(node_id, phs, idx), prop)
1425 * That is, @p prop is a property of the phandle's node, not a
1431 * n1: node-1 {
1435 * n2: node-2 {
1439 * n3: node-3 {
1450 * DT_PROP_BY_PHANDLE_IDX(N1, foo, 1, baz) // 43
1454 * @param phs lowercase-and-underscores property with type `phandle`,
1455 * `phandles`, or `phandle-array`
1458 * @param prop lowercase-and-underscores property of the phandle's node
1461 #define DT_PROP_BY_PHANDLE_IDX(node_id, phs, idx, prop) \ argument
1462 DT_PROP(DT_PHANDLE_BY_IDX(node_id, phs, idx), prop)
1469 * idx, prop). The @p default_value parameter is not expanded in this
1475 * @param phs lowercase-and-underscores property with type `phandle`,
1476 * `phandles`, or `phandle-array`
1479 * @param prop lowercase-and-underscores property of the phandle's node
1483 #define DT_PROP_BY_PHANDLE_IDX_OR(node_id, phs, idx, prop, default_value) \ argument
1484 DT_PROP_OR(DT_PHANDLE_BY_IDX(node_id, phs, idx), prop, default_value)
1489 * This is equivalent to DT_PROP_BY_PHANDLE_IDX(node_id, ph, 0, prop).
1492 * @param ph lowercase-and-underscores property of @p node_id
1494 * @param prop lowercase-and-underscores property of the phandle's node
1497 #define DT_PROP_BY_PHANDLE(node_id, ph, prop) \ argument
1498 DT_PROP_BY_PHANDLE_IDX(node_id, ph, 0, prop)
1501 * @brief Get a phandle-array specifier cell value at an index
1504 * `node->phandle_array[index].cell`. That is, the cell value is in
1512 * #gpio-cells = <2>;
1516 * #gpio-cells = <2>;
1527 * gpio-cells:
1528 * - pin
1529 * - flags
1534 * - index 0 has specifier <17 0x1>, so its `pin` cell is 17, and its
1536 * - index 1 has specifier <5 0x3>, so `pin` is 5 and `flags` is 0x3
1544 * DT_PHA_BY_IDX(LED, gpios, 1, flags) // 0x3
1548 * @param pha lowercase-and-underscores property with type `phandle-array`
1550 * @param cell lowercase-and-underscores cell name within the specifier
1573 * @param pha lowercase-and-underscores property with type `phandle-array`
1575 * @param cell lowercase-and-underscores cell name within the specifier
1586 * @param pha lowercase-and-underscores property with type `phandle-array`
1587 * @param cell lowercase-and-underscores cell name
1601 * @param pha lowercase-and-underscores property with type `phandle-array`
1602 * @param cell lowercase-and-underscores cell name
1610 * @brief Get a value within a phandle-array specifier by name
1616 * `node->phandle_struct.name.cell`. That is, the cell value is in the
1624 * io-channels = <&adc1 10>, <&adc2 20>;
1625 * io-channel-names = "SENSOR", "BANDGAP";
1632 * io-channel-cells:
1633 * - input
1644 * @param pha lowercase-and-underscores property with type `phandle-array`
1645 * @param name lowercase-and-underscores name of a specifier in @p pha
1646 * @param cell lowercase-and-underscores cell name in the named specifier
1667 * @param pha lowercase-and-underscores property with type `phandle-array`
1668 * @param name lowercase-and-underscores name of a specifier in @p pha
1669 * @param cell lowercase-and-underscores cell name in the named specifier
1680 * `node->phandle_struct.name.phandle`. That is, the phandle array is
1696 * io-channels = <&adc1 10>, <&adc2 20>;
1697 * io-channel-names = "SENSOR", "BANDGAP";
1701 * Above, "io-channels" has two elements:
1703 * - the element named `"SENSOR"` has phandle `&adc1`
1704 * - the element named `"BANDGAP"` has phandle `&adc2`
1716 * non-alphanumeric characters are converted to underscores.
1719 * @param pha lowercase-and-underscores property with type `phandle-array`
1720 * @param name lowercase-and-underscores name of an element in @p pha
1732 * Therefore, if @p prop has type `phandle`, @p idx must be zero. (A
1734 * 1).
1739 * n1: node-1 {
1743 * n2: node-2 { ... };
1744 * n3: node-3 { ... };
1749 * - index 0 has phandle `&n2`, which is `node-2`'s phandle
1750 * - index 1 has phandle `&n3`, which is `node-3`'s phandle
1757 * DT_PHANDLE_BY_IDX(N1, foo, 0) // node identifier for node-2
1758 * DT_PHANDLE_BY_IDX(N1, foo, 1) // node identifier for node-3
1761 * Behavior is analogous for phandle-arrays.
1770 * @param prop lowercase-and-underscores property name in @p node_id
1771 * with type `phandle`, `phandles` or `phandle-array`
1772 * @param idx index into @p prop
1775 #define DT_PHANDLE_BY_IDX(node_id, prop, idx) \ argument
1776 DT_CAT6(node_id, _P_, prop, _IDX_, idx, _PH)
1781 * This is equivalent to DT_PHANDLE_BY_IDX(node_id, prop, 0). Its primary
1782 * benefit is readability when @p prop has type `phandle`.
1785 * @param prop lowercase-and-underscores property of @p node_id
1789 #define DT_PHANDLE(node_id, prop) DT_PHANDLE_BY_IDX(node_id, prop, 0) argument
1796 * @defgroup devicetree-ranges-prop ranges property
1810 * compatible = "pcie-controller";
1811 * reg = <0 1>;
1812 * #address-cells = <3>;
1813 * #size-cells = <2>;
1820 * other: other@1 {
1821 * reg = <1 1>;
1842 * If this returns 1, then DT_RANGES_CHILD_BUS_ADDRESS_BY_IDX(node_id, idx),
1855 * compatible = "pcie-controller";
1856 * reg = <0 1>;
1857 * #address-cells = <3>;
1858 * #size-cells = <2>;
1865 * other: other@1 {
1866 * reg = <1 1>;
1876 * DT_RANGES_HAS_IDX(DT_NODELABEL(pcie0), 0) // 1
1877 * DT_RANGES_HAS_IDX(DT_NODELABEL(pcie0), 1) // 1
1878 * DT_RANGES_HAS_IDX(DT_NODELABEL(pcie0), 2) // 1
1880 * DT_RANGES_HAS_IDX(DT_NODELABEL(other), 0) // 1
1881 * DT_RANGES_HAS_IDX(DT_NODELABEL(other), 1) // 1
1888 * @return 1 if @p idx is a valid register block index,
1895 * @brief Does a ranges property have child bus flags at index?
1897 * If this returns 1, then DT_RANGES_CHILD_BUS_FLAGS_BY_IDX(node_id, idx) is valid.
1899 * This macro only returns 1 for PCIe buses (i.e. nodes whose bindings specify they
1906 * #address-cells = <2>;
1909 * compatible = "pcie-controller";
1910 * reg = <0 0 1>;
1911 * #address-cells = <3>;
1912 * #size-cells = <2>;
1919 * other: other@1 {
1920 * reg = <0 1 1>;
1931 * DT_RANGES_HAS_CHILD_BUS_FLAGS_AT_IDX(DT_NODELABEL(pcie0), 0) // 1
1932 * DT_RANGES_HAS_CHILD_BUS_FLAGS_AT_IDX(DT_NODELABEL(pcie0), 1) // 1
1933 * DT_RANGES_HAS_CHILD_BUS_FLAGS_AT_IDX(DT_NODELABEL(pcie0), 2) // 1
1936 * DT_RANGES_HAS_CHILD_BUS_FLAGS_AT_IDX(DT_NODELABEL(other), 1) // 0
1943 * @return 1 if @p idx is a valid child bus flags index,
1950 * @brief Get the ranges property child bus flags at index
1952 * When the node is a PCIe bus, the Child Bus Address has an extra cell used to store some
1953 * flags, thus this cell is extracted from the Child Bus Address as Child Bus Flags field.
1959 * #address-cells = <2>;
1962 * compatible = "pcie-controller";
1963 * reg = <0 0 1>;
1964 * #address-cells = <3>;
1965 * #size-cells = <2>;
1978 * DT_RANGES_CHILD_BUS_FLAGS_BY_IDX(DT_NODELABEL(pcie0), 1) // 0x2000000
1984 * @returns range child bus flags field at idx
1990 * @brief Get the ranges property child bus address at index
1992 * When the node is a PCIe bus, the Child Bus Address has an extra cell used to store some
1993 * flags, thus this cell is removed from the Child Bus Address.
1999 * #address-cells = <2>;
2002 * compatible = "pcie-controller";
2003 * reg = <0 0 1>;
2004 * #address-cells = <3>;
2005 * #size-cells = <2>;
2012 * other: other@1 {
2013 * reg = <0 1 1>;
2025 * DT_RANGES_CHILD_BUS_ADDRESS_BY_IDX(DT_NODELABEL(pcie0), 1) // 0x10000000
2028 * DT_RANGES_CHILD_BUS_ADDRESS_BY_IDX(DT_NODELABEL(other), 1) // 0x10000000
2033 * @returns range child bus address field at idx
2042 * for child bus flags cells when the node is a PCIe bus.
2048 * #address-cells = <2>;
2051 * compatible = "pcie-controller";
2052 * reg = <0 0 1>;
2053 * #address-cells = <3>;
2054 * #size-cells = <2>;
2061 * other: other@1 {
2062 * reg = <0 1 1>;
2074 * DT_RANGES_PARENT_BUS_ADDRESS_BY_IDX(DT_NODELABEL(pcie0), 1) // 0x10000000
2077 * DT_RANGES_PARENT_BUS_ADDRESS_BY_IDX(DT_NODELABEL(other), 1) // 0x10000000
2091 * for child bus flags cells when the node is a PCIe bus.
2097 * #address-cells = <2>;
2100 * compatible = "pcie-controller";
2101 * reg = <0 0 1>;
2102 * #address-cells = <3>;
2103 * #size-cells = <2>;
2110 * other: other@1 {
2111 * reg = <0 1 1>;
2123 * DT_RANGES_LENGTH_BY_IDX(DT_NODELABEL(pcie0), 1) // 0x2eff0000
2126 * DT_RANGES_LENGTH_BY_IDX(DT_NODELABEL(other), 1) // 0x2eff0000
2147 * reg = <0 0 1>;
2183 * @defgroup devicetree-generic-vendor Vendor and model name helpers
2195 * Example vendor-prefixes.txt:
2197 * vnd A stand-in for a real vendor
2198 * zephyr Zephyr-specific binding
2203 * n1: node-1 {
2211 * DT_NODE_VENDOR_BY_IDX(DT_NODELABEL(n1), 0) // "A stand-in for a real vendor"
2212 * DT_NODE_VENDOR_BY_IDX(DT_NODELABEL(n1), 2) // "Zephyr-specific binding"
2215 * Notice that the compatible at index 1 doesn't match any entries in the
2216 * vendor prefix file and therefore index 1 is not a valid vendor index. Use
2221 * @return string literal of the idx-th vendor
2229 * If this returns 1, then DT_NODE_VENDOR_BY_IDX(node_id, idx) is valid. If it
2235 * @return 1 if @p idx is a valid vendor index,
2251 * @return string literal of the idx-th vendor
2253 * @return string literal of the idx-th vendor or "default_value"
2275 * Example vendor-prefixes.txt:
2277 * vnd A stand-in for a real vendor
2278 * zephyr Zephyr-specific binding
2282 * n1: node-1 {
2291 * Notice that the compatible at index 1 doesn't match any entries in the
2292 * vendor prefix file and therefore index 1 is not a valid model index. Use
2297 * @return string literal of the idx-th model
2305 * If this returns 1, then DT_NODE_MODEL_BY_IDX(node_id, idx) is valid. If it
2311 * @return 1 if "idx" is a valid model index,
2327 * @return string literal of the idx-th model
2329 * @return string literal of the idx-th model or "default_value"
2351 * @defgroup devicetree-reg-prop reg property
2368 * If this returns 1, then DT_REG_ADDR_BY_IDX(node_id, idx) or
2373 * @return 1 if @p idx is a valid register block index,
2382 * If this returns 1, then DT_REG_ADDR_BY_NAME(node_id, name) or
2387 * @return 1 if @p name is a valid register block name,
2402 * @return address of the idx-th register block
2425 * @return address of the idx-th register block
2439 * @return size of the idx-th register block
2454 * @brief 64-bit version of DT_REG_ADDR()
2456 * This macro version adds the appropriate suffix for 64-bit unsigned
2477 * @param name lowercase-and-underscores register specifier name
2486 * @param name lowercase-and-underscores register specifier name
2496 * @brief 64-bit version of DT_REG_ADDR_BY_NAME()
2498 * This macro version adds the appropriate suffix for 64-bit unsigned
2504 * @param name lowercase-and-underscores register specifier name
2513 * @param name lowercase-and-underscores register specifier name
2522 * @param name lowercase-and-underscores register specifier name
2537 * @defgroup devicetree-interrupts-prop interrupts property
2569 * DT_NUM_NODELABELS(DT_NODELABEL(bar)) // 1
2589 * If this returns 1, then DT_IRQ_BY_IDX(node_id, idx) is valid.
2593 * @return 1 if the idx is valid for the interrupt property
2601 * If this returns 1, then DT_IRQ_BY_IDX(node_id, idx, cell) is valid.
2606 * @return 1 if the named cell exists in the interrupt specifier at index idx
2616 * @return 1 if the named cell exists in the interrupt specifier at index 0
2623 * If this returns 1, then DT_IRQ_BY_NAME(node_id, name, cell) is valid.
2626 * @param name lowercase-and-underscores interrupt specifier name
2627 * @return 1 if "name" is a valid named specifier
2637 * "node->interrupts[index].cell".
2645 * my-serial: serial@abcd1234 {
2646 * interrupts = < 33 0 >, < 34 1 >;
2650 * Assuming the node's interrupt domain has "#interrupt-cells = <2>;" and
2657 * ------------- -----
2660 * DT_IRQ_BY_IDX(SERIAL, 1, irq, 34
2661 * DT_IRQ_BY_IDX(SERIAL, 1, priority) 1
2675 * `node->interrupts.name.cell`.
2682 * @param name lowercase-and-underscores interrupt specifier name
2703 * interrupt-controller;
2704 * #interrupt-cells = <2>;
2708 * interrupt-parent = <&gpio0>;
2709 * interrupts = <1 1>, <2 2>;
2713 * interrupts-extended = <&gpio0 3 3>, <&pic0 4>;
2717 * interrupt-controller;
2718 * #interrupt-cells = <1>;
2722 * interrupt-names = "int1", "int2";
2730 * DT_IRQ_INTC_BY_IDX(DT_NODELABEL(foo), 1) // &gpio0
2732 * DT_IRQ_INTC_BY_IDX(DT_NODELABEL(bar), 1) // &pic0
2734 * DT_IRQ_INTC_BY_IDX(DT_NODELABEL(qux), 1) // &pic0
2748 * interrupt-controller;
2749 * #interrupt-cells = <2>;
2753 * interrupt-parent = <&gpio0>;
2754 * interrupts = <1 1>, <2 2>;
2755 * interrupt-names = "int1", "int2";
2759 * interrupts-extended = <&gpio0 3 3>, <&pic0 4>;
2760 * interrupt-names = "int1", "int2";
2764 * interrupt-controller;
2765 * #interrupt-cells = <1>;
2769 * interrupt-names = "int1", "int2";
2796 * interrupt-controller;
2797 * #interrupt-cells = <2>;
2801 * interrupt-parent = <&gpio0>;
2802 * interrupts = <1 1>;
2806 * interrupts-extended = <&gpio0 3 3>;
2810 * interrupt-controller;
2811 * #interrupt-cells = <1>;
2836 /* DT helper macro to encode a node's IRQN to level 1 according to the multi-level scheme */
2838 /* DT helper macro to encode a node's IRQN to level 2 according to the multi-level scheme */
2842 /* DT helper macro to encode a node's IRQN to level 3 according to the multi-level scheme */
2851 * DT helper macro to encode a node's interrupt number according to the Zephyr's multi-level scheme
2864 * multi-level encoded
2891 * @defgroup devicetree-generic-chosen Chosen nodes
2899 * This is only valid to call if `DT_HAS_CHOSEN(prop)` is 1.
2900 * @param prop lowercase-and-underscores property name for
2904 #define DT_CHOSEN(prop) DT_CAT(DT_CHOSEN_, prop) argument
2908 * @param prop lowercase-and-underscores devicetree property
2909 * @return 1 if the chosen property exists and refers to a node,
2912 #define DT_HAS_CHOSEN(prop) IS_ENABLED(DT_CAT3(DT_CHOSEN_, prop, _EXISTS)) argument
2919 * @defgroup devicetree-generic-foreach "For-each" macros
2939 * identifier for the node. The remaining are passed-in by the caller.
2967 * identifier for the node. The remaining are passed-in by the caller.
2982 * of a child node of @p node_id to enable traversal of all ancestor nodes.
3028 * @brief Invokes @p fn for each child of @p node_id
3031 * identifier of a child node of @p node_id.
3040 * child-1 {
3043 * child-2 {
3074 * @brief Invokes @p fn for each child of @p node_id with a separator
3077 * identifier of a child node of @p node_id.
3083 * child-1 {
3086 * child-2 {
3104 * "child-1", "child-2"
3117 * @brief Invokes @p fn for each child of @p node_id with multiple arguments
3120 * identifier for the child node. The remaining are passed-in by the caller.
3135 * @brief Invokes @p fn for each child of @p node_id with separator and multiple
3139 * identifier for the child node. The remaining are passed-in by the caller.
3153 * @brief Call @p fn on the child nodes with status `okay`
3156 * identifier for the child node.
3171 * @brief Call @p fn on the child nodes with status `okay` with separator
3174 * identifier for the child node.
3190 * @brief Call @p fn on the child nodes with status `okay` with multiple
3194 * identifier for the child node. The remaining are passed-in by the caller.
3212 * @brief Call @p fn on the child nodes with status `okay` with separator and
3216 * identifier for the child node. The remaining are passed-in by the caller.
3233 * @brief Invokes @p fn for each element in the value of property @p prop.
3235 * The macro @p fn must take three parameters: fn(node_id, prop, idx).
3236 * @p node_id and @p prop are the same as what is passed to
3240 * The @p prop argument must refer to a property that can be passed to
3247 * my-ints = <1 2 3>;
3254 * #define TIMES_TWO(node_id, prop, idx) \
3255 * (2 * DT_PROP_BY_IDX(node_id, prop, idx)),
3266 * (2 * 1), (2 * 2), (2 * 3),
3272 * fn(node_id, prop, 0) fn(node_id, prop, 1) [...] fn(node_id, prop, n-1)
3274 * where `n` is the number of elements in @p prop, as it would be
3275 * returned by `DT_PROP_LEN(node_id, prop)`.
3278 * @param prop lowercase-and-underscores property name
3282 #define DT_FOREACH_PROP_ELEM(node_id, prop, fn) \ argument
3283 DT_CAT4(node_id, _P_, prop, _FOREACH_PROP_ELEM)(fn)
3286 * @brief Invokes @p fn for each element in the value of property @p prop with
3293 * my-gpios = <&gpioa 0 GPIO_ACTICE_HIGH>,
3294 * <&gpiob 1 GPIO_ACTIVE_HIGH>;
3312 * GPIO_DT_SPEC_GET_BY_IDX(DT_NODELABEL(n), my_gpios, 1)
3316 * The @p prop parameter has the same restrictions as the same parameter
3320 * @param prop lowercase-and-underscores property name
3327 #define DT_FOREACH_PROP_ELEM_SEP(node_id, prop, fn, sep) \ argument
3328 DT_CAT4(node_id, _P_, prop, _FOREACH_PROP_ELEM_SEP)(fn, sep)
3331 * @brief Invokes @p fn for each element in the value of property @p prop with
3335 * `fn(node_id, prop, idx, ...)`. @p node_id and @p prop are the same as what
3338 * remaining arguments are passed-in by the caller.
3340 * The @p prop parameter has the same restrictions as the same parameter
3344 * @param prop lowercase-and-underscores property name
3350 #define DT_FOREACH_PROP_ELEM_VARGS(node_id, prop, fn, ...) \ argument
3351 DT_CAT4(node_id, _P_, prop, _FOREACH_PROP_ELEM_VARGS)(fn, __VA_ARGS__)
3354 * @brief Invokes @p fn for each element in the value of property @p prop with
3357 * The @p prop parameter has the same restrictions as the same parameter
3361 * @param prop lowercase-and-underscores property name
3369 #define DT_FOREACH_PROP_ELEM_SEP_VARGS(node_id, prop, fn, sep, ...) \ argument
3370 DT_CAT4(node_id, _P_, prop, _FOREACH_PROP_ELEM_SEP_VARGS)( \
3422 * @param compat lowercase-and-underscores devicetree compatible
3470 * @param compat lowercase-and-underscores devicetree compatible
3486 * @param compat lowercase-and-underscores devicetree compatible
3509 * passed as tokens to @p fn as-is, without any lowercasing or
3521 * int foo = 1;
3532 * int sum = 0 + 1 + 2 + 3;
3557 * int bar = 1;
3561 * DT_FOREACH_NODELABEL_VARGS(DT_NODELABEL(foo), VAR_PLUS, 1)
3568 * int bar = 1;
3569 * int foo_added = foo + 1;
3570 * int bar_added = bar + 1;
3585 * @defgroup devicetree-generic-exist Existence checks
3601 * @return 1 if the node identifier refers to a node,
3618 * - exists in the devicetree, and
3619 * - has a status property matching the second argument
3625 * @return 1 if the node has the given status, 0 otherwise.
3641 * - exists in the devicetree, and
3642 * - has a status property as `okay`
3648 * @return 1 if the node has status as `okay`, 0 otherwise.
3656 * and the given compatible. That is, this returns 1 if and only if
3658 * expressions return 1:
3668 * @param compat lowercase-and-underscores compatible, without quotes
3669 * @return 1 if both of the above conditions are met, 0 otherwise
3677 * @param compat lowercase-and-underscores compatible, without quotes
3691 * compatible = "vnd,specific-device", "generic-device";
3695 * Example usages which evaluate to 1:
3707 * @param compat lowercase-and-underscores compatible, without quotes
3708 * @return 1 if the node's compatible property contains @p compat,
3725 * @param compat lowercase-and-underscores compatible, without quotes
3738 * truth value, use DT_PROP(node_id, prop) instead.
3741 * @param prop lowercase-and-underscores property name
3742 * @return 1 if the node has the property, 0 otherwise.
3744 #define DT_NODE_HAS_PROP(node_id, prop) \ argument
3745 IS_ENABLED(DT_CAT4(node_id, _P_, prop, _EXISTS))
3751 * If this returns 1, then the phandle-array property @p pha has a cell
3757 * @param pha lowercase-and-underscores property with type `phandle-array`
3759 * @param cell lowercase-and-underscores cell name whose existence to check
3761 * @return 1 if the named cell exists in the specifier at index idx,
3771 * @param pha lowercase-and-underscores property with type `phandle-array`
3772 * @param cell lowercase-and-underscores cell name whose existence to check
3774 * @return 1 if the named cell exists in the specifier at index 0,
3785 * @defgroup devicetree-generic-bus Bus helpers
3804 * clock-frequency = < 100000 >;
3830 * temp: temperature-sensor@76 {
3831 * compatible = "vnd,some-sensor";
3841 * DT_ON_BUS(DT_NODELABEL(temp), i2c) // 1
3846 * @param bus lowercase-and-underscores bus type as a C token (i.e.
3848 * @return 1 if the node is on a bus of the given type,
3858 * @defgroup devicetree-inst Instance-based devicetree APIs
3890 * @brief Get a node identifier for a child node of DT_DRV_INST(inst)
3893 * @param child lowercase-and-underscores child node name
3894 * @return node identifier for the node with the name referred to by 'child'
3898 #define DT_INST_CHILD(inst, child) \ argument
3899 DT_CHILD(DT_DRV_INST(inst), child)
3902 * @brief Get the number of child nodes of a given node
3908 * @return Number of child nodes
3913 * @brief Get the number of child nodes of a given node
3919 * @return Number of child nodes which status are okay
3945 * @brief Call @p fn on all child nodes of DT_DRV_INST(inst).
3948 * identifier for the child node.
3954 * @param fn macro to invoke on each child node identifier
3962 * @brief Call @p fn on all child nodes of DT_DRV_INST(inst) with a separator
3965 * identifier for the child node.
3968 * @param fn macro to invoke on each child node identifier
3978 * @brief Call @p fn on all child nodes of DT_DRV_INST(inst).
3981 * identifier for the child node. The remaining are passed-in by the caller.
3987 * @param fn macro to invoke on each child node identifier
3996 * @brief Call @p fn on all child nodes of DT_DRV_INST(inst) with separator.
3999 * identifier for the child node. The remaining are passed-in by the caller.
4002 * @param fn macro to invoke on each child node identifier
4013 * @brief Call @p fn on all child nodes of DT_DRV_INST(inst) with status `okay`.
4016 * identifier for the child node.
4019 * @param fn macro to invoke on each child node identifier
4027 * @brief Call @p fn on all child nodes of DT_DRV_INST(inst) with status `okay`
4031 * identifier for the child node.
4034 * @param fn macro to invoke on each child node identifier
4044 * @brief Call @p fn on all child nodes of DT_DRV_INST(inst) with status `okay`
4048 * identifier for the child node. The remaining are passed-in by the caller.
4051 * @param fn macro to invoke on each child node identifier
4060 * @brief Call @p fn on all child nodes of DT_DRV_INST(inst) with status `okay`
4064 * identifier for the child node. The remaining are passed-in by the caller.
4067 * @param fn macro to invoke on each child node identifier
4080 * @param prop lowercase-and-underscores property name
4082 * @return zero-based index of the property's value in its enum: list
4084 #define DT_INST_ENUM_IDX_BY_IDX(inst, prop, idx) \ argument
4085 DT_ENUM_IDX_BY_IDX(DT_DRV_INST(inst), prop, idx)
4090 * @param prop lowercase-and-underscores property name
4091 * @return zero-based index of the property's value in its enum: list
4093 #define DT_INST_ENUM_IDX(inst, prop) \ argument
4094 DT_ENUM_IDX(DT_DRV_INST(inst), prop)
4099 * @param prop lowercase-and-underscores property name
4102 * @return zero-based index of the property's value in its enum if present,
4105 #define DT_INST_ENUM_IDX_BY_IDX_OR(inst, prop, idx, default_idx_value) \ argument
4106 DT_ENUM_IDX_BY_IDX_OR(DT_DRV_INST(inst), prop, idx, default_idx_value)
4111 * @param prop lowercase-and-underscores property name
4113 * @return zero-based index of the property's value in its enum if present,
4116 #define DT_INST_ENUM_IDX_OR(inst, prop, default_idx_value) \ argument
4117 DT_ENUM_IDX_OR(DT_DRV_INST(inst), prop, default_idx_value)
4122 * @param prop lowercase-and-underscores property name
4124 * @param value lowercase-and-underscores enumeration value
4125 * @return zero-based index of the property's value in its enum
4127 #define DT_INST_ENUM_HAS_VALUE_BY_IDX(inst, prop, idx, value) \ argument
4128 DT_ENUM_HAS_VALUE_BY_IDX(DT_DRV_INST(inst), prop, idx, value)
4134 * @param prop lowercase-and-underscores property name
4135 * @param value lowercase-and-underscores enumeration value
4136 * @return 1 if the node property has the value @a value, 0 otherwise.
4138 #define DT_INST_ENUM_HAS_VALUE(inst, prop, value) \ argument
4139 DT_ENUM_HAS_VALUE(DT_DRV_INST(inst), prop, value)
4144 * @param prop lowercase-and-underscores property name
4147 #define DT_INST_PROP(inst, prop) DT_PROP(DT_DRV_INST(inst), prop) argument
4152 * @param prop lowercase-and-underscores property name
4155 #define DT_INST_PROP_LEN(inst, prop) DT_PROP_LEN(DT_DRV_INST(inst), prop) argument
4161 * @param prop lowercase-and-underscores property name
4163 * @return 1 if @p idx is a valid index into the given property,
4166 #define DT_INST_PROP_HAS_IDX(inst, prop, idx) \ argument
4167 DT_PROP_HAS_IDX(DT_DRV_INST(inst), prop, idx)
4170 * @brief Is name @p name available in a `foo-names` property?
4172 * @param prop a lowercase-and-underscores `prop-names` type property
4173 * @param name a lowercase-and-underscores name to check
4174 * @return An expression which evaluates to 1 if @p name is an available
4177 #define DT_INST_PROP_HAS_NAME(inst, prop, name) \ argument
4178 DT_PROP_HAS_NAME(DT_DRV_INST(inst), prop, name)
4183 * @param prop lowercase-and-underscores property name
4185 * @return a representation of the idx-th element of the property
4187 #define DT_INST_PROP_BY_IDX(inst, prop, idx) \ argument
4188 DT_PROP_BY_IDX(DT_DRV_INST(inst), prop, idx)
4193 * @param prop lowercase-and-underscores property name
4195 * @return DT_INST_PROP(inst, prop) or @p default_value
4197 #define DT_INST_PROP_OR(inst, prop, default_value) \ argument
4198 DT_PROP_OR(DT_DRV_INST(inst), prop, default_value)
4203 * @param prop lowercase-and-underscores property name
4205 * @return DT_INST_PROP_LEN(inst, prop) or @p default_value
4207 #define DT_INST_PROP_LEN_OR(inst, prop, default_value) \ argument
4208 DT_PROP_LEN_OR(DT_DRV_INST(inst), prop, default_value)
4215 * @param prop lowercase-and-underscores property name
4216 * @return the value of @p prop as a token, i.e. without any quotes
4219 #define DT_INST_STRING_TOKEN(inst, prop) \ argument
4220 DT_STRING_TOKEN(DT_DRV_INST(inst), prop)
4225 * @param prop lowercase-and-underscores property name
4226 * @return the value of @p prop as an uppercased token, i.e. without
4229 #define DT_INST_STRING_UPPER_TOKEN(inst, prop) \ argument
4230 DT_STRING_UPPER_TOKEN(DT_DRV_INST(inst), prop)
4237 * @param prop lowercase-and-underscores property name
4238 * @return the value of @p prop as a sequence of tokens, with no quotes
4240 #define DT_INST_STRING_UNQUOTED(inst, prop) \ argument
4241 DT_STRING_UNQUOTED(DT_DRV_INST(inst), prop)
4244 * @brief Get an element out of string-array property as a token.
4246 * @param prop lowercase-and-underscores property name
4248 * @return the element in @p prop at index @p idx as a token
4250 #define DT_INST_STRING_TOKEN_BY_IDX(inst, prop, idx) \ argument
4251 DT_STRING_TOKEN_BY_IDX(DT_DRV_INST(inst), prop, idx)
4256 * @param prop lowercase-and-underscores property name
4258 * @return the element in @p prop at index @p idx as an uppercased token
4260 #define DT_INST_STRING_UPPER_TOKEN_BY_IDX(inst, prop, idx) \ argument
4261 DT_STRING_UPPER_TOKEN_BY_IDX(DT_DRV_INST(inst), prop, idx)
4264 * @brief Get an element out of string-array property as an unquoted sequence of tokens.
4266 * @param prop lowercase-and-underscores property name
4268 * @return the value of @p prop at index @p idx as a sequence of tokens, with no quotes
4270 #define DT_INST_STRING_UNQUOTED_BY_IDX(inst, prop, idx) \ argument
4271 DT_STRING_UNQUOTED_BY_IDX(DT_DRV_INST(inst), prop, idx)
4276 * @param ph lowercase-and-underscores property of @p inst
4278 * @param prop lowercase-and-underscores property of the phandle's node
4279 * @return the value of @p prop as described in the DT_PROP() documentation
4281 #define DT_INST_PROP_BY_PHANDLE(inst, ph, prop) \ argument
4282 DT_INST_PROP_BY_PHANDLE_IDX(inst, ph, 0, prop)
4288 * @param phs lowercase-and-underscores property with type `phandle`,
4289 * `phandles`, or `phandle-array`
4292 * @param prop lowercase-and-underscores property of the phandle's node
4293 * @return the value of @p prop as described in the DT_PROP() documentation
4295 #define DT_INST_PROP_BY_PHANDLE_IDX(inst, phs, idx, prop) \ argument
4296 DT_PROP_BY_PHANDLE_IDX(DT_DRV_INST(inst), phs, idx, prop)
4299 * @brief Get a `DT_DRV_COMPAT` instance's phandle-array specifier value at an index
4301 * @param pha lowercase-and-underscores property with type `phandle-array`
4312 * @param pha lowercase-and-underscores property with type `phandle-array`
4322 * @brief Get a `DT_DRV_COMPAT` instance's phandle-array specifier value
4325 * @param pha lowercase-and-underscores property with type `phandle-array`
4334 * @param pha lowercase-and-underscores property with type `phandle-array`
4343 * @brief Get a `DT_DRV_COMPAT` instance's value within a phandle-array
4346 * @param pha lowercase-and-underscores property with type `phandle-array`
4347 * @param name lowercase-and-underscores name of a specifier in @p pha
4357 * @param pha lowercase-and-underscores property with type `phandle-array`
4358 * @param name lowercase-and-underscores name of a specifier in @p pha
4370 * @param pha lowercase-and-underscores property with type `phandle-array`
4371 * @param name lowercase-and-underscores name of an element in @p pha
4381 * @param prop lowercase-and-underscores property name in @p inst
4382 * with type `phandle`, `phandles` or `phandle-array`
4383 * @param idx index into @p prop
4384 * @return a node identifier for the phandle at index @p idx in @p prop
4386 #define DT_INST_PHANDLE_BY_IDX(inst, prop, idx) \ argument
4387 DT_PHANDLE_BY_IDX(DT_DRV_INST(inst), prop, idx)
4393 * @param prop lowercase-and-underscores property of @p inst
4397 #define DT_INST_PHANDLE(inst, prop) DT_INST_PHANDLE_BY_IDX(inst, prop, 0) argument
4403 * @return 1 if @p idx is a valid register block index,
4412 * @return 1 if @p name is a valid register block name,
4418 * @brief Get a `DT_DRV_COMPAT` instance's idx-th register block's raw address
4421 * @return address of the instance's idx-th register block
4426 * @brief Get a `DT_DRV_COMPAT` instance's idx-th register block's address
4429 * @return address of the instance's idx-th register block
4434 * @brief Get a `DT_DRV_COMPAT` instance's idx-th register block's size
4437 * @return size of the instance's idx-th register block
4445 * @param name lowercase-and-underscores register specifier name
4454 * @param name lowercase-and-underscores register specifier name
4463 * @brief 64-bit version of DT_INST_REG_ADDR_BY_NAME()
4465 * This macro version adds the appropriate suffix for 64-bit unsigned
4471 * @param name lowercase-and-underscores register specifier name
4480 * @param name lowercase-and-underscores register specifier name
4489 * @param name lowercase-and-underscores register specifier name
4512 * @brief 64-bit version of DT_INST_REG_ADDR()
4514 * This macro version adds the appropriate suffix for 64-bit unsigned
4588 * @param name lowercase-and-underscores interrupt specifier name
4614 * @return the interrupt number for the node's idx-th interrupt
4629 * @return 1 if the given instance is on a bus of the given type,
4637 * @param name lowercase-and-underscores property name
4639 * @return if @p prop exists, its value as a token, i.e. without any quotes and
4650 * @param name lowercase-and-underscores property name
4661 * @param name lowercase-and-underscores property name
4679 * temp: temperature-sensor@76 {
4680 * compatible = "vnd,some-sensor";
4690 * DT_HAS_COMPAT_ON_BUS_STATUS_OKAY(vnd_some_sensor, i2c) // 1
4693 * @param compat lowercase-and-underscores compatible, without quotes
4695 * @return 1 if any enabled node with that compatible is on that bus type,
4705 * This is a special-purpose macro which can be useful when writing
4713 * temp: temperature-sensor@76 {
4714 * compatible = "vnd,some-sensor";
4726 * DT_ANY_INST_ON_BUS_STATUS_OKAY(i2c) // 1
4730 * @return 1 if any enabled node with that compatible is on that bus type,
4740 * @param prop lowercase-and-underscores property name
4747 * compatible = "vnd,some-sensor";
4750 * foo = <1>;
4754 * sensor1: sensor@1 {
4755 * compatible = "vnd,some-sensor";
4757 * reg = <1>;
4762 * compatible = "vnd,some-sensor";
4765 * baz = <1>;
4775 * DT_ANY_INST_HAS_PROP_STATUS_OKAY(foo) // 1
4776 * DT_ANY_INST_HAS_PROP_STATUS_OKAY(bar) // 1
4780 #define DT_ANY_INST_HAS_PROP_STATUS_OKAY(prop) \ argument
4781 COND_CODE_1(IS_EMPTY(DT_ANY_INST_HAS_PROP_STATUS_OKAY_(prop)), (0), (1))
4787 * @param compat lowercase-and-underscores devicetree compatible
4788 * @param prop lowercase-and-underscores property name
4795 * compatible = "vnd,some-sensor";
4798 * foo = <1>;
4802 * sensor1: sensor@1 {
4803 * compatible = "vnd,some-sensor";
4805 * reg = <1>;
4810 * compatible = "vnd,some-sensor";
4813 * baz = <1>;
4822 * DT_ANY_COMPAT_HAS_PROP_STATUS_OKAY(vnd_some_sensor, foo) // 1
4823 * DT_ANY_COMPAT_HAS_PROP_STATUS_OKAY(vnd_some_sensor, bar) // 1
4827 #define DT_ANY_COMPAT_HAS_PROP_STATUS_OKAY(compat, prop) \ argument
4828 (DT_COMPAT_FOREACH_STATUS_OKAY_VARGS(compat, DT_COMPAT_NODE_HAS_PROP_AND_OR, prop) 0)
4837 * @param prop lowercase-and-underscores property name
4844 * compatible = "vnd,some-sensor";
4851 * sensor1: sensor@1 {
4852 * compatible = "vnd,some-sensor";
4854 * reg = <1>;
4859 * compatible = "vnd,some-sensor";
4872 * DT_ANY_INST_HAS_BOOL_STATUS_OKAY(foo) // 1
4873 * DT_ANY_INST_HAS_BOOL_STATUS_OKAY(bar) // 1
4877 #define DT_ANY_INST_HAS_BOOL_STATUS_OKAY(prop) \ argument
4878 COND_CODE_1(IS_EMPTY(DT_ANY_INST_HAS_BOOL_STATUS_OKAY_(prop)), (0), (1))
4921 * MY_FN(0) MY_FN(1)
4996 * @brief Invokes @p fn for each element of property @p prop for
4999 * Equivalent to DT_FOREACH_PROP_ELEM(DT_DRV_INST(inst), prop, fn).
5002 * @param prop lowercase-and-underscores property name
5005 #define DT_INST_FOREACH_PROP_ELEM(inst, prop, fn) \ argument
5006 DT_FOREACH_PROP_ELEM(DT_DRV_INST(inst), prop, fn)
5009 * @brief Invokes @p fn for each element of property @p prop for
5012 * Equivalent to DT_FOREACH_PROP_ELEM_SEP(DT_DRV_INST(inst), prop, fn, sep).
5015 * @param prop lowercase-and-underscores property name
5020 #define DT_INST_FOREACH_PROP_ELEM_SEP(inst, prop, fn, sep) \ argument
5021 DT_FOREACH_PROP_ELEM_SEP(DT_DRV_INST(inst), prop, fn, sep)
5024 * @brief Invokes @p fn for each element of property @p prop for
5028 * DT_FOREACH_PROP_ELEM_VARGS(DT_DRV_INST(inst), prop, fn, __VA_ARGS__)
5031 * @param prop lowercase-and-underscores property name
5037 #define DT_INST_FOREACH_PROP_ELEM_VARGS(inst, prop, fn, ...) \ argument
5038 DT_FOREACH_PROP_ELEM_VARGS(DT_DRV_INST(inst), prop, fn, __VA_ARGS__)
5041 * @brief Invokes @p fn for each element of property @p prop for
5045 * DT_FOREACH_PROP_ELEM_SEP_VARGS(DT_DRV_INST(inst), prop, fn, sep,
5049 * @param prop lowercase-and-underscores property name
5057 #define DT_INST_FOREACH_PROP_ELEM_SEP_VARGS(inst, prop, fn, sep, ...) \ argument
5058 DT_FOREACH_PROP_ELEM_SEP_VARGS(DT_DRV_INST(inst), prop, fn, sep, \
5064 * @param prop lowercase-and-underscores property name
5065 * @return 1 if the instance has the property, 0 otherwise.
5067 #define DT_INST_NODE_HAS_PROP(inst, prop) \ argument
5068 DT_NODE_HAS_PROP(DT_DRV_INST(inst), prop)
5073 * @param compat lowercase-and-underscores compatible, without quotes
5074 * @return 1 if the instance matches the compatible, 0 otherwise.
5083 * @param pha lowercase-and-underscores property with type `phandle-array`
5086 * @return 1 if the named @p cell exists in the specifier at index @p idx,
5096 * @param pha lowercase-and-underscores property with type `phandle-array`
5098 * @return 1 if the named @p cell exists in the specifier at index 0,
5108 * @return 1 if the @p idx is valid for the interrupt property
5118 * @return 1 if the named @p cell exists in the interrupt specifier at index
5128 * @return 1 if the named @p cell exists in the interrupt specifier at index 0
5137 * @param name lowercase-and-underscores interrupt specifier name
5138 * @return 1 if @p name is a valid named specifier
5151 * This macro generates token "1," for instance of a device,
5152 * identified by index @p idx, if instance has property @p prop.
5155 * @param prop property to check for
5157 * @return Macro evaluates to `1,` if instance has the property,
5160 #define DT_ANY_INST_HAS_PROP_STATUS_OKAY__(idx, prop) \ argument
5161 COND_CODE_1(DT_INST_NODE_HAS_PROP(idx, prop), (1,), ())
5165 * DT_INST_FOREACH_STATUS_OKAY_VARG to generate comma separated list of 1,
5166 * where each 1 on the list represents instance that has a property
5167 * @p prop; the list may be empty, and the upper bound on number of
5170 * @param prop property to check
5172 * @return Evaluates to list of 1s (e.g: 1,1,1,) or nothing.
5174 #define DT_ANY_INST_HAS_PROP_STATUS_OKAY_(prop) \ argument
5175 DT_INST_FOREACH_STATUS_OKAY_VARGS(DT_ANY_INST_HAS_PROP_STATUS_OKAY__, prop)
5179 * This macro generates token "1," for instance of a device,
5181 * @p prop with value 1.
5184 * @param prop property to check for
5186 * @return Macro evaluates to `1,` if instance property value is 1,
5189 #define DT_ANY_INST_HAS_BOOL_STATUS_OKAY__(idx, prop) \ argument
5190 COND_CODE_1(DT_INST_PROP(idx, prop), (1,), ())
5194 * DT_INST_FOREACH_STATUS_OKAY_VARG to generate comma separated list of 1,
5195 * where each 1 on the list represents instance that has a property
5196 * @p prop of value 1; the list may be empty, and the upper bound on number of
5199 * @param prop property to check
5201 * @return Evaluates to list of 1s (e.g: 1,1,1,) or nothing.
5203 #define DT_ANY_INST_HAS_BOOL_STATUS_OKAY_(prop) \ argument
5204 DT_INST_FOREACH_STATUS_OKAY_VARGS(DT_ANY_INST_HAS_BOOL_STATUS_OKAY__, prop)
5224 * since its macro-based API is fiddly and can be hard to get right.
5260 #define DT_COMPAT_NODE_HAS_PROP_AND_OR(inst, compat, prop) \ argument
5261 DT_NODE_HAS_PROP(DT_INST(inst, compat), prop) ||
5293 #include <zephyr/devicetree/io-channels.h>
5299 #include <zephyr/devicetree/fixed-partitions.h>
5305 #include <zephyr/devicetree/port-endpoint.h>