Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

clk: mmp: try to use closer one when do round rate

The orignal code will use the bigger rate between
"previous rate" and "current rate" when caculate the
rate.
In fact, hardware cares about the closest one.
So choose the closer rate between "previous rate" and
"current rate".

Signed-off-by: Chao Xie <chao.xie@marvell.com>
Signed-off-by: Mike Turquette <mturquette@linaro.org>

authored by

Chao Xie and committed by
Mike Turquette
5d26c15d c45693a6

+7 -3
+7 -3
drivers/clk/mmp/clk-frac.c
··· 45 45 if (rate > drate) 46 46 break; 47 47 } 48 - if ((i == 0) || (i == factor->ftbl_cnt)) 48 + if ((i == 0) || (i == factor->ftbl_cnt)) { 49 49 return rate; 50 - else 51 - return prev_rate; 50 + } else { 51 + if ((drate - prev_rate) > (rate - drate)) 52 + return rate; 53 + else 54 + return prev_rate; 55 + } 52 56 } 53 57 54 58 static unsigned long clk_factor_recalc_rate(struct clk_hw *hw,