mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Laxman Dewangan <ldewangan@nvidia.com>
To: <broonie@kernel.org>, <robh+dt@kernel.org>, <pawel.moll@arm.com>,
	<mark.rutland@arm.com>, <ijc+devicetree@hellion.org.uk>
Cc: <lgirdwood@gmail.com>, <bjorn.andersson@sonymobile.com>,
	<swarren@wwwdotorg.org>, <devicetree@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>,
	Laxman Dewangan <ldewangan@nvidia.com>
Subject: [PATCH 2/2] regulator: Add support to scale ramp delay based on platform behavior
Date: Mon, 29 Feb 2016 20:10:29 +0530	[thread overview]
Message-ID: <1456756829-2277-2-git-send-email-ldewangan@nvidia.com> (raw)
In-Reply-To: <1456756829-2277-1-git-send-email-ldewangan@nvidia.com>

It is observed that voltage change in given rail affected by the load
and the capacitor in the rail. This may cause the slow ramp in voltage
against what PMIC has programmed.

The machine constraints ramp_delay provides the ramp delay configuration
for PMIC but actual voltage settling time may change based on platform.

Add ramp_delay_scale in the machine constraints for platform specific
scaling for final ramp delay calculation. On this case, final wait
delay time for voltage change is calculated as the
	DIV_ROUND_UP(ramp_delay * ramp_delay_scale, 100)

The value is provided in the term of percentage i.e. 300% means it will
do the 3x delay of calculated value.

Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
---
 drivers/regulator/core.c          | 6 ++++++
 drivers/regulator/of_regulator.c  | 7 +++++++
 include/linux/regulator/machine.h | 7 +++++++
 3 files changed, 20 insertions(+)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 055f8c1..476fe6c 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -2786,6 +2786,12 @@ static int _regulator_do_set_voltage(struct regulator_dev *rdev,
 			delay = 0;
 		}
 
+		if (delay && rdev->constraints &&
+		    rdev->constraints->ramp_delay_scale) {
+			delay *= rdev->constraints->ramp_delay_scale;
+			delay = DIV_ROUND_UP(delay, 100);
+		}
+
 		/* Insert any necessary delays */
 		if (delay >= 1000) {
 			mdelay(delay / 1000);
diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c
index 499e437..cd204b1 100644
--- a/drivers/regulator/of_regulator.c
+++ b/drivers/regulator/of_regulator.c
@@ -87,6 +87,13 @@ static void of_get_regulation_constraints(struct device_node *np,
 			constraints->ramp_disable = true;
 	}
 
+	if (constraints->ramp_delay) {
+		ret = of_property_read_u32(np, "regulator-ramp-delay-scale",
+					   &pval);
+		if (!ret)
+			constraints->ramp_delay_scale = pval;
+	}
+
 	ret = of_property_read_u32(np, "regulator-enable-ramp-delay", &pval);
 	if (!ret)
 		constraints->enable_time = pval;
diff --git a/include/linux/regulator/machine.h b/include/linux/regulator/machine.h
index a1067d0..5153e5a 100644
--- a/include/linux/regulator/machine.h
+++ b/include/linux/regulator/machine.h
@@ -100,6 +100,12 @@ 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)
+ * @ramp_delay_scale: Scaling in ramp delay to provide extra guard time
+ *		      to settle down after voltage change. This is
+ *		      provided in terms of percentage like 200% means
+ *		      2x of calculated ramp delay for given voltage change.
+ *		      The final delay is calucated as:
+			DIV_ROUND_UP(ramp_delay * ramp_delay_scale, 100);
  * @enable_time: Turn-on time of the rails (unit: microseconds)
  */
 struct regulation_constraints {
@@ -139,6 +145,7 @@ struct regulation_constraints {
 
 	unsigned int ramp_delay;
 	unsigned int enable_time;
+	unsigned int ramp_delay_scale;
 
 	/* constraint flags */
 	unsigned always_on:1;	/* regulator never off when system is on */
-- 
2.1.4

  reply	other threads:[~2016-02-29 14:54 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-29 14:40 [PATCH 1/2] regulator: DT: " Laxman Dewangan
2016-02-29 14:40 ` Laxman Dewangan [this message]
2016-02-29 17:47 ` Bjorn Andersson
2016-03-01  2:23   ` Mark Brown
2016-03-01  3:48     ` Laxman Dewangan
2016-03-02  3:38       ` Mark Brown
2016-03-02  3:35         ` Laxman Dewangan
2016-03-02  4:35           ` Mark Brown
2016-03-02  6:12             ` Laxman Dewangan
2016-03-15 13:41             ` Laxman Dewangan
2016-03-15 14:48               ` Mark Brown
2016-03-16 11:30                 ` Laxman Dewangan
2016-03-19  4:31               ` Bjorn Andersson
2016-03-19  8:35                 ` Laxman Dewangan
2016-03-30 13:29                   ` Laxman Dewangan
2016-03-30 18:16                     ` Mark Brown
2016-03-31  7:06                       ` Laxman Dewangan
2016-03-31 16:51                         ` Mark Brown
2016-03-31 17:13                           ` Laxman Dewangan
2016-03-31 17:47                             ` Mark Brown
2016-03-31 17:47                               ` Laxman Dewangan
2016-03-31 18:31                                 ` Mark Brown
2016-03-31 18:31                                   ` Laxman Dewangan
2016-03-31 18:45                                     ` Mark Brown
2016-03-31 18:39                                       ` Laxman Dewangan
2016-03-31 18:59                                         ` Mark Brown
2016-03-31 18:59                                           ` Laxman Dewangan
2016-03-31 19:22                                             ` Mark Brown
2016-03-31 19:48                                               ` Laxman Dewangan
2016-03-31 20:39                                                 ` Mark Brown
2016-04-01  7:15                                                   ` Laxman Dewangan
2016-04-01 16:11                                                     ` Mark Brown
2016-04-05  8:01                                                       ` Laxman Dewangan
2016-04-12  1:02                                                         ` Mark Brown
2016-04-12 13:29                                                           ` Laxman Dewangan
2016-04-13  6:53                                                             ` Mark Brown
2016-04-19 10:01                                                               ` Laxman Dewangan
2016-04-19 10:55                                                                 ` Mark Brown
2016-04-19 10:56                                                                   ` Laxman Dewangan
2016-04-19 15:47                                                                     ` Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1456756829-2277-2-git-send-email-ldewangan@nvidia.com \
    --to=ldewangan@nvidia.com \
    --cc=bjorn.andersson@sonymobile.com \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=ijc+devicetree@hellion.org.uk \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=pawel.moll@arm.com \
    --cc=robh+dt@kernel.org \
    --cc=swarren@wwwdotorg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome