From mboxrd@z Thu Jan 1 00:00:00 1970 From: Siarhei Siamashka Date: Fri, 30 Jan 2015 20:46:27 +0200 Subject: [U-Boot] [PATCH 1/4] sunxi: Make FEL mode usable again In-Reply-To: <1422619129-23352-2-git-send-email-siarhei.siamashka@gmail.com> References: <1422619129-23352-1-git-send-email-siarhei.siamashka@gmail.com> <1422619129-23352-2-git-send-email-siarhei.siamashka@gmail.com> Message-ID: <20150130204627.2f913d54@i7> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Fri, 30 Jan 2015 13:58:46 +0200 Siarhei Siamashka wrote: > The commit f630974ccb3ce93e9607a3354e9acb266a8b7e95 > 'sunxi: Move SPL s_init() code to board_init_f()' > broke the FEL boot mode. > > This patch moves the DRAM initialization back to s_init() and > introduces an assembly entry point for FEL in order to provide > guaranteed initialization of the gdata pointer (r9). The assembly > entry point is also needed to ensure that the SPL code starts > executing in ARM mode. > > Because the sunxi board_init_f() does not contain anything that > is not already done by the default board_init_f(), it is removed > too. > > Signed-off-by: Siarhei Siamashka > --- > arch/arm/cpu/armv7/sunxi/Makefile | 1 + > arch/arm/cpu/armv7/sunxi/board.c | 26 ++++++++++---------------- > arch/arm/cpu/armv7/sunxi/start_fel.S | 16 ++++++++++++++++ > arch/arm/cpu/armv7/sunxi/u-boot-spl-fel.lds | 3 ++- > 4 files changed, 29 insertions(+), 17 deletions(-) > create mode 100644 arch/arm/cpu/armv7/sunxi/start_fel.S [...] > +++ b/arch/arm/cpu/armv7/sunxi/start_fel.S > @@ -0,0 +1,16 @@ > +/* > + * Entry point of the FEL mode SPL. > + * > + * Copyright (c) 2015 Siarhei Siamashka > + * > + * SPDX-License-Identifier: GPL-2.0+ > + */ > + > +#include > +#include > +#include > + > +ENTRY(_start_fel) > + ldr r9, =gdata > + b s_init > +ENDPROC(_start_fel) In fact, we probably need to save/restore the r9 register and do it as: push {r9, lr} ldr r9, =gdata bl s_init pop {r9, pc} And maybe save some other registers, depending on the calling conventions expected by the FEL code in BROM. As a side note, corrupting r9 mimics the old u-boot sunxi behaviour. And it used not to cause any visible problems so far, at least when working with the BROM code in the current Allwinner SoCs. Also as I see it, the ".bss" sections is supposed to be in DRAM, and cleared only after the DRAM is initialized. This violates the C standard a little bit and enforces some sort of u-boot specific coding tricks. Such as explicitly placing gdata in the ".data" section instead of ".bss". This is ugly, but probably justified. I'll submit a fixed v2 version of this patch later, but will first wait for additional comments from the other people. -- Best regards, Siarhei Siamashka