devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
To: Mark Brown <broonie@kernel.org>
Cc: Kukjin Kim <kgene.kim@samsung.com>,
	Chanwoo Choi <cw00.choi@samsung.com>,
	Olof Johansson <olof@lixom.net>, Chris Zhong <zyw@rock-chips.com>,
	Krzysztof Kozlowski <k.kozlowski@samsung.com>,
	Abhilash Kesavan <kesavan.abhilash@gmail.com>,
	linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org,
	devicetree@vger.kernel.org,
	Javier Martinez Canillas <javier.martinez@collabora.co.uk>
Subject: [PATCH v4 10/14] regulator: of: Add support for parsing initial and suspend modes
Date: Mon,  3 Nov 2014 15:40:45 +0100	[thread overview]
Message-ID: <1415025649-8119-11-git-send-email-javier.martinez@collabora.co.uk> (raw)
In-Reply-To: <1415025649-8119-1-git-send-email-javier.martinez@collabora.co.uk>

Some regulators support their operating mode to be changed on startup
or by consumers when the system is running while others only support
their operating mode to be changed while the system has entered in a
suspend state.

The regulator Device Tree binding documents a set of properties to
configure the regulators operating modes from a FDT. This patch builds
on (40e20d6 regulator: of: Add support for parsing regulator_state for
suspend state) and adds support to parse those properties and fill the
regulator constraints so the regulator core can call the right suspend
handlers when the system enters into sleep.

The modes are defined in the Device Tree using the hardware specific
modes supported by the regulators. Regulator drivers have to define a
translation function that is used to map the hardware specific modes
to the standard ones.

Signed-off-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
---

Changes in v4:
 - Parse the properties in the core and map using driver provided functions.
   Suggested by Mark Brown

Changes in v3:
 - Use the standard suspend states binding instead of custom properties.
   Suggested by Mark Brown

 drivers/regulator/of_regulator.c | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c
