Fix iProc PLL output clock frequency calculation
Subsystems (2)
Ray Jui
maintainerPATCH 1/1 Fix iProc PLL output clock frequency calculation
This patch fixes incorrect iProc PLL clock frequency calculation. The issue is exposed when Cygnus audio PLL was being added.
This patch is based on v4.3-rc5 and has been tested on Cygnus bcm958305k wirelss audio board
This full tree is available here:
repo: https://github.com/Broadcom/cygnus-linux.git
branch: iproc-clk-pll-fix-v1
Simran Rai (1):
clk: iproc: Fix PLL output frequency calculation
drivers/clk/bcm/clk-iproc-pll.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
Signature · 1 line
1.9.1
Ray Jui
maintainerPATCH 1/1 clk: iproc: Fix PLL output frequency calculation
From: Simran Rai <[email protected]>
This patch affects the clocks that use fractional ndivider in their PLL output frequency calculation. Instead of 2^20 divide factor, the clock's ndiv integer shift was used. Fixed the bug by replacing ndiv integer shift with 2^20 factor.
--- drivers/clk/bcm/clk-iproc-pll.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
drivers/clk/bcm/clk-iproc-pll.c +5 -8
@@ -345,8 +345,8 @@ static unsigned long iproc_pll_recalc_rate(struct clk_hw *hw,struct iproc_pll *pll = clk->pll;const struct iproc_pll_ctrl *ctrl = pll->ctrl;u32 val; -u64 ndiv; -unsigned int ndiv_int, ndiv_frac, pdiv; +u64 ndiv, ndiv_int, ndiv_frac; +unsigned int pdiv;if (parent_rate ==0 )return 0 ;
@@ -366,22 +366,19 @@ static unsigned long iproc_pll_recalc_rate(struct clk_hw *hw, val =readl (pll->pll_base + ctrl->ndiv_int.offset); ndiv_int = (val >> ctrl->ndiv_int.shift) &bit_mask (ctrl->ndiv_int.width); - ndiv = (u64 )ndiv_int << ctrl->ndiv_int.shift; + ndiv = ndiv_int <<20 ;if (ctrl->flags &IPROC_CLK_PLL_HAS_NDIV_FRAC ) { val =readl (pll->pll_base + ctrl->ndiv_frac.offset); ndiv_frac = (val >> ctrl->ndiv_frac.shift) &bit_mask (ctrl->ndiv_frac.width); - -if (ndiv_frac !=0 ) - ndiv = ((u64 )ndiv_int << ctrl->ndiv_int.shift) | - ndiv_frac; + ndiv += ndiv_frac; } val =readl (pll->pll_base + ctrl->pdiv.offset); pdiv = (val >> ctrl->pdiv.shift) &bit_mask (ctrl->pdiv.width); - clk->rate = (ndiv * parent_rate) >> ctrl->ndiv_int.shift; + clk->rate = (ndiv * parent_rate) >>20 ;if (pdiv ==0 ) clk->rate *=2 ;
Signature · 1 line
1.9.1
Re: [PATCH] clk: iproc: Fix PLL output frequency calculation
Quoted 11 lines · Ray Jui
From: Simran Rai <[email protected]>
This patch affects the clocks that use fractional ndivider in their PLL output frequency calculation. Instead of 2^20 divide factor, the clock's ndiv integer shift was used. Fixed the bug by replacing ndiv integer shift with 2^20 factor.
Signed-off-by Simran Rai <[email protected]>Signed-off-by Ray Jui <[email protected]>Reviewed-by Scott Branden <[email protected]>---
Did you want any Fixes: tag so this goes back to stable?
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
Ray Jui
maintainerRe: [PATCH] clk: iproc: Fix PLL output frequency calculation
Quoted 8 lines · Stephen Boyd
Quoted 7 lines · Ray Jui
From: Simran Rai <[email protected]>
This patch affects the clocks that use fractional ndivider in their PLL output frequency calculation. Instead of 2^20 divide factor, the clock's ndiv integer shift was used. Fixed the bug by replacing ndiv integer shift with 2^20 factor.
Quoted 7 lines
Quoted 4 lines
Signed-off-by Simran Rai <[email protected]>Signed-off-by Ray Jui <[email protected]>Reviewed-by Scott Branden <[email protected]>---
Did you want any Fixes: tag so this goes back to stable?
Yes, we want this fix to go back to the stable kernel.
I will re-submit the patch with the Fixes: tag and at the same time cc [email protected] .
Thanks,
Ray
Re: [PATCH] clk: iproc: Fix PLL output frequency calculation
Quoted 16 lines · Ray Jui
Quoted 13 lines · Stephen Boyd
Quoted 11 lines · Ray Jui
From: Simran Rai <[email protected]>
This patch affects the clocks that use fractional ndivider in their PLL output frequency calculation. Instead of 2^20 divide factor, the clock's ndiv integer shift was used. Fixed the bug by replacing ndiv integer shift with 2^20 factor.
Signed-off-by Simran Rai <[email protected]>Signed-off-by Ray Jui <[email protected]>Reviewed-by Scott Branden <[email protected]>---
Quoted 7 lines
Quoted 2 lines
Did you want any Fixes: tag so this goes back to stable?
Yes, we want this fix to go back to the stable kernel.
I will re-submit the patch with the Fixes: tag and at the same time cc [email protected] .
Please just tell me the commit that this fixes, I can add the tag and apply to the right tree then.
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
Re: [PATCH] clk: iproc: Fix PLL output frequency calculation
Quoting Stephen Boyd (2015-10-19 15:16:05)
Quoted 20 lines · Ray Jui
Quoted 19 lines · Stephen Boyd
Quoted 15 lines · Ray Jui
Quoted 11 lines
From: Simran Rai <[email protected]>
This patch affects the clocks that use fractional ndivider in their PLL output frequency calculation. Instead of 2^20 divide factor, the clock's ndiv integer shift was used. Fixed the bug by replacing ndiv integer shift with 2^20 factor.
Signed-off-by Simran Rai <[email protected]>Signed-off-by Ray Jui <[email protected]>Reviewed-by Scott Branden <[email protected]>---
Did you want any Fixes: tag so this goes back to stable?
Quoted 8 lines
Quoted 4 lines
Yes, we want this fix to go back to the stable kernel.
I will re-submit the patch with the Fixes: tag and at the same time cc [email protected] .
=
Please just tell me the commit that this fixes, I can add the tag and apply to the right tree then.
I applied v2 of this patch and amended the commit log with:
Regards,
Mike
Quoted 7 lines
=
-- =
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
=20