From: Chen-Yu Tsai <wens@csie.org>
To: Mark Brown <broonie@kernel.org>, Lee Jones <lee.jones@linaro.org>,
Rob Herring <robh+dt@kernel.org>,
Grant Likely <grant.likely@linaro.org>,
Maxime Ripard <maxime.ripard@free-electrons.com>
Cc: devicetree@vger.kernel.org, Chen-Yu Tsai <wens@csie.org>,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org
Subject: [PATCH v9 4/5] regulators: axp20x: Change dcdc-workmode DT property to boolean flag
Date: Thu, 22 Jan 2015 23:39:06 +0800 [thread overview]
Message-ID: <1421941147-9682-5-git-send-email-wens@csie.org> (raw)
In-Reply-To: <1421941147-9682-1-git-send-email-wens@csie.org>
The "x-powers,dcdc-workmode" property only has 2 values. A request was
made to change this to a boolean flag named "x-powers,dcdc-workmode-pwm".
Given that this particular binding hasn't been used anywhere, it should
be safe to change.
Previously the absence of the property meant just keeping the PMIC in
whatever state was set by the bootloader. After this change, the absence
means using the "auto" (PWM/PFM hybrid) mode, which is also the hardware's
default.
This patch also makes axp20x_set_dcdc_workmode() ignore attempts to set
the workmode for non-DCDC regulators.
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
---
drivers/regulator/axp20x-regulator.c | 27 +++++++++++++--------------
1 file changed, 13 insertions(+), 14 deletions(-)
diff --git a/drivers/regulator/axp20x-regulator.c b/drivers/regulator/axp20x-regulator.c
index 990ac453abc8..0b099e5ece3f 100644
--- a/drivers/regulator/axp20x-regulator.c
+++ b/drivers/regulator/axp20x-regulator.c
@@ -202,19 +202,21 @@ static int axp20x_regulator_parse_dt(struct platform_device *pdev)
return 0;
}
-static int axp20x_set_dcdc_workmode(struct regulator_dev *rdev, int id, u32 workmode)
+static int axp20x_set_dcdc_workmode(struct regulator_dev *rdev, int id, bool workmode)
{
unsigned int mask = AXP20X_WORKMODE_DCDC2_MASK;
+ u32 val;
+ /* ignore setting workmode for non-dcdc regulators */
if ((id != AXP20X_DCDC2) && (id != AXP20X_DCDC3))
- return -EINVAL;
+ return 0;
if (id == AXP20X_DCDC3)
mask = AXP20X_WORKMODE_DCDC3_MASK;
- workmode <<= ffs(mask) - 1;
+ val = workmode ? mask : 0;
- return regmap_update_bits(rdev->regmap, AXP20X_DCDC_MODE, mask, workmode);
+ return regmap_update_bits(rdev->regmap, AXP20X_DCDC_MODE, mask, val);
}
static int axp20x_regulator_probe(struct platform_device *pdev)
@@ -225,8 +227,8 @@ static int axp20x_regulator_probe(struct platform_device *pdev)
.dev = pdev->dev.parent,
.regmap = axp20x->regmap,
};
- int ret, i;
- u32 workmode;
+ int i;
+ bool workmode;
/* This only sets the dcdc freq. Ignore any errors */
axp20x_regulator_parse_dt(pdev);
@@ -241,14 +243,11 @@ static int axp20x_regulator_probe(struct platform_device *pdev)
return PTR_ERR(rdev);
}
- ret = of_property_read_u32(rdev->dev.of_node,
- "x-powers,dcdc-workmode",
- &workmode);
- if (!ret) {
- if (axp20x_set_dcdc_workmode(rdev, i, workmode))
- dev_err(&pdev->dev, "Failed to set workmode on %s\n",
- axp20x_regulators[i].name);
- }
+ workmode = of_property_read_bool(rdev->dev.of_node,
+ "x-powers,dcdc-workmode-pwm");
+ if (axp20x_set_dcdc_workmode(rdev, i, workmode))
+ dev_err(&pdev->dev, "Failed to set workmode on %s\n",
+ axp20x_regulators[i].name);
}
return 0;
--
2.1.4
next prev parent reply other threads:[~2015-01-22 15:39 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-22 15:39 [PATCH v9 0/5] mfd: axp20x: add support for AXP202 and AXP209 Chen-Yu Tsai
2015-01-22 15:39 ` [PATCH v9 1/5] dt-bindings: add vendor-prefix for X-Powers Chen-Yu Tsai
2015-01-22 15:39 ` [PATCH v9 2/5] mfd: AXP20x: Add bindings documentation Chen-Yu Tsai
2015-01-22 16:02 ` Lee Jones
2015-01-31 16:49 ` Chen-Yu Tsai
2015-02-02 8:53 ` Lee Jones
2015-02-10 7:34 ` Chen-Yu Tsai
2015-01-22 15:39 ` [PATCH v9 3/5] regulators: axp20x: Use "clock-frequency" property for dcdc work frequency Chen-Yu Tsai
[not found] ` <1421941147-9682-4-git-send-email-wens-jdAy2FN1RRM@public.gmane.org>
2015-01-27 12:14 ` Mark Brown
2015-01-22 15:39 ` Chen-Yu Tsai [this message]
2015-01-27 12:27 ` [PATCH v9 4/5] regulators: axp20x: Change dcdc-workmode DT property to boolean flag Mark Brown
2015-01-22 15:39 ` [PATCH v9 5/5] ARM: sunxi: dts: axp209: Use clock-frequency for DC-DC work frequency Chen-Yu Tsai
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=1421941147-9682-5-git-send-email-wens@csie.org \
--to=wens@csie.org \
--cc=broonie@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=grant.likely@linaro.org \
--cc=lee.jones@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maxime.ripard@free-electrons.com \
--cc=robh+dt@kernel.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).