linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Henry Chen <henryc.chen@mediatek.com>
To: Rob Herring <robh+dt@kernel.org>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>,
	Matthias Brugger <matthias.bgg@gmail.com>
Cc: Pawel Moll <pawel.moll@arm.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Ian Campbell <ijc+devicetree@hellion.org.uk>,
	Kumar Gala <galak@codeaurora.org>,
	Stephen Boyd <sboyd@codeaurora.org>,
	Henry Chen <henryc.chen@mediatek.com>,
	Bjorn Andersson <bjorn.andersson@sonymobile.com>,
	Laxman Dewangan <ldewangan@nvidia.com>,
	<devicetree@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-mediatek@lists.infradead.org>
Subject: [PATCH 1/2] regulator: Add support for parsing operation mode
Date: Wed, 11 May 2016 17:12:08 +0800	[thread overview]
Message-ID: <1462957929-20105-2-git-send-email-henryc.chen@mediatek.com> (raw)
In-Reply-To: <1462957929-20105-1-git-send-email-henryc.chen@mediatek.com>

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>
---
 Documentation/devicetree/bindings/regulator/regulator.txt | 10 ++++++++++
 drivers/regulator/of_regulator.c                          | 14 ++++++++++++++
 2 files changed, 24 insertions(+)

diff --git a/Documentation/devicetree/bindings/regulator/regulator.txt b/Documentation/devicetree/bindings/regulator/regulator.txt
index ecfc593..88f98f0 100644
--- a/Documentation/devicetree/bindings/regulator/regulator.txt
+++ b/Documentation/devicetree/bindings/regulator/regulator.txt
@@ -49,6 +49,16 @@ Optional properties:
 	0: Disable active discharge.
 	1: Enable active discharge.
 	Absence of this property will leave configuration to default.
+- regulator-allow-change-mode: allow the regulator mode to be configured
+- regulator-supported-modes: Regulators can run in a variety of different operating
+  modes depending on output load. This allows further system power savings by
+  selecting the best (and most efficient) regulator mode for a desired load.
+  The definition for each of these operation is defined at
+  include/linux/regulator/consumer.h
+	0: FAST.
+	1: NORMAL.
+	2: IDLE.
+	3: STANDBY.
 
 Deprecated properties:
 - regulator-compatible: If a regulator chip contains multiple
diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c
index 6b0aa80..12fe8c8 100644
--- a/drivers/regulator/of_regulator.c
+++ b/drivers/regulator/of_regulator.c
@@ -167,6 +167,20 @@ static void of_get_regulation_constraints(struct device_node *np,
 		suspend_state = NULL;
 		suspend_np = NULL;
 	}
+
+	if (of_property_read_bool(np, "regulator-allow-change-mode"))
+		constraints->valid_ops_mask |= REGULATOR_CHANGE_MODE;
+
+	ret = of_property_count_elems_of_size(np,
+					      "regulator-supported-modes",
+					      sizeof(u32));
+	for (i = 0; i < ret; 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

  reply	other threads:[~2016-05-11  9:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-11  9:12 Add support for regulator operation mode of mt6397 Henry Chen
2016-05-11  9:12 ` Henry Chen [this message]
2016-05-11 10:53   ` [PATCH 1/2] regulator: Add support for parsing operation mode Daniel Kurtz
2016-05-11  9:12 ` [PATCH 2/2] regulator: mt6397: Add buck change mode regulator interface for mt6397 Henry Chen

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=1462957929-20105-2-git-send-email-henryc.chen@mediatek.com \
    --to=henryc.chen@mediatek.com \
    --cc=bjorn.andersson@sonymobile.com \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=galak@codeaurora.org \
    --cc=ijc+devicetree@hellion.org.uk \
    --cc=ldewangan@nvidia.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=mark.rutland@arm.com \
    --cc=matthias.bgg@gmail.com \
    --cc=pawel.moll@arm.com \
    --cc=robh+dt@kernel.org \
    --cc=sboyd@codeaurora.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).