0001
0002
0003
0004
0005
0006
0007
0008 #ifndef _SPRD_COMPOSITE_H_
0009 #define _SPRD_COMPOSITE_H_
0010
0011 #include "common.h"
0012 #include "mux.h"
0013 #include "div.h"
0014
0015 struct sprd_comp {
0016 struct sprd_mux_ssel mux;
0017 struct sprd_div_internal div;
0018 struct sprd_clk_common common;
0019 };
0020
0021 #define SPRD_COMP_CLK_HW_INIT_FN(_struct, _name, _parent, _reg, _table, \
0022 _mshift, _mwidth, _dshift, _dwidth, \
0023 _flags, _fn) \
0024 struct sprd_comp _struct = { \
0025 .mux = _SPRD_MUX_CLK(_mshift, _mwidth, _table), \
0026 .div = _SPRD_DIV_CLK(_dshift, _dwidth), \
0027 .common = { \
0028 .regmap = NULL, \
0029 .reg = _reg, \
0030 .hw.init = _fn(_name, _parent, \
0031 &sprd_comp_ops, _flags), \
0032 } \
0033 }
0034
0035 #define SPRD_COMP_CLK_TABLE(_struct, _name, _parent, _reg, _table, \
0036 _mshift, _mwidth, _dshift, _dwidth, _flags) \
0037 SPRD_COMP_CLK_HW_INIT_FN(_struct, _name, _parent, _reg, _table, \
0038 _mshift, _mwidth, _dshift, _dwidth, \
0039 _flags, CLK_HW_INIT_PARENTS)
0040
0041 #define SPRD_COMP_CLK(_struct, _name, _parent, _reg, _mshift, \
0042 _mwidth, _dshift, _dwidth, _flags) \
0043 SPRD_COMP_CLK_TABLE(_struct, _name, _parent, _reg, NULL, \
0044 _mshift, _mwidth, _dshift, _dwidth, _flags)
0045
0046 #define SPRD_COMP_CLK_DATA_TABLE(_struct, _name, _parent, _reg, _table, \
0047 _mshift, _mwidth, _dshift, \
0048 _dwidth, _flags) \
0049 SPRD_COMP_CLK_HW_INIT_FN(_struct, _name, _parent, _reg, _table, \
0050 _mshift, _mwidth, _dshift, _dwidth, \
0051 _flags, CLK_HW_INIT_PARENTS_DATA)
0052
0053 #define SPRD_COMP_CLK_DATA(_struct, _name, _parent, _reg, _mshift, \
0054 _mwidth, _dshift, _dwidth, _flags) \
0055 SPRD_COMP_CLK_DATA_TABLE(_struct, _name, _parent, _reg, NULL, \
0056 _mshift, _mwidth, _dshift, _dwidth, \
0057 _flags)
0058
0059 static inline struct sprd_comp *hw_to_sprd_comp(const struct clk_hw *hw)
0060 {
0061 struct sprd_clk_common *common = hw_to_sprd_clk_common(hw);
0062
0063 return container_of(common, struct sprd_comp, common);
0064 }
0065
0066 extern const struct clk_ops sprd_comp_ops;
0067
0068 #endif