aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYadwinder Singh Brar <yadi.brar@samsung.com>2013-06-29 08:51:15 -0400
committerMark Brown <broonie@linaro.org>2013-07-15 06:27:48 -0400
commit1653ccf4c52df6a4abe8ec2f33f2cb2896d129ea (patch)
tree2238091c98473856a1523b13974ad98815a63156
parentad81f0545ef01ea651886dddac4bef6cec930092 (diff)
regulator: core: Add support for disabling ramp delay
Some hardwares support disabling ramp delay, so adding ramp_disable flag to constraints. It will be used to figure out whether ramp_delay in constraints is explicitly set to zero or its unintialized (zero by default). And we don't need to call set_voltage_time_sel() for regulators for whom ramp delay is disabled in constraints. Signed-off-by: Yadwinder Singh Brar <yadi.brar@samsung.com> Signed-off-by: Mark Brown <broonie@linaro.org>
-rw-r--r--Documentation/devicetree/bindings/regulator/regulator.txt2
-rw-r--r--drivers/regulator/core.c6
-rw-r--r--drivers/regulator/of_regulator.c12
-rw-r--r--include/linux/regulator/machine.h1
4 files changed, 16 insertions, 5 deletions
diff --git a/Documentation/devicetree/bindings/regulator/regulator.txt b/Documentation/devicetree/bindings/regulator/regulator.txt
index 48a3b8e5d6bd..2bd8f0978765 100644
--- a/Documentation/devicetree/bindings/regulator/regulator.txt
+++ b/Documentation/devicetree/bindings/regulator/regulator.txt
@@ -12,6 +12,8 @@ Optional properties:
12- regulator-allow-bypass: allow the regulator to go into bypass mode 12- regulator-allow-bypass: allow the regulator to go into bypass mode
13- <name>-supply: phandle to the parent supply/regulator node 13- <name>-supply: phandle to the parent supply/regulator node
14- regulator-ramp-delay: ramp delay for regulator(in uV/uS) 14- regulator-ramp-delay: ramp delay for regulator(in uV/uS)
15 For hardwares which support disabling ramp rate, it should be explicitly
16 intialised to zero (regulator-ramp-delay = <0>) for disabling ramp delay.
15 17
16Deprecated properties: 18Deprecated properties:
17- regulator-compatible: If a regulator chip contains multiple 19- regulator-compatible: If a regulator chip contains multiple
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 288c75abc190..6e6371c2346c 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -984,7 +984,8 @@ static int set_machine_constraints(struct regulator_dev *rdev,
984 } 984 }
985 } 985 }
986 986
987 if (rdev->constraints->ramp_delay && ops->set_ramp_delay) { 987 if ((rdev->constraints->ramp_delay || rdev->constraints->ramp_disable)
988 && ops->set_ramp_delay) {
988 ret = ops->set_ramp_delay(rdev, rdev->constraints->ramp_delay); 989 ret = ops->set_ramp_delay(rdev, rdev->constraints->ramp_delay);
989 if (ret < 0) { 990 if (ret < 0) {
990 rdev_err(rdev, "failed to set ramp_delay\n"); 991 rdev_err(rdev, "failed to set ramp_delay\n");
@@ -2438,7 +2439,8 @@ static int _regulator_do_set_voltage(struct regulator_dev *rdev,
2438 } 2439 }
2439 2440
2440 /* Call set_voltage_time_sel if successfully obtained old_selector */ 2441 /* Call set_voltage_time_sel if successfully obtained old_selector */
2441 if (ret == 0 && _regulator_is_enabled(rdev) && old_selector >= 0 && 2442 if (ret == 0 && !rdev->constraints->ramp_disable &&
2443 _regulator_is_enabled(rdev) && old_selector >= 0 &&
2442 old_selector != selector && rdev->desc->ops->set_voltage_time_sel) { 2444 old_selector != selector && rdev->desc->ops->set_voltage_time_sel) {
2443 2445
2444 delay = rdev->desc->ops->set_voltage_time_sel(rdev, 2446 delay = rdev->desc->ops->set_voltage_time_sel(rdev,
diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c
index f3c8f8f9dc39..7827384680d6 100644
--- a/drivers/regulator/of_regulator.c
+++ b/drivers/regulator/of_regulator.c
@@ -21,6 +21,7 @@ static void of_get_regulation_constraints(struct device_node *np,
21{ 21{
22 const __be32 *min_uV, *max_uV, *uV_offset; 22 const __be32 *min_uV, *max_uV, *uV_offset;
23 const __be32 *min_uA, *max_uA, *ramp_delay; 23 const __be32 *min_uA, *max_uA, *ramp_delay;
24 struct property *prop;
24 struct regulation_constraints *constraints = &(*init_data)->constraints; 25 struct regulation_constraints *constraints = &(*init_data)->constraints;
25 26
26 constraints->name = of_get_property(np, "regulator-name", NULL); 27 constraints->name = of_get_property(np, "regulator-name", NULL);
@@ -64,9 +65,14 @@ static void of_get_regulation_constraints(struct device_node *np,
64 if (of_property_read_bool(np, "regulator-allow-bypass")) 65 if (of_property_read_bool(np, "regulator-allow-bypass"))
65 constraints->valid_ops_mask |= REGULATOR_CHANGE_BYPASS; 66 constraints->valid_ops_mask |= REGULATOR_CHANGE_BYPASS;
66 67
67 ramp_delay = of_get_property(np, "regulator-ramp-delay", NULL); 68 prop = of_find_property(np, "regulator-ramp-delay", NULL);
68 if (ramp_delay) 69 if (prop && prop->value) {
69 constraints->ramp_delay = be32_to_cpu(*ramp_delay); 70 ramp_delay = prop->value;
71 if (*ramp_delay)
72 constraints->ramp_delay = be32_to_cpu(*ramp_delay);
73 else
74 constraints->ramp_disable = true;
75 }
70} 76}
71 77
72/** 78/**
diff --git a/include/linux/regulator/machine.h b/include/linux/regulator/machine.h
index 36adbc82de6a..999b20ce06cf 100644
--- a/include/linux/regulator/machine.h
+++ b/include/linux/regulator/machine.h
@@ -134,6 +134,7 @@ struct regulation_constraints {
134 unsigned always_on:1; /* regulator never off when system is on */ 134 unsigned always_on:1; /* regulator never off when system is on */
135 unsigned boot_on:1; /* bootloader/firmware enabled regulator */ 135 unsigned boot_on:1; /* bootloader/firmware enabled regulator */
136 unsigned apply_uV:1; /* apply uV constraint if min == max */ 136 unsigned apply_uV:1; /* apply uV constraint if min == max */
137 unsigned ramp_disable:1; /* disable ramp delay */
137}; 138};
138 139
139/** 140/**