]> Git Repo - linux.git/commitdiff
pwm: atmel: Fix duty cycle calculation in .get_state()
authorUwe Kleine-König <[email protected]>
Tue, 20 Apr 2021 09:51:17 +0000 (11:51 +0200)
committerThierry Reding <[email protected]>
Fri, 23 Apr 2021 17:05:31 +0000 (19:05 +0200)
The CDTY register contains the number of inactive cycles. .apply() does
this correctly, however .get_state() got this wrong.

Fixes: 651b510a74d4 ("pwm: atmel: Implement .get_state()")
Signed-off-by: Uwe Kleine-König <[email protected]>
Signed-off-by: Thierry Reding <[email protected]>
drivers/pwm/pwm-atmel.c

index d49da708337faf4d408814c94b7a17392e0f11d4..ebaeb50dcfde2ce260f29983c37be5c16bd9414c 100644 (file)
@@ -319,7 +319,7 @@ static void atmel_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm,
 
                cdty = atmel_pwm_ch_readl(atmel_pwm, pwm->hwpwm,
                                          atmel_pwm->data->regs.duty);
-               tmp = (u64)cdty * NSEC_PER_SEC;
+               tmp = (u64)(cprd - cdty) * NSEC_PER_SEC;
                tmp <<= pres;
                state->duty_cycle = DIV64_U64_ROUND_UP(tmp, rate);
 
This page took 0.053864 seconds and 4 git commands to generate.