Hi Simon, On 02.12.2015 18:45, Simon Glass wrote: > Hi Stefan, > > On 2 December 2015 at 10:43, Stefan Roese <s...@denx.de> wrote: >> Hi Simon, >> >> ( Last mail for tonight - a glass of quite nice red wine is >> waiting for me ... ;) ) >> > > That's the only sad thing about me being so many hours behind. Still I > can do the same thing with people in Asia I suppose :-)
Right. I'm not sure about the wine quality in Asia though... ;) >> >> On 02.12.2015 17:53, Simon Glass wrote: >>> >>> Hi Stefan, >>> >>> On 2 December 2015 at 09:00, Stefan Roese <s...@denx.de> wrote: >>>> >>>> >>>> Hi Simon, >>>> >>>> On 02.12.2015 16:50, Simon Glass wrote: >>>> >>>> <snip> >>>> >>>>>>> I think it would be better to make it depend on whether the bit is >>>>>>> flipped, rather than whether you are in SPL or not. >>>>>> >>>>>> >>>>>> >>>>>> You simply can't detect if this "bit is flipped". You just have >>>>>> to know. This is a long lasting ugly thing on some Marvell >>>>>> patforms. Here the comment from armada-xp-gp.dts: >>>>> >>>>> >>>>> >>>>> Can you point me to the place in U-Boot where this bit is flipped? >>>>> Something, somewhere has to make the change. So something has to know. >>>>> Before it makes the change, the range works one way. Afterwards it >>>>> works another way. >>>> >>>> >>>> >>>> Sure. I've mentioned this before. Its here: >>>> >>>> arch/arm/mach-mvebu/cpu.c: >>>> >>>> int arch_cpu_init(void) >>>> { >>>> ... >>>> >>>> /* Linux expects the internal registers to be at 0xf1000000 */ >>>> writel(SOC_REGS_PHY_BASE, INTREG_BASE_ADDR_REG); >>>> >>>> This is the line that changes the register base address. And >>>> to change it back you need to write to the new address, as the >>>> address holding this base address is also moved. Quite ugly! >>>> >>>> So its really right at the start of U-Boot proper. >>> >>> >>> OK I see. So really we can determine which way the address 'switch' >>> it. It's just a case of making the change when we are ready, and >>> keeping a record of that. >> >> >> Yes. But how is the "common code" in dev_get_addr() supposed to know >> which version of U-Boot we are running on? This boils down to some >> callback again, or not? Or even worse the ugly #ifdef. > > You would call a driver-model core function to select the ranges > property to prefer. Then driver model will remember this setting and > use it. Yes. This can be done. I've taken the time to implement such a version. And attached a small patch in a hackish version, just as an RFC. As you will see, I've added the "ranges-spl" property to some of the DT nodes. And added the DM core functions to enable to usage of a different, non-standard "ranges" property name. All this is not really "clean" and will definitely break non-DM usage of fdt_support.c. Not sure where to go from here. I would still prefer my first patch version, even though I know that you don't like to add this hook / callback into the DM core code. Let me know what you think. Thanks, Stefan
>From ff81a6e4ced6f6b77047cae174546033d4098ee6 Mon Sep 17 00:00:00 2001 From: Stefan Roese <s...@denx.de> Date: Thu, 3 Dec 2015 11:35:11 +0100 Subject: [PATCH] dm: Add option to configure a different, non-standard ranges property name Signed-off-by: Stefan Roese <s...@denx.de> --- arch/arm/dts/armada-370-xp.dtsi | 1 + arch/arm/dts/armada-xp-gp.dts | 3 +++ arch/arm/mach-mvebu/spl.c | 6 ++++++ common/fdt_support.c | 8 +++++--- drivers/core/root.c | 24 ++++++++++++++++++++++++ drivers/core/simple-bus.c | 3 ++- include/dm/device.h | 4 ++++ 7 files changed, 45 insertions(+), 4 deletions(-) diff --git a/arch/arm/dts/armada-370-xp.dtsi b/arch/arm/dts/armada-370-xp.dtsi index 0b2a78d..b74050b 100644 --- a/arch/arm/dts/armada-370-xp.dtsi +++ b/arch/arm/dts/armada-370-xp.dtsi @@ -141,6 +141,7 @@ #address-cells = <1>; #size-cells = <1>; ranges = <0 MBUS_ID(0xf0, 0x01) 0 0x100000>; + ranges-spl = <0 MBUS_ID(0xf0, 0x01) 0 0x100000>; u-boot,dm-pre-reloc; rtc@10300 { diff --git a/arch/arm/dts/armada-xp-gp.dts b/arch/arm/dts/armada-xp-gp.dts index 27799d1..e1202b4 100644 --- a/arch/arm/dts/armada-xp-gp.dts +++ b/arch/arm/dts/armada-xp-gp.dts @@ -99,6 +99,9 @@ ranges = <MBUS_ID(0xf0, 0x01) 0 0 0xf1000000 0x100000 MBUS_ID(0x01, 0x1d) 0 0 0xfff00000 0x100000 MBUS_ID(0x01, 0x2f) 0 0 0xf0000000 0x1000000>; + ranges-spl = <MBUS_ID(0xf0, 0x01) 0 0 0xd0000000 0x100000 + MBUS_ID(0x01, 0x1d) 0 0 0xfff00000 0x100000 + MBUS_ID(0x01, 0x2f) 0 0 0xf0000000 0x1000000>; devbus-bootcs { status = "okay"; diff --git a/arch/arm/mach-mvebu/spl.c b/arch/arm/mach-mvebu/spl.c index 8edb2f3..81f4fff 100644 --- a/arch/arm/mach-mvebu/spl.c +++ b/arch/arm/mach-mvebu/spl.c @@ -5,6 +5,7 @@ */ #include <common.h> +#include <dm.h> #include <debug_uart.h> #include <fdtdec.h> #include <spl.h> @@ -60,6 +61,9 @@ void board_init_f(ulong dummy) hang(); } + /* Use special "ranges" name for SPL */ + dm_set_ranges_name("ranges-spl"); + preloader_console_init(); timer_init(); @@ -86,6 +90,7 @@ void board_init_f(ulong dummy) #endif } +#if 0 // test-only /* * When using DM with DT address translation, this does not work * with the standard fdt_translate_address() function on MVEBU @@ -101,3 +106,4 @@ fdt_addr_t platform_translate_address(void *blob, int node_offset, { return (addr & 0x00ffffff) | SOC_REGS_PHY_BASE; } +#endif diff --git a/common/fdt_support.c b/common/fdt_support.c index a7ff2df..84eb22b 100644 --- a/common/fdt_support.c +++ b/common/fdt_support.c @@ -8,6 +8,7 @@ */ #include <common.h> +#include <dm.h> #include <inttypes.h> #include <stdio_dev.h> #include <linux/ctype.h> @@ -1175,7 +1176,8 @@ static u64 __of_translate_address(void *blob, int node_offset, const fdt32_t *in u64 fdt_translate_address(void *blob, int node_offset, const fdt32_t *in_addr) { - return __of_translate_address(blob, node_offset, in_addr, "ranges"); + return __of_translate_address(blob, node_offset, in_addr, + dm_get_ranges_name()); } /** @@ -1433,7 +1435,7 @@ u64 fdt_get_base_address(void *fdt, int node) naddr = fdt_address_cells(fdt, node); - prop = fdt_getprop(fdt, node, "ranges", &size); + prop = fdt_getprop(fdt, node, dm_get_ranges_name(), &size); return prop ? fdt_translate_address(fdt, node, prop + naddr) : 0; } @@ -1500,7 +1502,7 @@ int fdt_read_range(void *fdt, int node, int n, uint64_t *child_addr, scells = fdt_getprop_u32_default_node(fdt, node, 0, "#size-cells", 1); /* Now try to get the ranges property */ - ranges = fdt_getprop(fdt, node, "ranges", &ranges_len); + ranges = fdt_getprop(fdt, node, dm_get_ranges_name(), &ranges_len); if (!ranges) return -FDT_ERR_NOTFOUND; ranges_len /= sizeof(uint32_t); diff --git a/drivers/core/root.c b/drivers/core/root.c index e7b1f24..7916b65 100644 --- a/drivers/core/root.c +++ b/drivers/core/root.c @@ -37,6 +37,30 @@ struct udevice *dm_root(void) return gd->dm_root; } +char *dm_get_ranges_name(void) +{ + struct udevice *root; + + root = dm_root(); + if (root) { + if (root->ranges_name) { + return root->ranges_name; + } + } + + /* Fallback to the standard range name */ + return "ranges"; +} + +void dm_set_ranges_name(char *name) +{ + struct udevice *root; + + root = dm_root(); + if (root) + root->ranges_name = name; +} + #if defined(CONFIG_NEEDS_MANUAL_RELOC) void fix_drivers(void) { diff --git a/drivers/core/simple-bus.c b/drivers/core/simple-bus.c index 913c3cc..56d5072 100644 --- a/drivers/core/simple-bus.c +++ b/drivers/core/simple-bus.c @@ -31,7 +31,8 @@ static int simple_bus_post_bind(struct udevice *dev) u32 cell[3]; int ret; - ret = fdtdec_get_int_array(gd->fdt_blob, dev->of_offset, "ranges", + ret = fdtdec_get_int_array(gd->fdt_blob, dev->of_offset, + dm_get_ranges_name(), cell, ARRAY_SIZE(cell)); if (!ret) { struct simple_bus_plat *plat = dev_get_uclass_platdata(dev); diff --git a/include/dm/device.h b/include/dm/device.h index 7fb9935..00967e0 100644 --- a/include/dm/device.h +++ b/include/dm/device.h @@ -105,6 +105,7 @@ struct udevice { #ifdef CONFIG_DEVRES struct list_head devres_head; #endif + char *ranges_name; }; /* Maximum sequence number supported */ @@ -776,4 +777,7 @@ static inline void devm_kfree(struct udevice *dev, void *ptr) #endif /* ! CONFIG_DEVRES */ +char *dm_get_ranges_name(void); +void dm_set_ranges_name(char *name); + #endif -- 2.6.3
_______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot