From: Saurabh Singh <saurabh1.s@samsung.com>
To: Mark Brown <broonie@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>,
"lgirdwood@gmail.com" <lgirdwood@gmail.com>,
"grant.likely@linaro.org" <grant.likely@linaro.org>,
"rob.herring@calxeda.com" <rob.herring@calxeda.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
"celinux-dev@tree.celinuxforum.org"
<celinux-dev@tree.celinuxforum.org>,
SREEVATSA D B <srevatsa@samsung.com>,
Praveen BP <bp.praveen@samsung.com>
Subject: Re: [PATCH] Parse missing regulator constraints from device tree blob
Date: Fri, 17 Jan 2014 15:11:19 +0000 (GMT) [thread overview]
Message-ID: <758915.615271389971476784.JavaMail.weblogic@epml20> (raw)
This patch adds support for parsing following regulator contraints from
device tree blob.
1. valid modes mask (valid_modes_mask)
2. initial mode (initial_mode)
3. initial state (initial_state)
4. state mem (state_mem)
5. state disk (state_disk)
6. state standby (state_standby)
Signed-off-by: Saurabh Singh Sengar <saurabh1.s@samsung.com>
---
.../devicetree/bindings/regulator/regulator.txt | 45 ++++++++++++
drivers/regulator/of_regulator.c | 77 ++++++++++++++++++++
2 files changed, 122 insertions(+), 0 deletions(-)
diff --git a/Documentation/devicetree/bindings/regulator/regulator.txt b/Documentation/devicetree/bindings/regulator/regulator.txt
index 2bd8f09..6dc935b 100644
--- a/Documentation/devicetree/bindings/regulator/regulator.txt
+++ b/Documentation/devicetree/bindings/regulator/regulator.txt
@@ -14,6 +14,36 @@ Optional properties:
- regulator-ramp-delay: ramp delay for regulator(in uV/uS)
For hardwares which support disabling ramp rate, it should be explicitly
intialised to zero (regulator-ramp-delay = <0>) for disabling ramp delay.
+- regulator-valid-modes-mask: valid operations for regulator on particular machine
+ Supports following modes of operations:
+ Mode Description
+ ---- -----------
+ fast Regulator can handle fast changes in it's load
+ normal Normal regulator power supply mode
+ idle Regulator runs in a more efficient mode for light loads.
+ standby Regulator runs in the most efficient mode for very light loads
+ See the example given below.
+
+- regulator-initial-mode: default mode to set on startup
+ Refer to regulator-initial-mode for modes supported
+
+- regulator-initial-state: suspend state to set at init
+ Any one of the following states can be set:
+ Mode Description
+ ---- -----------
+ suspend-mem suspend to memory
+ suspend-standby standby mode
+ suspend-disk suspend to disk
+ See the example given below.
+
+- regulator-state-mem, regulator-state-disk, regulator-state-standby:
+ defines regulator suspend to memory, suspend to disk (hibernate) and standby respectively.
+ have following sub-constarints:
+ - regulator-state-uv: voltage to set in suspend state
+ - regulator-state-mode: suspend regulator operating mode,
+ refer to regulator-valid-modes-mask for modes supported
+ - regulator-state-enabled: is regulator enabled in this suspend state
+ - regulator-state-disabled: is the regulator disbled in this suspend state
Deprecated properties:
- regulator-compatible: If a regulator chip contains multiple
@@ -29,6 +59,21 @@ Example:
regulator-max-microvolt = <2500000>;
regulator-always-on;
vin-supply = <&vin>;
+ regulator-initial-mode = "normal";
+ regulator-initial-state = "suspend-mem";
+ regulator-valid-modes-mask {
+ /*can support multiple mode
+ * in this example supporting fast and normal mode */
+ fast-mode;
+ normal-mode;
+ };
+ regulator-state-mem {
+ regulator-state-mode = "idle";
+ regulator-state-enabled;
+ };
+ regulator-state-disk {
+ regulator-state-disabled;
+ };
};
Regulator Consumers:
diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c
index 7827384..3030597 100644
--- a/drivers/regulator/of_regulator.c
+++ b/drivers/regulator/of_regulator.c
@@ -16,11 +16,36 @@
#include <linux/regulator/machine.h>
#include <linux/regulator/of_regulator.h>
+/**
+ * set_regulator_state_constraints - set regulator state for low power system states
+ * @np: device node for the low power regulator state
+ * @regulator_state: regulator_state structure need to be filled
+ */
+static void set_regulator_state_constraints(struct device_node *np,
+ struct regulator_state *state)
+{
+ of_property_read_u32(np, "regulator-state-uv", &state->uV);
+ if (!of_property_match_string(np, "regulator-state-mode", "fast"))
+ state->mode = REGULATOR_MODE_FAST;
+ else if (!of_property_match_string(np, "regulator-state-mode",
+ "normal"))
+ state->mode = REGULATOR_MODE_NORMAL;
+ else if (!of_property_match_string(np, "regulator-state-mode", "idle"))
+ state->mode = REGULATOR_MODE_IDLE;
+ else if (!of_property_match_string(np, "regulator-state-mode",
+ "standby"))
+ state->mode = REGULATOR_MODE_STANDBY;
+ state->enabled = of_property_read_bool(np, "regulator-state-enabled");
+ state->disabled = of_property_read_bool(np, "regulator-state-disabled");
+}
+
+
static void of_get_regulation_constraints(struct device_node *np,
struct regulator_init_data **init_data)
{
const __be32 *min_uV, *max_uV, *uV_offset;
const __be32 *min_uA, *max_uA, *ramp_delay;
+ struct device_node *state, *valid_modes;
struct property *prop;
struct regulation_constraints *constraints = &(*init_data)->constraints;
@@ -73,6 +98,58 @@ static void of_get_regulation_constraints(struct device_node *np,
else
constraints->ramp_disable = true;
}
+
+ valid_modes = of_find_node_by_name(np, "regulator-valid-modes-mask");
+ if (valid_modes) {
+ if (of_property_read_bool(valid_modes, "fast"))
+ constraints->valid_modes_mask = REGULATOR_MODE_FAST;
+ if (of_property_read_bool(valid_modes, "normal"))
+ constraints->valid_modes_mask |= REGULATOR_MODE_NORMAL;
+ if (of_property_read_bool(valid_modes, "idle"))
+ constraints->valid_modes_mask |= REGULATOR_MODE_IDLE;
+ if (of_property_read_bool(valid_modes, "standby"))
+ constraints->valid_modes_mask |= REGULATOR_MODE_STANDBY;
+ }
+
+ /* flag assignment for initial mode*/
+ if (!of_property_match_string(np, "regulator-initial-mode", "fast"))
+ constraints->initial_mode = REGULATOR_MODE_FAST;
+ else if (!of_property_match_string(np, "regulator-initial-mode",
+ "normal"))
+ constraints->initial_mode = REGULATOR_MODE_NORMAL;
+ else if (!of_property_match_string(np, "regulator-initial-mode",
+ "idle"))
+ constraints->initial_mode = REGULATOR_MODE_IDLE;
+ else if (!of_property_match_string(np, "regulator-initial-mode",
+ "standby"))
+ constraints->initial_mode = REGULATOR_MODE_STANDBY;
+
+ /* flag assignment for initial state*/
+ if (!of_property_match_string(np,
+ "regulator-initial-state", "suspend-mem"))
+ constraints->initial_state = PM_SUSPEND_MEM;
+ else if (!of_property_match_string(np,
+ "regulator-initial-state", "suspend-standby"))
+ constraints->initial_state = PM_SUSPEND_STANDBY;
+ else if (!of_property_match_string(np,
+ "regulator-initial-state", "suspend-disk"))
+ constraints->initial_state = PM_SUSPEND_MAX;
+
+ /* regulator state during low power system states */
+ state = of_find_node_by_name(np, "regulator-state-mem");
+ if (state)
+ set_regulator_state_constraints(state,
+ &constraints->state_mem);
+
+ state = of_find_node_by_name(np, "regulator-state-disk");
+ if (state)
+ set_regulator_state_constraints(state,
+ &constraints->state_disk);
+
+ state = of_find_node_by_name(np, "regulator-state-standby");
+ if (state)
+ set_regulator_state_constraints(state,
+ &constraints->state_standby);
}
/**
--
1.7.0.4
WARNING: multiple messages have this Message-ID (diff)
From: Saurabh Singh <saurabh1.s@samsung.com>
To: Mark Brown <broonie@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>,
"lgirdwood@gmail.com" <lgirdwood@gmail.com>,
"grant.likely@linaro.org" <grant.likely@linaro.org>,
"rob.herring@calxeda.com" <rob.herring@calxeda.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
"celinux-dev@tree.celinuxforum.org"
<celinux-dev@tree.celinuxforum.org>,
SREEVATSA D B <srevatsa@samsung.com>,
Praveen BP <bp.praveen@samsung.com>
Subject: Re: [PATCH] Parse missing regulator constraints from device tree blob
Date: Fri, 17 Jan 2014 15:11:19 +0000 (GMT) [thread overview]
Message-ID: <758915.615271389971476784.JavaMail.weblogic@epml20> (raw)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=windows-1252, Size: 7156 bytes --]
This patch adds support for parsing following regulator contraints from
device tree blob.
1. valid modes mask (valid_modes_mask)
2. initial mode (initial_mode)
3. initial state (initial_state)
4. state mem (state_mem)
5. state disk (state_disk)
6. state standby (state_standby)
Signed-off-by: Saurabh Singh Sengar <saurabh1.s@samsung.com>
---
.../devicetree/bindings/regulator/regulator.txt | 45 ++++++++++++
drivers/regulator/of_regulator.c | 77 ++++++++++++++++++++
2 files changed, 122 insertions(+), 0 deletions(-)
diff --git a/Documentation/devicetree/bindings/regulator/regulator.txt b/Documentation/devicetree/bindings/regulator/regulator.txt
index 2bd8f09..6dc935b 100644
--- a/Documentation/devicetree/bindings/regulator/regulator.txt
+++ b/Documentation/devicetree/bindings/regulator/regulator.txt
@@ -14,6 +14,36 @@ Optional properties:
- regulator-ramp-delay: ramp delay for regulator(in uV/uS)
For hardwares which support disabling ramp rate, it should be explicitly
intialised to zero (regulator-ramp-delay = <0>) for disabling ramp delay.
+- regulator-valid-modes-mask: valid operations for regulator on particular machine
+ Supports following modes of operations:
+ Mode Description
+ ---- -----------
+ fast Regulator can handle fast changes in it's load
+ normal Normal regulator power supply mode
+ idle Regulator runs in a more efficient mode for light loads.
+ standby Regulator runs in the most efficient mode for very light loads
+ See the example given below.
+
+- regulator-initial-mode: default mode to set on startup
+ Refer to regulator-initial-mode for modes supported
+
+- regulator-initial-state: suspend state to set at init
+ Any one of the following states can be set:
+ Mode Description
+ ---- -----------
+ suspend-mem suspend to memory
+ suspend-standby standby mode
+ suspend-disk suspend to disk
+ See the example given below.
+
+- regulator-state-mem, regulator-state-disk, regulator-state-standby:
+ defines regulator suspend to memory, suspend to disk (hibernate) and standby respectively.
+ have following sub-constarints:
+ - regulator-state-uv: voltage to set in suspend state
+ - regulator-state-mode: suspend regulator operating mode,
+ refer to regulator-valid-modes-mask for modes supported
+ - regulator-state-enabled: is regulator enabled in this suspend state
+ - regulator-state-disabled: is the regulator disbled in this suspend state
Deprecated properties:
- regulator-compatible: If a regulator chip contains multiple
@@ -29,6 +59,21 @@ Example:
regulator-max-microvolt = <2500000>;
regulator-always-on;
vin-supply = <&vin>;
+ regulator-initial-mode = "normal";
+ regulator-initial-state = "suspend-mem";
+ regulator-valid-modes-mask {
+ /*can support multiple mode
+ * in this example supporting fast and normal mode */
+ fast-mode;
+ normal-mode;
+ };
+ regulator-state-mem {
+ regulator-state-mode = "idle";
+ regulator-state-enabled;
+ };
+ regulator-state-disk {
+ regulator-state-disabled;
+ };
};
Regulator Consumers:
diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c
index 7827384..3030597 100644
--- a/drivers/regulator/of_regulator.c
+++ b/drivers/regulator/of_regulator.c
@@ -16,11 +16,36 @@
#include <linux/regulator/machine.h>
#include <linux/regulator/of_regulator.h>
+/**
+ * set_regulator_state_constraints - set regulator state for low power system states
+ * @np: device node for the low power regulator state
+ * @regulator_state: regulator_state structure need to be filled
+ */
+static void set_regulator_state_constraints(struct device_node *np,
+ struct regulator_state *state)
+{
+ of_property_read_u32(np, "regulator-state-uv", &state->uV);
+ if (!of_property_match_string(np, "regulator-state-mode", "fast"))
+ state->mode = REGULATOR_MODE_FAST;
+ else if (!of_property_match_string(np, "regulator-state-mode",
+ "normal"))
+ state->mode = REGULATOR_MODE_NORMAL;
+ else if (!of_property_match_string(np, "regulator-state-mode", "idle"))
+ state->mode = REGULATOR_MODE_IDLE;
+ else if (!of_property_match_string(np, "regulator-state-mode",
+ "standby"))
+ state->mode = REGULATOR_MODE_STANDBY;
+ state->enabled = of_property_read_bool(np, "regulator-state-enabled");
+ state->disabled = of_property_read_bool(np, "regulator-state-disabled");
+}
+
+
static void of_get_regulation_constraints(struct device_node *np,
struct regulator_init_data **init_data)
{
const __be32 *min_uV, *max_uV, *uV_offset;
const __be32 *min_uA, *max_uA, *ramp_delay;
+ struct device_node *state, *valid_modes;
struct property *prop;
struct regulation_constraints *constraints = &(*init_data)->constraints;
@@ -73,6 +98,58 @@ static void of_get_regulation_constraints(struct device_node *np,
else
constraints->ramp_disable = true;
}
+
+ valid_modes = of_find_node_by_name(np, "regulator-valid-modes-mask");
+ if (valid_modes) {
+ if (of_property_read_bool(valid_modes, "fast"))
+ constraints->valid_modes_mask = REGULATOR_MODE_FAST;
+ if (of_property_read_bool(valid_modes, "normal"))
+ constraints->valid_modes_mask |= REGULATOR_MODE_NORMAL;
+ if (of_property_read_bool(valid_modes, "idle"))
+ constraints->valid_modes_mask |= REGULATOR_MODE_IDLE;
+ if (of_property_read_bool(valid_modes, "standby"))
+ constraints->valid_modes_mask |= REGULATOR_MODE_STANDBY;
+ }
+
+ /* flag assignment for initial mode*/
+ if (!of_property_match_string(np, "regulator-initial-mode", "fast"))
+ constraints->initial_mode = REGULATOR_MODE_FAST;
+ else if (!of_property_match_string(np, "regulator-initial-mode",
+ "normal"))
+ constraints->initial_mode = REGULATOR_MODE_NORMAL;
+ else if (!of_property_match_string(np, "regulator-initial-mode",
+ "idle"))
+ constraints->initial_mode = REGULATOR_MODE_IDLE;
+ else if (!of_property_match_string(np, "regulator-initial-mode",
+ "standby"))
+ constraints->initial_mode = REGULATOR_MODE_STANDBY;
+
+ /* flag assignment for initial state*/
+ if (!of_property_match_string(np,
+ "regulator-initial-state", "suspend-mem"))
+ constraints->initial_state = PM_SUSPEND_MEM;
+ else if (!of_property_match_string(np,
+ "regulator-initial-state", "suspend-standby"))
+ constraints->initial_state = PM_SUSPEND_STANDBY;
+ else if (!of_property_match_string(np,
+ "regulator-initial-state", "suspend-disk"))
+ constraints->initial_state = PM_SUSPEND_MAX;
+
+ /* regulator state during low power system states */
+ state = of_find_node_by_name(np, "regulator-state-mem");
+ if (state)
+ set_regulator_state_constraints(state,
+ &constraints->state_mem);
+
+ state = of_find_node_by_name(np, "regulator-state-disk");
+ if (state)
+ set_regulator_state_constraints(state,
+ &constraints->state_disk);
+
+ state = of_find_node_by_name(np, "regulator-state-standby");
+ if (state)
+ set_regulator_state_constraints(state,
+ &constraints->state_standby);
}
/**
--
1.7.0.4ÿôèº{.nÇ+·®+%Ëÿ±éݶ\x17¥wÿº{.nÇ+·¥{±þG«éÿ{ayº\x1dÊÚë,j\a¢f£¢·hïêÿêçz_è®\x03(éÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?¨èÚ&£ø§~á¶iOæ¬z·vØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?I¥
next reply other threads:[~2014-01-17 15:11 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-17 15:11 Saurabh Singh [this message]
2014-01-17 15:11 ` [PATCH] Parse missing regulator constraints from device tree blob Saurabh Singh
-- strict thread matches above, loose matches on Subject: below --
2014-01-17 15:04 Saurabh Singh
2014-01-17 15:04 ` Saurabh Singh
2014-01-16 13:43 Saurabh Singh
2014-01-16 13:43 ` Saurabh Singh
2014-01-16 14:07 ` Mark Brown
2014-01-16 14:07 ` Mark Brown
2014-01-16 6:34 Saurabh Singh
2014-01-16 6:34 ` Saurabh Singh
2014-01-16 10:28 ` Mark Rutland
2014-01-16 10:28 ` Mark Rutland
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=758915.615271389971476784.JavaMail.weblogic@epml20 \
--to=saurabh1.s@samsung.com \
--cc=bp.praveen@samsung.com \
--cc=broonie@kernel.org \
--cc=celinux-dev@tree.celinuxforum.org \
--cc=devicetree@vger.kernel.org \
--cc=grant.likely@linaro.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=rob.herring@calxeda.com \
--cc=srevatsa@samsung.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.