blob: cf3552ea10192d2a82502c1b0b9fe0b06704376c [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/* legacy clock implementation */
5
Geert Uytterhoeven1f9c7a62014-05-14 03:10:16 +02006struct clk;
Kuninori Morimotof5942c72013-03-27 00:55:41 -07007unsigned long shmobile_fixed_ratio_clk_recalc(struct clk *clk);
8extern struct sh_clk_ops shmobile_fixed_ratio_clk_ops;
9
10/* clock ratio */
11struct clk_ratio {
12 int mul;
13 int div;
14};
15
16#define SH_CLK_RATIO(name, m, d) \
17static struct clk_ratio name ##_ratio = { \
18 .mul = m, \
19 .div = d, \
20}
21
22#define SH_FIXED_RATIO_CLKg(name, p, r) \
23struct clk name = { \
24 .parent = &p, \
25 .ops = &shmobile_fixed_ratio_clk_ops,\
26 .priv = &r ## _ratio, \
27}
28
29#define SH_FIXED_RATIO_CLK(name, p, r) \
Kuninori Morimotobdd5d282013-04-04 00:05:42 -070030static SH_FIXED_RATIO_CLKg(name, p, r)
Kuninori Morimotof5942c72013-03-27 00:55:41 -070031
32#define SH_FIXED_RATIO_CLK_SET(name, p, m, d) \
33 SH_CLK_RATIO(name, m, d); \
Kuninori Morimotobdd5d282013-04-04 00:05:42 -070034 SH_FIXED_RATIO_CLK(name, p, name)
Kuninori Morimotof5942c72013-03-27 00:55:41 -070035
36#define SH_CLK_SET_RATIO(p, m, d) \
Kuninori Morimotob6825a02013-04-12 00:41:07 -070037do { \
Kuninori Morimotof5942c72013-03-27 00:55:41 -070038 (p)->mul = m; \
39 (p)->div = d; \
Kuninori Morimotob6825a02013-04-12 00:41:07 -070040} while (0)
Kuninori Morimotof5942c72013-03-27 00:55:41 -070041
Kuninori Morimotof5942c72013-03-27 00:55:41 -070042#endif