public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/7] mx25: Fix decode_pll
@ 2012-09-27 20:26 Benoît Thébaudeau
  2012-09-27 20:27 ` [U-Boot] [PATCH 2/7] mx25: Clean up clock calculations Benoît Thébaudeau
                   ` (6 more replies)
  0 siblings, 7 replies; 13+ messages in thread
From: Benoît Thébaudeau @ 2012-09-27 20:26 UTC (permalink / raw)
  To: u-boot

The MFN bit-field of the PLL registers represents a signed value. See the
reference manual.

Signed-off-by: Beno?t Th?baudeau <benoit.thebaudeau@advansee.com>
Cc: Stefano Babic <sbabic@denx.de>
---
 .../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)

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2012-09-30 10:26 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-27 20:26 [U-Boot] [PATCH 1/7] mx25: Fix decode_pll Benoît Thébaudeau
2012-09-27 20:27 ` [U-Boot] [PATCH 2/7] mx25: Clean up clock calculations Benoît Thébaudeau
2012-09-27 20:27 ` [U-Boot] [PATCH 3/7] mx25: Define more standard clocks Benoît Thébaudeau
2012-09-27 20:27 ` [U-Boot] [PATCH 4/7] mx25 clocks: Fix MXC_FEC_CLK Benoît Thébaudeau
2012-09-28 10:33   ` Stefano Babic
2012-09-27 20:27 ` [U-Boot] [PATCH 5/7] mx25: Clean up clocks API Benoît Thébaudeau
2012-09-28 10:31   ` Stefano Babic
2012-09-27 20:28 ` [U-Boot] [PATCH 6/7] mx25: Define cpu_eth_init() only if needed Benoît Thébaudeau
2012-09-27 20:55   ` Fabio Estevam
2012-09-27 21:43     ` Benoît Thébaudeau
2012-09-28  9:09       ` Stefano Babic
2012-09-27 20:28 ` [U-Boot] [PATCH 7/7] mx25: Fix eSDHC support Benoît Thébaudeau
2012-09-30 10:26 ` [U-Boot] [PATCH 1/7] mx25: Fix decode_pll Stefano Babic

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox