GUI: Fix Tomato RAF theme for all builds. Compilation typo.
[tomato.git] / release / src-rt-6.x.4708 / linux / linux-2.6.36 / arch / sh / kernel / cpu / sh4a / clock-sh7763.c
blob1f1df48008cdfaf7bfe4d15e6a2ba375c3d7583f
1 /*
2 * arch/sh/kernel/cpu/sh4a/clock-sh7763.c
4 * SH7763 support for the clock framework
6 * Copyright (C) 2005 Paul Mundt
7 * Copyright (C) 2007 Yoshihiro Shimoda
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
11 * for more details.
13 #include <linux/init.h>
14 #include <linux/kernel.h>
15 #include <linux/io.h>
16 #include <asm/clkdev.h>
17 #include <asm/clock.h>
18 #include <asm/freq.h>
19 #include <asm/io.h>
21 static int bfc_divisors[] = { 1, 1, 1, 8, 1, 1, 1, 1 };
22 static int p0fc_divisors[] = { 1, 1, 1, 8, 1, 1, 1, 1 };
23 static int cfc_divisors[] = { 1, 1, 4, 1, 1, 1, 1, 1 };
25 static void master_clk_init(struct clk *clk)
27 clk->rate *= p0fc_divisors[(__raw_readl(FRQCR) >> 4) & 0x07];
30 static struct clk_ops sh7763_master_clk_ops = {
31 .init = master_clk_init,
34 static unsigned long module_clk_recalc(struct clk *clk)
36 int idx = ((__raw_readl(FRQCR) >> 4) & 0x07);
37 return clk->parent->rate / p0fc_divisors[idx];
40 static struct clk_ops sh7763_module_clk_ops = {
41 .recalc = module_clk_recalc,
44 static unsigned long bus_clk_recalc(struct clk *clk)
46 int idx = ((__raw_readl(FRQCR) >> 16) & 0x07);
47 return clk->parent->rate / bfc_divisors[idx];
50 static struct clk_ops sh7763_bus_clk_ops = {
51 .recalc = bus_clk_recalc,
54 static struct clk_ops sh7763_cpu_clk_ops = {
55 .recalc = followparent_recalc,
58 static struct clk_ops *sh7763_clk_ops[] = {
59 &sh7763_master_clk_ops,
60 &sh7763_module_clk_ops,
61 &sh7763_bus_clk_ops,
62 &sh7763_cpu_clk_ops,
65 void __init arch_init_clk_ops(struct clk_ops **ops, int idx)
67 if (idx < ARRAY_SIZE(sh7763_clk_ops))
68 *ops = sh7763_clk_ops[idx];
71 static unsigned long shyway_clk_recalc(struct clk *clk)
73 int idx = ((__raw_readl(FRQCR) >> 20) & 0x07);
74 return clk->parent->rate / cfc_divisors[idx];
77 static struct clk_ops sh7763_shyway_clk_ops = {
78 .recalc = shyway_clk_recalc,
81 static struct clk sh7763_shyway_clk = {
82 .flags = CLK_ENABLE_ON_INIT,
83 .ops = &sh7763_shyway_clk_ops,
87 * Additional SH7763-specific on-chip clocks that aren't already part of the
88 * clock framework
90 static struct clk *sh7763_onchip_clocks[] = {
91 &sh7763_shyway_clk,
94 #define CLKDEV_CON_ID(_id, _clk) { .con_id = _id, .clk = _clk }
96 static struct clk_lookup lookups[] = {
97 /* main clocks */
98 CLKDEV_CON_ID("shyway_clk", &sh7763_shyway_clk),
101 int __init arch_clk_init(void)
103 struct clk *clk;
104 int i, ret = 0;
106 cpg_clk_init();
108 clk = clk_get(NULL, "master_clk");
109 for (i = 0; i < ARRAY_SIZE(sh7763_onchip_clocks); i++) {
110 struct clk *clkp = sh7763_onchip_clocks[i];
112 clkp->parent = clk;
113 ret |= clk_register(clkp);
116 clk_put(clk);
118 clkdev_add_table(lookups, ARRAY_SIZE(lookups));
120 return ret;