diff options
Diffstat (limited to 'drivers/clk/sunxi-ng/ccu_nkm.h')
-rw-r--r-- | drivers/clk/sunxi-ng/ccu_nkm.h | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/drivers/clk/sunxi-ng/ccu_nkm.h b/drivers/clk/sunxi-ng/ccu_nkm.h new file mode 100644 index 000000000000..1936ac1c6b37 --- /dev/null +++ b/drivers/clk/sunxi-ng/ccu_nkm.h | |||
@@ -0,0 +1,68 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2016 Maxime Ripard. All rights reserved. | ||
3 | * | ||
4 | * This software is licensed under the terms of the GNU General Public | ||
5 | * License version 2, as published by the Free Software Foundation, and | ||
6 | * may be copied, distributed, and modified under those terms. | ||
7 | * | ||
8 | * This program is distributed in the hope that it will be useful, | ||
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
11 | * GNU General Public License for more details. | ||
12 | */ | ||
13 | |||
14 | #ifndef _CCU_NKM_H_ | ||
15 | #define _CCU_NKM_H_ | ||
16 | |||
17 | #include <linux/clk-provider.h> | ||
18 | |||
19 | #include "ccu_common.h" | ||
20 | #include "ccu_div.h" | ||
21 | #include "ccu_mult.h" | ||
22 | |||
23 | /* | ||
24 | * struct ccu_nkm - Definition of an N-K-M clock | ||
25 | * | ||
26 | * Clocks based on the formula parent * N * K / M | ||
27 | */ | ||
28 | struct ccu_nkm { | ||
29 | u32 enable; | ||
30 | u32 lock; | ||
31 | |||
32 | struct _ccu_mult n; | ||
33 | struct _ccu_mult k; | ||
34 | struct _ccu_div m; | ||
35 | |||
36 | struct ccu_common common; | ||
37 | }; | ||
38 | |||
39 | #define SUNXI_CCU_NKM_WITH_GATE_LOCK(_struct, _name, _parent, _reg, \ | ||
40 | _nshift, _nwidth, \ | ||
41 | _kshift, _kwidth, \ | ||
42 | _mshift, _mwidth, \ | ||
43 | _gate, _lock, _flags) \ | ||
44 | struct ccu_nkm _struct = { \ | ||
45 | .enable = _gate, \ | ||
46 | .lock = _lock, \ | ||
47 | .k = _SUNXI_CCU_MULT(_kshift, _kwidth), \ | ||
48 | .n = _SUNXI_CCU_MULT(_nshift, _nwidth), \ | ||
49 | .m = _SUNXI_CCU_DIV(_mshift, _mwidth), \ | ||
50 | .common = { \ | ||
51 | .reg = _reg, \ | ||
52 | .hw.init = CLK_HW_INIT(_name, \ | ||
53 | _parent, \ | ||
54 | &ccu_nkm_ops, \ | ||
55 | _flags), \ | ||
56 | }, \ | ||
57 | } | ||
58 | |||
59 | static inline struct ccu_nkm *hw_to_ccu_nkm(struct clk_hw *hw) | ||
60 | { | ||
61 | struct ccu_common *common = hw_to_ccu_common(hw); | ||
62 | |||
63 | return container_of(common, struct ccu_nkm, common); | ||
64 | } | ||
65 | |||
66 | extern const struct clk_ops ccu_nkm_ops; | ||
67 | |||
68 | #endif /* _CCU_NKM_H_ */ | ||