Lines Matching full:node

51         sorted_nodes = sorted(edt.nodes, key=lambda node: node.dep_ordinal)
55 for node in sorted_nodes:
56 node.z_path_id = node_z_path_id(node)
60 for node in sorted_nodes:
61 if 'zephyr,memory-region' in node.props:
62 region = node.props['zephyr,memory-region'].val
65 f"between {regions[region].path} and {node.path}")
66 regions[region] = node
68 for node in sorted_nodes:
69 write_node_comment(node)
71 out_comment("Node's full path:")
72 out_dt_define(f"{node.z_path_id}_PATH", f'"{escape(node.path)}"')
74 out_comment("Node's name with unit-address:")
75 out_dt_define(f"{node.z_path_id}_FULL_NAME",
76 f'"{escape(node.name)}"')
77 out_dt_define(f"{node.z_path_id}_FULL_NAME_UNQUOTED",
78 f'{escape(node.name)}')
79 out_dt_define(f"{node.z_path_id}_FULL_NAME_TOKEN",
80 f'{edtlib.str_as_token(escape(node.name))}')
81 out_dt_define(f"{node.z_path_id}_FULL_NAME_UPPER_TOKEN",
82 f'{edtlib.str_as_token(escape(node.name)).upper()}')
84 if node.parent is not None:
85 out_comment(f"Node parent ({node.parent.path}) identifier:")
86 out_dt_define(f"{node.z_path_id}_PARENT",
87 f"DT_{node.parent.z_path_id}")
89 out_comment(f"Node's index in its parent's list of children:")
90 out_dt_define(f"{node.z_path_id}_CHILD_IDX",
91 node.parent.child_index(node))
93 out_comment("Helpers for dealing with node labels:")
94 out_dt_define(f"{node.z_path_id}_NODELABEL_NUM", len(node.labels))
95 out_dt_define(f"{node.z_path_id}_FOREACH_NODELABEL(fn)",
96 " ".join(f"fn({nodelabel})" for nodelabel in node.labels))
97 out_dt_define(f"{node.z_path_id}_FOREACH_NODELABEL_VARGS(fn, ...)",
98 " ".join(f"fn({nodelabel}, __VA_ARGS__)" for nodelabel in node.labels))
100 write_parent(node)
101 write_children(node)
102 write_dep_info(node)
103 write_idents_and_existence(node)
104 write_bus(node)
105 write_special_props(node)
106 write_vanilla_props(node)
112 def node_z_path_id(node: edtlib.Node) -> str: argument
113 # Return the node specific bit of the node's path identifier:
115 # - the root node's path "/" has path identifier "N"
121 # the node.
124 if node.parent is not None:
126 node.path.split("/")[1:])
156 Node dependency ordering (ordinal and path):
162 + ", ".join(node.path for node in scc))
180 def write_node_comment(node: edtlib.Node) -> None: argument
181 # Writes a comment describing 'node' to the header and configuration file
184 Devicetree node: {node.path}
186 Node identifier: DT_{node.z_path_id}
189 if node.matching_compat:
190 if node.binding_path:
192 Binding (compatible = {node.matching_compat}):
193 {relativize(node.binding_path)}
197 Binding (compatible = {node.matching_compat}):
201 if node.description:
235 def write_idents_and_existence(node: edtlib.Node) -> None: argument
236 # Writes macros related to the node's aliases, labels, etc.,
240 idents = [f"N_ALIAS_{str2ident(alias)}" for alias in node.aliases]
242 for compat in node.compats:
243 instance_no = node.edt.compat2nodes[compat].index(node)
245 # Node labels
246 idents.extend(f"N_NODELABEL_{str2ident(label)}" for label in node.labels)
249 out_dt_define(f"{node.z_path_id}_EXISTS", 1)
255 out_dt_define(ident, f"DT_{node.z_path_id}", width=maxlen)
258 def write_bus(node: edtlib.Node) -> None: argument
259 # Macros about the node's bus controller, if there is one
261 bus = node.bus_node
265 out_comment(f"Bus info (controller: '{bus.path}', type: '{node.on_buses}')")
267 for one_bus in node.on_buses:
268 out_dt_define(f"{node.z_path_id}_BUS_{str2ident(one_bus)}", 1)
270 out_dt_define(f"{node.z_path_id}_BUS", f"DT_{bus.z_path_id}")
273 def write_special_props(node: edtlib.Node) -> None: argument
280 write_regs(node)
281 write_ranges(node)
282 write_interrupts(node)
283 write_compatibles(node)
284 write_status(node)
288 write_pinctrls(node)
289 write_fixed_partitions(node)
290 write_gpio_hogs(node)
293 def write_ranges(node: edtlib.Node) -> None: argument
299 path_id = node.z_path_id
301 if node.ranges is not None:
302 idx_vals.append((f"{path_id}_RANGES_NUM", len(node.ranges)))
304 for i,range in enumerate(node.ranges):
307 if "pcie" in node.buses:
315 if "pcie" in node.buses:
334 " ".join(f"fn(DT_{path_id}, {i})" for i,range in enumerate(node.ranges)))
337 def write_regs(node: edtlib.Node) -> None: argument
344 path_id = node.z_path_id
346 if node.regs is not None:
347 idx_vals.append((f"{path_id}_REG_NUM", len(node.regs)))
349 for i, reg in enumerate(node.regs):
374 def write_interrupts(node: edtlib.Node) -> None: argument
396 path_id = node.z_path_id
398 if node.interrupts is not None:
399 idx_vals.append((f"{path_id}_IRQ_NUM", len(node.interrupts)))
401 for i, irq in enumerate(node.interrupts):
428 while node.interrupts is not None and len(node.interrupts) > 0:
429 irq = node.interrupts[0]
431 if node == irq.controller:
433 node = irq.controller
442 def write_compatibles(node: edtlib.Node) -> None: argument
443 # Writes a macro for each of the node's compatibles. We don't care
445 # them. The compatibles the node provides are what is important.
447 for i, compat in enumerate(node.compats):
449 f"{node.z_path_id}_COMPAT_MATCHES_{str2ident(compat)}", 1)
451 if node.edt.compat2vendor[compat]:
452 out_dt_define(f"{node.z_path_id}_COMPAT_VENDOR_IDX_{i}_EXISTS", 1)
453 out_dt_define(f"{node.z_path_id}_COMPAT_VENDOR_IDX_{i}",
454 quote_str(node.edt.compat2vendor[compat]))
456 if node.edt.compat2model[compat]:
457 out_dt_define(f"{node.z_path_id}_COMPAT_MODEL_IDX_{i}_EXISTS", 1)
458 out_dt_define(f"{node.z_path_id}_COMPAT_MODEL_IDX_{i}",
459 quote_str(node.edt.compat2model[compat]))
461 def write_parent(node: edtlib.Node) -> None: argument
463 def _visit_parent_node(node: edtlib.Node): argument
464 while node is not None:
465 yield node.parent
466 node = node.parent
468 # Writes helper macros for dealing with node's parent.
469 out_dt_define(f"{node.z_path_id}_FOREACH_ANCESTOR(fn)",
471 _visit_parent_node(node) if parent is not None))
473 def write_children(node: edtlib.Node) -> None: argument
474 # Writes helper macros for dealing with node's children.
476 out_comment("Helper macros for child nodes of this node.")
478 out_dt_define(f"{node.z_path_id}_CHILD_NUM", len(node.children))
481 for child in node.children.values():
485 out_dt_define(f"{node.z_path_id}_CHILD_NUM_STATUS_OKAY", ok_nodes_num)
487 out_dt_define(f"{node.z_path_id}_FOREACH_CHILD(fn)",
489 node.children.values()))
491 out_dt_define(f"{node.z_path_id}_FOREACH_CHILD_SEP(fn, sep)",
493 for child in node.children.values()))
495 out_dt_define(f"{node.z_path_id}_FOREACH_CHILD_VARGS(fn, ...)",
497 for child in node.children.values()))
499 out_dt_define(f"{node.z_path_id}_FOREACH_CHILD_SEP_VARGS(fn, sep, ...)",
501 for child in node.children.values()))
503 out_dt_define(f"{node.z_path_id}_FOREACH_CHILD_STATUS_OKAY(fn)",
505 for child in node.children.values() if child.status == "okay"))
507 out_dt_define(f"{node.z_path_id}_FOREACH_CHILD_STATUS_OKAY_SEP(fn, sep)",
509 for child in node.children.values() if child.status == "okay"))
511 out_dt_define(f"{node.z_path_id}_FOREACH_CHILD_STATUS_OKAY_VARGS(fn, ...)",
513 for child in node.children.values() if child.status == "okay"))
515 out_dt_define(f"{node.z_path_id}_FOREACH_CHILD_STATUS_OKAY_SEP_VARGS(fn, sep, ...)",
517 for child in node.children.values() if child.status == "okay"))
520 def write_status(node: edtlib.Node) -> None: argument
521 out_dt_define(f"{node.z_path_id}_STATUS_{str2ident(node.status)}", 1)
524 def write_pinctrls(node: edtlib.Node) -> None: argument
529 out_dt_define(f"{node.z_path_id}_PINCTRL_NUM", len(node.pinctrls))
531 if not node.pinctrls:
534 for pc_idx, pinctrl in enumerate(node.pinctrls):
535 out_dt_define(f"{node.z_path_id}_PINCTRL_IDX_{pc_idx}_EXISTS", 1)
545 out_dt_define(f"{node.z_path_id}_PINCTRL_IDX_{pc_idx}_TOKEN", name)
546 out_dt_define(f"{node.z_path_id}_PINCTRL_IDX_{pc_idx}_UPPER_TOKEN", name.upper())
547 out_dt_define(f"{node.z_path_id}_PINCTRL_NAME_{name}_EXISTS", 1)
548 out_dt_define(f"{node.z_path_id}_PINCTRL_NAME_{name}_IDX", pc_idx)
550 out_dt_define(f"{node.z_path_id}_PINCTRL_NAME_{name}_IDX_{idx}_PH",
554 def write_fixed_partitions(node: edtlib.Node) -> None: argument
555 # Macros for child nodes of each fixed-partitions node.
557 if not (node.parent and "fixed-partitions" in node.parent.compats):
562 out_dt_define(f"{node.z_path_id}_PARTITION_ID", flash_area_num)
566 def write_gpio_hogs(node: edtlib.Node) -> None: argument
567 # Write special macros for gpio-hog node properties.
569 macro = f"{node.z_path_id}_GPIO_HOGS"
571 for i, entry in enumerate(node.gpio_hogs):
577 out_dt_define(f"{macro}_NUM", len(node.gpio_hogs))
582 def write_vanilla_props(node: edtlib.Node) -> None: argument
584 # "properties" section of the binding for the node.
594 for prop_name, prop in node.props.items():
596 macro = f"{node.z_path_id}_P_{prop_id}"
599 # DT_N_<node-id>_P_<prop-id>
604 # DT_N_<node-id>_P_<prop-id>_IDX_0:
605 # DT_N_<node-id>_P_<prop-id>_IDX_0_EXISTS:
621 # DT_N_<node-id>_P_<prop-id>_FOREACH_PROP_ELEM
623 ' \\\n\t'.join(f'fn(DT_{node.z_path_id}, {prop_id}, {i})'
626 # DT_N_<node-id>_P_<prop-id>_FOREACH_PROP_ELEM_SEP
629 f'fn(DT_{node.z_path_id}, {prop_id}, {i})'
632 # DT_N_<node-id>_P_<prop-id>_FOREACH_PROP_ELEM_VARGS
635 f'fn(DT_{node.z_path_id}, {prop_id}, {i}, __VA_ARGS__)'
638 # DT_N_<node-id>_P_<prop-id>_FOREACH_PROP_ELEM_SEP_VARGS
641 f'fn(DT_{node.z_path_id}, {prop_id}, {i}, __VA_ARGS__)'
644 # DT_N_<node-id>_P_<prop-id>_LEN
647 # DT_N_<node-id>_P_<prop-id>_EXISTS
660 # The 'macro' argument is the N_<node-id>_P_<prop-id>... part.
664 # DT_N_<node-id>_P_<prop-id>_IDX_<i>_STRING_UNQUOTED
666 # DT_N_<node-id>_P_<prop-id>_IDX_<i>_STRING_TOKEN
668 # DT_N_<node-id>_P_<prop-id>_IDX_<i>_STRING_UPPER_TOKEN
674 # The 'macro' argument is the N_<node-id>_P_<prop-id> part.
677 # DT_N_<node-id>_P_<prop-id>_IDX_<i>_ENUM_IDX
682 # DT_N_<node-id>_P_<prop-id>_IDX_<i>_EXISTS
684 # DT_N_<node-id>_P_<prop-id>_IDX_<i>_ENUM_VAL_<val>_EXISTS 1
692 # The 'macro' argument is the N_<node-id>_P_<prop-id> part.
696 # DT_N_<node-id>_P_<prop-id>_IDX_<i>_EXISTS
699 # DT_N_<node-id>_P_<prop-id>_IDX_<i>
702 # DT_N_<node-id>_P_<prop-id>_IDX_<i>_STRING_...
710 def write_dep_info(node: edtlib.Node) -> None: argument
711 # Write dependency-related information about the node.
716 sorted_list = sorted(dep_list, key=lambda node: node.dep_ordinal)
723 out_comment("Node's dependency ordinal:")
724 out_dt_define(f"{node.z_path_id}_ORD", node.dep_ordinal)
725 out_dt_define(f"{node.z_path_id}_ORD_STR_SORTABLE", f"{node.dep_ordinal:0>5}")
727 out_comment("Ordinals for what this node depends on directly:")
728 out_dt_define(f"{node.z_path_id}_REQUIRES_ORDS",
729 fmt_dep_list(node.depends_on))
731 out_comment("Ordinals for what depends directly on this node:")
732 out_dt_define(f"{node.z_path_id}_SUPPORTS_ORDS",
733 fmt_dep_list(node.required_by))
774 # parent node for "ranges" and "dma-ranges".
798 # The 'macro' argument is the N_<node-id>_P_<prop-id> bit.
817 for i, node in enumerate(prop.val):
818 ret[f"{macro}_IDX_{i}"] = f"DT_{node.z_path_id}"
819 ret[f"{macro}_IDX_{i}_PH"] = f"DT_{node.z_path_id}"
839 # the phandle's node) and associated data macros for a
845 # DT_N_<node-id>_P_<prop-id>_IDX_<i>_EXISTS
847 # DT_N_<node-id>_P_<prop-id>_IDX_<i>_PH
849 # DT_N_<node-id>_P_<prop-id>_IDX_<i>_VAL_<VAL>
858 # DT_N_<node-id>_P_<prop-id>_IDX_<i>_EXISTS
860 # DT_N_<node-id>_P_<prop-id>_IDX_<i>_NAME
862 # DT_N_<node-id>_P_<prop-id>_NAME_<NAME>_PH
864 # DT_N_<node-id>_P_<prop-id>_NAME_<NAME>_EXISTS
866 # DT_N_<node-id>_P_<prop-id>_NAME_<NAME>_VAL_<VAL>
881 for name, node in edt.chosen_nodes.items():
882 chosen[f"DT_CHOSEN_{str2ident(name)}"] = f"DT_{node.z_path_id}"
896 " ".join(f"fn(DT_{node.z_path_id})" for node in edt.nodes))
898 " ".join(f"fn(DT_{node.z_path_id})" for node in edt.nodes
899 if node.status == "okay"))
901 " ".join(f"fn(DT_{node.z_path_id}, __VA_ARGS__)" for node in edt.nodes))
903 " ".join(f"fn(DT_{node.z_path_id}, __VA_ARGS__)" for node in edt.nodes
904 if node.status == "okay"))
910 for node in okay_nodes:
911 buses = node.on_buses
919 # Helpers for non-INST for-each macros that take node
922 " ".join(f"fn(DT_{node.z_path_id})"
923 for node in okay_nodes))
925 " ".join(f"fn(DT_{node.z_path_id}, __VA_ARGS__)"
926 for node in okay_nodes))
934 " ".join(f"fn({edt.compat2nodes[compat].index(node)})"
935 for node in okay_nodes))
937 " ".join(f"fn({edt.compat2nodes[compat].index(node)}, __VA_ARGS__)"
938 for node in okay_nodes))
941 for node in nodes:
943 for child in node.children.values():