diff mbox series

[U-Boot,046/126] spl: Allow distinguishing between two phases in U-Boot

Message ID 20190925145750.200592-47-sjg@chromium.org
State Accepted
Commit 59c871bca799e1dae0144192d936ac0a3c172686
Delegated to: Bin Meng
Headers show
Series x86: Add initial support for apollolake | expand

Commit Message

Simon Glass Sept. 25, 2019, 2:56 p.m. UTC
U-Boot has two distinct phases: before and after relocation. These are
commonly referred to as F (running from Flash) and R (Relocated and
running from RAM). Some drivers want to do different things in these
phases so update the SPL phase function to return a different value for
each.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 include/spl.h | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

Comments

Bin Meng Oct. 5, 2019, 3:30 p.m. UTC | #1
On Wed, Sep 25, 2019 at 10:58 PM Simon Glass <sjg@chromium.org> wrote:
>
> U-Boot has two distinct phases: before and after relocation. These are
> commonly referred to as F (running from Flash) and R (Relocated and
> running from RAM). Some drivers want to do different things in these
> phases so update the SPL phase function to return a different value for
> each.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
>  include/spl.h | 16 +++++++++++-----
>  1 file changed, 11 insertions(+), 5 deletions(-)
>

Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Bin Meng Oct. 7, 2019, 1:55 a.m. UTC | #2
On Sat, Oct 5, 2019 at 11:30 PM Bin Meng <bmeng.cn@gmail.com> wrote:
>
> On Wed, Sep 25, 2019 at 10:58 PM Simon Glass <sjg@chromium.org> wrote:
> >
> > U-Boot has two distinct phases: before and after relocation. These are
> > commonly referred to as F (running from Flash) and R (Relocated and
> > running from RAM). Some drivers want to do different things in these
> > phases so update the SPL phase function to return a different value for
> > each.
> >
> > Signed-off-by: Simon Glass <sjg@chromium.org>
> > ---
> >
> >  include/spl.h | 16 +++++++++++-----
> >  1 file changed, 11 insertions(+), 5 deletions(-)
> >
>
> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

applied to u-boot-x86/next, thanks!
diff mbox series

Patch

diff --git a/include/spl.h b/include/spl.h
index 2869c9dc702..1ba90c36def 100644
--- a/include/spl.h
+++ b/include/spl.h
@@ -50,9 +50,10 @@  static inline bool u_boot_first_phase(void)
 }
 
 enum u_boot_phase {
-	PHASE_TPL,
-	PHASE_SPL,
-	PHASE_U_BOOT,
+	PHASE_TPL,	/* Running in TPL */
+	PHASE_SPL,	/* Running in SPL */
+	PHASE_BOARD_F,	/* Running in U-Boot before relocation */
+	PHASE_BOARD_R,	/* Running in U-Boot after relocation */
 };
 
 /**
@@ -92,7 +93,7 @@  enum u_boot_phase {
  *
  * but with this you can use:
  *
- *    if (spl_phase() == PHASE_U_BOOT) {
+ *    if (spl_phase() == PHASE_BOARD_F) {
  *       ...
  *    }
  *
@@ -105,7 +106,12 @@  static inline enum u_boot_phase spl_phase(void)
 #elif CONFIG_SPL_BUILD
 	return PHASE_SPL;
 #else
-	return PHASE_U_BOOT;
+	DECLARE_GLOBAL_DATA_PTR;
+
+	if (!(gd->flags & GD_FLG_RELOC))
+		return PHASE_BOARD_F;
+	else
+		return PHASE_BOARD_R;
 #endif
 }