From patchwork Thu Sep 27 20:26:54 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Beno=C3=AEt_Th=C3=A9baudeau?= X-Patchwork-Id: 187469 X-Patchwork-Delegate: sbabic@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id B90D02C00B1 for ; Fri, 28 Sep 2012 06:22:01 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 4E70D28080; Thu, 27 Sep 2012 22:22:00 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id HDI9SQDyNqqY; Thu, 27 Sep 2012 22:22:00 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 0DF9E28091; Thu, 27 Sep 2012 22:21:59 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D52AD28091 for ; Thu, 27 Sep 2012 22:21:57 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id pEWKDgA8Xsfw for ; Thu, 27 Sep 2012 22:21:57 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from zose-mta15.web4all.fr (zose-mta15.web4all.fr [176.31.217.11]) by theia.denx.de (Postfix) with ESMTP id 5507928080 for ; Thu, 27 Sep 2012 22:21:57 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by zose-mta15.web4all.fr (Postfix) with ESMTP id D471D3233D; Thu, 27 Sep 2012 22:24:58 +0200 (CEST) X-Virus-Scanned: amavisd-new at zose1.web4all.fr Received: from zose-mta15.web4all.fr ([127.0.0.1]) by localhost (zose-mta15.web4all.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id HpjEAzLDFevb; Thu, 27 Sep 2012 22:24:58 +0200 (CEST) Received: from zose-store12.web4all.fr (zose-store-12.w4a.fr [178.33.204.48]) by zose-mta15.web4all.fr (Postfix) with ESMTP id 985B732106; Thu, 27 Sep 2012 22:24:58 +0200 (CEST) Date: Thu, 27 Sep 2012 22:26:54 +0200 (CEST) From: =?utf-8?Q?Beno=C3=AEt_Th=C3=A9baudeau?= To: U-Boot-Users ML Message-ID: <354965566.5372561.1348777614543.JavaMail.root@advansee.com> MIME-Version: 1.0 X-Originating-IP: [88.188.188.98] X-Mailer: Zimbra 7.2.0_GA_2669 (ZimbraWebClient - FF3.0 (Win)/7.2.0_GA_2669) Subject: [U-Boot] [PATCH 1/7] mx25: Fix decode_pll X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de The MFN bit-field of the PLL registers represents a signed value. See the reference manual. Signed-off-by: Benoît Thébaudeau Cc: Stefano Babic --- .../arch/arm/cpu/arm926ejs/mx25/generic.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git u-boot-imx-e1eb75b.orig/arch/arm/cpu/arm926ejs/mx25/generic.c u-boot-imx-e1eb75b/arch/arm/cpu/arm926ejs/mx25/generic.c index 90e584a..2283a89 100644 --- u-boot-imx-e1eb75b.orig/arch/arm/cpu/arm926ejs/mx25/generic.c +++ u-boot-imx-e1eb75b/arch/arm/cpu/arm926ejs/mx25/generic.c @@ -48,7 +48,7 @@ static unsigned int imx_decode_pll(unsigned int pll, unsigned int f_ref) { unsigned int mfi = (pll >> CCM_PLL_MFI_SHIFT) & CCM_PLL_MFI_MASK; - unsigned int mfn = (pll >> CCM_PLL_MFN_SHIFT) + int mfn = (pll >> CCM_PLL_MFN_SHIFT) & CCM_PLL_MFN_MASK; unsigned int mfd = (pll >> CCM_PLL_MFD_SHIFT) & CCM_PLL_MFD_MASK; @@ -56,9 +56,12 @@ static unsigned int imx_decode_pll(unsigned int pll, unsigned int f_ref) & CCM_PLL_PD_MASK; mfi = mfi <= 5 ? 5 : mfi; + mfn = mfn >= 512 ? mfn - 1024 : mfn; + mfd += 1; + pd += 1; - return lldiv(2 * (u64) f_ref * (mfi * (mfd + 1) + mfn), - (mfd + 1) * (pd + 1)); + return lldiv(2 * (u64) f_ref * (mfi * mfd + mfn), + mfd * pd); } static ulong imx_get_mpllclk(void)