devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: ChiYuan Huang <u0084500@gmail.com>
To: Mark Brown <broonie@kernel.org>
Cc: lgirdwood@gmail.com, Rob Herring <robh+dt@kernel.org>,
	lkml <linux-kernel@vger.kernel.org>,
	cy_huang <cy_huang@richtek.com>,
	"open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" 
	<devicetree@vger.kernel.org>
Subject: Re: [PATCH v4 2/2] regulator: rt6160: Add support for Richtek RT6160
Date: Thu, 27 May 2021 11:14:17 +0800	[thread overview]
Message-ID: <CADiBU3-LjetAkzks4MZKiK=KXK5ziFhF9D13cAjJ4W5gytw74A@mail.gmail.com> (raw)
In-Reply-To: <CADiBU393NchfrTmgPApNRqSVrTBGT+bs+H+m2UF_H3tSGLyFVQ@mail.gmail.com>

HI, Mark:

ChiYuan Huang <u0084500@gmail.com> 於 2021年5月26日 週三 下午11:04寫道:
>
> HI:
>
> Mark Brown <broonie@kernel.org> 於 2021年5月26日 週三 下午6:50寫道:
> >
> > On Wed, May 26, 2021 at 01:47:48PM +0800, cy_huang wrote:
> >
> > This looks mostly good, a few small issues below:
> >
> > > +static int rt6160_set_suspend_voltage(struct regulator_dev *rdev, int uV)
> > > +{
> > > +     struct rt6160_priv *priv = rdev_get_drvdata(rdev);
> > > +     struct regmap *regmap = rdev_get_regmap(rdev);
> > > +     unsigned int reg = RT6160_REG_VSELH;
> > > +     int vsel;
> > > +
> > > +     vsel = regulator_map_voltage_linear(rdev, uV, uV);
> > > +     if (vsel < 0)
> > > +             return vsel;
> > > +
> > > +     if (priv->vsel_active_low)
> > > +             reg = RT6160_REG_VSELL;
> > > +
> > > +     return regmap_update_bits(regmap, reg, RT6160_VSEL_MASK, vsel);
> > > +}
> >
> > This seems to just be updating the normal voltage configuration
> > regulator, the suspend mode operations are there for devices that
> > have a hardware suspend mode that's entered as part of the very
> > low level system suspend process.
> >
> There's a independent 'vsel' pin. It depend on user's HW design.
> And that's why there's a 'richtek,vsel_active_low' property.
> Its normal application is to use vsel high active level, and it means
> the opposite level can be used for the suspend voltage
>
> And there're also two voltage registers for vsel level high and low.
> > > +static int rt6160_set_ramp_delay(struct regulator_dev *rdev, int ramp_delay)
> > > +{
> > > +     struct regmap *regmap = rdev_get_regmap(rdev);
> > > +     unsigned int ramp_value = RT6160_RAMPRATE_1VMS;
> > > +
> > > +     switch (ramp_delay) {
> > > +     case 1 ... 1000:
> > > +             ramp_value = RT6160_RAMPRATE_1VMS;
> > > +             break;
> >
> > This looks like it could be converted to regulator_set_ramp_delay_regmap()
> >
> I didn't notice there's the regulator_set_ramp_delay_regmap API that
> can be used in kernel 5.13.u
> Ack in next.

I review the regulator_set_ramp_delay_regmap API.
If seems I need to fill in the ramp_delay_table by the descend order.
But this chip ramp delay table is designed the ascending value reg bit
field [0 1 2 3] by
the ascending order [1000 2500 5000 10000] uV/uS
Even if I tried to filler in descending order, I also need a inverted operation.

And I found the regulator_set_ramp_delay_regmap API has some logic error.
From the include/linux/regulator/driver.h, the set_ramp_delay function says to
set the less or equal one ramp delay value.
But your logic will get the larger or equal one from the descending
ramp delay table.

Could you help to check about this?
> > > +static unsigned int rt6160_of_map_mode(unsigned int mode)
> > > +{
> > > +     if (mode == RT6160_MODE_FPWM)
> > > +             return REGULATOR_MODE_FAST;
> > > +     else if (mode == RT6160_MODE_AUTO)
> > > +             return REGULATOR_MODE_NORMAL;
> > > +
> >
> > This would be more idiomatically written as a switch statement.
> >
> Ack in next. Change the if-else to switch case. Thx.
> > > +     enable_gpio = devm_gpiod_get_optional(&i2c->dev, "enable", GPIOD_OUT_HIGH);
> > > +     if (IS_ERR(enable_gpio)) {
> > > +             dev_err(&i2c->dev, "Failed to get 'enable' gpio\n");
> > > +             return PTR_ERR(enable_gpio);
> > > +     }
> >
> > There's no other references to enable_gpio?
> >
> The IC is designed for low IQ.
> So from the driver probe, I only need to keep 'enable' pin high.
> Or if user specify the 'enable' gpio, it will block i2c communication,
> register also be reset,
> and add more delay time on enable/disable.
> That's why there's no other references to 'enable' gpio.
> > > +     regmap = devm_regmap_init_i2c(i2c, &rt6160_regmap_config);
> > > +     if (IS_ERR(regmap)) {
> > > +             dev_err(&i2c->dev, "Failed to init regmap\n");
> > > +             return PTR_ERR(regmap);
> > > +     }
> >
> > It's better to print the error code to help anyone who runs into
> > issues figure out what's wrong.
> Sure, change it to dev_err(&i2c->dev, "Failed to init regmap (%d)\n",
> PTR_ERR(regmap));
> Ack in next, thx.

  reply	other threads:[~2021-05-27  3:14 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-26  5:47 [PATCH v4 1/2] regulator: rt6160: Add DT binding document for Richtek RT6160 cy_huang
2021-05-26  5:47 ` [PATCH v4 2/2] regulator: rt6160: Add support " cy_huang
2021-05-26 10:51   ` Mark Brown
2021-05-26 15:04     ` ChiYuan Huang
2021-05-27  3:14       ` ChiYuan Huang [this message]
2021-06-01 15:52         ` Mark Brown
2021-06-02  1:48           ` ChiYuan Huang

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='CADiBU3-LjetAkzks4MZKiK=KXK5ziFhF9D13cAjJ4W5gytw74A@mail.gmail.com' \
    --to=u0084500@gmail.com \
    --cc=broonie@kernel.org \
    --cc=cy_huang@richtek.com \
    --cc=devicetree@vger.kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --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).