kconfig: import Kconfig files from Linux v3.15-rc7

Import
  - scripts/kconfig/*
  - include/linux/kconfig.h
from Linux Kernel v3.15-rc7.

I know they include lots of trailing spaces
but I keep intentionally them untouched.

Series-to: u-boot@lists.denx.de
Series-cc: Simon Glass <sjg@chromium.org>
Series-cc: Tom Rini <trini@ti.com>
Series-cc: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
Series-cc: Wolfgang Denk <wd@denx.de>
Series-prefix: RFCv2b
Cover-letter:
Kconfig for U-Boot

This series introduces Kconfig.

Besides Linux Kernel, Kconfig is used in some projects,
such as, BusyBox, Buildroot.

But our situation is a little more complicated.
For one board, we need to generate 3 images at most:
Full image, SPL and TPL.

In the previous version, each image has its own defconfig.

For example, C29XPCIE_NAND board has:

 - configs/C29XPCIE_NAND_defconfig     (For full U-boot)
 - configs/spl/C29XPCIE_NAND_defconfig (For SPL)
 - configs/tpl/C29XPCIE_NAND_defconfig (For TPL)

Pros for this approach are:
 (1) Maximum flexibility
   Each binary image can be configured independently.

 (2) More generic approach to each image
   ifdef CONFIG_SPL_BUILD is sprinkled everywhere in C sources
   and makefiles.  By treating full image, SPL and TPL as
   generic cases, we could clean-up the code.

Cons are:
 (1) Multiple configuration
   "make config/menuconfig" must be invoked multiple times.
   This is painful.

 (2) Duplicated CONFIG macros
   Some macros such as CONFIG_ARM=y are defined in
   all of the three defconfigs. This seems stupid.

In this version, contrast to v1, I tried to port Kconfig
in a totally different way:
Full image, SPL and TPL share a single defconfig.
Only one ".config" file is created by "make defconfig" based on
configs/<board_name>_defconfig.

But the next step is special.
Multiple auto.conf is generated by "make silentoldconfig" from a
single .config.

 - include/config/auto.config     (for Full image)
 - spl/include/config/auto.config (for SPL)
 - tpl/include/config/auto.config (for TPL)

This approach loses flexibility to some extent.
But in return, we get one-shot configuration and a single defconfig.

 How does it work?
 -----------------

Case 1. Boolean macros only for Full U-Boot image

Some macros make sense only in the full U-boot image.
For example, CONFIG_SYS_HUSH_PARSER.

In such a case, We can describe it as follows:

    config CONFIG_SYS_HUSH_PARSER
            bool "Hush perser"
            depends on !SPL_BUILD

CONFIG_SYS_HUSH_PARSER will appear in
include/config/auto.conf but be concealed in
{spl,tpl}/include/config/auto.conf
because CONFIG_SPL_BUILD is only defined in SPL and TPL build.

Case 2. Boolean macros which might be used in SPL too

Most boards enable serial only in the full image.
But some boards use it in SPL image too.
In such a case, CONFIG_SPL_SERIAL_SUPPORT should be defined.
You can see many configs prefixed with CONFIG_SPL_ in spl/Makefile

Now CONFIG_OF_CONTROL is supported only in the full image.
If we want to expand it to SPL, we will have to prepare a new
option, CONFIG_SPL_OF_CONTROL.

Case 3. Hex or integer values

In this case, we must define different macros.

For example, include/configs/C29XPCIE.h defines CONFIG_SPL_TEXT_BASE
like this:

  #ifdef CONFIG_TPL_BUILD
  #define CONFIG_SPL_TEXT_BASE            0xf8f81000
  #elif defined(CONFIG_SPL_BUILD)
  #define CONFIG_SPL_TEXT_BASE            0xff800000
  #endif

But defconfig cannot use conditionals.
We have to rename the former CONFIG_SPL_TEXT_BASE
to CONFIG_TPL_TEXT_BASE.

CONFIG_SPL_TEXT_BASE=0xff800000
CONFIG_TPL_TEXT_BASE=0xf8f81000

 Comments are welcome
 --------------------

This series is really exmperimental.
When I was writing this patch set, I started wondering,
"Does this approach really work?"

I think it would be very painful to duplicate many config macros
for SPL and TPL.

 Build Test
 ----------

I built all boards excepts some already broken ones.
I also checked MD5SUM of output binaries for all of them.

I believe this series should not break any boards.
But if you notice something got broken, please let me know.

Besides, I confirmed out-of-tree build, parallel build (-j make option)
works correctly.

 How to apply this series
 ------------------------

I confirmed this series can be applied on commit 9665fa8f.
END
Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Do not apply: tools: add genkconfig

 ========================================
 Do not apply this patch to the main line
 ========================================

 What is this tool?
 ------------------

This tool converts boards.cfg to defconfig and Kconfig files.

It automatically generates
 - arch/${ARCH}/Kconfig
 - board/${VENDOR}/${BOARD}/Kconfig
 - board/${BOARD}/Kconfig
 - arch/${ARCH}/configs/*_defconfig

 How to use?
 -----------

Open tools/print_allconfigs with an editor.

Adjust cross compilers part for your environment.

  # Specify your favoriate cross tools
  CROSS_COMPILE_ARC=arc-linux-
  CROSS_COMPILE_AARCH64=aarch64-linux-gnu-
  CROSS_COMPILE_ARM=arm-unknown-linux-gnueabi-
   [snip]
  CROSS_COMPILE_X86=i386-linux-

And then, run "tools/genkconfig".

 Why is this patch here?
 -----------------------

The file boards.cfg is touched very frequently.
All the time, new/old boards are being added/removed.

The next commit was generated based on the u-boot/master at the time
I posted it.
It will become out-dated soon.

You can update it with this tool.

Series-changes: 2
 - Do not generate defconfig files for SPL and TPL
 - Do not output CONFIG_BOARD_MAINTAINERS and CONFIG_BOARD_STATUS
 - Delete board/Kconfig and instead, move "source board/*/*/Kconfig"
   statements to arch/*/Kconfig.
kconfig: add board Kconfig and defconfig files

This commit adds
 - arch/*/Kconfig: provide a menu to select target boards
 - board/*/Kconfig: set CONFIG macros to the appropriate values
        for each board
 - arch/*/configs/*_defconfig: default setting of each board

(This commit was automatically generated by a conversion script
based on boards.cfg)
kconfig: add basic Kconfig files

This commit adds more Kconfig files, which were written by hand.
include: define CONFIG_SPL and CONFIG_TPL as 1

We are about to switch to Kconfig in the next commit.
But there are something to get done beforehand.

In Kconfig, include/generated/autoconf.h defines boolean
CONFIG macros as 1.

CONFIG_SPL and CONFIG_TPL, if defined, must be defined as 1.
Otherwise, when switching to Kconfig, the build log
would be sprinkled with warning messages like this:
  warning: "CONFIG_SPL" redefined [enabled by default]

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
kconfig: switch to Kconfig

This commit enables Kconfig.
Going forward, we use Kconfig for board configuration.
mkconfig will never be used. Nor will include/config.mk be generated.

Kconfig must be adjusted for U-Boot because our situation is
a little more complicated than Linux Kernel.
We have to generate multiple binary images (Full U-Boot, SPL, TPL)
from one source tree.
Each image needs each configuration input.

Our approach is like this:

Every board has a signle defconfig file under "configs" directory.
SPL/TPL image, if it is supported, shares the same defconfig file
with the full U-boot image.

First, you need to configure for the target baord like this.

     make ARCH=<arch> <board_name>_defconfig

(Please not ARCH= must be provided from the command line)

A file ".config" will be created, storing configs setting
for all the images of the  target board.
You can use "make config", "make menuconfig" etc. to create
a new .config or modify the existing one.

And then run "make ARCH=<arch>".

Kbuild will automatically invoke "make silentoldconfig" if auto.conf
is missing or need to be updated.
The full, SPL, TPL image has its own auto.conf:
  - include/config/auto.conf      (for full image)
  - spl/include/config/auto.conf  (for SPL)
  - tpl/include/config/auto.conf  (for TPL)

How to generate three different auto.conf file from the same .config ?

The key is CONFIG_SPL_BUILD and CONFIG_TPL_BUILD.
CONFIG_SPL_BUILD is defined for both SPL and TPL, while CONFIG_TPL
is only for TPL image.

Some config macros only make sense for the full U-Boot.

For instance,

If you describe Kconfig entry like this:

    config SYS_HUSH_PARSER
            bool "Hush Parser"
            depends on !SPL_BUILD

CONFIG_SYS_HUSH_PARSER will be conceiled from SPL/TPL auto.conf.

If you want to set a config macro for each image separately,
you need to define another CONFIG.
Maybe CONFIG_SPL_ or CPNFIG_TPL_ prefix would be better for clarification.
For example,  CONFIG_SYS_TEXT_BASE, CONFIG_SPL_TEXT_BASE,
CONFIG_TPL_TEXT_BASE, respectively.

I have to admit duplicating config macros is painful but we get
a single defconfig file in return.

By the way, there is another item worth remarking here:
coexistence of Kconfig and board herder files.

Prior to Kconfig, we used C headers to define define a set of configs.

We expect a very long term to move existing config macros to Kconfig.
Two different infractructure must coexist in the interim.

In our former configuration scheme, include/autoconf.mk was generated
for the use in makefiles.
It is still generated in include/, spl/include/, tpl/include/ directory
for the full, SPL, TPL image, respectively.
MAKEALL: adjust for Kconfig

Use "make <board>_defconfig" instead of "make <board>_config".

WARNING
This adjustment is not enough.
MAKEALL should parse defconfig files instead of boards.cfg.
This commit has not got this rework done yet.
buildman: adjust for Kconfig

Use "make <board>_defconfig" instead of "make <board>_config".

WARNING
This adjustment is not enough.
MAKEALL should parse defconfig files instead of boards.cfg.
This commit has not got this rework done yet.
MAKEALL: Show configuration
kconfig: delete redundant CONFIG_${ARCH} definition

CONFIG_${ARCH} is defined by Kconfig.

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
kbuild: remove CONFIG_SPL/CONFIG_TPL definition in config headers

CONFIG_SPL and CONFIG_TPL are defined in Kconfig.

Remove the redundant definition in config headers.

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
kconfig: remove old script

mkconfig is no longer used in Kconfig.
Do not apply: tools: add updatedefconfig
kconfig: add CONFIG_CROSS_COMPILE

Copy from Linux Kernel (with a few adjustments in comments).
kconfig: Add CONFIG_CC_OPTIMIZE_FOR_SIZE
Do not apply: tools: move_config
split CONFIG_SPL_TEXT_BASE and CONFIG_TPL_TEXT_BASE

We are about to move CONFIG_SPL_TEXT_BASE from header files to defconfig.
But we cannot move them as they are.

The problem is that #ifdef statements are used in board headers with
TPL support. Like this:

  #ifdef CONFIG_TPL_BUILD
  #define CONFIG_SPL_TEXT_BASE    0xD0001000
  #elif defined(CONFIG_SPL_BUILD)
  #define CONFIG_SPL_TEXT_BASE    0xff800000
  #endif

We cannot describe conditinal statments in defconfig.
One possible solution is to add CONFIG_TPL_TEXT_BASE.

This commit modifies the code as follow:

  #ifdef CONFIG_TPL_BUILD
  #define CONFIG_TPL_TEXT_BASE    0xD0001000
  #elif defined(CONFIG_SPL_BUILD)
  #define CONFIG_SPL_TEXT_BASE    0xff800000
  #endif

(include/config_fallbakcs.h should also be tweaked because some other
parts still reference to CONFIG_SPL_TEXT_BASE)

In the next commit, it will be converted into defconfig like this:

  CONFIG_SPL_TEXT_BASE=0xff800000
  CONFIG_TPL_TEXT_BASE=0xd0001000
move CONFIG_{SPL,TPL}_TEXT_BASE to defconfig

This commit was automatically generated by a conversion tool.
remove CONFIG_{SPL,TPL}_TEXT_BASE from config headers

All the CONFIG_SPL_TEXT_BASE and CONFIG_TPL_TEXT_BASE definition
were moved to defconfig.
Now we can clean-up config headers.