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
;
30 unsigned long max_m_n_ratio
;
31 unsigned long min_parent_m_ratio
;
33 struct ccu_common common
;
36 #define SUNXI_CCU_NKM_WITH_MUX_GATE_LOCK(_struct, _name, _parents, _reg, \
40 _muxshift, _muxwidth, \
41 _gate, _lock, _flags) \
42 struct ccu_nkm _struct = { \
45 .k = _SUNXI_CCU_MULT(_kshift, _kwidth), \
46 .n = _SUNXI_CCU_MULT(_nshift, _nwidth), \
47 .m = _SUNXI_CCU_DIV(_mshift, _mwidth), \
48 .mux = _SUNXI_CCU_MUX(_muxshift, _muxwidth), \
51 .hw.init = CLK_HW_INIT_PARENTS(_name, \
58 #define SUNXI_CCU_NKM_WITH_GATE_LOCK(_struct, _name, _parent, _reg, \
62 _gate, _lock, _flags) \
63 struct ccu_nkm _struct = { \
66 .k = _SUNXI_CCU_MULT(_kshift, _kwidth), \
67 .n = _SUNXI_CCU_MULT(_nshift, _nwidth), \
68 .m = _SUNXI_CCU_DIV(_mshift, _mwidth), \
71 .hw.init = CLK_HW_INIT(_name, \
78 static inline struct ccu_nkm
*hw_to_ccu_nkm(struct clk_hw
*hw
)
80 struct ccu_common
*common
= hw_to_ccu_common(hw
);
82 return container_of(common
, struct ccu_nkm
, common
);
85 extern const struct clk_ops ccu_nkm_ops
;
87 #endif /* _CCU_NKM_H_ */