linux/drivers/clk/ti
Tomi Valkeinen 7e50e7e176 clk: ti/divider: fix rate calculation for fractional rates
ti/clk-divider.c does not calculate the rates consistently at the moment.

As an example, on OMAP3 we have a clock divider with a source clock of
864000000 Hz. With dividers 6, 7 and 8 the theoretical rates are:

6: 144000000
7: 123428571.428571...
8: 108000000

Calling clk_round_rate() with the rate in the first column will give the
rate in the second column:

144000000 -> 144000000
143999999 -> 123428571
123428572 -> 123428571
123428571 -> 108000000

Note how clk_round_rate() returns 123428571 for rates from 123428572 to
143999999, which is mathematically correct, but when clk_round_rate() is
called with 123428571, the returned value is surprisingly 108000000.

This means that the following code works a bit oddly:

rate = clk_round_rate(clk, 123428572);
clk_set_rate(clk, rate);

As clk_set_rate() also does clock rate rounding, the result is that the
clock is set to the rate of 108000000, not 123428571 returned by the
clk_round_rate.

This patch changes the ti/clk-divider.c to use DIV_ROUND_UP when
calculating the rate. This gives the following behavior which fixes the
inconsistency:

144000000 -> 144000000
143999999 -> 123428572
123428572 -> 123428572
123428571 -> 108000000

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Signed-off-by: Mike Turquette <mturquette@linaro.org>
2014-02-26 18:23:58 -08:00
..
apll.c CLK: TI: DRA7: Add APLL support 2014-01-17 12:35:31 -08:00
autoidle.c CLK: TI: add autoidle support 2014-01-17 12:34:59 -08:00
clk-3xxx.c CLK: TI: add omap3 clock init file 2014-01-17 12:35:48 -08:00
clk-7xx.c CLK: TI: add dra7 clock init file 2014-01-17 12:35:37 -08:00
clk-33xx.c clk: ti: am335x: remove unecessary cpu0 clk node 2014-02-24 22:56:38 -08:00
clk-43xx.c CLK: TI: add am43xx clock init file 2014-01-17 12:35:52 -08:00
clk-44xx.c CLK: TI: add omap4 clock init file 2014-01-17 12:35:20 -08:00
clk-54xx.c CLK: TI: omap5: Initialize USB_DPLL at boot 2014-01-17 12:35:27 -08:00
clk.c CLK: ti: add init support for clock IP blocks 2014-01-17 12:34:52 -08:00
clockdomain.c CLK: TI: add support for clockdomain binding 2014-01-17 12:35:13 -08:00
composite.c clk: ti: add support for basic mux clock 2014-01-17 12:35:17 -08:00
divider.c clk: ti/divider: fix rate calculation for fractional rates 2014-02-26 18:23:58 -08:00
dpll.c CLK: TI: Add DPLL clock support 2014-01-17 12:34:55 -08:00
fixed-factor.c clk: ti: add support for TI fixed factor clock 2014-01-17 12:35:07 -08:00
gate.c CLK: TI: add support for gate clock 2014-01-17 12:35:10 -08:00
interface.c CLK: TI: add interface clock support for OMAP3 2014-01-17 12:35:45 -08:00
Makefile CLK: TI: add am43xx clock init file 2014-01-17 12:35:52 -08:00
mux.c clk: ti: add support for basic mux clock 2014-01-17 12:35:17 -08:00