From: "Bengt Jönsson" <bengt.g.jonsson@stericsson.com>
To: Axel Lin <axel.lin@ingics.com>
Cc: Mark Brown <broonie@opensource.wolfsonmicro.com>,
Lee Jones <lee.jones@linaro.org>,
Yvan FILLION <yvan.fillion@stericsson.com>,
Liam Girdwood <lgirdwood@gmail.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH RFT 1/2] regulator: ab8500: Fix set voltage for AB8540_LDO_AUX3
Date: Tue, 16 Apr 2013 12:57:59 +0200 [thread overview]
Message-ID: <516D2EB7.8010608@stericsson.com> (raw)
In-Reply-To: <1365576052.4283.2.camel@phoenix>
On 04/10/2013 08:40 AM, Axel Lin wrote:
> When setting voltage for AB8540_LDO_AUX3, current code only updates one of
> info->voltage_reg and info->expand_register registers which is wrong.
> To ensure we set to correct voltage, it always needs to clear or set
> expand_register.voltage_mask bit of expand_register.
The original code is wrong. It is not possible to leave 3.05 V once set.
The function of the expand register bit is the following (from the user
manual):
0: VAUX3 output voltage is determined by Vaux3Sel bit settings in
register VldoCVaux3Sel
1: VAUX3 output voltage is set to 3.05 V regardless of Vaux3Sel settings
in register VldoCVaux3Sel
(VldoCVaux3Sel is the register at 0x0421)
So when going to 3.05 V I would like to set the bit as you are doing.
But when leaving 3.05 V for another voltage I would prefer setting the
target voltage before clearing the expand register bit.
>
> Signed-off-by: Axel Lin <axel.lin@ingics.com>
> ---
> drivers/regulator/ab8500.c | 55 ++++++++++++++++++++++++++++----------------
> 1 file changed, 35 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/regulator/ab8500.c b/drivers/regulator/ab8500.c
> index 9ebd131..222a63e 100644
> --- a/drivers/regulator/ab8500.c
> +++ b/drivers/regulator/ab8500.c
> @@ -605,39 +605,54 @@ static int ab8540_aux3_regulator_set_voltage_sel(struct regulator_dev *rdev,
> {
> int ret;
> struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
> - u8 regval;
> + u8 regval, regval_expand;
>
> if (info == NULL) {
> dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
> return -EINVAL;
> }
>
> - if (selector >= info->expand_register.voltage_limit) {
> - /* Vaux3 bit4 has different layout */
> - regval = (u8)selector << info->expand_register.voltage_shift;
> - ret = abx500_mask_and_set_register_interruptible(info->dev,
> - info->expand_register.voltage_bank,
> - info->expand_register.voltage_reg,
> - info->expand_register.voltage_mask,
> - regval);
> - } else {
> - /* set the registers for the request */
> - regval = (u8)selector << info->voltage_shift;
> - ret = abx500_mask_and_set_register_interruptible(info->dev,
> + if (selector >= info->expand_register.voltage_limit)
> + regval_expand = info->expand_register.voltage_mask;
> + else
> + regval_expand = 0;
> +
> + ret = abx500_mask_and_set_register_interruptible(info->dev,
> + info->expand_register.voltage_bank,
> + info->expand_register.voltage_reg,
> + info->expand_register.voltage_mask,
> + regval_expand);
> + if (ret < 0) {
> + dev_err(rdev_get_dev(rdev),
> + "couldn't set expand voltage reg for regulator\n");
> + return ret;
> + }
> +
> + dev_vdbg(rdev_get_dev(rdev),
> + "%s-set_voltage expand (bank, reg, mask, value): 0x%x, 0x%x, 0x%x, 0x%x\n",
> + info->desc.name, info->expand_register.voltage_bank,
> + info->expand_register.voltage_reg,
> + info->expand_register.voltage_mask, regval_expand);
> +
> + if (selector >= info->expand_register.voltage_limit)
> + return 0;
> +
> + regval = (u8)selector << info->voltage_shift;
> + ret = abx500_mask_and_set_register_interruptible(info->dev,
> info->voltage_bank, info->voltage_reg,
> info->voltage_mask, regval);
> - }
> - if (ret < 0)
> + if (ret < 0) {
> dev_err(rdev_get_dev(rdev),
> "couldn't set voltage reg for regulator\n");
> + return ret;
> + }
>
> dev_vdbg(rdev_get_dev(rdev),
> - "%s-set_voltage (bank, reg, mask, value): 0x%x, 0x%x, 0x%x,"
> - " 0x%x\n",
> - info->desc.name, info->voltage_bank, info->voltage_reg,
> - info->voltage_mask, regval);
> + "%s-set_voltage (bank, reg, mask, value): 0x%x, 0x%x, 0x%x, 0x%x\n",
> + info->desc.name, info->voltage_bank, info->voltage_reg,
> + info->voltage_mask, regval);
>
> - return ret;
> + return 0;
> }
>
> static struct regulator_ops ab8500_regulator_volt_mode_ops = {
prev parent reply other threads:[~2013-04-16 10:58 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-10 6:40 [PATCH RFT 1/2] regulator: ab8500: Fix set voltage for AB8540_LDO_AUX3 Axel Lin
2013-04-10 6:46 ` [PATCH RFT 2/2] regulator: ab8500: Optimize ab8540_aux3_regulator_get_voltage_sel Axel Lin
2013-04-16 11:12 ` Bengt Jönsson
2013-04-16 11:24 ` Mark Brown
2013-04-16 10:57 ` Bengt Jönsson [this message]
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=516D2EB7.8010608@stericsson.com \
--to=bengt.g.jonsson@stericsson.com \
--cc=axel.lin@ingics.com \
--cc=broonie@opensource.wolfsonmicro.com \
--cc=lee.jones@linaro.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=yvan.fillion@stericsson.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.