1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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>
24
25static int md_table[] = { 1, 2, 3, 4, 6, 8, 12 };
26
27static void master_clk_init(struct clk *clk)
28{
29 clk->rate *= md_table[ctrl_inw(FRQCR) & 0x0007];
30}
31
32static struct clk_ops sh7710_master_clk_ops = {
33 .init = master_clk_init,
34};
35
36static unsigned long module_clk_recalc(struct clk *clk)
37{
38 int idx = (ctrl_inw(FRQCR) & 0x0007);
39 return clk->parent->rate / md_table[idx];
40}
41
42static struct clk_ops sh7710_module_clk_ops = {
43 .recalc = module_clk_recalc,
44};
45
46static unsigned long bus_clk_recalc(struct clk *clk)
47{
48 int idx = (ctrl_inw(FRQCR) & 0x0700) >> 8;
49 return clk->parent->rate / md_table[idx];
50}
51
52static struct clk_ops sh7710_bus_clk_ops = {
53 .recalc = bus_clk_recalc,
54};
55
56static unsigned long cpu_clk_recalc(struct clk *clk)
57{
58 int idx = (ctrl_inw(FRQCR) & 0x0070) >> 4;
59 return clk->parent->rate / md_table[idx];
60}
61
62static struct clk_ops sh7710_cpu_clk_ops = {
63 .recalc = cpu_clk_recalc,
64};
65
66static struct clk_ops *sh7710_clk_ops[] = {
67 &sh7710_master_clk_ops,
68 &sh7710_module_clk_ops,
69 &sh7710_bus_clk_ops,
70 &sh7710_cpu_clk_ops,
71};
72
73void __init arch_init_clk_ops(struct clk_ops **ops, int idx)
74{
75 if (idx < ARRAY_SIZE(sh7710_clk_ops))
76 *ops = sh7710_clk_ops[idx];
77}
78
79