[PATCH] pwm: imx-tpm: Use correct MODULO value for EPWM mode
Erik Schumacher
erik.schumacher at iris-sensing.com
Wed Oct 23 05:33:53 PDT 2024
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.
Signed-off-by: Erik Schumacher <erik.schumacher at iris-sensing.com>
---
drivers/pwm/pwm-imx-tpm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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;
/* calculate real period HW can support */
tmp = (u64)period_count << prescale;
--
2.47.0
More information about the linux-arm-kernel
mailing list