1 /* SPDX-License-Identifier: GPL-2.0+ */
3 // OWL factor 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_FACTOR_H_
12 #define _OWL_FACTOR_H_
14 #include "owl-common.h"
16 struct clk_factor_table
{
22 struct owl_factor_hw
{
27 struct clk_factor_table
*table
;
31 struct owl_factor_hw factor_hw
;
32 struct owl_clk_common common
;
35 #define OWL_FACTOR_HW(_reg, _shift, _width, _fct_flags, _table) \
40 .fct_flags = _fct_flags, \
44 #define OWL_FACTOR(_struct, _name, _parent, _reg, \
45 _shift, _width, _table, _fct_flags, _flags) \
46 struct owl_factor _struct = { \
47 .factor_hw = OWL_FACTOR_HW(_reg, _shift, \
48 _width, _fct_flags, _table), \
51 .hw.init = CLK_HW_INIT(_name, \
58 #define div_mask(d) ((1 << ((d)->width)) - 1)
60 static inline struct owl_factor
*hw_to_owl_factor(const struct clk_hw
*hw
)
62 struct owl_clk_common
*common
= hw_to_owl_clk_common(hw
);
64 return container_of(common
, struct owl_factor
, common
);
67 long owl_factor_helper_round_rate(struct owl_clk_common
*common
,
68 const struct owl_factor_hw
*factor_hw
,
70 unsigned long *parent_rate
);
72 unsigned long owl_factor_helper_recalc_rate(struct owl_clk_common
*common
,
73 const struct owl_factor_hw
*factor_hw
,
74 unsigned long parent_rate
);
76 int owl_factor_helper_set_rate(const struct owl_clk_common
*common
,
77 const struct owl_factor_hw
*factor_hw
,
79 unsigned long parent_rate
);
81 extern const struct clk_ops owl_factor_ops
;
83 #endif /* _OWL_FACTOR_H_ */