Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions dts/binding-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ description: |
# Used to map nodes to bindings
compatible: "manufacturer,device"

# Set this to a truthy value if this binding is describing a node that
# has a struct device representation within the Zephyr device
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could make it "... has a 'struct device' representation ..."

Was wondering what kind of device a "struct device" is.

# hierarchy.
#
# (This is used to track dependencies between such devices.)
is-device: true

# The 'compatible' above would match this node:
#
# device {
Expand Down
15 changes: 12 additions & 3 deletions scripts/dts/edtlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,9 +484,9 @@ def _check_binding(self, binding, binding_path):
_err("malformed or empty '{}' in {}"
.format(prop, binding_path))

ok_top = {"title", "description", "compatible", "properties", "#cells",
"bus", "on-bus", "parent-bus", "child-bus", "parent", "child",
"child-binding", "sub-node"}
ok_top = {"title", "description", "compatible", "is-device",
"properties", "#cells", "bus", "on-bus", "parent-bus",
"child-bus", "parent", "child", "child-binding", "sub-node"}

for prop in binding:
if prop not in ok_top and not prop.endswith("-cells"):
Expand Down Expand Up @@ -645,6 +645,10 @@ class Node:
name:
The name of the node

is_device:
True if the node's binding signals that it corresponds to a Zephyr
device model struct device. False otherwise.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'struct device'


unit_addr:
An integer with the ...@<unit-address> portion of the node name,
translated through any 'ranges' properties on parent nodes, or None if
Expand Down Expand Up @@ -755,6 +759,11 @@ def name(self):
"See the class docstring"
return self._node.name

@property
def is_device(self):
"See the class docstring"
return self._binding and self._binding.get('is-device', False)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this should default to True. As long as we have a matching-compat, we're likely to be a struct device.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Defaulting to True will break #22255. #22255 introduces default bindings for special nodes. These special nodes would be recognized as devices, but are none.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noted.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a personal quirk, but make it "is-device" instead of 'is-device' for consistency with the rest of the code.


@property
def unit_addr(self):
"See the class docstring"
Expand Down
16 changes: 16 additions & 0 deletions scripts/dts/gen_defines.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def main():
continue

write_node_comment(node)
write_deps(node)
write_regs(node)
write_irqs(node)
write_props(node)
Expand Down Expand Up @@ -166,6 +167,21 @@ def relativize(path):
return path


def write_deps(node):
# Writes dependency ordinal information for the node.

def dep_ords(nodes):
return [node.dep_ordinal for node in nodes]

out_node(node, 'ORDINAL', node.dep_ordinal)
out_node_init(node, 'REQUIRES_NODES', dep_ords(node.depends_on))
out_node_init(node, 'REQUIRES_DEVS',
dep_ords([n for n in node.depends_on if n.is_device]))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe dep or the like instead of n. Not sure what n stands for.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On second thought, this isn't enough to capture parameterized dependencies; I'll rethink this. I guess we'll need to special-case by type of dependency (clock subsystem, interrupt controller, GPIO spec, etc.)

out_node_init(node, 'SUPPORTS_NODES', dep_ords(node.required_by))
out_node_init(node, 'SUPPORTS_DEVS',
dep_ords([n for n in node.required_by if n.is_device]))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use double quotes for strings here too, for consistency.



def write_regs(node):
# Writes address/size output for the registers in the node's 'reg' property

Expand Down