summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>2013-02-13 11:06:40 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2013-02-14 09:27:26 +0100
commit9acb6113f0c7e40f70d20bd8c62b4f5dc9caa493 (patch)
treec7cbf0ff1a2baaf570243ca4dcec74c4936ad33e /drivers
parenta40e76cebcbe8b025bafdefdc6e27b7553209ed7 (diff)
downloadbarebox-9acb6113f0c7e40f70d20bd8c62b4f5dc9caa493.tar.gz
barebox-9acb6113f0c7e40f70d20bd8c62b4f5dc9caa493.tar.xz
of: make of_add_memory available for other board
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> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/of/base.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/drivers/of/base.c b/drivers/of/base.c
index eaaeaf4f49..ee4d22ed72 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -689,18 +689,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));
@@ -717,6 +722,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++;
}
@@ -725,7 +733,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;
@@ -738,9 +746,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)