i2c: Convert CONFIG_POWER_I2C et al to Kconfig

This converts the following to Kconfig:
   CONFIG_POWER_I2C
   CONFIG_POWER_LEGACY

They are handled at the same time due to a dependency between them.
Update the Makefile rule to use legacy power only in U-Boot proper.
Unfortunately a separate rule is needed in SPL to be able to build
legacy power.  Add SPL related symbols for both, to allow for SPL-only
usage.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Jaehoon Chung <jh80.chung@samsung.com>
[trini: More SPL related cleanups, reword commit message]
Signed-off-by: Tom Rini <trini@konsulko.com>
diff --git a/board/compulab/cl-som-imx7/cl-som-imx7.c b/board/compulab/cl-som-imx7/cl-som-imx7.c
index c54e02f..3ee1335 100644
--- a/board/compulab/cl-som-imx7/cl-som-imx7.c
+++ b/board/compulab/cl-som-imx7/cl-som-imx7.c
@@ -267,7 +267,7 @@
 	return 0;
 }
 
-#ifdef CONFIG_POWER_LEGACY
+#if CONFIG_IS_ENABLED(POWER_LEGACY)
 #define I2C_PMIC	0
 int power_init_board(void)
 {
@@ -293,7 +293,7 @@
 
 	return 0;
 }
-#endif /* CONFIG_POWER_LEGACY */
+#endif /* CONFIG_IS_ENABLED(POWER_LEGACY) */
 
 /*
  * cl_som_imx7_setup_wdog() - watchdog configuration.
diff --git a/board/freescale/imx8mp_evk/spl.c b/board/freescale/imx8mp_evk/spl.c
index d317f21..eca42c7 100644
--- a/board/freescale/imx8mp_evk/spl.c
+++ b/board/freescale/imx8mp_evk/spl.c
@@ -63,7 +63,7 @@
 	},
 };
 
-#ifdef CONFIG_POWER_LEGACY
+#if CONFIG_IS_ENABLED(POWER_LEGACY)
 #define I2C_PMIC	0
 int power_init_board(void)
 {
diff --git a/board/freescale/imx8mq_evk/spl.c b/board/freescale/imx8mq_evk/spl.c
index 6ee6230..67d069b 100644
--- a/board/freescale/imx8mq_evk/spl.c
+++ b/board/freescale/imx8mq_evk/spl.c
@@ -156,7 +156,7 @@
 	return 0;
 }
 
-#ifdef CONFIG_POWER_LEGACY
+#if CONFIG_IS_ENABLED(POWER_LEGACY)
 #define I2C_PMIC	0
 int power_init_board(void)
 {
diff --git a/board/samsung/common/board.c b/board/samsung/common/board.c
index 08f9202..97791aa 100644
--- a/board/samsung/common/board.c
+++ b/board/samsung/common/board.c
@@ -185,7 +185,7 @@
 }
 #endif
 
-#if defined(CONFIG_POWER_LEGACY) || defined(CONFIG_DM_PMIC)
+#if CONFIG_IS_ENABLED(POWER_LEGACY) || CONFIG_IS_ENABLED(DM_PMIC)
 int power_init_board(void)
 {
 	set_ps_hold_ctrl();
diff --git a/board/technexion/pico-imx7d/pico-imx7d.c b/board/technexion/pico-imx7d/pico-imx7d.c
index 81b1fb3..d97e13b 100644
--- a/board/technexion/pico-imx7d/pico-imx7d.c
+++ b/board/technexion/pico-imx7d/pico-imx7d.c
@@ -60,7 +60,7 @@
 	return 0;
 }
 
-#ifdef CONFIG_POWER_LEGACY
+#if CONFIG_IS_ENABLED(POWER_LEGACY)
 #define I2C_PMIC	3
 int power_init_board(void)
 {
diff --git a/board/tqc/tqma6/tqma6.c b/board/tqc/tqma6/tqma6.c
index f851e19..de9c001 100644
--- a/board/tqc/tqma6/tqma6.c
+++ b/board/tqc/tqma6/tqma6.c
@@ -247,7 +247,7 @@
 	};
 }
 
-#ifdef CONFIG_POWER_LEGACY
+#if CONFIG_IS_ENABLED(POWER_LEGACY)
 /* setup board specific PMIC */
 int power_init_board(void)
 {
diff --git a/board/udoo/neo/neo.c b/board/udoo/neo/neo.c
index 88889df..ce005d3 100644
--- a/board/udoo/neo/neo.c
+++ b/board/udoo/neo/neo.c
@@ -96,7 +96,7 @@
 };
 #endif
 
