diff options
author | Chao Xie <chao.xie@marvell.com> | 2014-01-23 10:47:42 +0800 |
---|---|---|
committer | Mike Turquette <mturquette@linaro.org> | 2014-03-26 20:59:27 -0700 |
commit | 5d26c15d3ba98c31b24286dac7a390a307fcff29 (patch) | |
tree | 32dadeb1f46b6bb918edf3b32960f64201e1742e /drivers/clk | |
parent | c45693a6480cee906557a9fba533a9f3c224f91e (diff) |
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>
Diffstat (limited to 'drivers/clk')
-rw-r--r-- | drivers/clk/mmp/clk-frac.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/drivers/clk/mmp/clk-frac.c b/drivers/clk/mmp/clk-frac.c index 5863a37ec84d..23a56f561812 100644 --- a/drivers/clk/mmp/clk-frac.c +++ b/drivers/clk/mmp/clk-frac.c @@ -45,10 +45,14 @@ static long clk_factor_round_rate(struct clk_hw *hw, unsigned long drate, if (rate > drate) break; } - if ((i == 0) || (i == factor->ftbl_cnt)) + if ((i == 0) || (i == factor->ftbl_cnt)) { return rate; - else - return prev_rate; + } else { + if ((drate - prev_rate) > (rate - drate)) + return rate; + else + return prev_rate; + } } static unsigned long clk_factor_recalc_rate(struct clk_hw *hw, |