]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
regulator: core: enable power when setting up constraints
authorOlliver Schinagl <oliver@schinagl.nl>
Mon, 26 Nov 2018 15:27:44 +0000 (17:27 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 13 Feb 2021 12:51:15 +0000 (13:51 +0100)
[ Upstream commit 2bb1666369339f69f227ad060c250afde94d5c69 ]

When a regulator is marked as always on, it is enabled early on, when
checking and setting up constraints. It makes the assumption that the
bootloader properly initialized the regulator, and just in case enables
the regulator anyway.

Some constraints however currently get missed, such as the soft-start
and ramp-delay. This causes the regulator to be enabled, without the
soft-start and ramp-delay being applied, which in turn can cause
high-currents or other start-up problems.

By moving the always-enabled constraints later in the constraints check,
we can at least ensure all constraints for the regulator are followed.

Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
Signed-off-by: Priit Laes <plaes@plaes.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/regulator/core.c

index fa8f5fc04d8fdd4ea95d38517c2cdf8ecef5da14..870baa7036ecd837c1c896983c025f25f8a05ca5 100644 (file)
@@ -1142,17 +1142,6 @@ static int set_machine_constraints(struct regulator_dev *rdev)
                }
        }
 
-       /* If the constraints say the regulator should be on at this point
-        * and we have control then make sure it is enabled.
-        */
-       if (rdev->constraints->always_on || rdev->constraints->boot_on) {
-               ret = _regulator_do_enable(rdev);
-               if (ret < 0 && ret != -EINVAL) {
-                       rdev_err(rdev, "failed to enable\n");
-                       return ret;
-               }
-       }
-
        if ((rdev->constraints->ramp_delay || rdev->constraints->ramp_disable)
                && ops->set_ramp_delay) {
                ret = ops->set_ramp_delay(rdev, rdev->constraints->ramp_delay);
@@ -1198,6 +1187,17 @@ static int set_machine_constraints(struct regulator_dev *rdev)
                }
        }
 
+       /* If the constraints say the regulator should be on at this point
+        * and we have control then make sure it is enabled.
+        */
+       if (rdev->constraints->always_on || rdev->constraints->boot_on) {
+               ret = _regulator_do_enable(rdev);
+               if (ret < 0 && ret != -EINVAL) {
+                       rdev_err(rdev, "failed to enable\n");
+                       return ret;
+               }
+       }
+
        print_constraints(rdev);
        return 0;
 }