Skip to content

Commit 49c8309

Browse files
Elaine Zhangrkhuangtao
authored andcommitted
clk: fractional-divider: Improve fractional divider jitter
Numerator is greater than 4,the clk jitter is better. Change-Id: I9fda9ddeb7b26c6b8559b4126e2ad1d29bb850d1 Signed-off-by: Elaine Zhang <zhangqing@rock-chips.com>
1 parent 07e28b1 commit 49c8309

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

drivers/clk/clk-fractional-divider.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,24 @@ static int clk_fd_set_rate(struct clk_hw *hw, unsigned long rate,
106106
GENMASK(fd->mwidth - 1, 0), GENMASK(fd->nwidth - 1, 0),
107107
&m, &n);
108108

109+
/*
110+
* When compensation the fractional divider,
111+
* the [1:0] bits of the numerator register are omitted,
112+
* which will lead to a large deviation in the result.
113+
* Therefore, it is required that the numerator must
114+
* be greater than 4.
115+
*/
116+
if (m < 4 && m != 0) {
117+
val = DIV_ROUND_UP(4, m);
118+
n *= val;
119+
m *= val;
120+
if (n > fd->nmask) {
121+
pr_debug("%s n(%ld) is overflow, use mask value\n",
122+
__func__, n);
123+
n = fd->nmask;
124+
}
125+
}
126+
109127
if (fd->lock)
110128
spin_lock_irqsave(fd->lock, flags);
111129
else

0 commit comments

Comments
 (0)