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


Groups > linux.kernel > #1405126

[PATCH v2 2/3] regulator: of: Add support for parsing operation mode

From Henry Chen <henryc.chen@mediatek.com>
Newsgroups linux.kernel
Subject [PATCH v2 2/3] regulator: of: Add support for parsing operation mode
Date 2016-05-23 09:20 +0200
Message-ID <rBSjE-2RI-45@gated-at.bofh.it> (permalink)
References <rBSjD-2RI-13@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Some regulators support their operating mode to be changed by consumers for
module specific purpose.

This patch adds support to parse those properties and fill the regulator
constraints so the regulator core can call the regualtor_set_mode to change
the modes.

Signed-off-by: Henry Chen <henryc.chen@mediatek.com>
---
 drivers/regulator/of_regulator.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c
index 6b0aa80..7f8d82e 100644
--- a/drivers/regulator/of_regulator.c
+++ b/drivers/regulator/of_regulator.c
@@ -31,7 +31,7 @@ static void of_get_regulation_constraints(struct device_node *np,
 	struct regulation_constraints *constraints = &(*init_data)->constraints;
 	struct regulator_state *suspend_state;
 	struct device_node *suspend_np;
-	int ret, i;
+	int ret, i, cnt;
 	u32 pval;
 
 	constraints->name = of_get_property(np, "regulator-name", NULL);
@@ -167,6 +167,19 @@ static void of_get_regulation_constraints(struct device_node *np,
 		suspend_state = NULL;
 		suspend_np = NULL;
 	}
+	cnt = of_property_count_elems_of_size(np,
+					      "regulator-supported-modes",
+					      sizeof(u32));
+	if (cnt > 0)
+		constraints->valid_ops_mask |= REGULATOR_CHANGE_MODE;
+
+	for (i = 0; i < cnt; i++) {
+		u32 mode;
+
+		of_property_read_u32_index(np, "regulator-supported-modes",
+					   i, &mode);
+		constraints->valid_modes_mask |= (1 << mode);
+	}
 }
 
 /**
-- 
1.8.1.1.dirty

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


Thread

Add support for regulator operation mode of mt6397 Henry Chen <henryc.chen@mediatek.com> - 2016-05-23 09:20 +0200
  [PATCH v2 1/3] regulator: DT: Add DT property for operation mode configuration Henry Chen <henryc.chen@mediatek.com> - 2016-05-23 09:20 +0200
    Re: [PATCH v2 1/3] regulator: DT: Add DT property for operation mode  configuration Mark Rutland <mark.rutland@arm.com> - 2016-05-23 12:50 +0200
      Re: [PATCH v2 1/3] regulator: DT: Add DT property for operation mode  configuration Mark Brown <broonie@kernel.org> - 2016-05-23 13:40 +0200
        Re: [PATCH v2 1/3] regulator: DT: Add DT property for operation  mode configuration Fan Chen <fan.chen@mediatek.com> - 2016-05-31 10:30 +0200
  [PATCH v2 2/3] regulator: of: Add support for parsing operation mode Henry Chen <henryc.chen@mediatek.com> - 2016-05-23 09:20 +0200
  [PATCH v2 3/3] regulator: mt6397: Add buck change mode regulator interface for mt6397 Henry Chen <henryc.chen@mediatek.com> - 2016-05-23 09:20 +0200
    Re: [PATCH v2 3/3] regulator: mt6397: Add buck change mode regulator  interface for mt6397 Mark Brown <broonie@kernel.org> - 2016-05-23 13:40 +0200
    Applied "regulator: mt6397: Add buck change mode regulator interface for mt6397" to the regulator tree Mark Brown <broonie@kernel.org> - 2016-05-23 20:00 +0200

csiph-web