diff options
Diffstat (limited to 'arch')
-rw-r--r-- | arch/arm/mach-shmobile/clock.c | 13 | ||||
-rw-r--r-- | arch/arm/mach-shmobile/include/mach/clock.h | 39 |
2 files changed, 52 insertions, 0 deletions
diff --git a/arch/arm/mach-shmobile/clock.c b/arch/arm/mach-shmobile/clock.c index e816ca9bd213..ad7df629d995 100644 --- a/arch/arm/mach-shmobile/clock.c +++ b/arch/arm/mach-shmobile/clock.c | |||
@@ -23,6 +23,19 @@ | |||
23 | #include <linux/init.h> | 23 | #include <linux/init.h> |
24 | #include <linux/sh_clk.h> | 24 | #include <linux/sh_clk.h> |
25 | #include <linux/export.h> | 25 | #include <linux/export.h> |
26 | #include <mach/clock.h> | ||
27 | #include <mach/common.h> | ||
28 | |||
29 | unsigned long shmobile_fixed_ratio_clk_recalc(struct clk *clk) | ||
30 | { | ||
31 | struct clk_ratio *p = clk->priv; | ||
32 | |||
33 | return clk->parent->rate / p->div * p->mul; | ||
34 | }; | ||
35 | |||
36 | struct sh_clk_ops shmobile_fixed_ratio_clk_ops = { | ||
37 | .recalc = shmobile_fixed_ratio_clk_recalc, | ||
38 | }; | ||
26 | 39 | ||
27 | int __init shmobile_clk_init(void) | 40 | int __init shmobile_clk_init(void) |
28 | { | 41 | { |
diff --git a/arch/arm/mach-shmobile/include/mach/clock.h b/arch/arm/mach-shmobile/include/mach/clock.h new file mode 100644 index 000000000000..76ac61292e48 --- /dev/null +++ b/arch/arm/mach-shmobile/include/mach/clock.h | |||
@@ -0,0 +1,39 @@ | |||
1 | #ifndef CLOCK_H | ||
2 | #define CLOCK_H | ||
3 | |||
4 | unsigned long shmobile_fixed_ratio_clk_recalc(struct clk *clk); | ||
5 | extern struct sh_clk_ops shmobile_fixed_ratio_clk_ops; | ||
6 | |||
7 | /* clock ratio */ | ||
8 | struct clk_ratio { | ||
9 | int mul; | ||
10 | int div; | ||
11 | }; | ||
12 | |||
13 | #define SH_CLK_RATIO(name, m, d) \ | ||
14 | static struct clk_ratio name ##_ratio = { \ | ||
15 | .mul = m, \ | ||
16 | .div = d, \ | ||
17 | } | ||
18 | |||
19 | #define SH_FIXED_RATIO_CLKg(name, p, r) \ | ||
20 | struct clk name = { \ | ||
21 | .parent = &p, \ | ||
22 | .ops = &shmobile_fixed_ratio_clk_ops,\ | ||
23 | .priv = &r ## _ratio, \ | ||
24 | } | ||
25 | |||
26 | #define SH_FIXED_RATIO_CLK(name, p, r) \ | ||
27 | static SH_FIXED_RATIO_CLKg(name, p, r); | ||
28 | |||
29 | #define SH_FIXED_RATIO_CLK_SET(name, p, m, d) \ | ||
30 | SH_CLK_RATIO(name, m, d); \ | ||
31 | SH_FIXED_RATIO_CLK(name, p, name); | ||
32 | |||
33 | #define SH_CLK_SET_RATIO(p, m, d) \ | ||
34 | { \ | ||
35 | (p)->mul = m; \ | ||
36 | (p)->div = d; \ | ||
37 | } | ||
38 | |||
39 | #endif | ||