summaryrefslogtreecommitdiffstats
path: root/arch/arm/cpu
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2015-11-06 16:10:35 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2015-11-06 16:10:35 +0100
commit5b476ef5e510c4305d81f82c9041eeedef2e8215 (patch)
treeb55cc39fd71f0dfb55861393d8813a513fb9cf12 /arch/arm/cpu
parent812a0fd6b87c620b931cd3a5f0edb6517f1df147 (diff)
parent0f0e0b4408e0ad720a036707fe2f841801dfe379 (diff)
downloadbarebox-5b476ef5e510c4305d81f82c9041eeedef2e8215.tar.gz
barebox-5b476ef5e510c4305d81f82c9041eeedef2e8215.tar.xz
Merge branch 'for-next/imx'
Diffstat (limited to 'arch/arm/cpu')
-rw-r--r--arch/arm/cpu/start.c48
1 files changed, 46 insertions, 2 deletions
diff --git a/arch/arm/cpu/start.c b/arch/arm/cpu/start.c
index 274652d7b2..64b0dd88dd 100644
--- a/arch/arm/cpu/start.c
+++ b/arch/arm/cpu/start.c
@@ -27,6 +27,8 @@
#include <asm/unaligned.h>
#include <asm/cache.h>
#include <memory.h>
+#include <uncompress.h>
+#include <malloc.h>
#include <debug_ll.h>
#include "mmu-early.h"
@@ -39,6 +41,13 @@ static bool blob_is_fdt(const void *blob)
return get_unaligned_be32(blob) == FDT_MAGIC;
}
+static bool blob_is_compressed_fdt(const void *blob)
+{
+ const struct barebox_arm_boarddata_compressed_dtb *dtb = blob;
+
+ return dtb->magic == BAREBOX_ARM_BOARDDATA_COMPRESSED_DTB_MAGIC;
+}
+
static bool blob_is_arm_boarddata(const void *blob)
{
const struct barebox_arm_boarddata *bd = blob;
@@ -58,10 +67,41 @@ u32 barebox_arm_machine(void)
void *barebox_arm_boot_dtb(void)
{
- if (barebox_boarddata && blob_is_fdt(barebox_boarddata))
+ void *dtb;
+ void *data;
+ int ret;
+ struct barebox_arm_boarddata_compressed_dtb *compressed_dtb;
+
+ if (barebox_boarddata && blob_is_fdt(barebox_boarddata)) {
+ pr_debug("%s: using barebox_boarddata\n", __func__);
return barebox_boarddata;
- else
+ }
+
+ if (!IS_ENABLED(CONFIG_ARM_USE_COMPRESSED_DTB) || !barebox_boarddata
+ || !blob_is_compressed_fdt(barebox_boarddata))
+ return NULL;
+
+ compressed_dtb = barebox_boarddata;
+
+ pr_debug("%s: using compressed_dtb\n", __func__);
+
+ dtb = malloc(compressed_dtb->datalen_uncompressed);
+ if (!dtb)
return NULL;
+
+ data = compressed_dtb + 1;
+
+ ret = uncompress(data, compressed_dtb->datalen, NULL, NULL,
+ dtb, NULL, NULL);
+ if (ret) {
+ pr_err("uncompressing dtb failed\n");
+ free(dtb);
+ return NULL;
+ }
+
+ barebox_boarddata = dtb;
+
+ return barebox_boarddata;
}
__noreturn void barebox_non_pbl_start(unsigned long membase,
@@ -105,6 +145,10 @@ __noreturn void barebox_non_pbl_start(unsigned long membase,
if (blob_is_fdt(boarddata)) {
totalsize = get_unaligned_be32(boarddata + 4);
name = "DTB";
+ } else if (blob_is_compressed_fdt(boarddata)) {
+ struct barebox_arm_boarddata_compressed_dtb *bd = boarddata;
+ totalsize = bd->datalen;
+ name = "Compressed DTB";
} else if (blob_is_arm_boarddata(boarddata)) {
totalsize = sizeof(struct barebox_arm_boarddata);
name = "machine type";