linux-mips
[Top] [All Lists]

[ 084/133] MIPS: ath79: use correct fractional dividers for {CPU,DDR}_PL

To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: [ 084/133] MIPS: ath79: use correct fractional dividers for {CPU,DDR}_PLL on AR934x
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Date: Thu, 11 Oct 2012 07:51:50 +0900
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>, alan@lxorguk.ukuu.org.uk, Gabor Juhos <juhosg@openwrt.org>, Ralf Baechle <ralf@linux-mips.org>, linux-mips@linux-mips.org
Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=from:to:cc:subject:date:message-id :in-reply-to:references; s=smtpout; bh=Q9sV+iHkkv4agkg7VCI79PFiz rU=; b=JZDK+qcQsaTlTo7Vxd8aQm1/fb21hQahteSwWRqY0rstr4D/L5w7i3/AP dfC9QPCDEMS6XR/WBswRNXF1VT4m/tDJY+UmHTQsa9YToTY9wn0V8PqpyAifDZNy eBx53nyb7nmhVMjTlAr/c7h+EvrL3KgH29KA4us5EfRE3W6EQ0=
In-reply-to: <20121010224854.313159132@linuxfoundation.org>
List-archive: <http://www.linux-mips.org/archives/linux-mips/>
List-help: <mailto:ecartis@linux-mips.org?Subject=help>
List-id: linux-mips <linux-mips.eddie.linux-mips.org>
List-owner: <mailto:ralf@linux-mips.org>
List-post: <mailto:linux-mips@linux-mips.org>
List-software: Ecartis version 1.0.0
List-subscribe: <mailto:ecartis@linux-mips.org?subject=subscribe%20linux-mips>
List-unsubscribe: <mailto:ecartis@linux-mips.org?subject=unsubscribe%20linux-mips>
References: <20121010224854.313159132@linuxfoundation.org>
Sender: linux-mips-bounce@linux-mips.org
User-agent: quilt/0.60-2.1.2
3.5-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Gabor Juhos <juhosg@openwrt.org>

commit 65fc7f9957c52ad4fdf4ee5dfe3a75aa0a633d39 upstream.

The current dividers in the code are wrong and this
leads to broken CPU frequency calculation on boards
where the fractional part is used.

For example, if the SoC is running from a 40MHz
reference clock, refdiv=1, nint=14, outdiv=0 and
nfrac=31 the real frequency is 579.375MHz but the
current code calculates 569.687MHz instead.

Because the system time is indirectly related to
the CPU frequency the broken computation causes
drift in the system time.

The correct divider is 2^6 for the CPU PLL and 2^10
for the DDR PLL. Use the correct values to fix the
issue.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/4305/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 arch/mips/ath79/clock.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- a/arch/mips/ath79/clock.c
+++ b/arch/mips/ath79/clock.c
@@ -189,7 +189,7 @@ static void __init ar934x_clocks_init(vo
               AR934X_PLL_CPU_CONFIG_NFRAC_MASK;
 
        cpu_pll = nint * ath79_ref_clk.rate / ref_div;
-       cpu_pll += frac * ath79_ref_clk.rate / (ref_div * (2 << 6));
+       cpu_pll += frac * ath79_ref_clk.rate / (ref_div * (1 << 6));
        cpu_pll /= (1 << out_div);
 
        pll = ath79_pll_rr(AR934X_PLL_DDR_CONFIG_REG);
@@ -203,7 +203,7 @@ static void __init ar934x_clocks_init(vo
               AR934X_PLL_DDR_CONFIG_NFRAC_MASK;
 
        ddr_pll = nint * ath79_ref_clk.rate / ref_div;
-       ddr_pll += frac * ath79_ref_clk.rate / (ref_div * (2 << 10));
+       ddr_pll += frac * ath79_ref_clk.rate / (ref_div * (1 << 10));
        ddr_pll /= (1 << out_div);
 
        clk_ctrl = ath79_pll_rr(AR934X_PLL_CPU_DDR_CLK_CTRL_REG);



<Prev in Thread] Current Thread [Next in Thread>
  • [ 084/133] MIPS: ath79: use correct fractional dividers for {CPU,DDR}_PLL on AR934x, Greg Kroah-Hartman <=