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