Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1346593

[PATCH 2/4] regulator: core: Add support for active-discharge configuration

From Laxman Dewangan <ldewangan@nvidia.com>
Newsgroups linux.kernel
Subject [PATCH 2/4] regulator: core: Add support for active-discharge configuration
Date 2016-03-01 14:00 +0100
Message-ID <r7S4b-Pg-37@gated-at.bofh.it> (permalink)
References <r7S4a-Pg-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/4] regulator: Add support for configuration of active-discharge Laxman Dewangan <ldewangan@nvidia.com> - 2016-03-01 14:00 +0100
  [PATCH 4/4] regulator: max77620: Add support to configure active-discharge Laxman Dewangan <ldewangan@nvidia.com> - 2016-03-01 14:00 +0100
  [PATCH 1/4] regulator: DT: Add DT property for active-discharge configuration Laxman Dewangan <ldewangan@nvidia.com> - 2016-03-01 14:00 +0100
  [PATCH 3/4] regulator: helper: Add helper to configure active-discharge using regmap Laxman Dewangan <ldewangan@nvidia.com> - 2016-03-01 14:00 +0100
  [PATCH 2/4] regulator: core: Add support for active-discharge configuration Laxman Dewangan <ldewangan@nvidia.com> - 2016-03-01 14:00 +0100
    Re: [PATCH 2/4] regulator: core: Add support for active-discharge  configuration Mark Brown <broonie@kernel.org> - 2016-03-02 02:50 +0100
      Re: [PATCH 2/4] regulator: core: Add support for active-discharge  configuration Laxman Dewangan <ldewangan@nvidia.com> - 2016-03-02 03:20 +0100
        Re: [PATCH 2/4] regulator: core: Add support for active-discharge  configuration Mark Brown <broonie@kernel.org> - 2016-03-02 04:20 +0100

csiph-web