From: Pali Rohár <pali@kernel.org>
Date: Fri, 6 May 2022 09:05:13 +0000 (+0200)
Subject: arm: Add new config option ARCH_VERY_EARLY_INIT
X-Git-Tag: v2025.01-rc5-pxa1908~1405^2~9
X-Git-Url: http://git.dujemihanovic.xyz/img/html/static/git-logo.png?a=commitdiff_plain;h=948da7773e340fe76d4d1b9c635d724bf8661d30;p=u-boot.git

arm: Add new config option ARCH_VERY_EARLY_INIT

When this option is set then ARM _main() function would call
arch_very_early_init() function at the beginning. It would be before
calling any other functions like debug_uart_init() and also before
initializing C runtime environment.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Stefan Roese <sr@denx.de>
---

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 0afec5155b..9898c7d68e 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -401,6 +401,12 @@ config SYS_ARM_CACHE_WRITEALLOC
 	  write is performed.
 endchoice
 
+config ARCH_VERY_EARLY_INIT
+	bool
+
+config SPL_ARCH_VERY_EARLY_INIT
+	bool
+
 config ARCH_CPU_INIT
 	bool "Enable ARCH_CPU_INIT"
 	help
diff --git a/arch/arm/lib/crt0.S b/arch/arm/lib/crt0.S
index ba312901f3..612a2d5b69 100644
--- a/arch/arm/lib/crt0.S
+++ b/arch/arm/lib/crt0.S
@@ -90,6 +90,11 @@ clbss_l:cmp	r0, r1			/* while not at end of BSS */
 
 ENTRY(_main)
 
+/* Call arch_very_early_init before initializing C runtime environment. */
+#if CONFIG_IS_ENABLED(ARCH_VERY_EARLY_INIT)
+	bl	arch_very_early_init
+#endif
+
 /*
  * Set up initial C runtime environment and call board_init_f(0).
  */