aboutsummaryrefslogtreecommitdiff
path: root/tools/dtoc/fdt.py
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2018-07-06 10:27:38 -0600
committerSimon Glass <sjg@chromium.org>2018-07-09 09:11:00 -0600
commit116adecb5e8e343cfc73a55f25a5d3d8463f4512 (patch)
tree98514b5da662a1bc1df3cb88a6f3671e35c55fd0 /tools/dtoc/fdt.py
parentfe57c784ad7187318a3aa6923d82095555bb50be (diff)
downloadu-boot-116adecb5e8e343cfc73a55f25a5d3d8463f4512.zip
u-boot-116adecb5e8e343cfc73a55f25a5d3d8463f4512.tar.gz
u-boot-116adecb5e8e343cfc73a55f25a5d3d8463f4512.tar.bz2
dtoc: Add functions to add integer properties
Add a few simple functions to add a placeholder integer property, and set its value. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools/dtoc/fdt.py')
-rw-r--r--tools/dtoc/fdt.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/tools/dtoc/fdt.py b/tools/dtoc/fdt.py
index e7703c1..9d69b42 100644
--- a/tools/dtoc/fdt.py
+++ b/tools/dtoc/fdt.py
@@ -270,6 +270,33 @@ class Node:
del self.props[prop_name]
self._fdt.Invalidate()
+ def AddZeroProp(self, prop_name):
+ """Add a new property to the device tree with an integer value of 0.
+
+ Args:
+ prop_name: Name of property
+ """
+ fdt_obj = self._fdt._fdt_obj
+ if fdt_obj.setprop_u32(self.Offset(), prop_name, 0,
+ (libfdt.NOSPACE,)) == -libfdt.NOSPACE:
+ fdt_obj.open_into(fdt_obj.totalsize() + 1024)
+ fdt_obj.setprop_u32(self.Offset(), prop_name, 0)
+ self.props[prop_name] = Prop(self, -1, prop_name, '\0' * 4)
+ self._fdt.Invalidate()
+
+ def SetInt(self, prop_name, val):
+ """Update an integer property int the device tree.
+
+ This is not allowed to change the size of the FDT.
+
+ Args:
+ prop_name: Name of property
+ val: Value to set
+ """
+ fdt_obj = self._fdt._fdt_obj
+ fdt_obj.setprop_u32(self.Offset(), prop_name, val)
+
+
class Fdt:
"""Provides simple access to a flat device tree blob using libfdts.