RT-AC66 3.0.0.4.374.130 core
[tomato.git] / release / src-rt-6.x / linux / linux-2.6 / arch / sh / kernel / cpu / sh4a / clock-sh73180.c
blob6d5ba373a75e461db8ded6d7d669c5104043aac9
1 /*
2 * arch/sh/kernel/cpu/sh4a/clock-sh73180.c
4 * SH73180 support for the clock framework
6 * Copyright (C) 2005 Paul Mundt
8 * FRQCR parsing hacked out of arch/sh/kernel/time.c
10 * Copyright (C) 1999 Tetsuya Okada & Niibe Yutaka
11 * Copyright (C) 2000 Philipp Rumpf <prumpf@tux.org>
12 * Copyright (C) 2002, 2003, 2004 Paul Mundt
13 * Copyright (C) 2002 M. R. Brown <mrbrown@linux-sh.org>
15 * This file is subject to the terms and conditions of the GNU General Public
16 * License. See the file "COPYING" in the main directory of this archive
17 * for more details.
19 #include <linux/init.h>
20 #include <linux/kernel.h>
21 #include <asm/clock.h>
22 #include <asm/freq.h>
23 #include <asm/io.h>
26 * SH73180 uses a common set of divisors, so this is quite simple..
28 static int divisors[] = { 1, 2, 3, 4, 6, 8, 12, 16 };
30 static void master_clk_init(struct clk *clk)
32 clk->rate *= divisors[ctrl_inl(FRQCR) & 0x0007];
35 static struct clk_ops sh73180_master_clk_ops = {
36 .init = master_clk_init,
39 static void module_clk_recalc(struct clk *clk)
41 int idx = (ctrl_inl(FRQCR) & 0x0007);
42 clk->rate = clk->parent->rate / divisors[idx];
45 static struct clk_ops sh73180_module_clk_ops = {
46 .recalc = module_clk_recalc,
49 static void bus_clk_recalc(struct clk *clk)
51 int idx = (ctrl_inl(FRQCR) >> 12) & 0x0007;
52 clk->rate = clk->parent->rate / divisors[idx];
55 static struct clk_ops sh73180_bus_clk_ops = {
56 .recalc = bus_clk_recalc,
59 static void cpu_clk_recalc(struct clk *clk)
61 int idx = (ctrl_inl(FRQCR) >> 20) & 0x0007;
62 clk->rate = clk->parent->rate / divisors[idx];
65 static struct clk_ops sh73180_cpu_clk_ops = {
66 .recalc = cpu_clk_recalc,
69 static struct clk_ops *sh73180_clk_ops[] = {
70 &sh73180_master_clk_ops,
71 &sh73180_module_clk_ops,
72 &sh73180_bus_clk_ops,
73 &sh73180_cpu_clk_ops,
76 void __init arch_init_clk_ops(struct clk_ops **ops, int idx)
78 if (idx < ARRAY_SIZE(sh73180_clk_ops))
79 *ops = sh73180_clk_ops[idx];