Commit 453e8b3d authored by Uwe Kleine-König's avatar Uwe Kleine-König Committed by Thierry Reding

pwm: atmel: Fix duty cycle calculation in .get_state()

The CDTY register contains the number of inactive cycles. .apply() does
this correctly, however .get_state() got this wrong.

Fixes: 651b510a ("pwm: atmel: Implement .get_state()")
Signed-off-by: default avatarUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: default avatarThierry Reding <thierry.reding@gmail.com>
parent 721b5957
...@@ -319,7 +319,7 @@ static void atmel_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, ...@@ -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, cdty = atmel_pwm_ch_readl(atmel_pwm, pwm->hwpwm,
atmel_pwm->data->regs.duty); atmel_pwm->data->regs.duty);
tmp = (u64)cdty * NSEC_PER_SEC; tmp = (u64)(cprd - cdty) * NSEC_PER_SEC;
tmp <<= pres; tmp <<= pres;
state->duty_cycle = DIV64_U64_ROUND_UP(tmp, rate); state->duty_cycle = DIV64_U64_ROUND_UP(tmp, rate);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment