Ver Fonte

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>
Chao Xie há 11 anos atrás
pai
commit
5d26c15d3b
1 ficheiros alterados com 7 adições e 3 exclusões
  1. 7 3
      drivers/clk/mmp/clk-frac.c

+ 7 - 3
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)
 		if (rate > drate)
 			break;
 			break;
 	}
 	}
-	if ((i == 0) || (i == factor->ftbl_cnt))
+	if ((i == 0) || (i == factor->ftbl_cnt)) {
 		return rate;
 		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,
 static unsigned long clk_factor_recalc_rate(struct clk_hw *hw,