From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by casper.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1e2ai1-0004dn-AK for barebox@lists.infradead.org; Thu, 12 Oct 2017 10:27:24 +0000 Received: from dude.hi.pengutronix.de ([2001:67c:670:100:1d::7] helo=dude.pengutronix.de.) by metis.ext.pengutronix.de with esmtp (Exim 4.84_2) (envelope-from ) id 1e2ahe-0003Lx-KT for barebox@lists.infradead.org; Thu, 12 Oct 2017 12:26:58 +0200 From: Lucas Stach Date: Thu, 12 Oct 2017 12:26:55 +0200 Message-Id: <20171012102658.17104-9-l.stach@pengutronix.de> In-Reply-To: <20171012102658.17104-1-l.stach@pengutronix.de> References: <20171012102658.17104-1-l.stach@pengutronix.de> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "barebox" Errors-To: barebox-bounces+u.kleine-koenig=pengutronix.de@lists.infradead.org Subject: [PATCH v2 09/12] vexpress: use device tree provided by QEMU if available To: barebox@lists.infradead.org From: Michael Olbrich Signed-off-by: Michael Olbrich Signed-off-by: Lucas Stach --- arch/arm/boards/vexpress/lowlevel.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/arch/arm/boards/vexpress/lowlevel.c b/arch/arm/boards/vexpress/lowlevel.c index 0a226b295c2a..9fe7c836b7b6 100644 --- a/arch/arm/boards/vexpress/lowlevel.c +++ b/arch/arm/boards/vexpress/lowlevel.c @@ -9,18 +9,34 @@ #include #include #include +#include #include static inline void start_vexpress_common(void *internal_dt) { void *fdt = internal_dt - get_runtime_offset(); + unsigned long membase, memsize = SZ_512M; arm_cpu_lowlevel_init(); if (amba_is_arm_sp804(IOMEM(0x10011000))) - barebox_arm_entry(0x60000000, SZ_512M, fdt); + membase = 0x60000000; else - barebox_arm_entry(0x80000000, SZ_512M, fdt); + membase = 0x80000000; + + /* QEMU may put a DTB at the start of RAM */ + if (IS_ENABLED(CONFIG_OFDEVICE) && + get_unaligned_be32((void*)membase) == FDT_MAGIC) { + fdt = (void*)membase; + /* + * Need to move membase a bit as the PBL wants to relocate + * to the start of RAM, which would overwrite the DTB. + */ + membase += SZ_4M; + memsize -= SZ_4M; + } + + barebox_arm_entry(membase, memsize, fdt); } extern char __dtb_vexpress_v2p_ca9_start[]; -- 2.11.0 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox