diff --git a/doc/guides/dts/macros.bnf b/doc/guides/dts/macros.bnf index 504b357a3be..5309cf1f81b 100644 --- a/doc/guides/dts/macros.bnf +++ b/doc/guides/dts/macros.bnf @@ -67,6 +67,8 @@ node-macro =/ %s"DT_N" path-id %s"_FOREACH_CHILD_VARGS" ; over each child node with status "okay". node-macro =/ %s"DT_N" path-id %s"_FOREACH_CHILD_STATUS_OKAY" node-macro =/ %s"DT_N" path-id %s"_FOREACH_CHILD_STATUS_OKAY_VARGS" +; The node's zero-based index in the list of it's parent's child nodes. +node-macro =/ %s"DT_N" path-id %s"_CHILD_IDX" ; The node's status macro; dt-name in this case is something like "okay" ; or "disabled". node-macro =/ %s"DT_N" path-id %s"_STATUS_" dt-name diff --git a/scripts/dts/gen_defines.py b/scripts/dts/gen_defines.py index 5c3b950a9a8..f8d72ede78f 100755 --- a/scripts/dts/gen_defines.py +++ b/scripts/dts/gen_defines.py @@ -132,6 +132,10 @@ def main(): out_dt_define(f"{node.z_path_id}_PARENT", f"DT_{node.parent.z_path_id}") + out_comment(f"Node's index in its parent's list of children:") + out_dt_define(f"{node.z_path_id}_CHILD_IDX", + node.parent.child_index(node)) + write_children(node) write_dep_info(node) write_idents_and_existence(node)