nfsd4: typo logical vs bitwise negate for want_mask
[linux-btrfs-devel.git] / arch / sh / kernel / cpu / sh3 / clock-sh3.c
blobb78384afac090de66a7e04e1ff14b274fff5ff9f
1 /*
2 * arch/sh/kernel/cpu/sh3/clock-sh3.c
4 * Generic SH-3 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>
25 static int stc_multipliers[] = { 1, 2, 3, 4, 6, 1, 1, 1 };
26 static int ifc_divisors[] = { 1, 2, 3, 4, 1, 1, 1, 1 };
27 static int pfc_divisors[] = { 1, 2, 3, 4, 6, 1, 1, 1 };
29 static void master_clk_init(struct clk *clk)
31 int frqcr = __raw_readw(FRQCR);
32 int idx = ((frqcr & 0x2000) >> 11) | (frqcr & 0x0003);
34 clk->rate *= pfc_divisors[idx];
37 static struct clk_ops sh3_master_clk_ops = {
38 .init = master_clk_init,
41 static unsigned long module_clk_recalc(struct clk *clk)
43 int frqcr = __raw_readw(FRQCR);
44 int idx = ((frqcr & 0x2000) >> 11) | (frqcr & 0x0003);
46 return clk->parent->rate / pfc_divisors[idx];
49 static struct clk_ops sh3_module_clk_ops = {
50 .recalc = module_clk_recalc,
53 static unsigned long bus_clk_recalc(struct clk *clk)
55 int frqcr = __raw_readw(FRQCR);
56 int idx = ((frqcr & 0x8000) >> 13) | ((frqcr & 0x0030) >> 4);
58 return clk->parent->rate / stc_multipliers[idx];
61 static struct clk_ops sh3_bus_clk_ops = {
62 .recalc = bus_clk_recalc,
65 static unsigned long cpu_clk_recalc(struct clk *clk)
67 int frqcr = __raw_readw(FRQCR);
68 int idx = ((frqcr & 0x4000) >> 12) | ((frqcr & 0x000c) >> 2);
70 return clk->parent->rate / ifc_divisors[idx];
73 static struct clk_ops sh3_cpu_clk_ops = {
74 .recalc = cpu_clk_recalc,
77 static struct clk_ops *sh3_clk_ops[] = {
78 &sh3_master_clk_ops,
79 &sh3_module_clk_ops,
80 &sh3_bus_clk_ops,
81 &sh3_cpu_clk_ops,
84 void __init arch_init_clk_ops(struct clk_ops **ops, int idx)
86 if (idx < ARRAY_SIZE(sh3_clk_ops))
87 *ops = sh3_clk_ops[idx];