1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright (c) 2016 Maxime Ripard. All rights reserved.
9 #include <linux/clk-provider.h>
11 #include "ccu_common.h"
16 * struct ccu_nkm - Definition of an N-K-M clock
18 * Clocks based on the formula parent * N * K / M
24 struct ccu_mult_internal n
;
25 struct ccu_mult_internal k
;
26 struct ccu_div_internal m
;
27 struct ccu_mux_internal mux
;
29 unsigned int fixed_post_div
;
31 struct ccu_common common
;
34 #define SUNXI_CCU_NKM_WITH_MUX_GATE_LOCK(_struct, _name, _parents, _reg, \
38 _muxshift, _muxwidth, \
39 _gate, _lock, _flags) \
40 struct ccu_nkm _struct = { \
43 .k = _SUNXI_CCU_MULT(_kshift, _kwidth), \
44 .n = _SUNXI_CCU_MULT(_nshift, _nwidth), \
45 .m = _SUNXI_CCU_DIV(_mshift, _mwidth), \
46 .mux = _SUNXI_CCU_MUX(_muxshift, _muxwidth), \
49 .hw.init = CLK_HW_INIT_PARENTS(_name, \
56 #define SUNXI_CCU_NKM_WITH_GATE_LOCK(_struct, _name, _parent, _reg, \
60 _gate, _lock, _flags) \
61 struct ccu_nkm _struct = { \
64 .k = _SUNXI_CCU_MULT(_kshift, _kwidth), \
65 .n = _SUNXI_CCU_MULT(_nshift, _nwidth), \
66 .m = _SUNXI_CCU_DIV(_mshift, _mwidth), \
69 .hw.init = CLK_HW_INIT(_name, \
76 static inline struct ccu_nkm
*hw_to_ccu_nkm(struct clk_hw
*hw
)
78 struct ccu_common
*common
= hw_to_ccu_common(hw
);
80 return container_of(common
, struct ccu_nkm
, common
);
83 extern const struct clk_ops ccu_nkm_ops
;
85 #endif /* _CCU_NKM_H_ */