1 /* SPDX-License-Identifier: GPL-2.0 */
3 // Spreadtrum composite clock driver
5 // Copyright (C) 2017 Spreadtrum, Inc.
6 // Author: Chunyan Zhang <chunyan.zhang@spreadtrum.com>
8 #ifndef _SPRD_COMPOSITE_H_
9 #define _SPRD_COMPOSITE_H_
16 struct sprd_mux_ssel mux
;
17 struct sprd_div_internal div
;
18 struct sprd_clk_common common
;
21 #define SPRD_COMP_CLK_HW_INIT_FN(_struct, _name, _parent, _reg, _table, \
22 _mshift, _mwidth, _doffset, _dshift, \
23 _dwidth, _flags, _fn) \
24 struct sprd_comp _struct = { \
25 .mux = _SPRD_MUX_CLK(_mshift, _mwidth, _table), \
26 .div = _SPRD_DIV_CLK(_doffset, _dshift, _dwidth), \
30 .hw.init = _fn(_name, _parent, \
31 &sprd_comp_ops, _flags), \
35 #define SPRD_COMP_CLK_TABLE(_struct, _name, _parent, _reg, _table, \
36 _mshift, _mwidth, _dshift, _dwidth, _flags) \
37 SPRD_COMP_CLK_HW_INIT_FN(_struct, _name, _parent, _reg, _table, \
38 _mshift, _mwidth, 0x0, _dshift, \
39 _dwidth, _flags, CLK_HW_INIT_PARENTS)
41 #define SPRD_COMP_CLK(_struct, _name, _parent, _reg, _mshift, \
42 _mwidth, _dshift, _dwidth, _flags) \
43 SPRD_COMP_CLK_TABLE(_struct, _name, _parent, _reg, NULL, \
44 _mshift, _mwidth, _dshift, _dwidth, _flags)
46 #define SPRD_COMP_CLK_DATA_TABLE(_struct, _name, _parent, _reg, _table, \
47 _mshift, _mwidth, _dshift, \
49 SPRD_COMP_CLK_HW_INIT_FN(_struct, _name, _parent, _reg, _table, \
50 _mshift, _mwidth, 0x0, _dshift, \
52 CLK_HW_INIT_PARENTS_DATA)
54 #define SPRD_COMP_CLK_DATA(_struct, _name, _parent, _reg, _mshift, \
55 _mwidth, _dshift, _dwidth, _flags) \
56 SPRD_COMP_CLK_DATA_TABLE(_struct, _name, _parent, _reg, NULL, \
57 _mshift, _mwidth, _dshift, _dwidth, \
60 #define SPRD_COMP_CLK_DATA_TABLE_OFFSET(_struct, _name, _parent, _reg, \
61 _table, _mshift, _mwidth, \
62 _doffset, _dshift, _dwidth, \
64 SPRD_COMP_CLK_HW_INIT_FN(_struct, _name, _parent, _reg, _table, \
65 _mshift, _mwidth, _doffset, _dshift, \
67 CLK_HW_INIT_PARENTS_DATA)
69 #define SPRD_COMP_CLK_DATA_OFFSET(_struct, _name, _parent, _reg, \
70 _mshift, _mwidth, _doffset, _dshift, \
72 SPRD_COMP_CLK_DATA_TABLE_OFFSET(_struct, _name, _parent, _reg, \
73 NULL, _mshift, _mwidth, \
74 _doffset, _dshift, _dwidth, \
77 static inline struct sprd_comp
*hw_to_sprd_comp(const struct clk_hw
*hw
)
79 struct sprd_clk_common
*common
= hw_to_sprd_clk_common(hw
);
81 return container_of(common
, struct sprd_comp
, common
);
84 extern const struct clk_ops sprd_comp_ops
;
86 #endif /* _SPRD_COMPOSITE_H_ */