mtd: spi: Clean up usage of CONFIG_SPI_FLASH_MTD
authorFrieder Schrempf <frieder.schrempf@kontron.de>
Wed, 23 Oct 2019 07:41:20 +0000 (07:41 +0000)
committerJagan Teki <jagan@amarulasolutions.com>
Thu, 24 Oct 2019 19:18:32 +0000 (00:48 +0530)
Most boards currently use SPI_FLASH_MTD only in U-Boot proper, not in
SPL. They often rely on hacks in the board header files to include
this option conditionally. To be able to fix this, we previously
introduced a separate option SPL_SPI_FLASH_MTD.

Therefore we can now adjust the Makefile and change the code in
sf_probe.c and sf_internal.h to use CONFIG_IS_ENABLED(SPI_FLASH_MTD).

We also need to move all occurences of CONFIG_SPI_FLASH_MTD from the
header files to the according defconfigs. The affected boards are
socfpga, aristainetos, cm_fx6, display5, ventana, rcar-gen2, dh_imx6
and da850evm.

We do this all in one patch to guarantee bisectibility.

This change was tested with buildman to make sure it does not
introduce any regressions by comparing the resulting binary sizes.

Signed-off-by: Frieder Schrempf <frieder.schrempf@kontron.de>
Reviewed-by: Stefan Roese <sr@denx.de>
Reviewed-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
Acked-by: Lukasz Majewski <lukma@denx.de>
Reviewed-by: Heiko Schocher <hs@denx.de>
Reviewed-by: Jagan Teki <jagan@amarulasolutions.com>
26 files changed:
configs/aristainetos2_defconfig
configs/aristainetos2b_defconfig
configs/aristainetos_defconfig
configs/cm_fx6_defconfig
configs/socfpga_arria5_defconfig
configs/socfpga_cyclone5_defconfig
configs/socfpga_dbm_soc1_defconfig
configs/socfpga_de0_nano_soc_defconfig
configs/socfpga_de10_nano_defconfig
configs/socfpga_is1_defconfig
configs/socfpga_mcvevk_defconfig
configs/socfpga_sockit_defconfig
configs/socfpga_socrates_defconfig
configs/socfpga_sr1500_defconfig
configs/socfpga_vining_fpga_defconfig
drivers/mtd/spi/Makefile
drivers/mtd/spi/sf_internal.h
drivers/mtd/spi/sf_probe.c
include/configs/aristainetos-common.h
include/configs/cm_fx6.h
include/configs/da850evm.h
include/configs/dh_imx6.h
include/configs/display5.h
include/configs/gw_ventana.h
include/configs/rcar-gen2-common.h
include/configs/socfpga_common.h

index 18ef5d2dce54af08e1e9c6d244c059ff7f22744d..0bfc1177622e1b36c0b2d94a64ea60d42d921975 100644 (file)
@@ -44,6 +44,7 @@ CONFIG_SF_DEFAULT_CS=1
 CONFIG_SF_DEFAULT_MODE=0
 CONFIG_SF_DEFAULT_SPEED=20000000
 CONFIG_SPI_FLASH_STMICRO=y
+CONFIG_SPI_FLASH_MTD=y
 CONFIG_MTD_UBI_FASTMAP=y
 CONFIG_MTD_UBI_FASTMAP_AUTOCONVERT=1
 CONFIG_PHYLIB=y
index 1054c05d8c1d793abcb1b25439019e08a1bf88f2..e2da747a8f93d8ea190e5a04b4d0ef53ae3120e8 100644 (file)
@@ -42,6 +42,7 @@ CONFIG_SPI_FLASH=y
 CONFIG_SF_DEFAULT_MODE=0
 CONFIG_SF_DEFAULT_SPEED=20000000
 CONFIG_SPI_FLASH_STMICRO=y
+CONFIG_SPI_FLASH_MTD=y
 CONFIG_MTD_UBI_FASTMAP=y
 CONFIG_MTD_UBI_FASTMAP_AUTOCONVERT=1
 CONFIG_PHYLIB=y
