diff options
Diffstat (limited to 'arch/arm/mach-mx1/clock.c')
-rw-r--r-- | arch/arm/mach-mx1/clock.c | 40 |
1 files changed, 8 insertions, 32 deletions
diff --git a/arch/arm/mach-mx1/clock.c b/arch/arm/mach-mx1/clock.c index 4bcd1ece55f5..0d0f306851d0 100644 --- a/arch/arm/mach-mx1/clock.c +++ b/arch/arm/mach-mx1/clock.c | |||
@@ -25,6 +25,7 @@ | |||
25 | 25 | ||
26 | #include <mach/clock.h> | 26 | #include <mach/clock.h> |
27 | #include <mach/hardware.h> | 27 | #include <mach/hardware.h> |
28 | #include <mach/common.h> | ||
28 | #include "crm_regs.h" | 29 | #include "crm_regs.h" |
29 | 30 | ||
30 | static int _clk_enable(struct clk *clk) | 31 | static int _clk_enable(struct clk *clk) |
@@ -87,33 +88,6 @@ static int _clk_parent_set_rate(struct clk *clk, unsigned long rate) | |||
87 | return clk->parent->set_rate(clk->parent, rate); | 88 | return clk->parent->set_rate(clk->parent, rate); |
88 | } | 89 | } |
89 | 90 | ||
90 | /* | ||
91 | * get the system pll clock in Hz | ||
92 | * | ||
93 | * mfi + mfn / (mfd +1) | ||
94 | * f = 2 * f_ref * -------------------- | ||
95 | * pd + 1 | ||
96 | */ | ||
97 | static unsigned long mx1_decode_pll(unsigned int pll, u32 f_ref) | ||
98 | { | ||
99 | unsigned long long ll; | ||
100 | unsigned long quot; | ||
101 | |||
102 | u32 mfi = (pll >> 10) & 0xf; | ||
103 | u32 mfn = pll & 0x3ff; | ||
104 | u32 mfd = (pll >> 16) & 0x3ff; | ||
105 | u32 pd = (pll >> 26) & 0xf; | ||
106 | |||
107 | mfi = mfi <= 5 ? 5 : mfi; | ||
108 | |||
109 | ll = 2 * (unsigned long long)f_ref * | ||
110 | ((mfi << 16) + (mfn << 16) / (mfd + 1)); | ||
111 | quot = (pd + 1) * (1 << 16); | ||
112 | ll += quot / 2; | ||
113 | do_div(ll, quot); | ||
114 | return (unsigned long)ll; | ||
115 | } | ||
116 | |||
117 | static unsigned long clk16m_get_rate(struct clk *clk) | 91 | static unsigned long clk16m_get_rate(struct clk *clk) |
118 | { | 92 | { |
119 | return 16000000; | 93 | return 16000000; |
@@ -188,7 +162,7 @@ static struct clk prem_clk = { | |||
188 | 162 | ||
189 | static unsigned long system_clk_get_rate(struct clk *clk) | 163 | static unsigned long system_clk_get_rate(struct clk *clk) |
190 | { | 164 | { |
191 | return mx1_decode_pll(__raw_readl(CCM_SPCTL0), | 165 | return mxc_decode_pll(__raw_readl(CCM_SPCTL0), |
192 | clk_get_rate(clk->parent)); | 166 | clk_get_rate(clk->parent)); |
193 | } | 167 | } |
194 | 168 | ||
@@ -200,7 +174,7 @@ static struct clk system_clk = { | |||
200 | 174 | ||
201 | static unsigned long mcu_clk_get_rate(struct clk *clk) | 175 | static unsigned long mcu_clk_get_rate(struct clk *clk) |
202 | { | 176 | { |
203 | return mx1_decode_pll(__raw_readl(CCM_MPCTL0), | 177 | return mxc_decode_pll(__raw_readl(CCM_MPCTL0), |
204 | clk_get_rate(clk->parent)); | 178 | clk_get_rate(clk->parent)); |
205 | } | 179 | } |
206 | 180 | ||
@@ -488,7 +462,7 @@ static struct clk clko_clk = { | |||
488 | }; | 462 | }; |
489 | 463 | ||
490 | static struct clk dma_clk = { | 464 | static struct clk dma_clk = { |
491 | .name = "dma_clk", | 465 | .name = "dma", |
492 | .parent = &hclk, | 466 | .parent = &hclk, |
493 | .round_rate = _clk_parent_round_rate, | 467 | .round_rate = _clk_parent_round_rate, |
494 | .set_rate = _clk_parent_set_rate, | 468 | .set_rate = _clk_parent_set_rate, |
@@ -539,7 +513,7 @@ static struct clk gpt_clk = { | |||
539 | }; | 513 | }; |
540 | 514 | ||
541 | static struct clk uart_clk = { | 515 | static struct clk uart_clk = { |
542 | .name = "uart_clk", | 516 | .name = "uart", |
543 | .parent = &perclk[0], | 517 | .parent = &perclk[0], |
544 | .round_rate = _clk_parent_round_rate, | 518 | .round_rate = _clk_parent_round_rate, |
545 | .set_rate = _clk_parent_set_rate, | 519 | .set_rate = _clk_parent_set_rate, |
@@ -621,7 +595,7 @@ static struct clk *mxc_clks[] = { | |||
621 | &rtc_clk, | 595 | &rtc_clk, |
622 | }; | 596 | }; |
623 | 597 | ||
624 | int __init mxc_clocks_init(unsigned long fref) | 598 | int __init mx1_clocks_init(unsigned long fref) |
625 | { | 599 | { |
626 | struct clk **clkp; | 600 | struct clk **clkp; |
627 | unsigned int reg; | 601 | unsigned int reg; |
@@ -652,5 +626,7 @@ int __init mxc_clocks_init(unsigned long fref) | |||
652 | clk_enable(&hclk); | 626 | clk_enable(&hclk); |
653 | clk_enable(&fclk); | 627 | clk_enable(&fclk); |
654 | 628 | ||
629 | mxc_timer_init(&gpt_clk); | ||
630 | |||
655 | return 0; | 631 | return 0; |
656 | } | 632 | } |