diff options
author | Holger Schurig <hs4233@mail.mn-solutions.de> | 2009-01-26 10:34:54 -0500 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2009-03-13 05:33:54 -0400 |
commit | aa3b0a6f57be50f1009a409e82731a8f9be80fc4 (patch) | |
tree | fc56f2b0f1448b73e6bc5a19d0cdff5a235a1711 /arch/arm/mach-mx2 | |
parent | 260a1fd26c62af482a22c6b31cc7882b4ec980d2 (diff) |
arm/imx21: clock support for i.MX21
Based on code from "Martin Fuzzey" <mfuzzey@gmail.com>
Signed-off-by: Holger Schurig <hs4233@mail.mn-solutions.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/arm/mach-mx2')
-rw-r--r-- | arch/arm/mach-mx2/Makefile | 2 | ||||
-rw-r--r-- | arch/arm/mach-mx2/clock_imx21.c | 984 | ||||
-rw-r--r-- | arch/arm/mach-mx2/crm_regs.h | 258 |
3 files changed, 1244 insertions, 0 deletions
diff --git a/arch/arm/mach-mx2/Makefile b/arch/arm/mach-mx2/Makefile index 382d86080e86..6e1a2bffc812 100644 --- a/arch/arm/mach-mx2/Makefile +++ b/arch/arm/mach-mx2/Makefile | |||
@@ -6,6 +6,8 @@ | |||
6 | 6 | ||
7 | obj-y := system.o generic.o devices.o serial.o | 7 | obj-y := system.o generic.o devices.o serial.o |
8 | 8 | ||
9 | obj-$(CONFIG_MACH_MX21) += clock_imx21.o | ||
10 | |||
9 | obj-$(CONFIG_MACH_MX27) += cpu_imx27.o | 11 | obj-$(CONFIG_MACH_MX27) += cpu_imx27.o |
10 | obj-$(CONFIG_MACH_MX27) += clock_imx27.o | 12 | obj-$(CONFIG_MACH_MX27) += clock_imx27.o |
11 | 13 | ||
diff --git a/arch/arm/mach-mx2/clock_imx21.c b/arch/arm/mach-mx2/clock_imx21.c new file mode 100644 index 000000000000..2dee5c87614c --- /dev/null +++ b/arch/arm/mach-mx2/clock_imx21.c | |||
@@ -0,0 +1,984 @@ | |||
1 | /* | ||
2 | * Copyright 2004-2007 Freescale Semiconductor, Inc. All Rights Reserved. | ||
3 | * Copyright 2008 Juergen Beisert, kernel@pengutronix.de | ||
4 | * Copyright 2008 Martin Fuzzey, mfuzzey@gmail.com | ||
5 | * | ||
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> | ||
24 | |||
25 | #include <mach/clock.h> | ||
26 | #include <mach/common.h> | ||
27 | #include <asm/clkdev.h> | ||
28 | #include <asm/div64.h> | ||
29 | |||
30 | #include "crm_regs.h" | ||
31 | |||
32 | static int _clk_enable(struct clk *clk) | ||
33 | { | ||
34 | u32 reg; | ||
35 | |||
36 | reg = __raw_readl(clk->enable_reg); | ||
37 | reg |= 1 << clk->enable_shift; | ||
38 | __raw_writel(reg, clk->enable_reg); | ||
39 | return 0; | ||
40 | } | ||
41 | |||
42 | static void _clk_disable(struct clk *clk) | ||
43 | { | ||
44 | u32 reg; | ||
45 | |||
46 | reg = __raw_readl(clk->enable_reg); | ||
47 | reg &= ~(1 << clk->enable_shift); | ||
48 | __raw_writel(reg, clk->enable_reg); | ||
49 | } | ||
50 | |||
51 | static int _clk_spll_enable(struct clk *clk) | ||
52 | { | ||
53 | u32 reg; | ||
54 | |||
55 | reg = __raw_readl(CCM_CSCR); | ||
56 | reg |= CCM_CSCR_SPEN; | ||
57 | __raw_writel(reg, CCM_CSCR); | ||
58 | |||
59 | while ((__raw_readl(CCM_SPCTL1) & CCM_SPCTL1_LF) == 0) | ||
60 | ; | ||
61 | return 0; | ||
62 | } | ||
63 | |||
64 | static void _clk_spll_disable(struct clk *clk) | ||
65 | { | ||
66 | u32 reg; | ||
67 | |||
68 | reg = __raw_readl(CCM_CSCR); | ||
69 | reg &= ~CCM_CSCR_SPEN; | ||
70 | __raw_writel(reg, CCM_CSCR); | ||
71 | } | ||
72 | |||
73 | |||
74 | #define CSCR() (__raw_readl(CCM_CSCR)) | ||
75 | #define PCDR0() (__raw_readl(CCM_PCDR0)) | ||
76 | #define PCDR1() (__raw_readl(CCM_PCDR1)) | ||
77 | |||
78 | static unsigned long _clk_perclkx_round_rate(struct clk *clk, | ||
79 | unsigned long rate) | ||
80 | { | ||
81 | u32 div; | ||
82 | unsigned long parent_rate; | ||
83 | |||
84 | parent_rate = clk_get_rate(clk->parent); | ||
85 | |||
86 | div = parent_rate / rate; | ||
87 | if (parent_rate % rate) | ||
88 | div++; | ||
89 | |||
90 | if (div > 64) | ||
91 | div = 64; | ||
92 | |||
93 | return parent_rate / div; | ||
94 | } | ||
95 | |||
96 | static int _clk_perclkx_set_rate(struct clk *clk, unsigned long rate) | ||
97 | { | ||
98 | u32 reg; | ||
99 | u32 div; | ||
100 | unsigned long parent_rate; | ||
101 | |||
102 | parent_rate = clk_get_rate(clk->parent); | ||
103 | |||
104 | if (clk->id < 0 || clk->id > 3) | ||
105 | return -EINVAL; | ||
106 | |||
107 | div = parent_rate / rate; | ||
108 | if (div > 64 || div < 1 || ((parent_rate / div) != rate)) | ||
109 | return -EINVAL; | ||
110 | div--; | ||
111 | |||
112 | reg = | ||
113 | __raw_readl(CCM_PCDR1) & ~(CCM_PCDR1_PERDIV1_MASK << | ||
114 | (clk->id << 3)); | ||
115 | reg |= div << (clk->id << 3); | ||
116 | __raw_writel(reg, CCM_PCDR1); | ||
117 | |||
118 | return 0; | ||
119 | } | ||
120 | |||
121 | static unsigned long _clk_usb_recalc(struct clk *clk) | ||
122 | { | ||
123 | unsigned long usb_pdf; | ||
124 | unsigned long parent_rate; | ||
125 | |||
126 | parent_rate = clk_get_rate(clk->parent); | ||
127 | |||
128 | usb_pdf = (CSCR() & CCM_CSCR_USB_MASK) >> CCM_CSCR_USB_OFFSET; | ||
129 | |||
130 | return parent_rate / (usb_pdf + 1U); | ||
131 | } | ||
132 | |||
133 | static unsigned long _clk_ssix_recalc(struct clk *clk, unsigned long pdf) | ||
134 | { | ||
135 | unsigned long parent_rate; | ||
136 | |||
137 | parent_rate = clk_get_rate(clk->parent); | ||
138 | |||
139 | pdf = (pdf < 2) ? 124UL : pdf; /* MX21 & MX27 TO1 */ | ||
140 | |||
141 | return 2UL * parent_rate / pdf; | ||
142 | } | ||
143 | |||
144 | static unsigned long _clk_ssi1_recalc(struct clk *clk) | ||
145 | { | ||
146 | return _clk_ssix_recalc(clk, | ||
147 | (PCDR0() & CCM_PCDR0_SSI1BAUDDIV_MASK) | ||
148 | >> CCM_PCDR0_SSI1BAUDDIV_OFFSET); | ||
149 | } | ||
150 | |||
151 | static unsigned long _clk_ssi2_recalc(struct clk *clk) | ||
152 | { | ||
153 | return _clk_ssix_recalc(clk, | ||
154 | (PCDR0() & CCM_PCDR0_SSI2BAUDDIV_MASK) >> | ||
155 | CCM_PCDR0_SSI2BAUDDIV_OFFSET); | ||
156 | } | ||
157 | |||
158 | static unsigned long _clk_nfc_recalc(struct clk *clk) | ||
159 | { | ||
160 | unsigned long nfc_pdf; | ||
161 | unsigned long parent_rate; | ||
162 | |||
163 | parent_rate = clk_get_rate(clk->parent); | ||
164 | |||
165 | nfc_pdf = (PCDR0() & CCM_PCDR0_NFCDIV_MASK) | ||
166 | >> CCM_PCDR0_NFCDIV_OFFSET; | ||
167 | |||
168 | return parent_rate / (nfc_pdf + 1); | ||
169 | } | ||
170 | |||
171 | static unsigned long _clk_parent_round_rate(struct clk *clk, unsigned long rate) | ||
172 | { | ||
173 | return clk->parent->round_rate(clk->parent, rate); | ||
174 | } | ||
175 | |||
176 | static int _clk_parent_set_rate(struct clk *clk, unsigned long rate) | ||
177 | { | ||
178 | return clk->parent->set_rate(clk->parent, rate); | ||
179 | } | ||
180 | |||
181 | static unsigned long external_high_reference; /* in Hz */ | ||
182 | |||
183 | static unsigned long get_high_reference_clock_rate(struct clk *clk) | ||
184 | { | ||
185 | return external_high_reference; | ||
186 | } | ||
187 | |||
188 | /* | ||
189 | * the high frequency external clock reference | ||
190 | * Default case is 26MHz. | ||
191 | */ | ||
192 | static struct clk ckih_clk = { | ||
193 | .get_rate = get_high_reference_clock_rate, | ||
194 | }; | ||
195 | |||
196 | static unsigned long external_low_reference; /* in Hz */ | ||
197 | |||
198 | static unsigned long get_low_reference_clock_rate(struct clk *clk) | ||
199 | { | ||
200 | return external_low_reference; | ||
201 | } | ||
202 | |||
203 | /* | ||
204 | * the low frequency external clock reference | ||
205 | * Default case is 32.768kHz. | ||
206 | */ | ||
207 | static struct clk ckil_clk = { | ||
208 | .get_rate = get_low_reference_clock_rate, | ||
209 | }; | ||
210 | |||
211 | |||
212 | static unsigned long _clk_fpm_recalc(struct clk *clk) | ||
213 | { | ||
214 | return clk_get_rate(clk->parent) * 512; | ||
215 | } | ||
216 | |||
217 | /* Output of frequency pre multiplier */ | ||
218 | static struct clk fpm_clk = { | ||
219 | .parent = &ckil_clk, | ||
220 | .get_rate = _clk_fpm_recalc, | ||
221 | }; | ||
222 | |||
223 | static unsigned long get_mpll_clk(struct clk *clk) | ||
224 | { | ||
225 | uint32_t reg; | ||
226 | unsigned long ref_clk; | ||
227 | unsigned long mfi = 0, mfn = 0, mfd = 0, pdf = 0; | ||
228 | unsigned long long temp; | ||
229 | |||
230 | ref_clk = clk_get_rate(clk->parent); | ||
231 | |||
232 | reg = __raw_readl(CCM_MPCTL0); | ||
233 | pdf = (reg & CCM_MPCTL0_PD_MASK) >> CCM_MPCTL0_PD_OFFSET; | ||
234 | mfd = (reg & CCM_MPCTL0_MFD_MASK) >> CCM_MPCTL0_MFD_OFFSET; | ||
235 | mfi = (reg & CCM_MPCTL0_MFI_MASK) >> CCM_MPCTL0_MFI_OFFSET; | ||
236 | mfn = (reg & CCM_MPCTL0_MFN_MASK) >> CCM_MPCTL0_MFN_OFFSET; | ||
237 | |||
238 | mfi = (mfi <= 5) ? 5 : mfi; | ||
239 | temp = 2LL * ref_clk * mfn; | ||
240 | do_div(temp, mfd + 1); | ||
241 | temp = 2LL * ref_clk * mfi + temp; | ||
242 | do_div(temp, pdf + 1); | ||
243 | |||
244 | return (unsigned long)temp; | ||
245 | } | ||
246 | |||
247 | static struct clk mpll_clk = { | ||
248 | .parent = &ckih_clk, | ||
249 | .get_rate = get_mpll_clk, | ||
250 | }; | ||
251 | |||
252 | static unsigned long _clk_fclk_get_rate(struct clk *clk) | ||
253 | { | ||
254 | unsigned long parent_rate; | ||
255 | u32 div; | ||
256 | |||
257 | div = (CSCR() & CCM_CSCR_PRESC_MASK) >> CCM_CSCR_PRESC_OFFSET; | ||
258 | parent_rate = clk_get_rate(clk->parent); | ||
259 | |||
260 | return parent_rate / (div+1); | ||
261 | } | ||
262 | |||
263 | static struct clk fclk_clk = { | ||
264 | .parent = &mpll_clk, | ||
265 | .get_rate = _clk_fclk_get_rate | ||
266 | }; | ||
267 | |||
268 | static unsigned long get_spll_clk(struct clk *clk) | ||
269 | { | ||
270 | uint32_t reg; | ||
271 | unsigned long ref_clk; | ||
272 | unsigned long mfi = 0, mfn = 0, mfd = 0, pdf = 0; | ||
273 | unsigned long long temp; | ||
274 | |||
275 | ref_clk = clk_get_rate(clk->parent); | ||
276 | |||
277 | reg = __raw_readl(CCM_SPCTL0); | ||
278 | pdf = (reg & CCM_SPCTL0_PD_MASK) >> CCM_SPCTL0_PD_OFFSET; | ||
279 | mfd = (reg & CCM_SPCTL0_MFD_MASK) >> CCM_SPCTL0_MFD_OFFSET; | ||
280 | mfi = (reg & CCM_SPCTL0_MFI_MASK) >> CCM_SPCTL0_MFI_OFFSET; | ||
281 | mfn = (reg & CCM_SPCTL0_MFN_MASK) >> CCM_SPCTL0_MFN_OFFSET; | ||
282 | |||
283 | mfi = (mfi <= 5) ? 5 : mfi; | ||
284 | temp = 2LL * ref_clk * mfn; | ||
285 | do_div(temp, mfd + 1); | ||
286 | temp = 2LL * ref_clk * mfi + temp; | ||
287 | do_div(temp, pdf + 1); | ||
288 | |||
289 | return (unsigned long)temp; | ||
290 | } | ||
291 | |||
292 | static struct clk spll_clk = { | ||
293 | .parent = &ckih_clk, | ||
294 | .get_rate = get_spll_clk, | ||
295 | .enable = _clk_spll_enable, | ||
296 | .disable = _clk_spll_disable, | ||
297 | }; | ||
298 | |||
299 | static unsigned long get_hclk_clk(struct clk *clk) | ||
300 | { | ||
301 | unsigned long rate; | ||
302 | unsigned long bclk_pdf; | ||
303 | |||
304 | bclk_pdf = (CSCR() & CCM_CSCR_BCLK_MASK) | ||
305 | >> CCM_CSCR_BCLK_OFFSET; | ||
306 | |||
307 | rate = clk_get_rate(clk->parent); | ||
308 | return rate / (bclk_pdf + 1); | ||
309 | } | ||
310 | |||
311 | static struct clk hclk_clk = { | ||
312 | .parent = &fclk_clk, | ||
313 | .get_rate = get_hclk_clk, | ||
314 | }; | ||
315 | |||
316 | static unsigned long get_ipg_clk(struct clk *clk) | ||
317 | { | ||
318 | unsigned long rate; | ||
319 | unsigned long ipg_pdf; | ||
320 | |||
321 | ipg_pdf = (CSCR() & CCM_CSCR_IPDIV) >> CCM_CSCR_IPDIV_OFFSET; | ||
322 | |||
323 | rate = clk_get_rate(clk->parent); | ||
324 | return rate / (ipg_pdf + 1); | ||
325 | } | ||
326 | |||
327 | static struct clk ipg_clk = { | ||
328 | .parent = &hclk_clk, | ||
329 | .get_rate = get_ipg_clk, | ||
330 | }; | ||
331 | |||
332 | static unsigned long _clk_perclkx_recalc(struct clk *clk) | ||
333 | { | ||
334 | unsigned long perclk_pdf; | ||
335 | unsigned long parent_rate; | ||
336 | |||
337 | parent_rate = clk_get_rate(clk->parent); | ||
338 | |||
339 | if (clk->id < 0 || clk->id > 3) | ||
340 | return 0; | ||
341 | |||
342 | perclk_pdf = (PCDR1() >> (clk->id << 3)) & CCM_PCDR1_PERDIV1_MASK; | ||
343 | |||
344 | return parent_rate / (perclk_pdf + 1); | ||
345 | } | ||
346 | |||
347 | static struct clk per_clk[] = { | ||
348 | { | ||
349 | .id = 0, | ||
350 | .parent = &mpll_clk, | ||
351 | .get_rate = _clk_perclkx_recalc, | ||
352 | }, { | ||
353 | .id = 1, | ||
354 | .parent = &mpll_clk, | ||
355 | .get_rate = _clk_perclkx_recalc, | ||
356 | }, { | ||
357 | .id = 2, | ||
358 | .parent = &mpll_clk, | ||
359 | .round_rate = _clk_perclkx_round_rate, | ||
360 | .set_rate = _clk_perclkx_set_rate, | ||
361 | .get_rate = _clk_perclkx_recalc, | ||
362 | /* Enable/Disable done via lcd_clkc[1] */ | ||
363 | }, { | ||
364 | .id = 3, | ||
365 | .parent = &mpll_clk, | ||
366 | .round_rate = _clk_perclkx_round_rate, | ||
367 | .set_rate = _clk_perclkx_set_rate, | ||
368 | .get_rate = _clk_perclkx_recalc, | ||
369 | /* Enable/Disable done via csi_clk[1] */ | ||
370 | }, | ||
371 | }; | ||
372 | |||
373 | static struct clk uart_ipg_clk[]; | ||
374 | |||
375 | static struct clk uart_clk[] = { | ||
376 | { | ||
377 | .id = 0, | ||
378 | .parent = &per_clk[0], | ||
379 | .secondary = &uart_ipg_clk[0], | ||
380 | }, { | ||
381 | .id = 1, | ||
382 | .parent = &per_clk[0], | ||
383 | .secondary = &uart_ipg_clk[1], | ||
384 | }, { | ||
385 | .id = 2, | ||
386 | .parent = &per_clk[0], | ||
387 | .secondary = &uart_ipg_clk[2], | ||
388 | }, { | ||
389 | .id = 3, | ||
390 | .parent = &per_clk[0], | ||
391 | .secondary = &uart_ipg_clk[3], | ||
392 | }, | ||
393 | }; | ||
394 | |||
395 | static struct clk uart_ipg_clk[] = { | ||
396 | { | ||
397 | .id = 0, | ||
398 | .parent = &ipg_clk, | ||
399 | .enable = _clk_enable, | ||
400 | .enable_reg = CCM_PCCR_UART1_REG, | ||
401 | .enable_shift = CCM_PCCR_UART1_OFFSET, | ||
402 | .disable = _clk_disable, | ||
403 | }, { | ||
404 | .id = 1, | ||
405 | .parent = &ipg_clk, | ||
406 | .enable = _clk_enable, | ||
407 | .enable_reg = CCM_PCCR_UART2_REG, | ||
408 | .enable_shift = CCM_PCCR_UART2_OFFSET, | ||
409 | .disable = _clk_disable, | ||
410 | }, { | ||
411 | .id = 2, | ||
412 | .parent = &ipg_clk, | ||
413 | .enable = _clk_enable, | ||
414 | .enable_reg = CCM_PCCR_UART3_REG, | ||
415 | .enable_shift = CCM_PCCR_UART3_OFFSET, | ||
416 | .disable = _clk_disable, | ||
417 | }, { | ||
418 | .id = 3, | ||
419 | .parent = &ipg_clk, | ||
420 | .enable = _clk_enable, | ||
421 | .enable_reg = CCM_PCCR_UART4_REG, | ||
422 | .enable_shift = CCM_PCCR_UART4_OFFSET, | ||
423 | .disable = _clk_disable, | ||
424 | }, | ||
425 | }; | ||
426 | |||
427 | static struct clk gpt_ipg_clk[]; | ||
428 | |||
429 | static struct clk gpt_clk[] = { | ||
430 | { | ||
431 | .id = 0, | ||
432 | .parent = &per_clk[0], | ||
433 | .secondary = &gpt_ipg_clk[0], | ||
434 | }, { | ||
435 | .id = 1, | ||
436 | .parent = &per_clk[0], | ||
437 | .secondary = &gpt_ipg_clk[1], | ||
438 | }, { | ||
439 | .id = 2, | ||
440 | .parent = &per_clk[0], | ||
441 | .secondary = &gpt_ipg_clk[2], | ||
442 | }, | ||
443 | }; | ||
444 | |||
445 | static struct clk gpt_ipg_clk[] = { | ||
446 | { | ||
447 | .id = 0, | ||
448 | .parent = &ipg_clk, | ||
449 | .enable = _clk_enable, | ||
450 | .enable_reg = CCM_PCCR_GPT1_REG, | ||
451 | .enable_shift = CCM_PCCR_GPT1_OFFSET, | ||
452 | .disable = _clk_disable, | ||
453 | }, { | ||
454 | .id = 1, | ||
455 | .parent = &ipg_clk, | ||
456 | .enable = _clk_enable, | ||
457 | .enable_reg = CCM_PCCR_GPT2_REG, | ||
458 | .enable_shift = CCM_PCCR_GPT2_OFFSET, | ||
459 | .disable = _clk_disable, | ||
460 | }, { | ||
461 | .id = 2, | ||
462 | .parent = &ipg_clk, | ||
463 | .enable = _clk_enable, | ||
464 | .enable_reg = CCM_PCCR_GPT3_REG, | ||
465 | .enable_shift = CCM_PCCR_GPT3_OFFSET, | ||
466 | .disable = _clk_disable, | ||
467 | }, | ||
468 | }; | ||
469 | |||
470 | static struct clk pwm_clk[] = { | ||
471 | { | ||
472 | .parent = &per_clk[0], | ||
473 | .secondary = &pwm_clk[1], | ||
474 | }, { | ||
475 | .parent = &ipg_clk, | ||
476 | .enable = _clk_enable, | ||
477 | .enable_reg = CCM_PCCR_PWM_REG, | ||
478 | .enable_shift = CCM_PCCR_PWM_OFFSET, | ||
479 | .disable = _clk_disable, | ||
480 | }, | ||
481 | }; | ||
482 | |||
483 | static struct clk sdhc_ipg_clk[]; | ||
484 | |||
485 | static struct clk sdhc_clk[] = { | ||
486 | { | ||
487 | .id = 0, | ||
488 | .parent = &per_clk[1], | ||
489 | .secondary = &sdhc_ipg_clk[0], | ||
490 | }, { | ||
491 | .id = 1, | ||
492 | .parent = &per_clk[1], | ||
493 | .secondary = &sdhc_ipg_clk[1], | ||
494 | }, | ||
495 | }; | ||
496 | |||
497 | static struct clk sdhc_ipg_clk[] = { | ||
498 | { | ||
499 | .id = 0, | ||
500 | .parent = &ipg_clk, | ||
501 | .enable = _clk_enable, | ||
502 | .enable_reg = CCM_PCCR_SDHC1_REG, | ||
503 | .enable_shift = CCM_PCCR_SDHC1_OFFSET, | ||
504 | .disable = _clk_disable, | ||
505 | }, { | ||
506 | .id = 1, | ||
507 | .parent = &ipg_clk, | ||
508 | .enable = _clk_enable, | ||
509 | .enable_reg = CCM_PCCR_SDHC2_REG, | ||
510 | .enable_shift = CCM_PCCR_SDHC2_OFFSET, | ||
511 | .disable = _clk_disable, | ||
512 | }, | ||
513 | }; | ||
514 | |||
515 | static struct clk cspi_ipg_clk[]; | ||
516 | |||
517 | static struct clk cspi_clk[] = { | ||
518 | { | ||
519 | .id = 0, | ||
520 | .parent = &per_clk[1], | ||
521 | .secondary = &cspi_ipg_clk[0], | ||
522 | }, { | ||
523 | .id = 1, | ||
524 | .parent = &per_clk[1], | ||
525 | .secondary = &cspi_ipg_clk[1], | ||
526 | }, { | ||
527 | .id = 2, | ||
528 | .parent = &per_clk[1], | ||
529 | .secondary = &cspi_ipg_clk[2], | ||
530 | }, | ||
531 | }; | ||
532 | |||
533 | static struct clk cspi_ipg_clk[] = { | ||
534 | { | ||
535 | .id = 0, | ||
536 | .parent = &ipg_clk, | ||
537 | .enable = _clk_enable, | ||
538 | .enable_reg = CCM_PCCR_CSPI1_REG, | ||
539 | .enable_shift = CCM_PCCR_CSPI1_OFFSET, | ||
540 | .disable = _clk_disable, | ||
541 | }, { | ||
542 | .id = 1, | ||
543 | .parent = &ipg_clk, | ||
544 | .enable = _clk_enable, | ||
545 | .enable_reg = CCM_PCCR_CSPI2_REG, | ||
546 | .enable_shift = CCM_PCCR_CSPI2_OFFSET, | ||
547 | .disable = _clk_disable, | ||
548 | }, { | ||
549 | .id = 3, | ||
550 | .parent = &ipg_clk, | ||
551 | .enable = _clk_enable, | ||
552 | .enable_reg = CCM_PCCR_CSPI3_REG, | ||
553 | .enable_shift = CCM_PCCR_CSPI3_OFFSET, | ||
554 | .disable = _clk_disable, | ||
555 | }, | ||
556 | }; | ||
557 | |||
558 | static struct clk lcdc_clk[] = { | ||
559 | { | ||
560 | .parent = &per_clk[2], | ||
561 | .secondary = &lcdc_clk[1], | ||
562 | .round_rate = _clk_parent_round_rate, | ||
563 | .set_rate = _clk_parent_set_rate, | ||
564 | }, { | ||
565 | .parent = &ipg_clk, | ||
566 | .secondary = &lcdc_clk[2], | ||
567 | .enable = _clk_enable, | ||
568 | .enable_reg = CCM_PCCR_LCDC_REG, | ||
569 | .enable_shift = CCM_PCCR_LCDC_OFFSET, | ||
570 | .disable = _clk_disable, | ||
571 | }, { | ||
572 | .parent = &hclk_clk, | ||
573 | .enable = _clk_enable, | ||
574 | .enable_reg = CCM_PCCR_HCLK_LCDC_REG, | ||
575 | .enable_shift = CCM_PCCR_HCLK_LCDC_OFFSET, | ||
576 | .disable = _clk_disable, | ||
577 | }, | ||
578 | }; | ||
579 | |||
580 | static struct clk csi_clk[] = { | ||
581 | { | ||
582 | .parent = &per_clk[3], | ||
583 | .secondary = &csi_clk[1], | ||
584 | .round_rate = _clk_parent_round_rate, | ||
585 | .set_rate = _clk_parent_set_rate, | ||
586 | }, { | ||
587 | .parent = &hclk_clk, | ||
588 | .enable = _clk_enable, | ||
589 | .enable_reg = CCM_PCCR_HCLK_CSI_REG, | ||
590 | .enable_shift = CCM_PCCR_HCLK_CSI_OFFSET, | ||
591 | .disable = _clk_disable, | ||
592 | }, | ||
593 | }; | ||
594 | |||
595 | static struct clk usb_clk[] = { | ||
596 | { | ||
597 | .parent = &spll_clk, | ||
598 | .get_rate = _clk_usb_recalc, | ||
599 | .enable = _clk_enable, | ||
600 | .enable_reg = CCM_PCCR_USBOTG_REG, | ||
601 | .enable_shift = CCM_PCCR_USBOTG_OFFSET, | ||
602 | .disable = _clk_disable, | ||
603 | }, { | ||
604 | .parent = &hclk_clk, | ||
605 | .enable = _clk_enable, | ||
606 | .enable_reg = CCM_PCCR_HCLK_USBOTG_REG, | ||
607 | .enable_shift = CCM_PCCR_HCLK_USBOTG_OFFSET, | ||
608 | .disable = _clk_disable, | ||
609 | } | ||
610 | }; | ||
611 | |||
612 | static struct clk ssi_ipg_clk[]; | ||
613 | |||
614 | static struct clk ssi_clk[] = { | ||
615 | { | ||
616 | .id = 0, | ||
617 | .parent = &mpll_clk, | ||
618 | .secondary = &ssi_ipg_clk[0], | ||
619 | .get_rate = _clk_ssi1_recalc, | ||
620 | .enable = _clk_enable, | ||
621 | .enable_reg = CCM_PCCR_SSI1_BAUD_REG, | ||
622 | .enable_shift = CCM_PCCR_SSI1_BAUD_OFFSET, | ||
623 | .disable = _clk_disable, | ||
624 | }, { | ||
625 | .id = 1, | ||
626 | .parent = &mpll_clk, | ||
627 | .secondary = &ssi_ipg_clk[1], | ||
628 | .get_rate = _clk_ssi2_recalc, | ||
629 | .enable = _clk_enable, | ||
630 | .enable_reg = CCM_PCCR_SSI2_BAUD_REG, | ||
631 | .enable_shift = CCM_PCCR_SSI2_BAUD_OFFSET, | ||
632 | .disable = _clk_disable, | ||
633 | }, | ||
634 | }; | ||
635 | |||
636 | static struct clk ssi_ipg_clk[] = { | ||
637 | { | ||
638 | .id = 0, | ||
639 | .parent = &ipg_clk, | ||
640 | .enable = _clk_enable, | ||
641 | .enable_reg = CCM_PCCR_SSI1_REG, | ||
642 | .enable_shift = CCM_PCCR_SSI1_IPG_OFFSET, | ||
643 | .disable = _clk_disable, | ||
644 | }, { | ||
645 | .id = 1, | ||
646 | .parent = &ipg_clk, | ||
647 | .enable = _clk_enable, | ||
648 | .enable_reg = CCM_PCCR_SSI2_REG, | ||
649 | .enable_shift = CCM_PCCR_SSI2_IPG_OFFSET, | ||
650 | .disable = _clk_disable, | ||
651 | }, | ||
652 | }; | ||
653 | |||
654 | |||
655 | static struct clk nfc_clk = { | ||
656 | .parent = &fclk_clk, | ||
657 | .get_rate = _clk_nfc_recalc, | ||
658 | .enable = _clk_enable, | ||
659 | .enable_reg = CCM_PCCR_NFC_REG, | ||
660 | .enable_shift = CCM_PCCR_NFC_OFFSET, | ||
661 | .disable = _clk_disable, | ||
662 | }; | ||
663 | |||
664 | static struct clk dma_clk[] = { | ||
665 | { | ||
666 | .parent = &hclk_clk, | ||
667 | .enable = _clk_enable, | ||
668 | .enable_reg = CCM_PCCR_DMA_REG, | ||
669 | .enable_shift = CCM_PCCR_DMA_OFFSET, | ||
670 | .disable = _clk_disable, | ||
671 | .secondary = &dma_clk[1], | ||
672 | }, { | ||
673 | .enable = _clk_enable, | ||
674 | .enable_reg = CCM_PCCR_HCLK_DMA_REG, | ||
675 | .enable_shift = CCM_PCCR_HCLK_DMA_OFFSET, | ||
676 | .disable = _clk_disable, | ||
677 | }, | ||
678 | }; | ||
679 | |||
680 | static struct clk brom_clk = { | ||
681 | .parent = &hclk_clk, | ||
682 | .enable = _clk_enable, | ||
683 | .enable_reg = CCM_PCCR_HCLK_BROM_REG, | ||
684 | .enable_shift = CCM_PCCR_HCLK_BROM_OFFSET, | ||
685 | .disable = _clk_disable, | ||
686 | }; | ||
687 | |||
688 | static struct clk emma_clk[] = { | ||
689 | { | ||
690 | .parent = &hclk_clk, | ||
691 | .enable = _clk_enable, | ||
692 | .enable_reg = CCM_PCCR_EMMA_REG, | ||
693 | .enable_shift = CCM_PCCR_EMMA_OFFSET, | ||
694 | .disable = _clk_disable, | ||
695 | .secondary = &emma_clk[1], | ||
696 | }, { | ||
697 | .enable = _clk_enable, | ||
698 | .enable_reg = CCM_PCCR_HCLK_EMMA_REG, | ||
699 | .enable_shift = CCM_PCCR_HCLK_EMMA_OFFSET, | ||
700 | .disable = _clk_disable, | ||
701 | } | ||
702 | }; | ||
703 | |||
704 | static struct clk slcdc_clk[] = { | ||
705 | { | ||
706 | .parent = &hclk_clk, | ||
707 | .enable = _clk_enable, | ||
708 | .enable_reg = CCM_PCCR_SLCDC_REG, | ||
709 | .enable_shift = CCM_PCCR_SLCDC_OFFSET, | ||
710 | .disable = _clk_disable, | ||
711 | .secondary = &slcdc_clk[1], | ||
712 | }, { | ||
713 | .enable = _clk_enable, | ||
714 | .enable_reg = CCM_PCCR_HCLK_SLCDC_REG, | ||
715 | .enable_shift = CCM_PCCR_HCLK_SLCDC_OFFSET, | ||
716 | .disable = _clk_disable, | ||
717 | } | ||
718 | }; | ||
719 | |||
720 | static struct clk wdog_clk = { | ||
721 | .parent = &ipg_clk, | ||
722 | .enable = _clk_enable, | ||
723 | .enable_reg = CCM_PCCR_WDT_REG, | ||
724 | .enable_shift = CCM_PCCR_WDT_OFFSET, | ||
725 | .disable = _clk_disable, | ||
726 | }; | ||
727 | |||
728 | static struct clk gpio_clk = { | ||
729 | .parent = &ipg_clk, | ||
730 | .enable = _clk_enable, | ||
731 | .enable_reg = CCM_PCCR_GPIO_REG, | ||
732 | .enable_shift = CCM_PCCR_GPIO_OFFSET, | ||
733 | .disable = _clk_disable, | ||
734 | }; | ||
735 | |||
736 | static struct clk i2c_clk = { | ||
737 | .id = 0, | ||
738 | .parent = &ipg_clk, | ||
739 | .enable = _clk_enable, | ||
740 | .enable_reg = CCM_PCCR_I2C1_REG, | ||
741 | .enable_shift = CCM_PCCR_I2C1_OFFSET, | ||
742 | .disable = _clk_disable, | ||
743 | }; | ||
744 | |||
745 | static struct clk kpp_clk = { | ||
746 | .parent = &ipg_clk, | ||
747 | .enable = _clk_enable, | ||
748 | .enable_reg = CCM_PCCR_KPP_REG, | ||
749 | .enable_shift = CCM_PCCR_KPP_OFFSET, | ||
750 | .disable = _clk_disable, | ||
751 | }; | ||
752 | |||
753 | static struct clk owire_clk = { | ||
754 | .parent = &ipg_clk, | ||
755 | .enable = _clk_enable, | ||
756 | .enable_reg = CCM_PCCR_OWIRE_REG, | ||
757 | .enable_shift = CCM_PCCR_OWIRE_OFFSET, | ||
758 | .disable = _clk_disable, | ||
759 | }; | ||
760 | |||
761 | static struct clk rtc_clk = { | ||
762 | .parent = &ipg_clk, | ||
763 | .enable = _clk_enable, | ||
764 | .enable_reg = CCM_PCCR_RTC_REG, | ||
765 | .enable_shift = CCM_PCCR_RTC_OFFSET, | ||
766 | .disable = _clk_disable, | ||
767 | }; | ||
768 | |||
769 | static unsigned long _clk_clko_round_rate(struct clk *clk, unsigned long rate) | ||
770 | { | ||
771 | u32 div; | ||
772 | unsigned long parent_rate; | ||
773 | |||
774 | parent_rate = clk_get_rate(clk->parent); | ||
775 | div = parent_rate / rate; | ||
776 | if (parent_rate % rate) | ||
777 | div++; | ||
778 | |||
779 | if (div > 8) | ||
780 | div = 8; | ||
781 | |||
782 | return parent_rate / div; | ||
783 | } | ||
784 | |||
785 | static int _clk_clko_set_rate(struct clk *clk, unsigned long rate) | ||
786 | { | ||
787 | u32 reg; | ||
788 | u32 div; | ||
789 | unsigned long parent_rate; | ||
790 | |||
791 | parent_rate = clk_get_rate(clk->parent); | ||
792 | |||
793 | div = parent_rate / rate; | ||
794 | |||
795 | if (div > 8 || div < 1 || ((parent_rate / div) != rate)) | ||
796 | return -EINVAL; | ||
797 | div--; | ||
798 | |||
799 | reg = __raw_readl(CCM_PCDR0); | ||
800 | |||
801 | if (clk->parent == &usb_clk[0]) { | ||
802 | reg &= ~CCM_PCDR0_48MDIV_MASK; | ||
803 | reg |= div << CCM_PCDR0_48MDIV_OFFSET; | ||
804 | } | ||
805 | __raw_writel(reg, CCM_PCDR0); | ||
806 | |||
807 | return 0; | ||
808 | } | ||
809 | |||
810 | static unsigned long _clk_clko_recalc(struct clk *clk) | ||
811 | { | ||
812 | u32 div = 0; | ||
813 | unsigned long parent_rate; | ||
814 | |||
815 | parent_rate = clk_get_rate(clk->parent); | ||
816 | |||
817 | if (clk->parent == &usb_clk[0]) /* 48M */ | ||
818 | div = __raw_readl(CCM_PCDR0) & CCM_PCDR0_48MDIV_MASK | ||
819 | >> CCM_PCDR0_48MDIV_OFFSET; | ||
820 | div++; | ||
821 | |||
822 | return parent_rate / div; | ||
823 | } | ||
824 | |||
825 | static struct clk clko_clk; | ||
826 | |||
827 | static int _clk_clko_set_parent(struct clk *clk, struct clk *parent) | ||
828 | { | ||
829 | u32 reg; | ||
830 | |||
831 | reg = __raw_readl(CCM_CCSR) & ~CCM_CCSR_CLKOSEL_MASK; | ||
832 | |||
833 | if (parent == &ckil_clk) | ||
834 | reg |= 0 << CCM_CCSR_CLKOSEL_OFFSET; | ||
835 | else if (parent == &fpm_clk) | ||
836 | reg |= 1 << CCM_CCSR_CLKOSEL_OFFSET; | ||
837 | else if (parent == &ckih_clk) | ||
838 | reg |= 2 << CCM_CCSR_CLKOSEL_OFFSET; | ||
839 | else if (parent == mpll_clk.parent) | ||
840 | reg |= 3 << CCM_CCSR_CLKOSEL_OFFSET; | ||
841 | else if (parent == spll_clk.parent) | ||
842 | reg |= 4 << CCM_CCSR_CLKOSEL_OFFSET; | ||
843 | else if (parent == &mpll_clk) | ||
844 | reg |= 5 << CCM_CCSR_CLKOSEL_OFFSET; | ||
845 | else if (parent == &spll_clk) | ||
846 | reg |= 6 << CCM_CCSR_CLKOSEL_OFFSET; | ||
847 | else if (parent == &fclk_clk) | ||
848 | reg |= 7 << CCM_CCSR_CLKOSEL_OFFSET; | ||
849 | else if (parent == &hclk_clk) | ||
850 | reg |= 8 << CCM_CCSR_CLKOSEL_OFFSET; | ||
851 | else if (parent == &ipg_clk) | ||
852 | reg |= 9 << CCM_CCSR_CLKOSEL_OFFSET; | ||
853 | else if (parent == &per_clk[0]) | ||
854 | reg |= 0xA << CCM_CCSR_CLKOSEL_OFFSET; | ||
855 | else if (parent == &per_clk[1]) | ||
856 | reg |= 0xB << CCM_CCSR_CLKOSEL_OFFSET; | ||
857 | else if (parent == &per_clk[2]) | ||
858 | reg |= 0xC << CCM_CCSR_CLKOSEL_OFFSET; | ||
859 | else if (parent == &per_clk[3]) | ||
860 | reg |= 0xD << CCM_CCSR_CLKOSEL_OFFSET; | ||
861 | else if (parent == &ssi_clk[0]) | ||
862 | reg |= 0xE << CCM_CCSR_CLKOSEL_OFFSET; | ||
863 | else if (parent == &ssi_clk[1]) | ||
864 | reg |= 0xF << CCM_CCSR_CLKOSEL_OFFSET; | ||
865 | else if (parent == &nfc_clk) | ||
866 | reg |= 0x10 << CCM_CCSR_CLKOSEL_OFFSET; | ||
867 | else if (parent == &usb_clk[0]) | ||
868 | reg |= 0x14 << CCM_CCSR_CLKOSEL_OFFSET; | ||
869 | else if (parent == &clko_clk) | ||
870 | reg |= 0x15 << CCM_CCSR_CLKOSEL_OFFSET; | ||
871 | else | ||
872 | return -EINVAL; | ||
873 | |||
874 | __raw_writel(reg, CCM_CCSR); | ||
875 | |||
876 | return 0; | ||
877 | } | ||
878 | |||
879 | static struct clk clko_clk = { | ||
880 | .get_rate = _clk_clko_recalc, | ||
881 | .set_rate = _clk_clko_set_rate, | ||
882 | .round_rate = _clk_clko_round_rate, | ||
883 | .set_parent = _clk_clko_set_parent, | ||
884 | }; | ||
885 | |||
886 | |||
887 | #define _REGISTER_CLOCK(d, n, c) \ | ||
888 | { \ | ||
889 | .dev_id = d, \ | ||
890 | .con_id = n, \ | ||
891 | .clk = &c, \ | ||
892 | }, | ||
893 | static struct clk_lookup lookups[] __initdata = { | ||
894 | /* It's unlikely that any driver wants one of them directly: | ||
895 | _REGISTER_CLOCK(NULL, "ckih", ckih_clk) | ||
896 | _REGISTER_CLOCK(NULL, "ckil", ckil_clk) | ||
897 | _REGISTER_CLOCK(NULL, "fpm", fpm_clk) | ||
898 | _REGISTER_CLOCK(NULL, "mpll", mpll_clk) | ||
899 | _REGISTER_CLOCK(NULL, "spll", spll_clk) | ||
900 | _REGISTER_CLOCK(NULL, "fclk", fclk_clk) | ||
901 | _REGISTER_CLOCK(NULL, "hclk", hclk_clk) | ||
902 | _REGISTER_CLOCK(NULL, "ipg", ipg_clk) | ||
903 | */ | ||
904 | _REGISTER_CLOCK(NULL, "perclk1", per_clk[0]) | ||
905 | _REGISTER_CLOCK(NULL, "perclk2", per_clk[1]) | ||
906 | _REGISTER_CLOCK(NULL, "perclk3", per_clk[2]) | ||
907 | _REGISTER_CLOCK(NULL, "perclk4", per_clk[3]) | ||
908 | _REGISTER_CLOCK(NULL, "clko", clko_clk) | ||
909 | _REGISTER_CLOCK("imx-uart.0", NULL, uart_clk[0]) | ||
910 | _REGISTER_CLOCK("imx-uart.1", NULL, uart_clk[1]) | ||
911 | _REGISTER_CLOCK("imx-uart.2", NULL, uart_clk[2]) | ||
912 | _REGISTER_CLOCK("imx-uart.3", NULL, uart_clk[3]) | ||
913 | _REGISTER_CLOCK(NULL, "gpt1", gpt_clk[0]) | ||
914 | _REGISTER_CLOCK(NULL, "gpt1", gpt_clk[1]) | ||
915 | _REGISTER_CLOCK(NULL, "gpt1", gpt_clk[2]) | ||
916 | _REGISTER_CLOCK(NULL, "pwm", pwm_clk[0]) | ||
917 | _REGISTER_CLOCK(NULL, "sdhc1", sdhc_clk[0]) | ||
918 | _REGISTER_CLOCK(NULL, "sdhc2", sdhc_clk[1]) | ||
919 | _REGISTER_CLOCK(NULL, "cspi1", cspi_clk[0]) | ||
920 | _REGISTER_CLOCK(NULL, "cspi2", cspi_clk[1]) | ||
921 | _REGISTER_CLOCK(NULL, "cspi3", cspi_clk[2]) | ||
922 | _REGISTER_CLOCK(NULL, "lcdc", lcdc_clk[0]) | ||
923 | _REGISTER_CLOCK(NULL, "csi", csi_clk[0]) | ||
924 | _REGISTER_CLOCK(NULL, "usb", usb_clk[0]) | ||
925 | _REGISTER_CLOCK(NULL, "ssi1", ssi_clk[0]) | ||
926 | _REGISTER_CLOCK(NULL, "ssi2", ssi_clk[1]) | ||
927 | _REGISTER_CLOCK(NULL, "nfc", nfc_clk) | ||
928 | _REGISTER_CLOCK(NULL, "dma", dma_clk[0]) | ||
929 | _REGISTER_CLOCK(NULL, "brom", brom_clk) | ||
930 | _REGISTER_CLOCK(NULL, "emma", emma_clk[0]) | ||
931 | _REGISTER_CLOCK(NULL, "slcdc", slcdc_clk[0]) | ||
932 | _REGISTER_CLOCK(NULL, "wdog", wdog_clk) | ||
933 | _REGISTER_CLOCK(NULL, "gpio", gpio_clk) | ||
934 | _REGISTER_CLOCK(NULL, "i2c", i2c_clk) | ||
935 | _REGISTER_CLOCK("mxc-keypad", NULL, kpp_clk) | ||
936 | _REGISTER_CLOCK(NULL, "owire", owire_clk) | ||
937 | _REGISTER_CLOCK(NULL, "rtc", rtc_clk) | ||
938 | }; | ||
939 | |||
940 | /* | ||
941 | * must be called very early to get information about the | ||
942 | * available clock rate when the timer framework starts | ||
943 | */ | ||
944 | int __init mx21_clocks_init(unsigned long lref, unsigned long href) | ||
945 | { | ||
946 | int i; | ||
947 | u32 cscr; | ||
948 | |||
949 | external_low_reference = lref; | ||
950 | external_high_reference = href; | ||
951 | |||
952 | /* detect clock reference for both system PLL */ | ||
953 | cscr = CSCR(); | ||
954 | if (cscr & CCM_CSCR_MCU) | ||
955 | mpll_clk.parent = &ckih_clk; | ||
956 | else | ||
957 | mpll_clk.parent = &fpm_clk; | ||
958 | |||
959 | if (cscr & CCM_CSCR_SP) | ||
960 | spll_clk.parent = &ckih_clk; | ||
961 | else | ||
962 | spll_clk.parent = &fpm_clk; | ||
963 | |||
964 | for (i = 0; i < ARRAY_SIZE(lookups); i++) | ||
965 | clkdev_add(&lookups[i]); | ||
966 | |||
967 | /* Turn off all clock gates */ | ||
968 | __raw_writel(0, CCM_PCCR0); | ||
969 | __raw_writel(CCM_PCCR_GPT1_MASK, CCM_PCCR1); | ||
970 | |||
971 | /* This turns of the serial PLL as well */ | ||
972 | spll_clk.disable(&spll_clk); | ||
973 | |||
974 | /* This will propagate to all children and init all the clock rates. */ | ||
975 | clk_enable(&per_clk[0]); | ||
976 | clk_enable(&gpio_clk); | ||
977 | |||
978 | #ifdef CONFIG_DEBUG_LL_CONSOLE | ||
979 | clk_enable(&uart_clk[0]); | ||
980 | #endif | ||
981 | |||
982 | mxc_timer_init(&gpt_clk[0]); | ||
983 | return 0; | ||
984 | } | ||
diff --git a/arch/arm/mach-mx2/crm_regs.h b/arch/arm/mach-mx2/crm_regs.h new file mode 100644 index 000000000000..749de76b3f95 --- /dev/null +++ b/arch/arm/mach-mx2/crm_regs.h | |||
@@ -0,0 +1,258 @@ | |||
1 | /* | ||
2 | * Copyright 2004-2007 Freescale Semiconductor, Inc. All Rights Reserved. | ||
3 | * Copyright 2008 Juergen Beisert, kernel@pengutronix.de | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or | ||
6 | * modify it under the terms of the GNU General Public License | ||
7 | * as published by the Free Software Foundation; either version 2 | ||
8 | * of the License, or (at your option) any later version. | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write to the Free Software | ||
16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | ||
17 | * MA 02110-1301, USA. | ||
18 | */ | ||
19 | |||
20 | #ifndef __ARCH_ARM_MACH_MX2_CRM_REGS_H__ | ||
21 | #define __ARCH_ARM_MACH_MX2_CRM_REGS_H__ | ||
22 | |||
23 | #include <mach/hardware.h> | ||
24 | |||
25 | /* Register offsets */ | ||
26 | #define CCM_CSCR (IO_ADDRESS(CCM_BASE_ADDR) + 0x0) | ||
27 | #define CCM_MPCTL0 (IO_ADDRESS(CCM_BASE_ADDR) + 0x4) | ||
28 | #define CCM_MPCTL1 (IO_ADDRESS(CCM_BASE_ADDR) + 0x8) | ||
29 | #define CCM_SPCTL0 (IO_ADDRESS(CCM_BASE_ADDR) + 0xC) | ||
30 | #define CCM_SPCTL1 (IO_ADDRESS(CCM_BASE_ADDR) + 0x10) | ||
31 | #define CCM_OSC26MCTL (IO_ADDRESS(CCM_BASE_ADDR) + 0x14) | ||
32 | #define CCM_PCDR0 (IO_ADDRESS(CCM_BASE_ADDR) + 0x18) | ||
33 | #define CCM_PCDR1 (IO_ADDRESS(CCM_BASE_ADDR) + 0x1c) | ||
34 | #define CCM_PCCR0 (IO_ADDRESS(CCM_BASE_ADDR) + 0x20) | ||
35 | #define CCM_PCCR1 (IO_ADDRESS(CCM_BASE_ADDR) + 0x24) | ||
36 | #define CCM_CCSR (IO_ADDRESS(CCM_BASE_ADDR) + 0x28) | ||
37 | #define CCM_PMCTL (IO_ADDRESS(CCM_BASE_ADDR) + 0x2c) | ||
38 | #define CCM_PMCOUNT (IO_ADDRESS(CCM_BASE_ADDR) + 0x30) | ||
39 | #define CCM_WKGDCTL (IO_ADDRESS(CCM_BASE_ADDR) + 0x34) | ||
40 | |||
41 | #define CCM_CSCR_PRESC_OFFSET 29 | ||
42 | #define CCM_CSCR_PRESC_MASK (0x7 << CCM_CSCR_PRESC_OFFSET) | ||
43 | |||
44 | #define CCM_CSCR_USB_OFFSET 26 | ||
45 | #define CCM_CSCR_USB_MASK (0x7 << CCM_CSCR_USB_OFFSET) | ||
46 | #define CCM_CSCR_SD_OFFSET 24 | ||
47 | #define CCM_CSCR_SD_MASK (0x3 << CCM_CSCR_SD_OFFSET) | ||
48 | #define CCM_CSCR_SPLLRES (1 << 22) | ||
49 | #define CCM_CSCR_MPLLRES (1 << 21) | ||
50 | #define CCM_CSCR_SSI2_OFFSET 20 | ||
51 | #define CCM_CSCR_SSI2 (1 << CCM_CSCR_SSI2_OFFSET) | ||
52 | #define CCM_CSCR_SSI1_OFFSET 19 | ||
53 | #define CCM_CSCR_SSI1 (1 << CCM_CSCR_SSI1_OFFSET) | ||
54 | #define CCM_CSCR_FIR_OFFSET 18 | ||
55 | #define CCM_CSCR_FIR (1 << CCM_CSCR_FIR_OFFSET) | ||
56 | #define CCM_CSCR_SP (1 << 17) | ||
57 | #define CCM_CSCR_MCU (1 << 16) | ||
58 | #define CCM_CSCR_BCLK_OFFSET 10 | ||
59 | #define CCM_CSCR_BCLK_MASK (0xf << CCM_CSCR_BCLK_OFFSET) | ||
60 | #define CCM_CSCR_IPDIV_OFFSET 9 | ||
61 | #define CCM_CSCR_IPDIV (1 << CCM_CSCR_IPDIV_OFFSET) | ||
62 | |||
63 | #define CCM_CSCR_OSC26MDIV (1 << 4) | ||
64 | #define CCM_CSCR_OSC26M (1 << 3) | ||
65 | #define CCM_CSCR_FPM (1 << 2) | ||
66 | #define CCM_CSCR_SPEN (1 << 1) | ||
67 | #define CCM_CSCR_MPEN 1 | ||
68 | |||
69 | |||
70 | |||
71 | #define CCM_MPCTL0_CPLM (1 << 31) | ||
72 | #define CCM_MPCTL0_PD_OFFSET 26 | ||
73 | #define CCM_MPCTL0_PD_MASK (0xf << 26) | ||
74 | #define CCM_MPCTL0_MFD_OFFSET 16 | ||
75 | #define CCM_MPCTL0_MFD_MASK (0x3ff << 16) | ||
76 | #define CCM_MPCTL0_MFI_OFFSET 10 | ||
77 | #define CCM_MPCTL0_MFI_MASK (0xf << 10) | ||
78 | #define CCM_MPCTL0_MFN_OFFSET 0 | ||
79 | #define CCM_MPCTL0_MFN_MASK 0x3ff | ||
80 | |||
81 | #define CCM_MPCTL1_LF (1 << 15) | ||
82 | #define CCM_MPCTL1_BRMO (1 << 6) | ||
83 | |||
84 | #define CCM_SPCTL0_CPLM (1 << 31) | ||
85 | #define CCM_SPCTL0_PD_OFFSET 26 | ||
86 | #define CCM_SPCTL0_PD_MASK (0xf << 26) | ||
87 | #define CCM_SPCTL0_MFD_OFFSET 16 | ||
88 | #define CCM_SPCTL0_MFD_MASK (0x3ff << 16) | ||
89 | #define CCM_SPCTL0_MFI_OFFSET 10 | ||
90 | #define CCM_SPCTL0_MFI_MASK (0xf << 10) | ||
91 | #define CCM_SPCTL0_MFN_OFFSET 0 | ||
92 | #define CCM_SPCTL0_MFN_MASK 0x3ff | ||
93 | |||
94 | #define CCM_SPCTL1_LF (1 << 15) | ||
95 | #define CCM_SPCTL1_BRMO (1 << 6) | ||
96 | |||
97 | #define CCM_OSC26MCTL_PEAK_OFFSET 16 | ||
98 | #define CCM_OSC26MCTL_PEAK_MASK (0x3 << 16) | ||
99 | #define CCM_OSC26MCTL_AGC_OFFSET 8 | ||
100 | #define CCM_OSC26MCTL_AGC_MASK (0x3f << 8) | ||
101 | #define CCM_OSC26MCTL_ANATEST_OFFSET 0 | ||
102 | #define CCM_OSC26MCTL_ANATEST_MASK 0x3f | ||
103 | |||
104 | #define CCM_PCDR0_SSI2BAUDDIV_OFFSET 26 | ||
105 | #define CCM_PCDR0_SSI2BAUDDIV_MASK (0x3f << 26) | ||
106 | #define CCM_PCDR0_SSI1BAUDDIV_OFFSET 16 | ||
107 | #define CCM_PCDR0_SSI1BAUDDIV_MASK (0x3f << 16) | ||
108 | #define CCM_PCDR0_NFCDIV_OFFSET 12 | ||
109 | #define CCM_PCDR0_NFCDIV_MASK (0xf << 12) | ||
110 | #define CCM_PCDR0_48MDIV_OFFSET 5 | ||
111 | #define CCM_PCDR0_48MDIV_MASK (0x7 << CCM_PCDR0_48MDIV_OFFSET) | ||
112 | #define CCM_PCDR0_FIRIDIV_OFFSET 0 | ||
113 | #define CCM_PCDR0_FIRIDIV_MASK 0x1f | ||
114 | #define CCM_PCDR1_PERDIV4_OFFSET 24 | ||
115 | #define CCM_PCDR1_PERDIV4_MASK (0x3f << 24) | ||
116 | #define CCM_PCDR1_PERDIV3_OFFSET 16 | ||
117 | #define CCM_PCDR1_PERDIV3_MASK (0x3f << 16) | ||
118 | #define CCM_PCDR1_PERDIV2_OFFSET 8 | ||
119 | #define CCM_PCDR1_PERDIV2_MASK (0x3f << 8) | ||
120 | #define CCM_PCDR1_PERDIV1_OFFSET 0 | ||
121 | #define CCM_PCDR1_PERDIV1_MASK 0x3f | ||
122 | |||
123 | #define CCM_PCCR_HCLK_CSI_OFFSET 31 | ||
124 | #define CCM_PCCR_HCLK_CSI_REG CCM_PCCR0 | ||
125 | #define CCM_PCCR_HCLK_DMA_OFFSET 30 | ||
126 | #define CCM_PCCR_HCLK_DMA_REG CCM_PCCR0 | ||
127 | #define CCM_PCCR_HCLK_BROM_OFFSET 28 | ||
128 | #define CCM_PCCR_HCLK_BROM_REG CCM_PCCR0 | ||
129 | #define CCM_PCCR_HCLK_EMMA_OFFSET 27 | ||
130 | #define CCM_PCCR_HCLK_EMMA_REG CCM_PCCR0 | ||
131 | #define CCM_PCCR_HCLK_LCDC_OFFSET 26 | ||
132 | #define CCM_PCCR_HCLK_LCDC_REG CCM_PCCR0 | ||
133 | #define CCM_PCCR_HCLK_SLCDC_OFFSET 25 | ||
134 | #define CCM_PCCR_HCLK_SLCDC_REG CCM_PCCR0 | ||
135 | #define CCM_PCCR_HCLK_USBOTG_OFFSET 24 | ||
136 | #define CCM_PCCR_HCLK_USBOTG_REG CCM_PCCR0 | ||
137 | #define CCM_PCCR_HCLK_BMI_OFFSET 23 | ||
138 | #define CCM_PCCR_BMI_MASK (1 << CCM_PCCR_BMI_MASK) | ||
139 | #define CCM_PCCR_HCLK_BMI_REG CCM_PCCR0 | ||
140 | #define CCM_PCCR_PERCLK4_OFFSET 22 | ||
141 | #define CCM_PCCR_PERCLK4_REG CCM_PCCR0 | ||
142 | #define CCM_PCCR_SLCDC_OFFSET 21 | ||
143 | #define CCM_PCCR_SLCDC_REG CCM_PCCR0 | ||
144 | #define CCM_PCCR_FIRI_BAUD_OFFSET 20 | ||
145 | #define CCM_PCCR_FIRI_BAUD_MASK (1 << CCM_PCCR_FIRI_BAUD_MASK) | ||
146 | #define CCM_PCCR_FIRI_BAUD_REG CCM_PCCR0 | ||
147 | #define CCM_PCCR_NFC_OFFSET 19 | ||
148 | #define CCM_PCCR_NFC_REG CCM_PCCR0 | ||
149 | #define CCM_PCCR_LCDC_OFFSET 18 | ||
150 | #define CCM_PCCR_LCDC_REG CCM_PCCR0 | ||
151 | #define CCM_PCCR_SSI1_BAUD_OFFSET 17 | ||
152 | #define CCM_PCCR_SSI1_BAUD_REG CCM_PCCR0 | ||
153 | #define CCM_PCCR_SSI2_BAUD_OFFSET 16 | ||
154 | #define CCM_PCCR_SSI2_BAUD_REG CCM_PCCR0 | ||
155 | #define CCM_PCCR_EMMA_OFFSET 15 | ||
156 | #define CCM_PCCR_EMMA_REG CCM_PCCR0 | ||
157 | #define CCM_PCCR_USBOTG_OFFSET 14 | ||
158 | #define CCM_PCCR_USBOTG_REG CCM_PCCR0 | ||
159 | #define CCM_PCCR_DMA_OFFSET 13 | ||
160 | #define CCM_PCCR_DMA_REG CCM_PCCR0 | ||
161 | #define CCM_PCCR_I2C1_OFFSET 12 | ||
162 | #define CCM_PCCR_I2C1_REG CCM_PCCR0 | ||
163 | #define CCM_PCCR_GPIO_OFFSET 11 | ||
164 | #define CCM_PCCR_GPIO_REG CCM_PCCR0 | ||
165 | #define CCM_PCCR_SDHC2_OFFSET 10 | ||
166 | #define CCM_PCCR_SDHC2_REG CCM_PCCR0 | ||
167 | #define CCM_PCCR_SDHC1_OFFSET 9 | ||
168 | #define CCM_PCCR_SDHC1_REG CCM_PCCR0 | ||
169 | #define CCM_PCCR_FIRI_OFFSET 8 | ||
170 | #define CCM_PCCR_FIRI_MASK (1 << CCM_PCCR_BAUD_MASK) | ||
171 | #define CCM_PCCR_FIRI_REG CCM_PCCR0 | ||
172 | #define CCM_PCCR_SSI2_IPG_OFFSET 7 | ||
173 | #define CCM_PCCR_SSI2_REG CCM_PCCR0 | ||
174 | #define CCM_PCCR_SSI1_IPG_OFFSET 6 | ||
175 | #define CCM_PCCR_SSI1_REG CCM_PCCR0 | ||
176 | #define CCM_PCCR_CSPI2_OFFSET 5 | ||
177 | #define CCM_PCCR_CSPI2_REG CCM_PCCR0 | ||
178 | #define CCM_PCCR_CSPI1_OFFSET 4 | ||
179 | #define CCM_PCCR_CSPI1_REG CCM_PCCR0 | ||
180 | #define CCM_PCCR_UART4_OFFSET 3 | ||
181 | #define CCM_PCCR_UART4_REG CCM_PCCR0 | ||
182 | #define CCM_PCCR_UART3_OFFSET 2 | ||
183 | #define CCM_PCCR_UART3_REG CCM_PCCR0 | ||
184 | #define CCM_PCCR_UART2_OFFSET 1 | ||
185 | #define CCM_PCCR_UART2_REG CCM_PCCR0 | ||
186 | #define CCM_PCCR_UART1_OFFSET 0 | ||
187 | #define CCM_PCCR_UART1_REG CCM_PCCR0 | ||
188 | |||
189 | #define CCM_PCCR_OWIRE_OFFSET 31 | ||
190 | #define CCM_PCCR_OWIRE_REG CCM_PCCR1 | ||
191 | #define CCM_PCCR_KPP_OFFSET 30 | ||
192 | #define CCM_PCCR_KPP_REG CCM_PCCR1 | ||
193 | #define CCM_PCCR_RTC_OFFSET 29 | ||
194 | #define CCM_PCCR_RTC_REG CCM_PCCR1 | ||
195 | #define CCM_PCCR_PWM_OFFSET 28 | ||
196 | #define CCM_PCCR_PWM_REG CCM_PCCR1 | ||
197 | #define CCM_PCCR_GPT3_OFFSET 27 | ||
198 | #define CCM_PCCR_GPT3_REG CCM_PCCR1 | ||
199 | #define CCM_PCCR_GPT2_OFFSET 26 | ||
200 | #define CCM_PCCR_GPT2_REG CCM_PCCR1 | ||
201 | #define CCM_PCCR_GPT1_OFFSET 25 | ||
202 | #define CCM_PCCR_GPT1_REG CCM_PCCR1 | ||
203 | #define CCM_PCCR_WDT_OFFSET 24 | ||
204 | #define CCM_PCCR_WDT_REG CCM_PCCR1 | ||
205 | #define CCM_PCCR_CSPI3_OFFSET 23 | ||
206 | #define CCM_PCCR_CSPI3_REG CCM_PCCR1 | ||
207 | |||
208 | #define CCM_PCCR_CSPI1_MASK (1 << CCM_PCCR_CSPI1_OFFSET) | ||
209 | #define CCM_PCCR_CSPI2_MASK (1 << CCM_PCCR_CSPI2_OFFSET) | ||
210 | #define CCM_PCCR_CSPI3_MASK (1 << CCM_PCCR_CSPI3_OFFSET) | ||
211 | #define CCM_PCCR_DMA_MASK (1 << CCM_PCCR_DMA_OFFSET) | ||
212 | #define CCM_PCCR_EMMA_MASK (1 << CCM_PCCR_EMMA_OFFSET) | ||
213 | #define CCM_PCCR_GPIO_MASK (1 << CCM_PCCR_GPIO_OFFSET) | ||
214 | #define CCM_PCCR_GPT1_MASK (1 << CCM_PCCR_GPT1_OFFSET) | ||
215 | #define CCM_PCCR_GPT2_MASK (1 << CCM_PCCR_GPT2_OFFSET) | ||
216 | #define CCM_PCCR_GPT3_MASK (1 << CCM_PCCR_GPT3_OFFSET) | ||
217 | #define CCM_PCCR_HCLK_BROM_MASK (1 << CCM_PCCR_HCLK_BROM_OFFSET) | ||
218 | #define CCM_PCCR_HCLK_CSI_MASK (1 << CCM_PCCR_HCLK_CSI_OFFSET) | ||
219 | #define CCM_PCCR_HCLK_DMA_MASK (1 << CCM_PCCR_HCLK_DMA_OFFSET) | ||
220 | #define CCM_PCCR_HCLK_EMMA_MASK (1 << CCM_PCCR_HCLK_EMMA_OFFSET) | ||
221 | #define CCM_PCCR_HCLK_LCDC_MASK (1 << CCM_PCCR_HCLK_LCDC_OFFSET) | ||
222 | #define CCM_PCCR_HCLK_SLCDC_MASK (1 << CCM_PCCR_HCLK_SLCDC_OFFSET) | ||
223 | #define CCM_PCCR_HCLK_USBOTG_MASK (1 << CCM_PCCR_HCLK_USBOTG_OFFSET) | ||
224 | #define CCM_PCCR_I2C1_MASK (1 << CCM_PCCR_I2C1_OFFSET) | ||
225 | #define CCM_PCCR_KPP_MASK (1 << CCM_PCCR_KPP_OFFSET) | ||
226 | #define CCM_PCCR_LCDC_MASK (1 << CCM_PCCR_LCDC_OFFSET) | ||
227 | #define CCM_PCCR_NFC_MASK (1 << CCM_PCCR_NFC_OFFSET) | ||
228 | #define CCM_PCCR_OWIRE_MASK (1 << CCM_PCCR_OWIRE_OFFSET) | ||
229 | #define CCM_PCCR_PERCLK4_MASK (1 << CCM_PCCR_PERCLK4_OFFSET) | ||
230 | #define CCM_PCCR_PWM_MASK (1 << CCM_PCCR_PWM_OFFSET) | ||
231 | #define CCM_PCCR_RTC_MASK (1 << CCM_PCCR_RTC_OFFSET) | ||
232 | #define CCM_PCCR_SDHC1_MASK (1 << CCM_PCCR_SDHC1_OFFSET) | ||
233 | #define CCM_PCCR_SDHC2_MASK (1 << CCM_PCCR_SDHC2_OFFSET) | ||
234 | #define CCM_PCCR_SLCDC_MASK (1 << CCM_PCCR_SLCDC_OFFSET) | ||
235 | #define CCM_PCCR_SSI1_BAUD_MASK (1 << CCM_PCCR_SSI1_BAUD_OFFSET) | ||
236 | #define CCM_PCCR_SSI1_IPG_MASK (1 << CCM_PCCR_SSI1_IPG_OFFSET) | ||
237 | #define CCM_PCCR_SSI2_BAUD_MASK (1 << CCM_PCCR_SSI2_BAUD_OFFSET) | ||
238 | #define CCM_PCCR_SSI2_IPG_MASK (1 << CCM_PCCR_SSI2_IPG_OFFSET) | ||
239 | #define CCM_PCCR_UART1_MASK (1 << CCM_PCCR_UART1_OFFSET) | ||
240 | #define CCM_PCCR_UART2_MASK (1 << CCM_PCCR_UART2_OFFSET) | ||
241 | #define CCM_PCCR_UART3_MASK (1 << CCM_PCCR_UART3_OFFSET) | ||
242 | #define CCM_PCCR_UART4_MASK (1 << CCM_PCCR_UART4_OFFSET) | ||
243 | #define CCM_PCCR_USBOTG_MASK (1 << CCM_PCCR_USBOTG_OFFSET) | ||
244 | #define CCM_PCCR_WDT_MASK (1 << CCM_PCCR_WDT_OFFSET) | ||
245 | |||
246 | |||
247 | #define CCM_CCSR_32KSR (1 << 15) | ||
248 | |||
249 | #define CCM_CCSR_CLKMODE1 (1 << 9) | ||
250 | #define CCM_CCSR_CLKMODE0 (1 << 8) | ||
251 | |||
252 | #define CCM_CCSR_CLKOSEL_OFFSET 0 | ||
253 | #define CCM_CCSR_CLKOSEL_MASK 0x1f | ||
254 | |||
255 | #define SYS_FMCR 0x14 /* Functional Muxing Control Reg */ | ||
256 | #define SYS_CHIP_ID 0x00 /* The offset of CHIP ID register */ | ||
257 | |||
258 | #endif /* __ARCH_ARM_MACH_MX2_CRM_REGS_H__ */ | ||