From 65a2779f25a38d65d38330f0665e963e7c4a8649 Mon Sep 17 00:00:00 2001 From: Declan Snyder Date: Sat, 12 Oct 2024 08:43:03 -0500 Subject: [PATCH] WIP addadding child-nodes to bindings mapping --- .../python-devicetree/src/devicetree/edtlib.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/scripts/dts/python-devicetree/src/devicetree/edtlib.py b/scripts/dts/python-devicetree/src/devicetree/edtlib.py index 26c1488950049..cd1cf53ad17d3 100644 --- a/scripts/dts/python-devicetree/src/devicetree/edtlib.py +++ b/scripts/dts/python-devicetree/src/devicetree/edtlib.py @@ -243,6 +243,19 @@ def __init__(self, path: Optional[str], fname2path: Dict[str, str], else: self.child_binding = None + self.child_nodes: Dict[str, 'Binding'] = {} + if "child-nodes" in raw: + #breakpoint() + if not (isinstance(raw["child-nodes"], list) and \ + all(isinstance(child_node, dict) for child_node in raw["child-nodes"])): + _err(f"malformed 'child-nodes:' in {self.path}, " + "expected a sequence of bindings (list of dictionaries)") + for child_node in raw["child-nodes"]: + self.child_nodes[child_node["name"]]: Optional['Binding'] = Binding( + path, fname2path, child_node, + require_compatible=False, require_description=False) + + # Make sure this is a well defined object. self._check(require_compatible, require_description) @@ -479,7 +492,7 @@ def _check(self, require_compatible: bool, require_description: bool): # Allowed top-level keys. The 'include' key should have been # removed by _load_raw() already. ok_top = {"description", "compatible", "bus", "on-bus", - "properties", "child-binding"} + "properties", "child-binding", "child-nodes", "name"} # Descriptive errors for legacy bindings. legacy_errors = { @@ -1443,6 +1456,9 @@ def _binding_from_parent(self) -> Optional[Binding]: if not pbinding: return None + if pbinding.child_nodes and self.name in pbinding.child_nodes: + return pbinding.child_nodes[self.name] + if pbinding.child_binding: return pbinding.child_binding