Lines Matching full:divider
2 * TI Divider Clock
40 static void _setup_mask(struct clk_omap_divider *divider) in _setup_mask() argument
46 if (divider->table) { in _setup_mask()
49 for (clkt = divider->table; clkt->div; clkt++) in _setup_mask()
53 max_val = divider->max; in _setup_mask()
55 if (!(divider->flags & CLK_DIVIDER_ONE_BASED) && in _setup_mask()
56 !(divider->flags & CLK_DIVIDER_POWER_OF_TWO)) in _setup_mask()
60 if (divider->flags & CLK_DIVIDER_POWER_OF_TWO) in _setup_mask()
65 divider->mask = (1 << fls(mask)) - 1; in _setup_mask()
68 static unsigned int _get_div(struct clk_omap_divider *divider, unsigned int val) in _get_div() argument
70 if (divider->flags & CLK_DIVIDER_ONE_BASED) in _get_div()
72 if (divider->flags & CLK_DIVIDER_POWER_OF_TWO) in _get_div()
74 if (divider->table) in _get_div()
75 return _get_table_div(divider->table, val); in _get_div()
90 static unsigned int _get_val(struct clk_omap_divider *divider, u8 div) in _get_val() argument
92 if (divider->flags & CLK_DIVIDER_ONE_BASED) in _get_val()
94 if (divider->flags & CLK_DIVIDER_POWER_OF_TWO) in _get_val()
96 if (divider->table) in _get_val()
97 return _get_table_val(divider->table, div); in _get_val()
104 struct clk_omap_divider *divider = to_clk_omap_divider(hw); in ti_clk_divider_recalc_rate() local
107 val = ti_clk_ll_ops->clk_readl(÷r->reg) >> divider->shift; in ti_clk_divider_recalc_rate()
108 val &= divider->mask; in ti_clk_divider_recalc_rate()
110 div = _get_div(divider, val); in ti_clk_divider_recalc_rate()
112 WARN(!(divider->flags & CLK_DIVIDER_ALLOW_ZERO), in ti_clk_divider_recalc_rate()
138 static bool _is_valid_div(struct clk_omap_divider *divider, unsigned int div) in _is_valid_div() argument
140 if (divider->flags & CLK_DIVIDER_POWER_OF_TWO) in _is_valid_div()
142 if (divider->table) in _is_valid_div()
143 return _is_valid_table_div(divider->table, div); in _is_valid_div()
179 struct clk_omap_divider *divider = to_clk_omap_divider(hw); in ti_clk_divider_bestdiv() local
187 maxdiv = divider->max; in ti_clk_divider_bestdiv()
191 bestdiv = _div_round(divider->table, parent_rate, rate); in ti_clk_divider_bestdiv()
198 * The maximum divider we can use without overflowing in ti_clk_divider_bestdiv()
204 if (!_is_valid_div(divider, i)) in ti_clk_divider_bestdiv()
210 * parent rate, so return the divider immediately. in ti_clk_divider_bestdiv()
226 bestdiv = divider->max; in ti_clk_divider_bestdiv()
246 struct clk_omap_divider *divider; in ti_clk_divider_set_rate() local
253 divider = to_clk_omap_divider(hw); in ti_clk_divider_set_rate()
257 if (div > divider->max) in ti_clk_divider_set_rate()
258 div = divider->max; in ti_clk_divider_set_rate()
259 if (div < divider->min) in ti_clk_divider_set_rate()
260 div = divider->min; in ti_clk_divider_set_rate()
262 value = _get_val(divider, div); in ti_clk_divider_set_rate()
264 val = ti_clk_ll_ops->clk_readl(÷r->reg); in ti_clk_divider_set_rate()
265 val &= ~(divider->mask << divider->shift); in ti_clk_divider_set_rate()
266 val |= value << divider->shift; in ti_clk_divider_set_rate()
267 ti_clk_ll_ops->clk_writel(val, ÷r->reg); in ti_clk_divider_set_rate()
269 ti_clk_latch(÷r->reg, divider->latch); in ti_clk_divider_set_rate()
275 * clk_divider_save_context - Save the divider value
278 * Save the divider value
282 struct clk_omap_divider *divider = to_clk_omap_divider(hw); in clk_divider_save_context() local
285 val = ti_clk_ll_ops->clk_readl(÷r->reg) >> divider->shift; in clk_divider_save_context()
286 divider->context = val & divider->mask; in clk_divider_save_context()
292 * clk_divider_restore_context - restore the saved the divider value
295 * Restore the saved the divider value
299 struct clk_omap_divider *divider = to_clk_omap_divider(hw); in clk_divider_restore_context() local
302 val = ti_clk_ll_ops->clk_readl(÷r->reg); in clk_divider_restore_context()
303 val &= ~(divider->mask << divider->shift); in clk_divider_restore_context()
304 val |= divider->context << divider->shift; in clk_divider_restore_context()
305 ti_clk_ll_ops->clk_writel(val, ÷r->reg); in clk_divider_restore_context()
344 u8 flags, struct clk_omap_divider *divider) in ti_clk_parse_divider_data() argument
352 divider->min = 1; in ti_clk_parse_divider_data()
353 divider->max = max_div; in ti_clk_parse_divider_data()
354 _setup_mask(divider); in ti_clk_parse_divider_data()
387 divider->min = min_div; in ti_clk_parse_divider_data()
388 divider->max = max_div; in ti_clk_parse_divider_data()
389 divider->table = tmp; in ti_clk_parse_divider_data()
390 _setup_mask(divider); in ti_clk_parse_divider_data()
414 /* Determine required size for divider table */ in ti_clk_get_div_table()
447 struct clk_omap_divider *divider) in _populate_divider_min_max() argument
454 if (!divider->table) { in _populate_divider_min_max()
455 /* Clk divider table not provided, determine min/max divs */ in _populate_divider_min_max()
465 for (clkt = divider->table; clkt->div; clkt++) { in _populate_divider_min_max()
474 divider->min = min_div; in _populate_divider_min_max()
475 divider->max = max_div; in _populate_divider_min_max()
476 _setup_mask(divider); in _populate_divider_min_max()
525 * Sets up a basic divider clock.
551 CLK_OF_DECLARE(divider_clk, "ti,divider-clock", of_ti_divider_clk_setup);
572 CLK_OF_DECLARE(ti_composite_divider_clk, "ti,composite-divider-clock",