diff mbox series

[v2,1/3] arm: sunxi: Move spl_boot_device in a separate function

Message ID 7c8317f3ea8169b31efb21440441eac5875a9f37.1505246502.git-series.maxime.ripard@free-electrons.com
State Accepted
Commit 8829076a5b1001ee20009528931383e912496fcd
Headers show
Series mmc: sunxi: index hack removal | expand

Commit Message

Maxime Ripard Sept. 12, 2017, 8:02 p.m. UTC
U-Boot itself might need to identify the boot device, for example to be
able to tell where to load the kernel from when several options are
possible.

Move the logic of spl_boot_device to a function that is compiled both for
the SPL and the main binary.

Tested-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
---
 arch/arm/include/asm/arch-sunxi/spl.h |  2 ++
 arch/arm/mach-sunxi/board.c           | 11 ++++++++---
 2 files changed, 10 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/arch/arm/include/asm/arch-sunxi/spl.h b/arch/arm/include/asm/arch-sunxi/spl.h
index 9358397da27a..a70b1797e5d7 100644
--- a/arch/arm/include/asm/arch-sunxi/spl.h
+++ b/arch/arm/include/asm/arch-sunxi/spl.h
@@ -78,4 +78,6 @@  typedef char boot_file_head_not_multiple_of_32[1 - 2*(sizeof(struct boot_file_he
 
 #define is_boot0_magic(addr)	(memcmp((void *)addr, BOOT0_MAGIC, 8) == 0)
 
+uint32_t sunxi_get_boot_device(void);
+
 #endif
diff --git a/arch/arm/mach-sunxi/board.c b/arch/arm/mach-sunxi/board.c
index 65b1ebd83787..0c60ee04da54 100644
--- a/arch/arm/mach-sunxi/board.c
+++ b/arch/arm/mach-sunxi/board.c
@@ -14,9 +14,7 @@ 
 #include <mmc.h>
 #include <i2c.h>
 #include <serial.h>
-#ifdef CONFIG_SPL_BUILD
 #include <spl.h>
-#endif
 #include <asm/gpio.h>
 #include <asm/io.h>
 #include <asm/arch/clock.h>
@@ -212,11 +210,12 @@  void s_init(void)
 
 #ifdef CONFIG_SPL_BUILD
 DECLARE_GLOBAL_DATA_PTR;
+#endif
 
 /* The sunxi internal brom will try to loader external bootloader
  * from mmc0, nand flash, mmc2.
  */
-u32 spl_boot_device(void)
+uint32_t sunxi_get_boot_device(void)
 {
 	int boot_source;
 
@@ -255,6 +254,12 @@  u32 spl_boot_device(void)
 	return -1;		/* Never reached */
 }
 
+#ifdef CONFIG_SPL_BUILD
+u32 spl_boot_device(void)
+{
+	return sunxi_get_boot_device();
+}
+
 /* No confirmation data available in SPL yet. Hardcode bootmode */
 u32 spl_boot_mode(const u32 boot_device)
 {