Skip to content

Commit 3317cb1

Browse files
smaeulmripard
authored andcommitted
clk: sunxi-ng: div: Add macros using clk_parent_data and clk_hw
Referencing parents with clk_hw pointers is more efficient and removes the dependency on global clock names. clk_parent_data is needed when some parent clocks are provided from another driver. Add macros for declaring dividers that take advantage of these. Signed-off-by: Samuel Holland <[email protected]> Signed-off-by: Maxime Ripard <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent c962f10 commit 3317cb1

File tree

1 file changed

+78
-0
lines changed

1 file changed

+78
-0
lines changed

drivers/clk/sunxi-ng/ccu_div.h

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,22 @@ struct ccu_div {
108108
_shift, _width, _table, 0, \
109109
_flags)
110110

111+
#define SUNXI_CCU_DIV_TABLE_HW(_struct, _name, _parent, _reg, \
112+
_shift, _width, \
113+
_table, _flags) \
114+
struct ccu_div _struct = { \
115+
.div = _SUNXI_CCU_DIV_TABLE(_shift, _width, \
116+
_table), \
117+
.common = { \
118+
.reg = _reg, \
119+
.hw.init = CLK_HW_INIT_HW(_name, \
120+
_parent, \
121+
&ccu_div_ops, \
122+
_flags), \
123+
} \
124+
}
125+
126+
111127
#define SUNXI_CCU_M_WITH_MUX_TABLE_GATE(_struct, _name, \
112128
_parents, _table, \
113129
_reg, \
@@ -166,6 +182,68 @@ struct ccu_div {
166182
SUNXI_CCU_M_WITH_GATE(_struct, _name, _parent, _reg, \
167183
_mshift, _mwidth, 0, _flags)
168184

185+
#define SUNXI_CCU_M_DATA_WITH_MUX_GATE(_struct, _name, _parents, _reg, \
186+
_mshift, _mwidth, \
187+
_muxshift, _muxwidth, \
188+
_gate, _flags) \
189+
struct ccu_div _struct = { \
190+
.enable = _gate, \
191+
.div = _SUNXI_CCU_DIV(_mshift, _mwidth), \
192+
.mux = _SUNXI_CCU_MUX(_muxshift, _muxwidth), \
193+
.common = { \
194+
.reg = _reg, \
195+
.hw.init = CLK_HW_INIT_PARENTS_DATA(_name, \
196+
_parents, \
197+
&ccu_div_ops, \
198+
_flags), \
199+
}, \
200+
}
201+
202+
#define SUNXI_CCU_M_DATA_WITH_MUX(_struct, _name, _parents, _reg, \
203+
_mshift, _mwidth, \
204+
_muxshift, _muxwidth, \
205+
_flags) \
206+
SUNXI_CCU_M_DATA_WITH_MUX_GATE(_struct, _name, _parents, _reg, \
207+
_mshift, _mwidth, \
208+
_muxshift, _muxwidth, \
209+
0, _flags)
210+
211+
#define SUNXI_CCU_M_HW_WITH_MUX_GATE(_struct, _name, _parents, _reg, \
212+
_mshift, _mwidth, _muxshift, _muxwidth, \
213+
_gate, _flags) \
214+
struct ccu_div _struct = { \
215+
.enable = _gate, \
216+
.div = _SUNXI_CCU_DIV(_mshift, _mwidth), \
217+
.mux = _SUNXI_CCU_MUX(_muxshift, _muxwidth), \
218+
.common = { \
219+
.reg = _reg, \
220+
.hw.init = CLK_HW_INIT_PARENTS_HW(_name, \
221+
_parents, \
222+
&ccu_div_ops, \
223+
_flags), \
224+
}, \
225+
}
226+
227+
#define SUNXI_CCU_M_HWS_WITH_GATE(_struct, _name, _parent, _reg, \
228+
_mshift, _mwidth, _gate, \
229+
_flags) \
230+
struct ccu_div _struct = { \
231+
.enable = _gate, \
232+
.div = _SUNXI_CCU_DIV(_mshift, _mwidth), \
233+
.common = { \
234+
.reg = _reg, \
235+
.hw.init = CLK_HW_INIT_HWS(_name, \
236+
_parent, \
237+
&ccu_div_ops, \
238+
_flags), \
239+
}, \
240+
}
241+
242+
#define SUNXI_CCU_M_HWS(_struct, _name, _parent, _reg, _mshift, \
243+
_mwidth, _flags) \
244+
SUNXI_CCU_M_HWS_WITH_GATE(_struct, _name, _parent, _reg, \
245+
_mshift, _mwidth, 0, _flags)
246+
169247
static inline struct ccu_div *hw_to_ccu_div(struct clk_hw *hw)
170248
{
171249
struct ccu_common *common = hw_to_ccu_common(hw);

0 commit comments

Comments
 (0)