diff options
author | Chao Xie <chao.xie@marvell.com> | 2014-01-23 03:47:41 +0100 |
---|---|---|
committer | Mike Turquette <mturquette@linaro.org> | 2014-03-27 04:59:27 +0100 |
commit | c45693a6480cee906557a9fba533a9f3c224f91e (patch) | |
tree | 1f1566bfffe25d0de323f87c3d50e1bef3de8f20 /drivers/clk | |
parent | clk: mmp: fix wrong mask when calculate denominator (diff) | |
download | linux-c45693a6480cee906557a9fba533a9f3c224f91e.tar.xz linux-c45693a6480cee906557a9fba533a9f3c224f91e.zip |
clk: mmp: fix the wrong calculation formula
The formula is numerator/denominator = Fin / (Fout * factor)
So
Fout = Fin * denominator / (numerator * factor).
Current clk_factor_round_rate and clk_factor_recalc_rate use
wrong formula. This patch will fix them.
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, 5 insertions, 5 deletions
diff --git a/drivers/clk/mmp/clk-frac.c b/drivers/clk/mmp/clk-frac.c index f6e7691c4efa..5863a37ec84d 100644 --- a/drivers/clk/mmp/clk-frac.c +++ b/drivers/clk/mmp/clk-frac.c @@ -40,12 +40,12 @@ static long clk_factor_round_rate(struct clk_hw *hw, unsigned long drate, for (i = 0; i < factor->ftbl_cnt; i++) { prev_rate = rate; - rate = (((*prate / 10000) * factor->ftbl[i].num) / - (factor->ftbl[i].den * factor->masks->factor)) * 10000; + rate = (((*prate / 10000) * factor->ftbl[i].den) / + (factor->ftbl[i].num * factor->masks->factor)) * 10000; if (rate > drate) break; } - if (i == 0) + if ((i == 0) || (i == factor->ftbl_cnt)) return rate; else return prev_rate; @@ -85,8 +85,8 @@ static int clk_factor_set_rate(struct clk_hw *hw, unsigned long drate, for (i = 0; i < factor->ftbl_cnt; i++) { prev_rate = rate; - rate = (((prate / 10000) * factor->ftbl[i].num) / - (factor->ftbl[i].den * factor->masks->factor)) * 10000; + rate = (((prate / 10000) * factor->ftbl[i].den) / + (factor->ftbl[i].num * factor->masks->factor)) * 10000; if (rate > drate) break; } |