2 * arch/sh/kernel/cpu/sh3/clock-sh7710.c
4 * SH7710 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
19 #include <linux/init.h>
20 #include <linux/kernel.h>
21 #include <asm/clock.h>
25 static int md_table
[] = { 1, 2, 3, 4, 6, 8, 12 };
27 static void master_clk_init(struct clk
*clk
)
29 clk
->rate
*= md_table
[ctrl_inw(FRQCR
) & 0x0007];
32 static struct clk_ops sh7710_master_clk_ops
= {
33 .init
= master_clk_init
,
36 static void module_clk_recalc(struct clk
*clk
)
38 int idx
= (ctrl_inw(FRQCR
) & 0x0007);
39 clk
->rate
= clk
->parent
->rate
/ md_table
[idx
];
42 static struct clk_ops sh7710_module_clk_ops
= {
43 .recalc
= module_clk_recalc
,
46 static void bus_clk_recalc(struct clk
*clk
)
48 int idx
= (ctrl_inw(FRQCR
) & 0x0700) >> 8;
49 clk
->rate
= clk
->parent
->rate
/ md_table
[idx
];
52 static struct clk_ops sh7710_bus_clk_ops
= {
53 .recalc
= bus_clk_recalc
,
56 static void cpu_clk_recalc(struct clk
*clk
)
58 int idx
= (ctrl_inw(FRQCR
) & 0x0070) >> 4;
59 clk
->rate
= clk
->parent
->rate
/ md_table
[idx
];
62 static struct clk_ops sh7710_cpu_clk_ops
= {
63 .recalc
= cpu_clk_recalc
,
66 static struct clk_ops
*sh7710_clk_ops
[] = {
67 &sh7710_master_clk_ops
,
68 &sh7710_module_clk_ops
,
73 void __init
arch_init_clk_ops(struct clk_ops
**ops
, int idx
)
75 if (idx
< ARRAY_SIZE(sh7710_clk_ops
))
76 *ops
= sh7710_clk_ops
[idx
];