Lines Matching +full:min +full:- +full:freq

4  *  Copyright (C) 2005 - 2010  Paul Mundt
8 * Copyright (C) 2004 - 2008 Nokia Corporation
46 unsigned long freq; in clk_rate_table_build() local
49 clk->nr_freqs = nr_freqs; in clk_rate_table_build()
55 if (src_table->divisors && i < src_table->nr_divisors) in clk_rate_table_build()
56 div = src_table->divisors[i]; in clk_rate_table_build()
58 if (src_table->multipliers && i < src_table->nr_multipliers) in clk_rate_table_build()
59 mult = src_table->multipliers[i]; in clk_rate_table_build()
62 freq = CPUFREQ_ENTRY_INVALID; in clk_rate_table_build()
64 freq = clk->parent->rate * mult / div; in clk_rate_table_build()
67 freq_table[i].frequency = freq; in clk_rate_table_build()
79 unsigned int min, max; member
84 #define for_each_frequency(pos, r, freq) \ argument
85 for (pos = r->min, freq = r->func(pos, r); \
86 pos <= r->max; pos++, freq = r->func(pos, r)) \
87 if (unlikely(freq == 0)) \
94 unsigned long highest, lowest, freq; in clk_rate_round_helper() local
95 long rate_best_fit = -ENOENT; in clk_rate_round_helper()
101 for_each_frequency(i, rounder, freq) { in clk_rate_round_helper()
102 if (freq > highest) in clk_rate_round_helper()
103 highest = freq; in clk_rate_round_helper()
104 if (freq < lowest) in clk_rate_round_helper()
105 lowest = freq; in clk_rate_round_helper()
107 rate_error = abs(freq - rounder->rate); in clk_rate_round_helper()
109 rate_best_fit = freq; in clk_rate_round_helper()
117 if (rounder->rate >= highest) in clk_rate_round_helper()
119 if (rounder->rate <= lowest) in clk_rate_round_helper()
128 struct cpufreq_frequency_table *freq_table = rounder->arg; in clk_rate_table_iter()
129 unsigned long freq = freq_table[pos].frequency; in clk_rate_table_iter() local
131 if (freq == CPUFREQ_ENTRY_INVALID) in clk_rate_table_iter()
132 freq = 0; in clk_rate_table_iter()
134 return freq; in clk_rate_table_iter()
142 .min = 0, in clk_rate_table_round()
143 .max = clk->nr_freqs - 1, in clk_rate_table_round()
149 if (clk->nr_freqs < 1) in clk_rate_table_round()
150 return -ENOSYS; in clk_rate_table_round()
158 return clk_get_rate(rounder->arg) / pos; in clk_rate_div_range_iter()
165 .min = div_min, in clk_rate_div_range_round()
178 return clk_get_rate(rounder->arg) * pos; in clk_rate_mult_range_iter()
185 .min = mult_min, in clk_rate_mult_range_round()
203 if (pos->frequency == rate) in clk_rate_table_find()
206 return -ENOENT; in clk_rate_table_find()
212 return clk->parent ? clk->parent->rate : 0; in followparent_recalc()
217 list_del_init(&child->sibling); in clk_reparent()
219 list_add(&child->sibling, &parent->children); in clk_reparent()
220 child->parent = parent; in clk_reparent()
230 list_for_each_entry(clkp, &tclk->children, sibling) { in propagate_rate()
231 if (clkp->ops && clkp->ops->recalc) in propagate_rate()
232 clkp->rate = clkp->ops->recalc(clkp); in propagate_rate()
240 if (WARN(!clk->usecount, "Trying to disable clock %p with 0 usecount\n", in __clk_disable()
244 if (!(--clk->usecount)) { in __clk_disable()
245 if (likely(allow_disable && clk->ops && clk->ops->disable)) in __clk_disable()
246 clk->ops->disable(clk); in __clk_disable()
247 if (likely(clk->parent)) in __clk_disable()
248 __clk_disable(clk->parent); in __clk_disable()
269 if (clk->usecount++ == 0) { in __clk_enable()
270 if (clk->parent) { in __clk_enable()
271 ret = __clk_enable(clk->parent); in __clk_enable()
276 if (clk->ops && clk->ops->enable) { in __clk_enable()
277 ret = clk->ops->enable(clk); in __clk_enable()
279 if (clk->parent) in __clk_enable()
280 __clk_disable(clk->parent); in __clk_enable()
288 clk->usecount--; in __clk_enable()
311 * recalculate_root_clocks - recalculate and propagate all root clocks
322 if (clkp->ops && clkp->ops->recalc) in recalculate_root_clocks()
323 clkp->rate = clkp->ops->recalc(clkp); in recalculate_root_clocks()
332 while (clk->parent) in lookup_root_clock()
333 clk = clk->parent; in lookup_root_clock()
340 struct clk_mapping *mapping = clk->mapping; in clk_establish_mapping()
351 if (!clk->parent) { in clk_establish_mapping()
352 clk->mapping = &dummy_mapping; in clk_establish_mapping()
361 mapping = clkp->mapping; in clk_establish_mapping()
368 if (!mapping->base && mapping->phys) { in clk_establish_mapping()
369 kref_init(&mapping->ref); in clk_establish_mapping()
371 mapping->base = ioremap(mapping->phys, mapping->len); in clk_establish_mapping()
372 if (unlikely(!mapping->base)) in clk_establish_mapping()
373 return -ENXIO; in clk_establish_mapping()
374 } else if (mapping->base) { in clk_establish_mapping()
378 kref_get(&mapping->ref); in clk_establish_mapping()
381 clk->mapping = mapping; in clk_establish_mapping()
383 clk->mapped_reg = clk->mapping->base; in clk_establish_mapping()
384 clk->mapped_reg += (phys_addr_t)clk->enable_reg - clk->mapping->phys; in clk_establish_mapping()
394 iounmap(mapping->base); in clk_destroy_mapping()
399 struct clk_mapping *mapping = clk->mapping; in clk_teardown_mapping()
405 kref_put(&mapping->ref, clk_destroy_mapping); in clk_teardown_mapping()
406 clk->mapping = NULL; in clk_teardown_mapping()
408 clk->mapped_reg = NULL; in clk_teardown_mapping()
416 return -EINVAL; in clk_register()
421 if (clk->node.next || clk->node.prev) in clk_register()
426 INIT_LIST_HEAD(&clk->children); in clk_register()
427 clk->usecount = 0; in clk_register()
433 if (clk->parent) in clk_register()
434 list_add(&clk->sibling, &clk->parent->children); in clk_register()
436 list_add(&clk->sibling, &root_clks); in clk_register()
438 list_add(&clk->node, &clock_list); in clk_register()
441 if (clk->ops && clk->ops->init) in clk_register()
442 clk->ops->init(clk); in clk_register()
455 list_del(&clk->sibling); in clk_unregister()
456 list_del(&clk->node); in clk_unregister()
467 if (clkp->flags & CLK_ENABLE_ON_INIT) in clk_enable_init_clocks()
476 return clk->rate; in clk_get_rate()
482 int ret = -EOPNOTSUPP; in clk_set_rate()
490 if (likely(clk->ops && clk->ops->set_rate)) { in clk_set_rate()
491 ret = clk->ops->set_rate(clk, rate); in clk_set_rate()
495 clk->rate = rate; in clk_set_rate()
499 if (clk->ops && clk->ops->recalc) in clk_set_rate()
500 clk->rate = clk->ops->recalc(clk); in clk_set_rate()
514 int ret = -EINVAL; in clk_set_parent()
518 if (clk->parent == parent) in clk_set_parent()
522 if (clk->usecount == 0) { in clk_set_parent()
523 if (clk->ops->set_parent) in clk_set_parent()
524 ret = clk->ops->set_parent(clk, parent); in clk_set_parent()
529 if (clk->ops->recalc) in clk_set_parent()
530 clk->rate = clk->ops->recalc(clk); in clk_set_parent()
532 clk, clk->parent, clk->rate); in clk_set_parent()
536 ret = -EBUSY; in clk_set_parent()
548 return clk->parent; in clk_get_parent()
557 if (likely(clk->ops && clk->ops->round_rate)) { in clk_round_rate()
561 rounded = clk->ops->round_rate(clk, rate); in clk_round_rate()
577 if (likely(clkp->usecount && clkp->ops)) { in clks_core_resume()
578 unsigned long rate = clkp->rate; in clks_core_resume()
580 if (likely(clkp->ops->set_parent)) in clks_core_resume()
581 clkp->ops->set_parent(clkp, in clks_core_resume()
582 clkp->parent); in clks_core_resume()
583 if (likely(clkp->ops->set_rate)) in clks_core_resume()
584 clkp->ops->set_rate(clkp, rate); in clks_core_resume()
585 else if (likely(clkp->ops->recalc)) in clks_core_resume()
586 clkp->rate = clkp->ops->recalc(clkp); in clks_core_resume()
614 if (!clk->usecount && clk->ops && clk->ops->disable) in clk_late_init()
615 clk->ops->disable(clk); in clk_late_init()