* [PATCH] Fix iProc PLL output clock frequency calculation
@ 2015-10-16 22:44 Ray Jui
2015-10-16 22:44 ` [PATCH] clk: iproc: Fix PLL output " Ray Jui
0 siblings, 1 reply; 6+ messages in thread
From: Ray Jui @ 2015-10-16 22:44 UTC (permalink / raw)
To: Michael Turquette, Stephen Boyd
Cc: linux-clk, linux-kernel, bcm-kernel-feedback-list, Simran Rai,
Ray Jui
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(-)
--
1.9.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] clk: iproc: Fix PLL output frequency calculation
2015-10-16 22:44 [PATCH] Fix iProc PLL output clock frequency calculation Ray Jui
@ 2015-10-16 22:44 ` Ray Jui
2015-10-19 21:49 ` Stephen Boyd
0 siblings, 1 reply; 6+ messages in thread
From: Ray Jui @ 2015-10-16 22:44 UTC (permalink / raw)
To: Michael Turquette, Stephen Boyd
Cc: linux-clk, linux-kernel, bcm-kernel-feedback-list, Simran Rai,
Ray Jui
From: Simran Rai <ssimran@broadcom.com>
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 <ssimran@broadcom.com>
Signed-off-by: Ray Jui <rjui@broadcom.com>
Reviewed-by: Scott Branden <sbranden@broadcom.com>
---
drivers/clk/bcm/clk-iproc-pll.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/drivers/clk/bcm/clk-iproc-pll.c b/drivers/clk/bcm/clk-iproc-pll.c
index 2dda4e8..d679ab8 100644
--- a/drivers/clk/bcm/clk-iproc-pll.c
+++ b/drivers/clk/bcm/clk-iproc-pll.c
@@ -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;
--
1.9.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] clk: iproc: Fix PLL output frequency calculation
2015-10-16 22:44 ` [PATCH] clk: iproc: Fix PLL output " Ray Jui
@ 2015-10-19 21:49 ` Stephen Boyd
2015-10-19 21:55 ` Ray Jui
0 siblings, 1 reply; 6+ messages in thread
From: Stephen Boyd @ 2015-10-19 21:49 UTC (permalink / raw)
To: Ray Jui
Cc: Michael Turquette, linux-clk, linux-kernel,
bcm-kernel-feedback-list, Simran Rai
On 10/16, Ray Jui wrote:
> From: Simran Rai <ssimran@broadcom.com>
>
> 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 <ssimran@broadcom.com>
> Signed-off-by: Ray Jui <rjui@broadcom.com>
> Reviewed-by: Scott Branden <sbranden@broadcom.com>
> ---
Did you want any Fixes: tag so this goes back to stable?
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] clk: iproc: Fix PLL output frequency calculation
2015-10-19 21:49 ` Stephen Boyd
@ 2015-10-19 21:55 ` Ray Jui
2015-10-19 22:16 ` Stephen Boyd
0 siblings, 1 reply; 6+ messages in thread
From: Ray Jui @ 2015-10-19 21:55 UTC (permalink / raw)
To: Stephen Boyd
Cc: Michael Turquette, linux-clk, linux-kernel,
bcm-kernel-feedback-list, Simran Rai
On 15-10-19 02:49 PM, Stephen Boyd wrote:
> On 10/16, Ray Jui wrote:
>> From: Simran Rai <ssimran@broadcom.com>
>>
>> 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 <ssimran@broadcom.com>
>> Signed-off-by: Ray Jui <rjui@broadcom.com>
>> Reviewed-by: Scott Branden <sbranden@broadcom.com>
>> ---
>
> 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
stable@vger.kernel.org .
Thanks,
Ray
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] clk: iproc: Fix PLL output frequency calculation
2015-10-19 21:55 ` Ray Jui
@ 2015-10-19 22:16 ` Stephen Boyd
2015-10-21 9:46 ` Michael Turquette
0 siblings, 1 reply; 6+ messages in thread
From: Stephen Boyd @ 2015-10-19 22:16 UTC (permalink / raw)
To: Ray Jui
Cc: Michael Turquette, linux-clk, linux-kernel,
bcm-kernel-feedback-list, Simran Rai
On 10/19/2015 02:55 PM, Ray Jui wrote:
>
>
> On 15-10-19 02:49 PM, Stephen Boyd wrote:
>> On 10/16, Ray Jui wrote:
>>> From: Simran Rai <ssimran@broadcom.com>
>>>
>>> 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 <ssimran@broadcom.com>
>>> Signed-off-by: Ray Jui <rjui@broadcom.com>
>>> Reviewed-by: Scott Branden <sbranden@broadcom.com>
>>> ---
>>
>> 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
> stable@vger.kernel.org .
Please just tell me the commit that this fixes, I can add the tag and
apply to the right tree then.
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] clk: iproc: Fix PLL output frequency calculation
2015-10-19 22:16 ` Stephen Boyd
@ 2015-10-21 9:46 ` Michael Turquette
0 siblings, 0 replies; 6+ messages in thread
From: Michael Turquette @ 2015-10-21 9:46 UTC (permalink / raw)
To: Stephen Boyd, Ray Jui
Cc: linux-clk, linux-kernel, bcm-kernel-feedback-list, Simran Rai
Quoting Stephen Boyd (2015-10-19 15:16:05)
> On 10/19/2015 02:55 PM, Ray Jui wrote:
> >
> >
> > On 15-10-19 02:49 PM, Stephen Boyd wrote:
> >> On 10/16, Ray Jui wrote:
> >>> From: Simran Rai <ssimran@broadcom.com>
> >>>
> >>> 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 <ssimran@broadcom.com>
> >>> Signed-off-by: Ray Jui <rjui@broadcom.com>
> >>> Reviewed-by: Scott Branden <sbranden@broadcom.com>
> >>> ---
> >>
> >> 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
> > stable@vger.kernel.org .
>
> 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:
Cc: <stable@vger.kernel.org> # v4.1+
Regards,
Mike
>
> --
> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
> a Linux Foundation Collaborative Project
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-10-21 9:46 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-16 22:44 [PATCH] Fix iProc PLL output clock frequency calculation Ray Jui
2015-10-16 22:44 ` [PATCH] clk: iproc: Fix PLL output " Ray Jui
2015-10-19 21:49 ` Stephen Boyd
2015-10-19 21:55 ` Ray Jui
2015-10-19 22:16 ` Stephen Boyd
2015-10-21 9:46 ` Michael Turquette
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).