summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>2021-04-20 11:51:17 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-05-19 10:13:04 +0200
commitb22e8f427c3de299c47350caae2a4f80f6d7eb61 (patch)
tree4f504c49e3c9f53dca04cd6f55b21af03c02bbba
parent0a9decf2dd4d859bdc791165abc2b646a85dd00f (diff)
downloadlinux-stable-b22e8f427c3de299c47350caae2a4f80f6d7eb61.tar.gz
linux-stable-b22e8f427c3de299c47350caae2a4f80f6d7eb61.tar.bz2
linux-stable-b22e8f427c3de299c47350caae2a4f80f6d7eb61.zip
pwm: atmel: Fix duty cycle calculation in .get_state()
[ Upstream commit 453e8b3d8e36ddcb283b3d1698864a03ea45599a ] 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 <u.kleine-koenig@pengutronix.de> Signed-off-by: Thierry Reding <thierry.reding@gmail.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--drivers/pwm/pwm-atmel.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/pwm/pwm-atmel.c b/drivers/pwm/pwm-atmel.c
index 6161e7e3e9ac..d7cb0dfa25a5 100644
--- a/drivers/pwm/pwm-atmel.c
+++ b/drivers/pwm/pwm-atmel.c
@@ -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);