[RFC PATCH v1] regulator: pwm-regulator: Fix continuous get_voltage for disabled PWM
Martin Blumenstingl
martin.blumenstingl at googlemail.com
Thu Dec 21 16:17:44 PST 2023
Hi Uwe,
On Thu, Dec 21, 2023 at 11:03 PM Uwe Kleine-König
<u.kleine-koenig at pengutronix.de> wrote:
[...]
> Note this isn't save in general. You're implicitly assuming that a
> disabled PWM runs with the minimal supported duty_cycle. Most disabled
> PWMs yield the inactive level (which corresponds to a 0% relative duty
> cycle). But there are exceptions.
Good catch - thank you!
[...]
> Without claiming to understand all implications, I'd say
> pwm_regulator_get_voltage should signal to the caller when the
> duty_cycle isn't contained in [min(max_uV_duty, min_uV_duty),
> max(max_uV_duty, min_uV_duty)].
It seems like there's -ENOTRECOVERABLE that we can signal to the caller.
This makes the following message appear in my kernel log:
VDDEE: Setting 1100000-1140000uV
Which means that pwm_regulator_set_voltage() is called which will then
pick the minimum voltage.
To make this work I will need to update meson8b-odroidc1.dts (which
isn't a problem, I just want to point it out as it's mandatory for
that solution. also I will send that in a separate patch).
See my attached patch (which replaces the initial patch I sent, it's
not meant to be applied on top).
One question that I still have is whether we are allowed to just
enable the PWM output within pwm_regulator_set_voltage().
Doing so is actually mandatory, otherwise we end up in an infinite
loop of not being able to read the voltage, then sets the minimum
voltage (but leaves the PWM output disabled) which then means that it
can't read back the voltage which means it tries to set the minimum
voltage ....
Best regards,
Martin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: odroidc1-vddee-fix-to-discuss.diff
Type: text/x-patch
Size: 1688 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-amlogic/attachments/20231222/59d698eb/attachment.bin>
More information about the linux-amlogic
mailing list