diff options
author | Paul Mundt <lethal@linux-sh.org> | 2008-09-29 07:09:17 -0400 |
---|---|---|
committer | Paul Mundt <lethal@linux-sh.org> | 2008-09-29 07:09:17 -0400 |
commit | 4d01cdafbafc0fdeb730838ca38a48e5ca2894cd (patch) | |
tree | 5157d3e9dd1882253ce848fd2d2650aaa17241aa /arch/sh/kernel/cpu/sh5 | |
parent | 50b72e600b62bcdf40971e55f609cf4771346cc1 (diff) |
sh: SH-5 clk fwk support.
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'arch/sh/kernel/cpu/sh5')
-rw-r--r-- | arch/sh/kernel/cpu/sh5/Makefile | 5 | ||||
-rw-r--r-- | arch/sh/kernel/cpu/sh5/clock-sh5.c | 79 |
2 files changed, 84 insertions, 0 deletions
diff --git a/arch/sh/kernel/cpu/sh5/Makefile b/arch/sh/kernel/cpu/sh5/Makefile index 8646363e9ded..ce4602ea23a8 100644 --- a/arch/sh/kernel/cpu/sh5/Makefile +++ b/arch/sh/kernel/cpu/sh5/Makefile | |||
@@ -5,3 +5,8 @@ obj-y := entry.o probe.o switchto.o | |||
5 | 5 | ||
6 | obj-$(CONFIG_SH_FPU) += fpu.o | 6 | obj-$(CONFIG_SH_FPU) += fpu.o |
7 | obj-$(CONFIG_KALLSYMS) += unwind.o | 7 | obj-$(CONFIG_KALLSYMS) += unwind.o |
8 | |||
9 | # Primary on-chip clocks (common) | ||
10 | clock-$(CONFIG_CPU_SH5) := clock-sh5.o | ||
11 | |||
12 | obj-y += $(clock-y) | ||
diff --git a/arch/sh/kernel/cpu/sh5/clock-sh5.c b/arch/sh/kernel/cpu/sh5/clock-sh5.c new file mode 100644 index 000000000000..52c49248833a --- /dev/null +++ b/arch/sh/kernel/cpu/sh5/clock-sh5.c | |||
@@ -0,0 +1,79 @@ | |||
1 | /* | ||
2 | * arch/sh/kernel/cpu/sh5/clock-sh5.c | ||
3 | * | ||
4 | * SH-5 support for the clock framework | ||
5 | * | ||
6 | * Copyright (C) 2008 Paul Mundt | ||
7 | * | ||
8 | * This file is subject to the terms and conditions of the GNU General Public | ||
9 | * License. See the file "COPYING" in the main directory of this archive | ||
10 | * for more details. | ||
11 | */ | ||
12 | #include <linux/init.h> | ||
13 | #include <linux/kernel.h> | ||
14 | #include <asm/clock.h> | ||
15 | #include <asm/io.h> | ||
16 | |||
17 | static int ifc_table[] = { 2, 4, 6, 8, 10, 12, 16, 24 }; | ||
18 | |||
19 | /* Clock, Power and Reset Controller */ | ||
20 | #define CPRC_BLOCK_OFF 0x01010000 | ||
21 | #define CPRC_BASE (PHYS_PERIPHERAL_BLOCK + CPRC_BLOCK_OFF) | ||
22 | |||
23 | static unsigned long cprc_base; | ||
24 | |||
25 | static void master_clk_init(struct clk *clk) | ||
26 | { | ||
27 | int idx = (ctrl_inl(cprc_base + 0x00) >> 6) & 0x0007; | ||
28 | clk->rate *= ifc_table[idx]; | ||
29 | } | ||
30 | |||
31 | static struct clk_ops sh5_master_clk_ops = { | ||
32 | .init = master_clk_init, | ||
33 | }; | ||
34 | |||
35 | static void module_clk_recalc(struct clk *clk) | ||
36 | { | ||
37 | int idx = (ctrl_inw(cprc_base) >> 12) & 0x0007; | ||
38 | clk->rate = clk->parent->rate / ifc_table[idx]; | ||
39 | } | ||
40 | |||
41 | static struct clk_ops sh5_module_clk_ops = { | ||
42 | .recalc = module_clk_recalc, | ||
43 | }; | ||
44 | |||
45 | static void bus_clk_recalc(struct clk *clk) | ||
46 | { | ||
47 | int idx = (ctrl_inw(cprc_base) >> 3) & 0x0007; | ||
48 | clk->rate = clk->parent->rate / ifc_table[idx]; | ||
49 | } | ||
50 | |||
51 | static struct clk_ops sh5_bus_clk_ops = { | ||
52 | .recalc = bus_clk_recalc, | ||
53 | }; | ||
54 | |||
55 | static void cpu_clk_recalc(struct clk *clk) | ||
56 | { | ||
57 | int idx = (ctrl_inw(cprc_base) & 0x0007); | ||
58 | clk->rate = clk->parent->rate / ifc_table[idx]; | ||
59 | } | ||
60 | |||
61 | static struct clk_ops sh5_cpu_clk_ops = { | ||
62 | .recalc = cpu_clk_recalc, | ||
63 | }; | ||
64 | |||
65 | static struct clk_ops *sh5_clk_ops[] = { | ||
66 | &sh5_master_clk_ops, | ||
67 | &sh5_module_clk_ops, | ||
68 | &sh5_bus_clk_ops, | ||
69 | &sh5_cpu_clk_ops, | ||
70 | }; | ||
71 | |||
72 | void __init arch_init_clk_ops(struct clk_ops **ops, int idx) | ||
73 | { | ||
74 | cprc_base = onchip_remap(CPRC_BASE, 1024, "CPRC"); | ||
75 | BUG_ON(!cprc_base); | ||
76 | |||
77 | if (idx < ARRAY_SIZE(sh5_clk_ops)) | ||
78 | *ops = sh5_clk_ops[idx]; | ||
79 | } | ||