[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1499329714-24119-1-git-send-email-zhangqing@rock-chips.com>
Date: Thu, 6 Jul 2017 16:28:34 +0800
From: Elaine Zhang <zhangqing@...k-chips.com>
To: mturquette@...libre.com, sboyd@...eaurora.org, heiko@...ech.de
Cc: linux-clk@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-rockchip@...ts.infradead.org, huangtao@...k-chips.com,
cl@...k-chips.com, xxx@...k-chips.com, xf@...k-chips.com,
Elaine Zhang <zhangqing@...k-chips.com>
Subject: [PATCH v1] clk: fractional-divider: fix up the fractional clk's jitter
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@...k-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
Powered by blists - more mailing lists