2 * arch/sh/kernel/cpu/sh4a/clock-sh7722.c
4 * SH7343, SH7722 & SH7366 support for the clock framework
6 * Copyright (c) 2006-2007 Nomad Global Solutions Inc
7 * Based on code for sh7343 by Paul Mundt
9 * This file is subject to the terms and conditions of the GNU General Public
10 * License. See the file "COPYING" in the main directory of this archive
13 #include <linux/init.h>
14 #include <linux/kernel.h>
16 #include <linux/errno.h>
17 #include <linux/stringify.h>
18 #include <asm/clock.h>
23 #define ROUND_NEAREST 0
27 static int adjust_algos[][3] = {
29 { NM, N, 1 }, /* N:1, N:1 */
30 { 3, 2, 2 }, /* 3:2:2 */
31 { 5, 2, 2 }, /* 5:2:2 */
32 { N, 1, 1 }, /* N:1:1 */
44 static unsigned long adjust_pair_of_clocks(unsigned long r1, unsigned long r2,
45 int m1, int m2, int round_flag)
47 unsigned long rem, div;
50 pr_debug( "Actual values: r1 = %ld\n", r1);
51 pr_debug( "...............r2 = %ld\n", r2);
55 pr_debug( "setting equal rates: r2 now %ld\n", r2);
56 } else if ((m2 == N && m1 == 1) ||
57 (m2 == NM && m1 == N)) { /* N:1 or NM:N */
58 pr_debug( "Setting rates as 1:N (N:N*M)\n");
60 pr_debug( "...remainder = %ld\n", rem);
63 pr_debug( "...div = %ld\n", div);
66 the_one = rem >= r1/2 ? 1 : 0; break;
73 r2 = r1 * (div + the_one);
74 pr_debug( "...setting r2 to %ld\n", r2);
76 } else if ((m2 == 1 && m1 == N) ||
77 (m2 == N && m1 == NM)) { /* 1:N or N:NM */
78 pr_debug( "Setting rates as N:1 (N*M:N)\n");
80 pr_debug( "...remainder = %ld\n", rem);
83 pr_debug( "...div = %ld\n", div);
86 the_one = rem > r2/2 ? 1 : 0; break;
93 r2 = r1 / (div + the_one);
94 pr_debug( "...setting r2 to %ld\n", r2);
96 } else { /* value:value */
97 pr_debug( "Setting rates as %d:%d\n", m1, m2);
100 pr_debug( "...div = %ld\n", div);
101 pr_debug( "...setting r2 to %ld\n", r2);
107 static void adjust_clocks(int originate, int *l, unsigned long v[],
112 pr_debug( "Go down from %d...\n", originate);
113 /* go up recalculation clocks */
114 for (x = originate; x>0; x -- )
115 v[x-1] = adjust_pair_of_clocks(v[x], v[x-1],
119 pr_debug( "Go up from %d...\n", originate);
120 /* go down recalculation clocks */
121 for (x = originate; x<n_in_line - 1; x ++ )
122 v[x+1] = adjust_pair_of_clocks(v[x], v[x+1],
129 * SH7722 uses a common set of multipliers and divisors, so this
133 #if defined(CONFIG_CPU_SUBTYPE_SH7724)
134 #define STCPLL(frqcr) ((((frqcr >> 24) & 0x3f) + 1) * 2)
136 #define STCPLL(frqcr) (((frqcr >> 24) & 0x1f) + 1)
140 * Instead of having two separate multipliers/divisors set, like this:
142 * static int multipliers[] = { 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
143 * static int divisors[] = { 1, 3, 2, 5, 3, 4, 5, 6, 8, 10, 12, 16, 20 };
145 * I created the divisors2 array, which is used to calculate rate like
146 * rate = parent * 2 / divisors2[ divisor ];
148 #if defined(CONFIG_CPU_SUBTYPE_SH7724)
149 static int divisors2[] = { 4, 1, 8, 12, 16, 24, 32, 1, 48, 64, 72, 96, 1, 144 };
151 static int divisors2[] = { 2, 3, 4, 5, 6, 8, 10, 12, 16, 20, 24, 32, 40 };
154 static unsigned long master_clk_recalc(struct clk *clk)
156 unsigned frqcr = ctrl_inl(FRQCR);
158 return CONFIG_SH_PCLK_FREQ * STCPLL(frqcr);
161 static void master_clk_init(struct clk *clk)
164 clk->rate = master_clk_recalc(clk);
167 static unsigned long module_clk_recalc(struct clk *clk)
169 unsigned long frqcr = ctrl_inl(FRQCR);
171 return clk->parent->rate / STCPLL(frqcr);
174 #if defined(CONFIG_CPU_SUBTYPE_SH7724)
175 #define MASTERDIVS { 12, 16, 24, 30, 32, 36, 48 }
177 #define DIVCALC(div) (div/2-1)
178 #define FRQCRKICK 0x80000000
180 #define MASTERDIVS { 2, 3, 4, 6, 8, 16 }
182 #define DIVCALC(div) (div-1)
183 #define FRQCRKICK 0x00000000
186 static int master_clk_setrate(struct clk *clk, unsigned long rate, int id)
188 int div = rate / clk->rate;
189 int master_divs[] = MASTERDIVS;
193 for (index = 1; index < ARRAY_SIZE(master_divs); index++)
194 if (div >= master_divs[index - 1] && div < master_divs[index])
197 if (index >= ARRAY_SIZE(master_divs))
198 index = ARRAY_SIZE(master_divs);
199 div = master_divs[index - 1];
201 frqcr = ctrl_inl(FRQCR);
202 frqcr &= ~(STCMASK << 24);
203 frqcr |= (DIVCALC(div) << 24);
205 ctrl_outl(frqcr, FRQCR);
210 static struct clk_ops sh7722_master_clk_ops = {
211 .init = master_clk_init,
212 .recalc = master_clk_recalc,
213 .set_rate = master_clk_setrate,
216 static struct clk_ops sh7722_module_clk_ops = {
217 .recalc = module_clk_recalc,
220 struct frqcr_context {
225 struct frqcr_context sh7722_get_clk_context(const char *name)
227 struct frqcr_context ctx = { 0, };
229 if (!strcmp(name, "peripheral_clk")) {
232 } else if (!strcmp(name, "sdram_clk")) {
235 } else if (!strcmp(name, "bus_clk")) {
238 } else if (!strcmp(name, "sh_clk")) {
241 } else if (!strcmp(name, "umem_clk")) {
244 } else if (!strcmp(name, "cpu_clk")) {
252 * sh7722_find_div_index - find divisor for setting rate
254 * All sh7722 clocks use the same set of multipliers/divisors. This function
255 * chooses correct divisor to set the rate of clock with parent clock that
256 * generates frequency of 'parent_rate'
258 * @parent_rate: rate of parent clock
259 * @rate: requested rate to be set
261 static int sh7722_find_div_index(unsigned long parent_rate, unsigned rate)
263 unsigned div2 = parent_rate * 2 / rate;
266 if (rate > parent_rate)
269 for (index = 1; index < ARRAY_SIZE(divisors2); index++) {
270 if (div2 > divisors2[index - 1] && div2 <= divisors2[index])
273 if (index >= ARRAY_SIZE(divisors2))
274 index = ARRAY_SIZE(divisors2) - 1;
278 static unsigned long sh7722_frqcr_recalc(struct clk *clk)
280 struct frqcr_context ctx = sh7722_get_clk_context(clk->name);
281 unsigned long frqcr = ctrl_inl(FRQCR);
284 index = (frqcr >> ctx.shift) & ctx.mask;
285 return clk->parent->rate * 2 / divisors2[index];
288 static int sh7722_frqcr_set_rate(struct clk *clk, unsigned long rate,
291 struct frqcr_context ctx = sh7722_get_clk_context(clk->name);
292 unsigned long parent_rate = clk->parent->rate;
298 if (parent_rate < rate)
301 /* look for multiplier/divisor pair */
302 div = sh7722_find_div_index(parent_rate, rate);
306 /* calculate new value of clock rate */
307 clk->rate = parent_rate * 2 / divisors2[div];
308 frqcr = ctrl_inl(FRQCR);
310 /* FIXME: adjust as algo_id specifies */
311 if (algo_id != NO_CHANGE) {
313 char *algo_group_1[] = { "cpu_clk", "umem_clk", "sh_clk" };
314 char *algo_group_2[] = { "sh_clk", "bus_clk" };
315 char *algo_group_3[] = { "sh_clk", "sdram_clk" };
316 char *algo_group_4[] = { "bus_clk", "peripheral_clk" };
317 char *algo_group_5[] = { "cpu_clk", "peripheral_clk" };
318 char **algo_current = NULL;
319 /* 3 is the maximum number of clocks in relation */
321 unsigned long values[3]; /* the same comment as above */
322 int part_length = -1;
326 * all the steps below only required if adjustion was
329 if (algo_id == IUS_N1_N1 ||
330 algo_id == IUS_322 ||
331 algo_id == IUS_522 ||
332 algo_id == IUS_N11) {
333 algo_current = algo_group_1;
336 if (algo_id == SB_N1) {
337 algo_current = algo_group_2;
340 if (algo_id == SB3_N1 ||
344 algo_current = algo_group_3;
347 if (algo_id == BP_N1) {
348 algo_current = algo_group_4;
351 if (algo_id == IP_N1) {
352 algo_current = algo_group_5;
356 goto incorrect_algo_id;
359 for (i = 0; i < part_length; i ++ ) {
360 if (originator >= 0 && !strcmp(clk->name,
363 ck[i] = clk_get(NULL, algo_current[i]);
364 values[i] = clk_get_rate(ck[i]);
368 adjust_clocks(originator, adjust_algos[algo_id],
369 values, part_length);
371 for (i = 0; i < part_length; i ++ ) {
372 struct frqcr_context part_ctx;
376 part_div = sh7722_find_div_index(parent_rate,
379 part_ctx = sh7722_get_clk_context(
381 frqcr &= ~(part_ctx.mask <<
383 frqcr |= part_div << part_ctx.shift;
388 ck[i]->ops->recalc(ck[i]);
393 /* was there any error during recalculation ? If so, bail out.. */
394 if (unlikely(err!=0))
397 /* clear FRQCR bits */
398 frqcr &= ~(ctx.mask << ctx.shift);
399 frqcr |= div << ctx.shift;
402 /* ...and perform actual change */
403 ctrl_outl(frqcr, FRQCR);
412 static long sh7722_frqcr_round_rate(struct clk *clk, unsigned long rate)
414 unsigned long parent_rate = clk->parent->rate;
417 /* look for multiplier/divisor pair */
418 div = sh7722_find_div_index(parent_rate, rate);
422 /* calculate new value of clock rate */
423 return parent_rate * 2 / divisors2[div];
426 static struct clk_ops sh7722_frqcr_clk_ops = {
427 .recalc = sh7722_frqcr_recalc,
428 .set_rate = sh7722_frqcr_set_rate,
429 .round_rate = sh7722_frqcr_round_rate,
433 * clock ops methods for SIU A/B and IrDA clock
435 #ifndef CONFIG_CPU_SUBTYPE_SH7343
436 static int sh7722_siu_set_rate(struct clk *clk, unsigned long rate, int algo_id)
441 r = ctrl_inl(clk->arch_flags);
442 div = sh7722_find_div_index(clk->parent->rate, rate);
445 r = (r & ~0xF) | div;
446 ctrl_outl(r, clk->arch_flags);
450 static unsigned long sh7722_siu_recalc(struct clk *clk)
454 r = ctrl_inl(clk->arch_flags);
455 return clk->parent->rate * 2 / divisors2[r & 0xF];
458 static int sh7722_siu_start_stop(struct clk *clk, int enable)
462 r = ctrl_inl(clk->arch_flags);
464 ctrl_outl(r & ~(1 << 8), clk->arch_flags);
466 ctrl_outl(r | (1 << 8), clk->arch_flags);
470 static int sh7722_siu_enable(struct clk *clk)
472 return sh7722_siu_start_stop(clk, 1);
475 static void sh7722_siu_disable(struct clk *clk)
477 sh7722_siu_start_stop(clk, 0);
480 static struct clk_ops sh7722_siu_clk_ops = {
481 .recalc = sh7722_siu_recalc,
482 .set_rate = sh7722_siu_set_rate,
483 .enable = sh7722_siu_enable,
484 .disable = sh7722_siu_disable,
487 #endif /* CONFIG_CPU_SUBTYPE_SH7343 */
489 static int sh7722_video_enable(struct clk *clk)
493 r = ctrl_inl(VCLKCR);
494 ctrl_outl( r & ~(1<<8), VCLKCR);
498 static void sh7722_video_disable(struct clk *clk)
502 r = ctrl_inl(VCLKCR);
503 ctrl_outl( r | (1<<8), VCLKCR);
506 static int sh7722_video_set_rate(struct clk *clk, unsigned long rate,
511 r = ctrl_inl(VCLKCR);
513 r |= ((clk->parent->rate / rate - 1) & 0x3F);
514 ctrl_outl(r, VCLKCR);
518 static unsigned long sh7722_video_recalc(struct clk *clk)
522 r = ctrl_inl(VCLKCR);
523 return clk->parent->rate / ((r & 0x3F) + 1);
526 static struct clk_ops sh7722_video_clk_ops = {
527 .recalc = sh7722_video_recalc,
528 .set_rate = sh7722_video_set_rate,
529 .enable = sh7722_video_enable,
530 .disable = sh7722_video_disable,
533 * and at last, clock definitions themselves
535 static struct clk sh7722_umem_clock = {
537 .ops = &sh7722_frqcr_clk_ops,
540 static struct clk sh7722_sh_clock = {
542 .ops = &sh7722_frqcr_clk_ops,
545 static struct clk sh7722_peripheral_clock = {
546 .name = "peripheral_clk",
547 .ops = &sh7722_frqcr_clk_ops,
550 static struct clk sh7722_sdram_clock = {
552 .ops = &sh7722_frqcr_clk_ops,
555 static struct clk sh7722_r_clock = {
560 #if !defined(CONFIG_CPU_SUBTYPE_SH7343) &&\
561 !defined(CONFIG_CPU_SUBTYPE_SH7724)
563 * these three clocks - SIU A, SIU B, IrDA - share the same clk_ops
564 * methods of clk_ops determine which register they should access by
565 * examining clk->name field
567 static struct clk sh7722_siu_a_clock = {
569 .arch_flags = SCLKACR,
570 .ops = &sh7722_siu_clk_ops,
573 static struct clk sh7722_siu_b_clock = {
575 .arch_flags = SCLKBCR,
576 .ops = &sh7722_siu_clk_ops,
578 #endif /* CONFIG_CPU_SUBTYPE_SH7343, SH7724 */
580 #if defined(CONFIG_CPU_SUBTYPE_SH7722) ||\
581 defined(CONFIG_CPU_SUBTYPE_SH7724)
582 static struct clk sh7722_irda_clock = {
584 .arch_flags = IrDACLKCR,
585 .ops = &sh7722_siu_clk_ops,
589 static struct clk sh7722_video_clock = {
591 .ops = &sh7722_video_clk_ops,
594 #define MSTPCR_ARCH_FLAGS(reg, bit) (((reg) << 8) | (bit))
595 #define MSTPCR_ARCH_FLAGS_REG(value) ((value) >> 8)
596 #define MSTPCR_ARCH_FLAGS_BIT(value) ((value) & 0xff)
598 static int sh7722_mstpcr_start_stop(struct clk *clk, int enable)
600 unsigned long bit = MSTPCR_ARCH_FLAGS_BIT(clk->arch_flags);
604 switch(MSTPCR_ARCH_FLAGS_REG(clk->arch_flags)) {
629 static int sh7722_mstpcr_enable(struct clk *clk)
631 return sh7722_mstpcr_start_stop(clk, 1);
634 static void sh7722_mstpcr_disable(struct clk *clk)
636 sh7722_mstpcr_start_stop(clk, 0);
639 static struct clk_ops sh7722_mstpcr_clk_ops = {
640 .enable = sh7722_mstpcr_enable,
641 .disable = sh7722_mstpcr_disable,
642 .recalc = followparent_recalc,
645 #define MSTPCR(_name, _parent, regnr, bitnr, _flags) \
649 .arch_flags = MSTPCR_ARCH_FLAGS(regnr, bitnr), \
650 .ops = (void *)_parent, \
653 static struct clk sh7722_mstpcr_clocks[] = {
654 #if defined(CONFIG_CPU_SUBTYPE_SH7722)
655 MSTPCR("uram0", "umem_clk", 0, 28, CLK_ENABLE_ON_INIT),
656 MSTPCR("xymem0", "bus_clk", 0, 26, CLK_ENABLE_ON_INIT),
657 MSTPCR("tmu0", "peripheral_clk", 0, 15, 0),
658 MSTPCR("cmt0", "r_clk", 0, 14, 0),
659 MSTPCR("rwdt0", "r_clk", 0, 13, 0),
660 MSTPCR("flctl0", "peripheral_clk", 0, 10, 0),
661 MSTPCR("scif0", "peripheral_clk", 0, 7, 0),
662 MSTPCR("scif1", "peripheral_clk", 0, 6, 0),
663 MSTPCR("scif2", "peripheral_clk", 0, 5, 0),
664 MSTPCR("i2c0", "peripheral_clk", 1, 9, 0),
665 MSTPCR("rtc0", "r_clk", 1, 8, 0),
666 MSTPCR("sdhi0", "peripheral_clk", 2, 18, 0),
667 MSTPCR("keysc0", "r_clk", 2, 14, 0),
668 MSTPCR("usbf0", "peripheral_clk", 2, 11, 0),
669 MSTPCR("2dg0", "bus_clk", 2, 9, 0),
670 MSTPCR("siu0", "bus_clk", 2, 8, 0),
671 MSTPCR("vou0", "bus_clk", 2, 5, 0),
672 MSTPCR("jpu0", "bus_clk", 2, 6, CLK_ENABLE_ON_INIT),
673 MSTPCR("beu0", "bus_clk", 2, 4, 0),
674 MSTPCR("ceu0", "bus_clk", 2, 3, 0),
675 MSTPCR("veu0", "bus_clk", 2, 2, CLK_ENABLE_ON_INIT),
676 MSTPCR("vpu0", "bus_clk", 2, 1, CLK_ENABLE_ON_INIT),
677 MSTPCR("lcdc0", "bus_clk", 2, 0, 0),
679 #if defined(CONFIG_CPU_SUBTYPE_SH7724)
680 /* See Datasheet : Overview -> Block Diagram */
681 MSTPCR("tlb0", "cpu_clk", 0, 31, 0),
682 MSTPCR("ic0", "cpu_clk", 0, 30, 0),
683 MSTPCR("oc0", "cpu_clk", 0, 29, 0),
684 MSTPCR("rs0", "bus_clk", 0, 28, 0),
685 MSTPCR("ilmem0", "cpu_clk", 0, 27, 0),
686 MSTPCR("l2c0", "sh_clk", 0, 26, 0),
687 MSTPCR("fpu0", "cpu_clk", 0, 24, 0),
688 MSTPCR("intc0", "peripheral_clk", 0, 22, 0),
689 MSTPCR("dmac0", "bus_clk", 0, 21, 0),
690 MSTPCR("sh0", "sh_clk", 0, 20, 0),
691 MSTPCR("hudi0", "peripheral_clk", 0, 19, 0),
692 MSTPCR("ubc0", "cpu_clk", 0, 17, 0),
693 MSTPCR("tmu0", "peripheral_clk", 0, 15, 0),
694 MSTPCR("cmt0", "r_clk", 0, 14, 0),
695 MSTPCR("rwdt0", "r_clk", 0, 13, 0),
696 MSTPCR("dmac1", "bus_clk", 0, 12, 0),
697 MSTPCR("tmu1", "peripheral_clk", 0, 10, 0),
698 MSTPCR("scif0", "peripheral_clk", 0, 9, 0),
699 MSTPCR("scif1", "peripheral_clk", 0, 8, 0),
700 MSTPCR("scif2", "peripheral_clk", 0, 7, 0),
701 MSTPCR("scif3", "bus_clk", 0, 6, 0),
702 MSTPCR("scif4", "bus_clk", 0, 5, 0),
703 MSTPCR("scif5", "bus_clk", 0, 4, 0),
704 MSTPCR("msiof0", "bus_clk", 0, 2, 0),
705 MSTPCR("msiof1", "bus_clk", 0, 1, 0),
706 MSTPCR("keysc0", "r_clk", 1, 12, 0),
707 MSTPCR("rtc0", "r_clk", 1, 11, 0),
708 MSTPCR("i2c0", "peripheral_clk", 1, 9, 0),
709 MSTPCR("i2c1", "peripheral_clk", 1, 8, 0),
710 MSTPCR("mmc0", "bus_clk", 2, 29, 0),
711 MSTPCR("eth0", "bus_clk", 2, 28, 0),
712 MSTPCR("atapi0", "bus_clk", 2, 26, 0),
713 MSTPCR("tpu0", "bus_clk", 2, 25, 0),
714 MSTPCR("irda0", "peripheral_clk", 2, 24, 0),
715 MSTPCR("tsif0", "bus_clk", 2, 22, 0),
716 MSTPCR("usb1", "bus_clk", 2, 21, 0),
717 MSTPCR("usb0", "bus_clk", 2, 20, 0),
718 MSTPCR("2dg0", "bus_clk", 2, 19, 0),
719 MSTPCR("sdhi0", "bus_clk", 2, 18, 0),
720 MSTPCR("sdhi1", "bus_clk", 2, 17, 0),
721 MSTPCR("veu1", "bus_clk", 2, 15, CLK_ENABLE_ON_INIT),
722 MSTPCR("ceu1", "bus_clk", 2, 13, 0),
723 MSTPCR("beu1", "bus_clk", 2, 12, 0),
724 MSTPCR("2ddmac0", "sh_clk", 2, 10, 0),
725 MSTPCR("spu0", "bus_clk", 2, 9, 0),
726 MSTPCR("jpu0", "bus_clk", 2, 6, 0),
727 MSTPCR("vou0", "bus_clk", 2, 5, 0),
728 MSTPCR("beu0", "bus_clk", 2, 4, 0),
729 MSTPCR("ceu0", "bus_clk", 2, 3, 0),
730 MSTPCR("veu0", "bus_clk", 2, 2, CLK_ENABLE_ON_INIT),
731 MSTPCR("vpu0", "bus_clk", 2, 1, CLK_ENABLE_ON_INIT),
732 MSTPCR("lcdc0", "bus_clk", 2, 0, 0),
734 #if defined(CONFIG_CPU_SUBTYPE_SH7343)
735 MSTPCR("uram0", "umem_clk", 0, 28, CLK_ENABLE_ON_INIT),
736 MSTPCR("xymem0", "bus_clk", 0, 26, CLK_ENABLE_ON_INIT),
737 MSTPCR("tmu0", "peripheral_clk", 0, 15, 0),
738 MSTPCR("cmt0", "r_clk", 0, 14, 0),
739 MSTPCR("rwdt0", "r_clk", 0, 13, 0),
740 MSTPCR("scif0", "peripheral_clk", 0, 7, 0),
741 MSTPCR("scif1", "peripheral_clk", 0, 6, 0),
742 MSTPCR("scif2", "peripheral_clk", 0, 5, 0),
743 MSTPCR("scif3", "peripheral_clk", 0, 4, 0),
744 MSTPCR("i2c0", "peripheral_clk", 1, 9, 0),
745 MSTPCR("i2c1", "peripheral_clk", 1, 8, 0),
746 MSTPCR("sdhi0", "peripheral_clk", 2, 18, 0),
747 MSTPCR("keysc0", "r_clk", 2, 14, 0),
748 MSTPCR("usbf0", "peripheral_clk", 2, 11, 0),
749 MSTPCR("siu0", "bus_clk", 2, 8, 0),
750 MSTPCR("jpu0", "bus_clk", 2, 6, CLK_ENABLE_ON_INIT),
751 MSTPCR("vou0", "bus_clk", 2, 5, 0),
752 MSTPCR("beu0", "bus_clk", 2, 4, 0),
753 MSTPCR("ceu0", "bus_clk", 2, 3, 0),
754 MSTPCR("veu0", "bus_clk", 2, 2, CLK_ENABLE_ON_INIT),
755 MSTPCR("vpu0", "bus_clk", 2, 1, CLK_ENABLE_ON_INIT),
756 MSTPCR("lcdc0", "bus_clk", 2, 0, 0),
758 #if defined(CONFIG_CPU_SUBTYPE_SH7366)
759 /* See page 52 of Datasheet V0.40: Overview -> Block Diagram */
760 MSTPCR("tlb0", "cpu_clk", 0, 31, 0),
761 MSTPCR("ic0", "cpu_clk", 0, 30, 0),
762 MSTPCR("oc0", "cpu_clk", 0, 29, 0),
763 MSTPCR("rsmem0", "sh_clk", 0, 28, CLK_ENABLE_ON_INIT),
764 MSTPCR("xymem0", "cpu_clk", 0, 26, CLK_ENABLE_ON_INIT),
765 MSTPCR("intc30", "peripheral_clk", 0, 23, 0),
766 MSTPCR("intc0", "peripheral_clk", 0, 22, 0),
767 MSTPCR("dmac0", "bus_clk", 0, 21, 0),
768 MSTPCR("sh0", "sh_clk", 0, 20, 0),
769 MSTPCR("hudi0", "peripheral_clk", 0, 19, 0),
770 MSTPCR("ubc0", "cpu_clk", 0, 17, 0),
771 MSTPCR("tmu0", "peripheral_clk", 0, 15, 0),
772 MSTPCR("cmt0", "r_clk", 0, 14, 0),
773 MSTPCR("rwdt0", "r_clk", 0, 13, 0),
774 MSTPCR("flctl0", "peripheral_clk", 0, 10, 0),
775 MSTPCR("scif0", "peripheral_clk", 0, 7, 0),
776 MSTPCR("scif1", "bus_clk", 0, 6, 0),
777 MSTPCR("scif2", "bus_clk", 0, 5, 0),
778 MSTPCR("msiof0", "peripheral_clk", 0, 2, 0),
779 MSTPCR("sbr0", "peripheral_clk", 0, 1, 0),
780 MSTPCR("i2c0", "peripheral_clk", 1, 9, 0),
781 MSTPCR("icb0", "bus_clk", 2, 27, 0),
782 MSTPCR("meram0", "sh_clk", 2, 26, 0),
783 MSTPCR("dacc0", "peripheral_clk", 2, 24, 0),
784 MSTPCR("dacy0", "peripheral_clk", 2, 23, 0),
785 MSTPCR("tsif0", "bus_clk", 2, 22, 0),
786 MSTPCR("sdhi0", "bus_clk", 2, 18, 0),
787 MSTPCR("mmcif0", "bus_clk", 2, 17, 0),
788 MSTPCR("usb0", "bus_clk", 2, 11, 0),
789 MSTPCR("siu0", "bus_clk", 2, 8, 0),
790 MSTPCR("veu1", "bus_clk", 2, 7, CLK_ENABLE_ON_INIT),
791 MSTPCR("vou0", "bus_clk", 2, 5, 0),
792 MSTPCR("beu0", "bus_clk", 2, 4, 0),
793 MSTPCR("ceu0", "bus_clk", 2, 3, 0),
794 MSTPCR("veu0", "bus_clk", 2, 2, CLK_ENABLE_ON_INIT),
795 MSTPCR("vpu0", "bus_clk", 2, 1, CLK_ENABLE_ON_INIT),
796 MSTPCR("lcdc0", "bus_clk", 2, 0, 0),
800 static struct clk *sh7722_clocks[] = {
803 &sh7722_peripheral_clock,
805 #if !defined(CONFIG_CPU_SUBTYPE_SH7343) &&\
806 !defined(CONFIG_CPU_SUBTYPE_SH7724)
810 /* 7724 should support FSI clock */
811 #if defined(CONFIG_CPU_SUBTYPE_SH7722) || \
812 defined(CONFIG_CPU_SUBTYPE_SH7724)
819 * init in order: master, module, bus, cpu
821 struct clk_ops *onchip_ops[] = {
822 &sh7722_master_clk_ops,
823 &sh7722_module_clk_ops,
824 &sh7722_frqcr_clk_ops,
825 &sh7722_frqcr_clk_ops,
829 arch_init_clk_ops(struct clk_ops **ops, int type)
831 BUG_ON(type < 0 || type >= ARRAY_SIZE(onchip_ops));
832 *ops = onchip_ops[type];
835 int __init arch_clk_init(void)
842 clk = clk_get(NULL, "master_clk");
843 for (i = 0; i < ARRAY_SIZE(sh7722_clocks); i++) {
844 pr_debug( "Registering clock '%s'\n", sh7722_clocks[i]->name);
845 sh7722_clocks[i]->parent = clk;
846 clk_register(sh7722_clocks[i]);
850 clk_register(&sh7722_r_clock);
852 for (i = 0; i < ARRAY_SIZE(sh7722_mstpcr_clocks); i++) {
853 pr_debug( "Registering mstpcr clock '%s'\n",
854 sh7722_mstpcr_clocks[i].name);
855 clk = clk_get(NULL, (void *) sh7722_mstpcr_clocks[i].ops);
856 sh7722_mstpcr_clocks[i].parent = clk;
857 sh7722_mstpcr_clocks[i].ops = &sh7722_mstpcr_clk_ops;
858 clk_register(&sh7722_mstpcr_clocks[i]);
862 propagate_rate(&sh7722_r_clock); /* make sure rate gets propagated */