index 4080a7b3108fc00c19032fbd4c1c75d5d5778247..5caf95c22f521d3ddee854444385954dab197eb7 100644 (file)
@@ -43,6 +43,7 @@ CONFIG_SF_DEFAULT_BUS=3
 CONFIG_SF_DEFAULT_MODE=0
 CONFIG_SF_DEFAULT_SPEED=20000000
 CONFIG_SPI_FLASH_STMICRO=y
+CONFIG_SPI_FLASH_MTD=y
 CONFIG_MTD_UBI_FASTMAP=y
 CONFIG_MTD_UBI_FASTMAP_AUTOCONVERT=1
 CONFIG_PHYLIB=y
index eed0558e2449a45d2ed59136abde0f0bed1ea661..fbaf79d1f0ab7180661c3db9a438a90b64f5a53b 100644 (file)
@@ -72,6 +72,7 @@ CONFIG_SPI_FLASH_SPANSION=y
 CONFIG_SPI_FLASH_STMICRO=y
 CONFIG_SPI_FLASH_SST=y
 CONFIG_SPI_FLASH_WINBOND=y
+CONFIG_SPI_FLASH_MTD=y
 CONFIG_PHYLIB=y
 CONFIG_MII=y
 CONFIG_DM_PMIC=y
index 93254677e7fd3fdb55c64dc2737295caf0ad6221..51f559cda8007a1cb6b23f226fdb922d8726f623 100644 (file)
@@ -47,6 +47,7 @@ CONFIG_SPI_FLASH=y
 CONFIG_SPI_FLASH_SPANSION=y
 CONFIG_SPI_FLASH_STMICRO=y
 # CONFIG_SPI_FLASH_USE_4K_SECTORS is not set
+CONFIG_SPI_FLASH_MTD=y
 CONFIG_PHY_MICREL=y
 CONFIG_PHY_MICREL_KSZ90X1=y
 CONFIG_DM_ETH=y
index 8e5b2e2f66f74503fd9cc129c1dbdc1c8efe2df2..c6481130297ac4d1c2bd52dd072f3b601ec9aa6a 100644 (file)
@@ -48,6 +48,7 @@ CONFIG_SPI_FLASH_MACRONIX=y
 CONFIG_SPI_FLASH_SPANSION=y
 CONFIG_SPI_FLASH_STMICRO=y
 # CONFIG_SPI_FLASH_USE_4K_SECTORS is not set
+CONFIG_SPI_FLASH_MTD=y
 CONFIG_PHY_MICREL=y
 CONFIG_PHY_MICREL_KSZ90X1=y
 CONFIG_DM_ETH=y
index c73f3821e7bc968e29817c7aa4feb497e561f860..414f13147e43c30a1f3912f3770ac17ad1f88cce 100644 (file)
@@ -46,6 +46,7 @@ CONFIG_SYS_I2C_DW=y
 CONFIG_DM_MMC=y
 CONFIG_MMC_DW=y
 CONFIG_MTD_DEVICE=y
+CONFIG_SPI_FLASH_MTD=y
 CONFIG_DM_ETH=y
 CONFIG_PHY_GIGE=y
 CONFIG_ETH_DESIGNWARE=y
index 80ccb33fbb5d3734a64eb855737e255570d43f26..6eb052e9db3174839ae89c280447a1a4ac0faa40 100644 (file)
@@ -43,6 +43,7 @@ CONFIG_SYS_I2C_DW=y
 CONFIG_DM_MMC=y
 CONFIG_MMC_DW=y
 CONFIG_MTD_DEVICE=y
+CONFIG_SPI_FLASH_MTD=y
 CONFIG_PHY_MICREL=y
 CONFIG_PHY_MICREL_KSZ90X1=y
 CONFIG_DM_ETH=y
