Skip to contentSkip to conversation

qemu-ppce500: Update get_phys_ccsrbar_addr_early()

PATCH New Tom Rini 2 participants 5 messages Aug 3, 2017

lore
Share & tools
lore

Tom Rini

author
#0 lore raw

PATCH 1/1 qemu-ppce500: Update get_phys_ccsrbar_addr_early()

The logic of what fdt_get_base_address() will search for and return has changed. Rework get_phys_ccsrbar_addr_early() to perform the logic that fdt_get_base_address used to perform.

Fixes 336a44877af8 ("fdt: Correct fdt_get_base_address()")
Cc Simon Glass <[email protected]>
Cc Alexander Graf <[email protected]>
---
 board/freescale/qemu-ppce500/qemu-ppce500.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
board/freescale/qemu-ppce500/qemu-ppce500.c +7 -1
index 6cb5692eda6e..0c65ec72d209 100644
@@ -50,13 +50,19 @@ uint64_t get_phys_ccsrbar_addr_early(void)
 {
 	void *fdt = get_fdt_virt();
 	uint64_t r;
+	int size, node;
+	u32 naddr;
+	const fdt32_t *prop;
 
 	/*
 	 * To be able to read the FDT we need to create a temporary TLB
 	 * map for it.
 	 */
 	map_fdt_as(10);
-	r = fdt_get_base_address(fdt, fdt_path_offset(fdt, "/soc"));
+	node = fdt_path_offset(fdt, "/soc");
+	naddr = fdt_address_cells(fdt, node);
+	prop = fdt_getprop(fdt, node, "ranges", &size);
+	r = fdt_translate_address(fdt, node, prop + naddr);
 	disable_tlb(10);
 
 	return r;
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/1 qemu-ppce500: Update get_phys_ccsrbar_addr_early()

Hi Tom,

Quoted 24 lines · Tom Rini

The logic of what fdt_get_base_address() will search for and return has changed. Rework get_phys_ccsrbar_addr_early() to perform the logic that fdt_get_base_address used to perform.

Fixes 336a44877af8 ("fdt: Correct fdt_get_base_address()")
Cc Simon Glass <[email protected]>
Cc Alexander Graf <[email protected]>
---
 board/freescale/qemu-ppce500/qemu-ppce500.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
board/freescale/qemu-ppce500/qemu-ppce500.c +3 -0
index 6cb5692eda6e..0c65ec72d209 100644
@@ -50,13 +50,19 @@ uint64_t get_phys_ccsrbar_addr_early(void)
 {
        void *fdt = get_fdt_virt();
        uint64_t r;
+       int size, node;
+       u32 naddr;
+       const fdt32_t *prop;
 

board/freescale/qemu-ppce500/qemu-ppce500.c uint64_t get_phys_ccsrbar_addr_early(void) · line 65

Quoted 10 lines
board/freescale/qemu-ppce500/qemu-ppce500.c +4 -1
        /*
         * To be able to read the FDT we need to create a temporary TLB
         * map for it.
         */
        map_fdt_as(10);
-       r = fdt_get_base_address(fdt, fdt_path_offset(fdt, "/soc"));
+       node = fdt_path_offset(fdt, "/soc");
+       naddr = fdt_address_cells(fdt, node);
+       prop = fdt_getprop(fdt, node, "ranges", &size);
+       r = fdt_translate_address(fdt, node, prop + naddr);

Maybe that function wasn't supposed to do what I thought? With no comments on it, it's not really possible to divine intent.

From what I can tell this is reading a DT that is stored somewhere, but it isn't using CONFIG_OF_CONTROL, right?

Quoted 6 lines
board/freescale/qemu-ppce500/qemu-ppce500.c +0 -1
        disable_tlb(10);
 
        return r;
--

1.9.1

Regards,
Simon

author
#2 lore raw

PATCH 1/1 qemu-ppce500: Update get_phys_ccsrbar_addr_early()

Quoted 40 lines · Simon Glass

Hi Tom,

Quoted 24 lines · Tom Rini

The logic of what fdt_get_base_address() will search for and return has changed. Rework get_phys_ccsrbar_addr_early() to perform the logic that fdt_get_base_address used to perform.

Fixes 336a44877af8 ("fdt: Correct fdt_get_base_address()")
Cc Simon Glass <[email protected]>
Cc Alexander Graf <[email protected]>
---
 board/freescale/qemu-ppce500/qemu-ppce500.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
board/freescale/qemu-ppce500/qemu-ppce500.c +3 -0
index 6cb5692eda6e..0c65ec72d209 100644
@@ -50,13 +50,19 @@ uint64_t get_phys_ccsrbar_addr_early(void)
 {
        void *fdt = get_fdt_virt();
        uint64_t r;
+       int size, node;
+       u32 naddr;
+       const fdt32_t *prop;
 

board/freescale/qemu-ppce500/qemu-ppce500.c uint64_t get_phys_ccsrbar_addr_early(void) · line 65

Quoted 10 lines
board/freescale/qemu-ppce500/qemu-ppce500.c +4 -1
        /*
         * To be able to read the FDT we need to create a temporary TLB
         * map for it.
         */
        map_fdt_as(10);
-       r = fdt_get_base_address(fdt, fdt_path_offset(fdt, "/soc"));
+       node = fdt_path_offset(fdt, "/soc");
+       naddr = fdt_address_cells(fdt, node);
+       prop = fdt_getprop(fdt, node, "ranges", &size);
+       r = fdt_translate_address(fdt, node, prop + naddr);
Quoted 5 lines

Maybe that function wasn't supposed to do what I thought? With no comments on it, it's not really possible to divine intent.

From what I can tell this is reading a DT that is stored somewhere, but it isn't using CONFIG_OF_CONTROL, right?

Correct. QEMU passes in a DTB file to us (or the kernel) and then we make use of it.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170803/51b5ae6f/attachment.sig>
#3 lore raw

PATCH 1/1 qemu-ppce500: Update get_phys_ccsrbar_addr_early()

Hi Tom,

Quoted 41 lines · Tom Rini
Quoted 40 lines · Simon Glass

Hi Tom,

Quoted 24 lines · Tom Rini

The logic of what fdt_get_base_address() will search for and return has changed. Rework get_phys_ccsrbar_addr_early() to perform the logic that fdt_get_base_address used to perform.

Fixes 336a44877af8 ("fdt: Correct fdt_get_base_address()")
Cc Simon Glass <[email protected]>
Cc Alexander Graf <[email protected]>
---
 board/freescale/qemu-ppce500/qemu-ppce500.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
board/freescale/qemu-ppce500/qemu-ppce500.c +3 -0
index 6cb5692eda6e..0c65ec72d209 100644
@@ -50,13 +50,19 @@ uint64_t get_phys_ccsrbar_addr_early(void)
 {
        void *fdt = get_fdt_virt();
        uint64_t r;
+       int size, node;
+       u32 naddr;
+       const fdt32_t *prop;
 

board/freescale/qemu-ppce500/qemu-ppce500.c uint64_t get_phys_ccsrbar_addr_early(void) · line 65

Quoted 10 lines
board/freescale/qemu-ppce500/qemu-ppce500.c +4 -1
        /*
         * To be able to read the FDT we need to create a temporary TLB
         * map for it.
         */
        map_fdt_as(10);
-       r = fdt_get_base_address(fdt, fdt_path_offset(fdt, "/soc"));
+       node = fdt_path_offset(fdt, "/soc");
+       naddr = fdt_address_cells(fdt, node);
+       prop = fdt_getprop(fdt, node, "ranges", &size);
+       r = fdt_translate_address(fdt, node, prop + naddr);
Quoted 8 lines
Quoted 5 lines

Maybe that function wasn't supposed to do what I thought? With no comments on it, it's not really possible to divine intent.

From what I can tell this is reading a DT that is stored somewhere, but it isn't using CONFIG_OF_CONTROL, right?

Correct. QEMU passes in a DTB file to us (or the kernel) and then we make use of it.

The really strange thing about this uncommented function and code is that it appears to return the size of the peripheral, not the address. That 'prop + naddr' threally confused me. Anyway from what I can tell you have replicated the behaviour.

Regards,
Simon

author
#4 lore raw

PATCH 1/1 qemu-ppce500: Update get_phys_ccsrbar_addr_early()

In reply to Tom Rini
Quoted 8 lines · Tom Rini

The logic of what fdt_get_base_address() will search for and return has changed. Rework get_phys_ccsrbar_addr_early() to perform the logic that fdt_get_base_address used to perform.

Fixes 336a44877af8 ("fdt: Correct fdt_get_base_address()")
Cc Alexander Graf <[email protected]>

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170803/a6142c79/attachment.sig>