diff options
author | Uwe Kleine-König <u.kleine-koenig@baylibre.com> | 2024-06-28 12:35:19 +0200 |
---|---|---|
committer | Uwe Kleine-König <ukleinek@kernel.org> | 2024-07-10 17:53:52 +0200 |
commit | 9dd42d019e6399e6e7d9e90759a61ff430625285 (patch) | |
tree | eaee7c4c0c9df040062291bcbff94a3467c483e4 /drivers/pwm/pwm-lpc32xx.c | |
parent | 14b9dc66e93abbd16b22ac9153f658de1acaaf49 (diff) | |
download | lwn-9dd42d019e6399e6e7d9e90759a61ff430625285.tar.gz lwn-9dd42d019e6399e6e7d9e90759a61ff430625285.zip |
pwm: Allow pwm state transitions from an invalid state
While driving a PWM via the sysfs API it's hard to determine the right
order of writes to the pseudo files "period" and "duty_cycle":
If you want to go from duty_cycle/period = 50/100 to 150/300 you have to
write period first (because 150/100 is invalid). If however you start at
400/500 the duty_cycle must be configured first. The rule that works is:
If you increase period write period first, otherwise write duty_cycle
first. A complication however is that it's usually sensible to configure
the polarity before both period and duty_cycle. This can only be done if
the current state's duty_cycle and period configuration isn't bogus
though. It is still worse (but I think only theoretic) if you have a PWM
that only supports inverted polarity and you start with period = 0 and
polarity = normal. Then you can change neither period (because polarity
= normal is refused) nor polarity (because there is still period = 0).
To simplify the corner cases for userspace, let invalid target states
pass if the current state is invalid already.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Link: https://lore.kernel.org/r/20240628103519.105020-2-u.kleine-koenig@baylibre.com
Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
Diffstat (limited to 'drivers/pwm/pwm-lpc32xx.c')
0 files changed, 0 insertions, 0 deletions