regulator: core: add support for configuring turn-on time through constraints
Laxman Dewangan [Mon, 23 Sep 2013 10:50:00 +0000 (15:50 +0530)]
The turn-on time of the regulator depends on the regulator device's
electrical characteristics. Sometimes regulator turn-on time also
depends on the capacitive load on the given platform and it can be
more than the datasheet value.

The driver provides the enable-time as per datasheet.

Add support for configure the enable ramp time through regulator
constraints so that regulator core can take this value for enable
time for that regulator.

Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Acked-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
(cherry picked from commit 00c877c69ba315d6c565a4df51c71b11e82cdeb8)

Change-Id: I2fa17ec0edcc1a2071f88892f8e15b1ae60009b9
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Reviewed-on: http://git-master/r/277822
GVS: Gerrit_Virtual_Submit
(cherry picked from commit dd27579000b7ab44b1e996cdb00327dcdc47b49c)
Signed-off-by: Ajay Nandakumar <anandakumarm@nvidia.com>

Documentation/devicetree/bindings/regulator/regulator.txt
drivers/regulator/core.c
drivers/regulator/of_regulator.c
include/linux/regulator/machine.h

index 0fd87f3..d8d57a1 100644 (file)
@@ -12,6 +12,11 @@ Optional properties:
 - <name>-supply: phandle to the parent supply/regulator node
 - regulator-ramp-delay: ramp delay for regulator(in uV/uS)
 - regulator-init-microvolt: Initial microvolt need to be set during registration
+- regulator-enable-ramp-delay: The time taken, in microseconds, for the supply
+  rail to reach the target voltage, plus/minus whatever tolerance the board
+  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.
 
 Deprecated properties:
 - regulator-compatible: If a regulator chip contains multiple
index 4083216..e2ad7b1 100644 (file)
@@ -1347,8 +1347,8 @@ overflow_err:
 
 static int _regulator_get_enable_time(struct regulator_dev *rdev)
 {
-       if (rdev->constraints->startup_delay)
-               return rdev->constraints->startup_delay;
+       if (rdev->constraints && rdev->constraints->enable_time)
+               return rdev->constraints->enable_time;
        if (!rdev->desc->ops->enable_time)
                return rdev->desc->enable_time;
        return rdev->desc->ops->enable_time(rdev);
index 3b6e2cf..bd46095 100644 (file)
@@ -75,6 +75,8 @@ static void of_get_regulation_constraints(struct device_node *np,
        const __be32 *min_uA, *max_uA, *ramp_delay;
        const __be32 *init_uV;
        struct regulation_constraints *constraints = &(*init_data)->constraints;
+       int ret;
+       u32 pval;
 
        constraints->name = of_get_property(np, "regulator-name", NULL);
 
@@ -120,6 +122,10 @@ static void of_get_regulation_constraints(struct device_node *np,
        ramp_delay = of_get_property(np, "regulator-ramp-delay", NULL);
        if (ramp_delay)
                constraints->ramp_delay = be32_to_cpu(*ramp_delay);
+
+       ret = of_property_read_u32(np, "regulator-enable-ramp-delay", &pval);
+       if (!ret)
+               constraints->enable_time = pval;
 }
 
 /**
index e126a32..f86a383 100644 (file)
@@ -98,7 +98,7 @@ struct regulator_state {
  * @initial_state: Suspend state to set by default.
  * @initial_mode: Mode to set at startup.
  * @ramp_delay: Time to settle down after voltage change (unit: uV/us)
- * @startup_delay: Time to settle down after rail enable (unit: us)
+ * @enable_time: Turn-on time of the rails (unit: microseconds)
  */
 struct regulation_constraints {
 
@@ -137,6 +137,7 @@ struct regulation_constraints {
        unsigned int sleep_mode;
 
        unsigned int ramp_delay;
+       unsigned int enable_time;
 
        unsigned int startup_delay;