summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenoît Thébaudeau <benoit.thebaudeau@advansee.com>2012-08-14 08:43:47 +0000
committerStefano Babic <sbabic@denx.de>2012-09-06 11:07:52 +0200
commit697191d57fb2fae7b31cec9581fb7749f965d877 (patch)
treed0ddce63862fe82ddc9b54583ac96fa2102fd1bd
parent543d247935f544acdd16f6dc136b8b8ceca2c2a5 (diff)
downloadu-boot-imx-697191d57fb2fae7b31cec9581fb7749f965d877.zip
u-boot-imx-697191d57fb2fae7b31cec9581fb7749f965d877.tar.gz
u-boot-imx-697191d57fb2fae7b31cec9581fb7749f965d877.tar.bz2
Fix mx31_decode_pll
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>
-rw-r--r--arch/arm/cpu/arm1136/mx31/generic.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/arch/arm/cpu/arm1136/mx31/generic.c b/arch/arm/cpu/arm1136/mx31/generic.c
index 8873fb7..3a35bfa 100644
--- a/arch/arm/cpu/arm1136/mx31/generic.c
+++ b/arch/arm/cpu/arm1136/mx31/generic.c
@@ -22,6 +22,7 @@
*/
#include <common.h>
+#include <div64.h>
#include <asm/arch/imx-regs.h>
#include <asm/arch/clock.h>
#include <asm/io.h>
@@ -30,16 +31,17 @@
static u32 mx31_decode_pll(u32 reg, u32 infreq)
{
u32 mfi = GET_PLL_MFI(reg);
- u32 mfn = GET_PLL_MFN(reg);
+ s32 mfn = GET_PLL_MFN(reg);
u32 mfd = GET_PLL_MFD(reg);
u32 pd = GET_PLL_PD(reg);
mfi = mfi <= 5 ? 5 : mfi;
+ mfn = mfn >= 512 ? mfn - 1024 : mfn;
mfd += 1;
pd += 1;
- return ((2 * (infreq >> 10) * (mfi * mfd + mfn)) /
- (mfd * pd)) << 10;
+ return lldiv(2 * (u64)infreq * (mfi * mfd + mfn),
+ mfd * pd);
}
static u32 mx31_get_mpl_dpdgck_clk(void)