regulator: rk8xx: Add CONFIG_SPL_REGULATOR_RK8XX
authorJustin Klaassen <justin@tidylabs.net>
Fri, 23 May 2025 16:53:39 +0000 (16:53 +0000)
committerKever Yang <kever.yang@rock-chips.com>
Fri, 6 Jun 2025 09:21:54 +0000 (17:21 +0800)
Allows use of the regulator functions of the RK8XX PMIC in SPL, which is
necessary to support the functionality of the Rockchip IO-domain driver
on relevant platforms.

Signed-off-by: Justin Klaassen <justin@tidylabs.net>
Reviewed-by: Quentin Schulz <quentin.schulz@cherry.de>
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
drivers/power/regulator/Kconfig
drivers/power/regulator/rk8xx.c

index 7ed435f..65b99e8 100644 (file)
@@ -264,6 +264,15 @@ config REGULATOR_RK8XX
        by the PMIC device. This driver is controlled by a device tree node
        which includes voltage limits.
 
+config SPL_REGULATOR_RK8XX
+       bool "Enable driver for RK8XX regulators in SPL"
+       depends on SPL_DM_REGULATOR && SPL_PMIC_RK8XX
+       help
+         Enable support for the regulator functions of the RK8XX PMIC in SPL. The
+         driver implements get/set api for the various BUCKS and LDOs supported
+         by the PMIC device. This driver is controlled by a device tree node
+         which includes voltage limits.
+
 config DM_REGULATOR_S2MPS11
        bool "Enable driver for S2MPS11 regulator"
        depends on DM_REGULATOR && PMIC_S2MPS11
index 368675e..88453bb 100644 (file)
 #include <power/pmic.h>
 #include <power/regulator.h>
 
-#ifndef CONFIG_XPL_BUILD
-#define ENABLE_DRIVER
-#endif
-
 /* Not used or exisit register and configure */
 #define NA                     0xff
 
@@ -202,7 +198,7 @@ static const struct rk8xx_reg_info rk818_buck[] = {
        { 1800000, 100000, REG_BUCK4_ON_VSEL, REG_BUCK4_SLP_VSEL, REG_BUCK4_CONFIG, RK818_BUCK4_VSEL_MASK, 0x00, 0x1f },
 };
 
-#ifdef ENABLE_DRIVER
+#if CONFIG_IS_ENABLED(REGULATOR_RK8XX)
 static const struct rk8xx_reg_info rk806_nldo[] = {
        /* nldo 1 */
        {  500000, 12500, RK806_NLDO_ON_VSEL(1), RK806_NLDO_SLP_VSEL(1), NA, RK806_NLDO_VSEL_MASK, 0x00, 0xe7},
@@ -454,7 +450,7 @@ static int _buck_set_enable(struct udevice *pmic, int buck, bool enable)
        return ret;
 }
 
-#ifdef ENABLE_DRIVER
+#if CONFIG_IS_ENABLED(REGULATOR_RK8XX)
 static int _buck_set_suspend_value(struct udevice *pmic, int buck, int uvolt)
 {
        const struct rk8xx_reg_info *info = get_buck_reg(pmic, buck, uvolt);