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 offset; 10 u8 shift; 11 u8 width; 12 u8 min; 13 u8 max; 14 }; 15 16 #define _SUNXI_CCU_MULT_OFFSET_MIN_MAX(_shift, _width, _offset, _min, _max) \ 17 { \ 18 .min = _min, \ 19 .max = _max, \ 20 .offset = _offset, \ 21 .shift = _shift, \ 22 .width = _width, \ 23 } 24 25 #define _SUNXI_CCU_MULT_MIN(_shift, _width, _min) \ 26 _SUNXI_CCU_MULT_OFFSET_MIN_MAX(_shift, _width, 1, _min, 0) 27 28 #define _SUNXI_CCU_MULT_OFFSET(_shift, _width, _offset) \ 29 _SUNXI_CCU_MULT_OFFSET_MIN_MAX(_shift, _width, _offset, 1, 0) 30 31 #define _SUNXI_CCU_MULT(_shift, _width) \ 32 _SUNXI_CCU_MULT_OFFSET_MIN_MAX(_shift, _width, 1, 1, 0) 33 34 struct ccu_mult { 35 u32 enable; 36 37 struct ccu_frac_internal frac; 38 struct ccu_mult_internal mult; 39 struct ccu_mux_internal mux; 40 struct ccu_common common; 41 }; 42 43 #define SUNXI_CCU_N_WITH_GATE_LOCK(_struct, _name, _parent, _reg, \ 44 _mshift, _mwidth, _gate, _lock, \ 45 _flags) \ 46 struct ccu_mult _struct = { \ 47 .enable = _gate, \ 48 .mult = _SUNXI_CCU_MULT(_mshift, _mwidth), \ 49 .common = { \ 50 .reg = _reg, \ 51 .hw.init = CLK_HW_INIT(_name, \ 52 _parent, \ 53 &ccu_mult_ops, \ 54 _flags), \ 55 }, \ 56 } 57 58 static inline struct ccu_mult *hw_to_ccu_mult(struct clk_hw *hw) 59 { 60 struct ccu_common *common = hw_to_ccu_common(hw); 61 62 return container_of(common, struct ccu_mult, common); 63 } 64 65 extern const struct clk_ops ccu_mult_ops; 66 67 #endif /* _CCU_MULT_H_ */ 68