]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/arm/mach-omap2/clock34xx.c
917664df1ac5f586b5b6e0fa76b51a4176991399
[linux-2.6-omap-h63xx.git] / arch / arm / mach-omap2 / clock34xx.c
1 /*
2  * OMAP3-specific clock framework functions
3  *
4  * Copyright (C) 2007-2008 Texas Instruments, Inc.
5  * Copyright (C) 2007-2008 Nokia Corporation
6  *
7  * Written by Paul Walmsley
8  * Testing and integration fixes by Jouni Högander
9  *
10  * Parts of this code are based on code written by
11  * Richard Woodruff, Tony Lindgren, Tuukka Tikkanen, Karthik Dasu
12  *
13  * This program is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License version 2 as
15  * published by the Free Software Foundation.
16  */
17 #undef DEBUG
18
19 #include <linux/module.h>
20 #include <linux/kernel.h>
21 #include <linux/device.h>
22 #include <linux/list.h>
23 #include <linux/errno.h>
24 #include <linux/delay.h>
25 #include <linux/clk.h>
26 #include <linux/io.h>
27 #include <linux/limits.h>
28 #include <linux/bitops.h>
29
30 #include <mach/clock.h>
31 #include <mach/sram.h>
32 #include <asm/div64.h>
33
34 #include <mach/sdrc.h>
35 #include "clock.h"
36 #include "clock34xx.h"
37 #include "prm.h"
38 #include "prm-regbits-34xx.h"
39 #include "cm.h"
40 #include "cm-regbits-34xx.h"
41
42 /* CM_AUTOIDLE_PLL*.AUTO_* bit values */
43 #define DPLL_AUTOIDLE_DISABLE                   0x0
44 #define DPLL_AUTOIDLE_LOW_POWER_STOP            0x1
45
46 #define MAX_DPLL_WAIT_TRIES             1000000
47
48 /**
49  * omap3_dpll_recalc - recalculate DPLL rate
50  * @clk: DPLL struct clk
51  * @parent_rate: rate of the DPLL's parent clock
52  * @rate_storage: flag indicating whether current or temporary rate is changing
53  *
54  * Recalculate and propagate the DPLL rate.
55  */
56 static void omap3_dpll_recalc(struct clk *clk, unsigned long parent_rate,
57                               u8 rate_storage)
58 {
59         unsigned long rate;
60
61         rate = omap2_get_dpll_rate(clk, parent_rate);
62
63         if (rate_storage == CURRENT_RATE)
64                 clk->rate = rate;
65         else if (rate_storage == TEMP_RATE)
66                 clk->temp_rate = rate;
67 }
68
69 /* _omap3_dpll_write_clken - write clken_bits arg to a DPLL's enable bits */
70 static void _omap3_dpll_write_clken(struct clk *clk, u8 clken_bits)
71 {
72         const struct dpll_data *dd;
73         u32 v;
74
75         dd = clk->dpll_data;
76
77         v = cm_read_mod_reg(clk->prcm_mod, dd->control_reg);
78         v &= ~dd->enable_mask;
79         v |= clken_bits << __ffs(dd->enable_mask);
80         cm_write_mod_reg(v, clk->prcm_mod, dd->control_reg);
81 }
82
83 /* _omap3_wait_dpll_status: wait for a DPLL to enter a specific state */
84 static int _omap3_wait_dpll_status(struct clk *clk, u8 state)
85 {
86         const struct dpll_data *dd;
87         int i = 0;
88         int ret = -EINVAL;
89
90         dd = clk->dpll_data;
91
92         state <<= __ffs(dd->idlest_mask);
93
94         while (((cm_read_mod_reg(clk->prcm_mod, dd->idlest_reg)
95                  & dd->idlest_mask) != state) &&
96                i < MAX_DPLL_WAIT_TRIES) {
97                 i++;
98                 udelay(1);
99         }
100
101         if (i == MAX_DPLL_WAIT_TRIES) {
102                 printk(KERN_ERR "clock: %s failed transition to '%s'\n",
103                        clk->name, (state) ? "locked" : "bypassed");
104         } else {
105                 pr_debug("clock: %s transition to '%s' in %d loops\n",
106                          clk->name, (state) ? "locked" : "bypassed", i);
107
108                 ret = 0;
109         }
110
111         return ret;
112 }
113
114 /* From 3430 TRM ES2 4.7.6.2 */
115 static u16 _omap3_dpll_compute_freqsel(struct clk *clk, u8 n)
116 {
117         unsigned long fint;
118         u16 f = 0;
119
120         fint = clk->parent->rate / (n + 1);
121
122         pr_debug("clock: fint is %lu\n", fint);
123
124         if (fint >= 750000 && fint <= 1000000)
125                 f = 0x3;
126         else if (fint > 1000000 && fint <= 1250000)
127                 f = 0x4;
128         else if (fint > 1250000 && fint <= 1500000)
129                 f = 0x5;
130         else if (fint > 1500000 && fint <= 1750000)
131                 f = 0x6;
132         else if (fint > 1750000 && fint <= 2100000)
133                 f = 0x7;
134         else if (fint > 7500000 && fint <= 10000000)
135                 f = 0xB;
136         else if (fint > 10000000 && fint <= 12500000)
137                 f = 0xC;
138         else if (fint > 12500000 && fint <= 15000000)
139                 f = 0xD;
140         else if (fint > 15000000 && fint <= 17500000)
141                 f = 0xE;
142         else if (fint > 17500000 && fint <= 21000000)
143                 f = 0xF;
144         else
145                 pr_debug("clock: unknown freqsel setting for %d\n", n);
146
147         return f;
148 }
149
150 /* Non-CORE DPLL (e.g., DPLLs that do not control SDRC) clock functions */
151
152 /*
153  * _omap3_noncore_dpll_lock - instruct a DPLL to lock and wait for readiness
154  * @clk: pointer to a DPLL struct clk
155  *
156  * Instructs a non-CORE DPLL to lock.  Waits for the DPLL to report
157  * readiness before returning.  Will save and restore the DPLL's
158  * autoidle state across the enable, per the CDP code.  If the DPLL
159  * locked successfully, return 0; if the DPLL did not lock in the time
160  * allotted, or DPLL3 was passed in, return -EINVAL.
161  */
162 static int _omap3_noncore_dpll_lock(struct clk *clk)
163 {
164         u8 ai;
165         int r;
166
167         if (clk == &dpll3_ck)
168                 return -EINVAL;
169
170         pr_debug("clock: locking DPLL %s\n", clk->name);
171
172         ai = omap3_dpll_autoidle_read(clk);
173
174         omap3_dpll_deny_idle(clk);
175
176         _omap3_dpll_write_clken(clk, DPLL_LOCKED);
177
178         r = _omap3_wait_dpll_status(clk, 1);
179
180         if (ai)
181                 omap3_dpll_allow_idle(clk);
182
183         return r;
184 }
185
186 /*
187  * _omap3_noncore_dpll_bypass - instruct a DPLL to bypass and wait for readiness
188  * @clk: pointer to a DPLL struct clk
189  *
190  * Instructs a non-CORE DPLL to enter low-power bypass mode.  In
191  * bypass mode, the DPLL's rate is set equal to its parent clock's
192  * rate.  Waits for the DPLL to report readiness before returning.
193  * Will save and restore the DPLL's autoidle state across the enable,
194  * per the CDP code.  If the DPLL entered bypass mode successfully,
195  * return 0; if the DPLL did not enter bypass in the time allotted, or
196  * DPLL3 was passed in, or the DPLL does not support low-power bypass,
197  * return -EINVAL.
198  */
199 static int _omap3_noncore_dpll_bypass(struct clk *clk)
200 {
201         int r;
202         u8 ai;
203
204         if (clk == &dpll3_ck)
205                 return -EINVAL;
206
207         if (!(clk->dpll_data->modes & (1 << DPLL_LOW_POWER_BYPASS)))
208                 return -EINVAL;
209
210         pr_debug("clock: configuring DPLL %s for low-power bypass\n",
211                  clk->name);
212
213         ai = omap3_dpll_autoidle_read(clk);
214
215         _omap3_dpll_write_clken(clk, DPLL_LOW_POWER_BYPASS);
216
217         r = _omap3_wait_dpll_status(clk, 0);
218
219         if (ai)
220                 omap3_dpll_allow_idle(clk);
221         else
222                 omap3_dpll_deny_idle(clk);
223
224         return r;
225 }
226
227 /*
228  * _omap3_noncore_dpll_stop - instruct a DPLL to stop
229  * @clk: pointer to a DPLL struct clk
230  *
231  * Instructs a non-CORE DPLL to enter low-power stop. Will save and
232  * restore the DPLL's autoidle state across the stop, per the CDP
233  * code.  If DPLL3 was passed in, or the DPLL does not support
234  * low-power stop, return -EINVAL; otherwise, return 0.
235  */
236 static int _omap3_noncore_dpll_stop(struct clk *clk)
237 {
238         u8 ai;
239
240         if (clk == &dpll3_ck)
241                 return -EINVAL;
242
243         if (!(clk->dpll_data->modes & (1 << DPLL_LOW_POWER_STOP)))
244                 return -EINVAL;
245
246         pr_debug("clock: stopping DPLL %s\n", clk->name);
247
248         ai = omap3_dpll_autoidle_read(clk);
249
250         _omap3_dpll_write_clken(clk, DPLL_LOW_POWER_STOP);
251
252         if (ai)
253                 omap3_dpll_allow_idle(clk);
254         else
255                 omap3_dpll_deny_idle(clk);
256
257         return 0;
258 }
259
260 /**
261  * omap3_noncore_dpll_enable - instruct a DPLL to enter bypass or lock mode
262  * @clk: pointer to a DPLL struct clk
263  *
264  * Instructs a non-CORE DPLL to enable, e.g., to enter bypass or lock.
265  * The choice of modes depends on the DPLL's programmed rate: if it is
266  * the same as the DPLL's parent clock, it will enter bypass;
267  * otherwise, it will enter lock.  This code will wait for the DPLL to
268  * indicate readiness before returning, unless the DPLL takes too long
269  * to enter the target state.  Intended to be used as the struct clk's
270  * enable function.  If DPLL3 was passed in, or the DPLL does not
271  * support low-power stop, or if the DPLL took too long to enter
272  * bypass or lock, return -EINVAL; otherwise, return 0.
273  */
274 static int omap3_noncore_dpll_enable(struct clk *clk)
275 {
276         int r;
277         struct dpll_data *dd;
278
279         if (clk == &dpll3_ck)
280                 return -EINVAL;
281
282         dd = clk->dpll_data;
283         if (!dd)
284                 return -EINVAL;
285
286         if (clk->rate == dd->bypass_clk->rate)
287                 r = _omap3_noncore_dpll_bypass(clk);
288         else
289                 r = _omap3_noncore_dpll_lock(clk);
290
291         return r;
292 }
293
294 /**
295  * omap3_noncore_dpll_enable - instruct a DPLL to enter bypass or lock mode
296  * @clk: pointer to a DPLL struct clk
297  *
298  * Instructs a non-CORE DPLL to enable, e.g., to enter bypass or lock.
299  * The choice of modes depends on the DPLL's programmed rate: if it is
300  * the same as the DPLL's parent clock, it will enter bypass;
301  * otherwise, it will enter lock.  This code will wait for the DPLL to
302  * indicate readiness before returning, unless the DPLL takes too long
303  * to enter the target state.  Intended to be used as the struct clk's
304  * enable function.  If DPLL3 was passed in, or the DPLL does not
305  * support low-power stop, or if the DPLL took too long to enter
306  * bypass or lock, return -EINVAL; otherwise, return 0.
307  */
308 static void omap3_noncore_dpll_disable(struct clk *clk)
309 {
310         if (clk == &dpll3_ck)
311                 return;
312
313         _omap3_noncore_dpll_stop(clk);
314 }
315
316
317 /* Non-CORE DPLL rate set code */
318
319 /*
320  * omap3_noncore_dpll_program - set non-core DPLL M,N values directly
321  * @clk: struct clk * of DPLL to set
322  * @m: DPLL multiplier to set
323  * @n: DPLL divider to set
324  * @freqsel: FREQSEL value to set
325  *
326  * Program the DPLL with the supplied M, N values, and wait for the DPLL to
327  * lock..  Returns -EINVAL upon error, or 0 upon success.
328  */
329 static int omap3_noncore_dpll_program(struct clk *clk, u16 m, u8 n, u16 freqsel)
330 {
331         struct dpll_data *dd;
332         u32 v;
333
334         if (!clk)
335                 return -EINVAL;
336
337         dd = clk->dpll_data;
338         if (!dd)
339                 return -EINVAL;
340
341         /*
342          * According to the 12-5 CDP code from TI, "Limitation 2.5"
343          * on 3430ES1 prevents us from changing DPLL multipliers or dividers
344          * on DPLL4.
345          */
346         if (omap_rev() == OMAP3430_REV_ES1_0 &&
347             !strcmp("dpll4_ck", clk->name)) {
348                 printk(KERN_ERR "clock: DPLL4 cannot change rate due to "
349                        "silicon 'Limitation 2.5' on 3430ES1.\n");
350                 return -EINVAL;
351         }
352
353         /* 3430 ES2 TRM: 4.7.6.9 DPLL Programming Sequence */
354         _omap3_noncore_dpll_bypass(clk);
355
356         /* Set jitter correction */
357         v = cm_read_mod_reg(clk->prcm_mod, dd->control_reg);
358         v &= ~dd->freqsel_mask;
359         v |= freqsel << __ffs(dd->freqsel_mask);
360         cm_write_mod_reg(v, clk->prcm_mod, dd->control_reg);
361
362         /* Set DPLL multiplier, divider */
363         v = cm_read_mod_reg(clk->prcm_mod, dd->mult_div1_reg);
364         v &= ~(dd->mult_mask | dd->div1_mask);
365         v |= m << __ffs(dd->mult_mask);
366         v |= (n - 1) << __ffs(dd->div1_mask);
367         cm_write_mod_reg(v, clk->prcm_mod, dd->mult_div1_reg);
368
369         /* We let the clock framework set the other output dividers later */
370
371         /* REVISIT: Set ramp-up delay? */
372
373         _omap3_noncore_dpll_lock(clk);
374
375         return 0;
376 }
377
378 /**
379  * omap3_noncore_dpll_set_rate - set non-core DPLL rate
380  * @clk: struct clk * of DPLL to set
381  * @rate: rounded target rate
382  *
383  * Set the DPLL CLKOUT to the target rate.  If the DPLL can enter
384  * low-power bypass, and the target rate is the bypass source clock
385  * rate, then configure the DPLL for bypass.  Otherwise, round the
386  * target rate if it hasn't been done already, then program and lock
387  * the DPLL.  Returns -EINVAL upon error, or 0 upon success.
388  */
389 static int omap3_noncore_dpll_set_rate(struct clk *clk, unsigned long rate)
390 {
391         u16 freqsel;
392         struct dpll_data *dd;
393         int ret;
394
395         if (!clk || !rate)
396                 return -EINVAL;
397
398         dd = clk->dpll_data;
399         if (!dd)
400                 return -EINVAL;
401
402         if (rate == omap2_get_dpll_rate(clk, clk->parent->rate))
403                 return 0;
404
405         if (dd->bypass_clk->rate == rate &&
406             (clk->dpll_data->modes & (1 << DPLL_LOW_POWER_BYPASS))) {
407
408                 pr_debug("clock: %s: set rate: entering bypass.\n", clk->name);
409
410                 ret = _omap3_noncore_dpll_bypass(clk);
411                 if (!ret)
412                         clk->rate = rate;
413
414         } else {
415
416                 if (dd->last_rounded_rate != rate)
417                         omap2_dpll_round_rate(clk, rate);
418
419                 if (dd->last_rounded_rate == 0)
420                         return -EINVAL;
421
422                 freqsel = _omap3_dpll_compute_freqsel(clk, dd->last_rounded_n);
423                 if (!freqsel)
424                         WARN_ON(1);
425
426                 pr_debug("clock: %s: set rate: locking rate to %lu.\n",
427                          clk->name, rate);
428
429                 ret = omap3_noncore_dpll_program(clk, dd->last_rounded_m,
430                                                  dd->last_rounded_n, freqsel);
431
432                 if (!ret)
433                         clk->rate = rate;
434
435         }
436
437         return 0;
438 }
439
440
441 /*
442  * CORE DPLL (DPLL3) rate programming functions
443  *
444  * These call into SRAM code to do the actual CM writes, since the SDRAM
445  * is clocked from DPLL3.
446  */
447
448 /**
449  * omap3_core_dpll_m2_set_rate - set CORE DPLL M2 divider
450  * @clk: struct clk * of DPLL to set
451  * @rate: rounded target rate
452  *
453  * Program the DPLL M2 divider with the rounded target rate.  Returns
454  * -EINVAL upon error, or 0 upon success.
455  */
456 static int omap3_core_dpll_m2_set_rate(struct clk *clk, unsigned long rate)
457 {
458         u32 new_div = 0;
459         unsigned long validrate, sdrcrate;
460         struct omap_sdrc_params *sp;
461
462         if (!clk || !rate)
463                 return -EINVAL;
464
465         if (clk != &dpll3_m2_ck)
466                 return -EINVAL;
467
468         if (rate == clk->rate)
469                 return 0;
470
471         validrate = omap2_clksel_round_rate_div(clk, rate, &new_div);
472         if (validrate != rate)
473                 return -EINVAL;
474
475         sdrcrate = sdrc_ick.rate;
476         if (rate > clk->rate)
477                 sdrcrate <<= ((rate / clk->rate) - 1);
478         else
479                 sdrcrate >>= ((clk->rate / rate) - 1);
480
481         sp = omap2_sdrc_get_params(sdrcrate);
482         if (!sp)
483                 return -EINVAL;
484
485         pr_info("clock: changing CORE DPLL rate from %lu to %lu\n", clk->rate,
486                 validrate);
487         pr_info("clock: SDRC timing params used: %08x %08x %08x\n",
488                 sp->rfr_ctrl, sp->actim_ctrla, sp->actim_ctrlb);
489
490         /* REVISIT: SRAM code doesn't support other M2 divisors yet */
491         WARN_ON(new_div != 1 && new_div != 2);
492
493         /* REVISIT: Add SDRC_MR changing to this code also */
494         local_irq_disable();
495         omap3_configure_core_dpll(sp->rfr_ctrl, sp->actim_ctrla,
496                                   sp->actim_ctrlb, new_div);
497         local_irq_enable();
498
499         return 0;
500 }
501
502
503 /* DPLL autoidle read/set code */
504
505
506 /**
507  * omap3_dpll_autoidle_read - read a DPLL's autoidle bits
508  * @clk: struct clk * of the DPLL to read
509  *
510  * Return the DPLL's autoidle bits, shifted down to bit 0.  Returns
511  * -EINVAL if passed a null pointer or if the struct clk does not
512  * appear to refer to a DPLL.
513  */
514 static u32 omap3_dpll_autoidle_read(struct clk *clk)
515 {
516         const struct dpll_data *dd;
517         u32 v;
518
519         if (!clk || !clk->dpll_data)
520                 return -EINVAL;
521
522         dd = clk->dpll_data;
523
524         v = cm_read_mod_reg(clk->prcm_mod, dd->autoidle_reg);
525         v &= dd->autoidle_mask;
526         v >>= __ffs(dd->autoidle_mask);
527
528         return v;
529 }
530
531 /**
532  * omap3_dpll_allow_idle - enable DPLL autoidle bits
533  * @clk: struct clk * of the DPLL to operate on
534  *
535  * Enable DPLL automatic idle control.  This automatic idle mode
536  * switching takes effect only when the DPLL is locked, at least on
537  * OMAP3430.  The DPLL will enter low-power stop when its downstream
538  * clocks are gated.  No return value.
539  */
540 static void omap3_dpll_allow_idle(struct clk *clk)
541 {
542         const struct dpll_data *dd;
543         u32 v;
544
545         if (!clk || !clk->dpll_data)
546                 return;
547
548         dd = clk->dpll_data;
549
550         /*
551          * REVISIT: CORE DPLL can optionally enter low-power bypass
552          * by writing 0x5 instead of 0x1.  Add some mechanism to
553          * optionally enter this mode.
554          */
555         v = cm_read_mod_reg(clk->prcm_mod, dd->autoidle_reg);
556         v &= ~dd->autoidle_mask;
557         v |= DPLL_AUTOIDLE_LOW_POWER_STOP << __ffs(dd->autoidle_mask);
558         cm_write_mod_reg(v, clk->prcm_mod, dd->autoidle_reg);
559 }
560
561 /**
562  * omap3_dpll_deny_idle - prevent DPLL from automatically idling
563  * @clk: struct clk * of the DPLL to operate on
564  *
565  * Disable DPLL automatic idle control.  No return value.
566  */
567 static void omap3_dpll_deny_idle(struct clk *clk)
568 {
569         const struct dpll_data *dd;
570         u32 v;
571
572         if (!clk || !clk->dpll_data)
573                 return;
574
575         dd = clk->dpll_data;
576
577         v = cm_read_mod_reg(clk->prcm_mod, dd->autoidle_reg);
578         v &= ~dd->autoidle_mask;
579         v |= DPLL_AUTOIDLE_DISABLE << __ffs(dd->autoidle_mask);
580         cm_write_mod_reg(v, clk->prcm_mod, dd->autoidle_reg);
581 }
582
583 /* Clock control for DPLL outputs */
584
585 /**
586  * omap3_clkoutx2_recalc - recalculate DPLL X2 output virtual clock rate
587  * @clk: DPLL output struct clk
588  * @parent_rate: rate of the parent clock of @clk
589  * @rate_storage: flag indicating whether current or temporary rate is changing
590  *
591  * Using parent clock DPLL data, look up DPLL state.  If locked, set our
592  * rate to the dpll_clk * 2; otherwise, just use dpll_clk.
593  */
594 static void omap3_clkoutx2_recalc(struct clk *clk, unsigned long parent_rate,
595                                   u8 rate_storage)
596 {
597         const struct dpll_data *dd;
598         u32 v;
599         unsigned long rate;
600         struct clk *pclk;
601
602         /* Walk up the parents of clk, looking for a DPLL */
603         pclk = clk->parent;
604         while (pclk && !pclk->dpll_data)
605                 pclk = pclk->parent;
606
607         /* clk does not have a DPLL as a parent? */
608         WARN_ON(!pclk);
609
610         dd = pclk->dpll_data;
611
612         WARN_ON(!dd->enable_mask);
613
614         rate = parent_rate;
615
616         v = cm_read_mod_reg(pclk->prcm_mod, dd->control_reg) & dd->enable_mask;
617         v >>= __ffs(dd->enable_mask);
618         if (v == OMAP3XXX_EN_DPLL_LOCKED)
619                 rate *= 2;
620
621         if (rate_storage == CURRENT_RATE)
622                 clk->rate = rate;
623         else if (rate_storage == TEMP_RATE)
624                 clk->temp_rate = rate;
625 }
626
627 /* Common clock code */
628
629 /*
630  * As it is structured now, this will prevent an OMAP2/3 multiboot
631  * kernel from compiling.  This will need further attention.
632  */
633 #if defined(CONFIG_ARCH_OMAP3)
634
635 static struct clk_functions omap2_clk_functions = {
636         .clk_enable             = omap2_clk_enable,
637         .clk_disable            = omap2_clk_disable,
638         .clk_round_rate         = omap2_clk_round_rate,
639         .clk_set_rate           = omap2_clk_set_rate,
640         .clk_set_parent         = omap2_clk_set_parent,
641         .clk_get_parent         = omap2_clk_get_parent,
642         .clk_disable_unused     = omap2_clk_disable_unused,
643 };
644
645 /*
646  * Set clocks for bypass mode for reboot to work.
647  */
648 void omap2_clk_prepare_for_reboot(void)
649 {
650         /* REVISIT: Not ready for 343x */
651 #if 0
652         u32 rate;
653
654         if (vclk == NULL || sclk == NULL)
655                 return;
656
657         rate = clk_get_rate(sclk);
658         clk_set_rate(vclk, rate);
659 #endif
660 }
661
662 /* REVISIT: Move this init stuff out into clock.c */
663
664 /*
665  * Switch the MPU rate if specified on cmdline.
666  * We cannot do this early until cmdline is parsed.
667  */
668 static int __init omap2_clk_arch_init(void)
669 {
670         if (!mpurate)
671                 return -EINVAL;
672
673         /* REVISIT: not yet ready for 343x */
674 #if 0
675         if (clk_set_rate(&virt_prcm_set, mpurate))
676                 printk(KERN_ERR "Could not find matching MPU rate\n");
677 #endif
678
679         recalculate_root_clocks();
680
681         printk(KERN_INFO "Switched to new clocking rate (Crystal/DPLL3/MPU): "
682                "%ld.%01ld/%ld/%ld MHz\n",
683                (osc_sys_ck.rate / 1000000), (osc_sys_ck.rate / 100000) % 10,
684                (core_ck.rate / 1000000), (dpll1_fck.rate / 1000000)) ;
685
686         return 0;
687 }
688 arch_initcall(omap2_clk_arch_init);
689
690 int __init omap2_clk_init(void)
691 {
692         /* struct prcm_config *prcm; */
693         struct clk **clkp;
694         /* u32 clkrate; */
695         u32 cpu_clkflg;
696
697         /* REVISIT: Ultimately this will be used for multiboot */
698 #if 0
699         if (cpu_is_omap242x()) {
700                 cpu_mask = RATE_IN_242X;
701                 cpu_clkflg = CLOCK_IN_OMAP242X;
702                 clkp = onchip_24xx_clks;
703         } else if (cpu_is_omap2430()) {
704                 cpu_mask = RATE_IN_243X;
705                 cpu_clkflg = CLOCK_IN_OMAP243X;
706                 clkp = onchip_24xx_clks;
707         }
708 #endif
709         if (cpu_is_omap34xx()) {
710                 cpu_mask = RATE_IN_343X;
711                 cpu_clkflg = CLOCK_IN_OMAP343X;
712                 clkp = onchip_34xx_clks;
713
714                 /*
715                  * Update this if there are further clock changes between ES2
716                  * and production parts
717                  */
718                 if (omap_rev() == OMAP3430_REV_ES1_0) {
719                         /* No 3430ES1-only rates exist, so no RATE_IN_3430ES1 */
720                         cpu_clkflg |= CLOCK_IN_OMAP3430ES1;
721                 } else {
722                         cpu_mask |= RATE_IN_3430ES2;
723                         cpu_clkflg |= CLOCK_IN_OMAP3430ES2;
724                 }
725         }
726
727         clk_init(&omap2_clk_functions);
728
729         for (clkp = onchip_34xx_clks;
730              clkp < onchip_34xx_clks + ARRAY_SIZE(onchip_34xx_clks);
731              clkp++) {
732                 if ((*clkp)->flags & cpu_clkflg) {
733                         clk_register(*clkp);
734                         omap2_init_clk_clkdm(*clkp);
735                 }
736         }
737
738         /* REVISIT: Not yet ready for OMAP3 */
739 #if 0
740         /* Check the MPU rate set by bootloader */
741         clkrate = omap2_get_dpll_rate_24xx(&dpll_ck);
742         for (prcm = rate_table; prcm->mpu_speed; prcm++) {
743                 if (!(prcm->flags & cpu_mask))
744                         continue;
745                 if (prcm->xtal_speed != sys_ck.rate)
746                         continue;
747                 if (prcm->dpll_speed <= clkrate)
748                          break;
749         }
750         curr_prcm_set = prcm;
751 #endif
752
753         recalculate_root_clocks();
754
755         printk(KERN_INFO "Clocking rate (Crystal/DPLL/ARM core): "
756                "%ld.%01ld/%ld/%ld MHz\n",
757                (osc_sys_ck.rate / 1000000), (osc_sys_ck.rate / 100000) % 10,
758                (core_ck.rate / 1000000), (arm_fck.rate / 1000000));
759
760         /*
761          * Only enable those clocks we will need, let the drivers
762          * enable other clocks as necessary
763          */
764         clk_enable_init_clocks();
765
766         /* Avoid sleeping during omap2_clk_prepare_for_reboot() */
767         /* REVISIT: not yet ready for 343x */
768 #if 0
769         vclk = clk_get(NULL, "virt_prcm_set");
770         sclk = clk_get(NULL, "sys_ck");
771 #endif
772         return 0;
773 }
774
775 #endif