[U-Boot] [PATCH 0/3] SPL: move CONFIG_SPL_*_LOAD to Kconfig

Moving to CONFIG_SPL_*_LOAD options to Kconfig offers several advantage: * simpler config headers * on some boards we can easily switch to another boot media without needing to modify the config headers.
This series fixes an issue in davinci where a wrong option was used in place of a CONFIG_SPL_*_LOAD option, then move the options to Kconfig options, and finally start using these Kconfig options for the OMAPL138-LCDK board.
Fabien Parent (3): davinci: spl: use correct macro to select boot device SPL: create Kconfig options for CONFIG_SPL_*_LOAD davinci: omapl138_lcdk: use new CONFIG_SPL_*_LOAD Kconfig options
arch/arm/mach-davinci/spl.c | 2 +- common/spl/Kconfig | 25 +++++++++++++++++++++++++ configs/omapl138_lcdk_defconfig | 1 + include/configs/omapl138_lcdk.h | 2 -- scripts/config_whitelist.txt | 3 --- 5 files changed, 27 insertions(+), 6 deletions(-)

The macro used to select the boot device is not the intended one. It should be CONFIG_SPL_NAND_LOAD and not CONFIG_SPL_NAND_SIMPLE.
Using the correct config option will help move them to Kconfig option.
Every davinci board that use the SPL are defining both CONFIG_SPL_NAND_LOAD and CONFIG_SPL_NAND_SIMPLE at the same place, so there should be no issue created by this change.
Signed-off-by: Fabien Parent fparent@baylibre.com --- arch/arm/mach-davinci/spl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm/mach-davinci/spl.c b/arch/arm/mach-davinci/spl.c index 0aeaa7d8b7..9d5a173701 100644 --- a/arch/arm/mach-davinci/spl.c +++ b/arch/arm/mach-davinci/spl.c @@ -52,7 +52,7 @@ u32 spl_boot_mode(const u32 boot_device)
u32 spl_boot_device(void) { -#ifdef CONFIG_SPL_NAND_SIMPLE +#ifdef CONFIG_SPL_NAND_LOAD return BOOT_DEVICE_NAND; #elif defined(CONFIG_SPL_SPI_LOAD) return BOOT_DEVICE_SPI;

In order to clean up the config headers and also to allow to easily switch the boot device for some boards without having to modify the config headers, it is better to move the options to Kconfig. This commit move the CONFIG_SPL_*_LOAD options to Kconfig files.
Signed-off-by: Fabien Parent fparent@baylibre.com --- common/spl/Kconfig | 25 +++++++++++++++++++++++++ scripts/config_whitelist.txt | 3 --- 2 files changed, 25 insertions(+), 3 deletions(-)
diff --git a/common/spl/Kconfig b/common/spl/Kconfig index cba51f5df6..9313870566 100644 --- a/common/spl/Kconfig +++ b/common/spl/Kconfig @@ -97,6 +97,31 @@ config SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR Address on the MMC to load U-Boot from, when the MMC is being used in raw mode. Units: MMC sectors (1 sector = 512 bytes).
+config SPL_SELECT_BOOT_MEDIA + bool "Select the media to boot from" + depends on SPL + help + Enable selection of the media that will be used to load u-boot or + the OS. This is not a must, some SoCs need this, some not. + +choice + prompt "Boot media" + depends on SPL_SELECT_BOOT_MEDIA + +config SPL_NAND_LOAD + bool "Load u-boot or OS from NAND" + depends on SPL_NAND_SUPPORT + +config SPL_SPI_LOAD + bool "Load u-boot or OS from SPI" + depends on SPL_SPI_FLASH_SUPPORT + +config SPL_MMC_LOAD + bool "Load u-boot or OS from MMC" + depends on SPL_MMC_SUPPORT + +endchoice + config TPL bool depends on SPL && SUPPORT_TPL diff --git a/scripts/config_whitelist.txt b/scripts/config_whitelist.txt index 8814841e1f..f9fb4b59f8 100644 --- a/scripts/config_whitelist.txt +++ b/scripts/config_whitelist.txt @@ -4163,7 +4163,6 @@ CONFIG_SPL_MAX_FOOTPRINT CONFIG_SPL_MAX_PEB_SIZE CONFIG_SPL_MAX_SIZE CONFIG_SPL_MMC_BOOT -CONFIG_SPL_MMC_LOAD CONFIG_SPL_MMC_MINIMAL CONFIG_SPL_MPC83XX_WAIT_FOR_NAND CONFIG_SPL_MXS_PSWITCH_WAIT @@ -4173,7 +4172,6 @@ CONFIG_SPL_NAND_BOOT CONFIG_SPL_NAND_DRIVERS CONFIG_SPL_NAND_ECC CONFIG_SPL_NAND_INIT -CONFIG_SPL_NAND_LOAD CONFIG_SPL_NAND_MINIMAL CONFIG_SPL_NAND_MXS CONFIG_SPL_NAND_RAW_ONLY @@ -4199,7 +4197,6 @@ CONFIG_SPL_SKIP_RELOCATE CONFIG_SPL_SPAACT_ADDR CONFIG_SPL_SPI_BOOT CONFIG_SPL_SPI_FLASH_MINIMAL -CONFIG_SPL_SPI_LOAD CONFIG_SPL_STACK CONFIG_SPL_STACK_ADDR CONFIG_SPL_STACK_SIZE

Instead of defining ourself the config options in the config header, let's use the new Kconfig options for it.
Signed-off-by: Fabien Parent fparent@baylibre.com --- configs/omapl138_lcdk_defconfig | 1 + include/configs/omapl138_lcdk.h | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/configs/omapl138_lcdk_defconfig b/configs/omapl138_lcdk_defconfig index 52681c92d0..7199d90ae9 100644 --- a/configs/omapl138_lcdk_defconfig +++ b/configs/omapl138_lcdk_defconfig @@ -11,6 +11,7 @@ CONFIG_VERSION_VARIABLE=y # CONFIG_DISPLAY_BOARDINFO is not set CONFIG_SPL=y CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0xb5 +CONFIG_SPL_SELECT_BOOT_MEDIA=y CONFIG_HUSH_PARSER=y CONFIG_SYS_PROMPT="U-Boot > " # CONFIG_CMD_IMLS is not set diff --git a/include/configs/omapl138_lcdk.h b/include/configs/omapl138_lcdk.h index 7c2f4141c9..f0b786f394 100644 --- a/include/configs/omapl138_lcdk.h +++ b/include/configs/omapl138_lcdk.h @@ -138,7 +138,6 @@ #define CONFIG_ENV_SPI_MAX_HZ CONFIG_SF_DEFAULT_SPEED
#ifdef CONFIG_USE_SPIFLASH -#define CONFIG_SPL_SPI_LOAD #define CONFIG_SYS_SPI_U_BOOT_OFFS 0x8000 #define CONFIG_SYS_SPI_U_BOOT_SIZE 0x30000 #endif @@ -198,7 +197,6 @@ #define CONFIG_SPL_NAND_DRIVERS #define CONFIG_SPL_NAND_ECC #define CONFIG_SPL_NAND_SIMPLE -#define CONFIG_SPL_NAND_LOAD #endif
#ifdef CONFIG_SYS_USE_NOR

On Tue, Dec 06, 2016 at 02:48:27PM +0100, Fabien Parent wrote:
Moving to CONFIG_SPL_*_LOAD options to Kconfig offers several advantage:
- simpler config headers
- on some boards we can easily switch to another boot media without needing to modify the config headers.
This series fixes an issue in davinci where a wrong option was used in place of a CONFIG_SPL_*_LOAD option, then move the options to Kconfig options, and finally start using these Kconfig options for the OMAPL138-LCDK board.
Fabien Parent (3): davinci: spl: use correct macro to select boot device SPL: create Kconfig options for CONFIG_SPL_*_LOAD davinci: omapl138_lcdk: use new CONFIG_SPL_*_LOAD Kconfig options
arch/arm/mach-davinci/spl.c | 2 +- common/spl/Kconfig | 25 +++++++++++++++++++++++++ configs/omapl138_lcdk_defconfig | 1 + include/configs/omapl138_lcdk.h | 2 -- scripts/config_whitelist.txt | 3 --- 5 files changed, 27 insertions(+), 6 deletions(-)
So, I think this shows that some of the SPL framework needs to be revisited for davinci. First, lets make it clear what CONFIG_SPL_{SPI,NAND,MMC}_LOAD is doing.
CONFIG_SPL_MMC_LOAD is used to flag that on davinci we're loading U-Boot from MMC. It's not set / used today but I assume it was working when I introduced all of this.
CONFIG_SPL_NAND_LOAD is used for two things. First, it is used to flag that on davinci we're loading U-Boot from NAND. Second, it is used to enable the non-SPL_FRAMEWORK NAND driver (drivers/mtd/nand/nand_spl_load.c). This driver is not used on davinci.
CONFIG_SPL_SPI_LOAD is used for two things. First, it is used to flag that on davinci we're loading U-Boot from SPI flash. Second, it used globally to enable common/spl/spl_spi.c.
NAND boot is done here via CONFIG_SPL_NAND_SIMPLE which is the regular SPL framework based NAND driver (drivers/mtd/nand/nand_spl_simple.c). This also means that the patch to update CONFIG_SYS_NAND_U_BOOT_SIZE was not needed since we don't use that driver.
Now, I think that in retrospect arch/arm/mach-davinci/spl.c::spl_boot_device could be re-worked to key off of CONFIG_SPL_NAND_SIMPLE / CONFIG_SPL_SPI_SUPPORT / SPL_MMC_SUPPORT.
And a good but possibly complex series would be to consolidate the usage of SPL_SPI_SUPPORT, SPL_SPI_FLASH_SUPPORT and SPL_SPI_LOAD just in to SPL_SPI_SUPPORT. I'll probably try and do this myself as there's a ton of build testing and size checking to make sure nothing odd breaks here to do.

Hi Tom,
On 12/06/16 16:32, Tom Rini wrote:
On Tue, Dec 06, 2016 at 02:48:27PM +0100, Fabien Parent wrote:
Moving to CONFIG_SPL_*_LOAD options to Kconfig offers several advantage:
- simpler config headers
- on some boards we can easily switch to another boot media without needing to modify the config headers.
This series fixes an issue in davinci where a wrong option was used in place of a CONFIG_SPL_*_LOAD option, then move the options to Kconfig options, and finally start using these Kconfig options for the OMAPL138-LCDK board.
Fabien Parent (3): davinci: spl: use correct macro to select boot device SPL: create Kconfig options for CONFIG_SPL_*_LOAD davinci: omapl138_lcdk: use new CONFIG_SPL_*_LOAD Kconfig options
arch/arm/mach-davinci/spl.c | 2 +- common/spl/Kconfig | 25 +++++++++++++++++++++++++ configs/omapl138_lcdk_defconfig | 1 + include/configs/omapl138_lcdk.h | 2 -- scripts/config_whitelist.txt | 3 --- 5 files changed, 27 insertions(+), 6 deletions(-)
So, I think this shows that some of the SPL framework needs to be revisited for davinci. First, lets make it clear what CONFIG_SPL_{SPI,NAND,MMC}_LOAD is doing.
CONFIG_SPL_MMC_LOAD is used to flag that on davinci we're loading U-Boot from MMC. It's not set / used today but I assume it was working when I introduced all of this.
CONFIG_SPL_NAND_LOAD is used for two things. First, it is used to flag that on davinci we're loading U-Boot from NAND. Second, it is used to enable the non-SPL_FRAMEWORK NAND driver (drivers/mtd/nand/nand_spl_load.c). This driver is not used on davinci.
CONFIG_SPL_SPI_LOAD is used for two things. First, it is used to flag that on davinci we're loading U-Boot from SPI flash. Second, it used globally to enable common/spl/spl_spi.c.
NAND boot is done here via CONFIG_SPL_NAND_SIMPLE which is the regular SPL framework based NAND driver (drivers/mtd/nand/nand_spl_simple.c). This also means that the patch to update CONFIG_SYS_NAND_U_BOOT_SIZE was not needed since we don't use that driver.
Now, I think that in retrospect arch/arm/mach-davinci/spl.c::spl_boot_device could be re-worked to key off of CONFIG_SPL_NAND_SIMPLE / CONFIG_SPL_SPI_SUPPORT / SPL_MMC_SUPPORT.
And a good but possibly complex series would be to consolidate the usage of SPL_SPI_SUPPORT, SPL_SPI_FLASH_SUPPORT and SPL_SPI_LOAD just in to SPL_SPI_SUPPORT. I'll probably try and do this myself as there's a ton of build testing and size checking to make sure nothing odd breaks here to do.
Just a thought... Are you sure you want to combine all three (spi, spi flash, and spi load) under one define? Won't be there any case for parsing some spi device (say eeprom) in the SPL, but no spi flash to load U-Boot from? It might be sensible to keep the "spi flash" and the "spi load" together, but I think it might be more beneficial to keep the spi bus support apart.

On Tue, Dec 06, 2016 at 05:57:57PM +0200, Igor Grinberg wrote:
Hi Tom,
On 12/06/16 16:32, Tom Rini wrote:
On Tue, Dec 06, 2016 at 02:48:27PM +0100, Fabien Parent wrote:
Moving to CONFIG_SPL_*_LOAD options to Kconfig offers several advantage:
- simpler config headers
- on some boards we can easily switch to another boot media without needing to modify the config headers.
This series fixes an issue in davinci where a wrong option was used in place of a CONFIG_SPL_*_LOAD option, then move the options to Kconfig options, and finally start using these Kconfig options for the OMAPL138-LCDK board.
Fabien Parent (3): davinci: spl: use correct macro to select boot device SPL: create Kconfig options for CONFIG_SPL_*_LOAD davinci: omapl138_lcdk: use new CONFIG_SPL_*_LOAD Kconfig options
arch/arm/mach-davinci/spl.c | 2 +- common/spl/Kconfig | 25 +++++++++++++++++++++++++ configs/omapl138_lcdk_defconfig | 1 + include/configs/omapl138_lcdk.h | 2 -- scripts/config_whitelist.txt | 3 --- 5 files changed, 27 insertions(+), 6 deletions(-)
So, I think this shows that some of the SPL framework needs to be revisited for davinci. First, lets make it clear what CONFIG_SPL_{SPI,NAND,MMC}_LOAD is doing.
CONFIG_SPL_MMC_LOAD is used to flag that on davinci we're loading U-Boot from MMC. It's not set / used today but I assume it was working when I introduced all of this.
CONFIG_SPL_NAND_LOAD is used for two things. First, it is used to flag that on davinci we're loading U-Boot from NAND. Second, it is used to enable the non-SPL_FRAMEWORK NAND driver (drivers/mtd/nand/nand_spl_load.c). This driver is not used on davinci.
CONFIG_SPL_SPI_LOAD is used for two things. First, it is used to flag that on davinci we're loading U-Boot from SPI flash. Second, it used globally to enable common/spl/spl_spi.c.
NAND boot is done here via CONFIG_SPL_NAND_SIMPLE which is the regular SPL framework based NAND driver (drivers/mtd/nand/nand_spl_simple.c). This also means that the patch to update CONFIG_SYS_NAND_U_BOOT_SIZE was not needed since we don't use that driver.
Now, I think that in retrospect arch/arm/mach-davinci/spl.c::spl_boot_device could be re-worked to key off of CONFIG_SPL_NAND_SIMPLE / CONFIG_SPL_SPI_SUPPORT / SPL_MMC_SUPPORT.
And a good but possibly complex series would be to consolidate the usage of SPL_SPI_SUPPORT, SPL_SPI_FLASH_SUPPORT and SPL_SPI_LOAD just in to SPL_SPI_SUPPORT. I'll probably try and do this myself as there's a ton of build testing and size checking to make sure nothing odd breaks here to do.
Just a thought... Are you sure you want to combine all three (spi, spi flash, and spi load) under one define? Won't be there any case for parsing some spi device (say eeprom) in the SPL, but no spi flash to load U-Boot from? It might be sensible to keep the "spi flash" and the "spi load" together, but I think it might be more beneficial to keep the spi bus support apart.
Ah, good point. I don't know if we have that case today, but that would be one of the gotchas I'd be size-checking for. And another place where the 'imply' keyword Masahiro pointed out earlier would be helpful for too. Thanks!
participants (3)
-
Fabien Parent
-
Igor Grinberg
-
Tom Rini