Skip to content

Commit 1653ccf

Browse files
Yadwinder Singh Brarbroonie
authored andcommitted
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>
1 parent ad81f05 commit 1653ccf

4 files changed

Lines changed: 16 additions & 5 deletions

File tree

‎Documentation/devicetree/bindings/regulator/regulator.txt‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ Optional properties:
1212
- regulator-allow-bypass: allow the regulator to go into bypass mode
1313
- <name>-supply: phandle to the parent supply/regulator node
1414
- 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.
1517

1618
Deprecated properties:
1719
- regulator-compatible: If a regulator chip contains multiple

‎drivers/regulator/core.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -984,7 +984,8 @@ static int set_machine_constraints(struct regulator_dev *rdev,
984984
}
985985
}
986986

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) {
988989
ret = ops->set_ramp_delay(rdev, rdev->constraints->ramp_delay);
989990
if (ret < 0) {
990991
rdev_err(rdev, "failed to set ramp_delay\n");
@@ -2438,7 +2439,8 @@ static int _regulator_do_set_voltage(struct regulator_dev *rdev,
24382439
}
24392440

24402441
/* 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 &&
24422444
old_selector != selector && rdev->desc->ops->set_voltage_time_sel) {
24432445

24442446
delay = rdev->desc->ops->set_voltage_time_sel(rdev,

‎drivers/regulator/of_regulator.c‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ static void of_get_regulation_constraints(struct device_node *np,
2121
{
2222
const __be32 *min_uV, *max_uV, *uV_offset;
2323
const __be32 *min_uA, *max_uA, *ramp_delay;
24+
struct property *prop;
2425
struct regulation_constraints *constraints = &(*init_data)->constraints;
2526

2627
constraints->name = of_get_property(np, "regulator-name", NULL);
@@ -64,9 +65,14 @@ static void of_get_regulation_constraints(struct device_node *np,
6465
if (of_property_read_bool(np, "regulator-allow-bypass"))
6566
constraints->valid_ops_mask |= REGULATOR_CHANGE_BYPASS;
6667

67-
ramp_delay = of_get_property(np, "regulator-ramp-delay", NULL);
68-
if (ramp_delay)
69-
constraints->ramp_delay = be32_to_cpu(*ramp_delay);
68+
prop = of_find_property(np, "regulator-ramp-delay", NULL);
69+
if (prop && prop->value) {
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+
}
7076
}
7177

7278
/**

‎include/linux/regulator/machine.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ struct regulation_constraints {
134134
unsigned always_on:1; /* regulator never off when system is on */
135135
unsigned boot_on:1; /* bootloader/firmware enabled regulator */
136136
unsigned apply_uV:1; /* apply uV constraint if min == max */
137+
unsigned ramp_disable:1; /* disable ramp delay */
137138
};
138139

139140
/**

0 commit comments

Comments
 (0)