regulator: Add soft start support
authorStephen Boyd <sboyd@codeaurora.org>
Fri, 12 Jun 2015 00:37:05 +0000 (17:37 -0700)
committerMark Brown <broonie@kernel.org>
Fri, 12 Jun 2015 12:16:57 +0000 (13:16 +0100)
Some regulators support a "soft start" feature where the voltage
ramps up slowly when the regulator is enabled. Add an op
(set_soft_start) and a DT property + constraint to support this.

Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
Documentation/devicetree/bindings/regulator/regulator.txt
drivers/regulator/core.c
drivers/regulator/of_regulator.c
include/linux/regulator/driver.h
include/linux/regulator/machine.h

index 6c79fd70ab5aec0a6fd3f963dc689d2b7b0118bf..4b1df61ccbd7f879bcadb97e78aac6cab9651500 100644 (file)
@@ -19,6 +19,7 @@ Optional properties:
   design requires. This property describes the total system ramp time
   required due to the combination of internal ramping of the regulator itself,
   and board design issues such as trace capacitance and load on the supply.
+- regulator-soft-start: Enable soft start so that voltage ramps slowly
 - regulator-state-mem sub-root node for Suspend-to-RAM mode
   : suspend to memory, the device goes to sleep, but all data stored in memory,
   only some external interrupt can wake the device.
index 60fcfba52592c8e67b8e551560ecd9574459fe5f..6dfb2d6c19aefc64ac086371349b908459c22cb5 100644 (file)
@@ -1059,6 +1059,14 @@ static int set_machine_constraints(struct regulator_dev *rdev,
                }
        }
 
+       if (rdev->constraints->soft_start && ops->set_soft_start) {
+               ret = ops->set_soft_start(rdev);
+               if (ret < 0) {
+                       rdev_err(rdev, "failed to set soft start\n");
+                       goto out;
+               }
+       }
+
        print_constraints(rdev);
        return 0;
 out:
index c3433db0acda50828c044323aa9657934f849718..207da037cd2d99f1fb1647458fe7faa3737ecbcb 100644 (file)
@@ -84,6 +84,9 @@ static void of_get_regulation_constraints(struct device_node *np,
        if (!ret)
                constraints->enable_time = pval;
 
+       constraints->soft_start = of_property_read_bool(np,
+                                       "regulator-soft-start");
+
        if (!of_property_read_u32(np, "regulator-initial-mode", &pval)) {
                if (desc && desc->of_map_mode) {
                        ret = desc->of_map_mode(pval);
index 76144a337ff72032edb97bfa0d6e879127070e6d..e0635d0894aafadd08be844c3d8aa71a2ae8de43 100644 (file)
@@ -161,6 +161,8 @@ struct regulator_ops {
                                     unsigned int old_selector,
                                     unsigned int new_selector);
 
+       int (*set_soft_start) (struct regulator_dev *);
+
        /* report regulator status ... most other accessors report
         * control inputs, this reports results of combining inputs
         * from Linux (and other sources) with the actual load.
index 8ffb0619a03cc245a096010841c6065418f613b7..7f7d0a3fe1e10ede2583d525f11c6183adcae40f 100644 (file)
@@ -142,6 +142,7 @@ struct regulation_constraints {
        unsigned boot_on:1;     /* bootloader/firmware enabled regulator */
        unsigned apply_uV:1;    /* apply uV constraint if min == max */
        unsigned ramp_disable:1; /* disable ramp delay */
+       unsigned soft_start:1;  /* ramp voltage slowly */
        unsigned pull_down:1;   /* pull down resistor when regulator off */
 };