All of lore.kernel.org
 help / color / mirror / Atom feed
From: "cy_huang(黃啟原)" <cy_huang@richtek.com>
To: "axel.lin@ingics.com" <axel.lin@ingics.com>,
	"broonie@kernel.org" <broonie@kernel.org>
Cc: "lgirdwood@gmail.com" <lgirdwood@gmail.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] regulator: rt6160: Convert to use regulator_set_ramp_delay_regmap
Date: Thu, 3 Jun 2021 10:20:41 +0000	[thread overview]
Message-ID: <1622715641.1034.5.camel@richtek.com> (raw)
In-Reply-To: <20210603093809.1108629-1-axel.lin@ingics.com>

Hi, Axel:> Use regulator_set_ramp_delay_regmap instead of open-coded.
>
There's some reason.
You can refer to https://lkml.org/lkml/2021/6/1/1145.

It's because our ramp value order is from small to large, not large to small.
It conflicts with find_closest_bigger value chosen logic.

That's why I need hard-coded for my ramp value selection.
> Signed-off-by: Axel Lin <axel.lin@ingics.com>
> ---
>  drivers/regulator/rt6160-regulator.c | 35 +++++++---------------------
>  1 file changed, 9 insertions(+), 26 deletions(-)
>
> diff --git a/drivers/regulator/rt6160-regulator.c b/drivers/regulator/rt6160-
> regulator.c
> index 4588ae0748a5..69550284083d 100644
> --- a/drivers/regulator/rt6160-regulator.c
> +++ b/drivers/regulator/rt6160-regulator.c
> @@ -46,6 +46,10 @@ struct rt6160_priv {
>  bool enable_state;
>  };
>
> +static const unsigned int rt6160_ramp_tables[] = {
> +1000, 2500, 5000, 10000
> +};
> +
>  static int rt6160_enable(struct regulator_dev *rdev)
>  {
>  struct rt6160_priv *priv = rdev_get_drvdata(rdev);
> @@ -140,31 +144,6 @@ static int rt6160_set_suspend_voltage(struct
> regulator_dev *rdev, int uV)
>  return regmap_update_bits(regmap, reg, RT6160_VSEL_MASK, vsel);
>  }
>
> -static int rt6160_set_ramp_delay(struct regulator_dev *rdev, int target)
> -{
> -struct regmap *regmap = rdev_get_regmap(rdev);
> -const int ramp_tables[] = { 1000, 2500, 5000, 10000 };
> -unsigned int i, sel;
> -
> -/* Find closest larger or equal */
> -for (i = 0; i < ARRAY_SIZE(ramp_tables); i++) {
> -sel = i;
> -
> -/* If ramp delay is equal to 0, directly set ramp speed to
> fastest */
> -if (target == 0) {
> -sel = ARRAY_SIZE(ramp_tables) - 1;
> -break;
> -}
> -
> -if (target <= ramp_tables[i])
> -break;
> -}
> -
> -sel <<= ffs(RT6160_RAMPRATE_MASK) - 1;
> -
> -return regmap_update_bits(regmap, RT6160_REG_CNTL,
> RT6160_RAMPRATE_MASK, sel);
> -}
> -
>  static int rt6160_get_error_flags(struct regulator_dev *rdev, unsigned int
> *flags)
>  {
>  struct regmap *regmap = rdev_get_regmap(rdev);
> @@ -203,7 +182,7 @@ static const struct regulator_ops rt6160_regulator_ops = {
>  .set_mode = rt6160_set_mode,
>  .get_mode = rt6160_get_mode,
>  .set_suspend_voltage = rt6160_set_suspend_voltage,
> -.set_ramp_delay = rt6160_set_ramp_delay,
> +.set_ramp_delay = regulator_set_ramp_delay_regmap,
>  .get_error_flags = rt6160_get_error_flags,
>  };
>
> @@ -292,6 +271,10 @@ static int rt6160_probe(struct i2c_client *i2c)
>  priv->desc.vsel_reg = RT6160_REG_VSELH;
>  priv->desc.vsel_mask = RT6160_VSEL_MASK;
>  priv->desc.n_voltages = RT6160_N_VOUTS;
> +priv->desc.ramp_reg = RT6160_REG_CNTL;
> +priv->desc.ramp_mask = RT6160_RAMPRATE_MASK;
> +priv->desc.ramp_delay_table = rt6160_ramp_tables;
> +priv->desc.n_ramp_values = ARRAY_SIZE(rt6160_ramp_tables);
>  priv->desc.of_map_mode = rt6160_of_map_mode;
>  priv->desc.ops = &rt6160_regulator_ops;
>  if (priv->vsel_active_low)
************* Email Confidentiality Notice ********************

The information contained in this e-mail message (including any attachments) may be confidential, proprietary, privileged, or otherwise exempt from disclosure under applicable laws. It is intended to be conveyed only to the designated recipient(s). Any use, dissemination, distribution, printing, retaining or copying of this e-mail (including its attachments) by unintended recipient(s) is strictly prohibited and may be unlawful. If you are not an intended recipient of this e-mail, or believe that you have received this e-mail in error, please notify the sender immediately (by replying to this e-mail), delete any and all copies of this e-mail (including any attachments) from your system, and do not disclose the content of this e-mail to any other person. Thank you!

  reply	other threads:[~2021-06-03 10:31 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-03  9:38 [PATCH] regulator: rt6160: Convert to use regulator_set_ramp_delay_regmap Axel Lin
2021-06-03 10:20 ` cy_huang(黃啟原) [this message]
2021-06-03 10:28   ` Axel Lin
2021-06-03 10:41     ` cy_huang(黃啟原)
2021-06-03 10:57       ` Axel Lin
2021-06-03 15:18       ` cy_huang(黃啟原)
2021-06-04  0:13         ` Axel Lin
     [not found]           ` <1622773474.9011.14.camel@richtek.com>
2021-06-04  3:30             ` Axel Lin
     [not found]               ` <1622785727.9011.17.camel@richtek.com>
2021-06-04  5:59                 ` Axel Lin
     [not found]                   ` <1622788151.9011.20.camel@richtek.com>
2021-06-09  3:32                     ` Axel Lin
2021-06-09  3:38                       ` cy_huang(黃啟原)
2021-06-14 19:53 ` 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=1622715641.1034.5.camel@richtek.com \
    --to=cy_huang@richtek.com \
    --cc=axel.lin@ingics.com \
    --cc=broonie@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.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 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.