From 7e5196c409f17091f2aeca144c6d76750df81cc4 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 11 Jun 2018 13:07:10 -0600 Subject: dm: core: Add ofnode function to read a 64-bit int We have a 32-bit version of this function. Add a 64-bit version as well so we can easily read 64-bit ints from the device tree. Signed-off-by: Simon Glass --- include/dm/ofnode.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'include/dm/ofnode.h') diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h index 5af6b7e616a..dbb4273db64 100644 --- a/include/dm/ofnode.h +++ b/include/dm/ofnode.h @@ -236,6 +236,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 * -- cgit v1.2.3 From fbe8d033fcc64eef90d3e9642545804a0ab9b74f Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 11 Jun 2018 13:07:11 -0600 Subject: dm: core: Fix a few ofnode function comments Tidy up three return-value errors. Signed-off-by: Simon Glass --- include/dm/ofnode.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'include/dm/ofnode.h') diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h index dbb4273db64..85cb87b83f4 100644 --- a/include/dm/ofnode.h +++ b/include/dm/ofnode.h @@ -262,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, @@ -490,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); @@ -645,7 +647,7 @@ 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); -- cgit v1.2.3 From c98ad4434c1a680915d10e5696e6bee9c81044d5 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 11 Jun 2018 13:07:12 -0600 Subject: dm: core: Add comments to ofnode_read_resource() functoins These functions are missing comments. Add some. Signed-off-by: Simon Glass --- include/dm/ofnode.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'include/dm/ofnode.h') diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h index 85cb87b83f4..61c42311f8e 100644 --- a/include/dm/ofnode.h +++ b/include/dm/ofnode.h @@ -651,7 +651,30 @@ int ofnode_read_simple_size_cells(ofnode node); */ 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); -- cgit v1.2.3 From c60f671b65a8b336c3533fcf0f0ee45dff287ff7 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 11 Jun 2018 13:07:13 -0600 Subject: dm: core: Add a way to find an ofnode by compatible string Add an ofnode_by_compatible() to allow iterating through ofnodes with a given compatible string. Signed-off-by: Simon Glass --- include/dm/ofnode.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'include/dm/ofnode.h') diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h index 61c42311f8e..cd08a7e4d02 100644 --- a/include/dm/ofnode.h +++ b/include/dm/ofnode.h @@ -678,6 +678,17 @@ 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_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 * -- cgit v1.2.3