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/Makefile b/Makefile
index 323d646..1001bc5 100644
--- a/Makefile
+++ b/Makefile
@@ -624,8 +624,9 @@
 UBOOTINCLUDE    := \
 		-Iinclude \
 		$(if $(KBUILD_SRC), -I$(srctree)/include) \
-		$(if $(CONFIG_SYS_THUMB_BUILD), $(if $(CONFIG_HAS_THUMB2),, \
-			-I$(srctree)/arch/$(ARCH)/thumb1/include),) \
+		$(if $(CONFIG_$(SPL_)SYS_THUMB_BUILD), \
+			$(if $(CONFIG_HAS_THUMB2),, \
+				-I$(srctree)/arch/$(ARCH)/thumb1/include),) \
 		-I$(srctree)/arch/$(ARCH)/include \
 		-include $(srctree)/include/linux/kconfig.h
 
diff --git a/README b/README
index ac6eaa5..aa907ce 100644
--- a/README
+++ b/README
@@ -592,14 +592,6 @@
 		Select high exception vectors of the ARM core, e.g., do not
 		clear the V bit of the c1 register of CP15.
 
-		CONFIG_SYS_THUMB_BUILD
-
-		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.
-
 		COUNTER_FREQUENCY
 		Generic timer clock source frequency.
 
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
diff --git a/arch/arm/config.mk b/arch/arm/config.mk
index 3a81f13..08d7d1b 100644
--- a/arch/arm/config.mk
+++ b/arch/arm/config.mk
@@ -31,7 +31,7 @@
 PLATFORM_CPPFLAGS += -D__ARM__
 
 # Choose between ARM/Thumb instruction sets
