[PATCH v2] pwm: imx-tpm: Use correct MODULO value for EPWM mode
Uwe Kleine-König
u.kleine-koenig at baylibre.com
Thu Oct 24 14:01:31 PDT 2024
Hello,
[dropping anson.huang at nxp.com from Cc]
On Thu, Oct 24, 2024 at 06:41:07AM +0000, Erik Schumacher wrote:
> The modulo register defines the period of the edge-aligned PWM mode
> (which is the only mode implemented). The reference manual states:
> "The EPWM period is determined by (MOD + 0001h) ..." So the value that
> is written to the MOD register must therefore be one less than the
> calculated period length.
> A correct MODULO value is particularly relevant if the PWM has to output
> a high frequency due to a low period value.
>
> Fixes: 738a1cfec2ed ("pwm: Add i.MX TPM PWM driver support")
> Cc: stable at vger.kernel.org
>
> Signed-off-by: Erik Schumacher <erik.schumacher at iris-sensing.com>
No empty line between these trailer lines please.
> diff --git a/drivers/pwm/pwm-imx-tpm.c b/drivers/pwm/pwm-imx-tpm.c
> index 96ea343856f0..a05b66ffe208 100644
> --- a/drivers/pwm/pwm-imx-tpm.c
> +++ b/drivers/pwm/pwm-imx-tpm.c
> @@ -106,7 +106,7 @@ static int pwm_imx_tpm_round_state(struct pwm_chip *chip,
> p->prescale = prescale;
>
> period_count = (clock_unit + ((1 << prescale) >> 1)) >> prescale;
> - p->mod = period_count;
> + p->mod = period_count - 1;
This looks bogus if period_count is 0.
Best regards
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/20241024/5c172b29/attachment.sig>
More information about the linux-arm-kernel
mailing list