0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef _OWL_DIVIDER_H_
0012 #define _OWL_DIVIDER_H_
0013
0014 #include "owl-common.h"
0015
0016 struct owl_divider_hw {
0017 u32 reg;
0018 u8 shift;
0019 u8 width;
0020 u8 div_flags;
0021 struct clk_div_table *table;
0022 };
0023
0024 struct owl_divider {
0025 struct owl_divider_hw div_hw;
0026 struct owl_clk_common common;
0027 };
0028
0029 #define OWL_DIVIDER_HW(_reg, _shift, _width, _div_flags, _table) \
0030 { \
0031 .reg = _reg, \
0032 .shift = _shift, \
0033 .width = _width, \
0034 .div_flags = _div_flags, \
0035 .table = _table, \
0036 }
0037
0038 #define OWL_DIVIDER(_struct, _name, _parent, _reg, \
0039 _shift, _width, _table, _div_flags, _flags) \
0040 struct owl_divider _struct = { \
0041 .div_hw = OWL_DIVIDER_HW(_reg, _shift, _width, \
0042 _div_flags, _table), \
0043 .common = { \
0044 .regmap = NULL, \
0045 .hw.init = CLK_HW_INIT(_name, \
0046 _parent, \
0047 &owl_divider_ops, \
0048 _flags), \
0049 }, \
0050 }
0051
0052 static inline struct owl_divider *hw_to_owl_divider(const struct clk_hw *hw)
0053 {
0054 struct owl_clk_common *common = hw_to_owl_clk_common(hw);
0055
0056 return container_of(common, struct owl_divider, common);
0057 }
0058
0059 long owl_divider_helper_round_rate(struct owl_clk_common *common,
0060 const struct owl_divider_hw *div_hw,
0061 unsigned long rate,
0062 unsigned long *parent_rate);
0063
0064 unsigned long owl_divider_helper_recalc_rate(struct owl_clk_common *common,
0065 const struct owl_divider_hw *div_hw,
0066 unsigned long parent_rate);
0067
0068 int owl_divider_helper_set_rate(const struct owl_clk_common *common,
0069 const struct owl_divider_hw *div_hw,
0070 unsigned long rate,
0071 unsigned long parent_rate);
0072
0073 extern const struct clk_ops owl_divider_ops;
0074
0075 #endif