Merge git://git.denx.de/u-boot-sunxi
[oweals/u-boot.git] / include / dm / ofnode.h
index 8eecce59d1059a4f78564d216f0c2da91bc25537..8b9932a569ce5a33a813f3bdb11ed2fc880c210b 100644 (file)
@@ -15,6 +15,8 @@
 /* Enable checks to protect against invalid calls */
 #undef OF_CHECKS
 
+struct resource;
+
 /**
  * ofnode - reference to a device tree node
  *
@@ -43,7 +45,7 @@
  * the DT.
  *
  * @np: Pointer to device node, used for live tree
- * @flat_ptr: Pointer into flat device tree, used for flat tree. Note that this
+ * @of_offset: Pointer into flat device tree, used for flat tree. Note that this
  *     is not a really a pointer to a node: it is an offset value. See above.
  */
 typedef union ofnode_union {
@@ -622,4 +624,32 @@ int ofnode_read_simple_size_cells(ofnode node);
  */
 bool ofnode_pre_reloc(ofnode node);
 
+int ofnode_read_resource(ofnode node, uint index, struct resource *res);
+int ofnode_read_resource_byname(ofnode node, const char *name,
+                               struct resource *res);
+
+/**
+ * ofnode_for_each_subnode() - iterate over all subnodes of a parent
+ *
+ * @node:       child node (ofnode, lvalue)
+ * @parent:     parent node (ofnode)
+ *
+ * This is a wrapper around a for loop and is used like so:
+ *
+ *     ofnode node;
+ *
+ *     ofnode_for_each_subnode(node, parent) {
+ *             Use node
+ *             ...
+ *     }
+ *
+ * Note that this is implemented as a macro and @node is used as
+ * iterator in the loop. The parent variable can be a constant or even a
+ * literal.
+ */
+#define ofnode_for_each_subnode(node, parent) \
+       for (node = ofnode_first_subnode(parent); \
+            ofnode_valid(node); \
+            node = ofnode_next_subnode(node))
+
 #endif