-#ifdef CONFIG_POWER_LEGACY
+#if CONFIG_IS_ENABLED(POWER_LEGACY)
 int power_init_board(void)
 {
 	struct pmic *p;
diff --git a/configs/am43xx_evm_qspiboot_defconfig b/configs/am43xx_evm_qspiboot_defconfig
index 6c42cbb..ebb46d4 100644
--- a/configs/am43xx_evm_qspiboot_defconfig
+++ b/configs/am43xx_evm_qspiboot_defconfig
@@ -49,6 +49,8 @@
 CONFIG_SPI_FLASH_MACRONIX=y
 CONFIG_MII=y
 CONFIG_DRIVER_TI_CPSW=y
+CONFIG_SPL_POWER_LEGACY=y
+CONFIG_SPL_POWER_I2C=y
 CONFIG_SYS_NS16550=y
 CONFIG_SPI=y
 CONFIG_TI_QSPI=y
diff --git a/configs/cl-som-imx7_defconfig b/configs/cl-som-imx7_defconfig
index 850bfcf..99c4685 100644
--- a/configs/cl-som-imx7_defconfig
+++ b/configs/cl-som-imx7_defconfig
@@ -82,7 +82,9 @@
 CONFIG_PHYLIB=y
 CONFIG_PHY_ATHEROS=y
 CONFIG_MII=y
+CONFIG_POWER_LEGACY=y
 CONFIG_DM_REGULATOR=y
+CONFIG_POWER_I2C=y
 CONFIG_MXC_UART=y
 CONFIG_SPI=y
 CONFIG_DM_SPI=y
diff --git a/configs/cm_t43_defconfig b/configs/cm_t43_defconfig
index 9faf1b8..18fbcf0 100644
--- a/configs/cm_t43_defconfig
+++ b/configs/cm_t43_defconfig
@@ -82,6 +82,8 @@
 CONFIG_PHY_ATHEROS=y
 CONFIG_MII=y
 CONFIG_DRIVER_TI_CPSW=y
+CONFIG_POWER_LEGACY=y
+CONFIG_POWER_I2C=y
 CONFIG_DM_SERIAL=y
 CONFIG_SPI=y
 CONFIG_DM_SPI=y
diff --git a/configs/gwventana_emmc_defconfig b/configs/gwventana_emmc_defconfig
index 45ff04b..d107432 100644
--- a/configs/gwventana_emmc_defconfig
+++ b/configs/gwventana_emmc_defconfig
@@ -102,8 +102,10 @@
 CONFIG_PCI=y
 CONFIG_PINCTRL=y
 CONFIG_PINCTRL_IMX6=y
+CONFIG_POWER_LEGACY=y
 CONFIG_DM_REGULATOR=y
 CONFIG_DM_REGULATOR_FIXED=y
+CONFIG_POWER_I2C=y
 CONFIG_CONS_INDEX=2
 CONFIG_DM_SERIAL=y
 CONFIG_MXC_UART=y
diff --git a/configs/gwventana_gw5904_defconfig b/configs/gwventana_gw5904_defconfig
index 42a22f6..f579d0f 100644
--- a/configs/gwventana_gw5904_defconfig
+++ b/configs/gwventana_gw5904_defconfig
@@ -106,8 +106,10 @@
 CONFIG_PCI=y
 CONFIG_PINCTRL=y
 CONFIG_PINCTRL_IMX6=y
+CONFIG_POWER_LEGACY=y
 CONFIG_DM_REGULATOR=y
 CONFIG_DM_REGULATOR_FIXED=y
+CONFIG_POWER_I2C=y
 CONFIG_CONS_INDEX=2
 CONFIG_DM_SERIAL=y
 CONFIG_MXC_UART=y
diff --git a/configs/gwventana_nand_defconfig b/configs/gwventana_nand_defconfig
index 784274b..b587ade 100644
--- a/configs/gwventana_nand_defconfig
+++ b/configs/gwventana_nand_defconfig
@@ -108,8 +108,10 @@
 CONFIG_PCI=y
 CONFIG_PINCTRL=y
 CONFIG_PINCTRL_IMX6=y
+CONFIG_POWER_LEGACY=y
 CONFIG_DM_REGULATOR=y
 CONFIG_DM_REGULATOR_FIXED=y
+CONFIG_POWER_I2C=y
 CONFIG_CONS_INDEX=2
 CONFIG_DM_SERIAL=y
 CONFIG_MXC_UART=y
diff --git a/configs/hikey_defconfig b/configs/hikey_defconfig
index bf8ac07..5d3d28d 100644
--- a/configs/hikey_defconfig
+++ b/configs/hikey_defconfig
@@ -26,6 +26,7 @@
 CONFIG_MMC_DW=y
 CONFIG_MMC_DW_K3=y
 CONFIG_DM_ETH=y
+CONFIG_POWER_LEGACY=y
 CONFIG_CONS_INDEX=4
 CONFIG_USB=y
 CONFIG_USB_DWC2=y
diff --git a/configs/imx8mp_evk_defconfig b/configs/imx8mp_evk_defconfig
index 20a0a42..0abe137 100644
--- a/configs/imx8mp_evk_defconfig
+++ b/configs/imx8mp_evk_defconfig
@@ -81,9 +81,11 @@
 CONFIG_PINCTRL=y
 CONFIG_SPL_PINCTRL=y
 CONFIG_PINCTRL_IMX8M=y
+CONFIG_SPL_POWER_LEGACY=y
 CONFIG_DM_REGULATOR=y
 CONFIG_DM_REGULATOR_FIXED=y
 CONFIG_DM_REGULATOR_GPIO=y
+CONFIG_SPL_POWER_I2C=y
 CONFIG_MXC_UART=y
 CONFIG_SYSRESET=y
 CONFIG_SPL_SYSRESET=y
diff --git a/configs/imx8mq_evk_defconfig b/configs/imx8mq_evk_defconfig
index 083eba6..62fe6f1 100644
--- a/configs/imx8mq_evk_defconfig
+++ b/configs/imx8mq_evk_defconfig
@@ -52,11 +52,13 @@
 CONFIG_PHY_IMX8MQ_USB=y
 CONFIG_PINCTRL=y
 CONFIG_PINCTRL_IMX8M=y
+CONFIG_SPL_POWER_LEGACY=y
 CONFIG_POWER_DOMAIN=y
 CONFIG_IMX8M_POWER_DOMAIN=y
 CONFIG_DM_REGULATOR=y
 CONFIG_DM_REGULATOR_FIXED=y
 CONFIG_DM_REGULATOR_GPIO=y
+CONFIG_SPL_POWER_I2C=y
 CONFIG_DM_RESET=y
 CONFIG_MXC_UART=y
 CONFIG_DM_THERMAL=y
diff --git a/configs/imx8mq_phanbell_defconfig b/configs/imx8mq_phanbell_defconfig
index e5d5d9e..911c339 100644
--- a/configs/imx8mq_phanbell_defconfig
+++ b/configs/imx8mq_phanbell_defconfig
@@ -54,11 +54,13 @@
 CONFIG_DM_ETH=y
 CONFIG_PINCTRL=y
 CONFIG_PINCTRL_IMX8M=y
+CONFIG_SPL_POWER_LEGACY=y
 CONFIG_POWER_DOMAIN=y
 CONFIG_IMX8M_POWER_DOMAIN=y
 CONFIG_DM_REGULATOR=y
 CONFIG_DM_REGULATOR_FIXED=y
 CONFIG_DM_REGULATOR_GPIO=y
+CONFIG_SPL_POWER_I2C=y
 CONFIG_DM_RESET=y
 CONFIG_MXC_UART=y
 CONFIG_DM_THERMAL=y
diff --git a/configs/ls1046ardb_emmc_defconfig b/configs/ls1046ardb_emmc_defconfig
index e79da63..e5402a2 100644
--- a/configs/ls1046ardb_emmc_defconfig
+++ b/configs/ls1046ardb_emmc_defconfig
@@ -83,6 +83,8 @@
 CONFIG_PCI=y
 CONFIG_PCIE_LAYERSCAPE_RC=y
 CONFIG_PCIE_LAYERSCAPE_EP=y
+CONFIG_POWER_LEGACY=y
+CONFIG_POWER_I2C=y
 CONFIG_SYS_QE_FMAN_FW_IN_MMC=y
 CONFIG_DM_SCSI=y
 CONFIG_SYS_NS16550=y
diff --git a/configs/ls1046ardb_qspi_SECURE_BOOT_defconfig b/configs/ls1046ardb_qspi_SECURE_BOOT_defconfig
index bfaf8c7..cd9e3a4 100644
--- a/configs/ls1046ardb_qspi_SECURE_BOOT_defconfig
+++ b/configs/ls1046ardb_qspi_SECURE_BOOT_defconfig
@@ -65,6 +65,8 @@
 CONFIG_PCI=y
 CONFIG_PCIE_LAYERSCAPE_RC=y
 CONFIG_PCIE_LAYERSCAPE_EP=y
+CONFIG_POWER_LEGACY=y
+CONFIG_POWER_I2C=y
 CONFIG_SYS_QE_FMAN_FW_IN_SPIFLASH=y
 CONFIG_DM_SCSI=y
 CONFIG_SYS_NS16550=y
diff --git a/configs/ls1046ardb_qspi_defconfig b/configs/ls1046ardb_qspi_defconfig
index 36b812d..93f0e88 100644
--- a/configs/ls1046ardb_qspi_defconfig
+++ b/configs/ls1046ardb_qspi_defconfig
@@ -69,6 +69,8 @@
 CONFIG_PCI=y
 CONFIG_PCIE_LAYERSCAPE_RC=y
 CONFIG_PCIE_LAYERSCAPE_EP=y
+CONFIG_POWER_LEGACY=y
+CONFIG_POWER_I2C=y
 CONFIG_SYS_QE_FMAN_FW_IN_SPIFLASH=y
 CONFIG_DM_SCSI=y
 CONFIG_SYS_NS16550=y
diff --git a/configs/ls1046ardb_qspi_spl_defconfig b/configs/ls1046ardb_qspi_spl_defconfig
index 1df12b2..a88baaf 100644
--- a/configs/ls1046ardb_qspi_spl_defconfig
+++ b/configs/ls1046ardb_qspi_spl_defconfig
@@ -87,6 +87,8 @@
 CONFIG_PCI=y
 CONFIG_PCIE_LAYERSCAPE_RC=y
 CONFIG_PCIE_LAYERSCAPE_EP=y
+CONFIG_POWER_LEGACY=y
+CONFIG_POWER_I2C=y
 CONFIG_SYS_QE_FMAN_FW_IN_SPIFLASH=y
 CONFIG_DM_SCSI=y
 CONFIG_SYS_NS16550=y
diff --git a/configs/ls1046ardb_sdcard_SECURE_BOOT_defconfig b/configs/ls1046ardb_sdcard_SECURE_BOOT_defconfig
index dabd609..36b91a0 100644
--- a/configs/ls1046ardb_sdcard_SECURE_BOOT_defconfig
+++ b/configs/ls1046ardb_sdcard_SECURE_BOOT_defconfig
@@ -81,6 +81,8 @@
 CONFIG_PCI=y
 CONFIG_PCIE_LAYERSCAPE_RC=y
 CONFIG_PCIE_LAYERSCAPE_EP=y
+CONFIG_POWER_LEGACY=y
+CONFIG_POWER_I2C=y
 CONFIG_SYS_QE_FMAN_FW_IN_MMC=y
 CONFIG_SYS_NS16550=y
 CONFIG_SPI=y
diff --git a/configs/ls1046ardb_sdcard_defconfig b/configs/ls1046ardb_sdcard_defconfig
index 1e5ec89..9ed24bb 100644
--- a/configs/ls1046ardb_sdcard_defconfig
+++ b/configs/ls1046ardb_sdcard_defconfig
@@ -81,6 +81,8 @@
 CONFIG_PCI=y
 CONFIG_PCIE_LAYERSCAPE_RC=y
 CONFIG_PCIE_LAYERSCAPE_EP=y
+CONFIG_POWER_LEGACY=y
+CONFIG_POWER_I2C=y
 CONFIG_SYS_QE_FMAN_FW_IN_MMC=y
 CONFIG_DM_SCSI=y
 CONFIG_SYS_NS16550=y
diff --git a/configs/ls1046ardb_tfa_SECURE_BOOT_defconfig b/configs/ls1046ardb_tfa_SECURE_BOOT_defconfig
index 217dc7f..a14df4d 100644
--- a/configs/ls1046ardb_tfa_SECURE_BOOT_defconfig
+++ b/configs/ls1046ardb_tfa_SECURE_BOOT_defconfig
@@ -62,6 +62,8 @@
 CONFIG_PCI=y
 CONFIG_PCIE_LAYERSCAPE_RC=y
 CONFIG_PCIE_LAYERSCAPE_EP=y
+CONFIG_POWER_LEGACY=y
+CONFIG_POWER_I2C=y
 CONFIG_DM_SCSI=y
 CONFIG_SYS_NS16550=y
 CONFIG_SPI=y
diff --git a/configs/ls1046ardb_tfa_defconfig b/configs/ls1046ardb_tfa_defconfig
index 445fad3..85491a3 100644
--- a/configs/ls1046ardb_tfa_defconfig
+++ b/configs/ls1046ardb_tfa_defconfig
@@ -68,6 +68,8 @@
 CONFIG_PCI=y
 CONFIG_PCIE_LAYERSCAPE_RC=y
 CONFIG_PCIE_LAYERSCAPE_EP=y
+CONFIG_POWER_LEGACY=y
+CONFIG_POWER_I2C=y
 CONFIG_DM_SCSI=y
 CONFIG_SYS_NS16550=y
 CONFIG_SPI=y
diff --git a/configs/mx51evk_defconfig b/configs/mx51evk_defconfig
index bc2dfde..f9ca4ee 100644
--- a/configs/mx51evk_defconfig
+++ b/configs/mx51evk_defconfig
@@ -42,6 +42,7 @@
 CONFIG_MII=y
 CONFIG_PINCTRL=y
 CONFIG_PINCTRL_IMX5=y
+CONFIG_POWER_LEGACY=y
 CONFIG_DM_REGULATOR=y
 CONFIG_DM_REGULATOR_FIXED=y
 CONFIG_DM_REGULATOR_GPIO=y
diff --git a/configs/mx53loco_defconfig b/configs/mx53loco_defconfig
index 9bd0d77..04df33c 100644
--- a/configs/mx53loco_defconfig
+++ b/configs/mx53loco_defconfig
@@ -48,9 +48,11 @@
 CONFIG_MII=y
 CONFIG_PINCTRL=y
 CONFIG_PINCTRL_IMX5=y
+CONFIG_POWER_LEGACY=y
 CONFIG_DM_REGULATOR=y
 CONFIG_DM_REGULATOR_FIXED=y
 CONFIG_DM_REGULATOR_GPIO=y
+CONFIG_POWER_I2C=y
 CONFIG_MXC_UART=y
 CONFIG_USB=y
 CONFIG_USB_EHCI_MX5=y
diff --git a/configs/mx6sabreauto_defconfig b/configs/mx6sabreauto_defconfig
index 3be9064..4427079 100644
--- a/configs/mx6sabreauto_defconfig
+++ b/configs/mx6sabreauto_defconfig
@@ -90,7 +90,9 @@
 CONFIG_MII=y
 CONFIG_PINCTRL=y
 CONFIG_PINCTRL_IMX6=y
+CONFIG_POWER_LEGACY=y
 CONFIG_DM_REGULATOR=y
+CONFIG_POWER_I2C=y
 CONFIG_MXC_UART=y
 CONFIG_SPI=y
 CONFIG_DM_SPI=y
diff --git a/configs/mx6sabresd_defconfig b/configs/mx6sabresd_defconfig
index 9431bff..5216bca 100644
--- a/configs/mx6sabresd_defconfig
+++ b/configs/mx6sabresd_defconfig
@@ -99,8 +99,10 @@
 CONFIG_PCI=y
 CONFIG_PINCTRL=y
 CONFIG_PINCTRL_IMX6=y
+CONFIG_POWER_LEGACY=y
 CONFIG_DM_REGULATOR=y
 CONFIG_DM_REGULATOR_FIXED=y
+CONFIG_POWER_I2C=y
 CONFIG_MXC_UART=y
 CONFIG_SPI=y
 CONFIG_DM_SPI=y
diff --git a/configs/novena_defconfig b/configs/novena_defconfig
index 0770dd1..81f1534 100644
--- a/configs/novena_defconfig
+++ b/configs/novena_defconfig
@@ -70,6 +70,8 @@
 CONFIG_PCI=y
 CONFIG_PINCTRL=y
 CONFIG_PINCTRL_IMX6=y
+CONFIG_POWER_LEGACY=y
+CONFIG_POWER_I2C=y
 CONFIG_MXC_UART=y
 CONFIG_DM_THERMAL=y
 CONFIG_IMX_THERMAL=y
diff --git a/configs/phycore-imx8mp_defconfig b/configs/phycore-imx8mp_defconfig
index 7d28713..f22798e 100644
--- a/configs/phycore-imx8mp_defconfig
+++ b/configs/phycore-imx8mp_defconfig
@@ -92,9 +92,11 @@
 CONFIG_PINCTRL=y
 CONFIG_SPL_PINCTRL=y
 CONFIG_PINCTRL_IMX8M=y
+CONFIG_SPL_POWER_LEGACY=y
 CONFIG_DM_REGULATOR=y
 CONFIG_DM_REGULATOR_FIXED=y
 CONFIG_DM_REGULATOR_GPIO=y
+CONFIG_SPL_POWER_I2C=y
 CONFIG_MXC_UART=y
 CONFIG_SYSRESET=y
 CONFIG_SPL_SYSRESET=y
diff --git a/configs/pico-dwarf-imx7d_defconfig b/configs/pico-dwarf-imx7d_defconfig
index 7942d6f..1be6605 100644
--- a/configs/pico-dwarf-imx7d_defconfig
+++ b/configs/pico-dwarf-imx7d_defconfig
@@ -72,6 +72,8 @@
 CONFIG_MII=y
 CONFIG_PINCTRL=y
 CONFIG_PINCTRL_IMX7=y
+CONFIG_POWER_LEGACY=y
+CONFIG_POWER_I2C=y
 CONFIG_MXC_UART=y
 CONFIG_IMX_THERMAL=y
 CONFIG_USB=y
diff --git a/configs/pico-hobbit-imx7d_defconfig b/configs/pico-hobbit-imx7d_defconfig
index a1851e1..a0c034c 100644
--- a/configs/pico-hobbit-imx7d_defconfig
+++ b/configs/pico-hobbit-imx7d_defconfig
@@ -72,6 +72,8 @@
 CONFIG_MII=y
 CONFIG_PINCTRL=y
 CONFIG_PINCTRL_IMX7=y
+CONFIG_POWER_LEGACY=y
+CONFIG_POWER_I2C=y
 CONFIG_MXC_UART=y
 CONFIG_IMX_THERMAL=y
 CONFIG_USB=y
diff --git a/configs/pico-imx7d_bl33_defconfig b/configs/pico-imx7d_bl33_defconfig
index 096a045..df81717 100644
--- a/configs/pico-imx7d_bl33_defconfig
+++ b/configs/pico-imx7d_bl33_defconfig
@@ -66,6 +66,8 @@
 CONFIG_MII=y
 CONFIG_PINCTRL=y
 CONFIG_PINCTRL_IMX7=y
+CONFIG_POWER_LEGACY=y
+CONFIG_POWER_I2C=y
 CONFIG_CONS_INDEX=4
 CONFIG_MXC_UART=y
 CONFIG_IMX_THERMAL=y
diff --git a/configs/pico-imx7d_defconfig b/configs/pico-imx7d_defconfig
index 4ba23a5..7d53562 100644
--- a/configs/pico-imx7d_defconfig
+++ b/configs/pico-imx7d_defconfig
@@ -72,6 +72,8 @@
 CONFIG_MII=y
 CONFIG_PINCTRL=y
 CONFIG_PINCTRL_IMX7=y
+CONFIG_POWER_LEGACY=y
+CONFIG_POWER_I2C=y
 CONFIG_MXC_UART=y
 CONFIG_IMX_THERMAL=y
 CONFIG_USB=y
diff --git a/configs/pico-imx8mq_defconfig b/configs/pico-imx8mq_defconfig
index 5b1dc81..b90a492 100644
--- a/configs/pico-imx8mq_defconfig
+++ b/configs/pico-imx8mq_defconfig
@@ -52,11 +52,13 @@
 CONFIG_DM_ETH=y
 CONFIG_PINCTRL=y
 CONFIG_PINCTRL_IMX8M=y
+CONFIG_SPL_POWER_LEGACY=y
 CONFIG_POWER_DOMAIN=y
 CONFIG_IMX8M_POWER_DOMAIN=y
 CONFIG_DM_REGULATOR=y
 CONFIG_DM_REGULATOR_FIXED=y
 CONFIG_DM_REGULATOR_GPIO=y
+CONFIG_SPL_POWER_I2C=y
 CONFIG_DM_RESET=y
 CONFIG_MXC_UART=y
 CONFIG_DM_THERMAL=y
diff --git a/configs/pico-nymph-imx7d_defconfig b/configs/pico-nymph-imx7d_defconfig
index 7942d6f..1be6605 100644
--- a/configs/pico-nymph-imx7d_defconfig
+++ b/configs/pico-nymph-imx7d_defconfig
@@ -72,6 +72,8 @@
 CONFIG_MII=y
 CONFIG_PINCTRL=y
 CONFIG_PINCTRL_IMX7=y
+CONFIG_POWER_LEGACY=y
+CONFIG_POWER_I2C=y
 CONFIG_MXC_UART=y
 CONFIG_IMX_THERMAL=y
 CONFIG_USB=y
diff --git a/configs/pico-pi-imx7d_defconfig b/configs/pico-pi-imx7d_defconfig
index 3f75141..e0be1b0 100644
--- a/configs/pico-pi-imx7d_defconfig
+++ b/configs/pico-pi-imx7d_defconfig
@@ -72,6 +72,8 @@
 CONFIG_MII=y
 CONFIG_PINCTRL=y
 CONFIG_PINCTRL_IMX7=y
+CONFIG_POWER_LEGACY=y
+CONFIG_POWER_I2C=y
 CONFIG_MXC_UART=y
 CONFIG_IMX_THERMAL=y
 CONFIG_USB=y
diff --git a/configs/udoo_neo_defconfig b/configs/udoo_neo_defconfig
index 5c463ea..2f549b35 100644
--- a/configs/udoo_neo_defconfig
+++ b/configs/udoo_neo_defconfig
@@ -50,5 +50,7 @@
 CONFIG_MII=y
 CONFIG_PINCTRL=y
 CONFIG_PINCTRL_IMX6=y
+CONFIG_POWER_LEGACY=y
+CONFIG_POWER_I2C=y
 CONFIG_MXC_UART=y
 CONFIG_IMX_THERMAL=y
diff --git a/configs/vining_2000_defconfig b/configs/vining_2000_defconfig
index 8c79ff3..24989ff 100644
--- a/configs/vining_2000_defconfig
+++ b/configs/vining_2000_defconfig
@@ -78,6 +78,8 @@
 CONFIG_PCI=y
 CONFIG_PINCTRL=y
 CONFIG_PINCTRL_IMX6=y
+CONFIG_POWER_LEGACY=y
+CONFIG_POWER_I2C=y
 CONFIG_PWM_IMX=y
 CONFIG_DM_SERIAL=y
 CONFIG_MXC_UART=y
diff --git a/configs/warp_defconfig b/configs/warp_defconfig
index 015a153..3d6c672 100644
--- a/configs/warp_defconfig
+++ b/configs/warp_defconfig
@@ -38,6 +38,8 @@
 CONFIG_SYS_I2C_MXC=y
 CONFIG_SUPPORT_EMMC_BOOT=y
 CONFIG_FSL_USDHC=y
+CONFIG_POWER_LEGACY=y
+CONFIG_POWER_I2C=y
 CONFIG_MXC_UART=y
 CONFIG_USB=y
 CONFIG_WATCHDOG_TIMEOUT_MSECS=30000
diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig
index 26257a7..f5681c9 100644
--- a/drivers/power/Kconfig
+++ b/drivers/power/Kconfig
@@ -1,5 +1,34 @@
 menu "Power"
 
+config POWER_LEGACY
+	bool "Legacy power support"
+	help
+	  Note: This is a legacy option. Use DM_PMIC instead.
+
+	  Enable support for power control in U-Boot. This includes support
+	  for PMICs (Power-management Integrated Circuits) and some of the
+	  features provided by PMICs. In particular, voltage regulators can
+	  be used to enable/disable power and vary its voltage. That can be
+	  useful in U-Boot to turn on boot peripherals and adjust CPU voltage
+	  so that the clock speed can be increased. This enables the drivers
+	  in drivers/power, drivers/power/pmic and drivers/power/regulator
+	  as part of a build.
+
+config SPL_POWER_LEGACY
+	bool "Legacy power support in SPL"
+	default y if POWER_LEGACY
+	help
+	  Note: This is a legacy option. Use SPL_DM_PMIC instead.
+
+	  Enable support for power control in SPL. This includes support
+	  for PMICs (Power-management Integrated Circuits) and some of the
+	  features provided by PMICs. In particular, voltage regulators can
+	  be used to enable/disable power and vary its voltage. That can be
+	  useful in SPL to turn on boot peripherals and adjust CPU voltage
+	  so that the clock speed can be increased. This enables the drivers
+	  in drivers/power, drivers/power/pmic and drivers/power/regulator
+	  as part of a build.
+
 source "drivers/power/acpi_pmc/Kconfig"
 
 source "drivers/power/domain/Kconfig"
@@ -383,4 +412,25 @@
 	  This adds poweroff driver for mt6323
 	  this pmic is used on mt7623 / Bananapi R2
 
+config POWER_I2C
+	bool "I2C-based power control for legacy power"
+	depends on POWER_LEGACY
+	help
+	  Enable this to use the I2C driver designed for the legacy PMIC
+	  interface.
+
+	  Not to be used for new designs and existing ones should be moved to
+	  the new PMIC interface based on driver model.
+
+config SPL_POWER_I2C
+	bool "I2C-based power control for legacy power"
+	depends on SPL_POWER_LEGACY
+	default y if POWER_I2C
+	help
+	  Enable this to use the I2C driver designed for the legacy PMIC
+	  interface.
+
+	  Not to be used for new designs and existing ones should be moved to
+	  the new PMIC interface based on driver model.
+
 endmenu
diff --git a/drivers/power/Makefile b/drivers/power/Makefile
index ab52bc1..801b727 100644
--- a/drivers/power/Makefile
+++ b/drivers/power/Makefile
@@ -16,9 +16,9 @@
 obj-$(CONFIG_TWL4030_POWER)	+= twl4030.o
 obj-$(CONFIG_TWL6030_POWER)	+= twl6030.o
 obj-$(CONFIG_PALMAS_POWER)	+= palmas.o
-obj-$(CONFIG_POWER_LEGACY) += power_core.o
+obj-$(CONFIG_$(SPL_TPL_)POWER_LEGACY) += power_core.o
 obj-$(CONFIG_DIALOG_POWER) += power_dialog.o
 obj-$(CONFIG_POWER_FSL) += power_fsl.o
-obj-$(CONFIG_POWER_I2C) += power_i2c.o
+obj-$(CONFIG_$(SPL_TPL_)POWER_I2C) += power_i2c.o
 obj-$(CONFIG_POWER_SPI) += power_spi.o
 obj-$(CONFIG_POWER_MT6323) += mt6323.o
diff --git a/include/configs/am43xx_evm.h b/include/configs/am43xx_evm.h
index ac735f8..d4d463d 100644
--- a/include/configs/am43xx_evm.h
+++ b/include/configs/am43xx_evm.h
@@ -23,10 +23,6 @@
 /* I2C Configuration */
 
 /* Power */
-#if !CONFIG_IS_ENABLED(DM_I2C)
-#define CONFIG_POWER_LEGACY
-#define CONFIG_POWER_I2C
-#endif
 #define CONFIG_POWER_TPS65218
 #define CONFIG_POWER_TPS62362
 
diff --git a/include/configs/cl-som-imx7.h b/include/configs/cl-som-imx7.h
index 0692653..ebfe356 100644
--- a/include/configs/cl-som-imx7.h
+++ b/include/configs/cl-som-imx7.h
@@ -22,8 +22,6 @@
 #define IMX_FEC_BASE			ENET_IPS_BASE_ADDR
 
 /* PMIC */
-#define CONFIG_POWER_LEGACY
-#define CONFIG_POWER_I2C
 #define CONFIG_POWER_PFUZE3000
 #define CONFIG_POWER_PFUZE3000_I2C_ADDR	0x08
 
diff --git a/include/configs/cm_t43.h b/include/configs/cm_t43.h
index 32d2581..a290cf0 100644
--- a/include/configs/cm_t43.h
+++ b/include/configs/cm_t43.h
@@ -50,8 +50,6 @@
 #define CONFIG_AM437X_USB2PHY2_HOST
 
 /* Power */
-#define CONFIG_POWER_LEGACY
-#define CONFIG_POWER_I2C
 #define CONFIG_POWER_TPS65218
 
 /* Enabling L2 Cache */
diff --git a/include/configs/el6x_common.h b/include/configs/el6x_common.h
index f8af7c4..279d712 100644
--- a/include/configs/el6x_common.h
+++ b/include/configs/el6x_common.h
@@ -23,8 +23,6 @@
 #define CONFIG_SYS_FSL_USDHC_NUM	2
 
 /* PMIC */
-#define CONFIG_POWER_LEGACY
-#define CONFIG_POWER_I2C
 #define CONFIG_POWER_PFUZE100
 #define CONFIG_POWER_PFUZE100_I2C_ADDR	0x08
 
diff --git a/include/configs/gw_ventana.h b/include/configs/gw_ventana.h
index 615cc0b..012c9b6 100644
--- a/include/configs/gw_ventana.h
+++ b/include/configs/gw_ventana.h
@@ -65,8 +65,6 @@
 /*
  * PMIC
  */
-#define CONFIG_POWER_LEGACY
-#define CONFIG_POWER_I2C
 #define CONFIG_POWER_PFUZE100
 #define CONFIG_POWER_PFUZE100_I2C_ADDR	0x08
 #define CONFIG_POWER_LTC3676
diff --git a/include/configs/hikey.h b/include/configs/hikey.h
index f6685a9..387971c 100644
--- a/include/configs/hikey.h
+++ b/include/configs/hikey.h
@@ -13,7 +13,6 @@
 
 #include <linux/sizes.h>
 
-#define CONFIG_POWER_LEGACY
 #define CONFIG_POWER_HI6553
 
 #define CONFIG_REMAKE_ELF
diff --git a/include/configs/imx8mp_evk.h b/include/configs/imx8mp_evk.h
index 1641792..bec6c1d 100644
--- a/include/configs/imx8mp_evk.h
+++ b/include/configs/imx8mp_evk.h
@@ -31,8 +31,6 @@
 
 #undef CONFIG_DM_MMC
 
-#define CONFIG_POWER_LEGACY
-#define CONFIG_POWER_I2C
 #define CONFIG_POWER_PCA9450
 
 #endif
diff --git a/include/configs/imx8mq_evk.h b/include/configs/imx8mq_evk.h
index d694379..ff4f789 100644
--- a/include/configs/imx8mq_evk.h
+++ b/include/configs/imx8mq_evk.h
@@ -44,8 +44,6 @@
 
 #define CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
 
-#define CONFIG_POWER_LEGACY
-#define CONFIG_POWER_I2C
 #define CONFIG_POWER_PFUZE100
 #define CONFIG_POWER_PFUZE100_I2C_ADDR 0x08
 #endif
diff --git a/include/configs/imx8mq_phanbell.h b/include/configs/imx8mq_phanbell.h
index ff8a168..c04c019 100644
--- a/include/configs/imx8mq_phanbell.h
+++ b/include/configs/imx8mq_phanbell.h
@@ -40,9 +40,6 @@
 #undef CONFIG_DM_MMC
 
 #define CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
-
-#define CONFIG_POWER_LEGACY
-#define CONFIG_POWER_I2C
 #endif
 
 #define CONFIG_REMAKE_ELF
diff --git a/include/configs/ls1046ardb.h b/include/configs/ls1046ardb.h
index b40a696..d3f5d8c 100644
--- a/include/configs/ls1046ardb.h
+++ b/include/configs/ls1046ardb.h
@@ -124,10 +124,6 @@
 #define I2C_RETIMER_ADDR			0x18
 
 /* PMIC */
-#define CONFIG_POWER_LEGACY
-#ifdef CONFIG_POWER_LEGACY
-#define CONFIG_POWER_I2C
-#endif
 
 /*
  * Environment
diff --git a/include/configs/mx51evk.h b/include/configs/mx51evk.h
index bd2d0e5..065e8c7 100644
--- a/include/configs/mx51evk.h
+++ b/include/configs/mx51evk.h
@@ -30,7 +30,6 @@
 #define CONFIG_MXC_UART_BASE	UART1_BASE
 
 /* PMIC Controller */
-#define CONFIG_POWER_LEGACY
 #define CONFIG_POWER_SPI
 #define CONFIG_POWER_FSL
 #define CONFIG_FSL_PMIC_BUS	0
diff --git a/include/configs/mx53loco.h b/include/configs/mx53loco.h
index a546e96..50fc962 100644
--- a/include/configs/mx53loco.h
+++ b/include/configs/mx53loco.h
@@ -33,8 +33,6 @@
 #define CONFIG_MXC_USB_FLAGS	0
 
 /* PMIC Controller */
-#define CONFIG_POWER_LEGACY
-#define CONFIG_POWER_I2C
 #define CONFIG_DIALOG_POWER
 #define CONFIG_POWER_FSL
 #define CONFIG_POWER_FSL_MC13892
diff --git a/include/configs/mx6sabreauto.h b/include/configs/mx6sabreauto.h
index ccf631d..1bfc035 100644
--- a/include/configs/mx6sabreauto.h
+++ b/include/configs/mx6sabreauto.h
@@ -59,8 +59,6 @@
 /* DMA stuff, needed for GPMI/MXS NAND support */
 
 /* PMIC */
-#define CONFIG_POWER_LEGACY
-#define CONFIG_POWER_I2C
 #define CONFIG_POWER_PFUZE100
 #define CONFIG_POWER_PFUZE100_I2C_ADDR	0x08
 
diff --git a/include/configs/mx6sabresd.h b/include/configs/mx6sabresd.h
index ee75ada..a9f353d 100644
--- a/include/configs/mx6sabresd.h
+++ b/include/configs/mx6sabresd.h
@@ -38,8 +38,6 @@
 #endif
 
 /* PMIC */
-#define CONFIG_POWER_LEGACY
-#define CONFIG_POWER_I2C
 #define CONFIG_POWER_PFUZE100
 #define CONFIG_POWER_PFUZE100_I2C_ADDR	0x08
 
diff --git a/include/configs/novena.h b/include/configs/novena.h
index e39191f..46c5301 100644
--- a/include/configs/novena.h
+++ b/include/configs/novena.h
@@ -68,8 +68,6 @@
 #endif
 
 /* PMIC */
-#define CONFIG_POWER_LEGACY
-#define CONFIG_POWER_I2C
 #define CONFIG_POWER_PFUZE100
 #define CONFIG_POWER_PFUZE100_I2C_ADDR	0x08
 
diff --git a/include/configs/phycore_imx8mp.h b/include/configs/phycore_imx8mp.h
index f9686e1..874c94e 100644
--- a/include/configs/phycore_imx8mp.h
+++ b/include/configs/phycore_imx8mp.h
@@ -29,8 +29,6 @@
 
 #define CONFIG_SPL_ABORT_ON_RAW_IMAGE
 
-#define CONFIG_POWER_LEGACY
-#define CONFIG_POWER_I2C
 #define CONFIG_POWER_PCA9450
 
 #endif
diff --git a/include/configs/pico-imx7d.h b/include/configs/pico-imx7d.h
index a0e782d..36c5792 100644
--- a/include/configs/pico-imx7d.h
+++ b/include/configs/pico-imx7d.h
@@ -122,8 +122,6 @@
 	(CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_SP_OFFSET)
 
 /* PMIC */
-#define CONFIG_POWER_LEGACY
-#define CONFIG_POWER_I2C
 #define CONFIG_POWER_PFUZE3000
 #define CONFIG_POWER_PFUZE3000_I2C_ADDR	0x08
 
diff --git a/include/configs/pico-imx8mq.h b/include/configs/pico-imx8mq.h
index c67264d..6c64239 100644
--- a/include/configs/pico-imx8mq.h
+++ b/include/configs/pico-imx8mq.h
@@ -40,9 +40,6 @@
 #undef CONFIG_DM_MMC
 
 #define CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
-
-#define CONFIG_POWER_LEGACY
-#define CONFIG_POWER_I2C
 #endif
 
 #define CONFIG_REMAKE_ELF
diff --git a/include/configs/tqma6.h b/include/configs/tqma6.h
index 11ad2f7..1efe9d5 100644
--- a/include/configs/tqma6.h
+++ b/include/configs/tqma6.h
@@ -42,8 +42,6 @@
 #define CONFIG_SYS_I2C_EEPROM_PAGE_WRITE_DELAY_MS	20
 
 #if !defined(CONFIG_DM_PMIC)
-#define CONFIG_POWER_LEGACY
-#define CONFIG_POWER_I2C
 #define CONFIG_POWER_PFUZE100
 #define CONFIG_POWER_PFUZE100_I2C_ADDR	0x08
 #define TQMA6_PFUZE100_I2C_BUS		2
diff --git a/include/configs/udoo_neo.h b/include/configs/udoo_neo.h
index d51a25d..b06abc9 100644
--- a/include/configs/udoo_neo.h
+++ b/include/configs/udoo_neo.h
@@ -68,8 +68,6 @@
 	(CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_SP_OFFSET)
 
 /* PMIC */
-#define CONFIG_POWER_LEGACY
-#define CONFIG_POWER_I2C
 #define CONFIG_POWER_PFUZE3000
 #define CONFIG_POWER_PFUZE3000_I2C_ADDR	0x08
 #define PFUZE3000_I2C_BUS	0
diff --git a/include/configs/vining_2000.h b/include/configs/vining_2000.h
index 4c34bec..dcdaffc 100644
--- a/include/configs/vining_2000.h
+++ b/include/configs/vining_2000.h
@@ -40,8 +40,6 @@
 #define CONFIG_SYS_FSL_ESDHC_ADDR	USDHC4_BASE_ADDR
 
 /* PMIC */
-#define CONFIG_POWER_LEGACY
-#define CONFIG_POWER_I2C
 #define CONFIG_POWER_PFUZE100
 #define CONFIG_POWER_PFUZE100_I2C_ADDR	0x08
 
diff --git a/include/configs/warp.h b/include/configs/warp.h
index 29f69bb7..11a9b31 100644
--- a/include/configs/warp.h
+++ b/include/configs/warp.h
@@ -52,8 +52,6 @@
 /* I2C Configs */
 
 /* PMIC */
-#define CONFIG_POWER_LEGACY
-#define CONFIG_POWER_I2C
 
 #define CONFIG_EXTRA_ENV_SETTINGS \
 	"script=boot.scr\0" \
diff --git a/include/power/max77686_pmic.h b/include/power/max77686_pmic.h
index 95ba61d..cf476c8 100644
--- a/include/power/max77686_pmic.h
+++ b/include/power/max77686_pmic.h
@@ -154,7 +154,7 @@
 	OPMODE_ON,
 };
 
