0001
0002 #ifndef _CCU_MULT_H_
0003 #define _CCU_MULT_H_
0004
0005 #include "ccu_common.h"
0006 #include "ccu_frac.h"
0007 #include "ccu_mux.h"
0008
0009 struct ccu_mult_internal {
0010 u8 offset;
0011 u8 shift;
0012 u8 width;
0013 u8 min;
0014 u8 max;
0015 };
0016
0017 #define _SUNXI_CCU_MULT_OFFSET_MIN_MAX(_shift, _width, _offset, _min, _max) \
0018 { \
0019 .min = _min, \
0020 .max = _max, \
0021 .offset = _offset, \
0022 .shift = _shift, \
0023 .width = _width, \
0024 }
0025
0026 #define _SUNXI_CCU_MULT_MIN(_shift, _width, _min) \
0027 _SUNXI_CCU_MULT_OFFSET_MIN_MAX(_shift, _width, 1, _min, 0)
0028
0029 #define _SUNXI_CCU_MULT_OFFSET(_shift, _width, _offset) \
0030 _SUNXI_CCU_MULT_OFFSET_MIN_MAX(_shift, _width, _offset, 1, 0)
0031
0032 #define _SUNXI_CCU_MULT(_shift, _width) \
0033 _SUNXI_CCU_MULT_OFFSET_MIN_MAX(_shift, _width, 1, 1, 0)
0034
0035 struct ccu_mult {
0036 u32 enable;
0037 u32 lock;
0038
0039 struct ccu_frac_internal frac;
0040 struct ccu_mult_internal mult;
0041 struct ccu_mux_internal mux;
0042 struct ccu_common common;
0043 };
0044
0045 #define SUNXI_CCU_N_WITH_GATE_LOCK(_struct, _name, _parent, _reg, \
0046 _mshift, _mwidth, _gate, _lock, \
0047 _flags) \
0048 struct ccu_mult _struct = { \
0049 .enable = _gate, \
0050 .lock = _lock, \
0051 .mult = _SUNXI_CCU_MULT(_mshift, _mwidth), \
0052 .common = { \
0053 .reg = _reg, \
0054 .hw.init = CLK_HW_INIT(_name, \
0055 _parent, \
0056 &ccu_mult_ops, \
0057 _flags), \
0058 }, \
0059 }
0060
0061 static inline struct ccu_mult *hw_to_ccu_mult(struct clk_hw *hw)
0062 {
0063 struct ccu_common *common = hw_to_ccu_common(hw);
0064
0065 return container_of(common, struct ccu_mult, common);
0066 }
0067
0068 extern const struct clk_ops ccu_mult_ops;
0069
0070 #endif