Skip to content

Commit

Permalink
MXC PLL decoding: calculate mfn value with less magic
Browse files Browse the repository at this point in the history
Also, use cpu_is_* macros rather than CONFIG_ARCH_*

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
  • Loading branch information
Sascha Hauer committed Aug 7, 2009
1 parent 5ef881b commit 6d73665
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions arch/arm/plat-mxc/clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include <linux/string.h>

#include <mach/clock.h>
#include <mach/hardware.h>

static LIST_HEAD(clocks);
static DEFINE_MUTEX(clocks_mutex);
Expand Down Expand Up @@ -363,21 +364,22 @@ unsigned long mxc_decode_pll(unsigned int reg_val, u32 freq)

mfn_abs = mfn;

#if !defined CONFIG_ARCH_MX1 && !defined CONFIG_ARCH_MX21
if (mfn >= 0x200) {
mfn |= 0xFFFFFE00;
mfn_abs = -mfn;
}
#endif
/* On all i.MXs except i.MX1 and i.MX21 mfn is a 10bit
* 2's complements number
*/
if (!cpu_is_mx1() && !cpu_is_mx21() && mfn >= 0x200)
mfn_abs = 0x400 - mfn;

freq *= 2;
freq /= pd + 1;

ll = (unsigned long long)freq * mfn_abs;

do_div(ll, mfd + 1);
if (mfn < 0)

if (!cpu_is_mx1() && !cpu_is_mx21() && mfn >= 0x200)
ll = -ll;

ll = (freq * mfi) + ll;

return ll;
Expand Down

0 comments on commit 6d73665

Please sign in to comment.