Hi Simon,

On 01.09.2015 08:25, Stefan Roese wrote:
I'm currently enabling DM support for the Marvell MVEBU SoC's I've
been working lately on (Armada XP and 38x right now). A problem I'm
facing here is the bus translation, as this is quite complex for these
SoC's. With multiple levels of translation ranges (multiple simple-bus
nodes to walk through).

The current implementation in dev_get_addr() does not work. This has
2 reasons:

a) It only translates 1 simple-bus node - we need to walk the
    complete DT to get the correct address.

b) The "ranges" property can have different sizes for "address"
    and "size" in all these busses / nodes. And also multiple
    ranges tuples are allowed and used in these dts files.

Of course this can be solved in the current implementation (device.c /
simple_bus.c). But especially b) is not that trivial to solve in
a generic way.

So my main question is, why don't you use fdt_translate_address()
from fdt_support.c instead of implementing your own translation
function simple_bus_translate()? Is this a size question because
this may be used in SPL as well?

The attached small patch demonstrates the usage of fdt_translate_address() and enables bus translation on the MVEBU platforms.

Thanks,
Stefan

>From 015369030d571f3b9ba763962e5cc80ef84a029e Mon Sep 17 00:00:00 2001
From: Stefan Roese <[email protected]>
Date: Tue, 1 Sep 2015 11:38:17 +0200
Subject: [PATCH] use translate_bus from fdt_common.c (testing only)

Signed-off-by: Stefan Roese <[email protected]>
---
 drivers/core/device.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/core/device.c b/drivers/core/device.c
index a31e25f..9ccfd39 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -11,6 +11,7 @@
 
 #include <common.h>
 #include <fdtdec.h>
+#include <fdt_support.h>
 #include <malloc.h>
 #include <dm/device.h>
 #include <dm/device-internal.h>
@@ -575,8 +576,10 @@ fdt_addr_t dev_get_addr(struct udevice *dev)
 
 	addr = fdtdec_get_addr(gd->fdt_blob, dev->of_offset, "reg");
 	if (addr != FDT_ADDR_T_NONE) {
-		if (device_get_uclass_id(dev->parent) == UCLASS_SIMPLE_BUS)
-			addr = simple_bus_translate(dev->parent, addr);
+		const fdt32_t *reg = fdt_getprop(gd->fdt_blob, dev->of_offset,
+						 "reg", NULL);
+		addr = fdt_translate_address((void *)gd->fdt_blob,
+					     dev->of_offset, reg);
 	}
 
 	return addr;
-- 
2.5.1

_______________________________________________
U-Boot mailing list
[email protected]
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to