summaryrefslogtreecommitdiffstats
path: root/include/dm
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2018-07-10 10:29:14 -0400
committerTom Rini <trini@konsulko.com>2018-07-10 10:29:14 -0400
commite3396ffd720877976141fa0b76a0b8ee9643d7d1 (patch)
tree7baee90ec8c5759a420f37a796b91fc77f69e7c7 /include/dm
parent495c70f9dfad1a5428ec84b52e8667ea4760ecd6 (diff)
parent16b8d6b76992690c65c58dc8b0591496cc5e46ef (diff)
downloadu-boot-e3396ffd720877976141fa0b76a0b8ee9643d7d1.tar.gz
u-boot-e3396ffd720877976141fa0b76a0b8ee9643d7d1.tar.xz
u-boot-e3396ffd720877976141fa0b76a0b8ee9643d7d1.zip
Merge git://git.denx.de/u-boot-dm
Diffstat (limited to 'include/dm')
-rw-r--r--include/dm/device-internal.h4
-rw-r--r--include/dm/of_access.h16
-rw-r--r--include/dm/of_extra.h51
-rw-r--r--include/dm/ofnode.h48
4 files changed, 114 insertions, 5 deletions
diff --git a/include/dm/device-internal.h b/include/dm/device-internal.h
index 5a4d50cbbe..f4af15448f 100644
--- a/include/dm/device-internal.h
+++ b/include/dm/device-internal.h
@@ -40,6 +40,10 @@ int device_bind(struct udevice *parent, const struct driver *drv,
const char *name, void *platdata, int of_offset,
struct udevice **devp);
+int device_bind_ofnode(struct udevice *parent, const struct driver *drv,
+ const char *name, void *platdata, ofnode node,
+ struct udevice **devp);
+
/**
* device_bind_with_driver_data() - Create a device and bind it to a driver
*
diff --git a/include/dm/of_access.h b/include/dm/of_access.h
index 74f0606e07..dd1abb8e97 100644
--- a/include/dm/of_access.h
+++ b/include/dm/of_access.h
@@ -219,6 +219,22 @@ struct device_node *of_find_node_by_phandle(phandle handle);
int of_read_u32(const struct device_node *np, const char *propname, u32 *outp);
/**
+ * of_read_u64() - Find and read a 64-bit integer from a property
+ *
+ * Search for a property in a device node and read a 64-bit value from
+ * it.
+ *
+ * @np: device node from which the property value is to be read.
+ * @propname: name of the property to be searched.
+ * @outp: pointer to return value, modified only if return value is 0.
+ *
+ * @return 0 on success, -EINVAL if the property does not exist,
+ * -ENODATA if property does not have a value, and -EOVERFLOW if the
+ * property data isn't large enough.
+ */
+int of_read_u64(const struct device_node *np, const char *propname, u64 *outp);
+
+/**
* of_read_u32_array() - Find and read an array of 32 bit integers
*
* Search for a property in a device node and read 32-bit value(s) from
diff --git a/include/dm/of_extra.h b/include/dm/of_extra.h
index 6f1529689f..97988b6663 100644
--- a/include/dm/of_extra.h
+++ b/include/dm/of_extra.h
@@ -34,12 +34,55 @@ struct fmap_entry {
/**
* Read a flash entry from the fdt
*
- * @param node Reference to node to read
- * @param name Name of node being read
+ * @param node Reference to node to read
* @param entry Place to put offset and size of this node
* @return 0 if ok, -ve on error
*/
-int of_read_fmap_entry(ofnode node, const char *name,
- struct fmap_entry *entry);
+int ofnode_read_fmap_entry(ofnode node, struct fmap_entry *entry);
+
+/**
+ * ofnode_decode_region() - Decode a memory region from a node
+ *
+ * Look up a property in a node which contains a memory region address and
+ * size. Then return a pointer to this address.
+ *
+ * The property must hold one address with a length. This is only tested on
+ * 32-bit machines.
+ *
+ * @param node ofnode to examine
+ * @param prop_name name of property to find
+ * @param basep Returns base address of region
+ * @param size Returns size of region
+ * @return 0 if ok, -1 on error (property not found)
+ */
+int ofnode_decode_region(ofnode node, const char *prop_name, fdt_addr_t *basep,
+ fdt_size_t *sizep);
+
+/**
+ * ofnode_decode_memory_region()- Decode a named region within a memory bank
+ *
+ * This function handles selection of a memory region. The region is
+ * specified as an offset/size within a particular type of memory.
+ *
+ * The properties used are:
+ *
+ * <mem_type>-memory<suffix> for the name of the memory bank
+ * <mem_type>-offset<suffix> for the offset in that bank
+ *
+ * The property value must have an offset and a size. The function checks
+ * that the region is entirely within the memory bank.5
+ *
+ * @param node ofnode containing the properties (-1 for /config)
+ * @param mem_type Type of memory to use, which is a name, such as
+ * "u-boot" or "kernel".
+ * @param suffix String to append to the memory/offset
+ * property names
+ * @param basep Returns base of region
+ * @param sizep Returns size of region
+ * @return 0 if OK, -ive on error
+ */
+int ofnode_decode_memory_region(ofnode config_node, const char *mem_type,
+ const char *suffix, fdt_addr_t *basep,
+ fdt_size_t *sizep);
#endif
diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h
index 5af6b7e616..cd08a7e4d0 100644
--- a/include/dm/ofnode.h
+++ b/include/dm/ofnode.h
@@ -237,6 +237,16 @@ int ofnode_read_u32_default(ofnode ref, const char *propname, u32 def);
int ofnode_read_s32_default(ofnode node, const char *propname, s32 def);
/**
+ * ofnode_read_u64_default() - Read a 64-bit integer from a property
+ *
+ * @ref: valid node reference to read property from
+ * @propname: name of the property to read from
+ * @def: default value to return if the property has no value
+ * @return property value, or @def if not found
+ */
+int ofnode_read_u64_default(ofnode node, const char *propname, u64 def);
+
+/**
* ofnode_read_string() - Read a string from a property
*
* @ref: valid node reference to read property from
@@ -252,6 +262,7 @@ const char *ofnode_read_string(ofnode node, const char *propname);
* @propname: name of the property to read
* @out_values: pointer to return value, modified only if return value is 0
* @sz: number of array elements to read
+ * @return 0 if OK, -ve on error
*
* Search for a property in a device node and read 32-bit value(s) from
* it. Returns 0 on success, -EINVAL if the property does not exist,
@@ -480,6 +491,7 @@ ofnode ofnode_path(const char *path);
* This looks for a property within the /chosen node and returns its value
*
* @propname: Property name to look for
+ * @return property value if found, else NULL
*/
const char *ofnode_get_chosen_prop(const char *propname);
@@ -635,15 +647,49 @@ int ofnode_read_simple_size_cells(ofnode node);
* new platforms.
*
* @node: node to check
- * @eturns true if node is needed in SPL/TL, false otherwise
+ * @return true if node is needed in SPL/TL, false otherwise
*/
bool ofnode_pre_reloc(ofnode node);
+/**
+ * ofnode_read_resource() - Read a resource from a node
+ *
+ * Read resource information from a node at the given index
+ *
+ * @node: Node to read from
+ * @index: Index of resource to read (0 = first)
+ * @res: Returns resource that was read, on success
+ * @return 0 if OK, -ve on error
+ */
int ofnode_read_resource(ofnode node, uint index, struct resource *res);
+
+/**
+ * ofnode_read_resource_byname() - Read a resource from a node by name
+ *
+ * Read resource information from a node matching the given name. This uses a
+ * 'reg-names' string list property with the names matching the associated
+ * 'reg' property list.
+ *
+ * @node: Node to read from
+ * @name: Name of resource to read
+ * @res: Returns resource that was read, on success
+ * @return 0 if OK, -ve on error
+ */
int ofnode_read_resource_byname(ofnode node, const char *name,
struct resource *res);
/**
+ * ofnode_by_compatible() - Find the next compatible node
+ *
+ * Find the next node after @from that is compatible with @compat
+ *
+ * @from: ofnode to start from (use ofnode_null() to start at the beginning)
+ * @compat: Compatible string to match
+ * @return ofnode found, or ofnode_null() if none
+ */
+ofnode ofnode_by_compatible(ofnode from, const char *compat);
+
+/**
* ofnode_for_each_subnode() - iterate over all subnodes of a parent
*
* @node: child node (ofnode, lvalue)