index 98e80b7c864954f46c7f6cba23386aae2349f594..6b8b5b41a1a6ab929ccdc714c788139e3569dde8 100644 (file)
@@ -39,6 +39,7 @@ CONFIG_SYS_I2C_DW=y
 CONFIG_DM_MMC=y
 CONFIG_MMC_DW=y
 CONFIG_MTD_DEVICE=y
+CONFIG_SPI_FLASH_MTD=y
 CONFIG_PHY_MICREL=y
 CONFIG_PHY_MICREL_KSZ90X1=y
 CONFIG_DM_ETH=y
index 99cdb26aae51766667de55c07896d42d232bc524..38b9f6c24b59f82489cb46e9314d7188a84b1751 100644 (file)
@@ -43,6 +43,7 @@ CONFIG_SYS_I2C_DW=y
 CONFIG_MTD_DEVICE=y
 CONFIG_SPI_FLASH=y
 CONFIG_SPI_FLASH_STMICRO=y
+CONFIG_SPI_FLASH_MTD=y
 CONFIG_PHY_MICREL=y
 CONFIG_PHY_MICREL_KSZ90X1=y
 CONFIG_DM_ETH=y
index e977cd77073dbe384562cc4a71d28bbbe124fdba..605ffd7c2b0810c9514bb740f15404cb670722ea 100644 (file)
@@ -42,6 +42,7 @@ CONFIG_DM_I2C=y
 CONFIG_SYS_I2C_DW=y
 CONFIG_DM_MMC=y
 CONFIG_MMC_DW=y
+CONFIG_SPI_FLASH_MTD=y
 CONFIG_DM_ETH=y
 CONFIG_PHY_GIGE=y
 CONFIG_ETH_DESIGNWARE=y
index b570b9dc949449c65f009e17373e60d5376aef85..cae6f7bc9b7b33b7ec7da0c4fc855b5b215de283 100644 (file)
@@ -48,6 +48,7 @@ CONFIG_SPI_FLASH_MACRONIX=y
 CONFIG_SPI_FLASH_SPANSION=y
 CONFIG_SPI_FLASH_STMICRO=y
 # CONFIG_SPI_FLASH_USE_4K_SECTORS is not set
+CONFIG_SPI_FLASH_MTD=y
 CONFIG_PHY_MICREL=y
 CONFIG_PHY_MICREL_KSZ90X1=y
 CONFIG_DM_ETH=y
index 9eac00e49dc218928d6345d58aa8dec319de873c..9cb1daa889c9d6e7d8ed29d33f3f131b83b16240 100644 (file)
@@ -48,6 +48,7 @@ CONFIG_SPI_FLASH=y
 CONFIG_SPI_FLASH_MACRONIX=y
 CONFIG_SPI_FLASH_SPANSION=y
 CONFIG_SPI_FLASH_STMICRO=y
+CONFIG_SPI_FLASH_MTD=y
 CONFIG_PHY_MICREL=y
 CONFIG_PHY_MICREL_KSZ90X1=y
 CONFIG_DM_ETH=y
index 092347a6df53ecca95dcce19352c0da7433ab58e..c48bbb0e9c340901c5449f69b72cb879722634f9 100644 (file)
@@ -49,6 +49,7 @@ CONFIG_SPI_FLASH=y
 CONFIG_SF_DEFAULT_SPEED=100000000
 CONFIG_SPI_FLASH_STMICRO=y
 # CONFIG_SPI_FLASH_USE_4K_SECTORS is not set
+CONFIG_SPI_FLASH_MTD=y
 CONFIG_PHY_MARVELL=y
 CONFIG_DM_ETH=y
 CONFIG_PHY_GIGE=y
index a9c594e219511120ab64ae24e67626c40f1824bb..80733ba6b150545481fe87d5bda538b03e0fe3c0 100644 (file)
@@ -72,6 +72,7 @@ CONFIG_SPI_FLASH=y
 CONFIG_SPI_FLASH_SPANSION=y
 CONFIG_SPI_FLASH_STMICRO=y
 # CONFIG_SPI_FLASH_USE_4K_SECTORS is not set
