2 * SH-Mobile Clock Framework
4 * Copyright (C) 2010 Magnus Damm
6 * Used together with arch/arm/common/clkdev.c and drivers/sh/clk.c.
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.
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.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #include <linux/kernel.h>
23 #include <linux/init.h>
25 #ifdef CONFIG_COMMON_CLK
26 #include <linux/clk.h>
27 #include <linux/clkdev.h>
28 #include <mach/clock.h>
30 void __init
shmobile_clk_workaround(const struct clk_name
*clks
,
31 int nr_clks
, bool enable
)
33 const struct clk_name
*clkn
;
37 for (i
= 0; i
< nr_clks
; ++i
) {
39 clk
= clk_get(NULL
, clkn
->clk
);
41 clk_register_clkdev(clk
, clkn
->con_id
, clkn
->dev_id
);
43 clk_prepare_enable(clk
);
49 #else /* CONFIG_COMMON_CLK */
50 #include <linux/sh_clk.h>
51 #include <linux/export.h>
52 #include <mach/clock.h>
53 #include <mach/common.h>
55 unsigned long shmobile_fixed_ratio_clk_recalc(struct clk
*clk
)
57 struct clk_ratio
*p
= clk
->priv
;
59 return clk
->parent
->rate
/ p
->div
* p
->mul
;
62 struct sh_clk_ops shmobile_fixed_ratio_clk_ops
= {
63 .recalc
= shmobile_fixed_ratio_clk_recalc
,
66 int __init
shmobile_clk_init(void)
68 /* Kick the child clocks.. */
69 recalculate_root_clocks();
71 /* Enable the necessary init clocks */
72 clk_enable_init_clocks();
77 int __clk_get(struct clk
*clk
)
81 EXPORT_SYMBOL(__clk_get
);
83 void __clk_put(struct clk
*clk
)
86 EXPORT_SYMBOL(__clk_put
);
88 #endif /* CONFIG_COMMON_CLK */