• Home
  • Raw
  • Download

Lines Matching full:core

97 	struct clk_core	*core;  member
107 static int clk_pm_runtime_get(struct clk_core *core) in clk_pm_runtime_get() argument
111 if (!core->dev) in clk_pm_runtime_get()
114 ret = pm_runtime_get_sync(core->dev); in clk_pm_runtime_get()
116 pm_runtime_put_noidle(core->dev); in clk_pm_runtime_get()
122 static void clk_pm_runtime_put(struct clk_core *core) in clk_pm_runtime_put() argument
124 if (!core->dev) in clk_pm_runtime_put()
127 pm_runtime_put_sync(core->dev); in clk_pm_runtime_put()
199 static bool clk_core_rate_is_protected(struct clk_core *core) in clk_core_rate_is_protected() argument
201 return core->protect_count; in clk_core_rate_is_protected()
204 static bool clk_core_is_prepared(struct clk_core *core) in clk_core_is_prepared() argument
212 if (!core->ops->is_prepared) in clk_core_is_prepared()
213 return core->prepare_count; in clk_core_is_prepared()
215 if (!clk_pm_runtime_get(core)) { in clk_core_is_prepared()
216 ret = core->ops->is_prepared(core->hw); in clk_core_is_prepared()
217 clk_pm_runtime_put(core); in clk_core_is_prepared()
223 static bool clk_core_is_enabled(struct clk_core *core) in clk_core_is_enabled() argument
231 if (!core->ops->is_enabled) in clk_core_is_enabled()
232 return core->enable_count; in clk_core_is_enabled()
244 if (core->dev) { in clk_core_is_enabled()
245 pm_runtime_get_noresume(core->dev); in clk_core_is_enabled()
246 if (!pm_runtime_active(core->dev)) { in clk_core_is_enabled()
252 ret = core->ops->is_enabled(core->hw); in clk_core_is_enabled()
254 if (core->dev) in clk_core_is_enabled()
255 pm_runtime_put(core->dev); in clk_core_is_enabled()
264 return !clk ? NULL : clk->core->name; in __clk_get_name()
270 return hw->core->name; in clk_hw_get_name()
276 return !clk ? NULL : clk->core->hw; in __clk_get_hw()
282 return hw->core->num_parents; in clk_hw_get_num_parents()
288 return hw->core->parent ? hw->core->parent->hw : NULL; in clk_hw_get_parent()
293 struct clk_core *core) in __clk_lookup_subtree() argument
298 if (!strcmp(core->name, name)) in __clk_lookup_subtree()
299 return core; in __clk_lookup_subtree()
301 hlist_for_each_entry(child, &core->children, child_node) { in __clk_lookup_subtree()
335 static struct clk_core *clk_core_get_parent_by_index(struct clk_core *core, in clk_core_get_parent_by_index() argument
338 if (!core || index >= core->num_parents) in clk_core_get_parent_by_index()
341 if (!core->parents[index]) in clk_core_get_parent_by_index()
342 core->parents[index] = in clk_core_get_parent_by_index()
343 clk_core_lookup(core->parent_names[index]); in clk_core_get_parent_by_index()
345 return core->parents[index]; in clk_core_get_parent_by_index()
353 parent = clk_core_get_parent_by_index(hw->core, index); in clk_hw_get_parent_by_index()
361 return !clk ? 0 : clk->core->enable_count; in __clk_get_enable_count()
364 static unsigned long clk_core_get_rate_nolock(struct clk_core *core) in clk_core_get_rate_nolock() argument
368 if (!core) { in clk_core_get_rate_nolock()
373 ret = core->rate; in clk_core_get_rate_nolock()
375 if (!core->num_parents) in clk_core_get_rate_nolock()
378 if (!core->parent) in clk_core_get_rate_nolock()
387 return clk_core_get_rate_nolock(hw->core); in clk_hw_get_rate()
391 static unsigned long __clk_get_accuracy(struct clk_core *core) in __clk_get_accuracy() argument
393 if (!core) in __clk_get_accuracy()
396 return core->accuracy; in __clk_get_accuracy()
401 return !clk ? 0 : clk->core->flags; in __clk_get_flags()
407 return hw->core->flags; in clk_hw_get_flags()
413 return clk_core_is_prepared(hw->core); in clk_hw_is_prepared()
418 return clk_core_rate_is_protected(hw->core); in clk_hw_rate_is_protected()
423 return clk_core_is_enabled(hw->core); in clk_hw_is_enabled()
431 return clk_core_is_enabled(clk->core); in __clk_is_enabled()
448 struct clk_core *core = hw->core, *parent, *best_parent = NULL; in clk_mux_determine_rate_flags() local
454 if (core->flags & CLK_SET_RATE_NO_REPARENT) { in clk_mux_determine_rate_flags()
455 parent = core->parent; in clk_mux_determine_rate_flags()
456 if (core->flags & CLK_SET_RATE_PARENT) { in clk_mux_determine_rate_flags()
466 best = clk_core_get_rate_nolock(core); in clk_mux_determine_rate_flags()
473 num_parents = core->num_parents; in clk_mux_determine_rate_flags()
475 parent = clk_core_get_parent_by_index(core, i); in clk_mux_determine_rate_flags()
479 if (core->flags & CLK_SET_RATE_PARENT) { in clk_mux_determine_rate_flags()
510 struct clk_core *core = clk_core_lookup(name); in __clk_lookup() local
512 return !core ? NULL : core->hw->clk; in __clk_lookup()
515 static void clk_core_get_boundaries(struct clk_core *core, in clk_core_get_boundaries() argument
521 *min_rate = core->min_rate; in clk_core_get_boundaries()
522 *max_rate = core->max_rate; in clk_core_get_boundaries()
524 hlist_for_each_entry(clk_user, &core->clks, clks_node) in clk_core_get_boundaries()
527 hlist_for_each_entry(clk_user, &core->clks, clks_node) in clk_core_get_boundaries()
534 hw->core->min_rate = min_rate; in clk_hw_set_rate_range()
535 hw->core->max_rate = max_rate; in clk_hw_set_rate_range()
560 static void clk_core_rate_unprotect(struct clk_core *core) in clk_core_rate_unprotect() argument
564 if (!core) in clk_core_rate_unprotect()
567 if (WARN(core->protect_count == 0, in clk_core_rate_unprotect()
568 "%s already unprotected\n", core->name)) in clk_core_rate_unprotect()
571 if (--core->protect_count > 0) in clk_core_rate_unprotect()
574 clk_core_rate_unprotect(core->parent); in clk_core_rate_unprotect()
577 static int clk_core_rate_nuke_protect(struct clk_core *core) in clk_core_rate_nuke_protect() argument
583 if (!core) in clk_core_rate_nuke_protect()
586 if (core->protect_count == 0) in clk_core_rate_nuke_protect()
589 ret = core->protect_count; in clk_core_rate_nuke_protect()
590 core->protect_count = 1; in clk_core_rate_nuke_protect()
591 clk_core_rate_unprotect(core); in clk_core_rate_nuke_protect()
628 clk_core_rate_unprotect(clk->core); in clk_rate_exclusive_put()
635 static void clk_core_rate_protect(struct clk_core *core) in clk_core_rate_protect() argument
639 if (!core) in clk_core_rate_protect()
642 if (core->protect_count == 0) in clk_core_rate_protect()
643 clk_core_rate_protect(core->parent); in clk_core_rate_protect()
645 core->protect_count++; in clk_core_rate_protect()
648 static void clk_core_rate_restore_protect(struct clk_core *core, int count) in clk_core_rate_restore_protect() argument
652 if (!core) in clk_core_rate_restore_protect()
658 clk_core_rate_protect(core); in clk_core_rate_restore_protect()
659 core->protect_count = count; in clk_core_rate_restore_protect()
686 clk_core_rate_protect(clk->core); in clk_rate_exclusive_get()
694 static void clk_core_unprepare(struct clk_core *core) in clk_core_unprepare() argument
698 if (!core) in clk_core_unprepare()
701 if (WARN(core->prepare_count == 0, in clk_core_unprepare()
702 "%s already unprepared\n", core->name)) in clk_core_unprepare()
705 if (WARN(core->prepare_count == 1 && core->flags & CLK_IS_CRITICAL, in clk_core_unprepare()
706 "Unpreparing critical %s\n", core->name)) in clk_core_unprepare()
709 if (core->flags & CLK_SET_RATE_GATE) in clk_core_unprepare()
710 clk_core_rate_unprotect(core); in clk_core_unprepare()
712 if (--core->prepare_count > 0) in clk_core_unprepare()
715 WARN(core->enable_count > 0, "Unpreparing enabled %s\n", core->name); in clk_core_unprepare()
717 trace_clk_unprepare(core); in clk_core_unprepare()
719 if (core->ops->unprepare) in clk_core_unprepare()
720 core->ops->unprepare(core->hw); in clk_core_unprepare()
722 clk_pm_runtime_put(core); in clk_core_unprepare()
724 trace_clk_unprepare_complete(core); in clk_core_unprepare()
725 clk_core_unprepare(core->parent); in clk_core_unprepare()
728 static void clk_core_unprepare_lock(struct clk_core *core) in clk_core_unprepare_lock() argument
731 clk_core_unprepare(core); in clk_core_unprepare_lock()
751 clk_core_unprepare_lock(clk->core); in clk_unprepare()
755 static int clk_core_prepare(struct clk_core *core) in clk_core_prepare() argument
761 if (!core) in clk_core_prepare()
764 if (core->prepare_count == 0) { in clk_core_prepare()
765 ret = clk_pm_runtime_get(core); in clk_core_prepare()
769 ret = clk_core_prepare(core->parent); in clk_core_prepare()
773 trace_clk_prepare(core); in clk_core_prepare()
775 if (core->ops->prepare) in clk_core_prepare()
776 ret = core->ops->prepare(core->hw); in clk_core_prepare()
778 trace_clk_prepare_complete(core); in clk_core_prepare()
784 core->prepare_count++; in clk_core_prepare()
793 if (core->flags & CLK_SET_RATE_GATE) in clk_core_prepare()
794 clk_core_rate_protect(core); in clk_core_prepare()
798 clk_core_unprepare(core->parent); in clk_core_prepare()
800 clk_pm_runtime_put(core); in clk_core_prepare()
804 static int clk_core_prepare_lock(struct clk_core *core) in clk_core_prepare_lock() argument
809 ret = clk_core_prepare(core); in clk_core_prepare_lock()
832 return clk_core_prepare_lock(clk->core); in clk_prepare()
836 static void clk_core_disable(struct clk_core *core) in clk_core_disable() argument
840 if (!core) in clk_core_disable()
843 if (WARN(core->enable_count == 0, "%s already disabled\n", core->name)) in clk_core_disable()
846 if (WARN(core->enable_count == 1 && core->flags & CLK_IS_CRITICAL, in clk_core_disable()
847 "Disabling critical %s\n", core->name)) in clk_core_disable()
850 if (--core->enable_count > 0) in clk_core_disable()
853 trace_clk_disable_rcuidle(core); in clk_core_disable()
855 if (core->ops->disable) in clk_core_disable()
856 core->ops->disable(core->hw); in clk_core_disable()
858 trace_clk_disable_complete_rcuidle(core); in clk_core_disable()
860 clk_core_disable(core->parent); in clk_core_disable()
863 static void clk_core_disable_lock(struct clk_core *core) in clk_core_disable_lock() argument
868 clk_core_disable(core); in clk_core_disable_lock()
889 clk_core_disable_lock(clk->core); in clk_disable()
893 static int clk_core_enable(struct clk_core *core) in clk_core_enable() argument
899 if (!core) in clk_core_enable()
902 if (WARN(core->prepare_count == 0, in clk_core_enable()
903 "Enabling unprepared %s\n", core->name)) in clk_core_enable()
906 if (core->enable_count == 0) { in clk_core_enable()
907 ret = clk_core_enable(core->parent); in clk_core_enable()
912 trace_clk_enable_rcuidle(core); in clk_core_enable()
914 if (core->ops->enable) in clk_core_enable()
915 ret = core->ops->enable(core->hw); in clk_core_enable()
917 trace_clk_enable_complete_rcuidle(core); in clk_core_enable()
920 clk_core_disable(core->parent); in clk_core_enable()
925 core->enable_count++; in clk_core_enable()
929 static int clk_core_enable_lock(struct clk_core *core) in clk_core_enable_lock() argument
935 ret = clk_core_enable(core); in clk_core_enable_lock()
959 return clk_core_enable_lock(clk->core); in clk_enable()
963 static int clk_core_prepare_enable(struct clk_core *core) in clk_core_prepare_enable() argument
967 ret = clk_core_prepare_lock(core); in clk_core_prepare_enable()
971 ret = clk_core_enable_lock(core); in clk_core_prepare_enable()
973 clk_core_unprepare_lock(core); in clk_core_prepare_enable()
978 static void clk_core_disable_unprepare(struct clk_core *core) in clk_core_disable_unprepare() argument
980 clk_core_disable_lock(core); in clk_core_disable_unprepare()
981 clk_core_unprepare_lock(core); in clk_core_disable_unprepare()
984 static void clk_unprepare_unused_subtree(struct clk_core *core) in clk_unprepare_unused_subtree() argument
990 hlist_for_each_entry(child, &core->children, child_node) in clk_unprepare_unused_subtree()
993 if (core->prepare_count) in clk_unprepare_unused_subtree()
996 if (core->flags & CLK_IGNORE_UNUSED) in clk_unprepare_unused_subtree()
999 if (clk_pm_runtime_get(core)) in clk_unprepare_unused_subtree()
1002 if (clk_core_is_prepared(core)) { in clk_unprepare_unused_subtree()
1003 trace_clk_unprepare(core); in clk_unprepare_unused_subtree()
1004 if (core->ops->unprepare_unused) in clk_unprepare_unused_subtree()
1005 core->ops->unprepare_unused(core->hw); in clk_unprepare_unused_subtree()
1006 else if (core->ops->unprepare) in clk_unprepare_unused_subtree()
1007 core->ops->unprepare(core->hw); in clk_unprepare_unused_subtree()
1008 trace_clk_unprepare_complete(core); in clk_unprepare_unused_subtree()
1011 clk_pm_runtime_put(core); in clk_unprepare_unused_subtree()
1014 static void clk_disable_unused_subtree(struct clk_core *core) in clk_disable_unused_subtree() argument
1021 hlist_for_each_entry(child, &core->children, child_node) in clk_disable_unused_subtree()
1024 if (core->flags & CLK_OPS_PARENT_ENABLE) in clk_disable_unused_subtree()
1025 clk_core_prepare_enable(core->parent); in clk_disable_unused_subtree()
1027 if (clk_pm_runtime_get(core)) in clk_disable_unused_subtree()
1032 if (core->enable_count) in clk_disable_unused_subtree()
1035 if (core->flags & CLK_IGNORE_UNUSED) in clk_disable_unused_subtree()
1043 if (clk_core_is_enabled(core)) { in clk_disable_unused_subtree()
1044 trace_clk_disable(core); in clk_disable_unused_subtree()
1045 if (core->ops->disable_unused) in clk_disable_unused_subtree()
1046 core->ops->disable_unused(core->hw); in clk_disable_unused_subtree()
1047 else if (core->ops->disable) in clk_disable_unused_subtree()
1048 core->ops->disable(core->hw); in clk_disable_unused_subtree()
1049 trace_clk_disable_complete(core); in clk_disable_unused_subtree()
1054 clk_pm_runtime_put(core); in clk_disable_unused_subtree()
1056 if (core->flags & CLK_OPS_PARENT_ENABLE) in clk_disable_unused_subtree()
1057 clk_core_disable_unprepare(core->parent); in clk_disable_unused_subtree()
1070 struct clk_core *core; in clk_disable_unused() local
1079 hlist_for_each_entry(core, &clk_root_list, child_node) in clk_disable_unused()
1080 clk_disable_unused_subtree(core); in clk_disable_unused()
1082 hlist_for_each_entry(core, &clk_orphan_list, child_node) in clk_disable_unused()
1083 clk_disable_unused_subtree(core); in clk_disable_unused()
1085 hlist_for_each_entry(core, &clk_root_list, child_node) in clk_disable_unused()
1086 clk_unprepare_unused_subtree(core); in clk_disable_unused()
1088 hlist_for_each_entry(core, &clk_orphan_list, child_node) in clk_disable_unused()
1089 clk_unprepare_unused_subtree(core); in clk_disable_unused()
1097 static int clk_core_determine_round_nolock(struct clk_core *core, in clk_core_determine_round_nolock() argument
1104 if (!core) in clk_core_determine_round_nolock()
1108 * At this point, core protection will be disabled if in clk_core_determine_round_nolock()
1113 if (clk_core_rate_is_protected(core)) { in clk_core_determine_round_nolock()
1114 req->rate = core->rate; in clk_core_determine_round_nolock()
1115 } else if (core->ops->determine_rate) { in clk_core_determine_round_nolock()
1116 return core->ops->determine_rate(core->hw, req); in clk_core_determine_round_nolock()
1117 } else if (core->ops->round_rate) { in clk_core_determine_round_nolock()
1118 rate = core->ops->round_rate(core->hw, req->rate, in clk_core_determine_round_nolock()
1131 static void clk_core_init_rate_req(struct clk_core * const core, in clk_core_init_rate_req() argument
1136 if (WARN_ON(!core || !req)) in clk_core_init_rate_req()
1139 parent = core->parent; in clk_core_init_rate_req()
1149 static bool clk_core_can_round(struct clk_core * const core) in clk_core_can_round() argument
1151 if (core->ops->determine_rate || core->ops->round_rate) in clk_core_can_round()
1157 static int clk_core_round_rate_nolock(struct clk_core *core, in clk_core_round_rate_nolock() argument
1162 if (!core) { in clk_core_round_rate_nolock()
1167 clk_core_init_rate_req(core, req); in clk_core_round_rate_nolock()
1169 if (clk_core_can_round(core)) in clk_core_round_rate_nolock()
1170 return clk_core_determine_round_nolock(core, req); in clk_core_round_rate_nolock()
1171 else if (core->flags & CLK_SET_RATE_PARENT) in clk_core_round_rate_nolock()
1172 return clk_core_round_rate_nolock(core->parent, req); in clk_core_round_rate_nolock()
1174 req->rate = core->rate; in clk_core_round_rate_nolock()
1192 return clk_core_round_rate_nolock(hw->core, req); in __clk_determine_rate()
1201 clk_core_get_boundaries(hw->core, &req.min_rate, &req.max_rate); in clk_hw_round_rate()
1204 ret = clk_core_round_rate_nolock(hw->core, &req); in clk_hw_round_rate()
1232 clk_core_rate_unprotect(clk->core); in clk_round_rate()
1234 clk_core_get_boundaries(clk->core, &req.min_rate, &req.max_rate); in clk_round_rate()
1237 ret = clk_core_round_rate_nolock(clk->core, &req); in clk_round_rate()
1240 clk_core_rate_protect(clk->core); in clk_round_rate()
1253 * @core: clk that is changing rate
1265 static int __clk_notify(struct clk_core *core, unsigned long msg, in __clk_notify() argument
1276 if (cn->clk->core == core) { in __clk_notify()
1290 * @core: first clk in the subtree
1297 static void __clk_recalc_accuracies(struct clk_core *core) in __clk_recalc_accuracies() argument
1304 if (core->parent) in __clk_recalc_accuracies()
1305 parent_accuracy = core->parent->accuracy; in __clk_recalc_accuracies()
1307 if (core->ops->recalc_accuracy) in __clk_recalc_accuracies()
1308 core->accuracy = core->ops->recalc_accuracy(core->hw, in __clk_recalc_accuracies()
1311 core->accuracy = parent_accuracy; in __clk_recalc_accuracies()
1313 hlist_for_each_entry(child, &core->children, child_node) in __clk_recalc_accuracies()
1317 static long clk_core_get_accuracy(struct clk_core *core) in clk_core_get_accuracy() argument
1322 if (core && (core->flags & CLK_GET_ACCURACY_NOCACHE)) in clk_core_get_accuracy()
1323 __clk_recalc_accuracies(core); in clk_core_get_accuracy()
1325 accuracy = __clk_get_accuracy(core); in clk_core_get_accuracy()
1345 return clk_core_get_accuracy(clk->core); in clk_get_accuracy()
1349 static unsigned long clk_recalc(struct clk_core *core, in clk_recalc() argument
1354 if (core->ops->recalc_rate && !clk_pm_runtime_get(core)) { in clk_recalc()
1355 rate = core->ops->recalc_rate(core->hw, parent_rate); in clk_recalc()
1356 clk_pm_runtime_put(core); in clk_recalc()
1363 * @core: first clk in the subtree
1373 static void __clk_recalc_rates(struct clk_core *core, unsigned long msg) in __clk_recalc_rates() argument
1381 old_rate = core->rate; in __clk_recalc_rates()
1383 if (core->parent) in __clk_recalc_rates()
1384 parent_rate = core->parent->rate; in __clk_recalc_rates()
1386 core->rate = clk_recalc(core, parent_rate); in __clk_recalc_rates()
1392 if (core->notifier_count && msg) in __clk_recalc_rates()
1393 __clk_notify(core, msg, old_rate, core->rate); in __clk_recalc_rates()
1395 hlist_for_each_entry(child, &core->children, child_node) in __clk_recalc_rates()
1399 static unsigned long clk_core_get_rate(struct clk_core *core) in clk_core_get_rate() argument
1405 if (core && (core->flags & CLK_GET_RATE_NOCACHE)) in clk_core_get_rate()
1406 __clk_recalc_rates(core, 0); in clk_core_get_rate()
1408 rate = clk_core_get_rate_nolock(core); in clk_core_get_rate()
1427 return clk_core_get_rate(clk->core); in clk_get_rate()
1431 static int clk_fetch_parent_index(struct clk_core *core, in clk_fetch_parent_index() argument
1439 for (i = 0; i < core->num_parents; i++) in clk_fetch_parent_index()
1440 if (clk_core_get_parent_by_index(core, i) == parent) in clk_fetch_parent_index()
1447 * Update the orphan status of @core and all its children.
1449 static void clk_core_update_orphan_status(struct clk_core *core, bool is_orphan) in clk_core_update_orphan_status() argument
1453 core->orphan = is_orphan; in clk_core_update_orphan_status()
1455 hlist_for_each_entry(child, &core->children, child_node) in clk_core_update_orphan_status()
1459 static void clk_reparent(struct clk_core *core, struct clk_core *new_parent) in clk_reparent() argument
1461 bool was_orphan = core->orphan; in clk_reparent()
1463 hlist_del(&core->child_node); in clk_reparent()
1469 if (new_parent->new_child == core) in clk_reparent()
1472 hlist_add_head(&core->child_node, &new_parent->children); in clk_reparent()
1475 clk_core_update_orphan_status(core, becomes_orphan); in clk_reparent()
1477 hlist_add_head(&core->child_node, &clk_orphan_list); in clk_reparent()
1479 clk_core_update_orphan_status(core, true); in clk_reparent()
1482 core->parent = new_parent; in clk_reparent()
1485 static struct clk_core *__clk_set_parent_before(struct clk_core *core, in __clk_set_parent_before() argument
1489 struct clk_core *old_parent = core->parent; in __clk_set_parent_before()
1512 if (core->flags & CLK_OPS_PARENT_ENABLE) { in __clk_set_parent_before()
1518 if (core->prepare_count) { in __clk_set_parent_before()
1520 clk_core_enable_lock(core); in __clk_set_parent_before()
1525 clk_reparent(core, parent); in __clk_set_parent_before()
1531 static void __clk_set_parent_after(struct clk_core *core, in __clk_set_parent_after() argument
1539 if (core->prepare_count) { in __clk_set_parent_after()
1540 clk_core_disable_lock(core); in __clk_set_parent_after()
1545 if (core->flags & CLK_OPS_PARENT_ENABLE) { in __clk_set_parent_after()
1551 static int __clk_set_parent(struct clk_core *core, struct clk_core *parent, in __clk_set_parent() argument
1558 old_parent = __clk_set_parent_before(core, parent); in __clk_set_parent()
1560 trace_clk_set_parent(core, parent); in __clk_set_parent()
1563 if (parent && core->ops->set_parent) in __clk_set_parent()
1564 ret = core->ops->set_parent(core->hw, p_index); in __clk_set_parent()
1566 trace_clk_set_parent_complete(core, parent); in __clk_set_parent()
1570 clk_reparent(core, old_parent); in __clk_set_parent()
1572 __clk_set_parent_after(core, old_parent, parent); in __clk_set_parent()
1577 __clk_set_parent_after(core, parent, old_parent); in __clk_set_parent()
1584 * @core: first clk in the subtree
1596 static int __clk_speculate_rates(struct clk_core *core, in __clk_speculate_rates() argument
1605 new_rate = clk_recalc(core, parent_rate); in __clk_speculate_rates()
1608 if (core->notifier_count) in __clk_speculate_rates()
1609 ret = __clk_notify(core, PRE_RATE_CHANGE, core->rate, new_rate); in __clk_speculate_rates()
1613 __func__, core->name, ret); in __clk_speculate_rates()
1617 hlist_for_each_entry(child, &core->children, child_node) { in __clk_speculate_rates()
1627 static void clk_calc_subtree(struct clk_core *core, unsigned long new_rate, in clk_calc_subtree() argument
1632 core->new_rate = new_rate; in clk_calc_subtree()
1633 core->new_parent = new_parent; in clk_calc_subtree()
1634 core->new_parent_index = p_index; in clk_calc_subtree()
1636 core->new_child = NULL; in clk_calc_subtree()
1637 if (new_parent && new_parent != core->parent) in clk_calc_subtree()
1638 new_parent->new_child = core; in clk_calc_subtree()
1640 hlist_for_each_entry(child, &core->children, child_node) { in clk_calc_subtree()
1650 static struct clk_core *clk_calc_new_rates(struct clk_core *core, in clk_calc_new_rates() argument
1653 struct clk_core *top = core; in clk_calc_new_rates()
1663 if (IS_ERR_OR_NULL(core)) in clk_calc_new_rates()
1667 parent = old_parent = core->parent; in clk_calc_new_rates()
1671 clk_core_get_boundaries(core, &min_rate, &max_rate); in clk_calc_new_rates()
1674 if (clk_core_can_round(core)) { in clk_calc_new_rates()
1681 clk_core_init_rate_req(core, &req); in clk_calc_new_rates()
1683 ret = clk_core_determine_round_nolock(core, &req); in clk_calc_new_rates()
1689 parent = req.best_parent_hw ? req.best_parent_hw->core : NULL; in clk_calc_new_rates()
1693 } else if (!parent || !(core->flags & CLK_SET_RATE_PARENT)) { in clk_calc_new_rates()
1695 core->new_rate = core->rate; in clk_calc_new_rates()
1706 (core->flags & CLK_SET_PARENT_GATE) && core->prepare_count) { in clk_calc_new_rates()
1708 __func__, core->name); in clk_calc_new_rates()
1713 if (parent && core->num_parents > 1) { in clk_calc_new_rates()
1714 p_index = clk_fetch_parent_index(core, parent); in clk_calc_new_rates()
1717 __func__, parent->name, core->name); in clk_calc_new_rates()
1722 if ((core->flags & CLK_SET_RATE_PARENT) && parent && in clk_calc_new_rates()
1727 clk_calc_subtree(core, new_rate, parent, p_index); in clk_calc_new_rates()
1737 static struct clk_core *clk_propagate_rate_change(struct clk_core *core, in clk_propagate_rate_change() argument
1743 if (core->rate == core->new_rate) in clk_propagate_rate_change()
1746 if (core->notifier_count) { in clk_propagate_rate_change()
1747 ret = __clk_notify(core, event, core->rate, core->new_rate); in clk_propagate_rate_change()
1749 fail_clk = core; in clk_propagate_rate_change()
1752 hlist_for_each_entry(child, &core->children, child_node) { in clk_propagate_rate_change()
1754 if (child->new_parent && child->new_parent != core) in clk_propagate_rate_change()
1761 /* handle the new child who might not be in core->children yet */ in clk_propagate_rate_change()
1762 if (core->new_child) { in clk_propagate_rate_change()
1763 tmp_clk = clk_propagate_rate_change(core->new_child, event); in clk_propagate_rate_change()
1775 static void clk_change_rate(struct clk_core *core) in clk_change_rate() argument
1785 old_rate = core->rate; in clk_change_rate()
1787 if (core->new_parent) { in clk_change_rate()
1788 parent = core->new_parent; in clk_change_rate()
1789 best_parent_rate = core->new_parent->rate; in clk_change_rate()
1790 } else if (core->parent) { in clk_change_rate()
1791 parent = core->parent; in clk_change_rate()
1792 best_parent_rate = core->parent->rate; in clk_change_rate()
1795 if (clk_pm_runtime_get(core)) in clk_change_rate()
1798 if (core->flags & CLK_SET_RATE_UNGATE) { in clk_change_rate()
1801 clk_core_prepare(core); in clk_change_rate()
1803 clk_core_enable(core); in clk_change_rate()
1807 if (core->new_parent && core->new_parent != core->parent) { in clk_change_rate()
1808 old_parent = __clk_set_parent_before(core, core->new_parent); in clk_change_rate()
1809 trace_clk_set_parent(core, core->new_parent); in clk_change_rate()
1811 if (core->ops->set_rate_and_parent) { in clk_change_rate()
1813 core->ops->set_rate_and_parent(core->hw, core->new_rate, in clk_change_rate()
1815 core->new_parent_index); in clk_change_rate()
1816 } else if (core->ops->set_parent) { in clk_change_rate()
1817 core->ops->set_parent(core->hw, core->new_parent_index); in clk_change_rate()
1820 trace_clk_set_parent_complete(core, core->new_parent); in clk_change_rate()
1821 __clk_set_parent_after(core, core->new_parent, old_parent); in clk_change_rate()
1824 if (core->flags & CLK_OPS_PARENT_ENABLE) in clk_change_rate()
1827 trace_clk_set_rate(core, core->new_rate); in clk_change_rate()
1829 if (!skip_set_rate && core->ops->set_rate) in clk_change_rate()
1830 core->ops->set_rate(core->hw, core->new_rate, best_parent_rate); in clk_change_rate()
1832 trace_clk_set_rate_complete(core, core->new_rate); in clk_change_rate()
1834 core->rate = clk_recalc(core, best_parent_rate); in clk_change_rate()
1836 if (core->flags & CLK_SET_RATE_UNGATE) { in clk_change_rate()
1840 clk_core_disable(core); in clk_change_rate()
1842 clk_core_unprepare(core); in clk_change_rate()
1845 if (core->flags & CLK_OPS_PARENT_ENABLE) in clk_change_rate()
1848 if (core->notifier_count && old_rate != core->rate) in clk_change_rate()
1849 __clk_notify(core, POST_RATE_CHANGE, old_rate, core->rate); in clk_change_rate()
1851 if (core->flags & CLK_RECALC_NEW_RATES) in clk_change_rate()
1852 (void)clk_calc_new_rates(core, core->new_rate); in clk_change_rate()
1858 hlist_for_each_entry_safe(child, tmp, &core->children, child_node) { in clk_change_rate()
1860 if (child->new_parent && child->new_parent != core) in clk_change_rate()
1865 /* handle the new child who might not be in core->children yet */ in clk_change_rate()
1866 if (core->new_child) in clk_change_rate()
1867 clk_change_rate(core->new_child); in clk_change_rate()
1869 clk_pm_runtime_put(core); in clk_change_rate()
1872 static unsigned long clk_core_req_round_rate_nolock(struct clk_core *core, in clk_core_req_round_rate_nolock() argument
1880 if (!core) in clk_core_req_round_rate_nolock()
1884 cnt = clk_core_rate_nuke_protect(core); in clk_core_req_round_rate_nolock()
1888 clk_core_get_boundaries(core, &req.min_rate, &req.max_rate); in clk_core_req_round_rate_nolock()
1891 ret = clk_core_round_rate_nolock(core, &req); in clk_core_req_round_rate_nolock()
1894 clk_core_rate_restore_protect(core, cnt); in clk_core_req_round_rate_nolock()
1899 static int clk_core_set_rate_nolock(struct clk_core *core, in clk_core_set_rate_nolock() argument
1906 if (!core) in clk_core_set_rate_nolock()
1909 rate = clk_core_req_round_rate_nolock(core, req_rate); in clk_core_set_rate_nolock()
1912 if (rate == clk_core_get_rate_nolock(core)) in clk_core_set_rate_nolock()
1916 if (clk_core_rate_is_protected(core)) in clk_core_set_rate_nolock()
1920 top = clk_calc_new_rates(core, req_rate); in clk_core_set_rate_nolock()
1924 ret = clk_pm_runtime_get(core); in clk_core_set_rate_nolock()
1941 core->req_rate = req_rate; in clk_core_set_rate_nolock()
1943 clk_pm_runtime_put(core); in clk_core_set_rate_nolock()
1980 clk_core_rate_unprotect(clk->core); in clk_set_rate()
1982 ret = clk_core_set_rate_nolock(clk->core, rate); in clk_set_rate()
1985 clk_core_rate_protect(clk->core); in clk_set_rate()
2028 ret = clk_core_set_rate_nolock(clk->core, rate); in clk_set_rate_exclusive()
2030 clk_core_rate_protect(clk->core); in clk_set_rate_exclusive()
2058 __func__, clk->core->name, clk->dev_id, clk->con_id, in clk_set_rate_range()
2066 clk_core_rate_unprotect(clk->core); in clk_set_rate_range()
2074 rate = clk_core_get_rate_nolock(clk->core); in clk_set_rate_range()
2094 ret = clk_core_set_rate_nolock(clk->core, rate); in clk_set_rate_range()
2103 clk_core_rate_protect(clk->core); in clk_set_rate_range()
2158 parent = !clk->core->parent ? NULL : clk->core->parent->hw->clk; in clk_get_parent()
2165 static struct clk_core *__clk_init_parent(struct clk_core *core) in __clk_init_parent() argument
2169 if (core->num_parents > 1 && core->ops->get_parent) in __clk_init_parent()
2170 index = core->ops->get_parent(core->hw); in __clk_init_parent()
2172 return clk_core_get_parent_by_index(core, index); in __clk_init_parent()
2175 static void clk_core_reparent(struct clk_core *core, in clk_core_reparent() argument
2178 clk_reparent(core, new_parent); in clk_core_reparent()
2179 __clk_recalc_accuracies(core); in clk_core_reparent()
2180 __clk_recalc_rates(core, POST_RATE_CHANGE); in clk_core_reparent()
2188 clk_core_reparent(hw->core, !new_parent ? NULL : new_parent->core); in clk_hw_reparent()
2203 struct clk_core *core, *parent_core; in clk_has_parent() local
2209 core = clk->core; in clk_has_parent()
2210 parent_core = parent->core; in clk_has_parent()
2213 if (core->parent == parent_core) in clk_has_parent()
2216 return match_string(core->parent_names, core->num_parents, in clk_has_parent()
2221 static int clk_core_set_parent_nolock(struct clk_core *core, in clk_core_set_parent_nolock() argument
2230 if (!core) in clk_core_set_parent_nolock()
2233 if (core->parent == parent) in clk_core_set_parent_nolock()
2237 if (core->num_parents > 1 && !core->ops->set_parent) in clk_core_set_parent_nolock()
2241 if ((core->flags & CLK_SET_PARENT_GATE) && core->prepare_count) in clk_core_set_parent_nolock()
2244 if (clk_core_rate_is_protected(core)) in clk_core_set_parent_nolock()
2249 p_index = clk_fetch_parent_index(core, parent); in clk_core_set_parent_nolock()
2252 __func__, parent->name, core->name); in clk_core_set_parent_nolock()
2258 ret = clk_pm_runtime_get(core); in clk_core_set_parent_nolock()
2263 ret = __clk_speculate_rates(core, p_rate); in clk_core_set_parent_nolock()
2270 ret = __clk_set_parent(core, parent, p_index); in clk_core_set_parent_nolock()
2274 __clk_recalc_rates(core, ABORT_RATE_CHANGE); in clk_core_set_parent_nolock()
2276 __clk_recalc_rates(core, POST_RATE_CHANGE); in clk_core_set_parent_nolock()
2277 __clk_recalc_accuracies(core); in clk_core_set_parent_nolock()
2281 clk_pm_runtime_put(core); in clk_core_set_parent_nolock()
2313 clk_core_rate_unprotect(clk->core); in clk_set_parent()
2315 ret = clk_core_set_parent_nolock(clk->core, in clk_set_parent()
2316 parent ? parent->core : NULL); in clk_set_parent()
2319 clk_core_rate_protect(clk->core); in clk_set_parent()
2327 static int clk_core_set_phase_nolock(struct clk_core *core, int degrees) in clk_core_set_phase_nolock() argument
2333 if (!core) in clk_core_set_phase_nolock()
2336 if (clk_core_rate_is_protected(core)) in clk_core_set_phase_nolock()
2339 trace_clk_set_phase(core, degrees); in clk_core_set_phase_nolock()
2341 if (core->ops->set_phase) { in clk_core_set_phase_nolock()
2342 ret = core->ops->set_phase(core->hw, degrees); in clk_core_set_phase_nolock()
2344 core->phase = degrees; in clk_core_set_phase_nolock()
2347 trace_clk_set_phase_complete(core, degrees); in clk_core_set_phase_nolock()
2387 clk_core_rate_unprotect(clk->core); in clk_set_phase()
2389 ret = clk_core_set_phase_nolock(clk->core, degrees); in clk_set_phase()
2392 clk_core_rate_protect(clk->core); in clk_set_phase()
2400 static int clk_core_get_phase(struct clk_core *core) in clk_core_get_phase() argument
2406 if (core->ops->get_phase) in clk_core_get_phase()
2407 core->phase = core->ops->get_phase(core->hw); in clk_core_get_phase()
2408 ret = core->phase; in clk_core_get_phase()
2426 return clk_core_get_phase(clk->core); in clk_get_phase()
2430 static void clk_core_reset_duty_cycle_nolock(struct clk_core *core) in clk_core_reset_duty_cycle_nolock() argument
2433 core->duty.num = 1; in clk_core_reset_duty_cycle_nolock()
2434 core->duty.den = 2; in clk_core_reset_duty_cycle_nolock()
2437 static int clk_core_update_duty_cycle_parent_nolock(struct clk_core *core);
2439 static int clk_core_update_duty_cycle_nolock(struct clk_core *core) in clk_core_update_duty_cycle_nolock() argument
2441 struct clk_duty *duty = &core->duty; in clk_core_update_duty_cycle_nolock()
2444 if (!core->ops->get_duty_cycle) in clk_core_update_duty_cycle_nolock()
2445 return clk_core_update_duty_cycle_parent_nolock(core); in clk_core_update_duty_cycle_nolock()
2447 ret = core->ops->get_duty_cycle(core->hw, duty); in clk_core_update_duty_cycle_nolock()
2460 clk_core_reset_duty_cycle_nolock(core); in clk_core_update_duty_cycle_nolock()
2464 static int clk_core_update_duty_cycle_parent_nolock(struct clk_core *core) in clk_core_update_duty_cycle_parent_nolock() argument
2468 if (core->parent && in clk_core_update_duty_cycle_parent_nolock()
2469 core->flags & CLK_DUTY_CYCLE_PARENT) { in clk_core_update_duty_cycle_parent_nolock()
2470 ret = clk_core_update_duty_cycle_nolock(core->parent); in clk_core_update_duty_cycle_parent_nolock()
2471 memcpy(&core->duty, &core->parent->duty, sizeof(core->duty)); in clk_core_update_duty_cycle_parent_nolock()
2473 clk_core_reset_duty_cycle_nolock(core); in clk_core_update_duty_cycle_parent_nolock()
2479 static int clk_core_set_duty_cycle_parent_nolock(struct clk_core *core,
2482 static int clk_core_set_duty_cycle_nolock(struct clk_core *core, in clk_core_set_duty_cycle_nolock() argument
2489 if (clk_core_rate_is_protected(core)) in clk_core_set_duty_cycle_nolock()
2492 trace_clk_set_duty_cycle(core, duty); in clk_core_set_duty_cycle_nolock()
2494 if (!core->ops->set_duty_cycle) in clk_core_set_duty_cycle_nolock()
2495 return clk_core_set_duty_cycle_parent_nolock(core, duty); in clk_core_set_duty_cycle_nolock()
2497 ret = core->ops->set_duty_cycle(core->hw, duty); in clk_core_set_duty_cycle_nolock()
2499 memcpy(&core->duty, duty, sizeof(*duty)); in clk_core_set_duty_cycle_nolock()
2501 trace_clk_set_duty_cycle_complete(core, duty); in clk_core_set_duty_cycle_nolock()
2506 static int clk_core_set_duty_cycle_parent_nolock(struct clk_core *core, in clk_core_set_duty_cycle_parent_nolock() argument
2511 if (core->parent && in clk_core_set_duty_cycle_parent_nolock()
2512 core->flags & (CLK_DUTY_CYCLE_PARENT | CLK_SET_RATE_PARENT)) { in clk_core_set_duty_cycle_parent_nolock()
2513 ret = clk_core_set_duty_cycle_nolock(core->parent, duty); in clk_core_set_duty_cycle_parent_nolock()
2514 memcpy(&core->duty, &core->parent->duty, sizeof(core->duty)); in clk_core_set_duty_cycle_parent_nolock()
2549 clk_core_rate_unprotect(clk->core); in clk_set_duty_cycle()
2551 ret = clk_core_set_duty_cycle_nolock(clk->core, &duty); in clk_set_duty_cycle()
2554 clk_core_rate_protect(clk->core); in clk_set_duty_cycle()
2562 static int clk_core_get_scaled_duty_cycle(struct clk_core *core, in clk_core_get_scaled_duty_cycle() argument
2565 struct clk_duty *duty = &core->duty; in clk_core_get_scaled_duty_cycle()
2570 ret = clk_core_update_duty_cycle_nolock(core); in clk_core_get_scaled_duty_cycle()
2592 return clk_core_get_scaled_duty_cycle(clk->core, scale); in clk_get_scaled_duty_cycle()
2613 /* true if clk->core pointers match. Avoid dereferencing garbage */ in clk_is_match()
2615 if (p->core == q->core) in clk_is_match()
2764 struct clk_core *core = s->private; in clk_flags_show() local
2765 unsigned long flags = core->flags; in clk_flags_show()
2785 struct clk_core *core = s->private; in possible_parents_show() local
2788 for (i = 0; i < core->num_parents - 1; i++) in possible_parents_show()
2789 seq_printf(s, "%s ", core->parent_names[i]); in possible_parents_show()
2791 seq_printf(s, "%s\n", core->parent_names[i]); in possible_parents_show()
2799 struct clk_core *core = s->private; in clk_duty_cycle_show() local
2800 struct clk_duty *duty = &core->duty; in clk_duty_cycle_show()
2808 static void clk_debug_create_one(struct clk_core *core, struct dentry *pdentry) in clk_debug_create_one() argument
2812 if (!core || !pdentry) in clk_debug_create_one()
2815 root = debugfs_create_dir(core->name, pdentry); in clk_debug_create_one()
2816 core->dentry = root; in clk_debug_create_one()
2818 debugfs_create_ulong("clk_rate", 0444, root, &core->rate); in clk_debug_create_one()
2819 debugfs_create_ulong("clk_accuracy", 0444, root, &core->accuracy); in clk_debug_create_one()
2820 debugfs_create_u32("clk_phase", 0444, root, &core->phase); in clk_debug_create_one()
2821 debugfs_create_file("clk_flags", 0444, root, core, &clk_flags_fops); in clk_debug_create_one()
2822 debugfs_create_u32("clk_prepare_count", 0444, root, &core->prepare_count); in clk_debug_create_one()
2823 debugfs_create_u32("clk_enable_count", 0444, root, &core->enable_count); in clk_debug_create_one()
2824 debugfs_create_u32("clk_protect_count", 0444, root, &core->protect_count); in clk_debug_create_one()
2825 debugfs_create_u32("clk_notifier_count", 0444, root, &core->notifier_count); in clk_debug_create_one()
2826 debugfs_create_file("clk_duty_cycle", 0444, root, core, in clk_debug_create_one()
2829 if (core->num_parents > 1) in clk_debug_create_one()
2830 debugfs_create_file("clk_possible_parents", 0444, root, core, in clk_debug_create_one()
2833 if (core->ops->debug_init) in clk_debug_create_one()
2834 core->ops->debug_init(core->hw, core->dentry); in clk_debug_create_one()
2839 * @core: the clk being added to the debugfs clk directory
2845 static void clk_debug_register(struct clk_core *core) in clk_debug_register() argument
2848 hlist_add_head(&core->debug_node, &clk_debug_list); in clk_debug_register()
2850 clk_debug_create_one(core, rootdir); in clk_debug_register()
2856 * @core: the clk being removed from the debugfs clk directory
2862 static void clk_debug_unregister(struct clk_core *core) in clk_debug_unregister() argument
2865 hlist_del_init(&core->debug_node); in clk_debug_unregister()
2866 debugfs_remove_recursive(core->dentry); in clk_debug_unregister()
2867 core->dentry = NULL; in clk_debug_unregister()
2882 struct clk_core *core; in clk_debug_init() local
2896 hlist_for_each_entry(core, &clk_debug_list, debug_node) in clk_debug_init()
2897 clk_debug_create_one(core, rootdir); in clk_debug_init()
2906 static inline void clk_debug_register(struct clk_core *core) { } in clk_debug_register() argument
2907 static inline void clk_debug_reparent(struct clk_core *core, in clk_debug_reparent() argument
2911 static inline void clk_debug_unregister(struct clk_core *core) in clk_debug_unregister() argument
2918 * @core: clk_core being initialized
2923 static int __clk_core_init(struct clk_core *core) in __clk_core_init() argument
2930 if (!core) in __clk_core_init()
2935 ret = clk_pm_runtime_get(core); in __clk_core_init()
2940 if (clk_core_lookup(core->name)) { in __clk_core_init()
2942 __func__, core->name); in __clk_core_init()
2948 if (core->ops->set_rate && in __clk_core_init()
2949 !((core->ops->round_rate || core->ops->determine_rate) && in __clk_core_init()
2950 core->ops->recalc_rate)) { in __clk_core_init()
2952 __func__, core->name); in __clk_core_init()
2957 if (core->ops->set_parent && !core->ops->get_parent) { in __clk_core_init()
2959 __func__, core->name); in __clk_core_init()
2964 if (core->num_parents > 1 && !core->ops->get_parent) { in __clk_core_init()
2966 __func__, core->name); in __clk_core_init()
2971 if (core->ops->set_rate_and_parent && in __clk_core_init()
2972 !(core->ops->set_parent && core->ops->set_rate)) { in __clk_core_init()
2974 __func__, core->name); in __clk_core_init()
2980 for (i = 0; i < core->num_parents; i++) in __clk_core_init()
2981 WARN(!core->parent_names[i], in __clk_core_init()
2983 __func__, core->name); in __clk_core_init()
2985 core->parent = __clk_init_parent(core); in __clk_core_init()
2988 * Populate core->parent if parent has already been clk_core_init'd. If in __clk_core_init()
2997 if (core->parent) { in __clk_core_init()
2998 hlist_add_head(&core->child_node, in __clk_core_init()
2999 &core->parent->children); in __clk_core_init()
3000 core->orphan = core->parent->orphan; in __clk_core_init()
3001 } else if (!core->num_parents) { in __clk_core_init()
3002 hlist_add_head(&core->child_node, &clk_root_list); in __clk_core_init()
3003 core->orphan = false; in __clk_core_init()
3005 hlist_add_head(&core->child_node, &clk_orphan_list); in __clk_core_init()
3006 core->orphan = true; in __clk_core_init()
3017 if (core->ops->init) in __clk_core_init()
3018 core->ops->init(core->hw); in __clk_core_init()
3027 if (core->ops->recalc_accuracy) in __clk_core_init()
3028 core->accuracy = core->ops->recalc_accuracy(core->hw, in __clk_core_init()
3029 __clk_get_accuracy(core->parent)); in __clk_core_init()
3030 else if (core->parent) in __clk_core_init()
3031 core->accuracy = core->parent->accuracy; in __clk_core_init()
3033 core->accuracy = 0; in __clk_core_init()
3040 if (core->ops->get_phase) in __clk_core_init()
3041 core->phase = core->ops->get_phase(core->hw); in __clk_core_init()
3043 core->phase = 0; in __clk_core_init()
3048 clk_core_update_duty_cycle_nolock(core); in __clk_core_init()
3056 if (core->ops->recalc_rate) in __clk_core_init()
3057 rate = core->ops->recalc_rate(core->hw, in __clk_core_init()
3058 clk_core_get_rate_nolock(core->parent)); in __clk_core_init()
3059 else if (core->parent) in __clk_core_init()
3060 rate = core->parent->rate; in __clk_core_init()
3063 core->rate = core->req_rate = rate; in __clk_core_init()
3070 if (core->flags & CLK_IS_CRITICAL) { in __clk_core_init()
3073 ret = clk_core_prepare(core); in __clk_core_init()
3078 ret = clk_core_enable(core); in __clk_core_init()
3081 clk_core_unprepare(core); in __clk_core_init()
3108 kref_init(&core->ref); in __clk_core_init()
3110 clk_pm_runtime_put(core); in __clk_core_init()
3113 hlist_del_init(&core->child_node); in __clk_core_init()
3118 clk_debug_register(core); in __clk_core_init()
3136 clk->core = hw->core; in __clk_create_clk()
3142 hlist_add_head(&clk->clks_node, &hw->core->clks); in __clk_create_clk()
3173 struct clk_core *core; in clk_register() local
3175 core = kzalloc(sizeof(*core), GFP_KERNEL); in clk_register()
3176 if (!core) { in clk_register()
3181 core->name = kstrdup_const(hw->init->name, GFP_KERNEL); in clk_register()
3182 if (!core->name) { in clk_register()
3191 core->ops = hw->init->ops; in clk_register()
3194 core->dev = dev; in clk_register()
3196 core->owner = dev->driver->owner; in clk_register()
3197 core->hw = hw; in clk_register()
3198 core->flags = hw->init->flags; in clk_register()
3199 core->num_parents = hw->init->num_parents; in clk_register()
3200 core->min_rate = 0; in clk_register()
3201 core->max_rate = ULONG_MAX; in clk_register()
3202 hw->core = core; in clk_register()
3205 core->parent_names = kcalloc(core->num_parents, sizeof(char *), in clk_register()
3208 if (!core->parent_names) { in clk_register()
3215 for (i = 0; i < core->num_parents; i++) { in clk_register()
3216 core->parent_names[i] = kstrdup_const(hw->init->parent_names[i], in clk_register()
3218 if (!core->parent_names[i]) { in clk_register()
3225 core->parents = kcalloc(core->num_parents, sizeof(*core->parents), in clk_register()
3227 if (!core->parents) { in clk_register()
3232 INIT_HLIST_HEAD(&core->clks); in clk_register()
3240 ret = __clk_core_init(core); in clk_register()
3248 kfree(core->parents); in clk_register()
3251 kfree_const(core->parent_names[i]); in clk_register()
3252 kfree(core->parent_names); in clk_register()
3255 kfree_const(core->name); in clk_register()
3257 kfree(core); in clk_register()
3282 struct clk_core *core = container_of(ref, struct clk_core, ref); in __clk_release() local
3283 int i = core->num_parents; in __clk_release()
3287 kfree(core->parents); in __clk_release()
3289 kfree_const(core->parent_names[i]); in __clk_release()
3291 kfree(core->parent_names); in __clk_release()
3292 kfree_const(core->name); in __clk_release()
3293 kfree(core); in __clk_release()
3346 static void clk_core_evict_parent_cache(struct clk_core *core) in clk_core_evict_parent_cache() argument
3355 clk_core_evict_parent_cache_subtree(root, core); in clk_core_evict_parent_cache()
3370 clk_debug_unregister(clk->core); in clk_unregister()
3374 if (clk->core->ops == &clk_nodrv_ops) { in clk_unregister()
3376 clk->core->name); in clk_unregister()
3384 clk->core->ops = &clk_nodrv_ops; in clk_unregister()
3387 if (!hlist_empty(&clk->core->children)) { in clk_unregister()
3392 hlist_for_each_entry_safe(child, t, &clk->core->children, in clk_unregister()
3397 clk_core_evict_parent_cache(clk->core); in clk_unregister()
3399 hlist_del_init(&clk->core->child_node); in clk_unregister()
3401 if (clk->core->prepare_count) in clk_unregister()
3403 __func__, clk->core->name); in clk_unregister()
3405 if (clk->core->protect_count) in clk_unregister()
3407 __func__, clk->core->name); in clk_unregister()
3409 kref_put(&clk->core->ref, __clk_release); in clk_unregister()
3547 struct clk_core *core = !clk ? NULL : clk->core; in __clk_get() local
3549 if (core) { in __clk_get()
3550 if (!try_module_get(core->owner)) in __clk_get()
3553 kref_get(&core->ref); in __clk_get()
3575 clk->core->protect_count -= (clk->exclusive_count - 1); in __clk_put()
3576 clk_core_rate_unprotect(clk->core); in __clk_put()
3581 if (clk->min_rate > clk->core->req_rate || in __clk_put()
3582 clk->max_rate < clk->core->req_rate) in __clk_put()
3583 clk_core_set_rate_nolock(clk->core, clk->core->req_rate); in __clk_put()
3585 owner = clk->core->owner; in __clk_put()
3586 kref_put(&clk->core->ref, __clk_release); in __clk_put()
3647 clk->core->notifier_count++; in clk_notifier_register()
3684 clk->core->notifier_count--; in clk_notifier_unregister()