blob: 5a1aa15c8a16140f17e75ea451b5441c9c413d10 [file] [log] [blame]
Juergen Beisertc46f5852008-07-05 10:02:59 +02001/*
2 * Copyright 2004-2007 Freescale Semiconductor, Inc. All Rights Reserved.
3 * Copyright 2008 Juergen Beisert, kernel@pengutronix.de
Sascha Haueredfcea82009-02-16 15:13:43 +01004 * Copyright 2008 Martin Fuzzey, mfuzzey@gmail.com
Juergen Beisertc46f5852008-07-05 10:02:59 +02005 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18 * MA 02110-1301, USA.
19 */
20
21#include <linux/clk.h>
22#include <linux/io.h>
23#include <linux/module.h>
Sascha Haueredfcea82009-02-16 15:13:43 +010024
25#include <asm/clkdev.h>
26#include <asm/div64.h>
Juergen Beisertc46f5852008-07-05 10:02:59 +020027
Russell Kinga09e64f2008-08-05 16:14:15 +010028#include <mach/clock.h>
29#include <mach/common.h>
Sascha Haueredfcea82009-02-16 15:13:43 +010030#include <mach/hardware.h>
Juergen Beisertc46f5852008-07-05 10:02:59 +020031
Uwe Kleine-Königa9b7a2d2009-12-17 11:56:43 +010032#define IO_ADDR_CCM(off) (MX27_IO_ADDRESS(MX27_CCM_BASE_ADDR + (off)))
Uwe Kleine-Königb7056462009-12-11 09:57:27 +010033
Sascha Haueredfcea82009-02-16 15:13:43 +010034/* Register offsets */
Uwe Kleine-Königb7056462009-12-11 09:57:27 +010035#define CCM_CSCR IO_ADDR_CCM(0x0)
36#define CCM_MPCTL0 IO_ADDR_CCM(0x4)
37#define CCM_MPCTL1 IO_ADDR_CCM(0x8)
38#define CCM_SPCTL0 IO_ADDR_CCM(0xc)
39#define CCM_SPCTL1 IO_ADDR_CCM(0x10)
40#define CCM_OSC26MCTL IO_ADDR_CCM(0x14)
41#define CCM_PCDR0 IO_ADDR_CCM(0x18)
42#define CCM_PCDR1 IO_ADDR_CCM(0x1c)
43#define CCM_PCCR0 IO_ADDR_CCM(0x20)
44#define CCM_PCCR1 IO_ADDR_CCM(0x24)
45#define CCM_CCSR IO_ADDR_CCM(0x28)
46#define CCM_PMCTL IO_ADDR_CCM(0x2c)
47#define CCM_PMCOUNT IO_ADDR_CCM(0x30)
48#define CCM_WKGDCTL IO_ADDR_CCM(0x34)
Juergen Beisertc46f5852008-07-05 10:02:59 +020049
Sascha Haueredfcea82009-02-16 15:13:43 +010050#define CCM_CSCR_UPDATE_DIS (1 << 31)
51#define CCM_CSCR_SSI2 (1 << 23)
52#define CCM_CSCR_SSI1 (1 << 22)
53#define CCM_CSCR_VPU (1 << 21)
54#define CCM_CSCR_MSHC (1 << 20)
55#define CCM_CSCR_SPLLRES (1 << 19)
56#define CCM_CSCR_MPLLRES (1 << 18)
57#define CCM_CSCR_SP (1 << 17)
58#define CCM_CSCR_MCU (1 << 16)
59#define CCM_CSCR_OSC26MDIV (1 << 4)
60#define CCM_CSCR_OSC26M (1 << 3)
61#define CCM_CSCR_FPM (1 << 2)
62#define CCM_CSCR_SPEN (1 << 1)
63#define CCM_CSCR_MPEN (1 << 0)
Juergen Beisertc46f5852008-07-05 10:02:59 +020064
Sascha Haueredfcea82009-02-16 15:13:43 +010065/* i.MX27 TO 2+ */
66#define CCM_CSCR_ARM_SRC (1 << 15)
67
68#define CCM_SPCTL1_LF (1 << 15)
69#define CCM_SPCTL1_BRMO (1 << 6)
70
71static struct clk mpll_main1_clk, mpll_main2_clk;
72
73static int clk_pccr_enable(struct clk *clk)
Juergen Beisertc46f5852008-07-05 10:02:59 +020074{
75 unsigned long reg;
76
Sascha Haueredfcea82009-02-16 15:13:43 +010077 if (!clk->enable_reg)
78 return 0;
79
Juergen Beisertc46f5852008-07-05 10:02:59 +020080 reg = __raw_readl(clk->enable_reg);
81 reg |= 1 << clk->enable_shift;
82 __raw_writel(reg, clk->enable_reg);
83
84 return 0;
85}
86
Sascha Haueredfcea82009-02-16 15:13:43 +010087static void clk_pccr_disable(struct clk *clk)
Juergen Beisertc46f5852008-07-05 10:02:59 +020088{
89 unsigned long reg;
90
Sascha Haueredfcea82009-02-16 15:13:43 +010091 if (!clk->enable_reg)
92 return;
93
Juergen Beisertc46f5852008-07-05 10:02:59 +020094 reg = __raw_readl(clk->enable_reg);
95 reg &= ~(1 << clk->enable_shift);
96 __raw_writel(reg, clk->enable_reg);
97}
98
Sascha Haueredfcea82009-02-16 15:13:43 +010099static int clk_spll_enable(struct clk *clk)
Juergen Beisertc46f5852008-07-05 10:02:59 +0200100{
101 unsigned long reg;
102
103 reg = __raw_readl(CCM_CSCR);
104 reg |= CCM_CSCR_SPEN;
105 __raw_writel(reg, CCM_CSCR);
106
Sascha Haueredfcea82009-02-16 15:13:43 +0100107 while (!(__raw_readl(CCM_SPCTL1) & CCM_SPCTL1_LF));
Juergen Beisertc46f5852008-07-05 10:02:59 +0200108
109 return 0;
110}
111
Sascha Haueredfcea82009-02-16 15:13:43 +0100112static void clk_spll_disable(struct clk *clk)
Juergen Beisertc46f5852008-07-05 10:02:59 +0200113{
114 unsigned long reg;
115
116 reg = __raw_readl(CCM_CSCR);
117 reg &= ~CCM_CSCR_SPEN;
118 __raw_writel(reg, CCM_CSCR);
119}
120
Sascha Haueredfcea82009-02-16 15:13:43 +0100121static int clk_cpu_set_parent(struct clk *clk, struct clk *parent)
Juergen Beisertc46f5852008-07-05 10:02:59 +0200122{
Sascha Haueredfcea82009-02-16 15:13:43 +0100123 int cscr = __raw_readl(CCM_CSCR);
Juergen Beisertc46f5852008-07-05 10:02:59 +0200124
125 if (clk->parent == parent)
126 return 0;
127
128 if (mx27_revision() >= CHIP_REV_2_0) {
Sascha Haueredfcea82009-02-16 15:13:43 +0100129 if (parent == &mpll_main1_clk) {
Juergen Beisertc46f5852008-07-05 10:02:59 +0200130 cscr |= CCM_CSCR_ARM_SRC;
131 } else {
Sascha Haueredfcea82009-02-16 15:13:43 +0100132 if (parent == &mpll_main2_clk)
Juergen Beisertc46f5852008-07-05 10:02:59 +0200133 cscr &= ~CCM_CSCR_ARM_SRC;
134 else
135 return -EINVAL;
136 }
137 __raw_writel(cscr, CCM_CSCR);
Sascha Haueredfcea82009-02-16 15:13:43 +0100138 clk->parent = parent;
139 return 0;
140 }
141 return -ENODEV;
Juergen Beisertc46f5852008-07-05 10:02:59 +0200142}
143
Sascha Haueredfcea82009-02-16 15:13:43 +0100144static unsigned long round_rate_cpu(struct clk *clk, unsigned long rate)
Juergen Beisertc46f5852008-07-05 10:02:59 +0200145{
146 int div;
147 unsigned long parent_rate;
148
149 parent_rate = clk_get_rate(clk->parent);
150
151 div = parent_rate / rate;
152 if (parent_rate % rate)
153 div++;
154
155 if (div > 4)
156 div = 4;
157
158 return parent_rate / div;
159}
160
Sascha Haueredfcea82009-02-16 15:13:43 +0100161static int set_rate_cpu(struct clk *clk, unsigned long rate)
Juergen Beisertc46f5852008-07-05 10:02:59 +0200162{
163 unsigned int div;
164 uint32_t reg;
165 unsigned long parent_rate;
166
167 parent_rate = clk_get_rate(clk->parent);
168
169 div = parent_rate / rate;
170
171 if (div > 4 || div < 1 || ((parent_rate / div) != rate))
172 return -EINVAL;
173
174 div--;
175
176 reg = __raw_readl(CCM_CSCR);
177 if (mx27_revision() >= CHIP_REV_2_0) {
Sascha Haueredfcea82009-02-16 15:13:43 +0100178 reg &= ~(3 << 12);
179 reg |= div << 12;
180 reg &= ~(CCM_CSCR_FPM | CCM_CSCR_SPEN);
181 __raw_writel(reg | CCM_CSCR_UPDATE_DIS, CCM_CSCR);
Juergen Beisertc46f5852008-07-05 10:02:59 +0200182 } else {
Sascha Haueredfcea82009-02-16 15:13:43 +0100183 printk(KERN_ERR "Can't set CPU frequency!\n");
Juergen Beisertc46f5852008-07-05 10:02:59 +0200184 }
185
186 return 0;
187}
188
Sascha Haueredfcea82009-02-16 15:13:43 +0100189static unsigned long round_rate_per(struct clk *clk, unsigned long rate)
Juergen Beisertc46f5852008-07-05 10:02:59 +0200190{
191 u32 div;
192 unsigned long parent_rate;
193
194 parent_rate = clk_get_rate(clk->parent);
195
196 div = parent_rate / rate;
197 if (parent_rate % rate)
198 div++;
199
200 if (div > 64)
201 div = 64;
202
203 return parent_rate / div;
204}
205
Sascha Haueredfcea82009-02-16 15:13:43 +0100206static int set_rate_per(struct clk *clk, unsigned long rate)
Juergen Beisertc46f5852008-07-05 10:02:59 +0200207{
208 u32 reg;
209 u32 div;
210 unsigned long parent_rate;
211
212 parent_rate = clk_get_rate(clk->parent);
213
214 if (clk->id < 0 || clk->id > 3)
215 return -EINVAL;
216
217 div = parent_rate / rate;
218 if (div > 64 || div < 1 || ((parent_rate / div) != rate))
219 return -EINVAL;
220 div--;
221
Sascha Haueredfcea82009-02-16 15:13:43 +0100222 reg = __raw_readl(CCM_PCDR1) & ~(0x3f << (clk->id << 3));
Juergen Beisertc46f5852008-07-05 10:02:59 +0200223 reg |= div << (clk->id << 3);
224 __raw_writel(reg, CCM_PCDR1);
225
226 return 0;
227}
228
Sascha Haueredfcea82009-02-16 15:13:43 +0100229static unsigned long get_rate_usb(struct clk *clk)
Juergen Beisertc46f5852008-07-05 10:02:59 +0200230{
231 unsigned long usb_pdf;
232 unsigned long parent_rate;
233
234 parent_rate = clk_get_rate(clk->parent);
235
Sascha Haueredfcea82009-02-16 15:13:43 +0100236 usb_pdf = (__raw_readl(CCM_CSCR) >> 28) & 0x7;
Juergen Beisertc46f5852008-07-05 10:02:59 +0200237
238 return parent_rate / (usb_pdf + 1U);
239}
240
Sascha Haueredfcea82009-02-16 15:13:43 +0100241static unsigned long get_rate_ssix(struct clk *clk, unsigned long pdf)
Juergen Beisertc46f5852008-07-05 10:02:59 +0200242{
Juergen Beisertc46f5852008-07-05 10:02:59 +0200243 unsigned long parent_rate;
244
245 parent_rate = clk_get_rate(clk->parent);
246
Juergen Beisertc46f5852008-07-05 10:02:59 +0200247 if (mx27_revision() >= CHIP_REV_2_0)
Sascha Haueredfcea82009-02-16 15:13:43 +0100248 pdf += 4; /* MX27 TO2+ */
Juergen Beisertc46f5852008-07-05 10:02:59 +0200249 else
Sascha Haueredfcea82009-02-16 15:13:43 +0100250 pdf = (pdf < 2) ? 124UL : pdf; /* MX21 & MX27 TO1 */
Juergen Beisertc46f5852008-07-05 10:02:59 +0200251
Sascha Haueredfcea82009-02-16 15:13:43 +0100252 return 2UL * parent_rate / pdf;
Juergen Beisertc46f5852008-07-05 10:02:59 +0200253}
254
Sascha Haueredfcea82009-02-16 15:13:43 +0100255static unsigned long get_rate_ssi1(struct clk *clk)
Juergen Beisertc46f5852008-07-05 10:02:59 +0200256{
Sascha Haueredfcea82009-02-16 15:13:43 +0100257 return get_rate_ssix(clk, (__raw_readl(CCM_PCDR0) >> 16) & 0x3f);
Juergen Beisertc46f5852008-07-05 10:02:59 +0200258}
259
Sascha Haueredfcea82009-02-16 15:13:43 +0100260static unsigned long get_rate_ssi2(struct clk *clk)
261{
262 return get_rate_ssix(clk, (__raw_readl(CCM_PCDR0) >> 26) & 0x3f);
263}
264
265static unsigned long get_rate_nfc(struct clk *clk)
Juergen Beisertc46f5852008-07-05 10:02:59 +0200266{
267 unsigned long nfc_pdf;
268 unsigned long parent_rate;
269
270 parent_rate = clk_get_rate(clk->parent);
271
Sascha Haueredfcea82009-02-16 15:13:43 +0100272 if (mx27_revision() >= CHIP_REV_2_0)
273 nfc_pdf = (__raw_readl(CCM_PCDR0) >> 6) & 0xf;
274 else
275 nfc_pdf = (__raw_readl(CCM_PCDR0) >> 12) & 0xf;
Juergen Beisertc46f5852008-07-05 10:02:59 +0200276
277 return parent_rate / (nfc_pdf + 1);
278}
279
Sascha Haueredfcea82009-02-16 15:13:43 +0100280static unsigned long get_rate_vpu(struct clk *clk)
Juergen Beisertc46f5852008-07-05 10:02:59 +0200281{
282 unsigned long vpu_pdf;
283 unsigned long parent_rate;
284
285 parent_rate = clk_get_rate(clk->parent);
286
287 if (mx27_revision() >= CHIP_REV_2_0) {
Sascha Haueredfcea82009-02-16 15:13:43 +0100288 vpu_pdf = (__raw_readl(CCM_PCDR0) >> 10) & 0x3f;
Juergen Beisertc46f5852008-07-05 10:02:59 +0200289 vpu_pdf += 4;
290 } else {
Sascha Haueredfcea82009-02-16 15:13:43 +0100291 vpu_pdf = (__raw_readl(CCM_PCDR0) >> 8) & 0xf;
Juergen Beisertc46f5852008-07-05 10:02:59 +0200292 vpu_pdf = (vpu_pdf < 2) ? 124 : vpu_pdf;
293 }
Sascha Haueredfcea82009-02-16 15:13:43 +0100294
Juergen Beisertc46f5852008-07-05 10:02:59 +0200295 return 2UL * parent_rate / vpu_pdf;
296}
297
Sascha Haueredfcea82009-02-16 15:13:43 +0100298static unsigned long round_rate_parent(struct clk *clk, unsigned long rate)
Juergen Beisertc46f5852008-07-05 10:02:59 +0200299{
300 return clk->parent->round_rate(clk->parent, rate);
301}
302
Sascha Haueredfcea82009-02-16 15:13:43 +0100303static unsigned long get_rate_parent(struct clk *clk)
304{
305 return clk_get_rate(clk->parent);
306}
307
308static int set_rate_parent(struct clk *clk, unsigned long rate)
Juergen Beisertc46f5852008-07-05 10:02:59 +0200309{
310 return clk->parent->set_rate(clk->parent, rate);
311}
312
313/* in Hz */
314static unsigned long external_high_reference = 26000000;
315
Sascha Haueredfcea82009-02-16 15:13:43 +0100316static unsigned long get_rate_high_reference(struct clk *clk)
Juergen Beisertc46f5852008-07-05 10:02:59 +0200317{
318 return external_high_reference;
319}
320
Juergen Beisertc46f5852008-07-05 10:02:59 +0200321/* in Hz */
322static unsigned long external_low_reference = 32768;
323
Sascha Haueredfcea82009-02-16 15:13:43 +0100324static unsigned long get_rate_low_reference(struct clk *clk)
Juergen Beisertc46f5852008-07-05 10:02:59 +0200325{
326 return external_low_reference;
327}
328
Sascha Haueredfcea82009-02-16 15:13:43 +0100329static unsigned long get_rate_fpm(struct clk *clk)
330{
331 return clk_get_rate(clk->parent) * 1024;
332}
Juergen Beisertc46f5852008-07-05 10:02:59 +0200333
Sascha Haueredfcea82009-02-16 15:13:43 +0100334static unsigned long get_rate_mpll(struct clk *clk)
Juergen Beisertc46f5852008-07-05 10:02:59 +0200335{
Sascha Hauera28651972009-01-26 15:41:16 +0100336 return mxc_decode_pll(__raw_readl(CCM_MPCTL0),
337 clk_get_rate(clk->parent));
Juergen Beisertc46f5852008-07-05 10:02:59 +0200338}
339
Sascha Haueredfcea82009-02-16 15:13:43 +0100340static unsigned long get_rate_mpll_main(struct clk *clk)
Juergen Beisertc46f5852008-07-05 10:02:59 +0200341{
342 unsigned long parent_rate;
343
344 parent_rate = clk_get_rate(clk->parent);
345
346 /* i.MX27 TO2:
Sascha Haueredfcea82009-02-16 15:13:43 +0100347 * clk->id == 0: arm clock source path 1 which is from 2 * MPLL / 2
348 * clk->id == 1: arm clock source path 2 which is from 2 * MPLL / 3
Juergen Beisertc46f5852008-07-05 10:02:59 +0200349 */
Juergen Beisertc46f5852008-07-05 10:02:59 +0200350 if (mx27_revision() >= CHIP_REV_2_0 && clk->id == 1)
351 return 2UL * parent_rate / 3UL;
352
353 return parent_rate;
354}
355
Sascha Haueredfcea82009-02-16 15:13:43 +0100356static unsigned long get_rate_spll(struct clk *clk)
Juergen Beisertc46f5852008-07-05 10:02:59 +0200357{
358 uint32_t reg;
Sascha Haueredfcea82009-02-16 15:13:43 +0100359 unsigned long rate;
Juergen Beisertc46f5852008-07-05 10:02:59 +0200360
Sascha Haueredfcea82009-02-16 15:13:43 +0100361 rate = clk_get_rate(clk->parent);
Juergen Beisertc46f5852008-07-05 10:02:59 +0200362
363 reg = __raw_readl(CCM_SPCTL0);
Sascha Hauera28651972009-01-26 15:41:16 +0100364
365 /* On TO2 we have to write the value back. Otherwise we
366 * read 0 from this register the next time.
367 */
Juergen Beisertc46f5852008-07-05 10:02:59 +0200368 if (mx27_revision() >= CHIP_REV_2_0)
369 __raw_writel(reg, CCM_SPCTL0);
370
Sascha Haueredfcea82009-02-16 15:13:43 +0100371 return mxc_decode_pll(reg, rate);
Juergen Beisertc46f5852008-07-05 10:02:59 +0200372}
373
Sascha Haueredfcea82009-02-16 15:13:43 +0100374static unsigned long get_rate_cpu(struct clk *clk)
Juergen Beisertc46f5852008-07-05 10:02:59 +0200375{
376 u32 div;
377 unsigned long rate;
378
379 if (mx27_revision() >= CHIP_REV_2_0)
Sascha Haueredfcea82009-02-16 15:13:43 +0100380 div = (__raw_readl(CCM_CSCR) >> 12) & 0x3;
Juergen Beisertc46f5852008-07-05 10:02:59 +0200381 else
Sascha Haueredfcea82009-02-16 15:13:43 +0100382 div = (__raw_readl(CCM_CSCR) >> 13) & 0x7;
Juergen Beisertc46f5852008-07-05 10:02:59 +0200383
384 rate = clk_get_rate(clk->parent);
385 return rate / (div + 1);
386}
387
Sascha Haueredfcea82009-02-16 15:13:43 +0100388static unsigned long get_rate_ahb(struct clk *clk)
Juergen Beisertc46f5852008-07-05 10:02:59 +0200389{
Sascha Haueredfcea82009-02-16 15:13:43 +0100390 unsigned long rate, bclk_pdf;
Juergen Beisertc46f5852008-07-05 10:02:59 +0200391
392 if (mx27_revision() >= CHIP_REV_2_0)
Sascha Haueredfcea82009-02-16 15:13:43 +0100393 bclk_pdf = (__raw_readl(CCM_CSCR) >> 8) & 0x3;
Juergen Beisertc46f5852008-07-05 10:02:59 +0200394 else
Sascha Haueredfcea82009-02-16 15:13:43 +0100395 bclk_pdf = (__raw_readl(CCM_CSCR) >> 9) & 0xf;
Juergen Beisertc46f5852008-07-05 10:02:59 +0200396
397 rate = clk_get_rate(clk->parent);
398 return rate / (bclk_pdf + 1);
399}
400
Sascha Haueredfcea82009-02-16 15:13:43 +0100401static unsigned long get_rate_ipg(struct clk *clk)
Juergen Beisertc46f5852008-07-05 10:02:59 +0200402{
Sascha Haueredfcea82009-02-16 15:13:43 +0100403 unsigned long rate, ipg_pdf;
Juergen Beisertc46f5852008-07-05 10:02:59 +0200404
405 if (mx27_revision() >= CHIP_REV_2_0)
406 return clk_get_rate(clk->parent);
407 else
Sascha Haueredfcea82009-02-16 15:13:43 +0100408 ipg_pdf = (__raw_readl(CCM_CSCR) >> 8) & 1;
Juergen Beisertc46f5852008-07-05 10:02:59 +0200409
410 rate = clk_get_rate(clk->parent);
411 return rate / (ipg_pdf + 1);
412}
413
Sascha Haueredfcea82009-02-16 15:13:43 +0100414static unsigned long get_rate_per(struct clk *clk)
Juergen Beisertc46f5852008-07-05 10:02:59 +0200415{
Sascha Haueredfcea82009-02-16 15:13:43 +0100416 unsigned long perclk_pdf, parent_rate;
Juergen Beisertc46f5852008-07-05 10:02:59 +0200417
418 parent_rate = clk_get_rate(clk->parent);
419
420 if (clk->id < 0 || clk->id > 3)
421 return 0;
422
Sascha Haueredfcea82009-02-16 15:13:43 +0100423 perclk_pdf = (__raw_readl(CCM_PCDR1) >> (clk->id << 3)) & 0x3f;
Juergen Beisertc46f5852008-07-05 10:02:59 +0200424
425 return parent_rate / (perclk_pdf + 1);
426}
427
Sascha Haueredfcea82009-02-16 15:13:43 +0100428/*
429 * the high frequency external clock reference
430 * Default case is 26MHz. Could be changed at runtime
431 * with a call to change_external_high_reference()
432 */
433static struct clk ckih_clk = {
434 .get_rate = get_rate_high_reference,
Juergen Beisertc46f5852008-07-05 10:02:59 +0200435};
436
Sascha Haueredfcea82009-02-16 15:13:43 +0100437static struct clk mpll_clk = {
438 .parent = &ckih_clk,
439 .get_rate = get_rate_mpll,
Juergen Beisertc46f5852008-07-05 10:02:59 +0200440};
441
Sascha Haueredfcea82009-02-16 15:13:43 +0100442/* For i.MX27 TO2, it is the MPLL path 1 of ARM core
443 * It provides the clock source whose rate is same as MPLL
444 */
445static struct clk mpll_main1_clk = {
446 .id = 0,
447 .parent = &mpll_clk,
448 .get_rate = get_rate_mpll_main,
Juergen Beisertc46f5852008-07-05 10:02:59 +0200449};
450
Sascha Haueredfcea82009-02-16 15:13:43 +0100451/* For i.MX27 TO2, it is the MPLL path 2 of ARM core
452 * It provides the clock source whose rate is same MPLL * 2 / 3
453 */
454static struct clk mpll_main2_clk = {
455 .id = 1,
456 .parent = &mpll_clk,
457 .get_rate = get_rate_mpll_main,
Juergen Beisertc46f5852008-07-05 10:02:59 +0200458};
459
Sascha Haueredfcea82009-02-16 15:13:43 +0100460static struct clk ahb_clk = {
461 .parent = &mpll_main2_clk,
462 .get_rate = get_rate_ahb,
Juergen Beisertc46f5852008-07-05 10:02:59 +0200463};
464
Sascha Haueredfcea82009-02-16 15:13:43 +0100465static struct clk ipg_clk = {
466 .parent = &ahb_clk,
467 .get_rate = get_rate_ipg,
Juergen Beisertc46f5852008-07-05 10:02:59 +0200468};
469
Sascha Haueredfcea82009-02-16 15:13:43 +0100470static struct clk cpu_clk = {
471 .parent = &mpll_main2_clk,
472 .set_parent = clk_cpu_set_parent,
473 .round_rate = round_rate_cpu,
474 .get_rate = get_rate_cpu,
475 .set_rate = set_rate_cpu,
Juergen Beisertc46f5852008-07-05 10:02:59 +0200476};
477
Sascha Haueredfcea82009-02-16 15:13:43 +0100478static struct clk spll_clk = {
479 .parent = &ckih_clk,
480 .get_rate = get_rate_spll,
481 .enable = clk_spll_enable,
482 .disable = clk_spll_disable,
Juergen Beisertc46f5852008-07-05 10:02:59 +0200483};
484
Sascha Haueredfcea82009-02-16 15:13:43 +0100485/*
486 * the low frequency external clock reference
487 * Default case is 32.768kHz.
488 */
489static struct clk ckil_clk = {
490 .get_rate = get_rate_low_reference,
Juergen Beisertc46f5852008-07-05 10:02:59 +0200491};
492
Sascha Haueredfcea82009-02-16 15:13:43 +0100493/* Output of frequency pre multiplier */
494static struct clk fpm_clk = {
495 .parent = &ckil_clk,
496 .get_rate = get_rate_fpm,
Juergen Beisertc46f5852008-07-05 10:02:59 +0200497};
498
Sascha Haueredfcea82009-02-16 15:13:43 +0100499#define PCCR0 CCM_PCCR0
500#define PCCR1 CCM_PCCR1
Juergen Beisertc46f5852008-07-05 10:02:59 +0200501
Sascha Haueredfcea82009-02-16 15:13:43 +0100502#define DEFINE_CLOCK(name, i, er, es, gr, s, p) \
503 static struct clk name = { \
504 .id = i, \
505 .enable_reg = er, \
506 .enable_shift = es, \
507 .get_rate = gr, \
508 .enable = clk_pccr_enable, \
509 .disable = clk_pccr_disable, \
510 .secondary = s, \
511 .parent = p, \
Juergen Beisertc46f5852008-07-05 10:02:59 +0200512 }
Juergen Beisertc46f5852008-07-05 10:02:59 +0200513
Sascha Haueredfcea82009-02-16 15:13:43 +0100514#define DEFINE_CLOCK1(name, i, er, es, getsetround, s, p) \
515 static struct clk name = { \
516 .id = i, \
517 .enable_reg = er, \
518 .enable_shift = es, \
519 .get_rate = get_rate_##getsetround, \
520 .set_rate = set_rate_##getsetround, \
521 .round_rate = round_rate_##getsetround, \
522 .enable = clk_pccr_enable, \
523 .disable = clk_pccr_disable, \
524 .secondary = s, \
525 .parent = p, \
526 }
527
528/* Forward declaration to keep the following list in order */
529static struct clk slcdc_clk1, sahara2_clk1, rtic_clk1, fec_clk1, emma_clk1,
530 dma_clk1, lcdc_clk2, vpu_clk1;
531
532/* All clocks we can gate through PCCRx in the order of PCCRx bits */
533DEFINE_CLOCK(ssi2_clk1, 1, PCCR0, 0, NULL, NULL, &ipg_clk);
534DEFINE_CLOCK(ssi1_clk1, 0, PCCR0, 1, NULL, NULL, &ipg_clk);
535DEFINE_CLOCK(slcdc_clk, 0, PCCR0, 2, NULL, &slcdc_clk1, &ahb_clk);
536DEFINE_CLOCK(sdhc3_clk1, 0, PCCR0, 3, NULL, NULL, &ipg_clk);
537DEFINE_CLOCK(sdhc2_clk1, 0, PCCR0, 4, NULL, NULL, &ipg_clk);
538DEFINE_CLOCK(sdhc1_clk1, 0, PCCR0, 5, NULL, NULL, &ipg_clk);
539DEFINE_CLOCK(scc_clk, 0, PCCR0, 6, NULL, NULL, &ipg_clk);
540DEFINE_CLOCK(sahara2_clk, 0, PCCR0, 7, NULL, &sahara2_clk1, &ahb_clk);
541DEFINE_CLOCK(rtic_clk, 0, PCCR0, 8, NULL, &rtic_clk1, &ahb_clk);
542DEFINE_CLOCK(rtc_clk, 0, PCCR0, 9, NULL, NULL, &ipg_clk);
543DEFINE_CLOCK(pwm_clk1, 0, PCCR0, 11, NULL, NULL, &ipg_clk);
544DEFINE_CLOCK(owire_clk, 0, PCCR0, 12, NULL, NULL, &ipg_clk);
545DEFINE_CLOCK(mstick_clk1, 0, PCCR0, 13, NULL, NULL, &ipg_clk);
546DEFINE_CLOCK(lcdc_clk1, 0, PCCR0, 14, NULL, &lcdc_clk2, &ipg_clk);
547DEFINE_CLOCK(kpp_clk, 0, PCCR0, 15, NULL, NULL, &ipg_clk);
548DEFINE_CLOCK(iim_clk, 0, PCCR0, 16, NULL, NULL, &ipg_clk);
549DEFINE_CLOCK(i2c2_clk, 1, PCCR0, 17, NULL, NULL, &ipg_clk);
550DEFINE_CLOCK(i2c1_clk, 0, PCCR0, 18, NULL, NULL, &ipg_clk);
551DEFINE_CLOCK(gpt6_clk1, 0, PCCR0, 29, NULL, NULL, &ipg_clk);
552DEFINE_CLOCK(gpt5_clk1, 0, PCCR0, 20, NULL, NULL, &ipg_clk);
553DEFINE_CLOCK(gpt4_clk1, 0, PCCR0, 21, NULL, NULL, &ipg_clk);
554DEFINE_CLOCK(gpt3_clk1, 0, PCCR0, 22, NULL, NULL, &ipg_clk);
555DEFINE_CLOCK(gpt2_clk1, 0, PCCR0, 23, NULL, NULL, &ipg_clk);
556DEFINE_CLOCK(gpt1_clk1, 0, PCCR0, 24, NULL, NULL, &ipg_clk);
557DEFINE_CLOCK(gpio_clk, 0, PCCR0, 25, NULL, NULL, &ipg_clk);
558DEFINE_CLOCK(fec_clk, 0, PCCR0, 26, NULL, &fec_clk1, &ahb_clk);
559DEFINE_CLOCK(emma_clk, 0, PCCR0, 27, NULL, &emma_clk1, &ahb_clk);
560DEFINE_CLOCK(dma_clk, 0, PCCR0, 28, NULL, &dma_clk1, &ahb_clk);
561DEFINE_CLOCK(cspi13_clk1, 0, PCCR0, 29, NULL, NULL, &ipg_clk);
562DEFINE_CLOCK(cspi2_clk1, 0, PCCR0, 30, NULL, NULL, &ipg_clk);
563DEFINE_CLOCK(cspi1_clk1, 0, PCCR0, 31, NULL, NULL, &ipg_clk);
564
565DEFINE_CLOCK(mstick_clk, 0, PCCR1, 2, NULL, &mstick_clk1, &ipg_clk);
566DEFINE_CLOCK(nfc_clk, 0, PCCR1, 3, get_rate_nfc, NULL, &cpu_clk);
567DEFINE_CLOCK(ssi2_clk, 1, PCCR1, 4, get_rate_ssi2, &ssi2_clk1, &mpll_main2_clk);
568DEFINE_CLOCK(ssi1_clk, 0, PCCR1, 5, get_rate_ssi1, &ssi1_clk1, &mpll_main2_clk);
569DEFINE_CLOCK(vpu_clk, 0, PCCR1, 6, get_rate_vpu, &vpu_clk1, &mpll_main2_clk);
570DEFINE_CLOCK1(per4_clk, 3, PCCR1, 7, per, NULL, &mpll_main2_clk);
571DEFINE_CLOCK1(per3_clk, 2, PCCR1, 8, per, NULL, &mpll_main2_clk);
572DEFINE_CLOCK1(per2_clk, 1, PCCR1, 9, per, NULL, &mpll_main2_clk);
573DEFINE_CLOCK1(per1_clk, 0, PCCR1, 10, per, NULL, &mpll_main2_clk);
574DEFINE_CLOCK(usb_clk1, 0, PCCR1, 11, NULL, NULL, &ahb_clk);
575DEFINE_CLOCK(slcdc_clk1, 0, PCCR1, 12, NULL, NULL, &ahb_clk);
576DEFINE_CLOCK(sahara2_clk1, 0, PCCR1, 13, NULL, NULL, &ahb_clk);
577DEFINE_CLOCK(rtic_clk1, 0, PCCR1, 14, NULL, NULL, &ahb_clk);
578DEFINE_CLOCK(lcdc_clk2, 0, PCCR1, 15, NULL, NULL, &ahb_clk);
579DEFINE_CLOCK(vpu_clk1, 0, PCCR1, 16, NULL, NULL, &ahb_clk);
580DEFINE_CLOCK(fec_clk1, 0, PCCR1, 17, NULL, NULL, &ahb_clk);
581DEFINE_CLOCK(emma_clk1, 0, PCCR1, 18, NULL, NULL, &ahb_clk);
582DEFINE_CLOCK(emi_clk, 0, PCCR1, 19, NULL, NULL, &ahb_clk);
583DEFINE_CLOCK(dma_clk1, 0, PCCR1, 20, NULL, NULL, &ahb_clk);
584DEFINE_CLOCK(csi_clk1, 0, PCCR1, 21, NULL, NULL, &ahb_clk);
585DEFINE_CLOCK(brom_clk, 0, PCCR1, 22, NULL, NULL, &ahb_clk);
586DEFINE_CLOCK(ata_clk, 0, PCCR1, 23, NULL, NULL, &ahb_clk);
587DEFINE_CLOCK(wdog_clk, 0, PCCR1, 24, NULL, NULL, &ipg_clk);
588DEFINE_CLOCK(usb_clk, 0, PCCR1, 25, get_rate_usb, &usb_clk1, &spll_clk);
589DEFINE_CLOCK(uart6_clk1, 0, PCCR1, 26, NULL, NULL, &ipg_clk);
590DEFINE_CLOCK(uart5_clk1, 0, PCCR1, 27, NULL, NULL, &ipg_clk);
591DEFINE_CLOCK(uart4_clk1, 0, PCCR1, 28, NULL, NULL, &ipg_clk);
592DEFINE_CLOCK(uart3_clk1, 0, PCCR1, 29, NULL, NULL, &ipg_clk);
593DEFINE_CLOCK(uart2_clk1, 0, PCCR1, 30, NULL, NULL, &ipg_clk);
594DEFINE_CLOCK(uart1_clk1, 0, PCCR1, 31, NULL, NULL, &ipg_clk);
595
596/* Clocks we cannot directly gate, but drivers need their rates */
597DEFINE_CLOCK(cspi1_clk, 0, 0, 0, NULL, &cspi1_clk1, &per2_clk);
598DEFINE_CLOCK(cspi2_clk, 1, 0, 0, NULL, &cspi2_clk1, &per2_clk);
599DEFINE_CLOCK(cspi3_clk, 2, 0, 0, NULL, &cspi13_clk1, &per2_clk);
600DEFINE_CLOCK(sdhc1_clk, 0, 0, 0, NULL, &sdhc1_clk1, &per2_clk);
601DEFINE_CLOCK(sdhc2_clk, 1, 0, 0, NULL, &sdhc2_clk1, &per2_clk);
602DEFINE_CLOCK(sdhc3_clk, 2, 0, 0, NULL, &sdhc3_clk1, &per2_clk);
603DEFINE_CLOCK(pwm_clk, 0, 0, 0, NULL, &pwm_clk1, &per1_clk);
604DEFINE_CLOCK(gpt1_clk, 0, 0, 0, NULL, &gpt1_clk1, &per1_clk);
605DEFINE_CLOCK(gpt2_clk, 1, 0, 0, NULL, &gpt2_clk1, &per1_clk);
606DEFINE_CLOCK(gpt3_clk, 2, 0, 0, NULL, &gpt3_clk1, &per1_clk);
607DEFINE_CLOCK(gpt4_clk, 3, 0, 0, NULL, &gpt4_clk1, &per1_clk);
608DEFINE_CLOCK(gpt5_clk, 4, 0, 0, NULL, &gpt5_clk1, &per1_clk);
609DEFINE_CLOCK(gpt6_clk, 5, 0, 0, NULL, &gpt6_clk1, &per1_clk);
610DEFINE_CLOCK(uart1_clk, 0, 0, 0, NULL, &uart1_clk1, &per1_clk);
611DEFINE_CLOCK(uart2_clk, 1, 0, 0, NULL, &uart2_clk1, &per1_clk);
612DEFINE_CLOCK(uart3_clk, 2, 0, 0, NULL, &uart3_clk1, &per1_clk);
613DEFINE_CLOCK(uart4_clk, 3, 0, 0, NULL, &uart4_clk1, &per1_clk);
614DEFINE_CLOCK(uart5_clk, 4, 0, 0, NULL, &uart5_clk1, &per1_clk);
615DEFINE_CLOCK(uart6_clk, 5, 0, 0, NULL, &uart6_clk1, &per1_clk);
616DEFINE_CLOCK1(lcdc_clk, 0, 0, 0, parent, &lcdc_clk1, &per3_clk);
617DEFINE_CLOCK1(csi_clk, 0, 0, 0, parent, &csi_clk1, &per4_clk);
618
619#define _REGISTER_CLOCK(d, n, c) \
620 { \
621 .dev_id = d, \
622 .con_id = n, \
623 .clk = &c, \
Juergen Beisertc46f5852008-07-05 10:02:59 +0200624 },
Sascha Haueredfcea82009-02-16 15:13:43 +0100625
Rabin Vincent6b4bfb82009-05-26 22:31:46 +0530626static struct clk_lookup lookups[] = {
Sascha Haueredfcea82009-02-16 15:13:43 +0100627 _REGISTER_CLOCK("imx-uart.0", NULL, uart1_clk)
628 _REGISTER_CLOCK("imx-uart.1", NULL, uart2_clk)
629 _REGISTER_CLOCK("imx-uart.2", NULL, uart3_clk)
630 _REGISTER_CLOCK("imx-uart.3", NULL, uart4_clk)
631 _REGISTER_CLOCK("imx-uart.4", NULL, uart5_clk)
632 _REGISTER_CLOCK("imx-uart.5", NULL, uart6_clk)
633 _REGISTER_CLOCK(NULL, "gpt1", gpt1_clk)
634 _REGISTER_CLOCK(NULL, "gpt2", gpt2_clk)
635 _REGISTER_CLOCK(NULL, "gpt3", gpt3_clk)
636 _REGISTER_CLOCK(NULL, "gpt4", gpt4_clk)
637 _REGISTER_CLOCK(NULL, "gpt5", gpt5_clk)
638 _REGISTER_CLOCK(NULL, "gpt6", gpt6_clk)
639 _REGISTER_CLOCK("mxc_pwm.0", NULL, pwm_clk)
640 _REGISTER_CLOCK("mxc-mmc.0", NULL, sdhc1_clk)
641 _REGISTER_CLOCK("mxc-mmc.1", NULL, sdhc2_clk)
642 _REGISTER_CLOCK("mxc-mmc.2", NULL, sdhc3_clk)
Sascha Hauer5cf3bcd2009-09-24 09:58:52 +0200643 _REGISTER_CLOCK("spi_imx.0", NULL, cspi1_clk)
644 _REGISTER_CLOCK("spi_imx.1", NULL, cspi2_clk)
645 _REGISTER_CLOCK("spi_imx.2", NULL, cspi3_clk)
Sascha Haueredfcea82009-02-16 15:13:43 +0100646 _REGISTER_CLOCK("imx-fb.0", NULL, lcdc_clk)
Baruch Siach94d35952010-06-21 08:15:59 +0300647 _REGISTER_CLOCK("mx2-camera.0", NULL, csi_clk)
javier Martin627fb3b2009-07-15 15:26:21 +0200648 _REGISTER_CLOCK("fsl-usb2-udc", "usb", usb_clk)
649 _REGISTER_CLOCK("fsl-usb2-udc", "usb_ahb", usb_clk1)
650 _REGISTER_CLOCK("mxc-ehci.0", "usb", usb_clk)
651 _REGISTER_CLOCK("mxc-ehci.0", "usb_ahb", usb_clk1)
652 _REGISTER_CLOCK("mxc-ehci.1", "usb", usb_clk)
653 _REGISTER_CLOCK("mxc-ehci.1", "usb_ahb", usb_clk1)
654 _REGISTER_CLOCK("mxc-ehci.2", "usb", usb_clk)
655 _REGISTER_CLOCK("mxc-ehci.2", "usb_ahb", usb_clk1)
Sascha Hauer23291df2009-10-22 14:50:33 +0200656 _REGISTER_CLOCK("imx-ssi.0", NULL, ssi1_clk)
657 _REGISTER_CLOCK("imx-ssi.1", NULL, ssi2_clk)
Sascha Haueredfcea82009-02-16 15:13:43 +0100658 _REGISTER_CLOCK("mxc_nand.0", NULL, nfc_clk)
659 _REGISTER_CLOCK(NULL, "vpu", vpu_clk)
660 _REGISTER_CLOCK(NULL, "dma", dma_clk)
661 _REGISTER_CLOCK(NULL, "rtic", rtic_clk)
662 _REGISTER_CLOCK(NULL, "brom", brom_clk)
663 _REGISTER_CLOCK(NULL, "emma", emma_clk)
664 _REGISTER_CLOCK(NULL, "slcdc", slcdc_clk)
665 _REGISTER_CLOCK("fec.0", NULL, fec_clk)
666 _REGISTER_CLOCK(NULL, "emi", emi_clk)
667 _REGISTER_CLOCK(NULL, "sahara2", sahara2_clk)
668 _REGISTER_CLOCK(NULL, "ata", ata_clk)
669 _REGISTER_CLOCK(NULL, "mstick", mstick_clk)
Valentin Longchamp679bfef2009-10-08 18:12:24 +0200670 _REGISTER_CLOCK("imx-wdt.0", NULL, wdog_clk)
Sascha Haueredfcea82009-02-16 15:13:43 +0100671 _REGISTER_CLOCK(NULL, "gpio", gpio_clk)
672 _REGISTER_CLOCK("imx-i2c.0", NULL, i2c1_clk)
673 _REGISTER_CLOCK("imx-i2c.1", NULL, i2c2_clk)
674 _REGISTER_CLOCK(NULL, "iim", iim_clk)
675 _REGISTER_CLOCK(NULL, "kpp", kpp_clk)
676 _REGISTER_CLOCK("mxc_w1.0", NULL, owire_clk)
677 _REGISTER_CLOCK(NULL, "rtc", rtc_clk)
678 _REGISTER_CLOCK(NULL, "scc", scc_clk)
Juergen Beisertc46f5852008-07-05 10:02:59 +0200679};
680
Sascha Haueredfcea82009-02-16 15:13:43 +0100681/* Adjust the clock path for TO2 and later */
682static void __init to2_adjust_clocks(void)
Juergen Beisertc46f5852008-07-05 10:02:59 +0200683{
Sascha Haueredfcea82009-02-16 15:13:43 +0100684 unsigned long cscr = __raw_readl(CCM_CSCR);
Juergen Beisertc46f5852008-07-05 10:02:59 +0200685
686 if (mx27_revision() >= CHIP_REV_2_0) {
Sascha Haueredfcea82009-02-16 15:13:43 +0100687 if (cscr & CCM_CSCR_ARM_SRC)
688 cpu_clk.parent = &mpll_main1_clk;
Juergen Beisertc46f5852008-07-05 10:02:59 +0200689
Sascha Haueredfcea82009-02-16 15:13:43 +0100690 if (!(cscr & CCM_CSCR_SSI2))
691 ssi1_clk.parent = &spll_clk;
Juergen Beisertc46f5852008-07-05 10:02:59 +0200692
Sascha Haueredfcea82009-02-16 15:13:43 +0100693 if (!(cscr & CCM_CSCR_SSI1))
694 ssi1_clk.parent = &spll_clk;
Juergen Beisertc46f5852008-07-05 10:02:59 +0200695
Sascha Haueredfcea82009-02-16 15:13:43 +0100696 if (!(cscr & CCM_CSCR_VPU))
Juergen Beisertc46f5852008-07-05 10:02:59 +0200697 vpu_clk.parent = &spll_clk;
698 } else {
699 cpu_clk.parent = &mpll_clk;
700 cpu_clk.set_parent = NULL;
701 cpu_clk.round_rate = NULL;
702 cpu_clk.set_rate = NULL;
703 ahb_clk.parent = &mpll_clk;
704
Sascha Haueredfcea82009-02-16 15:13:43 +0100705 per1_clk.parent = &mpll_clk;
706 per2_clk.parent = &mpll_clk;
707 per3_clk.parent = &mpll_clk;
708 per4_clk.parent = &mpll_clk;
Juergen Beisertc46f5852008-07-05 10:02:59 +0200709
Sascha Haueredfcea82009-02-16 15:13:43 +0100710 ssi1_clk.parent = &mpll_clk;
711 ssi2_clk.parent = &mpll_clk;
Juergen Beisertc46f5852008-07-05 10:02:59 +0200712
713 vpu_clk.parent = &mpll_clk;
714 }
715}
716
717/*
718 * must be called very early to get information about the
719 * available clock rate when the timer framework starts
720 */
Sascha Hauer30c730f2009-02-16 14:36:49 +0100721int __init mx27_clocks_init(unsigned long fref)
Juergen Beisertc46f5852008-07-05 10:02:59 +0200722{
Sascha Haueredfcea82009-02-16 15:13:43 +0100723 u32 cscr = __raw_readl(CCM_CSCR);
Juergen Beisertc46f5852008-07-05 10:02:59 +0200724
725 external_high_reference = fref;
726
Sascha Haueredfcea82009-02-16 15:13:43 +0100727 /* detect clock reference for both system PLLs */
Juergen Beisertc46f5852008-07-05 10:02:59 +0200728 if (cscr & CCM_CSCR_MCU)
729 mpll_clk.parent = &ckih_clk;
730 else
Sascha Haueredfcea82009-02-16 15:13:43 +0100731 mpll_clk.parent = &fpm_clk;
Juergen Beisertc46f5852008-07-05 10:02:59 +0200732
733 if (cscr & CCM_CSCR_SP)
734 spll_clk.parent = &ckih_clk;
735 else
Sascha Haueredfcea82009-02-16 15:13:43 +0100736 spll_clk.parent = &fpm_clk;
Juergen Beisertc46f5852008-07-05 10:02:59 +0200737
Sascha Haueredfcea82009-02-16 15:13:43 +0100738 to2_adjust_clocks();
Juergen Beisertc46f5852008-07-05 10:02:59 +0200739
Russell King0a0300d2010-01-12 12:28:00 +0000740 clkdev_add_table(lookups, ARRAY_SIZE(lookups));
Juergen Beisertc46f5852008-07-05 10:02:59 +0200741
Sascha Haueredfcea82009-02-16 15:13:43 +0100742 /* Turn off all clocks we do not need */
743 __raw_writel(0, CCM_PCCR0);
744 __raw_writel((1 << 10) | (1 << 19), CCM_PCCR1);
Juergen Beisertc46f5852008-07-05 10:02:59 +0200745
Juergen Beisertc46f5852008-07-05 10:02:59 +0200746 spll_clk.disable(&spll_clk);
747
Sascha Haueredfcea82009-02-16 15:13:43 +0100748 /* enable basic clocks */
749 clk_enable(&per1_clk);
Juergen Beisertc46f5852008-07-05 10:02:59 +0200750 clk_enable(&gpio_clk);
Sascha Haueredfcea82009-02-16 15:13:43 +0100751 clk_enable(&emi_clk);
Juergen Beisertc46f5852008-07-05 10:02:59 +0200752 clk_enable(&iim_clk);
Sascha Haueredfcea82009-02-16 15:13:43 +0100753
Uwe Kleine-König97adeda2009-11-12 22:56:29 +0100754#if defined(CONFIG_DEBUG_LL) && !defined(CONFIG_DEBUG_ICEDCC)
Sascha Haueredfcea82009-02-16 15:13:43 +0100755 clk_enable(&uart1_clk);
Juergen Beisertc46f5852008-07-05 10:02:59 +0200756#endif
Sascha Hauer30c730f2009-02-16 14:36:49 +0100757
Uwe Kleine-Königbc9ea6c2009-12-16 17:30:27 +0100758 mxc_timer_init(&gpt1_clk, MX27_IO_ADDRESS(MX27_GPT1_BASE_ADDR),
Uwe Kleine-König3f35d1f2009-12-09 11:32:11 +0100759 MX27_INT_GPT1);
Sascha Hauer30c730f2009-02-16 14:36:49 +0100760
Juergen Beisertc46f5852008-07-05 10:02:59 +0200761 return 0;
762}
Sascha Haueredfcea82009-02-16 15:13:43 +0100763