scripts: dts: Support DT_NODE_HAS_PROP(node_id, ranges)

This is a one-line fix for edtlib, which lets gen_defines.py indicate
whether the `ranges` property exists within a given node.

Although address translation through ranges is typically automatic,
users can choose to manually inspect ranges using DT_FOREACH_RANGE(),
DT_NUM_RANGES(), and other DT_RANGES_* macros. These can be used to
implement manual translation at runtime, which is currently done for
PCIe controllers.

The only thing missing is being able to check if a node contains an
empty `ranges;`, which signifies a 1:1 translation to the parent bus.
Checking DT_NUM_RANGES() is insufficient, because it returns zero
whether or not `ranges;` is present.

It should be possible to use DT_NODE_HAS_PROP(), but it was not working,
because edtlib ignores properties which are undeclared in bindings and
don't have a default type. Add a missing PropertySpec for `ranges` with
"compound" type; it can't be "array" because it can be empty-valued.

Signed-off-by: Grzegorz Swiderski <grzegorz.swiderski@nordicsemi.no>
This commit is contained in:
Grzegorz Swiderski 2023-06-05 15:41:20 +02:00 committed by Martí Bolívar
commit dcd8d60119

View file

@ -3176,6 +3176,7 @@ _BindingLoader.add_constructor("!include", _binding_include)
_DEFAULT_PROP_TYPES: Dict[str, str] = {
"compatible": "string-array",
"status": "string",
"ranges": "compound", # NUMS or EMPTY
"reg": "array",
"reg-names": "string-array",
"label": "string",