mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Cristian Ciocaltea <cristian.ciocaltea@gmail.com>
To: Axel Lin <axel.lin@ingics.com>
Cc: Mark Brown <broonie@kernel.org>,
	Manivannan Sadhasivam <mani@kernel.org>,
	linux-actions@lists.infradead.org,
	Liam Girdwood <lgirdwood@gmail.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH RFT] regulator: atc260x: Fix n_voltages and min_sel for pickable linear ranges
Date: Sat, 29 May 2021 01:06:26 +0300	[thread overview]
Message-ID: <20210528220626.GA222540@BV030612LT> (raw)
In-Reply-To: <20210528123826.350771-1-axel.lin@ingics.com>

Hi Axel,

On Fri, May 28, 2021 at 08:38:26PM +0800, Axel Lin wrote:
> The .n_voltages was missed for pickable linear ranges, fix it.

Nice spot! I'm not quite sure if this is really mandatory to be manually
specified or gets computed internally based on the provided linear
ranges, but let's be on the safe side.

> The min_sel for each pickable range should be starting from 0.

Right, although in this particular case the driver behaves correctly
because the overflow bit of every item in the 2nd range is exactly the
range selector (bit 5 - LDO<N>_VOL_SEL in datasheet). Additionally, this
bit is not cleared internally as the selector mask (vsel_mask) is not
applied directly, but in conjunction with the range mask, according to
the implementation of "regulator_set_voltage_sel_pickable_regmap()":

	[...]
		ret = regmap_update_bits(rdev->regmap,
					 rdev->desc->vsel_reg,
					 rdev->desc->vsel_range_mask |
					 rdev->desc->vsel_mask, sel | range);
	[...]

As a matter of fact, using 0-based ranges will break the driver because
the 2nd item in the range sel array "atc260x_ldo_voltage_range_sel" is
not correct, it should be 0x20 instead of 0x1 (0x1<<5, since it is not
shifted automatically as in the case of the voltage selectors).

> Fixes: 3b15ccac161a ("regulator: Add regulator driver for ATC260x PMICs")
> Signed-off-by: Axel Lin <axel.lin@ingics.com>
> ---
> Hi Cristian,
> I don't have this h/w to test, please review and test this patch.

Unfortunately I can only test the ATC2603C variant, I haven't been able
to get a 2609A based board yet.

Thanks,
Cristi

> Thanks,
> Axel
>  drivers/regulator/atc260x-regulator.c | 17 +++++++++--------
>  1 file changed, 9 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/regulator/atc260x-regulator.c b/drivers/regulator/atc260x-regulator.c
> index d8b429955d33..5dee02394cd9 100644
> --- a/drivers/regulator/atc260x-regulator.c
> +++ b/drivers/regulator/atc260x-regulator.c
> @@ -28,12 +28,12 @@ static const struct linear_range atc2609a_dcdc_voltage_ranges[] = {
>  
>  static const struct linear_range atc2609a_ldo_voltage_ranges0[] = {
>  	REGULATOR_LINEAR_RANGE(700000, 0, 15, 100000),
> -	REGULATOR_LINEAR_RANGE(2100000, 16, 28, 100000),
> +	REGULATOR_LINEAR_RANGE(2100000, 0, 12, 100000),
>  };
>  
>  static const struct linear_range atc2609a_ldo_voltage_ranges1[] = {
>  	REGULATOR_LINEAR_RANGE(850000, 0, 15, 100000),
> -	REGULATOR_LINEAR_RANGE(2100000, 16, 27, 100000),
> +	REGULATOR_LINEAR_RANGE(2100000, 0, 11, 100000),
>  };
>  
>  static const unsigned int atc260x_ldo_voltage_range_sel[] = {
> @@ -411,7 +411,7 @@ enum atc2609a_reg_ids {
>  	.owner = THIS_MODULE, \
>  }
>  
> -#define atc2609a_reg_desc_ldo_range_pick(num, n_range) { \
> +#define atc2609a_reg_desc_ldo_range_pick(num, n_range, n_volt) { \
>  	.name = "LDO"#num, \
>  	.supply_name = "ldo"#num, \
>  	.of_match = of_match_ptr("ldo"#num), \
> @@ -421,6 +421,7 @@ enum atc2609a_reg_ids {
>  	.type = REGULATOR_VOLTAGE, \
>  	.linear_ranges = atc2609a_ldo_voltage_ranges##n_range, \
>  	.n_linear_ranges = ARRAY_SIZE(atc2609a_ldo_voltage_ranges##n_range), \
> +	.n_voltages = n_volt, \
>  	.vsel_reg = ATC2609A_PMU_LDO##num##_CTL0, \
>  	.vsel_mask = GENMASK(4, 1), \
>  	.vsel_range_reg = ATC2609A_PMU_LDO##num##_CTL0, \
> @@ -458,12 +459,12 @@ static const struct regulator_desc atc2609a_reg[] = {
>  	atc2609a_reg_desc_ldo_bypass(0),
>  	atc2609a_reg_desc_ldo_bypass(1),
>  	atc2609a_reg_desc_ldo_bypass(2),
> -	atc2609a_reg_desc_ldo_range_pick(3, 0),
> -	atc2609a_reg_desc_ldo_range_pick(4, 0),
> +	atc2609a_reg_desc_ldo_range_pick(3, 0, 29),
> +	atc2609a_reg_desc_ldo_range_pick(4, 0, 29),
>  	atc2609a_reg_desc_ldo(5),
> -	atc2609a_reg_desc_ldo_range_pick(6, 1),
> -	atc2609a_reg_desc_ldo_range_pick(7, 0),
> -	atc2609a_reg_desc_ldo_range_pick(8, 0),
> +	atc2609a_reg_desc_ldo_range_pick(6, 1, 28),
> +	atc2609a_reg_desc_ldo_range_pick(7, 0, 29),
> +	atc2609a_reg_desc_ldo_range_pick(8, 0, 29),
>  	atc2609a_reg_desc_ldo_fixed(9),
>  };
>  
> -- 
> 2.25.1
> 

  reply	other threads:[~2021-05-28 22:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-28 12:38 Axel Lin
2021-05-28 22:06 ` Cristian Ciocaltea [this message]
2021-06-01 17:38 ` Mark Brown

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=20210528220626.GA222540@BV030612LT \
    --to=cristian.ciocaltea@gmail.com \
    --cc=axel.lin@ingics.com \
    --cc=broonie@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-actions@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mani@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

all inboxes | Powered by JetHome®