pwm: jz4740: Improve algorithm of clock calculation
authorPaul Cercueil <paul@crapouillou.net>
Mon, 23 Mar 2020 14:24:19 +0000 (15:24 +0100)
committerThierry Reding <thierry.reding@gmail.com>
Mon, 30 Mar 2020 16:03:09 +0000 (18:03 +0200)
commit485b56f08f3342f353369ee6f9c26053efb2b925
treef380328c4159b49761dd8fd50ead4df230d5b0b0
parentce1f9cece057843a03a6b9de361a03eb37dd3fac
pwm: jz4740: Improve algorithm of clock calculation

The previous algorithm hardcoded details about how the TCU clocks work.
The new algorithm will use clk_round_rate to find the perfect clock rate
for the PWM channel.

This code relies on the fact that clk_round_rate() will always round
down, which is not a valid assumption given by the clk API, but only
happens to be true with the clk drivers used for Ingenic SoCs.

Right now, there is no alternative as the clk API does not have a
round-down function (and won't have one for a while), but if it ever
comes to light, a round-down function should be used instead.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Tested-by: Mathieu Malaterre <malat@debian.org>
Tested-by: Artur Rojek <contact@artur-rojek.eu>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
drivers/pwm/pwm-jz4740.c