Re: [PATCH] pwm: meson: Convert to waveform API

From: Uwe Kleine-König

Date: Thu Oct 15 2026 - 13:21:29 EST


Hello Alexandre,

On Fri, Jul 17, 2026 at 09:18:17PM +0200, Alexandre Mergnat wrote:
> The PWM subsystem introduced a new waveform abstraction that
> describes a PWM signal by period length, duty length and duty offset
> instead of period, duty cycle and polarity. The meson driver still
> uses the legacy .apply() and .get_state() callbacks and does not
> implement the waveform callbacks, so consumers cannot use the
> pwm_*_waveform() helper functions with it.
>
> Adopt the new API by implementing .round_waveform_tohw(),
> .round_waveform_fromhw(), .read_waveform() and .write_waveform()
> with a private meson_pwm_waveform struct holding the hardware
> representation. The cached channel state fields (rate, hi, lo,
> constant, inverted) are removed; counter values are now computed in
> .round_waveform_tohw() via clk_round_rate() without register writes,
> then committed in .write_waveform().
>
> The hardware invert bit places the duty active phase at the end of the
> period on revisions that have it. Input clock rates are kept at or
> below 1 GHz so each counter cycle remains representable in nanoseconds
> by .round_waveform_fromhw(). Requests for which clk_round_rate() cannot
> provide such a rate are rejected. Otherwise, period counts above the
> 16-bit range are clamped, while a zero count is rounded up to one and
> signalled by .round_waveform_tohw() returning 1.
>
> Signed-off-by: Alexandre Mergnat <amergnat@xxxxxxxxxxxx>

I applied your patch now to

https://git.kernel.org/pub/scm/linux/kernel/git/ukleinek/linux.git pwm/for-nexxt

as v7.5-rc1 material (sorry, I was to slow for the upcoming merge
window, I want that patch cook in next for some time).

Thanks for your patience
Uwe

Attachment: signature.asc
Description: PGP signature