Merge tag 'block-5.11-2021-01-10' of git://git.kernel.dk/linux-block
[linux/fpc-iii.git] / drivers / clk / sprd / composite.h
blobadbabbe596b7018bc0c67f4d1c1d77639708fb1c
1 /* SPDX-License-Identifier: GPL-2.0 */
2 //
3 // Spreadtrum composite clock driver
4 //
5 // Copyright (C) 2017 Spreadtrum, Inc.
6 // Author: Chunyan Zhang <chunyan.zhang@spreadtrum.com>
8 #ifndef _SPRD_COMPOSITE_H_
9 #define _SPRD_COMPOSITE_H_
11 #include "common.h"
12 #include "mux.h"
13 #include "div.h"
15 struct sprd_comp {
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, _dshift, _dwidth, \
23 _flags, _fn) \
24 struct sprd_comp _struct = { \
25 .mux = _SPRD_MUX_CLK(_mshift, _mwidth, _table), \
26 .div = _SPRD_DIV_CLK(_dshift, _dwidth), \
27 .common = { \
28 .regmap = NULL, \
29 .reg = _reg, \
30 .hw.init = _fn(_name, _parent, \
31 &sprd_comp_ops, _flags), \
32 } \
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, _dshift, _dwidth, \
39 _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, \
48 _dwidth, _flags) \
49 SPRD_COMP_CLK_HW_INIT_FN(_struct, _name, _parent, _reg, _table, \
50 _mshift, _mwidth, _dshift, _dwidth, \
51 _flags, CLK_HW_INIT_PARENTS_DATA)
53 #define SPRD_COMP_CLK_DATA(_struct, _name, _parent, _reg, _mshift, \
54 _mwidth, _dshift, _dwidth, _flags) \
55 SPRD_COMP_CLK_DATA_TABLE(_struct, _name, _parent, _reg, NULL, \
56 _mshift, _mwidth, _dshift, _dwidth, \
57 _flags)
59 static inline struct sprd_comp *hw_to_sprd_comp(const struct clk_hw *hw)
61 struct sprd_clk_common *common = hw_to_sprd_clk_common(hw);
63 return container_of(common, struct sprd_comp, common);
66 extern const struct clk_ops sprd_comp_ops;
68 #endif /* _SPRD_COMPOSITE_H_ */