public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Siarhei Siamashka <siarhei.siamashka@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 1/4] sunxi: Make FEL mode usable again
Date: Fri, 30 Jan 2015 20:46:27 +0200	[thread overview]
Message-ID: <20150130204627.2f913d54@i7> (raw)
In-Reply-To: <1422619129-23352-2-git-send-email-siarhei.siamashka@gmail.com>

On Fri, 30 Jan 2015 13:58:46 +0200
Siarhei Siamashka <siarhei.siamashka@gmail.com> 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 <siarhei.siamashka@gmail.com>
> ---
>  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 <siarhei.siamashka@gmail.com>
> + *
> + * SPDX-License-Identifier:	GPL-2.0+
> + */
> +
> +#include <asm-offsets.h>
> +#include <config.h>
> +#include <linux/linkage.h>
> +
> +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

  reply	other threads:[~2015-01-30 18:46 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-30 11:58 [U-Boot] [PATCH 0/4] sunxi: FEL mode fixes Siarhei Siamashka
2015-01-30 11:58 ` [U-Boot] [PATCH 1/4] sunxi: Make FEL mode usable again Siarhei Siamashka
2015-01-30 18:46   ` Siarhei Siamashka [this message]
2015-02-01 16:28   ` Simon Glass
2015-02-01 18:48     ` Siarhei Siamashka
2015-02-01 20:59       ` Simon Glass
2015-02-01 23:59         ` Siarhei Siamashka
2015-02-02 18:45           ` Simon Glass
2015-01-30 11:58 ` [U-Boot] [PATCH 2/4] sunxi: Use Thumb2 for the FEL mode SPL Siarhei Siamashka
2015-01-30 11:58 ` [U-Boot] [PATCH 3/4] sunxi: Get rid of u-boot-spl-fel.lds Siarhei Siamashka
2015-01-30 11:58 ` [U-Boot] [PATCH 4/4] sunxi: Use more realistic size limit for FEL SPL Siarhei Siamashka
2015-02-02 15:10 ` [U-Boot] [PATCH 0/4] sunxi: FEL mode fixes Tom Rini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150130204627.2f913d54@i7 \
    --to=siarhei.siamashka@gmail.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox