Lines Matching refs:clk

39 void clk_rate_table_build(struct clk *clk,  in clk_rate_table_build()  argument
49 clk->nr_freqs = nr_freqs; in clk_rate_table_build()
64 freq = clk->parent->rate * mult / div; in clk_rate_table_build()
137 long clk_rate_table_round(struct clk *clk, in clk_rate_table_round() argument
143 .max = clk->nr_freqs - 1, in clk_rate_table_round()
149 if (clk->nr_freqs < 1) in clk_rate_table_round()
161 long clk_rate_div_range_round(struct clk *clk, unsigned int div_min, in clk_rate_div_range_round() argument
168 .arg = clk_get_parent(clk), in clk_rate_div_range_round()
181 long clk_rate_mult_range_round(struct clk *clk, unsigned int mult_min, in clk_rate_mult_range_round() argument
188 .arg = clk_get_parent(clk), in clk_rate_mult_range_round()
195 int clk_rate_table_find(struct clk *clk, in clk_rate_table_find() argument
210 unsigned long followparent_recalc(struct clk *clk) in followparent_recalc() argument
212 return clk->parent ? clk->parent->rate : 0; in followparent_recalc()
215 int clk_reparent(struct clk *child, struct clk *parent) in clk_reparent()
226 void propagate_rate(struct clk *tclk) in propagate_rate()
228 struct clk *clkp; in propagate_rate()
238 static void __clk_disable(struct clk *clk) in __clk_disable() argument
240 if (WARN(!clk->usecount, "Trying to disable clock %p with 0 usecount\n", in __clk_disable()
241 clk)) 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()
252 void clk_disable(struct clk *clk) in clk_disable() argument
256 if (!clk) in clk_disable()
260 __clk_disable(clk); in clk_disable()
265 static int __clk_enable(struct clk *clk) in __clk_enable() argument
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()
292 int clk_enable(struct clk *clk) in clk_enable() argument
297 if (!clk) in clk_enable()
301 ret = __clk_enable(clk); in clk_enable()
319 struct clk *clkp; in recalculate_root_clocks()
330 static struct clk *lookup_root_clock(struct clk *clk) in lookup_root_clock() argument
332 while (clk->parent) in lookup_root_clock()
333 clk = clk->parent; in lookup_root_clock()
335 return clk; in lookup_root_clock()
338 static int clk_establish_mapping(struct clk *clk) in clk_establish_mapping() argument
340 struct clk_mapping *mapping = clk->mapping; in clk_establish_mapping()
346 struct clk *clkp; in clk_establish_mapping()
351 if (!clk->parent) { in clk_establish_mapping()
352 clk->mapping = &dummy_mapping; in clk_establish_mapping()
360 clkp = lookup_root_clock(clk); 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()
397 static void clk_teardown_mapping(struct clk *clk) in clk_teardown_mapping() argument
399 struct clk_mapping *mapping = clk->mapping; in clk_teardown_mapping()
406 clk->mapping = NULL; in clk_teardown_mapping()
408 clk->mapped_reg = NULL; in clk_teardown_mapping()
411 int clk_register(struct clk *clk) in clk_register() argument
415 if (IS_ERR_OR_NULL(clk)) 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()
429 ret = clk_establish_mapping(clk); 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()
452 void clk_unregister(struct clk *clk) in clk_unregister() argument
455 list_del(&clk->sibling); in clk_unregister()
456 list_del(&clk->node); in clk_unregister()
457 clk_teardown_mapping(clk); in clk_unregister()
464 struct clk *clkp; in clk_enable_init_clocks()
471 unsigned long clk_get_rate(struct clk *clk) in clk_get_rate() argument
473 if (!clk) in clk_get_rate()
476 return clk->rate; in clk_get_rate()
480 int clk_set_rate(struct clk *clk, unsigned long rate) in clk_set_rate() argument
485 if (!clk) 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()
502 propagate_rate(clk); in clk_set_rate()
511 int clk_set_parent(struct clk *clk, struct clk *parent) in clk_set_parent() argument
516 if (!parent || !clk) 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()
526 ret = clk_reparent(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()
533 propagate_rate(clk); in clk_set_parent()
543 struct clk *clk_get_parent(struct clk *clk) in clk_get_parent() argument
545 if (!clk) in clk_get_parent()
548 return clk->parent; in clk_get_parent()
552 long clk_round_rate(struct clk *clk, unsigned long rate) in clk_round_rate() argument
554 if (!clk) in clk_round_rate()
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()
567 return clk_get_rate(clk); in clk_round_rate()
574 struct clk *clkp; in clks_core_resume()
607 struct clk *clk; in clk_late_init() local
613 list_for_each_entry(clk, &clock_list, node) in clk_late_init()
614 if (!clk->usecount && clk->ops && clk->ops->disable) in clk_late_init()
615 clk->ops->disable(clk); in clk_late_init()