[U-Boot] [PATCH v2 2/2] core: ofnode: Add ofnode_get_addr_size_index
Keerthy
j-keerthy at ti.com
Mon Nov 5 05:55:43 UTC 2018
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 at ti.com>
---
Changes in v2:
* Added the missing header file declaration of the new function.
drivers/core/ofnode.c | 14 ++++++++++----
include/dm/ofnode.h | 13 +++++++++++++
2 files changed, 23 insertions(+), 4 deletions(-)
diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c
index c80e1cb..b98b0b9 100644
--- a/drivers/core/ofnode.c
+++ b/drivers/core/ofnode.c
@@ -251,16 +251,15 @@ 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, u64 *size)
{
int na, ns;
- u64 size;
if (ofnode_is_np(node)) {
const __be32 *prop_val;
uint flags;
- prop_val = of_get_address(ofnode_to_np(node), index, &size,
+ prop_val = of_get_address(ofnode_to_np(node), index, size,
&flags);
if (!prop_val)
return FDT_ADDR_T_NONE;
@@ -278,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, &size, true);
+ index, na, ns, size, true);
}
return FDT_ADDR_T_NONE;
}
+fdt_addr_t ofnode_get_addr_index(ofnode node, int index)
+{
+ u64 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);
diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h
index 2fc9fa3..149acaa 100644
--- a/include/dm/ofnode.h
+++ b/include/dm/ofnode.h
@@ -356,6 +356,19 @@ int ofnode_read_size(ofnode node, const char *propname);
phys_addr_t ofnode_get_addr_index(ofnode node, int index);
/**
+ * ofnode_get_addr_size_index() - get an address/size from a node
+ * based on index
+ *
+ * This reads the register address from a node
+ *
+ * @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, u64 *size);
+
+/**
* ofnode_get_addr() - get an address from a node
*
* This reads the register address from a node
--
1.9.1
More information about the U-Boot
mailing list