0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef _OWL_FACTOR_H_
0012 #define _OWL_FACTOR_H_
0013
0014 #include "owl-common.h"
0015
0016 struct clk_factor_table {
0017 unsigned int val;
0018 unsigned int mul;
0019 unsigned int div;
0020 };
0021
0022 struct owl_factor_hw {
0023 u32 reg;
0024 u8 shift;
0025 u8 width;
0026 u8 fct_flags;
0027 struct clk_factor_table *table;
0028 };
0029
0030 struct owl_factor {
0031 struct owl_factor_hw factor_hw;
0032 struct owl_clk_common common;
0033 };
0034
0035 #define OWL_FACTOR_HW(_reg, _shift, _width, _fct_flags, _table) \
0036 { \
0037 .reg = _reg, \
0038 .shift = _shift, \
0039 .width = _width, \
0040 .fct_flags = _fct_flags, \
0041 .table = _table, \
0042 }
0043
0044 #define OWL_FACTOR(_struct, _name, _parent, _reg, \
0045 _shift, _width, _table, _fct_flags, _flags) \
0046 struct owl_factor _struct = { \
0047 .factor_hw = OWL_FACTOR_HW(_reg, _shift, \
0048 _width, _fct_flags, _table), \
0049 .common = { \
0050 .regmap = NULL, \
0051 .hw.init = CLK_HW_INIT(_name, \
0052 _parent, \
0053 &owl_factor_ops, \
0054 _flags), \
0055 }, \
0056 }
0057
0058 #define div_mask(d) ((1 << ((d)->width)) - 1)
0059
0060 static inline struct owl_factor *hw_to_owl_factor(const struct clk_hw *hw)
0061 {
0062 struct owl_clk_common *common = hw_to_owl_clk_common(hw);
0063
0064 return container_of(common, struct owl_factor, common);
0065 }
0066
0067 long owl_factor_helper_round_rate(struct owl_clk_common *common,
0068 const struct owl_factor_hw *factor_hw,
0069 unsigned long rate,
0070 unsigned long *parent_rate);
0071
0072 unsigned long owl_factor_helper_recalc_rate(struct owl_clk_common *common,
0073 const struct owl_factor_hw *factor_hw,
0074 unsigned long parent_rate);
0075
0076 int owl_factor_helper_set_rate(const struct owl_clk_common *common,
0077 const struct owl_factor_hw *factor_hw,
0078 unsigned long rate,
0079 unsigned long parent_rate);
0080
0081 extern const struct clk_ops owl_factor_ops;
0082
0083 #endif