]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
core: ofnode: Add ofnode_get_addr_size_index
authorKeerthy <j-keerthy@ti.com>
Wed, 24 Apr 2019 11:49:53 +0000 (17:19 +0530)
committerSimon Glass <sjg@chromium.org>
Tue, 21 May 2019 23:33:23 +0000 (17:33 -0600)
Add ofnode_get_addr_size_index function to fetch the address
and size of the reg space based on index.

Signed-off-by: Keerthy <j-keerthy@ti.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
drivers/core/ofnode.c
include/dm/ofnode.h

index cc0c031e0d7a359d871baf7b04f8d7ffa48fa021..12977a779071802f90f6dde4c212b0cede6e10ff 100644 (file)
@@ -251,7 +251,7 @@ int ofnode_read_size(ofnode node, const char *propname)
        return -EINVAL;
 }
 
-fdt_addr_t ofnode_get_addr_index(ofnode node, int index)
+fdt_addr_t ofnode_get_addr_size_index(ofnode node, int index, fdt_size_t *size)
 {
        int na, ns;
 
@@ -260,7 +260,7 @@ fdt_addr_t ofnode_get_addr_index(ofnode node, int index)
                uint flags;
 
                prop_val = of_get_address(ofnode_to_np(node), index,
-                                         NULL, &flags);
+                                         (u64 *)size, &flags);
                if (!prop_val)
                        return FDT_ADDR_T_NONE;
 
@@ -277,12 +277,19 @@ fdt_addr_t ofnode_get_addr_index(ofnode node, int index)
                ns = ofnode_read_simple_size_cells(ofnode_get_parent(node));
                return fdtdec_get_addr_size_fixed(gd->fdt_blob,
                                                  ofnode_to_offset(node), "reg",
-                                                 index, na, ns, NULL, true);
+                                                 index, na, ns, size, true);
        }
 
        return FDT_ADDR_T_NONE;
 }
 
+fdt_addr_t ofnode_get_addr_index(ofnode node, int index)
+{
+       fdt_size_t size;
+
+       return ofnode_get_addr_size_index(node, index, &size);
+}
+
 fdt_addr_t ofnode_get_addr(ofnode node)
 {
        return ofnode_get_addr_index(node, 0);
index d206ee2caab72a07f5fdebdb3643b0b17a7219d5..1be5ba4b45eeb0aeb06badcb8b093922e84397dc 100644 (file)
@@ -354,6 +354,20 @@ ofnode ofnode_get_by_phandle(uint phandle);
  */
 int ofnode_read_size(ofnode node, const char *propname);
 
+/**
+ * ofnode_get_addr_size_index() - get an address/size from a node
+ *                               based on index
+ *
+ * This reads the register address/size from a node based on index
+ *
+ * @node: node to read from
+ * @index: Index of address to read (0 for first)
+ * @size: Pointer to size of the address
+ * @return address, or FDT_ADDR_T_NONE if not present or invalid
+ */
+phys_addr_t ofnode_get_addr_size_index(ofnode node, int index,
+                                      fdt_size_t *size);
+
 /**
  * ofnode_get_addr_index() - get an address from a node
  *