+CONFIG_SPI_FLASH_MTD=y
 CONFIG_MTD_UBI_FASTMAP=y
 CONFIG_PHY_MICREL=y
 CONFIG_PHY_MICREL_KSZ90X1=y
index 20db1015d9ed6323af60bf818051f1296c1a7775..b5dfa300de49c9563252ef3fda7ad4bbd75c549a 100644 (file)
@@ -19,5 +19,5 @@ endif
 
 obj-$(CONFIG_SPI_FLASH) += spi-nor.o
 obj-$(CONFIG_SPI_FLASH_DATAFLASH) += sf_dataflash.o
-obj-$(CONFIG_SPI_FLASH_MTD) += sf_mtd.o
+obj-$(CONFIG_$(SPL_)SPI_FLASH_MTD) += sf_mtd.o
 obj-$(CONFIG_SPI_FLASH_SANDBOX) += sandbox.o
index bb8c19a31cf70df90de1d89e2a3fdad236354a56..5c643034c691ae101bddb561584920e5ce896f6c 100644 (file)
@@ -77,7 +77,7 @@ extern const struct flash_info spi_nor_ids[];
 int spi_flash_cmd_get_sw_write_prot(struct spi_flash *flash);
 
 
-#ifdef CONFIG_SPI_FLASH_MTD
+#if CONFIG_IS_ENABLED(SPI_FLASH_MTD)
 int spi_flash_mtd_register(struct spi_flash *flash);
 void spi_flash_mtd_unregister(void);
 #endif
index 73297e1a0a512a0a82ce7ac38b9665e7bceddcca..f051e473ffc4d9a945f1b729c249a77771404db3 100644 (file)
@@ -44,7 +44,7 @@ static int spi_flash_probe_slave(struct spi_flash *flash)
        if (ret)
                goto err_read_id;
 
-#ifdef CONFIG_SPI_FLASH_MTD
+#if CONFIG_IS_ENABLED(SPI_FLASH_MTD)
        ret = spi_flash_mtd_register(flash);
 #endif
 
