Merge tag 'block-5.11-2021-01-10' of git://git.kernel.dk/linux-block
[linux/fpc-iii.git] / drivers / clk / actions / owl-factor.h
blob04b89cbfdccbb0ded9ceb5abc4df9607e3613c0a
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 //
3 // OWL factor clock driver
4 //
5 // Copyright (c) 2014 Actions Semi Inc.
6 // Author: David Liu <liuwei@actions-semi.com>
7 //
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 {
17 unsigned int val;
18 unsigned int mul;
19 unsigned int div;
22 struct owl_factor_hw {
23 u32 reg;
24 u8 shift;
25 u8 width;
26 u8 fct_flags;
27 struct clk_factor_table *table;
30 struct owl_factor {
31 struct owl_factor_hw factor_hw;
32 struct owl_clk_common common;
35 #define OWL_FACTOR_HW(_reg, _shift, _width, _fct_flags, _table) \
36 { \
37 .reg = _reg, \
38 .shift = _shift, \
39 .width = _width, \
40 .fct_flags = _fct_flags, \
41 .table = _table, \
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), \
49 .common = { \
50 .regmap = NULL, \
51 .hw.init = CLK_HW_INIT(_name, \
52 _parent, \
53 &owl_factor_ops, \
54 _flags), \
55 }, \
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,
69 unsigned long rate,
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,
78 unsigned long rate,
79 unsigned long parent_rate);
81 extern const struct clk_ops owl_factor_ops;
83 #endif /* _OWL_FACTOR_H_ */