mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
To: barebox@lists.infradead.org
Cc: Rob Herring <rob.herring@calxeda.com>
Subject: [PATCH 2/6] of: make of_add_memory available for other board
Date: Wed, 13 Feb 2013 11:06:40 +0100	[thread overview]
Message-ID: <1360750004-17713-2-git-send-email-plagnioj@jcrosoft.com> (raw)
In-Reply-To: <1360750004-17713-1-git-send-email-plagnioj@jcrosoft.com>

so when the first stage booloader of firmware provide the dtb
we can use it to probe the memory

also allow to print what we probe

Cc: Rob Herring <rob.herring@calxeda.com>
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 drivers/of/base.c |   20 ++++++++++++++------
 include/of.h      |    6 ++++++
 2 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index 1f32bfb..f2986ab 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -734,18 +734,23 @@ u64 dt_mem_next_cell(int s, const __be32 **cellp)
 	return of_read_number(p, s);
 }
 
-static int of_add_memory(struct device_node *node)
+int of_add_memory(struct device_node *node, bool dump)
 {
 	int na, nc;
 	const __be32 *reg, *endp;
 	int len, r = 0;
 	static char str[6];
+	struct property *type;
+
+	type = of_find_property(node, "device_type");
+	if (!type)
+		return -ENXIO;
 
 	of_bus_count_cells(node, &na, &nc);
 
 	reg = of_get_property(node, "reg", &len);
 	if (!reg)
-		return 0;
+		return -EINVAL;
 
 	endp = reg + (len / sizeof(__be32));
 
@@ -762,6 +767,9 @@ static int of_add_memory(struct device_node *node)
 
                 barebox_add_memory_bank(str, base, size);
 
+		if (dump)
+			pr_info("%s: %s: 0x%llx@0x%llx\n", node->name, str, size, base);
+
 		r++;
         }
 
@@ -770,7 +778,7 @@ static int of_add_memory(struct device_node *node)
 
 static int add_of_device_resource(struct device_node *node)
 {
-	struct property *reg, *type;
+	struct property *reg;
 	u64 address, size;
 	struct resource *res;
 	struct device_d *dev;
@@ -783,9 +791,9 @@ static int add_of_device_resource(struct device_node *node)
 		list_add_tail(&node->phandles, &phandle_list);
 	}
 
-	type = of_find_property(node, "device_type");
-	if (type)
-		return of_add_memory(node);
+	ret = of_add_memory(node, false);
+	if (ret != -ENXIO)
+		return ret;
 
 	reg = of_find_property(node, "reg");
 	if (!reg)
diff --git a/include/of.h b/include/of.h
index d413d72..4dc5b6c 100644
--- a/include/of.h
+++ b/include/of.h
@@ -132,6 +132,7 @@ int of_alias_get_id(struct device_node *np, const char *stem);
 int of_device_is_stdout_path(struct device_d *dev);
 const char *of_get_model(void);
 void *of_flatten_dtb(void);
+int of_add_memory(struct device_node *node, bool dump);
 #else
 static inline int of_parse_partitions(const char *cdevname,
 					  struct device_node *node)
@@ -163,6 +164,11 @@ static inline void *of_flatten_dtb(void)
 {
 	return NULL;
 }
+
+static inline int of_add_memory(struct device_node *node, bool dump)
+{
+	return -EINVAL;
+}
 #endif
 
 #endif /* __OF_H */
-- 
1.7.10.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2013-02-13 10:07 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-13 10:02 [PATCH 0/6 v3] arm: add Calxeda Highbank support Jean-Christophe PLAGNIOL-VILLARD
2013-02-13 10:06 ` [PATCH 1/6] ahci-generic: add oftree support Jean-Christophe PLAGNIOL-VILLARD
2013-02-13 10:06   ` Jean-Christophe PLAGNIOL-VILLARD [this message]
2013-02-13 17:31     ` [PATCH 2/6] of: make of_add_memory available for other board Sascha Hauer
2013-02-13 17:59       ` Jean-Christophe PLAGNIOL-VILLARD
2013-02-13 18:09       ` [PATCH 1/1] of_add_memory: check the device_type is memory Jean-Christophe PLAGNIOL-VILLARD
2013-02-13 10:06   ` [PATCH 3/6] highbank: add xgmac support Jean-Christophe PLAGNIOL-VILLARD
2013-02-13 10:06   ` [PATCH 4/6] arm: add highbank support Jean-Christophe PLAGNIOL-VILLARD
2013-02-13 10:06   ` [PATCH 5/6] highbank: add l2x0 support Jean-Christophe PLAGNIOL-VILLARD
2013-02-13 10:06   ` [PATCH 6/6] highbank: use the provided dtb by the firmware to probe barebox device and mem size Jean-Christophe PLAGNIOL-VILLARD
2013-02-14 13:47 ` [PATCH 0/6 v3] arm: add Calxeda Highbank support Sascha Hauer

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=1360750004-17713-2-git-send-email-plagnioj@jcrosoft.com \
    --to=plagnioj@jcrosoft.com \
    --cc=barebox@lists.infradead.org \
    --cc=rob.herring@calxeda.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox