edtlib: move PinCtrl

This is just moving the class definition higher in the file
to make it easier to type annotate the module.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
This commit is contained in:
Martí Bolívar 2023-04-14 01:22:37 -07:00 committed by Marti Bolivar
parent a5d82337b7
commit ba4b8a406e

View file

@ -824,6 +824,46 @@ class ControllerAndData:
return "<ControllerAndData, {}>".format(", ".join(fields)) return "<ControllerAndData, {}>".format(", ".join(fields))
class PinCtrl:
"""
Represents a pin control configuration for a set of pins on a device,
e.g. pinctrl-0 or pinctrl-1.
These attributes are available on PinCtrl objects:
node:
The Node instance the pinctrl-* property is on
name:
The name of the configuration, as given in pinctrl-names, or None if
there is no pinctrl-names property
name_as_token:
Like 'name', but with non-alphanumeric characters converted to underscores.
conf_nodes:
A list of Node instances for the pin configuration nodes, e.g.
the nodes pointed at by &state_1 and &state_2 in
pinctrl-0 = <&state_1 &state_2>;
"""
@property
def name_as_token(self):
"See the class docstring"
return str_as_token(self.name) if self.name is not None else None
def __repr__(self):
fields = []
if self.name is not None:
fields.append("name: " + self.name)
fields.append("configuration nodes: " + str(self.conf_nodes))
return "<PinCtrl, {}>".format(", ".join(fields))
class EDT: class EDT:
""" """
Represents a devicetree augmented with information from bindings. Represents a devicetree augmented with information from bindings.
@ -2213,46 +2253,6 @@ class Node:
return dict(zip(cell_names, data_list)) return dict(zip(cell_names, data_list))
class PinCtrl:
"""
Represents a pin control configuration for a set of pins on a device,
e.g. pinctrl-0 or pinctrl-1.
These attributes are available on PinCtrl objects:
node:
The Node instance the pinctrl-* property is on
name:
The name of the configuration, as given in pinctrl-names, or None if
there is no pinctrl-names property
name_as_token:
Like 'name', but with non-alphanumeric characters converted to underscores.
conf_nodes:
A list of Node instances for the pin configuration nodes, e.g.
the nodes pointed at by &state_1 and &state_2 in
pinctrl-0 = <&state_1 &state_2>;
"""
@property
def name_as_token(self):
"See the class docstring"
return str_as_token(self.name) if self.name is not None else None
def __repr__(self):
fields = []
if self.name is not None:
fields.append("name: " + self.name)
fields.append("configuration nodes: " + str(self.conf_nodes))
return "<PinCtrl, {}>".format(", ".join(fields))
def bindings_from_paths(yaml_paths, ignore_errors=False): def bindings_from_paths(yaml_paths, ignore_errors=False):
""" """
Get a list of Binding objects from the yaml files 'yaml_paths'. Get a list of Binding objects from the yaml files 'yaml_paths'.