Lines Matching +full:has +full:- +full:magic +full:- +full:addr
3 # Copyright (c) 2019 - 2020 Nordic Semiconductor ASA
6 # SPDX-License-Identifier: BSD-3-Clause
11 # Note: Do not access private (_-prefixed) identifiers from edtlib here (and
25 sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'python-devicetree',
46 with open(args.header_out, "w", encoding="utf-8") as header_file:
58 # Check to see if we have duplicate "zephyr,memory-region" property values.
61 if 'zephyr,memory-region' in node.props:
62 region = node.props['zephyr,memory-region'].val
64 sys.exit(f"ERROR: Duplicate 'zephyr,memory-region' ({region}) properties "
74 out_comment("Node's name with unit-address:")
112 def node_z_path_id(node: edtlib.Node) -> str:
115 # - the root node's path "/" has path identifier "N"
116 # - "/foo" has "N_S_foo"
117 # - "/foo/bar" has "N_S_foo_S_bar"
118 # - "/foo/bar@123" has "N_S_foo_S_bar_123"
131 def parse_args() -> argparse.Namespace:
132 # Returns parsed command-line arguments
135 parser.add_argument("--header-out", required=True,
137 parser.add_argument("--edt-pickle",
143 def write_top_comment(edt: edtlib.EDT) -> None:
173 def write_utils() -> None:
180 def write_node_comment(node: edtlib.Node) -> None:
209 # themselves couldn't contain C multi-line comments, which is
219 def relativize(path) -> Optional[str]:
235 def write_idents_and_existence(node: edtlib.Node) -> None:
258 def write_bus(node: edtlib.Node) -> None:
273 def write_special_props(node: edtlib.Node) -> None:
293 def write_ranges(node: edtlib.Node) -> None:
294 # ranges property: edtlib knows the right #address-cells and
295 # #size-cells of parent and child, and can therefore pack the
310 idx_value = range.child_bus_addr >> ((range.child_bus_cells - 1) * 32)
316 idx_value = range.child_bus_addr & ((1 << (range.child_bus_cells - 1) * 32) - 1)
337 def write_regs(node: edtlib.Node) -> None:
338 # reg property: edtlib knows the right #address-cells and
339 # #size-cells, and can therefore pack the register base addresses
351 if reg.addr is not None:
354 f"{reg.addr} /* {hex(reg.addr)} */"))
374 def write_interrupts(node: edtlib.Node) -> None:
375 # interrupts property: we have some hard-coded logic for interrupt
379 # macro magic in devicetree.h?
385 "interrupt-cells")
442 def write_compatibles(node: edtlib.Node) -> None:
461 def write_parent(node: edtlib.Node) -> None:
473 def write_children(node: edtlib.Node) -> None:
520 def write_status(node: edtlib.Node) -> None:
524 def write_pinctrls(node: edtlib.Node) -> None:
525 # Write special macros for pinctrl-<index> and pinctrl-names properties.
527 out_comment("Pin control (pinctrl-<i>, pinctrl-names) properties:")
543 # pinctrl-<pc_idx> properties are contiguous, start from 0,
554 def write_fixed_partitions(node: edtlib.Node) -> None:
555 # Macros for child nodes of each fixed-partitions node.
557 if not (node.parent and "fixed-partitions" in node.parent.compats):
561 out_comment("fixed-partitions identifier:")
566 def write_gpio_hogs(node: edtlib.Node) -> None:
567 # Write special macros for gpio-hog node properties.
582 def write_vanilla_props(node: edtlib.Node) -> None:
588 # never-ending amounts of special case code here to skip special
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:
607 # string-array of length 1.
621 # DT_N_<node-id>_P_<prop-id>_FOREACH_PROP_ELEM
626 # DT_N_<node-id>_P_<prop-id>_FOREACH_PROP_ELEM_SEP
632 # DT_N_<node-id>_P_<prop-id>_FOREACH_PROP_ELEM_VARGS
638 # DT_N_<node-id>_P_<prop-id>_FOREACH_PROP_ELEM_SEP_VARGS
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
673 # Returns a dict of macros for property 'prop' with a defined enum in their dt-binding.
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:
711 # Write dependency-related information about the node.
736 def prop2value(prop: edtlib.Property) -> edtlib.PropertyValType:
738 # a single well-defined C rvalue that it can be represented as.
750 if prop.type in ["array", "uint8-array"]:
753 if prop.type == "string-array":
756 # phandle, phandles, phandle-array, path, compound: nothing
760 def prop_len(prop: edtlib.Property) -> Optional[int]:
769 # This deliberately excludes ranges, dma-ranges, reg and interrupts.
771 # basically nonsense semantically due to #address-cells and
772 # #size-cells for "reg", #interrupt-cells for "interrupts"
773 # and #address-cells, #size-cells and the #address-cells from the
774 # parent node for "ranges" and "dma-ranges".
784 # string is treated as a string-array of length 1.
787 if (prop.type in ["array", "uint8-array", "string-array",
788 "phandles", "phandle-array"] and
789 prop.name not in ["ranges", "dma-ranges", "reg", "interrupts"]):
795 def phandle_macros(prop: edtlib.Property, macro: str) -> dict:
798 # The 'macro' argument is the N_<node-id>_P_<prop-id> bit.
806 # to use the same macros for phandle, phandles, and phandle-array.
821 elif prop.type == "phandle-array":
824 # Unspecified element. The phandle-array at this index
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>
877 # Tree-wide information such as chosen nodes is printed here.
890 # Global or tree-wide information, such as number of instances
919 # Helpers for non-INST for-each macros that take node
928 # Helpers for INST versions of for-each macros, which take
930 # avoiding an intermediate node_id --> instance number
942 if compat == "fixed-partitions":
970 def str2ident(s: str) -> str:
973 return re.sub('[-,.@/+]', '_', s.lower())
976 def list2init(l: Iterable[str]) -> str:
987 ) -> str:
990 # The macro will be left-justified to 'width' characters if that
1009 ) -> None:
1024 def out_comment(s: str, blank_before=True) -> None:
1033 # Format multi-line comments like
1049 # Format single-line comments like
1064 def escape(s: str) -> str:
1065 # Backslash-escapes any double quotes, backslashes, and new lines in 's'
1070 def quote_str(s: str) -> str:
1077 def escape_unquoted(s: str) -> str:
1086 def err(s: str) -> NoReturn: