Discussion:
[U-Boot] [PATCH v3 0/2] core: ofnode: Fix ofnode_get_addr_index function
Keerthy
2018-11-19 06:14:46 UTC
Permalink
The series adds a fix to ofnode_get_addr_index function and
also adds a new ofnode_get_addr_size_index function.

Changes in v3:

Fixed compilation issues with sandbox_defconfig

Keerthy (2):
core: ofnode: Fix ofnode_get_addr_index function
core: ofnode: Add ofnode_get_addr_size_index

drivers/core/ofnode.c | 25 +++++++++++++++++--------
include/dm/ofnode.h | 14 ++++++++++++++
2 files changed, 31 insertions(+), 8 deletions(-)
--
1.9.1
Keerthy
2018-11-19 06:14:47 UTC
Permalink
Currently the else part of ofnode_get_addr_index function
does not fetch addresses based on the index but rather just
returns the base address. Fix that.

Signed-off-by: Keerthy <j-***@ti.com>
---
drivers/core/ofnode.c | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c
index d9b5280..0e584c1 100644
--- a/drivers/core/ofnode.c
+++ b/drivers/core/ofnode.c
@@ -253,15 +253,15 @@ int ofnode_read_size(ofnode node, const char *propname)

fdt_addr_t ofnode_get_addr_index(ofnode node, int index)
{
+ int na, ns;
+ fdt_size_t size;
+
if (ofnode_is_np(node)) {
const __be32 *prop_val;
uint flags;
- u64 size;
- int na;
- int ns;

- prop_val = of_get_address(ofnode_to_np(node), index, &size,
- &flags);
+ prop_val = of_get_address(ofnode_to_np(node), index,
+ (u64 *)&size, &flags);
if (!prop_val)
return FDT_ADDR_T_NONE;

@@ -274,8 +274,11 @@ fdt_addr_t ofnode_get_addr_index(ofnode node, int index)
return of_read_number(prop_val, na);
}
} else {
- return fdt_get_base_address(gd->fdt_blob,
- ofnode_to_offset(node));
+ na = ofnode_read_simple_addr_cells(ofnode_get_parent(node));
+ 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);
}

return FDT_ADDR_T_NONE;
--
1.9.1
Keerthy
2018-11-19 06:14:48 UTC
Permalink
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-***@ti.com>
---
drivers/core/ofnode.c | 14 ++++++++++----
include/dm/ofnode.h | 14 ++++++++++++++
2 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c
index 0e584c1..db29a33 100644
--- a/drivers/core/ofnode.c
+++ b/drivers/core/ofnode.c
@@ -251,17 +251,16 @@ 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;
- fdt_size_t size;

if (ofnode_is_np(node)) {
const __be32 *prop_val;
uint flags;

prop_val = of_get_address(ofnode_to_np(node), index,
- (u64 *)&size, &flags);
+ (u64 *)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)
+{
+ 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);
diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h
index 2fc9fa3..8bfe062 100644
--- a/include/dm/ofnode.h
+++ b/include/dm/ofnode.h
@@ -356,6 +356,20 @@ 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,
+ fdt_size_t *size);
+
+/**
* ofnode_get_addr() - get an address from a node
*
* This reads the register address from a node
--
1.9.1
s***@google.com
2018-11-29 17:42:09 UTC
Permalink
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-***@ti.com>
---
drivers/core/ofnode.c | 14 ++++++++++----
include/dm/ofnode.h | 14 ++++++++++++++
2 files changed, 24 insertions(+), 4 deletions(-)

Applied to u-boot-dm/master, thanks!
Lokesh Vutla
2018-12-10 13:45:17 UTC
Permalink
Hi Simon,
Post by Keerthy
Add ofnode_get_addr_size_index function to fetch the address
and size of the reg space based on index.
---
drivers/core/ofnode.c | 14 ++++++++++----
include/dm/ofnode.h | 14 ++++++++++++++
2 files changed, 24 insertions(+), 4 deletions(-)
Applied to u-boot-dm/master, thanks!
I do not see this patch in master branch. Any reason why this is dropped?

Thanks and regards,
Lokesh
Tom Rini
2018-12-10 13:55:30 UTC
Permalink
Post by Lokesh Vutla
Hi Simon,
Post by Keerthy
Add ofnode_get_addr_size_index function to fetch the address
and size of the reg space based on index.
---
drivers/core/ofnode.c | 14 ++++++++++----
include/dm/ofnode.h | 14 ++++++++++++++
2 files changed, 24 insertions(+), 4 deletions(-)
Applied to u-boot-dm/master, thanks!
I do not see this patch in master branch. Any reason why this is dropped?
As I reported in https://patchwork.ozlabs.org/patch/1005644/ this breaks
test.py on sandbox for non-obvious reasons and Keerthy said they'll look
into it.
--
Tom
s***@google.com
2018-11-29 17:42:10 UTC
Permalink
Currently the else part of ofnode_get_addr_index function
does not fetch addresses based on the index but rather just
returns the base address. Fix that.

Signed-off-by: Keerthy <j-***@ti.com>
---
drivers/core/ofnode.c | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)

Applied to u-boot-dm/master, thanks!
Loading...