pwm: ab8500: Fix calculation of duty and period
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Wed, 18 Jan 2023 15:48:16 +0000 (16:48 +0100)
committerThierry Reding <thierry.reding@gmail.com>
Fri, 17 Feb 2023 14:59:51 +0000 (15:59 +0100)
commit486dd4e846814016443abfcbfee0b8b3f3b35330
tree8be347dc66dc90e83b010d1738573a8fd579022c
parent2781f8e9203685208c9f3717593601d4b4674372
pwm: ab8500: Fix calculation of duty and period

After a check of the manual it becomes obvious that the calculations in
.apply() are totally bogus:

FreqPWMOutx was always written as zero, so the period was fixed at
3413333.33 ns. However state->period wasn't checked at all.
The lower 10 bits of duty_cycle were just used as DutyPWMOutx. So if
a duty cycle of 512 ns (or 1536 ns) was requested, it actually
programmed 1710000 ns. Other values were wrong by the same factor.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
drivers/pwm/pwm-ab8500.c