@@ -83,7 +83,7 @@ struct spi_flash *spi_flash_probe(unsigned int busnum, unsigned int cs,
 
 void spi_flash_free(struct spi_flash *flash)
 {
-#ifdef CONFIG_SPI_FLASH_MTD
+#if CONFIG_IS_ENABLED(SPI_FLASH_MTD)
        spi_flash_mtd_unregister();
 #endif
        spi_free_slave(flash->spi);
@@ -152,7 +152,7 @@ static int spi_flash_std_probe(struct udevice *dev)
 
 static int spi_flash_std_remove(struct udevice *dev)
 {
-#ifdef CONFIG_SPI_FLASH_MTD
+#if CONFIG_IS_ENABLED(SPI_FLASH_MTD)
        spi_flash_mtd_unregister();
 #endif
        return 0;
index e998d9b1b279800f27a67be3e091574d9aec6cf9..b451c7e7dccb94b63026799b8b8235cc01d40b46 100644 (file)
@@ -30,7 +30,6 @@
 #define CONFIG_ETHPRIME                        "FEC"
 #define CONFIG_FEC_MXC_PHYADDR         0
 
-#define CONFIG_SPI_FLASH_MTD
 #define CONFIG_SYS_SPI_ST_ENABLE_WP_PIN
 
 #define CONFIG_EXTRA_ENV_SETTINGS \
index b957e9cba4b5e29a8195eefd4972cfa1f7fc0411..c1a6625fcb10abb2580d576677c7c81e87f6cfb8 100644 (file)
 #define CONFIG_MXC_UART_BASE           UART4_BASE
 #define CONFIG_SYS_BAUDRATE_TABLE      {9600, 19200, 38400, 57600, 115200}
 
-/* SPI flash */
-
-/* MTD support */
-#ifndef CONFIG_SPL_BUILD
-#define CONFIG_SPI_FLASH_MTD
-#endif
-
 /* Environment */
 #define CONFIG_ENV_SECT_SIZE           (64 * 1024)
 #define CONFIG_ENV_SIZE                        (8 * 1024)
index 41f0813a01982c5d3030996113cec3f7daccbfdc..6876134a00cb6187b840357a20a641fb7c9d53a2 100644 (file)
 #define CONFIG_ENV_SECT_SIZE           CONFIG_SYS_FLASH_SECT_SZ
 #endif
 
-#ifdef CONFIG_USE_SPIFLASH
-#ifdef CONFIG_ENV_IS_IN_SPI_FLASH
+#if defined(CONFIG_USE_SPIFLASH) && defined(CONFIG_ENV_IS_IN_SPI_FLASH)
 #define CONFIG_ENV_SIZE                        (64 << 10)
 #define CONFIG_ENV_OFFSET              (512 << 10)
 #define CONFIG_ENV_SECT_SIZE   (64 << 10)
 #endif
-#ifdef CONFIG_SPL_BUILD
-#undef CONFIG_SPI_FLASH_MTD
-#endif
-#endif
 
 /*
  * U-Boot general configuration
index a854d0b53152d1df7b2ffb1f254b3d54d2b7f6a6..86c1192035281b56c1570a14f321d27f48a95170 100644 (file)
@@ -59,7 +59,6 @@
 #if defined(CONFIG_SPL_BUILD)
 #undef CONFIG_DM_SPI
 #undef CONFIG_DM_SPI_FLASH
-#undef CONFIG_SPI_FLASH_MTD
 #endif
 
 /* UART */
index d80641568eb44c8294cbc7713762c984b9305574..65dae1f62faeaf13584a6c73588e1764a069959b 100644 (file)
@@ -39,7 +39,6 @@
 #if defined(CONFIG_SPL_BUILD)
 #undef CONFIG_DM_SPI
 #undef CONFIG_DM_SPI_FLASH
-#undef CONFIG_SPI_FLASH_MTD
 #endif
 
 /* Below values are "dummy" - only to avoid build break */
index a27627e72199afb405ea93457105d61c6794640d..e543061bff6d630d2b3249dd0ccc9226c3e2101b 100644 (file)
 #define CONFIG_MXC_UART
 #define CONFIG_MXC_UART_BASE          UART2_BASE
 
-#ifdef CONFIG_SPI_FLASH
-
-/* SPI */
-#ifdef CONFIG_CMD_SF
-  #define CONFIG_SPI_FLASH_MTD
-                                            /* GPIO 3-19 (21248) */
-#endif
-
-#elif defined(CONFIG_SPL_NAND_SUPPORT)
+#if !defined(CONFIG_SPI_FLASH) && defined(CONFIG_SPL_NAND_SUPPORT)
 /* Enable NAND support */
 #ifdef CONFIG_CMD_NAND
   #define CONFIG_SYS_MAX_NAND_DEVICE   1
index 71a5909045b3dd180f443fdd7e5077b80275c70a..e940a8b70a3b3ab72187688ffdf355fd136cccf6 100644 (file)
 #define CONFIG_ENV_SIZE_REDUND (CONFIG_SYS_MONITOR_LEN)
 
 /* SF MTD */
-#if defined(CONFIG_SPI_FLASH_MTD) && !defined(CONFIG_SPL_BUILD)
-#else
+#ifdef CONFIG_SPL_BUILD
 #undef CONFIG_DM_SPI
 #undef CONFIG_DM_SPI_FLASH
-#undef CONFIG_SPI_FLASH_MTD
 #endif
 
 /* Timer */
index 94268ed7a310ca99f61cb4b6a4ed7be5c5dcb673..baa214399ff9d94a78aaa3707273224b8769227e 100644 (file)
 /*
  * QSPI support
  */
-/* Enable multiple SPI NOR flash manufacturers */
-#ifndef CONFIG_SPL_BUILD
-#define CONFIG_SPI_FLASH_MTD
-#endif
 /* QSPI reference clock */
 #ifndef __ASSEMBLY__
 unsigned int cm_get_qspi_controller_clk_hz(void);