]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
regulator: rk8xx: Use buck variable consistently
authorJonas Karlman <jonas@kwiboo.se>
Tue, 17 Sep 2024 20:59:18 +0000 (20:59 +0000)
committerKever Yang <kever.yang@rock-chips.com>
Fri, 27 Sep 2024 10:20:49 +0000 (18:20 +0800)
The buck variable is zero based, i.e. buck=0 match BUCK1 in datasheet.

Remove any buck + 1 calculation to be more consistent in usage of the
buck variable across the different RK8xx variants in the driver.

Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
drivers/power/regulator/rk8xx.c

index b910943c2c4642b932adb1ab3167435dc1d348c7..375d06e3207f7381e18c121995f1978d7d7fdb2c 100644 (file)
@@ -381,7 +381,7 @@ static int _buck_set_value(struct udevice *pmic, int buck, int uvolt)
                val = ((uvolt - info->min_uv) / info->step_uv) + info->min_sel;
 
        debug("%s: volt=%d, buck=%d, reg=0x%x, mask=0x%x, val=0x%x\n",
-             __func__, uvolt, buck + 1, info->vsel_reg, mask, val);
+             __func__, uvolt, buck, info->vsel_reg, mask, val);
 
        if (priv->variant == RK816_ID) {
                pmic_clrsetbits(pmic, info->vsel_reg, mask, val);
@@ -470,7 +470,7 @@ static int _buck_set_suspend_value(struct udevice *pmic, int buck, int uvolt)
                val = ((uvolt - info->min_uv) / info->step_uv) + info->min_sel;
 
        debug("%s: volt=%d, buck=%d, reg=0x%x, mask=0x%x, val=0x%x\n",
-             __func__, uvolt, buck + 1, info->vsel_sleep_reg, mask, val);
+             __func__, uvolt, buck, info->vsel_sleep_reg, mask, val);
 
        return pmic_clrsetbits(pmic, info->vsel_sleep_reg, mask, val);
 }
@@ -539,9 +539,10 @@ static int _buck_set_suspend_enable(struct udevice *pmic, int buck, bool enable)
                {
                        u8 reg;
 
-                       if (buck + 1 >= 9) {
+                       if (buck >= 8) {
+                               /* BUCK9 and BUCK10 */
                                reg = RK806_POWER_SLP_EN1;
-                               mask = BIT(buck + 1 - 3);
+                               mask = BIT(buck - 2);
                        } else {
                                reg = RK806_POWER_SLP_EN0;
                                mask = BIT(buck);
@@ -590,9 +591,10 @@ static int _buck_get_suspend_enable(struct udevice *pmic, int buck)
                {
                        u8 reg;
 
-                       if (buck + 1 >= 9) {
+                       if (buck >= 8) {
+                               /* BUCK9 and BUCK10 */
                                reg = RK806_POWER_SLP_EN1;
-                               mask = BIT(buck + 1 - 3);
+                               mask = BIT(buck - 2);
                        } else {
                                reg = RK806_POWER_SLP_EN0;
                                mask = BIT(buck);