clk: ingenic: Fix divider calculation with div tables
authorPaul Cercueil <paul@crapouillou.net>
Sat, 12 Dec 2020 13:57:33 +0000 (13:57 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 30 Dec 2020 10:54:25 +0000 (11:54 +0100)
commit070e386727fd5960fec99d845e1a915576495d43
treed2dc5cb4a1f64b9f7d4beff1012e45455b812767
parentdcea0b3835dff7df8eca6c3358010c620a328d4d
clk: ingenic: Fix divider calculation with div tables

commit 11a163f2c7d6a9f27ce144cd7e367a81c851621a upstream.

The previous code assumed that a higher hardware value always resulted
in a bigger divider, which is correct for the regular clocks, but is
an invalid assumption when a divider table is provided for the clock.

Perfect example of this is the PLL0_HALF clock, which applies a /2
divider with the hardware value 0, and a /1 divider otherwise.

Fixes: a9fa2893fcc6 ("clk: ingenic: Add support for divider tables")
Cc: <stable@vger.kernel.org> # 5.2
Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Link: https://lore.kernel.org/r/20201212135733.38050-1-paul@crapouillou.net
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/clk/ingenic/cgu.c