1 // SPDX-License-Identifier: GPL-2.0+
3 // OWL composite clock driver
5 // Copyright (c) 2014 Actions Semi Inc.
6 // Author: David Liu <liuwei@actions-semi.com>
8 // Copyright (c) 2018 Linaro Ltd.
9 // Author: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
11 #ifndef _OWL_COMPOSITE_H_
12 #define _OWL_COMPOSITE_H_
14 #include "owl-common.h"
17 #include "owl-factor.h"
18 #include "owl-fixed-factor.h"
19 #include "owl-divider.h"
22 struct owl_divider_hw div_hw
;
23 struct owl_factor_hw factor_hw
;
24 struct clk_fixed_factor fix_fact_hw
;
27 struct owl_composite
{
28 struct owl_mux_hw mux_hw
;
29 struct owl_gate_hw gate_hw
;
32 const struct clk_ops
*fix_fact_ops
;
34 struct owl_clk_common common
;
37 #define OWL_COMP_DIV(_struct, _name, _parent, \
38 _mux, _gate, _div, _flags) \
39 struct owl_composite _struct = { \
42 .rate.div_hw = _div, \
45 .hw.init = CLK_HW_INIT_PARENTS(_name, \
52 #define OWL_COMP_DIV_FIXED(_struct, _name, _parent, \
53 _gate, _div, _flags) \
54 struct owl_composite _struct = { \
56 .rate.div_hw = _div, \
59 .hw.init = CLK_HW_INIT(_name, \
66 #define OWL_COMP_FACTOR(_struct, _name, _parent, \
67 _mux, _gate, _factor, _flags) \
68 struct owl_composite _struct = { \
71 .rate.factor_hw = _factor, \
74 .hw.init = CLK_HW_INIT_PARENTS(_name, \
81 #define OWL_COMP_FIXED_FACTOR(_struct, _name, _parent, \
82 _gate, _mul, _div, _flags) \
83 struct owl_composite _struct = { \
85 .rate.fix_fact_hw.mult = _mul, \
86 .rate.fix_fact_hw.div = _div, \
87 .fix_fact_ops = &clk_fixed_factor_ops, \
90 .hw.init = CLK_HW_INIT(_name, \
92 &owl_comp_fix_fact_ops,\
97 #define OWL_COMP_PASS(_struct, _name, _parent, \
98 _mux, _gate, _flags) \
99 struct owl_composite _struct = { \
104 .hw.init = CLK_HW_INIT_PARENTS(_name, \
111 static inline struct owl_composite
*hw_to_owl_comp(const struct clk_hw
*hw
)
113 struct owl_clk_common
*common
= hw_to_owl_clk_common(hw
);
115 return container_of(common
, struct owl_composite
, common
);
118 extern const struct clk_ops owl_comp_div_ops
;
119 extern const struct clk_ops owl_comp_fact_ops
;
120 extern const struct clk_ops owl_comp_fix_fact_ops
;
121 extern const struct clk_ops owl_comp_pass_ops
;
122 extern const struct clk_ops clk_fixed_factor_ops
;
124 #endif /* _OWL_COMPOSITE_H_ */