devicetree.vger.kernel.org archive mirror
 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, lgirdwood@gmail.com
Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	Laxman Dewangan <ldewangan@nvidia.com>
Subject: [PATCH 2/4] regulator: core: Add support for active-discharge configuration
Date: Tue, 1 Mar 2016 18:08:13 +0530	[thread overview]
Message-ID: <1456835895-16503-3-git-send-email-ldewangan@nvidia.com> (raw)
In-Reply-To: <1456835895-16503-1-git-send-email-ldewangan@nvidia.com>

Add support to enable/disable active discharge of regulator via
machine constraints. This configuration is done when setting
machine constraint during regulator register and if regulator
driver implemented the callback ops.

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

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 055f8c1..3e865b0 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1139,6 +1139,16 @@ static int set_machine_constraints(struct regulator_dev *rdev,
 		}
 	}
 
+	if ((rdev->constraints->active_discharge >= 0)
+		&& ops->set_active_discharge) {
+		ret = ops->set_active_discharge(rdev,
+				rdev->constraints->active_discharge);
+		if (ret < 0) {
+			rdev_err(rdev, "failed to set active discharge\n");
+			return ret;
+		}
+	}
+
 	print_constraints(rdev);
 	return 0;
 }
diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c
index 499e437..d1e0c03 100644
--- a/drivers/regulator/of_regulator.c
+++ b/drivers/regulator/of_regulator.c
@@ -93,6 +93,11 @@ static void of_get_regulation_constraints(struct device_node *np,
 
 	constraints->soft_start = of_property_read_bool(np,
 					"regulator-soft-start");
+	ret = of_property_read_u32(np, "regulator-active-discharge", &pval);
+	if (!ret)
+		constraints->active_discharge = pval;
+	else
+		constraints->active_discharge = -1;
 
 	if (!of_property_read_u32(np, "regulator-initial-mode", &pval)) {
 		if (desc && desc->of_map_mode) {
diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/driver.h
index 16ac9e1..59dbaf7 100644
--- a/include/linux/regulator/driver.h
+++ b/include/linux/regulator/driver.h
@@ -93,6 +93,8 @@ struct regulator_linear_range {
  * @get_current_limit: Get the configured limit for a current-limited regulator.
  * @set_input_current_limit: Configure an input limit.
  *
+ * @set_active_discharge: Set active discharge enable/disable of regulators.
+ *
  * @set_mode: Set the configured operating mode for the regulator.
  * @get_mode: Get the configured operating mode for the regulator.
  * @get_status: Return actual (not as-configured) status of regulator, as a
@@ -149,6 +151,7 @@ struct regulator_ops {
 
 	int (*set_input_current_limit) (struct regulator_dev *, int lim_uA);
 	int (*set_over_current_protection) (struct regulator_dev *);
+	int (*set_active_discharge) (struct regulator_dev *, bool enable);
 
 	/* enable/disable regulator */
 	int (*enable) (struct regulator_dev *);
diff --git a/include/linux/regulator/machine.h b/include/linux/regulator/machine.h
index a1067d0..408cde7 100644
--- a/include/linux/regulator/machine.h
+++ b/include/linux/regulator/machine.h
@@ -100,6 +100,8 @@ 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)
+ * @active_discharge: Enable/disable active discharge. The values are:
+ *		      -1: Default, 0: Disable, 1: Enable.
  * @enable_time: Turn-on time of the rails (unit: microseconds)
  */
 struct regulation_constraints {
@@ -140,6 +142,8 @@ struct regulation_constraints {
 	unsigned int ramp_delay;
 	unsigned int enable_time;
 
+	int active_discharge;
+
 	/* constraint flags */
 	unsigned always_on:1;	/* regulator never off when system is on */
 	unsigned boot_on:1;	/* bootloader/firmware enabled regulator */
-- 
2.1.4

  parent reply	other threads:[~2016-03-01 12:38 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-01 12:38 [PATCH 0/4] regulator: Add support for configuration of active-discharge Laxman Dewangan
2016-03-01 12:38 ` [PATCH 1/4] regulator: DT: Add DT property for active-discharge configuration Laxman Dewangan
2016-03-01 12:38 ` Laxman Dewangan [this message]
2016-03-02  1:44   ` [PATCH 2/4] regulator: core: Add support " Mark Brown
2016-03-02  2:01     ` Laxman Dewangan
     [not found]       ` <56D64984.8080405-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2016-03-02  3:13         ` Mark Brown
2016-03-01 12:38 ` [PATCH 3/4] regulator: helper: Add helper to configure active-discharge using regmap Laxman Dewangan
2016-03-01 12:38 ` [PATCH 4/4] regulator: max77620: Add support to configure active-discharge Laxman Dewangan
  -- strict thread matches above, loose matches on Subject: below --
2016-03-02  6:56 [PATCH V2 0/4] regulator: Add support for configuration of active-discharge Laxman Dewangan
     [not found] ` <1456901797-21340-1-git-send-email-ldewangan-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org>
2016-03-02  6:56   ` [PATCH 2/4] regulator: core: Add support for active-discharge configuration Laxman Dewangan

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=1456835895-16503-3-git-send-email-ldewangan@nvidia.com \
    --to=ldewangan@nvidia.com \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --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 \
    /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;
as well as URLs for NNTP newsgroup(s).