All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michal Simek <michal.simek@xilinx.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] Revert "fdt: fdtdec_setup_memory_banksize() use livetree"
Date: Thu,  4 Oct 2018 09:24:24 +0200	[thread overview]
Message-ID: <4951156071ba41dacd40c2bd1c9a321046dd40b5.1538637860.git.michal.simek@xilinx.com> (raw)

This reverts commit c35a7d375ec8f0a8ee343ae4868be3242172632e.
This commit is breaking SPL on zc706.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---

 lib/fdtdec.c | 44 +++++++++++++++++++++++---------------------
 1 file changed, 23 insertions(+), 21 deletions(-)

diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index 74196ce7f9f7..bf5e0f6a57c0 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -15,7 +15,6 @@
 #include <serial.h>
 #include <asm/sections.h>
 #include <linux/ctype.h>
-#include <linux/ioport.h>
 #include <linux/lzo.h>
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -1182,34 +1181,41 @@ int fdtdec_setup_mem_size_base(void)
 
 #if defined(CONFIG_NR_DRAM_BANKS)
 
-static ofnode get_next_memory_node(ofnode mem)
+static int get_next_memory_node(const void *blob, int mem)
 {
 	do {
-		mem = ofnode_by_prop_value(mem, "device_type", "memory", 7);
-	} while (ofnode_valid(mem) && !ofnode_is_available(mem));
+		mem = fdt_node_offset_by_prop_value(gd->fdt_blob, mem,
+						    "device_type", "memory", 7);
+	} while (!fdtdec_get_is_enabled(blob, mem));
 
 	return mem;
 }
 
 int fdtdec_setup_memory_banksize(void)
 {
-	int bank, reg = 0;
-	struct resource res;
-	ofnode mem;
+	int bank, ret, mem, reg = 0;
+	struct fdt_resource res;
 
-	mem = get_next_memory_node(ofnode_null());
-	if (!ofnode_valid(mem))
-		goto missing_node;
+	mem = get_next_memory_node(gd->fdt_blob, -1);
+	if (mem < 0) {
+		debug("%s: Missing /memory node\n", __func__);
+		return -EINVAL;
+	}
 
 	for (bank = 0; bank < CONFIG_NR_DRAM_BANKS; bank++) {
-		while (ofnode_read_resource(mem, reg++, &res)) {
+		ret = fdt_get_resource(gd->fdt_blob, mem, "reg", reg++, &res);
+		if (ret == -FDT_ERR_NOTFOUND) {
 			reg = 0;
-			mem = get_next_memory_node(mem);
-			if (!ofnode_valid(mem)) {
-				if (bank)
-					return 0;
-				goto missing_node;
-			}
+			mem = get_next_memory_node(gd->fdt_blob, mem);
+			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;
@@ -1223,10 +1229,6 @@ int fdtdec_setup_memory_banksize(void)
 	}
 
 	return 0;
-
-missing_node:
-	debug("%s: Missing /memory node\n", __func__);
-	return -EINVAL;
 }
 #endif
 
-- 
1.9.1

             reply	other threads:[~2018-10-04  7:24 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-04  7:24 Michal Simek [this message]
2018-10-06 13:33 ` [U-Boot] [PATCH] Revert "fdt: fdtdec_setup_memory_banksize() use livetree" Patrice CHOTARD
2018-10-08  6:28   ` Michal Simek
2018-10-09  9:15     ` Patrice CHOTARD
2018-10-09 11:05       ` Michal Simek
2018-10-08 12:39   ` Simon Glass
2018-10-08 14:15     ` Michal Simek
2018-10-09 11:55 ` Patrice CHOTARD

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4951156071ba41dacd40c2bd1c9a321046dd40b5.1538637860.git.michal.simek@xilinx.com \
    --to=michal.simek@xilinx.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.