Merge branch 'master' of git://git.denx.de/u-boot-rockchip
[platform/kernel/u-boot.git] / include / dm / ofnode.h
index 149622a..210ddb2 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
  *
@@ -359,7 +361,7 @@ int ofnode_stringlist_search(ofnode node, const char *propname,
                             const char *string);
 
 /**
- * fdt_stringlist_get() - obtain the string at a given index in a string list
+ * ofnode_read_string_index() - obtain an indexed string from a string list
  *
  * Note that this will successfully extract strings from properties with
  * non-NUL-terminated values. For example on small-valued cell properties
@@ -380,6 +382,16 @@ int ofnode_read_string_index(ofnode node, const char *propname, int index,
                             const char **outp);
 
 /**
+ * ofnode_read_string_count() - find the number of strings in a string list
+ *
+ * @node: node to check
+ * @propname: name of the property containing the string list
+ * @return:
+ *   number of strings in the list, or -ve error value if not found
+ */
+int ofnode_read_string_count(ofnode node, const char *property);
+
+/**
  * ofnode_parse_phandle_with_args() - Find a node pointed by phandle in a list
  *
  * This function is useful to parse lists of phandles and their arguments.
@@ -423,6 +435,23 @@ int ofnode_parse_phandle_with_args(ofnode node, const char *list_name,
                                   struct ofnode_phandle_args *out_args);
 
 /**
+ * ofnode_count_phandle_with_args() - Count number of phandle in a list
+ *
+ * This function is useful to count phandles into a list.
+ * Returns number of phandle on success, on error returns appropriate
+ * errno value.
+ *
+ * @node:      device tree node containing a list
+ * @list_name: property name that contains a list
+ * @cells_name:        property name that specifies phandles' arguments count
+ * @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);
+
+/**
  * ofnode_path() - find a node by full path
  *
  * @path: Full path to node, e.g. "/bus/spi@1"
@@ -463,14 +492,14 @@ int ofnode_decode_display_timing(ofnode node, int index,
                                 struct display_timing *config);
 
 /**
- * ofnode_read_prop()- - read a node property
+ * ofnode_get_property()- - get a pointer to the value of a node property
  *
  * @node: node to read
  * @propname: property to read
  * @lenp: place to put length on success
  * @return pointer to property, or NULL if not found
  */
-const u32 *ofnode_read_prop(ofnode node, const char *propname, int *lenp);
+const void *ofnode_get_property(ofnode node, const char *propname, int *lenp);
 
 /**
  * ofnode_is_available() - check if a node is marked available
@@ -552,6 +581,26 @@ int ofnode_read_addr_cells(ofnode node);
 int ofnode_read_size_cells(ofnode node);
 
 /**
+ * ofnode_read_simple_addr_cells() - Get the address cells property in a node
+ *
+ * This function matches fdt_address_cells().
+ *
+ * @np: Node pointer to check
+ * @return value of #address-cells property in this node, or 2 if none
+ */
+int ofnode_read_simple_addr_cells(ofnode node);
+
+/**
+ * ofnode_read_simple_size_cells() - Get the size cells property in a node
+ *
+ * This function matches fdt_size_cells().
+ *
+ * @np: Node pointer to check
+ * @return value of #size-cells property in this node, or 2 if none
+ */
+int ofnode_read_simple_size_cells(ofnode node);
+
+/**
  * ofnode_pre_reloc() - check if a node should be bound before relocation
  *
  * Device tree nodes can be marked as needing-to-be-bound in the loader stages
@@ -575,4 +624,6 @@ int ofnode_read_size_cells(ofnode node);
  */
 bool ofnode_pre_reloc(ofnode node);
 
+int ofnode_read_resource(ofnode node, uint index, struct resource *res);
+
 #endif