diff options
| author | Erik Schumacher <[email protected]> | 2024-10-25 08:37:00 +0000 |
|---|---|---|
| committer | Uwe Kleine-König <[email protected]> | 2024-10-25 09:29:17 +0000 |
| commit | cc6a931d1f3b412263d515fd93b21fc0ca5147fe (patch) | |
| tree | c202c2fc454016c9dcb92a85a1ebe3b1da005d26 /drivers/pwm/pwm-imx-tpm.c | |
| parent | Linux 6.12-rc1 (diff) | |
| download | kernel-cc6a931d1f3b412263d515fd93b21fc0ca5147fe.tar.gz kernel-cc6a931d1f3b412263d515fd93b21fc0ca5147fe.zip | |
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: 738a1cfec2ed ("pwm: Add i.MX TPM PWM driver support")
Cc: [email protected]
Signed-off-by: Erik Schumacher <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Uwe Kleine-König <[email protected]>
Diffstat (limited to 'drivers/pwm/pwm-imx-tpm.c')
| -rw-r--r-- | drivers/pwm/pwm-imx-tpm.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/pwm/pwm-imx-tpm.c b/drivers/pwm/pwm-imx-tpm.c index 96ea343856f0..7ee7b65b9b90 100644 --- a/drivers/pwm/pwm-imx-tpm.c +++ b/drivers/pwm/pwm-imx-tpm.c @@ -106,7 +106,9 @@ 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; + if (period_count == 0) + return -EINVAL; + p->mod = period_count - 1; /* calculate real period HW can support */ tmp = (u64)period_count << prescale; |
