Skip to content

Commit 03c7f95

Browse files
finley1226rkhuangtao
authored andcommitted
clk: rockchip: half-divider: Use maximal and best divider
The bigger the divider, the better the clock jitter. Change-Id: I4b4e06c71c2f0bdb0e32422fb42c8d490c3ec4bd Signed-off-by: Finley Xiao <finley.xiao@rock-chips.com>
1 parent 734b08e commit 03c7f95

1 file changed

Lines changed: 2 additions & 12 deletions

File tree

drivers/clk/rockchip/clk-half-divider.c

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ static bool _is_best_half_div(unsigned long rate, unsigned long now,
1616
unsigned long best, unsigned long flags)
1717
{
1818
if (flags & CLK_DIVIDER_ROUND_CLOSEST)
19-
return abs(rate - now) < abs(rate - best);
19+
return abs(rate - now) <= abs(rate - best);
2020

21-
return now <= rate && now > best;
21+
return now <= rate && now >= best;
2222
}
2323

2424
static unsigned long clk_half_divider_recalc_rate(struct clk_hw *hw,
@@ -40,7 +40,6 @@ static int clk_half_divider_bestdiv(struct clk_hw *hw, unsigned long rate,
4040
{
4141
unsigned int i, bestdiv = 0;
4242
unsigned long parent_rate, best = 0, now, maxdiv;
43-
unsigned long parent_rate_saved = *best_parent_rate;
4443
bool is_bestdiv = false;
4544

4645
if (!rate)
@@ -66,15 +65,6 @@ static int clk_half_divider_bestdiv(struct clk_hw *hw, unsigned long rate,
6665
maxdiv = min(ULONG_MAX / rate, maxdiv);
6766

6867
for (i = 0; i <= maxdiv; i++) {
69-
if (((u64)rate * (i * 2 + 3)) == ((u64)parent_rate_saved * 2)) {
70-
/*
71-
* It's the most ideal case if the requested rate can be
72-
* divided from parent clock without needing to change
73-
* parent rate, so return the divider immediately.
74-
*/
75-
*best_parent_rate = parent_rate_saved;
76-
return i;
77-
}
7868
parent_rate = clk_hw_round_rate(clk_hw_get_parent(hw),
7969
((u64)rate * (i * 2 + 3)) / 2);
8070
now = DIV_ROUND_UP_ULL(((u64)parent_rate * 2),

0 commit comments

Comments
 (0)