2 * Copyright (c) 2016 Maxime Ripard. All rights reserved.
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.
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.
17 #include <linux/clk-provider.h>
19 #include "ccu_common.h"
24 * struct ccu_nkm - Definition of an N-K-M clock
26 * Clocks based on the formula parent * N * K / M
32 struct ccu_mult_internal n
;
33 struct ccu_mult_internal k
;
34 struct ccu_div_internal m
;
35 struct ccu_mux_internal mux
;
37 unsigned int fixed_post_div
;
39 struct ccu_common common
;
42 #define SUNXI_CCU_NKM_WITH_MUX_GATE_LOCK(_struct, _name, _parents, _reg, \
46 _muxshift, _muxwidth, \
47 _gate, _lock, _flags) \
48 struct ccu_nkm _struct = { \
51 .k = _SUNXI_CCU_MULT(_kshift, _kwidth), \
52 .n = _SUNXI_CCU_MULT(_nshift, _nwidth), \
53 .m = _SUNXI_CCU_DIV(_mshift, _mwidth), \
54 .mux = _SUNXI_CCU_MUX(_muxshift, _muxwidth), \
57 .hw.init = CLK_HW_INIT_PARENTS(_name, \
64 #define SUNXI_CCU_NKM_WITH_GATE_LOCK(_struct, _name, _parent, _reg, \
68 _gate, _lock, _flags) \
69 struct ccu_nkm _struct = { \
72 .k = _SUNXI_CCU_MULT(_kshift, _kwidth), \
73 .n = _SUNXI_CCU_MULT(_nshift, _nwidth), \
74 .m = _SUNXI_CCU_DIV(_mshift, _mwidth), \
77 .hw.init = CLK_HW_INIT(_name, \
84 static inline struct ccu_nkm
*hw_to_ccu_nkm(struct clk_hw
*hw
)
86 struct ccu_common
*common
= hw_to_ccu_common(hw
);
88 return container_of(common
, struct ccu_nkm
, common
);
91 extern const struct clk_ops ccu_nkm_ops
;
93 #endif /* _CCU_NKM_H_ */