Kuninori Morimoto | f5942c7 | 2013-03-27 00:55:41 -0700 | [diff] [blame] | 1 | #ifndef CLOCK_H |
| 2 | #define CLOCK_H |
| 3 | |
Magnus Damm | 25f5550 | 2014-03-13 08:36:17 +0900 | [diff] [blame] | 4 | #ifdef CONFIG_COMMON_CLK |
| 5 | /* temporary clock configuration helper for platform devices */ |
| 6 | |
| 7 | struct clk_name { |
| 8 | const char *clk; |
| 9 | const char *con_id; |
| 10 | const char *dev_id; |
| 11 | }; |
| 12 | |
| 13 | void 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 Uytterhoeven | 1f9c7a6 | 2014-05-14 03:10:16 +0200 | [diff] [blame] | 19 | struct clk; |
Kuninori Morimoto | f5942c7 | 2013-03-27 00:55:41 -0700 | [diff] [blame] | 20 | unsigned long shmobile_fixed_ratio_clk_recalc(struct clk *clk); |
| 21 | extern struct sh_clk_ops shmobile_fixed_ratio_clk_ops; |
| 22 | |
| 23 | /* clock ratio */ |
| 24 | struct clk_ratio { |
| 25 | int mul; |
| 26 | int div; |
| 27 | }; |
| 28 | |
| 29 | #define SH_CLK_RATIO(name, m, d) \ |
| 30 | static struct clk_ratio name ##_ratio = { \ |
| 31 | .mul = m, \ |
| 32 | .div = d, \ |
| 33 | } |
| 34 | |
| 35 | #define SH_FIXED_RATIO_CLKg(name, p, r) \ |
| 36 | struct 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 Morimoto | bdd5d28 | 2013-04-04 00:05:42 -0700 | [diff] [blame] | 43 | static SH_FIXED_RATIO_CLKg(name, p, r) |
Kuninori Morimoto | f5942c7 | 2013-03-27 00:55:41 -0700 | [diff] [blame] | 44 | |
| 45 | #define SH_FIXED_RATIO_CLK_SET(name, p, m, d) \ |
| 46 | SH_CLK_RATIO(name, m, d); \ |
Kuninori Morimoto | bdd5d28 | 2013-04-04 00:05:42 -0700 | [diff] [blame] | 47 | SH_FIXED_RATIO_CLK(name, p, name) |
Kuninori Morimoto | f5942c7 | 2013-03-27 00:55:41 -0700 | [diff] [blame] | 48 | |
| 49 | #define SH_CLK_SET_RATIO(p, m, d) \ |
Kuninori Morimoto | b6825a0 | 2013-04-12 00:41:07 -0700 | [diff] [blame] | 50 | do { \ |
Kuninori Morimoto | f5942c7 | 2013-03-27 00:55:41 -0700 | [diff] [blame] | 51 | (p)->mul = m; \ |
| 52 | (p)->div = d; \ |
Kuninori Morimoto | b6825a0 | 2013-04-12 00:41:07 -0700 | [diff] [blame] | 53 | } while (0) |
Kuninori Morimoto | f5942c7 | 2013-03-27 00:55:41 -0700 | [diff] [blame] | 54 | |
Magnus Damm | 25f5550 | 2014-03-13 08:36:17 +0900 | [diff] [blame] | 55 | #endif /* CONFIG_COMMON_CLK */ |
Kuninori Morimoto | f5942c7 | 2013-03-27 00:55:41 -0700 | [diff] [blame] | 56 | #endif |