]> git.sur5r.net Git - u-boot/blobdiff - tools/dtoc/fdt_normal.py
mmc: zynq: rename CONFIG_ZYNQ_SDHCI to CONFIG_MMC_SDHCI_ZYNQ
[u-boot] / tools / dtoc / fdt_normal.py
index f2cf608b1e881c7e778844251f39c055bd96cfe9..cce5c06d8c15a677fbd84468f74f3516673cc82a 100644 (file)
@@ -43,6 +43,14 @@ class Prop(PropBase):
             return
         self.type, self.value = self.BytesToValue(bytes)
 
+    def GetOffset(self):
+        """Get the offset of a property
+
+        Returns:
+            The offset of the property (struct fdt_property) within the file
+        """
+        return self._node._fdt.GetStructOffset(self._offset)
+
 class Node(NodeBase):
     """A device tree node
 
@@ -73,7 +81,7 @@ class Node(NodeBase):
         This fills in the props and subnodes properties, recursively
         searching into subnodes so that the entire tree is built.
         """
-        self.props = self._fdt.GetProps(self, self.path)
+        self.props = self._fdt.GetProps(self)
 
         offset = libfdt.fdt_first_subnode(self._fdt.GetFdt(), self.Offset())
         while offset >= 0:
@@ -151,7 +159,7 @@ class FdtNormal(Fdt):
         fdt_len = libfdt.fdt_totalsize(self._fdt)
         del self._fdt[fdt_len:]
 
-    def GetProps(self, node, path):
+    def GetProps(self, node):
         """Get all properties from a node.
 
         Args:
@@ -164,11 +172,8 @@ class FdtNormal(Fdt):
         Raises:
             ValueError: if the node does not exist.
         """
-        offset = libfdt.fdt_path_offset(self._fdt, path)
-        if offset < 0:
-            libfdt.Raise(offset)
         props_dict = {}
-        poffset = libfdt.fdt_first_property_offset(self._fdt, offset)
+        poffset = libfdt.fdt_first_property_offset(self._fdt, node._offset)
         while poffset >= 0:
             dprop, plen = libfdt.fdt_get_property_by_offset(self._fdt, poffset)
             prop = Prop(node, poffset, libfdt.String(self._fdt, dprop.nameoff),
@@ -193,6 +198,16 @@ class FdtNormal(Fdt):
         """Refresh the offset cache"""
         self._root.Refresh(0)
 
+    def GetStructOffset(self, offset):
+        """Get the file offset of a given struct offset
+
+        Args:
+            offset: Offset within the 'struct' region of the device tree
+        Returns:
+            Position of @offset within the device tree binary
+        """
+        return libfdt.fdt_off_dt_struct(self._fdt) + offset
+
     @classmethod
     def Node(self, fdt, offset, name, path):
         """Create a new node