Skip to content

Commit cc6a931

Browse files
iris-erscUwe Kleine-König
authored andcommitted
pwm: imx-tpm: Use correct MODULO value for EPWM mode
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. Return -EINVAL if the calculated length is already zero. A correct MODULO value is particularly relevant if the PWM has to output a high frequency due to a low period value. Fixes: 738a1cf ("pwm: Add i.MX TPM PWM driver support") Cc: stable@vger.kernel.org Signed-off-by: Erik Schumacher <erik.schumacher@iris-sensing.com> Link: https://lore.kernel.org/r/1a3890966d68b9f800d457cbf095746627495e18.camel@iris-sensing.com Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
1 parent 9852d85 commit cc6a931

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/pwm/pwm-imx-tpm.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,9 @@ static int pwm_imx_tpm_round_state(struct pwm_chip *chip,
106106
p->prescale = prescale;
107107

108108
period_count = (clock_unit + ((1 << prescale) >> 1)) >> prescale;
109-
p->mod = period_count;
109+
if (period_count == 0)
110+
return -EINVAL;
111+
p->mod = period_count - 1;
110112

111113
/* calculate real period HW can support */
112114
tmp = (u64)period_count << prescale;

0 commit comments

Comments
 (0)