blob: 31b6417463e651f87ab51ec96a9d36a635a50d7b [file] [log] [blame]
Kuninori Morimotof5942c72013-03-27 00:55:41 -07001#ifndef CLOCK_H
2#define CLOCK_H
3
Magnus Damm25f55502014-03-13 08:36:17 +09004#ifdef CONFIG_COMMON_CLK
5/* temporary clock configuration helper for platform devices */
6
7struct clk_name {
8 const char *clk;
9 const char *con_id;
10 const char *dev_id;
11};
12
13void shmobile_clk_workaround(const struct clk_name *clks, int nr_clks,
14 bool enable);
15
16#else /* CONFIG_COMMON_CLK */
17/* legacy clock implementation */
18
Geert Uytterhoeven1f9c7a62014-05-14 03:10:16 +020019struct clk;
Kuninori Morimotof5942c72013-03-27 00:55:41 -070020unsigned long shmobile_fixed_ratio_clk_recalc(struct clk *clk);
21extern struct sh_clk_ops shmobile_fixed_ratio_clk_ops;
22
23/* clock ratio */
24struct clk_ratio {
25 int mul;
26 int div;
27};
28
29#define SH_CLK_RATIO(name, m, d) \
30static struct clk_ratio name ##_ratio = { \
31 .mul = m, \
32 .div = d, \
33}
34
35#define SH_FIXED_RATIO_CLKg(name, p, r) \
36struct clk name = { \
37 .parent = &p, \
38 .ops = &shmobile_fixed_ratio_clk_ops,\
39 .priv = &r ## _ratio, \
40}
41
42#define SH_FIXED_RATIO_CLK(name, p, r) \
Kuninori Morimotobdd5d282013-04-04 00:05:42 -070043static SH_FIXED_RATIO_CLKg(name, p, r)
Kuninori Morimotof5942c72013-03-27 00:55:41 -070044
45#define SH_FIXED_RATIO_CLK_SET(name, p, m, d) \
46 SH_CLK_RATIO(name, m, d); \
Kuninori Morimotobdd5d282013-04-04 00:05:42 -070047 SH_FIXED_RATIO_CLK(name, p, name)
Kuninori Morimotof5942c72013-03-27 00:55:41 -070048
49#define SH_CLK_SET_RATIO(p, m, d) \
Kuninori Morimotob6825a02013-04-12 00:41:07 -070050do { \
Kuninori Morimotof5942c72013-03-27 00:55:41 -070051 (p)->mul = m; \
52 (p)->div = d; \
Kuninori Morimotob6825a02013-04-12 00:41:07 -070053} while (0)
Kuninori Morimotof5942c72013-03-27 00:55:41 -070054
Magnus Damm25f55502014-03-13 08:36:17 +090055#endif /* CONFIG_COMMON_CLK */
Kuninori Morimotof5942c72013-03-27 00:55:41 -070056#endif