3 # Copyright (C) 2016 Google, Inc
4 # Written by Simon Glass <sjg@chromium.org>
6 # SPDX-License-Identifier: GPL-2.0+
14 # This deals with a device tree, presenting it as an assortment of Node and
15 # Prop objects, representing nodes and properties, respectively. This file
16 # contains the base classes and defines the high-level API. Most of the
17 # implementation is in the FdtFallback and FdtNormal subclasses. See
18 # fdt_select.py for how to create an Fdt object.
20 def CheckErr(errnum, msg):
22 raise ValueError('Error %d: %s: %s' %
23 (errnum, libfdt.fdt_strerror(errnum), msg))
26 """A device tree property
29 name: Property name (as per the device tree)
30 value: Property value as a string of bytes, or a list of strings of
34 def __init__(self, node, offset, name):
44 offset: Integer offset in the device tree
45 name: Device tree node tname
46 path: Full path to node, along with the node name itself
47 _fdt: Device tree object
48 subnodes: A list of subnodes for this node, each a Node object
49 props: A dict of properties for this node, each a Prop object.
50 Keyed by property name
52 def __init__(self, fdt, offset, name, path):
61 """Provides simple access to a flat device tree blob.
64 fname: Filename of fdt
65 _root: Root of device tree (a Node object)
67 def __init__(self, fname):