-#ifdef CONFIG_POWER_LEGACY
+#if CONFIG_IS_ENABLED(POWER_LEGACY)
 int max77686_set_ldo_voltage(struct pmic *p, int ldo, ulong uV);
 int max77686_set_ldo_mode(struct pmic *p, int ldo, char opmode);
 int max77686_set_buck_voltage(struct pmic *p, int buck, ulong uV);
diff --git a/include/power/pmic.h b/include/power/pmic.h
index a10e173..97f855c 100644
--- a/include/power/pmic.h
+++ b/include/power/pmic.h
@@ -18,7 +18,7 @@
 enum { PMIC_I2C, PMIC_SPI, PMIC_NONE};
 
 /* TODO: Change to !CONFIG_IS_ENABLED(DM_PMIC) when SPL_DM_PMIC exists */
-#ifdef CONFIG_POWER_LEGACY
+#if CONFIG_IS_ENABLED(POWER_LEGACY)
 enum { I2C_PMIC, I2C_NUM, };
 enum { PMIC_READ, PMIC_WRITE, };
 enum { PMIC_SENSOR_BYTE_ORDER_LITTLE, PMIC_SENSOR_BYTE_ORDER_BIG, };
@@ -83,7 +83,7 @@
 	struct pmic *parent;
 	struct list_head list;
 };
