Messages in this thread Patch in this message | | | From | Elaine Zhang <> | Subject | [PATCH v1] clk: fractional-divider: fix up the fractional clk's jitter | Date | Thu, 6 Jul 2017 16:28:34 +0800 |
| |
fractional divider must set that denominator is 20 times larger than numerator to generate precise clock frequency. Otherwise the CLK jitter is very big, poor quality of the clock signal.
RK document description: 3.1.9 Fractional divider usage To get specific frequency, clocks of I2S, SPDIF, UARTcan be generated by fractional divider. Generally you must set that denominator is 20 times larger than numerator to generate precise clock frequency. So the fractional divider applies only to generate low frequency clock like I2S, UART.
Signed-off-by: Elaine Zhang <zhangqing@rock-chips.com> --- drivers/clk/clk-fractional-divider.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
diff --git a/drivers/clk/clk-fractional-divider.c b/drivers/clk/clk-fractional-divider.c index aab904618eb6..1c29d6f5ffd8 100644 --- a/drivers/clk/clk-fractional-divider.c +++ b/drivers/clk/clk-fractional-divider.c @@ -56,11 +56,24 @@ static long clk_fd_round_rate(struct clk_hw *hw, unsigned long rate, unsigned long scale; unsigned long m, n; u64 ret; + struct clk_hw *p_parent; + unsigned long p_rate, p_parent_rate; if (!rate || rate >= *parent_rate) return *parent_rate; /* + * fractional divider must set that denominator is 20 times larger than + * numerator to generate precise clock frequency. + */ + p_rate = clk_hw_get_rate(clk_hw_get_parent(hw)); + if ((rate * 20 > p_rate) && (p_rate % rate != 0)) { + p_parent = clk_hw_get_parent(clk_hw_get_parent(hw)); + p_parent_rate = clk_hw_get_rate(p_parent); + *parent_rate = p_parent_rate; + } + + /* * Get rate closer to *parent_rate to guarantee there is no overflow * for m and n. In the result it will be the nearest rate left shifted * by (scale - fd->nwidth) bits. -- 1.9.1
| |