mirror of
https://github.com/torvalds/linux.git
synced 2024-12-25 20:32:22 +00:00
gpio: mvebu: improve pwm period calculation accuracy
Change 'off' register value calculation from $off = (period - duty_cycle) * clkrate / NSEC_PER_SEC to $off = (period * clkrate / NSEC_PER_SEC) - $on That is, divide the full period value to reduce rounding error. Reported-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Baruch Siach <baruch@tkos.co.il> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
This commit is contained in:
parent
4bf2426103
commit
aa37e27f61
@ -715,9 +715,9 @@ static int mvebu_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
|
||||
else
|
||||
on = 1;
|
||||
|
||||
val = (unsigned long long) mvpwm->clk_rate *
|
||||
(state->period - state->duty_cycle);
|
||||
val = (unsigned long long) mvpwm->clk_rate * state->period;
|
||||
do_div(val, NSEC_PER_SEC);
|
||||
val -= on;
|
||||
if (val > UINT_MAX)
|
||||
return -EINVAL;
|
||||
if (val)
|
||||
|
Loading…
Reference in New Issue
Block a user