diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2009-01-26 09:41:16 -0500 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2009-03-13 05:33:46 -0400 |
commit | a2865197a5dad23c619c84f44b7fdf7fdbef3f9c (patch) | |
tree | e62afa2bf72a8bad1cbfd400f79b92a13617fac6 /arch/arm/mach-mx2/clock_imx27.c | |
parent | 5512e88f3a1f1b498fd07181f14596ee117b3471 (diff) |
[ARM] MXC: Use a single function for decoding a PLL
We had 3 versions of this function in clock support for MX1/2/3
Use a single one instead. I picked the one from the MX3 as it seems
to calculate more accurate as the other ones. Also, on MX27 and MX31 mfn
can be negative, this hasn't been handled correctly on MX27 since now.
This patch has been tested on MX27 and MX31 and produces the same clock
frequencies for me.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/arm/mach-mx2/clock_imx27.c')
-rw-r--r-- | arch/arm/mach-mx2/clock_imx27.c | 42 |
1 files changed, 7 insertions, 35 deletions
diff --git a/arch/arm/mach-mx2/clock_imx27.c b/arch/arm/mach-mx2/clock_imx27.c index c69896d011a1..047e71e6ea9a 100644 --- a/arch/arm/mach-mx2/clock_imx27.c +++ b/arch/arm/mach-mx2/clock_imx27.c | |||
@@ -486,26 +486,8 @@ static struct clk ckil_clk = { | |||
486 | 486 | ||
487 | static unsigned long get_mpll_clk(struct clk *clk) | 487 | static unsigned long get_mpll_clk(struct clk *clk) |
488 | { | 488 | { |
489 | uint32_t reg; | 489 | return mxc_decode_pll(__raw_readl(CCM_MPCTL0), |
490 | unsigned long ref_clk; | 490 | clk_get_rate(clk->parent)); |
491 | unsigned long mfi = 0, mfn = 0, mfd = 0, pdf = 0; | ||
492 | unsigned long long temp; | ||
493 | |||
494 | ref_clk = clk_get_rate(clk->parent); | ||
495 | |||
496 | reg = __raw_readl(CCM_MPCTL0); | ||
497 | pdf = (reg & CCM_MPCTL0_PD_MASK) >> CCM_MPCTL0_PD_OFFSET; | ||
498 | mfd = (reg & CCM_MPCTL0_MFD_MASK) >> CCM_MPCTL0_MFD_OFFSET; | ||
499 | mfi = (reg & CCM_MPCTL0_MFI_MASK) >> CCM_MPCTL0_MFI_OFFSET; | ||
500 | mfn = (reg & CCM_MPCTL0_MFN_MASK) >> CCM_MPCTL0_MFN_OFFSET; | ||
501 | |||
502 | mfi = (mfi <= 5) ? 5 : mfi; | ||
503 | temp = 2LL * ref_clk * mfn; | ||
504 | do_div(temp, mfd + 1); | ||
505 | temp = 2LL * ref_clk * mfi + temp; | ||
506 | do_div(temp, pdf + 1); | ||
507 | |||
508 | return (unsigned long)temp; | ||
509 | } | 491 | } |
510 | 492 | ||
511 | static struct clk mpll_clk = { | 493 | static struct clk mpll_clk = { |
@@ -555,28 +537,18 @@ static unsigned long get_spll_clk(struct clk *clk) | |||
555 | { | 537 | { |
556 | uint32_t reg; | 538 | uint32_t reg; |
557 | unsigned long ref_clk; | 539 | unsigned long ref_clk; |
558 | unsigned long mfi = 0, mfn = 0, mfd = 0, pdf = 0; | ||
559 | unsigned long long temp; | ||
560 | 540 | ||
561 | ref_clk = clk_get_rate(clk->parent); | 541 | ref_clk = clk_get_rate(clk->parent); |
562 | 542 | ||
563 | reg = __raw_readl(CCM_SPCTL0); | 543 | reg = __raw_readl(CCM_SPCTL0); |
564 | /*TODO: This is TO2 Bug */ | 544 | |
545 | /* On TO2 we have to write the value back. Otherwise we | ||
546 | * read 0 from this register the next time. | ||
547 | */ | ||
565 | if (mx27_revision() >= CHIP_REV_2_0) | 548 | if (mx27_revision() >= CHIP_REV_2_0) |
566 | __raw_writel(reg, CCM_SPCTL0); | 549 | __raw_writel(reg, CCM_SPCTL0); |
567 | 550 | ||
568 | pdf = (reg & CCM_SPCTL0_PD_MASK) >> CCM_SPCTL0_PD_OFFSET; | 551 | return mxc_decode_pll(reg, ref_clk); |
569 | mfd = (reg & CCM_SPCTL0_MFD_MASK) >> CCM_SPCTL0_MFD_OFFSET; | ||
570 | mfi = (reg & CCM_SPCTL0_MFI_MASK) >> CCM_SPCTL0_MFI_OFFSET; | ||
571 | mfn = (reg & CCM_SPCTL0_MFN_MASK) >> CCM_SPCTL0_MFN_OFFSET; | ||
572 | |||
573 | mfi = (mfi <= 5) ? 5 : mfi; | ||
574 | temp = 2LL * ref_clk * mfn; | ||
575 | do_div(temp, mfd + 1); | ||
576 | temp = 2LL * ref_clk * mfi + temp; | ||
577 | do_div(temp, pdf + 1); | ||
578 | |||
579 | return (unsigned long)temp; | ||
580 | } | 552 | } |
581 | 553 | ||
582 | static struct clk spll_clk = { | 554 | static struct clk spll_clk = { |