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