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

Biju Das
2024-07-31T13:08:28Z

Hi Pavel,

> -----Original Message-----
> From: Pavel Machek <pavel@denx.de>
> Sent: Wednesday, July 31, 2024 11:06 AM
> Subject: Re: [PATCH 5.10.y-cip 02/13] regulator: core: Add helper for
> allow HW access to enable/disable regulator
>
> Hi!
>
> > > > +++ 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.
>
> So the contexts allowed differ based on what low-level driver is used?
> That's quite unfortunate...

The only limitation is it has to be exclusive usage. Other than that it is for generic usage.

Ie, can be used for regulator_gpio_enable or regulator_regmap_enable()

Currently regulator API won't allow you to enable or disable() in atomic context.
But this API allows to you do that.

Cheers,
Biju