Lines Matching full:binding
17 but a binding can also come from a 'child-binding:' key in the binding for the
23 The top-level entry points for the library are the EDT and Binding classes.
38 # create several EDT objects with independent binding paths and flags. If you
98 class Binding: class
100 Represents a parsed binding.
102 These attributes are available on Binding objects:
105 The absolute path to the file defining the binding.
108 The free-form description of the binding, or None.
111 The compatible string the binding matches.
113 This may be None. For example, it's None when the Binding is inferred
114 from node properties. It can also be None for Binding objects created
115 using 'child-binding:' with no compatible.
125 For example, if the binding YAML contains 'pin' and 'flags' cell names
132 Then the Binding object will have a 'specifier2cells' attribute mapping
137 The binding as an object parsed from YAML.
140 If nodes with this binding's 'compatible' describe a bus, a string
144 Note that this is the raw value from the binding where it can be
151 no 'bus:' in this binding.
154 If nodes with this binding's 'compatible' appear on a bus, a string
158 If this binding describes the properties of child nodes, then
159 this is a Binding object for those children; it is None otherwise.
160 A Binding object's 'child_binding.child_binding' is not None if there
161 are multiple levels of 'child-binding' descriptions in the binding.
168 Binding constructor.
171 Path to binding YAML file. May be None.
178 Optional raw content in the binding.
184 If True, it is an error if the binding does not contain a
187 if it is present in the binding.
190 If True, it is an error if the binding does not contain a
193 if it is present in the binding.
205 # inherited child binding definitions, so it has to be done
212 if "child-binding" in raw:
213 if not isinstance(raw["child-binding"], dict):
214 _err(f"malformed 'child-binding:' in {self.path}, "
215 "expected a binding (dictionary with keys/values)")
216 self.child_binding: Optional['Binding'] = Binding(
218 raw=raw["child-binding"],
242 return f"<Binding {basename}" + compat + ">"
278 # This treats 'binding_path' as the binding file being built up
306 child_filter = elem.pop('child-binding', None)
340 # Returns the contents of the binding given by 'fname' after merging
358 # Does sanity checking on the binding.
381 "properties", "child-binding"}
390 "sub-node": "use 'child-binding' instead",
476 property provided by a binding file, like its type and description.
480 binding:
481 The Binding object which defined this property.
487 The file where this property was defined. In case a binding includes
491 The type of the property as a string, as given in the binding.
497 A list of values the property may take as given in the binding, or None.
504 binding to be tokenizable. Additionally, the "enum:" values must be
515 The property's constant value as given in the binding, or None.
518 The property's default value as given in the binding, or None.
527 The specifier space for the property as given in the binding, or None.
530 def __init__(self, name: str, binding: Binding): argument
531 self.binding: Binding = binding
533 self._raw: Dict[str, Any] = self.binding.raw["properties"][name]
541 return self.binding.path
624 additional info from the 'properties:' section of the binding.
641 which comes from the 'type:' string in the binding.
677 list in the binding), or None if spec.enum is None.
803 A dictionary that maps names from the *-cells key in the binding for the
881 The description string from the binding for the node, or None if the node
882 has no binding. Leading and trailing whitespace (including newlines) is
930 The 'compatible' string for the binding that matched the node, or None if
931 the node has no binding
934 The path to the binding file for the node, or None if the node has no
935 binding
951 that are mentioned in 'properties:' in the binding.
966 If the node is a bus node (has a 'bus:' key in its binding), then this
974 by searching upwards for a parent node whose binding has a 'bus:' key,
1018 self._binding: Optional[Binding] = None
1256 True if the node's binding contains a child-binding definition, False
1268 binding = "binding " + self.binding_path
1270 binding = "no binding"
1271 return f"<Node {self.path} in '{self.edt.dts_path}', {binding}>"
1274 # Initializes Node._binding. It holds data from the node's binding file,
1276 # None if the node has no binding.
1295 binding = None
1299 binding = self.edt._compat2binding[compat, bus]
1302 if not binding:
1304 binding = self.edt._compat2binding[compat, None]
1308 self._binding = binding
1311 # No 'compatible' property. See if the parent binding has
1313 # nesting with 'child-binding:'.
1320 # No binding found
1324 # Sets up a Binding object synthesized from the properties in the node.
1327 _err(f"compatible in node with inferred binding: {self.path}")
1329 # Synthesize a 'raw' binding as if it had been parsed from YAML.
1331 'description': 'Inferred binding from properties, via edtlib.',
1357 _err(f"cannot infer binding from property: {prop} "
1363 self._binding = Binding(None, {}, raw=raw, require_compatible=False)
1365 def _binding_from_parent(self) -> Optional[Binding]:
1366 # Returns the binding from 'child-binding:' in the parent node's
1367 # binding.
1392 # bus be None means we'll always match the binding for fixed-partitions
1420 # properties on the node are declared in its binding.
1445 # 'prop_spec' is a PropertySpec object from the node's binding.
1489 # Property name from binding
1492 # PropertySpec from binding
1499 binding_path = prop_spec.binding.path
1588 # Checks that all properties are declared in the binding
1593 # Allow a few special properties to not be declared in the binding
1781 # list in the binding for the phandle nodes.
1834 # binding for 'controller' to cell values. 'data' is the raw data, as a
1839 f"for {self._node!r} lacks binding")
1844 # Treat no *-cells in the binding the same as an empty *-cells, so
1851 _err(f"unexpected '{basename}-cells:' length in binding for "
1954 to None. This allows 'fixed-partitions' binding to match regardless
2000 self._compat2binding: Dict[Tuple[str, Optional[str]], Binding] = {}
2070 return (f"<EDT for '{self.dts_path}', binding directories "
2135 # If the binding defines child bindings, link the child properties to
2140 # Not a child node, normal node on a different binding.
2172 # (<compatible>, <bus>) tuples (both strings) to Binding objects.
2174 # The Binding objects are created from YAML files discovered
2178 # contains the Binding for the 'company,dev' device, when it
2182 # self._compat2binding["company,notonbus", None] is the Binding.
2203 # Load the binding and check that it actually matches one of the
2213 f"'{binding_path}' appears in binding directories "
2216 # Convert the raw data to a Binding object, erroring out
2218 binding = self._binding(raw, binding_path, dt_compats)
2220 # Register the binding in self._compat2binding, along with
2222 while binding is not None:
2223 if binding.compatible:
2224 self._register_binding(binding)
2225 binding = binding.child_binding
2230 dt_compats: Set[str]) -> Optional[Binding]:
2231 # Convert a 'raw' binding from YAML to a Binding object and return it.
2233 # Error out if the raw data looks like an invalid binding.
2235 # Return None if the file doesn't contain a binding or the
2236 # binding's compatible isn't in dt_compats.
2240 # Empty file, binding fragment, spurious file, etc.
2249 # Initialize and return the Binding object.
2250 return Binding(binding_path, self._binding_fname2path, raw=raw)
2252 def _register_binding(self, binding: Binding) -> None: argument
2256 assert binding.compatible
2257 old_binding = self._compat2binding.get((binding.compatible,
2258 binding.on_bus))
2260 msg = (f"both {old_binding.path} and {binding.path} have "
2261 f"'compatible: {binding.compatible}'")
2262 if binding.on_bus is not None:
2263 msg += f" and 'on-bus: {binding.on_bus}'"
2266 # Register the binding.
2267 self._compat2binding[binding.compatible, binding.on_bus] = binding
2353 for binding in self._compat2binding.values():
2354 for spec in binding.prop2specs.values():
2360 f"compatible '{binding.compatible}' "
2361 f"in binding '{binding.path}' has non-tokenizable enum "
2366 f"compatible '{binding.compatible}' "
2367 f"in binding '{binding.path}' has enum for property "
2391 ignore_errors: bool = False) -> List[Binding]:
2393 Get a list of Binding objects from the yaml files 'yaml_paths'.
2403 ret.append(Binding(path, fname2path))
2413 "Exception raised for devicetree- and binding-related errors"
2484 # child-binding filter 'child_filter' has valid structure.
2502 child_copy.pop('child-binding', None))
2508 f"'child-binding': {child_copy}")
2513 "'property-blocklist:' in a 'child-binding:'")
2524 # 'raw["child-binding"]', if they exist, according to
2530 child_binding = raw.get('child-binding')
2536 child_filter = child_filter.get('child-binding')
2537 child_binding = child_binding.get('child-binding')
2595 # 'from_dict', and 'binding_path' is the path to the top-level binding.
2611 # Binding._check()
2659 # Binding._check_properties() helper. Checks 'type:', 'default:',
3245 # Custom PyYAML binding loader class to avoid modifying yaml.Loader directly,
3255 # "Default" binding for properties which are defined by the spec.
3288 _DEFAULT_PROP_BINDING: Binding = Binding(