Merge tag 'xilinx-for-v2021.01-v2' of https://gitlab.denx.de/u-boot/custodians/u...
[pandora-u-boot.git] / include / dm / ofnode.h
index 618fc10..ced7f6f 100644 (file)
@@ -10,6 +10,7 @@
 /* TODO(sjg@chromium.org): Drop fdtdec.h include */
 #include <fdtdec.h>
 #include <dm/of.h>
+#include <log.h>
 
 /* Enable checks to protect against invalid calls */
 #undef OF_CHECKS
@@ -48,7 +49,7 @@ struct resource;
  *     is not a really a pointer to a node: it is an offset value. See above.
  */
 typedef union ofnode_union {
-       const struct device_node *np;   /* will be used for future live tree */
+       const struct device_node *np;
        long of_offset;
 } ofnode;
 
@@ -84,7 +85,7 @@ struct ofprop {
 };
 
 /**
- * _ofnode_to_np() - convert an ofnode to a live DT node pointer
+ * ofnode_to_np() - convert an ofnode to a live DT node pointer
  *
  * This cannot be called if the reference contains an offset.
  *
@@ -127,7 +128,7 @@ static inline bool ofnode_valid(ofnode node)
        if (of_live_active())
                return node.np != NULL;
        else
-               return node.of_offset != -1;
+               return node.of_offset >= 0;
 }
 
 /**
@@ -182,8 +183,8 @@ static inline bool ofnode_is_np(ofnode node)
         * live tree is in use.
         */
        assert(!ofnode_valid(node) ||
-              (of_live_active() ? _ofnode_to_np(node)
-                                 : _ofnode_to_np(node)));
+              (of_live_active() ? ofnode_to_np(node)
+                                 : ofnode_to_np(node)));
 #endif
        return of_live_active() && ofnode_valid(node);
 }
@@ -555,12 +556,13 @@ int ofnode_parse_phandle_with_args(ofnode node, const char *list_name,
  * @node:      device tree node containing a list
  * @list_name: property name that contains a list
  * @cells_name:        property name that specifies phandles' arguments count
+ * @cells_count: Cell count to use if @cells_name is NULL
  * @return number of phandle on success, -ENOENT if @list_name does not
  *      exist, -EINVAL if a phandle was not found, @cells_name could not
  *      be found.
  */
 int ofnode_count_phandle_with_args(ofnode node, const char *list_name,
-                                  const char *cells_name);
+                                  const char *cells_name, int cell_count);
 
 /**
  * ofnode_path() - find a node by full path
@@ -603,6 +605,28 @@ const char *ofnode_read_chosen_string(const char *propname);
  */
 ofnode ofnode_get_chosen_node(const char *propname);
 
+/**
+ * ofnode_read_aliases_prop() - get the value of a aliases property
+ *
+ * This looks for a property within the /aliases node and returns its value
+ *
+ * @propname: Property name to look for
+ * @sizep: Returns size of property, or FDT_ERR_... error code if function
+ *     returns NULL
+ * @return property value if found, else NULL
+ */
+const void *ofnode_read_aliases_prop(const char *propname, int *sizep);
+
+/**
+ * ofnode_get_aliases_node() - get a referenced node from the aliases node
+ *
+ * This looks up a named property in the aliases node and uses that as a path to
+ * look up a code.
+ *
+ * @return the referenced node if present, else ofnode_null()
+ */
+ofnode ofnode_get_aliases_node(const char *propname);
+
 struct display_timing;
 /**
  * ofnode_decode_display_timing() - decode display timings
@@ -879,6 +903,14 @@ ofnode ofnode_by_prop_value(ofnode from, const char *propname,
             ofnode_valid(node); \
             node = ofnode_next_subnode(node))
 
+/**
+ * ofnode_get_child_count() - get the child count of a ofnode
+ *
+ * @node: valid node to get its child count
+ * @return the number of subnodes
+ */
+int ofnode_get_child_count(ofnode parent);
+
 /**
  * ofnode_translate_address() - Translate a device-tree address
  *