summaryrefslogtreecommitdiffstats
path: root/arch/arm/cpu
diff options
context:
space:
mode:
authorAhmad Fatoum <ahmad@a3f.at>2021-02-22 07:30:52 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2021-02-22 08:59:33 +0100
commit87d6abb654b993948a9eea2169ffe7d5fc631154 (patch)
treecc1e6cb79da2f556956ebb9d64a556da14d272f1 /arch/arm/cpu
parent28cc86df3d47838342140894db5b46e41b211f4e (diff)
downloadbarebox-87d6abb654b993948a9eea2169ffe7d5fc631154.tar.gz
barebox-87d6abb654b993948a9eea2169ffe7d5fc631154.tar.xz
pbl: provide externally visible fdt_find_mem
of_find_mem can be used for generic DT images for other architectures as well. To support this, move the definition, so it can be used by others in the future. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/arm/cpu')
-rw-r--r--arch/arm/cpu/board-dt-2nd.c68
1 files changed, 1 insertions, 67 deletions
diff --git a/arch/arm/cpu/board-dt-2nd.c b/arch/arm/cpu/board-dt-2nd.c
index 7a8155b7b0..bb13180785 100644
--- a/arch/arm/cpu/board-dt-2nd.c
+++ b/arch/arm/cpu/board-dt-2nd.c
@@ -8,73 +8,7 @@
#include <debug_ll.h>
#include <asm/cache.h>
#include <asm/sections.h>
-#include <linux/libfdt.h>
-
-static void fdt_find_mem(const void *fdt, unsigned long *membase, unsigned long *memsize)
-{
- const __be32 *nap, *nsp, *reg;
- uint32_t na, ns;
- uint64_t memsize64, membase64;
- int node, size, i;
-
- /* Make sure FDT blob is sane */
- if (fdt_check_header(fdt) != 0) {
- pr_err("Invalid device tree blob\n");
- goto err;
- }
-
- /* Find the #address-cells and #size-cells properties */
- node = fdt_path_offset(fdt, "/");
- if (node < 0) {
- pr_err("Cannot find root node\n");
- goto err;
- }
-
- nap = fdt_getprop(fdt, node, "#address-cells", &size);
- if (!nap || (size != 4)) {
- pr_err("Cannot find #address-cells property");
- goto err;
- }
- na = fdt32_to_cpu(*nap);
-
- nsp = fdt_getprop(fdt, node, "#size-cells", &size);
- if (!nsp || (size != 4)) {
- pr_err("Cannot find #size-cells property");
- goto err;
- }
- ns = fdt32_to_cpu(*nap);
-
- /* Find the memory range */
- node = fdt_node_offset_by_prop_value(fdt, -1, "device_type",
- "memory", sizeof("memory"));
- if (node < 0) {
- pr_err("Cannot find memory node\n");
- goto err;
- }
-
- reg = fdt_getprop(fdt, node, "reg", &size);
- if (size < (na + ns) * sizeof(u32)) {
- pr_err("cannot get memory range\n");
- goto err;
- }
-
- membase64 = 0;
- for (i = 0; i < na; i++)
- membase64 = (membase64 << 32) | fdt32_to_cpu(*reg++);
-
- /* get the memsize and truncate it to under 4G on 32 bit machines */
- memsize64 = 0;
- for (i = 0; i < ns; i++)
- memsize64 = (memsize64 << 32) | fdt32_to_cpu(*reg++);
-
- *membase = membase64;
- *memsize = memsize64;
-
- return;
-err:
- pr_err("No memory, cannot continue\n");
- while (1);
-}
+#include <pbl.h>
#ifdef CONFIG_CPU_V8