index cbc1d71..cd65885 100644
--- a/drivers/regulator/of_regulator.c
+++ b/drivers/regulator/of_regulator.c
@@ -25,7 +25,8 @@ static const char *const regulator_states[PM_SUSPEND_MAX + 1] = {
 };
 
 static void of_get_regulation_constraints(struct device_node *np,
-					struct regulator_init_data **init_data)
+					struct regulator_init_data **init_data,
+					const struct regulator_desc *desc)
 {
 	const __be32 *min_uV, *max_uV;
 	struct regulation_constraints *constraints = &(*init_data)->constraints;
@@ -81,6 +82,14 @@ static void of_get_regulation_constraints(struct device_node *np,
 	if (!ret)
 		constraints->enable_time = pval;
 
+	if (!of_property_read_u32(np, "regulator-initial-mode", &pval)) {
+		if (desc && desc->map_modes)
+			constraints->initial_mode = desc->map_modes(pval);
+		else
+			pr_warn("%s: failed to parse regulator-initial-mode\n",
+				np->name);
+	}
+
 	for (i = 0; i < ARRAY_SIZE(regulator_states); i++) {
 		switch (i) {
 		case PM_SUSPEND_MEM:
@@ -100,6 +109,15 @@ static void of_get_regulation_constraints(struct device_node *np,
 		if (!suspend_np || !suspend_state)
 			continue;
 
+		if (!of_property_read_u32(suspend_np, "regulator-mode",
+					  &pval)) {
+			if (desc && desc->map_modes)
+				suspend_state->mode = desc->map_modes(pval);
+			else
+				pr_warn("%s: failed to parse regulator-mode\n",
+					np->name);
+		}
+
 		if (of_property_read_bool(suspend_np,
 					"regulator-on-in-suspend"))
 			suspend_state->enabled = true;
@@ -140,7 +158,7 @@ struct regulator_init_data *of_get_regulator_init_data(struct device *dev,
 	if (!init_data)
 		return NULL; /* Out of memory? */
 
-	of_get_regulation_constraints(node, &init_data);
+	of_get_regulation_constraints(node, &init_data, desc);
 	return init_data;
 }
 EXPORT_SYMBOL_GPL(of_get_regulator_init_data);
-- 
2.1.0

  parent reply	other threads:[~2014-11-03 14:40 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-03 14:40 [PATCH v4 00/14] Add max77802 regulator operating mode support Javier Martinez Canillas
2014-11-03 14:40 ` [PATCH v4 01/14] regulator: Document binding for initial and suspend modes Javier Martinez Canillas
2014-11-03 14:40 ` [PATCH v4 02/14] regulator: Add function to map modes to struct regulator_desc Javier Martinez Canillas
2014-11-04 10:31   ` Krzysztof Kozlowski
2014-11-04 11:02     ` Javier Martinez Canillas
2014-11-04 11:09       ` Krzysztof Kozlowski
2014-11-03 14:40 ` [PATCH v4 03/14] regulator: of: Add regulator desc param to of_get_regulator_init_data() Javier Martinez Canillas
2014-11-03 15:33   ` Mark Brown
2014-11-03 15:48     ` Javier Martinez Canillas
2014-11-03 15:59       ` Mark Brown
2014-11-03 16:11         ` Javier Martinez Canillas
2014-11-03 14:40 ` [PATCH v4 04/14] regulator: of: Pass the regulator description in the match table Javier Martinez Canillas
2014-11-03 14:40 ` [PATCH v4 06/14] regulator: max77686: zero-initialize regulator " Javier Martinez Canillas
2014-11-03 15:55   ` Mark Brown
2014-11-03 14:40 ` [PATCH v4 07/14] regulator: max77802: " Javier Martinez Canillas
2014-11-03 15:55   ` Mark Brown
     [not found] ` <1415025649-8119-1-git-send-email-javier.martinez-ZGY8ohtN/8pPYcu2f3hruQ@public.gmane.org>
2014-11-03 14:40   ` [PATCH v4 05/14] regulator: max1586: zero-initialize regulator match table array Javier Martinez Canillas
2014-11-03 15:41     ` Mark Brown
2014-11-03 15:51       ` Javier Martinez Canillas
2014-11-03 14:40   ` [PATCH v4 08/14] regulator: max8660: " Javier Martinez Canillas
2014-11-03 15:56     ` Mark Brown
2014-11-04 10:44   ` [PATCH v4 00/14] Add max77802 regulator operating mode support Krzysztof Kozlowski
2014-11-04 10:51     ` Javier Martinez Canillas
2014-11-04 11:04       ` Krzysztof Kozlowski
2014-11-03 14:40 ` [PATCH v4 09/14] regulator: s2mpa01: zero-initialize regulator match table array Javier Martinez Canillas
2014-11-03 15:56   ` Mark Brown
2014-11-03 14:40 ` Javier Martinez Canillas [this message]
     [not found]   ` <1415025649-8119-11-git-send-email-javier.martinez-ZGY8ohtN/8pPYcu2f3hruQ@public.gmane.org>
2014-11-04 10:41     ` [PATCH v4 10/14] regulator: of: Add support for parsing initial and suspend modes Krzysztof Kozlowski
2014-11-04 11:07       ` Javier Martinez Canillas
2014-11-03 14:40 ` [PATCH v4 11/14] regulator: max77802: Document binding for regulator operating modes Javier Martinez Canillas
2014-11-04 10:50   ` Krzysztof Kozlowski
2014-11-04 11:10     ` Javier Martinez Canillas
2014-11-03 14:40 ` [PATCH v4 12/14] regulator: max77802: Use unsigned int for modes in max77802_map_mode() Javier Martinez Canillas
2014-11-03 16:08   ` Mark Brown
2014-11-03 14:40 ` [PATCH v4 13/14] regulator: max77802: Set regulator modes translation callback Javier Martinez Canillas
2014-11-03 14:40 ` [PATCH v4 14/14] ARM: dts: Configure regulators for suspend on exynos Peach boards Javier Martinez Canillas
2014-11-03 15:54 ` [PATCH v4 00/14] Add max77802 regulator operating mode support Mark Brown
2014-11-03 16:07   ` Mark Brown
2014-11-03 16:08   ` Javier Martinez Canillas

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=1415025649-8119-11-git-send-email-javier.martinez@collabora.co.uk \
    --to=javier.martinez@collabora.co.uk \
    --cc=broonie@kernel.org \
    --cc=cw00.choi@samsung.com \
    --cc=devicetree@vger.kernel.org \
    --cc=k.kozlowski@samsung.com \
    --cc=kesavan.abhilash@gmail.com \
    --cc=kgene.kim@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=olof@lixom.net \
    --cc=zyw@rock-chips.com \
    /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).