RE: [PATCH 5.10.y-cip 02/13] regulator: core: Add helper for allow HW access to enable/disable regulator

Biju Das
2024-07-30T12:32:40Z

Hi Pavel,

Thanks for the feedback.

> -----Original Message-----
> From: Pavel Machek <pavel@denx.de>
> Sent: Tuesday, July 30, 2024 1:28 PM
> enable/disable regulator
>
> Hi!
>
> > commit 1cb7d29157603561af4c38535e936850ceb99f0f upstream.
> >
> > Add a helper function that allow regulator consumers to allow
> > low-level HW access, in order to enable/disable regulator in atomic context.
> >
> > The use-case for RZ/G2L SoC is to enable VBUS selection register based
> > on vbus detection that happens in interrupt context.
> >
> > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> > Link:
> > https://patch.msgid.link/20240616105402.45211-4-biju.das.jz@bp.renesas
> > .com
> > Signed-off-by: Mark Brown <broonie@kernel.org>
> > Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> > ---
> > Documentation/power/regulator/consumer.rst | 6 +++++
> > drivers/regulator/core.c | 28 ++++++++++++++++++++++
> > include/linux/regulator/consumer.h | 7 ++++++
> > 3 files changed, 41 insertions(+)
> >
> > diff --git a/Documentation/power/regulator/consumer.rst
> > b/Documentation/power/regulator/consumer.rst
> > index 0cd8cc1275a7..ebc4c8076711 100644
> > --- a/Documentation/power/regulator/consumer.rst
> > +++ b/Documentation/power/regulator/consumer.rst
> > @@ -227,3 +227,9 @@ directly written to the voltage selector register, use::
> >
> > int regulator_list_hardware_vsel(struct regulator *regulator,
> > unsigned selector);
> > +
> > +To access the hardware for enabling/disabling the regulator,
> > +consumers must use regulator_get_exclusive(), as it can't work if
> > +there's more than one consumer. To enable/disable regulator use::
> > +
> > + int regulator_hardware_enable(struct regulator *regulator, bool
> > +enable);
> > diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index
> > 7082cffdd10e..c5b6979b2560 100644
> > --- a/drivers/regulator/core.c
> > +++ b/drivers/regulator/core.c
> > @@ -3244,6 +3244,34 @@ int regulator_list_hardware_vsel(struct
> > regulator *regulator, }
> > EXPORT_SYMBOL_GPL(regulator_list_hardware_vsel);
> >
> > +/**
> > + * regulator_hardware_enable - access the HW for enable/disable
> > +regulator
> > + * @regulator: regulator source
> > + * @enable: true for enable, false for disable
> > + *
> > + * Request that the regulator be enabled/disabled with the regulator
> > +output at
> > + * the predefined voltage or current value.
>
> "Unlinke other functions, this can be called ...".
>
> And fill in the blanks. "from interrupt context"? "with interrupts disabled"? I'm not sure what real
> limits are. Probably can't do that from NMI?

From interrupt context provided the callback function does not uses any sleeping calls.

Cheers,
Biju

>
> Best regards,
> Pavel
> --
> DENX Software Engineering GmbH, Managing Director: Erika Unter
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany