From: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
To: Mark Brown <broonie@kernel.org>
Cc: Lee Jones <lee.jones@linaro.org>,
Doug Anderson <dianders@chromium.org>,
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 v2 1/7] regulator: max77802: Add .{get,set}_mode callbacks
Date: Thu, 16 Oct 2014 18:48:47 +0200 [thread overview]
Message-ID: <1413478133-2577-2-git-send-email-javier.martinez@collabora.co.uk> (raw)
In-Reply-To: <1413478133-2577-1-git-send-email-javier.martinez@collabora.co.uk>
Some max77802 LDOs (1, 3, 20 and 21) support to be configured in Low
Power Mode during system normal operation. Add function handlers for
the .get_mode and .set_mode operations to set the mode on these LDOs.
Signed-off-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
---
Changes since v1:
- Use a static inline function instead of a macro to map the modes.
Suggested by Mark Brown.
- Don't have multiple standard modes mapping onto a single hw mode.
Suggested by Mark Brown.
drivers/regulator/max77802.c | 46 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 46 insertions(+)
diff --git a/drivers/regulator/max77802.c b/drivers/regulator/max77802.c
index 8425c0d..6eabb95 100644
--- a/drivers/regulator/max77802.c
+++ b/drivers/regulator/max77802.c
@@ -70,6 +70,12 @@ struct max77802_regulator_prv {
unsigned int opmode[MAX77802_REG_MAX];
};
+static inline int max77802_map_mode(int mode)
+{
+ return mode == MAX77802_OPMODE_NORMAL ?
+ REGULATOR_MODE_NORMAL : REGULATOR_MODE_STANDBY;
+}
+
static int max77802_get_opmode_shift(int id)
{
if (id == MAX77802_BUCK1 || (id >= MAX77802_BUCK5 &&
@@ -105,6 +111,44 @@ static int max77802_set_suspend_disable(struct regulator_dev *rdev)
}
/*
+ * Some LDOs support Low Power Mode while the system is running.
+ *
+ * LDOs 1, 3, 20, 21.
+ */
+static int max77802_set_mode(struct regulator_dev *rdev, unsigned int mode)
+{
+ struct max77802_regulator_prv *max77802 = rdev_get_drvdata(rdev);
+ int id = rdev_get_id(rdev);
+ unsigned int val;
+ int shift = max77802_get_opmode_shift(id);
+
+ switch (mode) {
+ case REGULATOR_MODE_STANDBY:
+ val = MAX77802_OPMODE_LP; /* ON in Low Power Mode */
+ break;
+ case REGULATOR_MODE_NORMAL:
+ val = MAX77802_OPMODE_NORMAL; /* ON in Normal Mode */
+ break;
+ default:
+ dev_warn(&rdev->dev, "%s: regulator mode: 0x%x not supported\n",
+ rdev->desc->name, mode);
+ return -EINVAL;
+ }
+
+ max77802->opmode[id] = val;
+ return regmap_update_bits(rdev->regmap, rdev->desc->enable_reg,
+ rdev->desc->enable_mask, val << shift);
+}
+
+static unsigned max77802_get_mode(struct regulator_dev *rdev)
+{
+ struct max77802_regulator_prv *max77802 = rdev_get_drvdata(rdev);
+ int id = rdev_get_id(rdev);
+
+ return max77802_map_mode(max77802->opmode[id]);
+}
+
+/*
* Some LDOs supports LPM-ON/OFF/Normal-ON mode during suspend state
* (Enable Control Logic1 by PWRREQ)
*
@@ -268,6 +312,8 @@ static struct regulator_ops max77802_ldo_ops_logic2 = {
.get_voltage_sel = regulator_get_voltage_sel_regmap,
.set_voltage_sel = regulator_set_voltage_sel_regmap,
.set_voltage_time_sel = regulator_set_voltage_time_sel,
+ .set_mode = max77802_set_mode,
+ .get_mode = max77802_get_mode,
.set_suspend_mode = max77802_ldo_set_suspend_mode_logic2,
};
--
2.1.0
next prev parent reply other threads:[~2014-10-16 16:48 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-16 16:48 [PATCH v2 0/7] Add max77802 regulator operating mode support Javier Martinez Canillas
2014-10-16 16:48 ` Javier Martinez Canillas [this message]
2014-10-17 12:39 ` [PATCH v2 1/7] regulator: max77802: Add .{get,set}_mode callbacks Mark Brown
2014-10-16 16:48 ` [PATCH v2 2/7] regulator: max77802: Add set suspend mode for BUCKs and simplify code Javier Martinez Canillas
2014-10-17 12:39 ` Mark Brown
2014-10-16 16:48 ` [PATCH v2 3/7] regulator: max77802: Don't treat OFF as an operating mode Javier Martinez Canillas
2014-10-17 12:44 ` Mark Brown
2014-10-16 16:48 ` [PATCH v2 4/7] regulator: max77802: Add header for operating modes Javier Martinez Canillas
[not found] ` <1413478133-2577-5-git-send-email-javier.martinez-ZGY8ohtN/8pPYcu2f3hruQ@public.gmane.org>
2014-10-17 8:04 ` Lee Jones
2014-10-17 12:45 ` Mark Brown
2014-10-16 16:48 ` [PATCH v2 5/7] regulator: max77802: Document regulator opmode DT properties Javier Martinez Canillas
2014-10-17 11:57 ` Mark Brown
[not found] ` <20141017115701.GE1820-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2014-10-17 12:39 ` Javier Martinez Canillas
[not found] ` <54410DF3.5020005-ZGY8ohtN/8pPYcu2f3hruQ@public.gmane.org>
2014-10-17 13:54 ` Mark Brown
[not found] ` <20141017135441.GR1820-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2014-10-17 14:18 ` Javier Martinez Canillas
2014-10-16 16:48 ` [PATCH v2 6/7] regulator: max77802: Parse regulator operating mode properties Javier Martinez Canillas
2014-10-16 16:48 ` [PATCH v2 7/7] ARM: dts: Configure regulators for suspend on exynos Peach boards 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=1413478133-2577-2-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=dianders@chromium.org \
--cc=k.kozlowski@samsung.com \
--cc=kesavan.abhilash@gmail.com \
--cc=lee.jones@linaro.org \
--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).