-ifeq ($(CONFIG_SYS_THUMB_BUILD),y)
+ifeq ($(CONFIG_$(SPL_)SYS_THUMB_BUILD),y)
 AFLAGS_IMPLICIT_IT	:= $(call as-option,-Wa$(comma)-mimplicit-it=always)
 PF_CPPFLAGS_ARM		:= $(AFLAGS_IMPLICIT_IT) \
 			$(call cc-option, -mthumb -mthumb-interwork,\
@@ -44,8 +44,7 @@
 endif
 
 # Only test once
-ifneq ($(CONFIG_SPL_BUILD),y)
-ifeq ($(CONFIG_SYS_THUMB_BUILD),y)
+ifeq ($(CONFIG_$(SPL_)SYS_THUMB_BUILD),y)
 archprepare: checkthumb
 
 checkthumb:
@@ -57,7 +56,6 @@
 		false; \
 	fi
 endif
-endif
 
 # Try if EABI is supported, else fall back to old API,
 # i. e. for example:
@@ -99,7 +97,7 @@
 #
 # http://sourceware.org/bugzilla/show_bug.cgi?id=12532
 #
-ifeq ($(CONFIG_SYS_THUMB_BUILD),y)
+ifeq ($(CONFIG_$(SPL_)SYS_THUMB_BUILD),y)
 ifeq ($(GAS_BUG_12532),)
 export GAS_BUG_12532:=$(shell if [ $(call binutils-version) -lt 0222 ] ; \
 	then echo y; else echo n; fi)
diff --git a/arch/arm/cpu/arm920t/Makefile b/arch/arm/cpu/arm920t/Makefile
index 1832b9d..7aa432a 100644
--- a/arch/arm/cpu/arm920t/Makefile
+++ b/arch/arm/cpu/arm920t/Makefile
@@ -16,6 +16,6 @@
 
 # some files can only build in ARM mode
 
-ifdef CONFIG_SYS_THUMB_BUILD
+ifdef CONFIG_$(SPL_)SYS_THUMB_BUILD
 CFLAGS_cpu.o := -marm
 endif
diff --git a/arch/arm/cpu/arm926ejs/Makefile b/arch/arm/cpu/arm926ejs/Makefile
index fe78922..0f73011 100644
--- a/arch/arm/cpu/arm926ejs/Makefile
+++ b/arch/arm/cpu/arm926ejs/Makefile
@@ -23,7 +23,7 @@
 
 # some files can only build in ARM or THUMB2, not THUMB1
 
-ifdef CONFIG_SYS_THUMB_BUILD
+ifdef CONFIG_$(SPL_)SYS_THUMB_BUILD
 ifndef CONFIG_HAS_THUMB2
 
 CFLAGS_cpu.o := -marm
diff --git a/arch/arm/cpu/arm926ejs/cache.c b/arch/arm/cpu/arm926ejs/cache.c
index 02cb24c..d56e594 100644
--- a/arch/arm/cpu/arm926ejs/cache.c
+++ b/arch/arm/cpu/arm926ejs/cache.c
@@ -63,6 +63,6 @@
 
 __weak void l2_cache_disable(void) {}
 
-#if defined CONFIG_SYS_THUMB_BUILD
+#if CONFIG_IS_ENABLED(SYS_THUMB_BUILD)
 __weak void invalidate_l2_cache(void) {}
 #endif
diff --git a/arch/arm/cpu/armv7/cache_v7_asm.S b/arch/arm/cpu/armv7/cache_v7_asm.S
index a433628..bd27ab2 100644
--- a/arch/arm/cpu/armv7/cache_v7_asm.S
+++ b/arch/arm/cpu/armv7/cache_v7_asm.S
@@ -7,7 +7,7 @@
 #include <linux/sizes.h>
 #include <asm/system.h>
 
-#ifdef CONFIG_SYS_THUMB_BUILD
+#if CONFIG_IS_ENABLED(SYS_THUMB_BUILD)
 #define ARM(x...)
 #define THUMB(x...)	x
 #else
diff --git a/arch/arm/cpu/pxa/cache.c b/arch/arm/cpu/pxa/cache.c
index d26354e..30e1e34 100644
--- a/arch/arm/cpu/pxa/cache.c
+++ b/arch/arm/cpu/pxa/cache.c
@@ -52,6 +52,6 @@
 
 __weak void l2_cache_disable(void) {}
 
-#if defined CONFIG_SYS_THUMB_BUILD
+#if CONFIG_IS_ENABLED(SYS_THUMB_BUILD)
 __weak void invalidate_l2_cache(void) {}
 #endif
diff --git a/arch/arm/include/asm/assembler.h b/arch/arm/include/asm/assembler.h
index d24be2d..b146918 100644
--- a/arch/arm/include/asm/assembler.h
+++ b/arch/arm/include/asm/assembler.h
@@ -77,7 +77,7 @@
  * We disable it especially for Thumb builds since those instructions
  * are not made in a Thumb ready way...
  */
-#ifdef CONFIG_SYS_THUMB_BUILD
+#if CONFIG_IS_ENABLED(SYS_THUMB_BUILD)
 #define CALGN(code...)
 #else
 #define CALGN(code...) code
diff --git a/arch/arm/include/asm/cache.h b/arch/arm/include/asm/cache.h
index 5400cbe..fac65d8 100644
--- a/arch/arm/include/asm/cache.h
+++ b/arch/arm/include/asm/cache.h
@@ -16,7 +16,7 @@
 /*
  * Invalidate L2 Cache using co-proc instruction
  */
-#ifdef CONFIG_SYS_THUMB_BUILD
+#if CONFIG_IS_ENABLED(SYS_THUMB_BUILD)
 void invalidate_l2_cache(void);
 #else
 static inline void invalidate_l2_cache(void)
diff --git a/arch/arm/include/asm/setjmp.h b/arch/arm/include/asm/setjmp.h
index df9934b..c3399a7 100644
--- a/arch/arm/include/asm/setjmp.h
+++ b/arch/arm/include/asm/setjmp.h
@@ -39,7 +39,7 @@
 		  "x30", "cc", "memory");
 #else
 	asm volatile(
-#ifdef CONFIG_SYS_THUMB_BUILD
+#if CONFIG_IS_ENABLED(SYS_THUMB_BUILD)
 		".align 2\n"
 		"adr r0, jmp_target\n"
 		"add r0, r0, $1\n"
diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile
index 166fa9e..b95e105 100644
--- a/arch/arm/lib/Makefile
+++ b/arch/arm/lib/Makefile
@@ -71,7 +71,7 @@
 
 # some files can only build in ARM or THUMB2, not THUMB1
 
-ifdef CONFIG_SYS_THUMB_BUILD
+ifdef CONFIG_$(SPL_)SYS_THUMB_BUILD
 asflags-$(CONFIG_HAS_THUMB2) += -DCONFIG_THUMB2_KERNEL
 ifndef CONFIG_HAS_THUMB2
 
diff --git a/arch/arm/lib/cache.c b/arch/arm/lib/cache.c
index 4f72f89..7683386 100644
--- a/arch/arm/lib/cache.c
+++ b/arch/arm/lib/cache.c
@@ -107,7 +107,7 @@
 }
 #endif /* CONFIG_SYS_NONCACHED_MEMORY */
 
-#if defined(CONFIG_SYS_THUMB_BUILD)
+#if CONFIG_IS_ENABLED(SYS_THUMB_BUILD)
 void invalidate_l2_cache(void)
 {
 	unsigned int val = 0;
diff --git a/arch/arm/lib/crt0.S b/arch/arm/lib/crt0.S
index 2c4867a..fa81317 100644
--- a/arch/arm/lib/crt0.S
+++ b/arch/arm/lib/crt0.S
@@ -156,7 +156,7 @@
 	mov     r0, r9                  /* gd_t */
 	ldr	r1, [r9, #GD_RELOCADDR]	/* dest_addr */
 	/* call board_init_r */
-#if defined(CONFIG_SYS_THUMB_BUILD)
+#if CONFIG_IS_ENABLED(SYS_THUMB_BUILD)
 	ldr	lr, =board_init_r	/* this is auto-relocated! */
 	bx	lr
 #else
diff --git a/arch/arm/lib/lib1funcs.S b/arch/arm/lib/lib1funcs.S
index 76968ce..6e29cbf 100644
--- a/arch/arm/lib/lib1funcs.S
+++ b/arch/arm/lib/lib1funcs.S
@@ -368,7 +368,7 @@
 .popsection
 
 /* Thumb-1 specialities */
-#if defined(CONFIG_SYS_THUMB_BUILD) && !defined(CONFIG_HAS_THUMB2)
+#if CONFIG_IS_ENABLED(SYS_THUMB_BUILD) && !defined(CONFIG_HAS_THUMB2)
 .pushsection .text.__gnu_thumb1_case_sqi, "ax"
 ENTRY(__gnu_thumb1_case_sqi)
 	push	{r1}
diff --git a/arch/arm/lib/memcpy.S b/arch/arm/lib/memcpy.S
index 00602e9..588b3f8 100644
--- a/arch/arm/lib/memcpy.S
+++ b/arch/arm/lib/memcpy.S
@@ -56,7 +56,7 @@
 
 /* Prototype: void *memcpy(void *dest, const void *src, size_t n); */
 	.syntax unified
-#if defined(CONFIG_SYS_THUMB_BUILD) && !defined(MEMCPY_NO_THUMB_BUILD)
+#if CONFIG_IS_ENABLED(SYS_THUMB_BUILD) && !defined(MEMCPY_NO_THUMB_BUILD)
 	.thumb
 	.thumb_func
 #endif
diff --git a/arch/arm/lib/memset.S b/arch/arm/lib/memset.S
index df053a3..cc4cc44 100644
--- a/arch/arm/lib/memset.S
+++ b/arch/arm/lib/memset.S
@@ -16,7 +16,7 @@
 	.align	5
 
 	.syntax unified
-#if defined(CONFIG_SYS_THUMB_BUILD) && !defined(MEMSET_NO_THUMB_BUILD)
+#if CONFIG_IS_ENABLED(SYS_THUMB_BUILD) && !defined(MEMSET_NO_THUMB_BUILD)
 	.thumb
 	.thumb_func
 #endif
diff --git a/arch/arm/mach-at91/arm926ejs/Makefile b/arch/arm/mach-at91/arm926ejs/Makefile
index d36e15a..624ccd7 100644
--- a/arch/arm/mach-at91/arm926ejs/Makefile
+++ b/arch/arm/mach-at91/arm926ejs/Makefile
@@ -27,3 +27,11 @@
 ifndef CONFIG_SKIP_LOWLEVEL_INIT
 obj-y	+= lowlevel_init.o
 endif
+
+ifdef CONFIG_$(SPL_)SYS_THUMB_BUILD
+ifndef CONFIG_HAS_THUMB2
+
+CFLAGS_cache.o := -marm
+
+endif
+endif
diff --git a/arch/arm/mach-orion5x/Makefile b/arch/arm/mach-orion5x/Makefile
index 33dcad4..5249aa8 100644
--- a/arch/arm/mach-orion5x/Makefile
+++ b/arch/arm/mach-orion5x/Makefile
@@ -19,7 +19,7 @@
 
 # some files can only build in ARM or THUMB2, not THUMB1
 
-ifdef CONFIG_SYS_THUMB_BUILD
+ifdef CONFIG_$(SPL_)SYS_THUMB_BUILD
 ifndef CONFIG_HAS_THUMB2
 
 CFLAGS_cpu.o := -marm
diff --git a/configs/am335x_evm_norboot_defconfig b/configs/am335x_evm_norboot_defconfig
index f82ca16..cb61842 100644
--- a/configs/am335x_evm_norboot_defconfig
+++ b/configs/am335x_evm_norboot_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+# CONFIG_SYS_THUMB_BUILD is not set
 CONFIG_AM33XX=y
 CONFIG_TARGET_AM335X_EVM=y
 CONFIG_NOR=y
diff --git a/configs/am3517_crane_defconfig b/configs/am3517_crane_defconfig
index 99c95c4..91cf89a 100644
--- a/configs/am3517_crane_defconfig
+++ b/configs/am3517_crane_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+# CONFIG_SYS_THUMB_BUILD is not set
 CONFIG_OMAP34XX=y
 # CONFIG_SPL_GPIO_SUPPORT is not set
 CONFIG_TARGET_AM3517_CRANE=y
diff --git a/configs/am3517_evm_defconfig b/configs/am3517_evm_defconfig
index 8d20981..1f2cd07 100644
--- a/configs/am3517_evm_defconfig
+++ b/configs/am3517_evm_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+# CONFIG_SYS_THUMB_BUILD is not set
 CONFIG_OMAP34XX=y
 # CONFIG_SPL_GPIO_SUPPORT is not set
 CONFIG_TARGET_AM3517_EVM=y
diff --git a/configs/am43xx_evm_qspiboot_defconfig b/configs/am43xx_evm_qspiboot_defconfig
index a9c8726..83546ed 100644
--- a/configs/am43xx_evm_qspiboot_defconfig
+++ b/configs/am43xx_evm_qspiboot_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+# CONFIG_SYS_THUMB_BUILD is not set
 CONFIG_AM43XX=y
 CONFIG_TARGET_AM43XX_EVM=y
 CONFIG_ISW_ENTRY_ADDR=0x30000000
diff --git a/configs/apalis_imx6_nospl_com_defconfig b/configs/apalis_imx6_nospl_com_defconfig
index 457d527..b0e0995 100644
--- a/configs/apalis_imx6_nospl_com_defconfig
+++ b/configs/apalis_imx6_nospl_com_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_SYS_THUMB_BUILD=y
 CONFIG_ARCH_MX6=y
 CONFIG_TARGET_APALIS_IMX6=y
 CONFIG_VIDEO=y
diff --git a/configs/apalis_imx6_nospl_it_defconfig b/configs/apalis_imx6_nospl_it_defconfig
index bdd4a67..231639e 100644
--- a/configs/apalis_imx6_nospl_it_defconfig
+++ b/configs/apalis_imx6_nospl_it_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_SYS_THUMB_BUILD=y
 CONFIG_ARCH_MX6=y
 CONFIG_TARGET_APALIS_IMX6=y
 CONFIG_VIDEO=y
diff --git a/configs/armadillo-800eva_defconfig b/configs/armadillo-800eva_defconfig
index b850efe..4c16ec1 100644
--- a/configs/armadillo-800eva_defconfig
+++ b/configs/armadillo-800eva_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+# CONFIG_SYS_THUMB_BUILD is not set
 CONFIG_ARCH_RMOBILE=y
 CONFIG_TARGET_ARMADILLO_800EVA=y
 CONFIG_BOOTDELAY=3
diff --git a/configs/axm_defconfig b/configs/axm_defconfig
index 8347f6a..14ec8a1 100644
--- a/configs/axm_defconfig
+++ b/configs/axm_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_SPL_SYS_THUMB_BUILD=y
 # CONFIG_SPL_USE_ARCH_MEMCPY is not set
 # CONFIG_SPL_USE_ARCH_MEMSET is not set
 CONFIG_ARCH_AT91=y
diff --git a/configs/bk4r1_defconfig b/configs/bk4r1_defconfig
index 964cfed..1dff0d4 100644
--- a/configs/bk4r1_defconfig
+++ b/configs/bk4r1_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_SYS_THUMB_BUILD=y
 CONFIG_TARGET_BK4R1=y
 CONFIG_DEFAULT_DEVICE_TREE="bk4r1"
 CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=board/phytec/pcm052/imximage.cfg,ENV_IS_IN_NAND"
diff --git a/configs/cm_t3517_defconfig b/configs/cm_t3517_defconfig
index 1997e56..0357b91 100644
--- a/configs/cm_t3517_defconfig
+++ b/configs/cm_t3517_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+# CONFIG_SYS_THUMB_BUILD is not set
 CONFIG_OMAP34XX=y
 CONFIG_TARGET_CM_T3517=y
 CONFIG_BOOTDELAY=3
diff --git a/configs/cm_t35_defconfig b/configs/cm_t35_defconfig
index 1983ac7..6c12b28 100644
--- a/configs/cm_t35_defconfig
+++ b/configs/cm_t35_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+# CONFIG_SYS_THUMB_BUILD is not set
 CONFIG_OMAP34XX=y
 CONFIG_TARGET_CM_T35=y
 CONFIG_BOOTDELAY=3
diff --git a/configs/cm_t43_defconfig b/configs/cm_t43_defconfig
index e817f28..7095c6d 100644
--- a/configs/cm_t43_defconfig
+++ b/configs/cm_t43_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_SYS_THUMB_BUILD=y
 CONFIG_TARGET_CM_T43=y
 CONFIG_SPL_LIBCOMMON_SUPPORT=y
 CONFIG_SPL_LIBGENERIC_SUPPORT=y
diff --git a/configs/colibri_imx6_nospl_defconfig b/configs/colibri_imx6_nospl_defconfig
index c75f7d4..7a82b48 100644
--- a/configs/colibri_imx6_nospl_defconfig
+++ b/configs/colibri_imx6_nospl_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_SYS_THUMB_BUILD=y
 CONFIG_ARCH_MX6=y
 CONFIG_TARGET_COLIBRI_IMX6=y
 CONFIG_VIDEO=y
diff --git a/configs/colibri_imx7_defconfig b/configs/colibri_imx7_defconfig
index 341c99d..5c051d5 100644
--- a/configs/colibri_imx7_defconfig
+++ b/configs/colibri_imx7_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_SYS_THUMB_BUILD=y
 CONFIG_ARCH_MX7=y
 CONFIG_TARGET_COLIBRI_IMX7=y
 CONFIG_IMX_RDC=y
diff --git a/configs/colibri_vf_defconfig b/configs/colibri_vf_defconfig
index 0a12e1a..6ba673d 100644
--- a/configs/colibri_vf_defconfig
+++ b/configs/colibri_vf_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_SYS_THUMB_BUILD=y
 CONFIG_TARGET_COLIBRI_VF=y
 CONFIG_DEFAULT_DEVICE_TREE="vf610-colibri"
 CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=board/toradex/colibri_vf/imximage.cfg,ENV_IS_IN_NAND,IMX_NAND"
diff --git a/configs/eco5pk_defconfig b/configs/eco5pk_defconfig
index 29ee7a2..ac37764 100644
--- a/configs/eco5pk_defconfig
+++ b/configs/eco5pk_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+# CONFIG_SYS_THUMB_BUILD is not set
 CONFIG_OMAP34XX=y
 CONFIG_TARGET_ECO5PK=y
 CONFIG_FIT=y
diff --git a/configs/highbank_defconfig b/configs/highbank_defconfig
index 20801fc..041d048 100644
--- a/configs/highbank_defconfig
+++ b/configs/highbank_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_SYS_THUMB_BUILD=y
 CONFIG_ARCH_HIGHBANK=y
 CONFIG_FIT=y
 CONFIG_OF_BOARD_SETUP=y
diff --git a/configs/kzm9g_defconfig b/configs/kzm9g_defconfig
index 29d4298..bc3e5d9 100644
--- a/configs/kzm9g_defconfig
+++ b/configs/kzm9g_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+# CONFIG_SYS_THUMB_BUILD is not set
 CONFIG_ARCH_RMOBILE=y
 CONFIG_TARGET_KZM9G=y
 CONFIG_BOOTDELAY=3
diff --git a/configs/mcx_defconfig b/configs/mcx_defconfig
index aecbfda..fa619de 100644
--- a/configs/mcx_defconfig
+++ b/configs/mcx_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+# CONFIG_SYS_THUMB_BUILD is not set
 CONFIG_OMAP34XX=y
 # CONFIG_SPL_GPIO_SUPPORT is not set
 CONFIG_TARGET_MCX=y
diff --git a/configs/mt_ventoux_defconfig b/configs/mt_ventoux_defconfig
index cfa00d4..c6aad14 100644
--- a/configs/mt_ventoux_defconfig
+++ b/configs/mt_ventoux_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+# CONFIG_SYS_THUMB_BUILD is not set
 CONFIG_OMAP34XX=y
 CONFIG_TARGET_MT_VENTOUX=y
 CONFIG_VIDEO=y
diff --git a/configs/nokia_rx51_defconfig b/configs/nokia_rx51_defconfig
index 0b8fccf..181bdb1 100644
--- a/configs/nokia_rx51_defconfig
+++ b/configs/nokia_rx51_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+# CONFIG_SYS_THUMB_BUILD is not set
 CONFIG_OMAP34XX=y
 CONFIG_TARGET_NOKIA_RX51=y
 CONFIG_VIDEO=y
diff --git a/configs/omap3_evm_defconfig b/configs/omap3_evm_defconfig
index 573ae80..915a142 100644
--- a/configs/omap3_evm_defconfig
+++ b/configs/omap3_evm_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+# CONFIG_SYS_THUMB_BUILD is not set
 CONFIG_OMAP34XX=y
 CONFIG_TARGET_OMAP3_EVM=y
 CONFIG_BOOTDELAY=3
diff --git a/configs/omap3_ha_defconfig b/configs/omap3_ha_defconfig
index 5be1139..c4ff136 100644
--- a/configs/omap3_ha_defconfig
+++ b/configs/omap3_ha_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+# CONFIG_SYS_THUMB_BUILD is not set
 CONFIG_OMAP34XX=y
 CONFIG_TARGET_TAO3530=y
 CONFIG_SYS_EXTRA_OPTIONS="SYS_BOARD_OMAP3_HA"
diff --git a/configs/openrd_base_defconfig b/configs/openrd_base_defconfig
index 067ddbc..2abf3ab 100644
--- a/configs/openrd_base_defconfig
+++ b/configs/openrd_base_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_SYS_THUMB_BUILD=y
 CONFIG_KIRKWOOD=y
 CONFIG_TARGET_OPENRD=y
 CONFIG_IDENT_STRING="\nOpenRD-Base"
diff --git a/configs/openrd_client_defconfig b/configs/openrd_client_defconfig
index b90ead1..8b3f25f 100644
--- a/configs/openrd_client_defconfig
+++ b/configs/openrd_client_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_SYS_THUMB_BUILD=y
 CONFIG_KIRKWOOD=y
 CONFIG_TARGET_OPENRD=y
 CONFIG_IDENT_STRING="\nOpenRD-Client"
diff --git a/configs/openrd_ultimate_defconfig b/configs/openrd_ultimate_defconfig
index 2bc8ace..ba77473 100644
--- a/configs/openrd_ultimate_defconfig
+++ b/configs/openrd_ultimate_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_SYS_THUMB_BUILD=y
 CONFIG_KIRKWOOD=y
 CONFIG_TARGET_OPENRD=y
 CONFIG_IDENT_STRING="\nOpenRD-Ultimate"
diff --git a/configs/pcm052_defconfig b/configs/pcm052_defconfig
index fbd7841..4f35a1c 100644
--- a/configs/pcm052_defconfig
+++ b/configs/pcm052_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_SYS_THUMB_BUILD=y
 CONFIG_TARGET_PCM052=y
 CONFIG_DEFAULT_DEVICE_TREE="pcm052"
 CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=board/phytec/pcm052/imximage.cfg,ENV_IS_IN_NAND"
diff --git a/configs/smartweb_defconfig b/configs/smartweb_defconfig
index 2e43c41..48c8781 100644
--- a/configs/smartweb_defconfig
+++ b/configs/smartweb_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_SPL_SYS_THUMB_BUILD=y
 # CONFIG_SPL_USE_ARCH_MEMCPY is not set
 # CONFIG_SPL_USE_ARCH_MEMSET is not set
 CONFIG_ARCH_AT91=y
diff --git a/configs/sniper_defconfig b/configs/sniper_defconfig
index b67ff88..ca2762a 100644
--- a/configs/sniper_defconfig
+++ b/configs/sniper_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+# CONFIG_SYS_THUMB_BUILD is not set
 CONFIG_OMAP34XX=y
 CONFIG_TARGET_SNIPER=y
 # CONFIG_SPL_NAND_SUPPORT is not set
diff --git a/configs/tao3530_defconfig b/configs/tao3530_defconfig
index 7140ae5..8f12a99 100644
--- a/configs/tao3530_defconfig
+++ b/configs/tao3530_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+# CONFIG_SYS_THUMB_BUILD is not set
 CONFIG_OMAP34XX=y
 CONFIG_TARGET_TAO3530=y
 CONFIG_BOOTDELAY=3
diff --git a/configs/taurus_defconfig b/configs/taurus_defconfig
index aa9eefa..2de9cad 100644
--- a/configs/taurus_defconfig
+++ b/configs/taurus_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_SPL_SYS_THUMB_BUILD=y
 # CONFIG_SPL_USE_ARCH_MEMCPY is not set
 # CONFIG_SPL_USE_ARCH_MEMSET is not set
 CONFIG_ARCH_AT91=y
diff --git a/configs/tbs2910_defconfig b/configs/tbs2910_defconfig
index 95a23d8..9ba1609 100644
--- a/configs/tbs2910_defconfig
+++ b/configs/tbs2910_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_SYS_THUMB_BUILD=y
 CONFIG_ARCH_MX6=y
 CONFIG_TARGET_TBS2910=y
 CONFIG_PRE_CONSOLE_BUFFER=y
diff --git a/configs/twister_defconfig b/configs/twister_defconfig
index fefd490..9928d0e 100644
--- a/configs/twister_defconfig
+++ b/configs/twister_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+# CONFIG_SYS_THUMB_BUILD is not set
 CONFIG_OMAP34XX=y
 CONFIG_TARGET_TWISTER=y
 CONFIG_FIT=y
diff --git a/configs/x600_defconfig b/configs/x600_defconfig
index 86f6fea..a72c3d4 100644
--- a/configs/x600_defconfig
+++ b/configs/x600_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_SYS_THUMB_BUILD=y
 # CONFIG_SPL_USE_ARCH_MEMCPY is not set
 # CONFIG_SPL_USE_ARCH_MEMSET is not set
 CONFIG_TARGET_X600=y
diff --git a/include/configs/apalis_imx6.h b/include/configs/apalis_imx6.h
index 9c899e4..cad0420 100644
--- a/include/configs/apalis_imx6.h
+++ b/include/configs/apalis_imx6.h
@@ -10,7 +10,6 @@
 #define __CONFIG_H
 
 #include "mx6_common.h"
-#define CONFIG_SYS_THUMB_BUILD
 
 #undef CONFIG_DISPLAY_BOARDINFO
 #define CONFIG_DISPLAY_BOARDINFO_LATE	/* Calls show_board_info() */
diff --git a/include/configs/colibri_imx6.h b/include/configs/colibri_imx6.h
index 2fbadf2..b1f6b87 100644
--- a/include/configs/colibri_imx6.h
+++ b/include/configs/colibri_imx6.h
@@ -10,7 +10,6 @@
 #define __CONFIG_H
 
 #include "mx6_common.h"
-#define CONFIG_SYS_THUMB_BUILD
 
 #undef CONFIG_DISPLAY_BOARDINFO
 #define CONFIG_DISPLAY_BOARDINFO_LATE	/* Calls show_board_info() */
diff --git a/include/configs/colibri_imx7.h b/include/configs/colibri_imx7.h
index 3da4211..4da91d3 100644
--- a/include/configs/colibri_imx7.h
+++ b/include/configs/colibri_imx7.h
@@ -14,8 +14,6 @@
 
 #include "mx7_common.h"
 
-#define CONFIG_SYS_THUMB_BUILD
-
 /*#define CONFIG_DBG_MONITOR*/
 #define PHYS_SDRAM_SIZE			SZ_512M
 
diff --git a/include/configs/colibri_vf.h b/include/configs/colibri_vf.h
index bfd5fbd..e01be9d 100644
--- a/include/configs/colibri_vf.h
+++ b/include/configs/colibri_vf.h
@@ -15,7 +15,6 @@
 #include <asm/arch/imx-regs.h>
 
 #define CONFIG_VF610
-#define CONFIG_SYS_THUMB_BUILD
 #define CONFIG_SYS_FSL_CLK
 
 #define CONFIG_DISPLAY_BOARDINFO_LATE	/* Calls show_board_info() */
diff --git a/include/configs/highbank.h b/include/configs/highbank.h
index b47624a..6793732 100644
--- a/include/configs/highbank.h
+++ b/include/configs/highbank.h
@@ -10,7 +10,6 @@
 #include <config_distro_defaults.h>
 
 #define CONFIG_SYS_DCACHE_OFF
-#define CONFIG_SYS_THUMB_BUILD
 
 #define CONFIG_SYS_BOOTMAPSZ		(16 << 20)
 
diff --git a/include/configs/imx6_spl.h b/include/configs/imx6_spl.h
index 3a389ed..4598d27 100644
--- a/include/configs/imx6_spl.h
+++ b/include/configs/imx6_spl.h
@@ -24,7 +24,6 @@
  *    and some padding thus 'our' max size is really 0x00908000 - 0x00918000
  *    or 64KB
  */
-#define CONFIG_SYS_THUMB_BUILD
 #define CONFIG_SPL_LDSCRIPT	"arch/arm/mach-omap2/u-boot-spl.lds"
 #define CONFIG_SPL_TEXT_BASE		0x00908000
 #define CONFIG_SPL_MAX_SIZE		0x10000
diff --git a/include/configs/kc1.h b/include/configs/kc1.h
index cc78a09..dd18329 100644
--- a/include/configs/kc1.h
+++ b/include/configs/kc1.h
@@ -16,8 +16,6 @@
  * Build
  */
 
-#define CONFIG_SYS_THUMB_BUILD
-
 /*
  * CPU
  */
diff --git a/include/configs/openrd.h b/include/configs/openrd.h
index 14cf3b4..19660db 100644
--- a/include/configs/openrd.h
+++ b/include/configs/openrd.h
@@ -21,7 +21,6 @@
 #define CONFIG_KW88F6281	1	/* SOC Name */
 #define CONFIG_MACH_OPENRD_BASE	/* Machine type */
 #define CONFIG_SKIP_LOWLEVEL_INIT	/* disable board lowlevel_init */
-#define CONFIG_SYS_THUMB_BUILD
 
 /*
  * Commands configuration
diff --git a/include/configs/pcm052.h b/include/configs/pcm052.h
index 4909049..2cbd8fe 100644
--- a/include/configs/pcm052.h
+++ b/include/configs/pcm052.h
@@ -13,8 +13,6 @@
 
 #define CONFIG_VF610
 
-#define CONFIG_SYS_THUMB_BUILD
-
 #define CONFIG_SKIP_LOWLEVEL_INIT
 
 /* Enable passing of ATAGs */
diff --git a/include/configs/rcar-gen2-common.h b/include/configs/rcar-gen2-common.h
index 39c40d3..286b5d6 100644
--- a/include/configs/rcar-gen2-common.h
+++ b/include/configs/rcar-gen2-common.h
@@ -14,8 +14,6 @@
 #define CONFIG_CMD_DFL
 #define CONFIG_CMD_SDRAM
 
-#define CONFIG_SYS_THUMB_BUILD
-
 /* Support File sytems */
 #define CONFIG_FAT_WRITE
 #define CONFIG_SUPPORT_VFAT
diff --git a/include/configs/rk3036_common.h b/include/configs/rk3036_common.h
index 318a52c..f07f237 100644
--- a/include/configs/rk3036_common.h
+++ b/include/configs/rk3036_common.h
@@ -17,7 +17,6 @@
 #define CONFIG_SYS_MALLOC_LEN		(32 << 20)
 #define CONFIG_SYS_CBSIZE		1024
 #define CONFIG_SKIP_LOWLEVEL_INIT
-#define CONFIG_SYS_THUMB_BUILD
 
 #define CONFIG_SYS_TIMER_RATE		(24 * 1000 * 1000)
 #define CONFIG_SYS_TIMER_BASE		0x200440a0 /* TIMER5 */
diff --git a/include/configs/rk3288_common.h b/include/configs/rk3288_common.h
index b5606d4..a08c852 100644
--- a/include/configs/rk3288_common.h
+++ b/include/configs/rk3288_common.h
@@ -17,7 +17,6 @@
 #define CONFIG_BAUDRATE			115200
 #define CONFIG_SYS_MALLOC_LEN		(32 << 20)
 #define CONFIG_SYS_CBSIZE		1024
-#define CONFIG_SYS_THUMB_BUILD
 
 #define CONFIG_SYS_TIMER_RATE		(24 * 1000 * 1000)
 #define	CONFIG_SYS_TIMER_BASE		0xff810020 /* TIMER7 */
diff --git a/include/configs/smartweb.h b/include/configs/smartweb.h
index f53f5d8..46ace67 100644
--- a/include/configs/smartweb.h
+++ b/include/configs/smartweb.h
@@ -270,7 +270,6 @@
 #define CONFIG_SYS_AT91_PLLB		0x10483f0e
 
 #if defined(CONFIG_SPL_BUILD)
-#define CONFIG_SYS_THUMB_BUILD
 #define CONFIG_SYS_ICACHE_OFF
 #define CONFIG_SYS_DCACHE_OFF
 #endif
diff --git a/include/configs/socfpga_common.h b/include/configs/socfpga_common.h
index 582b04a..2f1d817 100644
--- a/include/configs/socfpga_common.h
+++ b/include/configs/socfpga_common.h
@@ -9,8 +9,6 @@
 /* Virtual target or real hardware */
 #undef CONFIG_SOCFPGA_VIRTUAL_TARGET
 
-#define CONFIG_SYS_THUMB_BUILD
-
 /*
  * High level configuration
  */
diff --git a/include/configs/stm32f429-discovery.h b/include/configs/stm32f429-discovery.h
index 69135ff..42d46b0 100644
--- a/include/configs/stm32f429-discovery.h
+++ b/include/configs/stm32f429-discovery.h
@@ -8,7 +8,6 @@
 #ifndef __CONFIG_H
 #define __CONFIG_H
 
-#define CONFIG_SYS_THUMB_BUILD
 #define CONFIG_STM32F4DISCOVERY
 
 #define CONFIG_MISC_INIT_R
diff --git a/include/configs/stm32f746-disco.h b/include/configs/stm32f746-disco.h
index ae3211ab..734dc00 100644
--- a/include/configs/stm32f746-disco.h
+++ b/include/configs/stm32f746-disco.h
@@ -8,8 +8,6 @@
 #ifndef __CONFIG_H
 #define __CONFIG_H
 
-#define CONFIG_SYS_THUMB_BUILD
-
 #define CONFIG_SYS_FLASH_BASE		0x08000000
 #define CONFIG_SYS_INIT_SP_ADDR		0x20050000
 #define CONFIG_SYS_TEXT_BASE		0x08000000
diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h
index d48bdac..e5a514f 100644
--- a/include/configs/sunxi-common.h
+++ b/include/configs/sunxi-common.h
@@ -32,13 +32,6 @@
 # define CONFIG_MACH_TYPE_COMPAT_REV	1
 #endif
 
-/*
- * High Level Configuration Options
- */
-#if defined(CONFIG_SPL_BUILD) && !defined(CONFIG_ARM64)
-#define CONFIG_SYS_THUMB_BUILD	/* Thumbs mode to save space in SPL */
-#endif
-
 /* Serial & console */
 #define CONFIG_SYS_NS16550_SERIAL
 /* ns16550 reg in the low bits of cpu reg */
diff --git a/include/configs/taurus.h b/include/configs/taurus.h
index ba7346c..b452ea9 100644
--- a/include/configs/taurus.h
+++ b/include/configs/taurus.h
@@ -23,7 +23,6 @@
 #include <linux/sizes.h>
 
 #if defined(CONFIG_SPL_BUILD)
-#define CONFIG_SYS_THUMB_BUILD
 #define CONFIG_SYS_ICACHE_OFF
 #define CONFIG_SYS_DCACHE_OFF
 #endif
diff --git a/include/configs/tbs2910.h b/include/configs/tbs2910.h
index 09a7942..f69df33 100644
--- a/include/configs/tbs2910.h
+++ b/include/configs/tbs2910.h
@@ -12,7 +12,6 @@
 #include "mx6_common.h"
 
 /* General configuration */
-#define CONFIG_SYS_THUMB_BUILD
 
 #define CONFIG_MACH_TYPE		3980
 
diff --git a/include/configs/ti_armv7_common.h b/include/configs/ti_armv7_common.h
index fbe8859..ca7d6a3 100644
--- a/include/configs/ti_armv7_common.h
+++ b/include/configs/ti_armv7_common.h
@@ -278,8 +278,6 @@
 #define CONFIG_CMD_SPL
 #endif
 
-#define CONFIG_SYS_THUMB_BUILD
-
 /* General parts of the framework, required. */
 #define CONFIG_SPL_BOARD_INIT
 
diff --git a/include/configs/ti_omap4_common.h b/include/configs/ti_omap4_common.h
index 8e0f9eb..d07cb9f 100644
--- a/include/configs/ti_omap4_common.h
+++ b/include/configs/ti_omap4_common.h
@@ -18,8 +18,6 @@
 #define CONFIG_OMAP4430		1	/* which is in a 4430 */
 #define CONFIG_MISC_INIT_R
 
-#define CONFIG_SYS_THUMB_BUILD
-
 #ifndef CONFIG_SYS_L2CACHE_OFF
 #define CONFIG_SYS_L2_PL310		1
 #define CONFIG_SYS_PL310_BASE	0x48242000
diff --git a/include/configs/tricorder.h b/include/configs/tricorder.h
index 2b80352..2448dd7 100644
--- a/include/configs/tricorder.h
+++ b/include/configs/tricorder.h
@@ -17,7 +17,6 @@
 #define __CONFIG_H
 
 /* High Level Configuration Options */
-#define CONFIG_SYS_THUMB_BUILD
 #define CONFIG_OMAP			/* in a TI OMAP core */
 
 #define CONFIG_MACH_TYPE		MACH_TYPE_TRICORDER
diff --git a/include/configs/x600.h b/include/configs/x600.h
index 67c70f6..082ce1f 100644
--- a/include/configs/x600.h
+++ b/include/configs/x600.h
@@ -16,7 +16,6 @@
  */
 #define CONFIG_SPEAR600				/* SPEAr600 SoC */
 #define CONFIG_X600				/* on X600 board */
-#define CONFIG_SYS_THUMB_BUILD
 
 #include <asm/arch/hardware.h>