-#endif /* CONFIG_POWER_LEGACY */
+#endif /* CONFIG_IS_ENABLED(POWER_LEGACY) */
 
 /* TODO: Change to CONFIG_IS_ENABLED(DM_PMIC) when SPL_DM_PMIC exists */
 #ifdef CONFIG_DM_PMIC
@@ -311,7 +311,7 @@
 #endif /* DM_PMIC */
 
 /* TODO: Change to CONFIG_IS_ENABLED(DM_PMIC) when SPL_DM_PMIC exists */
-#ifdef CONFIG_POWER_LEGACY
+#if CONFIG_IS_ENABLED(POWER_LEGACY)
 
 /* Legacy API, do not use */
 int pmic_init(unsigned char bus);
@@ -324,7 +324,7 @@
 int pmic_reg_read(struct pmic *p, u32 reg, u32 *val);
 int pmic_reg_write(struct pmic *p, u32 reg, u32 val);
 int pmic_set_output(struct pmic *p, u32 reg, int ldo, int on);
-#endif /* CONFIG_POWER_LEGACY */
+#endif /* CONFIG_IS_ENABLED(POWER_LEGACY) */
 
 #define pmic_i2c_addr (p->hw.i2c.addr)
 #define pmic_i2c_tx_num (p->hw.i2c.tx_num)
diff --git a/scripts/config_whitelist.txt b/scripts/config_whitelist.txt
index 50e607f..6abb18b 100644
--- a/scripts/config_whitelist.txt
+++ b/scripts/config_whitelist.txt
@@ -1035,8 +1035,6 @@
 CONFIG_POWER_FSL
 CONFIG_POWER_FSL_MC13892
 CONFIG_POWER_HI6553
-CONFIG_POWER_I2C
-CONFIG_POWER_LEGACY
 CONFIG_POWER_LTC3676
 CONFIG_POWER_LTC3676_I2C_ADDR
 CONFIG_POWER_MAX77696_I2C_ADDR