summaryrefslogtreecommitdiffstats
path: root/arch/arm
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2013-06-23 16:27:20 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2013-06-26 18:20:53 +0200
commit76571ed68dd16b7fc26f99f12f62c06bde6a193b (patch)
treece1b87ad7f3e757d91884e7fccfb24f392120e5a /arch/arm
parent0cbb2155193ae04b4b9be501d22339ab80c03fee (diff)
downloadbarebox-76571ed68dd16b7fc26f99f12f62c06bde6a193b.tar.gz
barebox-76571ed68dd16b7fc26f99f12f62c06bde6a193b.tar.xz
ARM: Allow to pass a devicetree via boarddata
Addionally to having a builtin DTB provide the possibility for the board to provide a dtb via boarddata. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/arm')
-rw-r--r--arch/arm/cpu/Makefile2
-rw-r--r--arch/arm/cpu/dtb.c22
-rw-r--r--arch/arm/cpu/start.c20
-rw-r--r--arch/arm/include/asm/barebox-arm.h2
4 files changed, 43 insertions, 3 deletions
diff --git a/arch/arm/cpu/Makefile b/arch/arm/cpu/Makefile
index c442b35797..99973ae46e 100644
--- a/arch/arm/cpu/Makefile
+++ b/arch/arm/cpu/Makefile
@@ -8,7 +8,7 @@ obj-y += start.o setupc.o
#
obj-$(CONFIG_CMD_ARM_CPUINFO) += cpuinfo.o
obj-$(CONFIG_CMD_ARM_MMUINFO) += mmuinfo.o
-obj-$(CONFIG_BUILTIN_DTB) += dtb.o
+obj-$(CONFIG_OFDEVICE) += dtb.o
obj-$(CONFIG_MMU) += mmu.o cache.o mmu-early.o
pbl-$(CONFIG_MMU) += cache.o mmu-early.o
obj-$(CONFIG_CPU_32v4T) += cache-armv4.o
diff --git a/arch/arm/cpu/dtb.c b/arch/arm/cpu/dtb.c
index 10b73bd519..a5881dd721 100644
--- a/arch/arm/cpu/dtb.c
+++ b/arch/arm/cpu/dtb.c
@@ -17,20 +17,38 @@
#include <common.h>
#include <init.h>
#include <of.h>
+#include <asm/barebox-arm.h>
extern char __dtb_start[];
static int of_arm_init(void)
{
struct device_node *root;
+ void *fdt;
+ /* See if we already have a dtb */
root = of_get_root_node();
if (root)
return 0;
- root = of_unflatten_dtb(NULL, __dtb_start);
- if (root) {
+ /* See if we are provided a dtb in boarddata */
+ fdt = barebox_arm_boot_dtb();
+ if (fdt)
+ pr_debug("using boarddata provided DTB\n");
+
+ /* Next see if we have a builtin dtb */
+ if (!fdt && IS_ENABLED(CONFIG_BUILTIN_DTB)) {
+ fdt = __dtb_start;
pr_debug("using internal DTB\n");
+ }
+
+ if (!fdt) {
+ pr_debug("No DTB found\n");
+ return 0;
+ }
+
+ root = of_unflatten_dtb(NULL, fdt);
+ if (root) {
of_set_root_node(root);
if (IS_ENABLED(CONFIG_OFDEVICE))
of_probe();
diff --git a/arch/arm/cpu/start.c b/arch/arm/cpu/start.c
index 5a3c629c73..1f397ec789 100644
--- a/arch/arm/cpu/start.c
+++ b/arch/arm/cpu/start.c
@@ -24,6 +24,7 @@
#include <asm/barebox-arm-head.h>
#include <asm-generic/memory_layout.h>
#include <asm/sections.h>
+#include <asm/unaligned.h>
#include <asm/cache.h>
#include <memory.h>
@@ -40,6 +41,13 @@ unsigned long barebox_arm_boarddata(void)
return barebox_boarddata;
}
+static void *barebox_boot_dtb;
+
+void *barebox_arm_boot_dtb(void)
+{
+ return barebox_boot_dtb;
+}
+
static noinline __noreturn void __start(uint32_t membase, uint32_t memsize,
uint32_t boarddata)
{
@@ -66,6 +74,18 @@ static noinline __noreturn void __start(uint32_t membase, uint32_t memsize,
mmu_early_enable(membase, memsize, endmem);
}
+ /*
+ * If boarddata is a pointer inside valid memory and contains a
+ * FDT magic then use it as later to probe devices
+ */
+ if (boarddata > membase && boarddata < membase + memsize &&
+ get_unaligned_be32((void *)boarddata) == FDT_MAGIC) {
+ uint32_t totalsize = get_unaligned_be32((void *)boarddata + 4);
+ endmem -= ALIGN(totalsize, 64);
+ barebox_boot_dtb = (void *)endmem;
+ memcpy(barebox_boot_dtb, (void *)boarddata, totalsize);
+ }
+
if ((unsigned long)_text > membase + memsize ||
(unsigned long)_text < membase)
/*
diff --git a/arch/arm/include/asm/barebox-arm.h b/arch/arm/include/asm/barebox-arm.h
index cd8decfccd..ddcafd1af7 100644
--- a/arch/arm/include/asm/barebox-arm.h
+++ b/arch/arm/include/asm/barebox-arm.h
@@ -54,6 +54,8 @@ static inline void arm_fixup_vectors(void)
}
#endif
+void *barebox_arm_boot_dtb(void);
+
/*
* For relocatable binaries find a suitable start address for the
* relocated binary. Beginning at the memory end substract the reserved