ARM: shmobile: Remove FSF address from copyright headers
[cascardo/linux.git] / arch / arm / mach-shmobile / clock.c
1 /*
2  * SH-Mobile Clock Framework
3  *
4  * Copyright (C) 2010  Magnus Damm
5  *
6  * Used together with arch/arm/common/clkdev.c and drivers/sh/clk.c.
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; version 2 of the License.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  */
18 #include <linux/kernel.h>
19 #include <linux/init.h>
20
21 #ifdef CONFIG_COMMON_CLK
22 #include <linux/clk.h>
23 #include <linux/clkdev.h>
24 #include "clock.h"
25
26 void __init shmobile_clk_workaround(const struct clk_name *clks,
27                                     int nr_clks, bool enable)
28 {
29         const struct clk_name *clkn;
30         struct clk *clk;
31         unsigned int i;
32
33         for (i = 0; i < nr_clks; ++i) {
34                 clkn = clks + i;
35                 clk = clk_get(NULL, clkn->clk);
36                 if (!IS_ERR(clk)) {
37                         clk_register_clkdev(clk, clkn->con_id, clkn->dev_id);
38                         if (enable)
39                                 clk_prepare_enable(clk);
40                         clk_put(clk);
41                 }
42         }
43 }
44
45 #else /* CONFIG_COMMON_CLK */
46 #include <linux/sh_clk.h>
47 #include <linux/export.h>
48 #include "clock.h"
49 #include "common.h"
50
51 unsigned long shmobile_fixed_ratio_clk_recalc(struct clk *clk)
52 {
53         struct clk_ratio *p = clk->priv;
54
55         return clk->parent->rate / p->div * p->mul;
56 };
57
58 struct sh_clk_ops shmobile_fixed_ratio_clk_ops = {
59         .recalc = shmobile_fixed_ratio_clk_recalc,
60 };
61
62 int __init shmobile_clk_init(void)
63 {
64         /* Kick the child clocks.. */
65         recalculate_root_clocks();
66
67         /* Enable the necessary init clocks */
68         clk_enable_init_clocks();
69
70         return 0;
71 }
72
73 int __clk_get(struct clk *clk)
74 {
75         return 1;
76 }
77 EXPORT_SYMBOL(__clk_get);
78
79 void __clk_put(struct clk *clk)
80 {
81 }
82 EXPORT_SYMBOL(__clk_put);
83
84 #endif /* CONFIG_COMMON_CLK */