Lines Matching +full:n +full:- +full:factor

1 // SPDX-License-Identifier: GPL-2.0+
3 // OWL factor clock driver
6 // Author: David Liu <liuwei@actions-semi.com>
11 #include <linux/clk-provider.h>
15 #include "owl-factor.h"
22 for (clkt = table; clkt->div; clkt++) in _get_table_maxval()
23 if (clkt->val > maxval) in _get_table_maxval()
24 maxval = clkt->val; in _get_table_maxval()
33 for (clkt = table; clkt->div; clkt++) { in _get_table_div_mul()
34 if (clkt->val == val) { in _get_table_div_mul()
35 *mul = clkt->mul; in _get_table_div_mul()
36 *div = clkt->div; in _get_table_div_mul()
48 int val = -1; in _get_table_val()
51 for (clkt = table; clkt->div; clkt++) { in _get_table_val()
52 calc_rate = parent_rate * clkt->mul; in _get_table_val()
53 do_div(calc_rate, clkt->div); in _get_table_val()
56 val = clkt->val; in _get_table_val()
61 if (val == -1) in _get_table_val()
71 const struct clk_factor_table *clkt = factor_hw->table; in owl_clk_val_best()
85 for (clkt = factor_hw->table; clkt->div; clkt++) { in owl_clk_val_best()
86 try_parent_rate = rate * clkt->div / clkt->mul; in owl_clk_val_best()
89 pr_debug("%s: [%d %d %d] found try_parent_rate %ld\n", in owl_clk_val_best()
90 __func__, clkt->val, clkt->mul, clkt->div, in owl_clk_val_best()
98 return clkt->val; in owl_clk_val_best()
103 cur_rate = DIV_ROUND_UP(parent_rate, clkt->div) * clkt->mul; in owl_clk_val_best()
105 bestval = clkt->val; in owl_clk_val_best()
125 const struct clk_factor_table *clkt = factor_hw->table; in owl_factor_helper_round_rate()
128 val = owl_clk_val_best(factor_hw, &common->hw, rate, parent_rate); in owl_factor_helper_round_rate()
137 struct owl_factor *factor = hw_to_owl_factor(hw); in owl_factor_round_rate() local
138 struct owl_factor_hw *factor_hw = &factor->factor_hw; in owl_factor_round_rate()
140 return owl_factor_helper_round_rate(&factor->common, factor_hw, in owl_factor_round_rate()
148 const struct clk_factor_table *clkt = factor_hw->table; in owl_factor_helper_recalc_rate()
155 regmap_read(common->regmap, factor_hw->reg, &reg); in owl_factor_helper_recalc_rate()
157 val = reg >> factor_hw->shift; in owl_factor_helper_recalc_rate()
162 WARN(!(factor_hw->fct_flags & CLK_DIVIDER_ALLOW_ZERO), in owl_factor_helper_recalc_rate()
163 "%s: Zero divisor and CLK_DIVIDER_ALLOW_ZERO not set\n", in owl_factor_helper_recalc_rate()
164 __clk_get_name(common->hw.clk)); in owl_factor_helper_recalc_rate()
177 struct owl_factor *factor = hw_to_owl_factor(hw); in owl_factor_recalc_rate() local
178 struct owl_factor_hw *factor_hw = &factor->factor_hw; in owl_factor_recalc_rate()
179 struct owl_clk_common *common = &factor->common; in owl_factor_recalc_rate()
191 val = _get_table_val(factor_hw->table, rate, parent_rate); in owl_factor_helper_set_rate()
196 regmap_read(common->regmap, factor_hw->reg, &reg); in owl_factor_helper_set_rate()
198 reg &= ~(div_mask(factor_hw) << factor_hw->shift); in owl_factor_helper_set_rate()
199 reg |= val << factor_hw->shift; in owl_factor_helper_set_rate()
201 regmap_write(common->regmap, factor_hw->reg, reg); in owl_factor_helper_set_rate()
209 struct owl_factor *factor = hw_to_owl_factor(hw); in owl_factor_set_rate() local
210 struct owl_factor_hw *factor_hw = &factor->factor_hw; in owl_factor_set_rate()
211 struct owl_clk_common *common = &factor->common; in owl_factor_set_rate()