Skip to contentSkip to conversation

clk: imx: Fix fractional clock set rate computation

PATCH Applied Abel Vesa 2 participants 2 messages Jan 18, 2019 – Jan 24, 2019

Subsystems (3)
lore
Share & tools
lore

Abel Vesa

author
#0 lore raw

PATCH 1/1 clk: imx: Fix fractional clock set rate computation

Before multiplying by PLL_FRAC_DENOM, the temp64 needs to be
temp64 = rate * 2 - divfi * parent_rate * 8, instead of:
temp64 = (rate * 2 - divfi) * parent_rate

Fixes 6209624b9a5c1e ("clk: imx: Add fractional PLL output clock")
---
 drivers/clk/imx/clk-frac-pll.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/clk/imx/clk-frac-pll.c +3 -2
index 0026c39..76b9eb1 100644
@@ -155,13 +155,14 @@ static int clk_pll_set_rate(struct clk_hw *hw, unsigned long rate,
 {
 	struct clk_frac_pll *pll = to_clk_frac_pll(hw);
 	u32 val, divfi, divff;
-	u64 temp64 = parent_rate;
+	u64 temp64;
 	int ret;
 
 	parent_rate *= 8;
 	rate *= 2;
 	divfi = rate / parent_rate;
-	temp64 *= rate - divfi;
+	temp64 = parent_rate * divfi;
+	temp64 = rate - temp64;
 	temp64 *= PLL_FRAC_DENOM;
 	do_div(temp64, parent_rate);
 	divff = temp64;
Signature · 1 line
2.7.4
maintainer Applied
#1 lore raw

Quoting Abel Vesa (2019-01-18 04:54:13)

Quoted 7 lines

Before multiplying by PLL_FRAC_DENOM, the temp64 needs to be
temp64 = rate * 2 - divfi * parent_rate * 8, instead of:
temp64 = (rate * 2 - divfi) * parent_rate

Fixes 6209624b9a5c1e ("clk: imx: Add fractional PLL output clock")

---

Applied to clk-fixes