[PATCH v3] pwm: imx-tpm: reset counter if CMOD is 0
Uwe Kleine-König
ukleinek at kernel.org
Tue Jul 29 09:10:20 PDT 2025
Hello Laurentiu,
On Mon, Jul 28, 2025 at 03:41:44PM -0400, Laurentiu Mihalcea wrote:
> From: Laurentiu Mihalcea <laurentiu.mihalcea at nxp.com>
>
> As per the i.MX93 TRM, section 67.3.2.1 "MOD register update", the value
> of the TPM counter does NOT get updated when writing MOD.MOD unless
> SC.CMOD != 0. Therefore, with the current code, assuming the following
> sequence:
>
> 1) pwm_disable()
> 2) pwm_apply_might_sleep() /* period is changed here */
> 3) pwm_enable()
>
> and assuming only one channel is active, if CNT.COUNT is higher than the
> MOD.MOD value written during the pwm_apply_might_sleep() call then, when
> re-enabling the PWM during pwm_enable(), the counter will end up resetting
> after UINT32_MAX - CNT.COUNT + MOD.MOD cycles instead of MOD.MOD cycles as
> normally expected.
>
> Fix this problem by forcing a reset of the TPM counter before MOD.MOD is
> written.
>
> Fixes: 738a1cfec2ed ("pwm: Add i.MX TPM PWM driver support")
> Cc: stable at vger.kernel.org
> Signed-off-by: Laurentiu Mihalcea <laurentiu.mihalcea at nxp.com>
Thanks for the respin, looks good now. For consistency I capitalized
"Reset" in the Subject.
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/ukleinek/linux.git pwm/fixes
. I'll give that a day or two in next and then send it to Linus for
6.17-rc1.
Thanks
Uwe
-------------- 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-arm-kernel/attachments/20250729/e64d4a52/attachment.sig>
More information about the linux-arm-kernel
mailing list