Skip to content

Commit

Permalink
edtlib: updated to Zephyr 3.6.0 RC1
Browse files Browse the repository at this point in the history
  • Loading branch information
dottspina committed Feb 8, 2024
1 parent e89b1de commit 7479607
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 27 deletions.
5 changes: 2 additions & 3 deletions src/devicetree/README
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
This directory mirrors the edtlib implementation
found in Zephyr 3.3.0.
This directory contains a snapshot of Zephyr's python-devicetree library.

See https://github.com/zephyrproject-rtos/zephyr/tree/v3.3.0/scripts/dts.
See https://github.com/zephyrproject-rtos/zephyr/scripts/dts


- edtlib:
Expand Down
75 changes: 51 additions & 24 deletions src/devicetree/edtlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -2052,6 +2052,56 @@ def scc_order(self) -> List[List[Node]]:
except Exception as e:
raise EDTError(e)

def _process_properties_r(self, root_node, props_node):
"""
Process props_node properties for dependencies, and add those as
dependencies of root_node. Then walk through all the props_node
children and do the same recursively, maintaining the same root_node.
This ensures that on a node with child nodes, the parent node includes
the dependencies of all the child nodes as well as its own.
"""
# A Node depends on any Nodes present in 'phandle',
# 'phandles', or 'phandle-array' property values.
for prop in props_node.props.values():
if prop.type == 'phandle':
self._graph.add_edge(root_node, prop.val)
elif prop.type == 'phandles':
if TYPE_CHECKING:
assert isinstance(prop.val, list)
for phandle_node in prop.val:
self._graph.add_edge(root_node, phandle_node)
elif prop.type == 'phandle-array':
if TYPE_CHECKING:
assert isinstance(prop.val, list)
for cd in prop.val:
if cd is None:
continue
if TYPE_CHECKING:
assert isinstance(cd, ControllerAndData)
self._graph.add_edge(root_node, cd.controller)

# A Node depends on whatever supports the interrupts it
# generates.
for intr in props_node.interrupts:
self._graph.add_edge(root_node, intr.controller)

# If the binding defines child bindings, link the child properties to
# the root_node as well.
if props_node._binding and props_node._binding.child_binding:
for child in props_node.children.values():
if "compatible" in child.props:
# Not a child node, normal node on a different binding.
continue
self._process_properties_r(root_node, child)

def _process_properties(self, node):
"""
Add node dependencies based on own as well as child node properties,
start from the node itself.
"""
self._process_properties_r(node, node)

def _init_graph(self) -> None:
# Constructs a graph of dependencies between Node instances,
# which is usable for computing a partial order over the dependencies.
Expand All @@ -2069,30 +2119,7 @@ def _init_graph(self) -> None:
for child in node.children.values():
self._graph.add_edge(child, node)

# A Node depends on any Nodes present in 'phandle',
# 'phandles', or 'phandle-array' property values.
for prop in node.props.values():
if prop.type == 'phandle':
self._graph.add_edge(node, prop.val)
elif prop.type == 'phandles':
if TYPE_CHECKING:
assert isinstance(prop.val, list)
for phandle_node in prop.val:
self._graph.add_edge(node, phandle_node)
elif prop.type == 'phandle-array':
if TYPE_CHECKING:
assert isinstance(prop.val, list)
for cd in prop.val:
if cd is None:
continue
if TYPE_CHECKING:
assert isinstance(cd, ControllerAndData)
self._graph.add_edge(node, cd.controller)

# A Node depends on whatever supports the interrupts it
# generates.
for intr in node.interrupts:
self._graph.add_edge(node, intr.controller)
self._process_properties(node)

def _init_compat2binding(self) -> None:
# Creates self._compat2binding, a dictionary that maps
Expand Down
5 changes: 5 additions & 0 deletions src/devicetree/typed.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copyright (c) 2023 Christophe Dufaza <chris@openmarl.org>
#
# SPDX-License-Identifier: Apache-2.0

# Marker file for PEP 561.

0 comments on commit 7479607

Please sign in to comment.