arm: Migrate SYS_THUMB_BUILD to Kconfig, introduce SPL_SYS_THUMB_BUILD

Today, we have cases where we wish to build all of U-Boot in Thumb2 mode for
various reasons.  We also have cases where we only build SPL in Thumb2 mode due
to size constraints and wish to build the rest of the system in ARM mode.  So
in this migration we introduce a new symbol as well, SPL_SYS_THUMB_BUILD to
control if we build everything or just SPL (or in theory, just U-Boot) in
Thumb2 mode.

Signed-off-by: Tom Rini <trini@konsulko.com>
Acked-by: Siarhei Siamashka <siarhei.siamashka@gmail.com>
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 7c5012ac..d6b0cea 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -181,6 +181,25 @@
 	  the hosted environment to call out to the emulator to
 	  retrieve files from the host machine.
 
+config SYS_THUMB_BUILD
+	bool "Build U-Boot using the Thumb instruction set"
+	depends on !ARM64
+	help
+	   Use this flag to build U-Boot using the Thumb instruction set for
+	   ARM architectures. Thumb instruction set provides better code
+	   density. For ARM architectures that support Thumb2 this flag will
+	   result in Thumb2 code generated by GCC.
+
+config SPL_SYS_THUMB_BUILD
+	bool "Build SPL using the Thumb instruction set"
+	default y if SYS_THUMB_BUILD
+	depends on !ARM64
+	help
+	   Use this flag to build SPL using the Thumb instruction set for
+	   ARM architectures. Thumb instruction set provides better code
+	   density. For ARM architectures that support Thumb2 this flag will
+	   result in Thumb2 code generated by GCC.
+
 config SYS_L2CACHE_OFF
 	bool "L2cache off"
 	help
@@ -571,6 +590,7 @@
 	bool "TI Keystone"
 	select CPU_V7
 	select SUPPORT_SPL
+	select SYS_THUMB_BUILD
 	select CMD_POWEROFF
 
 config ARCH_MESON
@@ -595,6 +615,7 @@
 	select SYS_FSL_HAS_SEC if SECURE_BOOT
 	select SYS_FSL_SEC_COMPAT_4
 	select SYS_FSL_SEC_LE
+	select SYS_THUMB_BUILD if SPL
 
 config ARCH_MX5
 	bool "Freescale MX5"
@@ -654,6 +675,7 @@
 	imply SPL_NAND_SUPPORT
 	imply SPL_POWER_SUPPORT
 	imply SPL_SERIAL_SUPPORT
+	imply SYS_THUMB_BUILD
 
 config OMAP44XX
 	bool "OMAP44XX SoC"
@@ -671,11 +693,13 @@
 	imply SPL_NAND_SUPPORT
 	imply SPL_POWER_SUPPORT
 	imply SPL_SERIAL_SUPPORT
+	imply SYS_THUMB_BUILD
 
 config OMAP54XX
 	bool "OMAP54XX SoC"
 	select ARCH_OMAP2
 	select ARM_ERRATA_798870
+	select SYS_THUMB_BUILD
 	imply SPL_DISPLAY_PRINT
 	imply SPL_ENV_SUPPORT
 	imply SPL_EXT_SUPPORT
@@ -693,6 +717,7 @@
 config AM43XX
 	bool "AM43XX SoC"
 	select ARCH_OMAP2
+	imply SYS_THUMB_BUILD
 	help
 	  Support for AM43xx SOC from Texas Instruments.
 	  The AM43xx high performance SOC features a Cortex-A9
@@ -703,6 +728,7 @@
 config AM33XX
 	bool "AM33XX SoC"
 	select ARCH_OMAP2
+	imply SYS_THUMB_BUILD
 	help
 	  Support for AM335x SOC from Texas Instruments.
 	  The AM335x high performance SOC features a Cortex-A8
@@ -715,6 +741,7 @@
 	select DM
 	select DM_SERIAL
 	select BOARD_EARLY_INIT_F
+	imply SYS_THUMB_BUILD
 
 config TARGET_S32V234EVB
 	bool "Support s32v234evb"
@@ -744,6 +771,7 @@
 	select ARCH_EARLY_INIT_R
 	select ARCH_MISC_INIT
 	select SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION
+	select SYS_THUMB_BUILD
 
 config TARGET_CM_T43
 	bool "Support cm_t43"
@@ -766,6 +794,7 @@
 	select SPL_STACK_R if SUPPORT_SPL
 	select SPL_SYS_MALLOC_SIMPLE if SUPPORT_SPL
 	select SYS_NS16550
+	select SPL_SYS_THUMB_BUILD if !ARM64
 	select USB if DISTRO_DEFAULTS
 	select USB_STORAGE if DISTRO_DEFAULTS
 	select USB_KEYBOARD if DISTRO_DEFAULTS
@@ -1095,6 +1124,7 @@
 	select CPU_V7M
 	select DM
 	select DM_SERIAL
+	select SYS_THUMB_BUILD
 
 config ARCH_STI
 	bool "Support STMicrolectronics SoCs"
@@ -1114,6 +1144,7 @@
 	select DM
 	select SPL_DM if SPL
 	select SYS_MALLOC_F
+	select SYS_THUMB_BUILD if !ARM64
 	select SPL_SYS_MALLOC_SIMPLE if SPL
 	select DM_GPIO
 	select DM_I2C