* [U-Boot] [PATCH] fdtdec: Support parsing multiple /memory nodes
@ 2017-11-29 2:45 Marek Vasut
2017-11-29 2:58 ` Tom Rini
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Marek Vasut @ 2017-11-29 2:45 UTC (permalink / raw)
To: u-boot
It is legal to have multiple /memory nodes in a device tree . Currently,
fdtdec_setup_memory_size() only supports parsing the first node . This
patch extends the function such that if a particular /memory node does
no longer have further "reg" entries and CONFIG_NR_DRAM_BANKS still
allows for more DRAM banks, the code moves on to the next memory node
and checks it's "reg"s. This makes it possible to handle both systems
with single memory node with multiple entries and systems with multiple
memory nodes with single entry.
Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
Cc: Tom Rini <trini@konsulko.com>
Cc: Simon Glass <sjg@chromium.org>
---
lib/fdtdec.c | 24 ++++++++++++++++++------
1 file changed, 18 insertions(+), 6 deletions(-)
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index c4582eacca..46df0f15f9 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -1176,21 +1176,33 @@ int fdtdec_setup_memory_size(void)
#if defined(CONFIG_NR_DRAM_BANKS)
int fdtdec_setup_memory_banksize(void)
{
- int bank, ret, mem;
+ int bank, ret, mem, reg = 0;
struct fdt_resource res;
- mem = fdt_path_offset(gd->fdt_blob, "/memory");
+ mem = fdt_node_offset_by_prop_value(gd->fdt_blob, -1, "device_type",
+ "memory", 7);
if (mem < 0) {
debug("%s: Missing /memory node\n", __func__);
return -EINVAL;
}
for (bank = 0; bank < CONFIG_NR_DRAM_BANKS; bank++) {
- ret = fdt_get_resource(gd->fdt_blob, mem, "reg", bank, &res);
- if (ret == -FDT_ERR_NOTFOUND)
- break;
- if (ret != 0)
+ ret = fdt_get_resource(gd->fdt_blob, mem, "reg", reg++, &res);
+ if (ret == -FDT_ERR_NOTFOUND) {
+ reg = 0;
+ mem = fdt_node_offset_by_prop_value(gd->fdt_blob, mem,
+ "device_type",
+ "memory", 7);
+ if (mem == -FDT_ERR_NOTFOUND)
+ break;
+
+ ret = fdt_get_resource(gd->fdt_blob, mem, "reg", reg++, &res);
+ if (ret == -FDT_ERR_NOTFOUND)
+ break;
+ }
+ if (ret != 0) {
return -EINVAL;
+ }
gd->bd->bi_dram[bank].start = (phys_addr_t)res.start;
gd->bd->bi_dram[bank].size =
--
2.15.0
^ permalink raw reply related [flat|nested] 6+ messages in thread* [U-Boot] [PATCH] fdtdec: Support parsing multiple /memory nodes
2017-11-29 2:45 [U-Boot] [PATCH] fdtdec: Support parsing multiple /memory nodes Marek Vasut
@ 2017-11-29 2:58 ` Tom Rini
2017-11-29 3:11 ` Marek Vasut
2017-11-29 13:08 ` Simon Glass
2017-11-29 13:23 ` Lothar Waßmann
2 siblings, 1 reply; 6+ messages in thread
From: Tom Rini @ 2017-11-29 2:58 UTC (permalink / raw)
To: u-boot
On Wed, Nov 29, 2017 at 03:45:45AM +0100, Marek Vasut wrote:
> It is legal to have multiple /memory nodes in a device tree . Currently,
> fdtdec_setup_memory_size() only supports parsing the first node . This
> patch extends the function such that if a particular /memory node does
> no longer have further "reg" entries and CONFIG_NR_DRAM_BANKS still
> allows for more DRAM banks, the code moves on to the next memory node
> and checks it's "reg"s. This makes it possible to handle both systems
> with single memory node with multiple entries and systems with multiple
> memory nodes with single entry.
>
> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
> Cc: Tom Rini <trini@konsulko.com>
> Cc: Simon Glass <sjg@chromium.org>
https://www.devicetree.org/downloads/devicetree-specification-v0.1-20160524.pdf
says that multiple nodes can be used, so this is the correct fix here.
Thanks!
Reviewed-by: Tom Rini <trini@konsulko.com>
--
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20171128/bf20f9fe/attachment.sig>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH] fdtdec: Support parsing multiple /memory nodes
2017-11-29 2:58 ` Tom Rini
@ 2017-11-29 3:11 ` Marek Vasut
0 siblings, 0 replies; 6+ messages in thread
From: Marek Vasut @ 2017-11-29 3:11 UTC (permalink / raw)
To: u-boot
On 11/29/2017 03:58 AM, Tom Rini wrote:
> On Wed, Nov 29, 2017 at 03:45:45AM +0100, Marek Vasut wrote:
>
>> It is legal to have multiple /memory nodes in a device tree . Currently,
>> fdtdec_setup_memory_size() only supports parsing the first node . This
>> patch extends the function such that if a particular /memory node does
>> no longer have further "reg" entries and CONFIG_NR_DRAM_BANKS still
>> allows for more DRAM banks, the code moves on to the next memory node
>> and checks it's "reg"s. This makes it possible to handle both systems
>> with single memory node with multiple entries and systems with multiple
>> memory nodes with single entry.
>>
>> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
>> Cc: Tom Rini <trini@konsulko.com>
>> Cc: Simon Glass <sjg@chromium.org>
>
> https://www.devicetree.org/downloads/devicetree-specification-v0.1-20160524.pdf
> says that multiple nodes can be used, so this is the correct fix here.
I am not a big fan of this kind of practice, but that's how our DTs are,
so it cannot be helped and we have to support this :-(
> Thanks!
>
> Reviewed-by: Tom Rini <trini@konsulko.com>
Thanks.
--
Best regards,
Marek Vasut
^ permalink raw reply [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH] fdtdec: Support parsing multiple /memory nodes
2017-11-29 2:45 [U-Boot] [PATCH] fdtdec: Support parsing multiple /memory nodes Marek Vasut
2017-11-29 2:58 ` Tom Rini
@ 2017-11-29 13:08 ` Simon Glass
2017-12-07 11:49 ` Simon Glass
2017-11-29 13:23 ` Lothar Waßmann
2 siblings, 1 reply; 6+ messages in thread
From: Simon Glass @ 2017-11-29 13:08 UTC (permalink / raw)
To: u-boot
On 28 November 2017 at 19:45, Marek Vasut <marek.vasut@gmail.com> wrote:
> It is legal to have multiple /memory nodes in a device tree . Currently,
> fdtdec_setup_memory_size() only supports parsing the first node . This
> patch extends the function such that if a particular /memory node does
> no longer have further "reg" entries and CONFIG_NR_DRAM_BANKS still
> allows for more DRAM banks, the code moves on to the next memory node
> and checks it's "reg"s. This makes it possible to handle both systems
> with single memory node with multiple entries and systems with multiple
> memory nodes with single entry.
>
> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
> Cc: Tom Rini <trini@konsulko.com>
> Cc: Simon Glass <sjg@chromium.org>
> ---
> lib/fdtdec.c | 24 ++++++++++++++++++------
> 1 file changed, 18 insertions(+), 6 deletions(-)
Oh for a test of this code!
Acked-by: Simon Glass <sjg@chromium.org>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH] fdtdec: Support parsing multiple /memory nodes
2017-11-29 13:08 ` Simon Glass
@ 2017-12-07 11:49 ` Simon Glass
0 siblings, 0 replies; 6+ messages in thread
From: Simon Glass @ 2017-12-07 11:49 UTC (permalink / raw)
To: u-boot
Hi,
On 29 November 2017 at 06:08, Simon Glass <sjg@chromium.org> wrote:
> On 28 November 2017 at 19:45, Marek Vasut <marek.vasut@gmail.com> wrote:
>> It is legal to have multiple /memory nodes in a device tree . Currently,
>> fdtdec_setup_memory_size() only supports parsing the first node . This
>> patch extends the function such that if a particular /memory node does
>> no longer have further "reg" entries and CONFIG_NR_DRAM_BANKS still
>> allows for more DRAM banks, the code moves on to the next memory node
>> and checks it's "reg"s. This makes it possible to handle both systems
>> with single memory node with multiple entries and systems with multiple
>> memory nodes with single entry.
>>
>> Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
>> Cc: Tom Rini <trini@konsulko.com>
>> Cc: Simon Glass <sjg@chromium.org>
>> ---
>> lib/fdtdec.c | 24 ++++++++++++++++++------
>> 1 file changed, 18 insertions(+), 6 deletions(-)
>
> Oh for a test of this code!
>
> Acked-by: Simon Glass <sjg@chromium.org>
This is in my queue but seems to have already made it to mainline.
Regards,
Simon
^ permalink raw reply [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH] fdtdec: Support parsing multiple /memory nodes
2017-11-29 2:45 [U-Boot] [PATCH] fdtdec: Support parsing multiple /memory nodes Marek Vasut
2017-11-29 2:58 ` Tom Rini
2017-11-29 13:08 ` Simon Glass
@ 2017-11-29 13:23 ` Lothar Waßmann
2 siblings, 0 replies; 6+ messages in thread
From: Lothar Waßmann @ 2017-11-29 13:23 UTC (permalink / raw)
To: u-boot
Hi,
On Wed, 29 Nov 2017 03:45:45 +0100 Marek Vasut wrote:
> It is legal to have multiple /memory nodes in a device tree . Currently,
> fdtdec_setup_memory_size() only supports parsing the first node . This
> patch extends the function such that if a particular /memory node does
> no longer have further "reg" entries and CONFIG_NR_DRAM_BANKS still
> allows for more DRAM banks, the code moves on to the next memory node
> and checks it's "reg"s. This makes it possible to handle both systems
>
<nit>
s/it's/its/
</nit>
Lothar Waßmann
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-12-07 11:49 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-29 2:45 [U-Boot] [PATCH] fdtdec: Support parsing multiple /memory nodes Marek Vasut
2017-11-29 2:58 ` Tom Rini
2017-11-29 3:11 ` Marek Vasut
2017-11-29 13:08 ` Simon Glass
2017-12-07 11:49 ` Simon Glass
2017-11-29 13:23 ` Lothar Waßmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox