diff mbox series

[U-Boot,3/3] Kconfig: move CONFIG_STANDALONE_LOAD_ADDR to Kconfig

Message ID 20180923200209.12233-4-daniel.schwierzeck@gmail.com
State Deferred
Delegated to: Tom Rini
Headers show
Series Kconfig: move CONFIG_STANDALONE_LOAD_ADDR to Kconfig | expand

Commit Message

Daniel Schwierzeck Sept. 23, 2018, 8:02 p.m. UTC
Create a new Kconfig menu called 'Standalone programs' with
'Program load address' as menu entry. It's possible now to build without
the standalone example. Anyway the default value for CONFIG_STANDALONE
is 'y' to maintain the current behavior.

Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

---

 Kconfig                                          |  2 ++
 README                                           |  8 --------
 arch/arc/Kconfig                                 |  3 +++
 arch/arc/config.mk                               |  3 ---
 arch/arm/Kconfig                                 |  7 +++++++
 arch/arm/config.mk                               |  8 --------
 .../arm/include/asm/arch-fsl-layerscape/config.h |  2 --
 arch/m68k/Kconfig                                |  3 +++
 arch/m68k/config.mk                              |  2 --
 arch/microblaze/Kconfig                          |  3 +++
 arch/microblaze/config.mk                        |  2 --
 arch/mips/Kconfig                                |  4 ++++
 arch/mips/config.mk                              |  2 --
 arch/nds32/Kconfig                               |  3 +++
 arch/nds32/config.mk                             |  1 -
 arch/nios2/Kconfig                               |  3 +++
 arch/nios2/config.mk                             |  2 --
 arch/powerpc/Kconfig                             |  3 +++
 arch/powerpc/config.mk                           |  1 -
 arch/riscv/Kconfig                               |  3 +++
 arch/riscv/config.mk                             |  1 -
 arch/sandbox/Kconfig                             |  3 +++
 arch/sh/Kconfig                                  |  3 +++
 arch/sh/config.mk                                |  1 -
 arch/x86/Kconfig                                 |  3 +++
 arch/x86/config.mk                               |  2 --
 arch/xtensa/Kconfig                              |  3 +++
 config.mk                                        |  1 -
 configs/display5_defconfig                       |  1 +
 configs/display5_factory_defconfig               |  1 +
 configs/kzm9g_defconfig                          |  1 +
 configs/opos6uldev_defconfig                     |  1 +
 examples/Makefile                                |  2 +-
 examples/standalone/Kconfig                      | 14 ++++++++++++++
 include/configs/display5.h                       |  1 -
 include/configs/kzm9g.h                          |  2 --
 include/configs/opos6uldev.h                     |  3 ---
 include/configs/sunxi-common.h                   |  7 -------
 include/configs/xtfpga.h                         | 16 ----------------
 scripts/config_whitelist.txt                     |  1 -
 40 files changed, 65 insertions(+), 67 deletions(-)
 create mode 100644 examples/standalone/Kconfig

Comments

Max Filippov Sept. 24, 2018, 5:55 p.m. UTC | #1
On Sun, Sep 23, 2018 at 1:02 PM, Daniel Schwierzeck
<daniel.schwierzeck@gmail.com> wrote:
> Create a new Kconfig menu called 'Standalone programs' with
> 'Program load address' as menu entry. It's possible now to build without
> the standalone example. Anyway the default value for CONFIG_STANDALONE
> is 'y' to maintain the current behavior.
>
> Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

[...]

> diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig
> index 2ba7132c20..e228f15660 100644
> --- a/arch/xtensa/Kconfig
> +++ b/arch/xtensa/Kconfig
> @@ -8,6 +8,9 @@ config SYS_ARCH
>  config SYS_CPU
>         string "Xtensa Core Variant"
>
> +config STANDALONE_LOAD_ADDR
> +       default 0x00800000
> +

This doesn't preserve current address assignment for xtensa
XTFPGA boards:

> --- a/include/configs/xtfpga.h
> +++ b/include/configs/xtfpga.h
> @@ -74,22 +74,6 @@
>  #define CONFIG_SYS_MEMTEST_START       MEMADDR(0x01000000)
>  #define CONFIG_SYS_MEMTEST_END         MEMADDR(0x02000000)
>
> -/* Load address for stand-alone applications.
> - * MEMADDR cannot be used here, because the definition needs to be
> - * a plain number as it's used as -Ttext argument for ld in standalone
> - * example makefile.
> - * Handle noMMU vs MMUv2 vs MMUv3 distinction here manually.
> - */
> -#if XCHAL_HAVE_PTP_MMU
> -#if XCHAL_VECBASE_RESET_VADDR == XCHAL_VECBASE_RESET_PADDR
> -#define CONFIG_STANDALONE_LOAD_ADDR    0x00800000
> -#else
> -#define CONFIG_STANDALONE_LOAD_ADDR    0xd0800000
> -#endif
> -#else
> -#define CONFIG_STANDALONE_LOAD_ADDR    0x60800000
> -#endif

OTOH I don't see any way to express this in Kconfig.
Daniel Schwierzeck Sept. 24, 2018, 7:40 p.m. UTC | #2
On 24.09.2018 19:55, Max Filippov wrote:
> On Sun, Sep 23, 2018 at 1:02 PM, Daniel Schwierzeck
> <daniel.schwierzeck@gmail.com> wrote:
>> Create a new Kconfig menu called 'Standalone programs' with
>> 'Program load address' as menu entry. It's possible now to build without
>> the standalone example. Anyway the default value for CONFIG_STANDALONE
>> is 'y' to maintain the current behavior.
>>
>> Signed-off-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
> 
> [...]
> 
>> diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig
>> index 2ba7132c20..e228f15660 100644
>> --- a/arch/xtensa/Kconfig
>> +++ b/arch/xtensa/Kconfig
>> @@ -8,6 +8,9 @@ config SYS_ARCH
>>  config SYS_CPU
>>         string "Xtensa Core Variant"
>>
>> +config STANDALONE_LOAD_ADDR
>> +       default 0x00800000
>> +
> 
> This doesn't preserve current address assignment for xtensa
> XTFPGA boards:
> 
>> --- a/include/configs/xtfpga.h
>> +++ b/include/configs/xtfpga.h
>> @@ -74,22 +74,6 @@
>>  #define CONFIG_SYS_MEMTEST_START       MEMADDR(0x01000000)
>>  #define CONFIG_SYS_MEMTEST_END         MEMADDR(0x02000000)
>>
>> -/* Load address for stand-alone applications.
>> - * MEMADDR cannot be used here, because the definition needs to be
>> - * a plain number as it's used as -Ttext argument for ld in standalone
>> - * example makefile.
>> - * Handle noMMU vs MMUv2 vs MMUv3 distinction here manually.
>> - */
>> -#if XCHAL_HAVE_PTP_MMU
>> -#if XCHAL_VECBASE_RESET_VADDR == XCHAL_VECBASE_RESET_PADDR
>> -#define CONFIG_STANDALONE_LOAD_ADDR    0x00800000
>> -#else
>> -#define CONFIG_STANDALONE_LOAD_ADDR    0xd0800000
>> -#endif
>> -#else
>> -#define CONFIG_STANDALONE_LOAD_ADDR    0x60800000
>> -#endif
> 
> OTOH I don't see any way to express this in Kconfig.
> 

I see you set the SYS_CPU string manually. I think this is error-prone
and not user-friendly. I suggest to convert this to Kconfig symbols like
this:

config SYS_CPU
	default "dc232b" if CPU_DC232B
	default "dc233c" if CPU_DC233C
	default "de212" if CPU_DE212

choice
	prompt "Xtensa Core Variant"
	default CPU_DC233C

config CPU_DC232B
	bool "dc232b"

config CPU_DC233C
	bool "dc233c"

config CPU_DE212
	bool "de212"

endchoice

Then the user can only choose between the three supported cores and
SYS_CPU will be automatically updated. The default value for
STANDALONE_LOAD_ADDR could be set like this:

config STANDALONE_LOAD_ADDR
	default 0xd0800000 if CPU_DC232B
	default 0x00800000 if CPU_DC233C
	default 0x60800000 if CPU_DE212

Alternatively you model the MMU configuration also as Kconfig symbol
which can be selected by those CPU_* symbols. Then you set the default
value of STANDALONE_LOAD_ADDR dependent on that MMU setting. What do you
think?
Max Filippov Sept. 26, 2018, 7:35 p.m. UTC | #3
Hi Daniel,

On Mon, Sep 24, 2018 at 12:40 PM, Daniel Schwierzeck
<daniel.schwierzeck@gmail.com> wrote:
> I see you set the SYS_CPU string manually. I think this is error-prone
> and not user-friendly. I suggest to convert this to Kconfig symbols like
> this:
>
> config SYS_CPU
>         default "dc232b" if CPU_DC232B
>         default "dc233c" if CPU_DC233C
>         default "de212" if CPU_DE212
>
> choice
>         prompt "Xtensa Core Variant"
>         default CPU_DC233C
>
> config CPU_DC232B
>         bool "dc232b"
>
> config CPU_DC233C
>         bool "dc233c"
>
> config CPU_DE212
>         bool "de212"
>
> endchoice

These cpus are just a few examples included into the u-boot that cover
three major xtensa MMU types. There's no fixed list of xtensa CPUs and
users are expected to add CPUs that they configure themselves.

> Then the user can only choose between the three supported cores and
> SYS_CPU will be automatically updated. The default value for
> STANDALONE_LOAD_ADDR could be set like this:
>/fac/proj_software/filippov/git/homewood/logs/log.DC_212GP.7441
> config STANDALONE_LOAD_ADDR
>         default 0xd0800000 if CPU_DC232B
>         default 0x00800000 if CPU_DC233C
>         default 0x60800000 if CPU_DE212
>
> Alternatively you model the MMU configuration also as Kconfig symbol
> which can be selected by those CPU_* symbols. Then you set the default
> value of STANDALONE_LOAD_ADDR dependent on that MMU setting.
> What do you think?

That is possible, but is also not user-friendly: the headers that describe
CPU are generated by the xtensa CPU build process and currently the
user just copies them into arch/xtensa/include/asm and selects correct
CPU name. Remaining information is extracted from these headers.

If the user is asked to select CPU MMU type in Kconfig that's a space
for an error. We can add a check that MMU type configured in Kconfig
matches selected CPU type.

Or we could generate Kconfig snippet for each CPU and make Kconfig
include it. Let me look at it closer.
diff mbox series

Patch

diff --git a/Kconfig b/Kconfig
index 1aadf5dd2d..06f1396dc9 100644
--- a/Kconfig
+++ b/Kconfig
@@ -491,6 +491,8 @@  source "dts/Kconfig"
 
 source "env/Kconfig"
 
+source "examples/standalone/Kconfig"
+
 source "net/Kconfig"
 
 source "drivers/Kconfig"
diff --git a/README b/README
index f7ed7eaae1..f9d2bc2162 100644
--- a/README
+++ b/README
@@ -2377,14 +2377,6 @@  FIT uImage format:
  -150	common/cmd_nand.c	Incorrect FIT image format
   151	common/cmd_nand.c	FIT image format OK
 
-- Standalone program support:
-		CONFIG_STANDALONE_LOAD_ADDR
-
-		This option defines a board specific value for the
-		address where standalone program gets loaded, thus
-		overwriting the architecture dependent default
-		settings.
-
 - Frame Buffer Address:
 		CONFIG_FB_ADDR
 
diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig
index d59aa3ae29..2d2de6f2b6 100644
--- a/arch/arc/Kconfig
+++ b/arch/arc/Kconfig
@@ -8,6 +8,9 @@  config SYS_CPU
 	default "arcv1" if ISA_ARCOMPACT
 	default "arcv2" if ISA_ARCV2
 
+config STANDALONE_LOAD_ADDR
+	default 0x82000000
+
 choice
 	prompt "ARC Instruction Set"
 	default ISA_ARCOMPACT
diff --git a/arch/arc/config.mk b/arch/arc/config.mk
index 169e5d7fae..1d550fc74a 100644
--- a/arch/arc/config.mk
+++ b/arch/arc/config.mk
@@ -53,6 +53,3 @@  PLATFORM_RELFLAGS += -ffunction-sections -fdata-sections
 
 # Needed for relocation
 LDFLAGS_FINAL += -pie --gc-sections
-
-# Load address for standalone apps
-CONFIG_STANDALONE_LOAD_ADDR ?= 0x82000000
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 0f8dd32bdd..d73c7cef3b 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -4,6 +4,13 @@  menu "ARM architecture"
 config SYS_ARCH
 	default "arm"
 
+config STANDALONE_LOAD_ADDR
+	default 0x80300000 if ARCH_OMAP2PLUS
+	default 0x80300000 if FSL_LAYERSCAPE
+	default 0x22000000 if MACH_SUN9I
+	default 0x42000000 if ARCH_SUNXI
+	default 0xc100000
+
 config ARM64
 	bool
 	select PHYS_64BIT
diff --git a/arch/arm/config.mk b/arch/arm/config.mk
index f25603109e..c7bb5a1311 100644
--- a/arch/arm/config.mk
+++ b/arch/arm/config.mk
@@ -3,14 +3,6 @@ 
 # (C) Copyright 2000-2002
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 
-ifndef CONFIG_STANDALONE_LOAD_ADDR
-ifneq ($(CONFIG_ARCH_OMAP2PLUS),)
-CONFIG_STANDALONE_LOAD_ADDR = 0x80300000
-else
-CONFIG_STANDALONE_LOAD_ADDR = 0xc100000
-endif
-endif
-
 CFLAGS_NON_EFI := -fno-pic -ffixed-r9 -ffunction-sections -fdata-sections
 CFLAGS_EFI := -fpic -fshort-wchar
 
diff --git a/arch/arm/include/asm/arch-fsl-layerscape/config.h b/arch/arm/include/asm/arch-fsl-layerscape/config.h
index 8a05148136..9b6308866b 100644
--- a/arch/arm/include/asm/arch-fsl-layerscape/config.h
+++ b/arch/arm/include/asm/arch-fsl-layerscape/config.h
@@ -9,8 +9,6 @@ 
 #include <linux/kconfig.h>
 #include <fsl_ddrc_version.h>
 
-#define CONFIG_STANDALONE_LOAD_ADDR	0x80300000
-
 /*
  * Reserve secure memory
  * To be aligned with MMU block size
diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig
index 1f6df5c870..ff35f5019a 100644
--- a/arch/m68k/Kconfig
+++ b/arch/m68k/Kconfig
@@ -4,6 +4,9 @@  menu "M68000 architecture"
 config SYS_ARCH
 	default "m68k"
 
+config STANDALONE_LOAD_ADDR
+	default 0x20000
+
 # processor family
 config MCF520x
 	bool
diff --git a/arch/m68k/config.mk b/arch/m68k/config.mk
index a27a5245fe..f095001ecc 100644
--- a/arch/m68k/config.mk
+++ b/arch/m68k/config.mk
@@ -7,8 +7,6 @@  ifeq ($(CROSS_COMPILE),)
 CROSS_COMPILE := m68k-elf-
 endif
 
-CONFIG_STANDALONE_LOAD_ADDR ?= 0x20000
-
 PLATFORM_CPPFLAGS += -D__M68K__
 PLATFORM_LDFLAGS  += -n
 PLATFORM_RELFLAGS += -ffunction-sections -fdata-sections
diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig
index 5cc68d63c4..3c417c726a 100644
--- a/arch/microblaze/Kconfig
+++ b/arch/microblaze/Kconfig
@@ -4,6 +4,9 @@  menu "MicroBlaze architecture"
 config SYS_ARCH
 	default "microblaze"
 
+config STANDALONE_LOAD_ADDR
+	default 0x80F00000
+
 choice
 	prompt "Target select"
 	optional
diff --git a/arch/microblaze/config.mk b/arch/microblaze/config.mk
index 3c5866a295..0d087229f8 100644
--- a/arch/microblaze/config.mk
+++ b/arch/microblaze/config.mk
@@ -10,8 +10,6 @@  ifeq ($(CROSS_COMPILE),)
 CROSS_COMPILE := mb-
 endif
 
-CONFIG_STANDALONE_LOAD_ADDR ?= 0x80F00000
-
 PLATFORM_CPPFLAGS += -ffixed-r31 -D__microblaze__
 
 ifeq ($(CONFIG_SPL_BUILD),)
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 071dea04ec..286328af10 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -8,6 +8,10 @@  config SYS_CPU
 	default "mips32" if CPU_MIPS32
 	default "mips64" if CPU_MIPS64
 
+config STANDALONE_LOAD_ADDR
+	default 0x80200000 if CPU_MIPS32
+	default 0xffffffff80200000 if CPU_MIPS64
+
 choice
 	prompt "Target select"
 	optional
diff --git a/arch/mips/config.mk b/arch/mips/config.mk
index 1ae8bf7b71..d1d700a22a 100644
--- a/arch/mips/config.mk
+++ b/arch/mips/config.mk
@@ -25,14 +25,12 @@  ifdef CONFIG_32BIT
 PLATFORM_CPPFLAGS	+= -mabi=32
 PLATFORM_LDFLAGS	+= -m $(32bit-emul)
 OBJCOPYFLAGS		+= -O $(32bit-bfd)
-CONFIG_STANDALONE_LOAD_ADDR	?= 0x80200000
 endif
 
 ifdef CONFIG_64BIT
 PLATFORM_CPPFLAGS	+= -mabi=64
 PLATFORM_LDFLAGS	+= -m$(64bit-emul)
 OBJCOPYFLAGS		+= -O $(64bit-bfd)
-CONFIG_STANDALONE_LOAD_ADDR	?= 0xffffffff80200000
 endif
 
 PLATFORM_CPPFLAGS += -D__MIPS__
diff --git a/arch/nds32/Kconfig b/arch/nds32/Kconfig
index d72ff46113..989330b019 100644
--- a/arch/nds32/Kconfig
+++ b/arch/nds32/Kconfig
@@ -4,6 +4,9 @@  menu "NDS32 architecture"
 config SYS_ARCH
 	default "nds32"
 
+config STANDALONE_LOAD_ADDR
+	default 0x300000
+
 choice
 	prompt "Target select"
 	optional
diff --git a/arch/nds32/config.mk b/arch/nds32/config.mk
index 0a93fd428d..8f2971a5b8 100644
--- a/arch/nds32/config.mk
+++ b/arch/nds32/config.mk
@@ -12,7 +12,6 @@  ifeq ($(CROSS_COMPILE),)
 CROSS_COMPILE := nds32le-linux-
 endif
 
-CONFIG_STANDALONE_LOAD_ADDR = 0x300000
 LDFLAGS_STANDALONE	+= -T $(srctree)/examples/standalone/nds32.lds
 
 PLATFORM_RELFLAGS	+= -fno-strict-aliasing -fno-common -mrelax
diff --git a/arch/nios2/Kconfig b/arch/nios2/Kconfig
index bb4fb2ac3a..10fdfdb3ff 100644
--- a/arch/nios2/Kconfig
+++ b/arch/nios2/Kconfig
@@ -11,4 +11,7 @@  config SYS_CONFIG_NAME
 	  The header file include/configs/<CONFIG_SYS_CONFIG_NAME>.h
 	  should be included from include/config.h.
 
+config STANDALONE_LOAD_ADDR
+	default 0x02000000
+
 endmenu
diff --git a/arch/nios2/config.mk b/arch/nios2/config.mk
index c63d170eae..6119d6101f 100644
--- a/arch/nios2/config.mk
+++ b/arch/nios2/config.mk
@@ -8,8 +8,6 @@  ifeq ($(CROSS_COMPILE),)
 CROSS_COMPILE := nios2-elf-
 endif
 
-CONFIG_STANDALONE_LOAD_ADDR ?= 0x02000000
-
 PLATFORM_CPPFLAGS += -D__NIOS2__
 PLATFORM_CPPFLAGS += -G0
 
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 8faef0ba9f..98ed2f901b 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -4,6 +4,9 @@  menu "PowerPC architecture"
 config SYS_ARCH
 	default "powerpc"
 
+config STANDALONE_LOAD_ADDR
+	default 0x40000
+
 choice
 	prompt "CPU select"
 	optional
diff --git a/arch/powerpc/config.mk b/arch/powerpc/config.mk
index f5d21c837a..aca0c2a519 100644
--- a/arch/powerpc/config.mk
+++ b/arch/powerpc/config.mk
@@ -7,7 +7,6 @@  ifeq ($(CROSS_COMPILE),)
 CROSS_COMPILE := ppc_8xx-
 endif
 
-CONFIG_STANDALONE_LOAD_ADDR ?= 0x40000
 LDFLAGS_FINAL += --gc-sections
 LDFLAGS_FINAL += --bss-plt
 PLATFORM_RELFLAGS += -fpic -mrelocatable -ffunction-sections \
diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index 20a43d88e3..c7ef8864b2 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -4,6 +4,9 @@  menu "RISCV architecture"
 config SYS_ARCH
 	default "riscv"
 
+config STANDALONE_LOAD_ADDR
+	default 0x00000000
+
 choice
 	prompt "Target select"
 	optional
diff --git a/arch/riscv/config.mk b/arch/riscv/config.mk
index d0b7e8e88b..70da5bcee0 100644
--- a/arch/riscv/config.mk
+++ b/arch/riscv/config.mk
@@ -27,7 +27,6 @@  PLATFORM_LDFLAGS	+= -m $(64bit-emul)
 EFI_LDS			:= elf_riscv64_efi.lds
 endif
 
-CONFIG_STANDALONE_LOAD_ADDR = 0x00000000
 LDFLAGS_STANDALONE += -T $(srctree)/examples/standalone/riscv.lds
 
 PLATFORM_CPPFLAGS	+= -ffixed-gp -fpic
diff --git a/arch/sandbox/Kconfig b/arch/sandbox/Kconfig
index 2a08533c4b..8198f8a0a0 100644
--- a/arch/sandbox/Kconfig
+++ b/arch/sandbox/Kconfig
@@ -10,6 +10,9 @@  config SYS_BOARD
 config SYS_CPU
 	default "sandbox"
 
+config STANDALONE_LOAD_ADDR
+	default 0x0
+
 config SANDBOX64
 	bool "Use 64-bit addresses"
 	select PHYS_64BIT
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index d20761e66c..84b91020f2 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -125,6 +125,9 @@  config SYS_CPU
 	default "sh3" if CPU_SH3
 	default "sh4" if CPU_SH4
 
+config STANDALONE_LOAD_ADDR
+	default 0x8C000000
+
 source "arch/sh/lib/Kconfig"
 
 source "board/alphaproject/ap_sh4a_4a/Kconfig"
diff --git a/arch/sh/config.mk b/arch/sh/config.mk
index 6ef44638ab..1e719aa881 100644
--- a/arch/sh/config.mk
+++ b/arch/sh/config.mk
@@ -7,7 +7,6 @@  ifeq ($(CROSS_COMPILE),)
 CROSS_COMPILE := sh4-linux-
 endif
 
-CONFIG_STANDALONE_LOAD_ADDR ?= 0x8C000000
 ifeq ($(CPU),sh2)
 LDFLAGS_STANDALONE += -EB
 endif
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index a1c18d26e1..7947525645 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -4,6 +4,9 @@  menu "x86 architecture"
 config SYS_ARCH
 	default "x86"
 
+config STANDALONE_LOAD_ADDR
+	default 0x40000
+
 choice
 	prompt "Run U-Boot in 32/64-bit mode"
 	default X86_RUN_32BIT
diff --git a/arch/x86/config.mk b/arch/x86/config.mk
index 5b04febd68..097506f4fd 100644
--- a/arch/x86/config.mk
+++ b/arch/x86/config.mk
@@ -3,8 +3,6 @@ 
 # (C) Copyright 2000-2002
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 
-CONFIG_STANDALONE_LOAD_ADDR ?= 0x40000
-
 PLATFORM_CPPFLAGS += -fno-strict-aliasing
 PLATFORM_CPPFLAGS += -fomit-frame-pointer
 PF_CPPFLAGS_X86   := $(call cc-option, -fno-toplevel-reorder, \
diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig
index 2ba7132c20..e228f15660 100644
--- a/arch/xtensa/Kconfig
+++ b/arch/xtensa/Kconfig
@@ -8,6 +8,9 @@  config SYS_ARCH
 config SYS_CPU
 	string "Xtensa Core Variant"
 
+config STANDALONE_LOAD_ADDR
+	default 0x00800000
+
 choice
 	prompt "Target select"
 
diff --git a/config.mk b/config.mk
index caf0dd9b81..b170842979 100644
--- a/config.mk
+++ b/config.mk
@@ -77,4 +77,3 @@  export PLATFORM_CPPFLAGS
 export RELFLAGS
 export LDFLAGS_FINAL
 export LDFLAGS_STANDALONE
-export CONFIG_STANDALONE_LOAD_ADDR
diff --git a/configs/display5_defconfig b/configs/display5_defconfig
index 697138eede..4c2bd5c52e 100644
--- a/configs/display5_defconfig
+++ b/configs/display5_defconfig
@@ -1,4 +1,5 @@ 
 CONFIG_ARM=y
+CONFIG_STANDALONE_LOAD_ADDR=0x10001000
 CONFIG_ARCH_MX6=y
 CONFIG_SYS_TEXT_BASE=0x17800000
 CONFIG_SPL_GPIO_SUPPORT=y
diff --git a/configs/display5_factory_defconfig b/configs/display5_factory_defconfig
index 5962b642b2..42c3e11305 100644
--- a/configs/display5_factory_defconfig
+++ b/configs/display5_factory_defconfig
@@ -1,4 +1,5 @@ 
 CONFIG_ARM=y
+CONFIG_STANDALONE_LOAD_ADDR=0x10001000
 CONFIG_ARCH_MX6=y
 CONFIG_SYS_TEXT_BASE=0x17800000
 CONFIG_SPL_GPIO_SUPPORT=y
diff --git a/configs/kzm9g_defconfig b/configs/kzm9g_defconfig
index b64a437f77..29ee3cd75a 100644
--- a/configs/kzm9g_defconfig
+++ b/configs/kzm9g_defconfig
@@ -1,4 +1,5 @@ 
 CONFIG_ARM=y
+CONFIG_STANDALONE_LOAD_ADDR=0x41000000
 # CONFIG_SYS_THUMB_BUILD is not set
 CONFIG_ARCH_RMOBILE=y
 CONFIG_SYS_TEXT_BASE=0x00000000
diff --git a/configs/opos6uldev_defconfig b/configs/opos6uldev_defconfig
index c2c1ea7605..47cf7b1801 100644
--- a/configs/opos6uldev_defconfig
+++ b/configs/opos6uldev_defconfig
@@ -1,4 +1,5 @@ 
 CONFIG_ARM=y
+CONFIG_STANDALONE_LOAD_ADDR=0x82000000
 CONFIG_ARCH_MX6=y
 CONFIG_SYS_TEXT_BASE=0x87800000
 CONFIG_SPL_GPIO_SUPPORT=y
diff --git a/examples/Makefile b/examples/Makefile
index d440bc5655..c230a1820a 100644
--- a/examples/Makefile
+++ b/examples/Makefile
@@ -6,6 +6,6 @@  ifdef FTRACE
 subdir-ccflags-y += -finstrument-functions -DFTRACE
 endif
 
-subdir-y += standalone
+subdir-$(CONFIG_STANDALONE) += standalone
 subdir-$(CONFIG_API) += api
 endif
diff --git a/examples/standalone/Kconfig b/examples/standalone/Kconfig
new file mode 100644
index 0000000000..70c9442a71
--- /dev/null
+++ b/examples/standalone/Kconfig
@@ -0,0 +1,14 @@ 
+menuconfig STANDALONE
+	bool "Standalone programs"
+	default y
+
+if STANDALONE
+
+config STANDALONE_LOAD_ADDR
+	hex "Program load address"
+	help
+	   This option defines the address where a standalone program is linked to
+	   and where it is loaded to in RAM. In most cases you can use the default
+	   value defined by your architecture.
+
+endif	# STANDALONE
diff --git a/include/configs/display5.h b/include/configs/display5.h
index 6d00699ebd..497c7f914b 100644
--- a/include/configs/display5.h
+++ b/include/configs/display5.h
@@ -350,7 +350,6 @@ 
 #define CONFIG_SYS_MAXARGS		32
 #define CONFIG_SYS_BARGSIZE		CONFIG_SYS_CBSIZE
 
-#define CONFIG_STANDALONE_LOAD_ADDR	0x10001000
 #define CONFIG_SYS_HZ			1000
 
 /* Physical Memory Map */
diff --git a/include/configs/kzm9g.h b/include/configs/kzm9g.h
index dd7ad3e659..bdd4ba5a12 100644
--- a/include/configs/kzm9g.h
+++ b/include/configs/kzm9g.h
@@ -60,8 +60,6 @@ 
 #define CONFIG_SYS_MALLOC_LEN	(CONFIG_ENV_SIZE + 128 * 1024)
 #define CONFIG_SYS_BOOTMAPSZ	(8 * 1024 * 1024)
 
-#define CONFIG_STANDALONE_LOAD_ADDR	0x41000000
-
 /* FLASH */
 #define CONFIG_FLASH_CFI_DRIVER
 #define CONFIG_SYS_FLASH_CFI
diff --git a/include/configs/opos6uldev.h b/include/configs/opos6uldev.h
index ecf6c133c5..89208ced6f 100644
--- a/include/configs/opos6uldev.h
+++ b/include/configs/opos6uldev.h
@@ -21,9 +21,6 @@ 
 /* Size of malloc() pool */
 #define CONFIG_SYS_MALLOC_LEN		(16 << 20)
 
-/* Miscellaneous configurable options */
-#define CONFIG_STANDALONE_LOAD_ADDR	0x82000000
-
 /* Physical Memory Map */
 #define CONFIG_SYS_SDRAM_BASE		MMDC0_ARB_BASE_ADDR
 #define CONFIG_SYS_INIT_RAM_ADDR	IRAM_BASE_ADDR
diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h
index 0338d85b7f..88e94252ba 100644
--- a/include/configs/sunxi-common.h
+++ b/include/configs/sunxi-common.h
@@ -169,13 +169,6 @@ 
 #define CONFIG_SYS_CBSIZE	1024	/* Console I/O Buffer Size */
 #define CONFIG_SYS_PBSIZE	1024	/* Print Buffer Size */
 
-/* standalone support */
-#ifdef CONFIG_MACH_SUN9I
-#define CONFIG_STANDALONE_LOAD_ADDR	0x22000000
-#else
-#define CONFIG_STANDALONE_LOAD_ADDR	0x42000000
-#endif
-
 /* FLASH and environment organization */
 
 #define CONFIG_SYS_MONITOR_LEN		(768 << 10)	/* 768 KiB */
diff --git a/include/configs/xtfpga.h b/include/configs/xtfpga.h
index 90310c46ac..a55dd60262 100644
--- a/include/configs/xtfpga.h
+++ b/include/configs/xtfpga.h
@@ -74,22 +74,6 @@ 
 #define CONFIG_SYS_MEMTEST_START	MEMADDR(0x01000000)
 #define CONFIG_SYS_MEMTEST_END		MEMADDR(0x02000000)
 
-/* Load address for stand-alone applications.
- * MEMADDR cannot be used here, because the definition needs to be
- * a plain number as it's used as -Ttext argument for ld in standalone
- * example makefile.
- * Handle noMMU vs MMUv2 vs MMUv3 distinction here manually.
- */
-#if XCHAL_HAVE_PTP_MMU
-#if XCHAL_VECBASE_RESET_VADDR == XCHAL_VECBASE_RESET_PADDR
-#define CONFIG_STANDALONE_LOAD_ADDR	0x00800000
-#else
-#define CONFIG_STANDALONE_LOAD_ADDR	0xd0800000
-#endif
-#else
-#define CONFIG_STANDALONE_LOAD_ADDR	0x60800000
-#endif
-
 #if defined(CONFIG_MAX_MEM_MAPPED) && \
 	CONFIG_MAX_MEM_MAPPED < CONFIG_SYS_SDRAM_SIZE
 #define CONFIG_SYS_MEMORY_SIZE		CONFIG_MAX_MEM_MAPPED
diff --git a/scripts/config_whitelist.txt b/scripts/config_whitelist.txt
index e058a06e8f..1195fa2235 100644
--- a/scripts/config_whitelist.txt
+++ b/scripts/config_whitelist.txt
@@ -1970,7 +1970,6 @@  CONFIG_SSP1_BASE
 CONFIG_SSP2_BASE
 CONFIG_SSP3_BASE
 CONFIG_STACKBASE
-CONFIG_STANDALONE_LOAD_ADDR
 CONFIG_STATIC_BOARD_REV
 CONFIG_STD_DEVICES_SETTINGS
 CONFIG_STM32_FLASH