Re: [RFC PATCH v1] regulator: pwm-regulator: Fix continuous get_voltage for disabled PWM

From: Mark Brown
Date: Fri Dec 22 2023 - 06:53:57 EST


On Thu, Dec 21, 2023 at 11:07:41PM +0100, Uwe Kleine-König wrote:
> On Thu, Dec 21, 2023 at 09:45:49PM +0000, Mark Brown wrote:

> > > - voltage = pwm_get_relative_duty_cycle(&pstate, duty_unit);
> > > + if (pstate.enabled)
> > > + voltage = pwm_get_relative_duty_cycle(&pstate, duty_unit);
> > > + else if (max_uV_duty < min_uV_duty)
> > > + voltage = max_uV_duty;
> > > + else
> > > + voltage = min_uV_duty;

> > AFAICT this means that enabling the PWM changes the voltage read back
> > which isn't what we expect (other than a change from 0 to target) and is
> > likely to cause issues. get_voltage() should not change after an
> > enable(), and indeed I'm unclear how this change works? I'd expect a
> > change in the init_state() function, possibly one that programs the PWM
> > to reflect the actual hardware state but I'm not 100% confident on that
> > without digging into the PWM API more.

> What is your question here? Looking at pwm_regulator_set_voltage() I
> think this lacks a

> pstate.enabled = true;

> which might also fix Martin's problem?

That's not really a question, it's a statement - I don't see how the
change works at all and as it stands it introduces a problem with the
behaviour when the regulator is enabled.

Attachment: signature.asc
Description: PGP signature