xref: /linux/drivers/clk/sunxi-ng/ccu_mult.h (revision d77e8135)
1 #ifndef _CCU_MULT_H_
2 #define _CCU_MULT_H_
3 
4 #include "ccu_common.h"
5 #include "ccu_frac.h"
6 #include "ccu_mux.h"
7 
8 struct ccu_mult_internal {
9 	u8	shift;
10 	u8	width;
11 	u8	min;
12 };
13 
14 #define _SUNXI_CCU_MULT_MIN(_shift, _width, _min)	\
15 	{						\
16 		.shift	= _shift,			\
17 		.width	= _width,			\
18 		.min	= _min,				\
19 	}
20 
21 #define _SUNXI_CCU_MULT(_shift, _width)		\
22 	_SUNXI_CCU_MULT_MIN(_shift, _width, 1)
23 
24 struct ccu_mult {
25 	u32			enable;
26 
27 	struct ccu_frac_internal	frac;
28 	struct ccu_mult_internal	mult;
29 	struct ccu_mux_internal	mux;
30 	struct ccu_common	common;
31 };
32 
33 #define SUNXI_CCU_N_WITH_GATE_LOCK(_struct, _name, _parent, _reg,	\
34 				   _mshift, _mwidth, _gate, _lock,	\
35 				   _flags)				\
36 	struct ccu_mult _struct = {					\
37 		.enable	= _gate,					\
38 		.mult	= _SUNXI_CCU_MULT(_mshift, _mwidth),		\
39 		.common	= {						\
40 			.reg		= _reg,				\
41 			.hw.init	= CLK_HW_INIT(_name,		\
42 						      _parent,		\
43 						      &ccu_mult_ops,	\
44 						      _flags),		\
45 		},							\
46 	}
47 
48 static inline struct ccu_mult *hw_to_ccu_mult(struct clk_hw *hw)
49 {
50 	struct ccu_common *common = hw_to_ccu_common(hw);
51 
52 	return container_of(common, struct ccu_mult, common);
53 }
54 
55 extern const struct clk_ops ccu_mult_ops;
56 
57 #endif /* _CCU_MULT_H_ */
58