diff options
author | Clement Leger <cleger@kalray.eu> | 2020-03-25 18:27:37 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2020-03-30 07:31:16 +0200 |
commit | 8226f7f9097348464c4a4872e13ef271da9c74da (patch) | |
tree | 197c3c15318935a379a5fced81db2f5496ef44fb /drivers/of | |
parent | e0ed32ee61676ef2e4090fe44220c63b8a66beaf (diff) | |
download | barebox-8226f7f9097348464c4a4872e13ef271da9c74da.tar.gz barebox-8226f7f9097348464c4a4872e13ef271da9c74da.tar.xz |
of: base: parse all available memory nodes
Currently, barebox only parse one memory node which is either the
"/memory" node or the first node with device_type == "memory".
However, the use of multiple memory nodes with device_type = "memory"
property is allowed by the device tree specification and already
correctly parsed by Linux kernel.
In order to fix that, add of_probe_memory function which loop over all
available memory nodes matching device_type == "memory".
Signed-off-by: Clement Leger <cleger@kalray.eu>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/of')
-rw-r--r-- | drivers/of/base.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/drivers/of/base.c b/drivers/of/base.c index 2ea8d75160..6d13b66a0e 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -2062,9 +2062,23 @@ const struct of_device_id of_default_bus_match_table[] = { } }; +static void of_probe_memory(void) +{ + struct device_node *memory = root_node; + + /* Parse all available node with "memory" device_type */ + while (1) { + memory = of_find_node_by_type(memory, "memory"); + if (!memory) + break; + + of_add_memory(memory, false); + } +} + int of_probe(void) { - struct device_node *memory, *firmware; + struct device_node *firmware; if(!root_node) return -ENODEV; @@ -2075,11 +2089,7 @@ int of_probe(void) if (of_model) barebox_set_model(of_model); - memory = of_find_node_by_path("/memory"); - if (!memory) - memory = of_find_node_by_type(root_node, "memory"); - if (memory) - of_add_memory(memory, false); + of_probe_memory(); firmware = of_find_node_by_path("/firmware"); if (firmware) |