[RFC PATCH v1] regulator: pwm-regulator: Fix continuous get_voltage for disabled PWM
Uwe Kleine-König
u.kleine-koenig at pengutronix.de
Fri Dec 22 02:27:23 PST 2023
On Fri, Dec 22, 2023 at 11:12:30AM +0100, Martin Blumenstingl wrote:
> Hello Uwe,
>
> On Fri, Dec 22, 2023 at 8:10 AM Uwe Kleine-König
> <u.kleine-koenig at pengutronix.de> wrote:
> [...]
> > Also the calculation is wrong: If a relative duty-cyle in the interval
> > [91%; 0%] maps lineary to [860 mV; 1140 mV] you get 1100 mV at
> >
> > 1100 mV - 860 mV
> > 91 + ---------------- * (0 - 91) = 13
> > 1140 mV - 860 mV
> >
> > (If the calculations in the driver used signed multiplication and
> > division, all the checks for max_uV_duty < min_uV_duty could just go
> > away.)
> >
> > So you want
> >
> > + pwm-dutycycle-range = <13 0>;
> Thank you!
>
> > (if this restriction is really necessary).
> I could not find a way around this.
> Without this change pwm_regulator_set_voltage() is called with req_min
> 860mV and req_max 1140mV.
> pwm_regulator_set_voltage() will then pick the lowest possible
> voltage, which then results in 860mV (exactly what I get without any
> patches).
>
> To be able to keep the original minimum voltage in .dts would be to
> work on what Mark suggested where he said:
> "I'd expect a change in the init_state() function, possibly one that
> programs the PWM to reflect the actual hardware state"
>
> [...]
> > > - 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;
> > > + voltage = pwm_get_relative_duty_cycle(&pstate, duty_unit);
> >
> > I'd add here:
> >
> > if (voltage < min(max_uV_duty, min_uV_duty) ||
> > voltage > max(max_uV_duty, min_uV_duty))
> > return -ENOTRECOVERABLE;
> I can do that - although I think it should be a separate change.
That can go in together with the
if (pstate.enabled)
return -ENOTRECOVERABLE;
Otherwise +1 to not mix that with the machine specfic stuff.
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | https://www.pengutronix.de/ |
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-amlogic/attachments/20231222/5737fcca/attachment.sig>
More information about the linux-amlogic
mailing list