aboutsummaryrefslogtreecommitdiff
path: root/include/spl.h
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2019-09-25 08:56:30 -0600
committerBin Meng <bmeng.cn@gmail.com>2019-10-08 13:57:45 +0800
commit59c871bca799e1dae0144192d936ac0a3c172686 (patch)
tree49b14531d74141ec4fd4ea3e43ab4cc1eb1e8867 /include/spl.h
parentb51882d0079d3275bdb83ce49fdc8a90133f7f07 (diff)
downloadu-boot-59c871bca799e1dae0144192d936ac0a3c172686.zip
u-boot-59c871bca799e1dae0144192d936ac0a3c172686.tar.gz
u-boot-59c871bca799e1dae0144192d936ac0a3c172686.tar.bz2
spl: Allow distinguishing between two phases in U-Boot
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> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Diffstat (limited to 'include/spl.h')
-rw-r--r--include/spl.h16
1 files changed, 11 insertions, 5 deletions
diff --git a/include/spl.h b/include/spl.h
index 9be8d0d..c7cc2b0 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
}