summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/arm/cpu/start.c43
-rw-r--r--arch/arm/include/asm/barebox-arm.h27
2 files changed, 53 insertions, 17 deletions
diff --git a/arch/arm/cpu/start.c b/arch/arm/cpu/start.c
index 304ed0cee7..91badc97b3 100644
--- a/arch/arm/cpu/start.c
+++ b/arch/arm/cpu/start.c
@@ -28,17 +28,22 @@
#include <asm/cache.h>
#include <memory.h>
+#include <debug_ll.h>
#include "mmu-early.h"
unsigned long arm_stack_top;
static void *barebox_boarddata;
-/*
- * return the boarddata variable passed to barebox_arm_entry
- */
-void *barebox_arm_boarddata(void)
+u32 barebox_arm_machine(void)
{
- return barebox_boarddata;
+ struct barebox_arm_boarddata *bd;
+
+ if (!barebox_boarddata)
+ return 0;
+
+ bd = barebox_boarddata;
+
+ return bd->machine;
}
static void *barebox_boot_dtb;
@@ -81,17 +86,23 @@ static noinline __noreturn void __start(unsigned long membase,
}
}
- /*
- * If boarddata is a pointer inside valid memory and contains a
- * FDT magic then use it as later to probe devices
- */
- if (boarddata && get_unaligned_be32(boarddata) == FDT_MAGIC) {
- uint32_t totalsize = get_unaligned_be32(boarddata + 4);
- endmem -= ALIGN(totalsize, 64);
- barebox_boot_dtb = (void *)endmem;
- pr_debug("found DTB in boarddata, copying to 0x%p\n",
- barebox_boot_dtb);
- memcpy(barebox_boot_dtb, boarddata, totalsize);
+ if (boarddata) {
+ if (get_unaligned_be32(boarddata) == FDT_MAGIC) {
+ uint32_t totalsize = get_unaligned_be32(boarddata + 4);
+ endmem -= ALIGN(totalsize, 64);
+ barebox_boot_dtb = (void *)endmem;
+ pr_debug("found DTB in boarddata, copying to 0x%p\n",
+ barebox_boot_dtb);
+ memcpy(barebox_boot_dtb, boarddata, totalsize);
+ } else if (((struct barebox_arm_boarddata *)boarddata)->magic ==
+ BAREBOX_ARM_BOARDDATA_MAGIC) {
+ endmem -= ALIGN(sizeof(struct barebox_arm_boarddata), 64);
+ barebox_boarddata = (void *)endmem;
+ pr_debug("found machine type in boarddata, copying to 0x%p\n",
+ barebox_boarddata);
+ memcpy(barebox_boarddata, boarddata,
+ sizeof(struct barebox_arm_boarddata));
+ }
}
if ((unsigned long)_text > membase + memsize ||
diff --git a/arch/arm/include/asm/barebox-arm.h b/arch/arm/include/asm/barebox-arm.h
index dbc8aaaba7..0b8acb8b8e 100644
--- a/arch/arm/include/asm/barebox-arm.h
+++ b/arch/arm/include/asm/barebox-arm.h
@@ -48,7 +48,32 @@ void setup_c(void);
void relocate_to_current_adr(void);
void relocate_to_adr(unsigned long target);
void __noreturn barebox_arm_entry(unsigned long membase, unsigned long memsize, void *boarddata);
-void *barebox_arm_boarddata(void);
+
+struct barebox_arm_boarddata {
+#define BAREBOX_ARM_BOARDDATA_MAGIC 0xabe742c3
+ u32 magic;
+ u32 machine; /* machine number to pass to barebox. This may or may
+ * not be a ARM machine number registered on arm.linux.org.uk.
+ * It must only be unique across barebox. Please use a number
+ * that do not potientially clashes with registered machines,
+ * i.e. use a number > 0x10000.
+ */
+};
+
+/*
+ * Create a boarddata struct at given address. Suitable to be passed
+ * as boarddata to barebox_arm_entry(). The machine can be retrieved
+ * later with barebox_arm_machine().
+ */
+static inline void boarddata_create(void *adr, u32 machine)
+{
+ struct barebox_arm_boarddata *bd = adr;
+
+ bd->magic = BAREBOX_ARM_BOARDDATA_MAGIC;
+ bd->machine = machine;
+}
+
+u32 barebox_arm_machine(void);
#if defined(CONFIG_RELOCATABLE) && defined(CONFIG_ARM_EXCEPTIONS)
void arm_fixup_vectors(void);