For some hardwares ramp_delay for BUCKs is a configurable parameter which can
be configured through DT or board file.This patch adds ramp_delay to regulator
constraints and allow user to configure it for regulators which supports this
feature, through DT or board file. It will provide two ways of setting the
ramp_delay for a regulator:
First, by setting it as constraints in board file(for configurable
regulators) and set_machine_constraints() will take care of setting it on
hardware by calling(the provided) .set_ramp_delay() operation(callback).
Second, by setting it as data in regulator_desc(as fixed/default
ramp_delay rate) for a regulator in driver.
regulator_set_voltage_time_sel() will give preference to
constraints-ramp_delay while reading ramp_delay rate for regulator. Similarly
users should also take care accordingly while refering ramp_delay rate(in case
of implementing their private .set_voltage_time_sel() callbacks for different
regulators).
Signed-off-by: Yadwinder Singh Brar yadi.b...@samsung.com
---
.../devicetree/bindings/regulator/regulator.txt|1 +
drivers/regulator/core.c | 23 ---
drivers/regulator/of_regulator.c |6 -
include/linux/regulator/driver.h |3 ++
include/linux/regulator/machine.h |3 ++
5 files changed, 31 insertions(+), 5 deletions(-)
diff --git a/Documentation/devicetree/bindings/regulator/regulator.txt
b/Documentation/devicetree/bindings/regulator/regulator.txt
index 5b7a408..d0a7b12 100644
--- a/Documentation/devicetree/bindings/regulator/regulator.txt
+++ b/Documentation/devicetree/bindings/regulator/regulator.txt
@@ -10,6 +10,7 @@ Optional properties:
- regulator-always-on: boolean, regulator should never be disabled
- regulator-boot-on: bootloader/firmware enabled regulator
- name-supply: phandle to the parent supply/regulator node
+- regulator-ramp-delay: ramp delay for regulator(in mV/uS)
Example:
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 63507a5..0ffd917 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -967,6 +967,14 @@ static int set_machine_constraints(struct regulator_dev
*rdev,
}
}
+ if (rdev-constraints-ramp_delay ops-set_ramp_delay) {
+ ret = ops-set_ramp_delay(rdev, rdev-constraints-ramp_delay);
+ if (ret 0) {
+ rdev_err(rdev, failed to set ramp_delay\n);
+ goto out;
+ }
+ }
+
print_constraints(rdev);
return 0;
out:
@@ -2305,10 +2313,17 @@ int regulator_set_voltage_time_sel(struct regulator_dev
*rdev,
unsigned int old_selector,
unsigned int new_selector)
{
- if (rdev-desc-ramp_delay rdev-desc-uV_step)
- return DIV_ROUND_UP(rdev-desc-uV_step *
- abs(new_selector - old_selector),
- rdev-desc-ramp_delay * 1000);
+ if (rdev-desc-uV_step) {
+ if (rdev-constraints-ramp_delay)
+ return DIV_ROUND_UP(rdev-desc-uV_step *
+ abs(new_selector - old_selector),
+ rdev-constraints-ramp_delay * 1000);
+ if (rdev-desc-ramp_delay)
+ return DIV_ROUND_UP(rdev-desc-uV_step *
+ abs(new_selector - old_selector),
+ rdev-desc-ramp_delay * 1000);
+ rdev_warn(rdev, ramp_delay not set\n);
+ }
return 0;
}
diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c
index 56593b7..e2a7310 100644
--- a/drivers/regulator/of_regulator.c
+++ b/drivers/regulator/of_regulator.c
@@ -20,7 +20,7 @@ static void of_get_regulation_constraints(struct device_node
*np,
struct regulator_init_data **init_data)
{
const __be32 *min_uV, *max_uV, *uV_offset;
- const __be32 *min_uA, *max_uA;
+ const __be32 *min_uA, *max_uA, *ramp_delay;
struct regulation_constraints *constraints = (*init_data)-constraints;
constraints-name = of_get_property(np, regulator-name, NULL);
@@ -60,6 +60,10 @@ static void of_get_regulation_constraints(struct device_node
*np,
constraints-always_on = true;
else /* status change should be possible if not always on. */
constraints-valid_ops_mask |= REGULATOR_CHANGE_STATUS;
+
+ ramp_delay = of_get_property(np, regulator-ramp-delay, NULL);
+ if (ramp_delay)
+ constraints-min_uV = be32_to_cpu(*ramp_delay);
}
/**
diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/driver.h
index ae5c253..ddc155d 100644
--- a/include/linux/regulator/driver.h
+++ b/include/linux/regulator/driver.h
@@ -67,6 +67,8 @@ enum