regulator: Add ramp_delay configuration to constraints

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).

[Rewrote subject for 80 columns -- broonie]

Signed-off-by: Yadwinder Singh Brar <yadi.brar@samsung.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 6ffca9b..b615ae6 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -967,6 +967,14 @@
 		}
 	}
 
+	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:
@@ -2296,10 +2304,17 @@
 				   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;
 }