Lines Matching refs:core

50 	struct clk_core		*core;  member
98 struct clk_core *core; member
109 static int clk_pm_runtime_get(struct clk_core *core) in clk_pm_runtime_get() argument
113 if (!core->rpm_enabled) in clk_pm_runtime_get()
116 ret = pm_runtime_get_sync(core->dev); in clk_pm_runtime_get()
118 pm_runtime_put_noidle(core->dev); in clk_pm_runtime_get()
124 static void clk_pm_runtime_put(struct clk_core *core) in clk_pm_runtime_put() argument
126 if (!core->rpm_enabled) in clk_pm_runtime_put()
129 pm_runtime_put_sync(core->dev); in clk_pm_runtime_put()
201 static bool clk_core_rate_is_protected(struct clk_core *core) in clk_core_rate_is_protected() argument
203 return core->protect_count; in clk_core_rate_is_protected()
206 static bool clk_core_is_prepared(struct clk_core *core) in clk_core_is_prepared() argument
214 if (!core->ops->is_prepared) in clk_core_is_prepared()
215 return core->prepare_count; in clk_core_is_prepared()
217 if (!clk_pm_runtime_get(core)) { in clk_core_is_prepared()
218 ret = core->ops->is_prepared(core->hw); in clk_core_is_prepared()
219 clk_pm_runtime_put(core); in clk_core_is_prepared()
225 static bool clk_core_is_enabled(struct clk_core *core) in clk_core_is_enabled() argument
233 if (!core->ops->is_enabled) in clk_core_is_enabled()
234 return core->enable_count; in clk_core_is_enabled()
246 if (core->rpm_enabled) { in clk_core_is_enabled()
247 pm_runtime_get_noresume(core->dev); in clk_core_is_enabled()
248 if (!pm_runtime_active(core->dev)) { in clk_core_is_enabled()
254 ret = core->ops->is_enabled(core->hw); in clk_core_is_enabled()
256 if (core->rpm_enabled) in clk_core_is_enabled()
257 pm_runtime_put(core->dev); in clk_core_is_enabled()
266 return !clk ? NULL : clk->core->name; in __clk_get_name()
272 return hw->core->name; in clk_hw_get_name()
278 return !clk ? NULL : clk->core->hw; in __clk_get_hw()
284 return hw->core->num_parents; in clk_hw_get_num_parents()
290 return hw->core->parent ? hw->core->parent->hw : NULL; in clk_hw_get_parent()
295 struct clk_core *core) in __clk_lookup_subtree() argument
300 if (!strcmp(core->name, name)) in __clk_lookup_subtree()
301 return core; in __clk_lookup_subtree()
303 hlist_for_each_entry(child, &core->children, child_node) { in __clk_lookup_subtree()
392 static struct clk_core *clk_core_get(struct clk_core *core, u8 p_index) in clk_core_get() argument
394 const char *name = core->parents[p_index].fw_name; in clk_core_get()
395 int index = core->parents[p_index].index; in clk_core_get()
397 struct device *dev = core->dev; in clk_core_get()
399 struct device_node *np = core->of_node; in clk_core_get()
417 return hw->core; in clk_core_get()
420 static void clk_core_fill_parent_index(struct clk_core *core, u8 index) in clk_core_fill_parent_index() argument
422 struct clk_parent_map *entry = &core->parents[index]; in clk_core_fill_parent_index()
426 parent = entry->hw->core; in clk_core_fill_parent_index()
435 parent = clk_core_get(core, index); in clk_core_fill_parent_index()
442 entry->core = parent; in clk_core_fill_parent_index()
445 static struct clk_core *clk_core_get_parent_by_index(struct clk_core *core, in clk_core_get_parent_by_index() argument
448 if (!core || index >= core->num_parents || !core->parents) in clk_core_get_parent_by_index()
451 if (!core->parents[index].core) in clk_core_get_parent_by_index()
452 clk_core_fill_parent_index(core, index); in clk_core_get_parent_by_index()
454 return core->parents[index].core; in clk_core_get_parent_by_index()
462 parent = clk_core_get_parent_by_index(hw->core, index); in clk_hw_get_parent_by_index()
470 return !clk ? 0 : clk->core->enable_count; in __clk_get_enable_count()
473 static unsigned long clk_core_get_rate_nolock(struct clk_core *core) in clk_core_get_rate_nolock() argument
475 if (!core) in clk_core_get_rate_nolock()
478 if (!core->num_parents || core->parent) in clk_core_get_rate_nolock()
479 return core->rate; in clk_core_get_rate_nolock()
491 return clk_core_get_rate_nolock(hw->core); in clk_hw_get_rate()
495 static unsigned long clk_core_get_accuracy_no_lock(struct clk_core *core) in clk_core_get_accuracy_no_lock() argument
497 if (!core) in clk_core_get_accuracy_no_lock()
500 return core->accuracy; in clk_core_get_accuracy_no_lock()
505 return hw->core->flags; in clk_hw_get_flags()
511 return clk_core_is_prepared(hw->core); in clk_hw_is_prepared()
517 return clk_core_rate_is_protected(hw->core); in clk_hw_rate_is_protected()
523 return clk_core_is_enabled(hw->core); in clk_hw_is_enabled()
532 return clk_core_is_enabled(clk->core); in __clk_is_enabled()
549 struct clk_core *core = hw->core, *parent, *best_parent = NULL; in clk_mux_determine_rate_flags() local
555 if (core->flags & CLK_SET_RATE_NO_REPARENT) { in clk_mux_determine_rate_flags()
556 parent = core->parent; in clk_mux_determine_rate_flags()
557 if (core->flags & CLK_SET_RATE_PARENT) { in clk_mux_determine_rate_flags()
567 best = clk_core_get_rate_nolock(core); in clk_mux_determine_rate_flags()
574 num_parents = core->num_parents; in clk_mux_determine_rate_flags()
576 parent = clk_core_get_parent_by_index(core, i); in clk_mux_determine_rate_flags()
580 if (core->flags & CLK_SET_RATE_PARENT) { in clk_mux_determine_rate_flags()
611 struct clk_core *core = clk_core_lookup(name); in __clk_lookup() local
613 return !core ? NULL : core->hw->clk; in __clk_lookup()
616 static void clk_core_get_boundaries(struct clk_core *core, in clk_core_get_boundaries() argument
624 *min_rate = core->min_rate; in clk_core_get_boundaries()
625 *max_rate = core->max_rate; in clk_core_get_boundaries()
627 hlist_for_each_entry(clk_user, &core->clks, clks_node) in clk_core_get_boundaries()
630 hlist_for_each_entry(clk_user, &core->clks, clks_node) in clk_core_get_boundaries()
637 hw->core->min_rate = min_rate; in clk_hw_set_rate_range()
638 hw->core->max_rate = max_rate; in clk_hw_set_rate_range()
669 static void clk_core_rate_unprotect(struct clk_core *core) in clk_core_rate_unprotect() argument
673 if (!core) in clk_core_rate_unprotect()
676 if (WARN(core->protect_count == 0, in clk_core_rate_unprotect()
677 "%s already unprotected\n", core->name)) in clk_core_rate_unprotect()
680 if (--core->protect_count > 0) in clk_core_rate_unprotect()
683 clk_core_rate_unprotect(core->parent); in clk_core_rate_unprotect()
686 static int clk_core_rate_nuke_protect(struct clk_core *core) in clk_core_rate_nuke_protect() argument
692 if (!core) in clk_core_rate_nuke_protect()
695 if (core->protect_count == 0) in clk_core_rate_nuke_protect()
698 ret = core->protect_count; in clk_core_rate_nuke_protect()
699 core->protect_count = 1; in clk_core_rate_nuke_protect()
700 clk_core_rate_unprotect(core); in clk_core_rate_nuke_protect()
737 clk_core_rate_unprotect(clk->core); in clk_rate_exclusive_put()
744 static void clk_core_rate_protect(struct clk_core *core) in clk_core_rate_protect() argument
748 if (!core) in clk_core_rate_protect()
751 if (core->protect_count == 0) in clk_core_rate_protect()
752 clk_core_rate_protect(core->parent); in clk_core_rate_protect()
754 core->protect_count++; in clk_core_rate_protect()
757 static void clk_core_rate_restore_protect(struct clk_core *core, int count) in clk_core_rate_restore_protect() argument
761 if (!core) in clk_core_rate_restore_protect()
767 clk_core_rate_protect(core); in clk_core_rate_restore_protect()
768 core->protect_count = count; in clk_core_rate_restore_protect()
795 clk_core_rate_protect(clk->core); in clk_rate_exclusive_get()
803 static void clk_core_unprepare(struct clk_core *core) in clk_core_unprepare() argument
807 if (!core) in clk_core_unprepare()
810 if (WARN(core->prepare_count == 0, in clk_core_unprepare()
811 "%s already unprepared\n", core->name)) in clk_core_unprepare()
814 if (WARN(core->prepare_count == 1 && core->flags & CLK_IS_CRITICAL, in clk_core_unprepare()
815 "Unpreparing critical %s\n", core->name)) in clk_core_unprepare()
818 if (core->flags & CLK_SET_RATE_GATE) in clk_core_unprepare()
819 clk_core_rate_unprotect(core); in clk_core_unprepare()
821 if (--core->prepare_count > 0) in clk_core_unprepare()
824 WARN(core->enable_count > 0, "Unpreparing enabled %s\n", core->name); in clk_core_unprepare()
826 trace_clk_unprepare(core); in clk_core_unprepare()
828 if (core->ops->unprepare) in clk_core_unprepare()
829 core->ops->unprepare(core->hw); in clk_core_unprepare()
831 clk_pm_runtime_put(core); in clk_core_unprepare()
833 trace_clk_unprepare_complete(core); in clk_core_unprepare()
834 clk_core_unprepare(core->parent); in clk_core_unprepare()
837 static void clk_core_unprepare_lock(struct clk_core *core) in clk_core_unprepare_lock() argument
840 clk_core_unprepare(core); in clk_core_unprepare_lock()
860 clk_core_unprepare_lock(clk->core); in clk_unprepare()
864 static int clk_core_prepare(struct clk_core *core) in clk_core_prepare() argument
870 if (!core) in clk_core_prepare()
873 if (core->prepare_count == 0) { in clk_core_prepare()
874 ret = clk_pm_runtime_get(core); in clk_core_prepare()
878 ret = clk_core_prepare(core->parent); in clk_core_prepare()
882 trace_clk_prepare(core); in clk_core_prepare()
884 if (core->ops->prepare) in clk_core_prepare()
885 ret = core->ops->prepare(core->hw); in clk_core_prepare()
887 trace_clk_prepare_complete(core); in clk_core_prepare()
893 core->prepare_count++; in clk_core_prepare()
902 if (core->flags & CLK_SET_RATE_GATE) in clk_core_prepare()
903 clk_core_rate_protect(core); in clk_core_prepare()
907 clk_core_unprepare(core->parent); in clk_core_prepare()
909 clk_pm_runtime_put(core); in clk_core_prepare()
913 static int clk_core_prepare_lock(struct clk_core *core) in clk_core_prepare_lock() argument
918 ret = clk_core_prepare(core); in clk_core_prepare_lock()
941 return clk_core_prepare_lock(clk->core); in clk_prepare()
945 static void clk_core_disable(struct clk_core *core) in clk_core_disable() argument
949 if (!core) in clk_core_disable()
952 if (WARN(core->enable_count == 0, "%s already disabled\n", core->name)) in clk_core_disable()
955 if (WARN(core->enable_count == 1 && core->flags & CLK_IS_CRITICAL, in clk_core_disable()
956 "Disabling critical %s\n", core->name)) in clk_core_disable()
959 if (--core->enable_count > 0) in clk_core_disable()
962 trace_clk_disable_rcuidle(core); in clk_core_disable()
964 if (core->ops->disable) in clk_core_disable()
965 core->ops->disable(core->hw); in clk_core_disable()
967 trace_clk_disable_complete_rcuidle(core); in clk_core_disable()
969 clk_core_disable(core->parent); in clk_core_disable()
972 static void clk_core_disable_lock(struct clk_core *core) in clk_core_disable_lock() argument
977 clk_core_disable(core); in clk_core_disable_lock()
998 clk_core_disable_lock(clk->core); in clk_disable()
1002 static int clk_core_enable(struct clk_core *core) in clk_core_enable() argument
1008 if (!core) in clk_core_enable()
1011 if (WARN(core->prepare_count == 0, in clk_core_enable()
1012 "Enabling unprepared %s\n", core->name)) in clk_core_enable()
1015 if (core->enable_count == 0) { in clk_core_enable()
1016 ret = clk_core_enable(core->parent); in clk_core_enable()
1021 trace_clk_enable_rcuidle(core); in clk_core_enable()
1023 if (core->ops->enable) in clk_core_enable()
1024 ret = core->ops->enable(core->hw); in clk_core_enable()
1026 trace_clk_enable_complete_rcuidle(core); in clk_core_enable()
1029 clk_core_disable(core->parent); in clk_core_enable()
1034 core->enable_count++; in clk_core_enable()
1038 static int clk_core_enable_lock(struct clk_core *core) in clk_core_enable_lock() argument
1044 ret = clk_core_enable(core); in clk_core_enable_lock()
1062 struct clk_core *core = hw->core; in clk_gate_restore_context() local
1064 if (core->enable_count) in clk_gate_restore_context()
1065 core->ops->enable(hw); in clk_gate_restore_context()
1067 core->ops->disable(hw); in clk_gate_restore_context()
1071 static int clk_core_save_context(struct clk_core *core) in clk_core_save_context() argument
1076 hlist_for_each_entry(child, &core->children, child_node) { in clk_core_save_context()
1082 if (core->ops && core->ops->save_context) in clk_core_save_context()
1083 ret = core->ops->save_context(core->hw); in clk_core_save_context()
1088 static void clk_core_restore_context(struct clk_core *core) in clk_core_restore_context() argument
1092 if (core->ops && core->ops->restore_context) in clk_core_restore_context()
1093 core->ops->restore_context(core->hw); in clk_core_restore_context()
1095 hlist_for_each_entry(child, &core->children, child_node) in clk_core_restore_context()
1135 struct clk_core *core; in clk_restore_context() local
1137 hlist_for_each_entry(core, &clk_root_list, child_node) in clk_restore_context()
1138 clk_core_restore_context(core); in clk_restore_context()
1140 hlist_for_each_entry(core, &clk_orphan_list, child_node) in clk_restore_context()
1141 clk_core_restore_context(core); in clk_restore_context()
1163 return clk_core_enable_lock(clk->core); in clk_enable()
1184 return clk && !(clk->core->ops->enable && clk->core->ops->disable); in clk_is_enabled_when_prepared()
1188 static int clk_core_prepare_enable(struct clk_core *core) in clk_core_prepare_enable() argument
1192 ret = clk_core_prepare_lock(core); in clk_core_prepare_enable()
1196 ret = clk_core_enable_lock(core); in clk_core_prepare_enable()
1198 clk_core_unprepare_lock(core); in clk_core_prepare_enable()
1203 static void clk_core_disable_unprepare(struct clk_core *core) in clk_core_disable_unprepare() argument
1205 clk_core_disable_lock(core); in clk_core_disable_unprepare()
1206 clk_core_unprepare_lock(core); in clk_core_disable_unprepare()
1209 static void __init clk_unprepare_unused_subtree(struct clk_core *core) in clk_unprepare_unused_subtree() argument
1215 hlist_for_each_entry(child, &core->children, child_node) in clk_unprepare_unused_subtree()
1218 if (core->prepare_count) in clk_unprepare_unused_subtree()
1221 if (core->flags & CLK_IGNORE_UNUSED) in clk_unprepare_unused_subtree()
1224 if (clk_pm_runtime_get(core)) in clk_unprepare_unused_subtree()
1227 if (clk_core_is_prepared(core)) { in clk_unprepare_unused_subtree()
1228 trace_clk_unprepare(core); in clk_unprepare_unused_subtree()
1229 if (core->ops->unprepare_unused) in clk_unprepare_unused_subtree()
1230 core->ops->unprepare_unused(core->hw); in clk_unprepare_unused_subtree()
1231 else if (core->ops->unprepare) in clk_unprepare_unused_subtree()
1232 core->ops->unprepare(core->hw); in clk_unprepare_unused_subtree()
1233 trace_clk_unprepare_complete(core); in clk_unprepare_unused_subtree()
1236 clk_pm_runtime_put(core); in clk_unprepare_unused_subtree()
1239 static void __init clk_disable_unused_subtree(struct clk_core *core) in clk_disable_unused_subtree() argument
1246 hlist_for_each_entry(child, &core->children, child_node) in clk_disable_unused_subtree()
1249 if (core->flags & CLK_OPS_PARENT_ENABLE) in clk_disable_unused_subtree()
1250 clk_core_prepare_enable(core->parent); in clk_disable_unused_subtree()
1252 if (clk_pm_runtime_get(core)) in clk_disable_unused_subtree()
1257 if (core->enable_count) in clk_disable_unused_subtree()
1260 if (core->flags & CLK_IGNORE_UNUSED) in clk_disable_unused_subtree()
1268 if (clk_core_is_enabled(core)) { in clk_disable_unused_subtree()
1269 trace_clk_disable(core); in clk_disable_unused_subtree()
1270 if (core->ops->disable_unused) in clk_disable_unused_subtree()
1271 core->ops->disable_unused(core->hw); in clk_disable_unused_subtree()
1272 else if (core->ops->disable) in clk_disable_unused_subtree()
1273 core->ops->disable(core->hw); in clk_disable_unused_subtree()
1274 trace_clk_disable_complete(core); in clk_disable_unused_subtree()
1279 clk_pm_runtime_put(core); in clk_disable_unused_subtree()
1281 if (core->flags & CLK_OPS_PARENT_ENABLE) in clk_disable_unused_subtree()
1282 clk_core_disable_unprepare(core->parent); in clk_disable_unused_subtree()
1295 struct clk_core *core; in clk_disable_unused() local
1304 hlist_for_each_entry(core, &clk_root_list, child_node) in clk_disable_unused()
1305 clk_disable_unused_subtree(core); in clk_disable_unused()
1307 hlist_for_each_entry(core, &clk_orphan_list, child_node) in clk_disable_unused()
1308 clk_disable_unused_subtree(core); in clk_disable_unused()
1310 hlist_for_each_entry(core, &clk_root_list, child_node) in clk_disable_unused()
1311 clk_unprepare_unused_subtree(core); in clk_disable_unused()
1313 hlist_for_each_entry(core, &clk_orphan_list, child_node) in clk_disable_unused()
1314 clk_unprepare_unused_subtree(core); in clk_disable_unused()
1322 static int clk_core_determine_round_nolock(struct clk_core *core, in clk_core_determine_round_nolock() argument
1329 if (!core) in clk_core_determine_round_nolock()
1338 if (clk_core_rate_is_protected(core)) { in clk_core_determine_round_nolock()
1339 req->rate = core->rate; in clk_core_determine_round_nolock()
1340 } else if (core->ops->determine_rate) { in clk_core_determine_round_nolock()
1341 return core->ops->determine_rate(core->hw, req); in clk_core_determine_round_nolock()
1342 } else if (core->ops->round_rate) { in clk_core_determine_round_nolock()
1343 rate = core->ops->round_rate(core->hw, req->rate, in clk_core_determine_round_nolock()
1356 static void clk_core_init_rate_req(struct clk_core * const core, in clk_core_init_rate_req() argument
1361 if (WARN_ON(!core || !req)) in clk_core_init_rate_req()
1364 parent = core->parent; in clk_core_init_rate_req()
1374 static bool clk_core_can_round(struct clk_core * const core) in clk_core_can_round() argument
1376 return core->ops->determine_rate || core->ops->round_rate; in clk_core_can_round()
1379 static int clk_core_round_rate_nolock(struct clk_core *core, in clk_core_round_rate_nolock() argument
1384 if (!core) { in clk_core_round_rate_nolock()
1389 clk_core_init_rate_req(core, req); in clk_core_round_rate_nolock()
1391 if (clk_core_can_round(core)) in clk_core_round_rate_nolock()
1392 return clk_core_determine_round_nolock(core, req); in clk_core_round_rate_nolock()
1393 else if (core->flags & CLK_SET_RATE_PARENT) in clk_core_round_rate_nolock()
1394 return clk_core_round_rate_nolock(core->parent, req); in clk_core_round_rate_nolock()
1396 req->rate = core->rate; in clk_core_round_rate_nolock()
1414 return clk_core_round_rate_nolock(hw->core, req); in __clk_determine_rate()
1438 clk_core_get_boundaries(hw->core, &req.min_rate, &req.max_rate); in clk_hw_round_rate()
1441 ret = clk_core_round_rate_nolock(hw->core, &req); in clk_hw_round_rate()
1469 clk_core_rate_unprotect(clk->core); in clk_round_rate()
1471 clk_core_get_boundaries(clk->core, &req.min_rate, &req.max_rate); in clk_round_rate()
1474 ret = clk_core_round_rate_nolock(clk->core, &req); in clk_round_rate()
1477 clk_core_rate_protect(clk->core); in clk_round_rate()
1502 static int __clk_notify(struct clk_core *core, unsigned long msg, in __clk_notify() argument
1513 if (cn->clk->core == core) { in __clk_notify()
1534 static void __clk_recalc_accuracies(struct clk_core *core) in __clk_recalc_accuracies() argument
1541 if (core->parent) in __clk_recalc_accuracies()
1542 parent_accuracy = core->parent->accuracy; in __clk_recalc_accuracies()
1544 if (core->ops->recalc_accuracy) in __clk_recalc_accuracies()
1545 core->accuracy = core->ops->recalc_accuracy(core->hw, in __clk_recalc_accuracies()
1548 core->accuracy = parent_accuracy; in __clk_recalc_accuracies()
1550 hlist_for_each_entry(child, &core->children, child_node) in __clk_recalc_accuracies()
1554 static long clk_core_get_accuracy_recalc(struct clk_core *core) in clk_core_get_accuracy_recalc() argument
1556 if (core && (core->flags & CLK_GET_ACCURACY_NOCACHE)) in clk_core_get_accuracy_recalc()
1557 __clk_recalc_accuracies(core); in clk_core_get_accuracy_recalc()
1559 return clk_core_get_accuracy_no_lock(core); in clk_core_get_accuracy_recalc()
1579 accuracy = clk_core_get_accuracy_recalc(clk->core); in clk_get_accuracy()
1586 static unsigned long clk_recalc(struct clk_core *core, in clk_recalc() argument
1591 if (core->ops->recalc_rate && !clk_pm_runtime_get(core)) { in clk_recalc()
1592 rate = core->ops->recalc_rate(core->hw, parent_rate); in clk_recalc()
1593 clk_pm_runtime_put(core); in clk_recalc()
1610 static void __clk_recalc_rates(struct clk_core *core, unsigned long msg) in __clk_recalc_rates() argument
1618 old_rate = core->rate; in __clk_recalc_rates()
1620 if (core->parent) in __clk_recalc_rates()
1621 parent_rate = core->parent->rate; in __clk_recalc_rates()
1623 core->rate = clk_recalc(core, parent_rate); in __clk_recalc_rates()
1629 if (core->notifier_count && msg) in __clk_recalc_rates()
1630 __clk_notify(core, msg, old_rate, core->rate); in __clk_recalc_rates()
1632 hlist_for_each_entry(child, &core->children, child_node) in __clk_recalc_rates()
1636 static unsigned long clk_core_get_rate_recalc(struct clk_core *core) in clk_core_get_rate_recalc() argument
1638 if (core && (core->flags & CLK_GET_RATE_NOCACHE)) in clk_core_get_rate_recalc()
1639 __clk_recalc_rates(core, 0); in clk_core_get_rate_recalc()
1641 return clk_core_get_rate_nolock(core); in clk_core_get_rate_recalc()
1660 rate = clk_core_get_rate_recalc(clk->core); in clk_get_rate()
1667 static int clk_fetch_parent_index(struct clk_core *core, in clk_fetch_parent_index() argument
1675 for (i = 0; i < core->num_parents; i++) { in clk_fetch_parent_index()
1677 if (core->parents[i].core == parent) in clk_fetch_parent_index()
1681 if (core->parents[i].core) in clk_fetch_parent_index()
1685 if (core->parents[i].hw) { in clk_fetch_parent_index()
1686 if (core->parents[i].hw == parent->hw) in clk_fetch_parent_index()
1694 if (parent == clk_core_get(core, i)) in clk_fetch_parent_index()
1698 if (core->parents[i].name && in clk_fetch_parent_index()
1699 !strcmp(parent->name, core->parents[i].name)) in clk_fetch_parent_index()
1703 if (i == core->num_parents) in clk_fetch_parent_index()
1706 core->parents[i].core = parent; in clk_fetch_parent_index()
1724 return clk_fetch_parent_index(hw->core, parent->core); in clk_hw_get_parent_index()
1731 static void clk_core_update_orphan_status(struct clk_core *core, bool is_orphan) in clk_core_update_orphan_status() argument
1735 core->orphan = is_orphan; in clk_core_update_orphan_status()
1737 hlist_for_each_entry(child, &core->children, child_node) in clk_core_update_orphan_status()
1741 static void clk_reparent(struct clk_core *core, struct clk_core *new_parent) in clk_reparent() argument
1743 bool was_orphan = core->orphan; in clk_reparent()
1745 hlist_del(&core->child_node); in clk_reparent()
1751 if (new_parent->new_child == core) in clk_reparent()
1754 hlist_add_head(&core->child_node, &new_parent->children); in clk_reparent()
1757 clk_core_update_orphan_status(core, becomes_orphan); in clk_reparent()
1759 hlist_add_head(&core->child_node, &clk_orphan_list); in clk_reparent()
1761 clk_core_update_orphan_status(core, true); in clk_reparent()
1764 core->parent = new_parent; in clk_reparent()
1767 static struct clk_core *__clk_set_parent_before(struct clk_core *core, in __clk_set_parent_before() argument
1771 struct clk_core *old_parent = core->parent; in __clk_set_parent_before()
1794 if (core->flags & CLK_OPS_PARENT_ENABLE) { in __clk_set_parent_before()
1800 if (core->prepare_count) { in __clk_set_parent_before()
1802 clk_core_enable_lock(core); in __clk_set_parent_before()
1807 clk_reparent(core, parent); in __clk_set_parent_before()
1813 static void __clk_set_parent_after(struct clk_core *core, in __clk_set_parent_after() argument
1821 if (core->prepare_count) { in __clk_set_parent_after()
1822 clk_core_disable_lock(core); in __clk_set_parent_after()
1827 if (core->flags & CLK_OPS_PARENT_ENABLE) { in __clk_set_parent_after()
1833 static int __clk_set_parent(struct clk_core *core, struct clk_core *parent, in __clk_set_parent() argument
1840 old_parent = __clk_set_parent_before(core, parent); in __clk_set_parent()
1842 trace_clk_set_parent(core, parent); in __clk_set_parent()
1845 if (parent && core->ops->set_parent) in __clk_set_parent()
1846 ret = core->ops->set_parent(core->hw, p_index); in __clk_set_parent()
1848 trace_clk_set_parent_complete(core, parent); in __clk_set_parent()
1852 clk_reparent(core, old_parent); in __clk_set_parent()
1854 __clk_set_parent_after(core, old_parent, parent); in __clk_set_parent()
1859 __clk_set_parent_after(core, parent, old_parent); in __clk_set_parent()
1878 static int __clk_speculate_rates(struct clk_core *core, in __clk_speculate_rates() argument
1887 new_rate = clk_recalc(core, parent_rate); in __clk_speculate_rates()
1890 if (core->notifier_count) in __clk_speculate_rates()
1891 ret = __clk_notify(core, PRE_RATE_CHANGE, core->rate, new_rate); in __clk_speculate_rates()
1895 __func__, core->name, ret); in __clk_speculate_rates()
1899 hlist_for_each_entry(child, &core->children, child_node) { in __clk_speculate_rates()
1909 static void clk_calc_subtree(struct clk_core *core, unsigned long new_rate, in clk_calc_subtree() argument
1914 core->new_rate = new_rate; in clk_calc_subtree()
1915 core->new_parent = new_parent; in clk_calc_subtree()
1916 core->new_parent_index = p_index; in clk_calc_subtree()
1918 core->new_child = NULL; in clk_calc_subtree()
1919 if (new_parent && new_parent != core->parent) in clk_calc_subtree()
1920 new_parent->new_child = core; in clk_calc_subtree()
1922 hlist_for_each_entry(child, &core->children, child_node) { in clk_calc_subtree()
1932 static struct clk_core *clk_calc_new_rates(struct clk_core *core, in clk_calc_new_rates() argument
1935 struct clk_core *top = core; in clk_calc_new_rates()
1945 if (IS_ERR_OR_NULL(core)) in clk_calc_new_rates()
1949 parent = old_parent = core->parent; in clk_calc_new_rates()
1953 clk_core_get_boundaries(core, &min_rate, &max_rate); in clk_calc_new_rates()
1956 if (clk_core_can_round(core)) { in clk_calc_new_rates()
1963 clk_core_init_rate_req(core, &req); in clk_calc_new_rates()
1965 ret = clk_core_determine_round_nolock(core, &req); in clk_calc_new_rates()
1971 parent = req.best_parent_hw ? req.best_parent_hw->core : NULL; in clk_calc_new_rates()
1975 } else if (!parent || !(core->flags & CLK_SET_RATE_PARENT)) { in clk_calc_new_rates()
1977 core->new_rate = core->rate; in clk_calc_new_rates()
1988 (core->flags & CLK_SET_PARENT_GATE) && core->prepare_count) { in clk_calc_new_rates()
1990 __func__, core->name); in clk_calc_new_rates()
1995 if (parent && core->num_parents > 1) { in clk_calc_new_rates()
1996 p_index = clk_fetch_parent_index(core, parent); in clk_calc_new_rates()
1999 __func__, parent->name, core->name); in clk_calc_new_rates()
2004 if ((core->flags & CLK_SET_RATE_PARENT) && parent && in clk_calc_new_rates()
2009 clk_calc_subtree(core, new_rate, parent, p_index); in clk_calc_new_rates()
2019 static struct clk_core *clk_propagate_rate_change(struct clk_core *core, in clk_propagate_rate_change() argument
2025 if (core->rate == core->new_rate) in clk_propagate_rate_change()
2028 if (core->notifier_count) { in clk_propagate_rate_change()
2029 ret = __clk_notify(core, event, core->rate, core->new_rate); in clk_propagate_rate_change()
2031 fail_clk = core; in clk_propagate_rate_change()
2034 hlist_for_each_entry(child, &core->children, child_node) { in clk_propagate_rate_change()
2036 if (child->new_parent && child->new_parent != core) in clk_propagate_rate_change()
2044 if (core->new_child) { in clk_propagate_rate_change()
2045 tmp_clk = clk_propagate_rate_change(core->new_child, event); in clk_propagate_rate_change()
2057 static void clk_change_rate(struct clk_core *core) in clk_change_rate() argument
2067 old_rate = core->rate; in clk_change_rate()
2069 if (core->new_parent) { in clk_change_rate()
2070 parent = core->new_parent; in clk_change_rate()
2071 best_parent_rate = core->new_parent->rate; in clk_change_rate()
2072 } else if (core->parent) { in clk_change_rate()
2073 parent = core->parent; in clk_change_rate()
2074 best_parent_rate = core->parent->rate; in clk_change_rate()
2077 if (clk_pm_runtime_get(core)) in clk_change_rate()
2080 if (core->flags & CLK_SET_RATE_UNGATE) { in clk_change_rate()
2081 clk_core_prepare(core); in clk_change_rate()
2082 clk_core_enable_lock(core); in clk_change_rate()
2085 if (core->new_parent && core->new_parent != core->parent) { in clk_change_rate()
2086 old_parent = __clk_set_parent_before(core, core->new_parent); in clk_change_rate()
2087 trace_clk_set_parent(core, core->new_parent); in clk_change_rate()
2089 if (core->ops->set_rate_and_parent) { in clk_change_rate()
2091 core->ops->set_rate_and_parent(core->hw, core->new_rate, in clk_change_rate()
2093 core->new_parent_index); in clk_change_rate()
2094 } else if (core->ops->set_parent) { in clk_change_rate()
2095 core->ops->set_parent(core->hw, core->new_parent_index); in clk_change_rate()
2098 trace_clk_set_parent_complete(core, core->new_parent); in clk_change_rate()
2099 __clk_set_parent_after(core, core->new_parent, old_parent); in clk_change_rate()
2102 if (core->flags & CLK_OPS_PARENT_ENABLE) in clk_change_rate()
2105 trace_clk_set_rate(core, core->new_rate); in clk_change_rate()
2107 if (!skip_set_rate && core->ops->set_rate) in clk_change_rate()
2108 core->ops->set_rate(core->hw, core->new_rate, best_parent_rate); in clk_change_rate()
2110 trace_clk_set_rate_complete(core, core->new_rate); in clk_change_rate()
2112 core->rate = clk_recalc(core, best_parent_rate); in clk_change_rate()
2114 if (core->flags & CLK_SET_RATE_UNGATE) { in clk_change_rate()
2115 clk_core_disable_lock(core); in clk_change_rate()
2116 clk_core_unprepare(core); in clk_change_rate()
2119 if (core->flags & CLK_OPS_PARENT_ENABLE) in clk_change_rate()
2122 if (core->notifier_count && old_rate != core->rate) in clk_change_rate()
2123 __clk_notify(core, POST_RATE_CHANGE, old_rate, core->rate); in clk_change_rate()
2125 if (core->flags & CLK_RECALC_NEW_RATES) in clk_change_rate()
2126 (void)clk_calc_new_rates(core, core->new_rate); in clk_change_rate()
2132 hlist_for_each_entry_safe(child, tmp, &core->children, child_node) { in clk_change_rate()
2134 if (child->new_parent && child->new_parent != core) in clk_change_rate()
2140 if (core->new_child) in clk_change_rate()
2141 clk_change_rate(core->new_child); in clk_change_rate()
2143 clk_pm_runtime_put(core); in clk_change_rate()
2146 static unsigned long clk_core_req_round_rate_nolock(struct clk_core *core, in clk_core_req_round_rate_nolock() argument
2154 if (!core) in clk_core_req_round_rate_nolock()
2158 cnt = clk_core_rate_nuke_protect(core); in clk_core_req_round_rate_nolock()
2162 clk_core_get_boundaries(core, &req.min_rate, &req.max_rate); in clk_core_req_round_rate_nolock()
2165 ret = clk_core_round_rate_nolock(core, &req); in clk_core_req_round_rate_nolock()
2168 clk_core_rate_restore_protect(core, cnt); in clk_core_req_round_rate_nolock()
2173 static int clk_core_set_rate_nolock(struct clk_core *core, in clk_core_set_rate_nolock() argument
2180 if (!core) in clk_core_set_rate_nolock()
2183 rate = clk_core_req_round_rate_nolock(core, req_rate); in clk_core_set_rate_nolock()
2186 if (rate == clk_core_get_rate_nolock(core)) in clk_core_set_rate_nolock()
2190 if (clk_core_rate_is_protected(core)) in clk_core_set_rate_nolock()
2194 top = clk_calc_new_rates(core, req_rate); in clk_core_set_rate_nolock()
2198 ret = clk_pm_runtime_get(core); in clk_core_set_rate_nolock()
2215 core->req_rate = req_rate; in clk_core_set_rate_nolock()
2217 clk_pm_runtime_put(core); in clk_core_set_rate_nolock()
2254 clk_core_rate_unprotect(clk->core); in clk_set_rate()
2256 ret = clk_core_set_rate_nolock(clk->core, rate); in clk_set_rate()
2259 clk_core_rate_protect(clk->core); in clk_set_rate()
2302 ret = clk_core_set_rate_nolock(clk->core, rate); in clk_set_rate_exclusive()
2304 clk_core_rate_protect(clk->core); in clk_set_rate_exclusive()
2330 trace_clk_set_rate_range(clk->core, min, max); in clk_set_rate_range()
2334 __func__, clk->core->name, clk->dev_id, clk->con_id, in clk_set_rate_range()
2342 clk_core_rate_unprotect(clk->core); in clk_set_rate_range()
2350 rate = clk_core_get_rate_nolock(clk->core); in clk_set_rate_range()
2370 ret = clk_core_set_rate_nolock(clk->core, rate); in clk_set_rate_range()
2379 clk_core_rate_protect(clk->core); in clk_set_rate_range()
2399 trace_clk_set_min_rate(clk->core, rate); in clk_set_min_rate()
2417 trace_clk_set_max_rate(clk->core, rate); in clk_set_max_rate()
2438 parent = !clk->core->parent ? NULL : clk->core->parent->hw->clk; in clk_get_parent()
2445 static struct clk_core *__clk_init_parent(struct clk_core *core) in __clk_init_parent() argument
2449 if (core->num_parents > 1 && core->ops->get_parent) in __clk_init_parent()
2450 index = core->ops->get_parent(core->hw); in __clk_init_parent()
2452 return clk_core_get_parent_by_index(core, index); in __clk_init_parent()
2455 static void clk_core_reparent(struct clk_core *core, in clk_core_reparent() argument
2458 clk_reparent(core, new_parent); in clk_core_reparent()
2459 __clk_recalc_accuracies(core); in clk_core_reparent()
2460 __clk_recalc_rates(core, POST_RATE_CHANGE); in clk_core_reparent()
2468 clk_core_reparent(hw->core, !new_parent ? NULL : new_parent->core); in clk_hw_reparent()
2483 struct clk_core *core, *parent_core; in clk_has_parent() local
2490 core = clk->core; in clk_has_parent()
2491 parent_core = parent->core; in clk_has_parent()
2494 if (core->parent == parent_core) in clk_has_parent()
2497 for (i = 0; i < core->num_parents; i++) in clk_has_parent()
2498 if (!strcmp(core->parents[i].name, parent_core->name)) in clk_has_parent()
2505 static int clk_core_set_parent_nolock(struct clk_core *core, in clk_core_set_parent_nolock() argument
2514 if (!core) in clk_core_set_parent_nolock()
2517 if (core->parent == parent) in clk_core_set_parent_nolock()
2521 if (core->num_parents > 1 && !core->ops->set_parent) in clk_core_set_parent_nolock()
2525 if ((core->flags & CLK_SET_PARENT_GATE) && core->prepare_count) in clk_core_set_parent_nolock()
2528 if (clk_core_rate_is_protected(core)) in clk_core_set_parent_nolock()
2533 p_index = clk_fetch_parent_index(core, parent); in clk_core_set_parent_nolock()
2536 __func__, parent->name, core->name); in clk_core_set_parent_nolock()
2542 ret = clk_pm_runtime_get(core); in clk_core_set_parent_nolock()
2547 ret = __clk_speculate_rates(core, p_rate); in clk_core_set_parent_nolock()
2554 ret = __clk_set_parent(core, parent, p_index); in clk_core_set_parent_nolock()
2558 __clk_recalc_rates(core, ABORT_RATE_CHANGE); in clk_core_set_parent_nolock()
2560 __clk_recalc_rates(core, POST_RATE_CHANGE); in clk_core_set_parent_nolock()
2561 __clk_recalc_accuracies(core); in clk_core_set_parent_nolock()
2565 clk_pm_runtime_put(core); in clk_core_set_parent_nolock()
2572 return clk_core_set_parent_nolock(hw->core, parent->core); in clk_hw_set_parent()
2603 clk_core_rate_unprotect(clk->core); in clk_set_parent()
2605 ret = clk_core_set_parent_nolock(clk->core, in clk_set_parent()
2606 parent ? parent->core : NULL); in clk_set_parent()
2609 clk_core_rate_protect(clk->core); in clk_set_parent()
2617 static int clk_core_set_phase_nolock(struct clk_core *core, int degrees) in clk_core_set_phase_nolock() argument
2623 if (!core) in clk_core_set_phase_nolock()
2626 if (clk_core_rate_is_protected(core)) in clk_core_set_phase_nolock()
2629 trace_clk_set_phase(core, degrees); in clk_core_set_phase_nolock()
2631 if (core->ops->set_phase) { in clk_core_set_phase_nolock()
2632 ret = core->ops->set_phase(core->hw, degrees); in clk_core_set_phase_nolock()
2634 core->phase = degrees; in clk_core_set_phase_nolock()
2637 trace_clk_set_phase_complete(core, degrees); in clk_core_set_phase_nolock()
2677 clk_core_rate_unprotect(clk->core); in clk_set_phase()
2679 ret = clk_core_set_phase_nolock(clk->core, degrees); in clk_set_phase()
2682 clk_core_rate_protect(clk->core); in clk_set_phase()
2690 static int clk_core_get_phase(struct clk_core *core) in clk_core_get_phase() argument
2695 if (!core->ops->get_phase) in clk_core_get_phase()
2699 ret = core->ops->get_phase(core->hw); in clk_core_get_phase()
2701 core->phase = ret; in clk_core_get_phase()
2721 ret = clk_core_get_phase(clk->core); in clk_get_phase()
2728 static void clk_core_reset_duty_cycle_nolock(struct clk_core *core) in clk_core_reset_duty_cycle_nolock() argument
2731 core->duty.num = 1; in clk_core_reset_duty_cycle_nolock()
2732 core->duty.den = 2; in clk_core_reset_duty_cycle_nolock()
2735 static int clk_core_update_duty_cycle_parent_nolock(struct clk_core *core);
2737 static int clk_core_update_duty_cycle_nolock(struct clk_core *core) in clk_core_update_duty_cycle_nolock() argument
2739 struct clk_duty *duty = &core->duty; in clk_core_update_duty_cycle_nolock()
2742 if (!core->ops->get_duty_cycle) in clk_core_update_duty_cycle_nolock()
2743 return clk_core_update_duty_cycle_parent_nolock(core); in clk_core_update_duty_cycle_nolock()
2745 ret = core->ops->get_duty_cycle(core->hw, duty); in clk_core_update_duty_cycle_nolock()
2758 clk_core_reset_duty_cycle_nolock(core); in clk_core_update_duty_cycle_nolock()
2762 static int clk_core_update_duty_cycle_parent_nolock(struct clk_core *core) in clk_core_update_duty_cycle_parent_nolock() argument
2766 if (core->parent && in clk_core_update_duty_cycle_parent_nolock()
2767 core->flags & CLK_DUTY_CYCLE_PARENT) { in clk_core_update_duty_cycle_parent_nolock()
2768 ret = clk_core_update_duty_cycle_nolock(core->parent); in clk_core_update_duty_cycle_parent_nolock()
2769 memcpy(&core->duty, &core->parent->duty, sizeof(core->duty)); in clk_core_update_duty_cycle_parent_nolock()
2771 clk_core_reset_duty_cycle_nolock(core); in clk_core_update_duty_cycle_parent_nolock()
2777 static int clk_core_set_duty_cycle_parent_nolock(struct clk_core *core,
2780 static int clk_core_set_duty_cycle_nolock(struct clk_core *core, in clk_core_set_duty_cycle_nolock() argument
2787 if (clk_core_rate_is_protected(core)) in clk_core_set_duty_cycle_nolock()
2790 trace_clk_set_duty_cycle(core, duty); in clk_core_set_duty_cycle_nolock()
2792 if (!core->ops->set_duty_cycle) in clk_core_set_duty_cycle_nolock()
2793 return clk_core_set_duty_cycle_parent_nolock(core, duty); in clk_core_set_duty_cycle_nolock()
2795 ret = core->ops->set_duty_cycle(core->hw, duty); in clk_core_set_duty_cycle_nolock()
2797 memcpy(&core->duty, duty, sizeof(*duty)); in clk_core_set_duty_cycle_nolock()
2799 trace_clk_set_duty_cycle_complete(core, duty); in clk_core_set_duty_cycle_nolock()
2804 static int clk_core_set_duty_cycle_parent_nolock(struct clk_core *core, in clk_core_set_duty_cycle_parent_nolock() argument
2809 if (core->parent && in clk_core_set_duty_cycle_parent_nolock()
2810 core->flags & (CLK_DUTY_CYCLE_PARENT | CLK_SET_RATE_PARENT)) { in clk_core_set_duty_cycle_parent_nolock()
2811 ret = clk_core_set_duty_cycle_nolock(core->parent, duty); in clk_core_set_duty_cycle_parent_nolock()
2812 memcpy(&core->duty, &core->parent->duty, sizeof(core->duty)); in clk_core_set_duty_cycle_parent_nolock()
2847 clk_core_rate_unprotect(clk->core); in clk_set_duty_cycle()
2849 ret = clk_core_set_duty_cycle_nolock(clk->core, &duty); in clk_set_duty_cycle()
2852 clk_core_rate_protect(clk->core); in clk_set_duty_cycle()
2860 static int clk_core_get_scaled_duty_cycle(struct clk_core *core, in clk_core_get_scaled_duty_cycle() argument
2863 struct clk_duty *duty = &core->duty; in clk_core_get_scaled_duty_cycle()
2868 ret = clk_core_update_duty_cycle_nolock(core); in clk_core_get_scaled_duty_cycle()
2890 return clk_core_get_scaled_duty_cycle(clk->core, scale); in clk_get_scaled_duty_cycle()
2913 if (p->core == q->core) in clk_is_match()
3066 struct clk_core *core = data; in clk_rate_set() local
3070 ret = clk_core_set_rate_nolock(core, val); in clk_rate_set()
3080 struct clk_core *core = data; in clk_prepare_enable_set() local
3084 ret = clk_prepare_enable(core->hw->clk); in clk_prepare_enable_set()
3086 clk_disable_unprepare(core->hw->clk); in clk_prepare_enable_set()
3093 struct clk_core *core = data; in clk_prepare_enable_get() local
3095 *val = core->enable_count && core->prepare_count; in clk_prepare_enable_get()
3109 struct clk_core *core = data; in clk_rate_get() local
3112 *val = clk_core_get_rate_recalc(core); in clk_rate_get()
3142 struct clk_core *core = s->private; in clk_flags_show() local
3143 unsigned long flags = core->flags; in clk_flags_show()
3161 static void possible_parent_show(struct seq_file *s, struct clk_core *core, in possible_parent_show() argument
3178 parent = clk_core_get_parent_by_index(core, i); in possible_parent_show()
3181 else if (core->parents[i].name) in possible_parent_show()
3182 seq_puts(s, core->parents[i].name); in possible_parent_show()
3183 else if (core->parents[i].fw_name) in possible_parent_show()
3184 seq_printf(s, "<%s>(fw)", core->parents[i].fw_name); in possible_parent_show()
3185 else if (core->parents[i].index >= 0) in possible_parent_show()
3187 of_clk_get_parent_name(core->of_node, in possible_parent_show()
3188 core->parents[i].index)); in possible_parent_show()
3197 struct clk_core *core = s->private; in possible_parents_show() local
3200 for (i = 0; i < core->num_parents - 1; i++) in possible_parents_show()
3201 possible_parent_show(s, core, i, ' '); in possible_parents_show()
3203 possible_parent_show(s, core, i, '\n'); in possible_parents_show()
3211 struct clk_core *core = s->private; in current_parent_show() local
3213 if (core->parent) in current_parent_show()
3214 seq_printf(s, "%s\n", core->parent->name); in current_parent_show()
3222 struct clk_core *core = s->private; in clk_duty_cycle_show() local
3223 struct clk_duty *duty = &core->duty; in clk_duty_cycle_show()
3233 struct clk_core *core = s->private; in clk_min_rate_show() local
3237 clk_core_get_boundaries(core, &min_rate, &max_rate); in clk_min_rate_show()
3247 struct clk_core *core = s->private; in clk_max_rate_show() local
3251 clk_core_get_boundaries(core, &min_rate, &max_rate); in clk_max_rate_show()
3259 static void clk_debug_create_one(struct clk_core *core, struct dentry *pdentry) in clk_debug_create_one() argument
3263 if (!core || !pdentry) in clk_debug_create_one()
3266 root = debugfs_create_dir(core->name, pdentry); in clk_debug_create_one()
3267 core->dentry = root; in clk_debug_create_one()
3269 debugfs_create_file("clk_rate", clk_rate_mode, root, core, in clk_debug_create_one()
3271 debugfs_create_file("clk_min_rate", 0444, root, core, &clk_min_rate_fops); in clk_debug_create_one()
3272 debugfs_create_file("clk_max_rate", 0444, root, core, &clk_max_rate_fops); in clk_debug_create_one()
3273 debugfs_create_ulong("clk_accuracy", 0444, root, &core->accuracy); in clk_debug_create_one()
3274 debugfs_create_u32("clk_phase", 0444, root, &core->phase); in clk_debug_create_one()
3275 debugfs_create_file("clk_flags", 0444, root, core, &clk_flags_fops); in clk_debug_create_one()
3276 debugfs_create_u32("clk_prepare_count", 0444, root, &core->prepare_count); in clk_debug_create_one()
3277 debugfs_create_u32("clk_enable_count", 0444, root, &core->enable_count); in clk_debug_create_one()
3278 debugfs_create_u32("clk_protect_count", 0444, root, &core->protect_count); in clk_debug_create_one()
3279 debugfs_create_u32("clk_notifier_count", 0444, root, &core->notifier_count); in clk_debug_create_one()
3280 debugfs_create_file("clk_duty_cycle", 0444, root, core, in clk_debug_create_one()
3283 debugfs_create_file("clk_prepare_enable", 0644, root, core, in clk_debug_create_one()
3287 if (core->num_parents > 0) in clk_debug_create_one()
3288 debugfs_create_file("clk_parent", 0444, root, core, in clk_debug_create_one()
3291 if (core->num_parents > 1) in clk_debug_create_one()
3292 debugfs_create_file("clk_possible_parents", 0444, root, core, in clk_debug_create_one()
3295 if (core->ops->debug_init) in clk_debug_create_one()
3296 core->ops->debug_init(core->hw, core->dentry); in clk_debug_create_one()
3307 static void clk_debug_register(struct clk_core *core) in clk_debug_register() argument
3310 hlist_add_head(&core->debug_node, &clk_debug_list); in clk_debug_register()
3312 clk_debug_create_one(core, rootdir); in clk_debug_register()
3324 static void clk_debug_unregister(struct clk_core *core) in clk_debug_unregister() argument
3327 hlist_del_init(&core->debug_node); in clk_debug_unregister()
3328 debugfs_remove_recursive(core->dentry); in clk_debug_unregister()
3329 core->dentry = NULL; in clk_debug_unregister()
3344 struct clk_core *core; in clk_debug_init() local
3358 hlist_for_each_entry(core, &clk_debug_list, debug_node) in clk_debug_init()
3359 clk_debug_create_one(core, rootdir); in clk_debug_init()
3368 static inline void clk_debug_register(struct clk_core *core) { } in clk_debug_register() argument
3369 static inline void clk_debug_unregister(struct clk_core *core) in clk_debug_unregister() argument
3409 static int __clk_core_init(struct clk_core *core) in __clk_core_init() argument
3416 if (!core) in __clk_core_init()
3427 core->hw->core = core; in __clk_core_init()
3429 ret = clk_pm_runtime_get(core); in __clk_core_init()
3434 if (clk_core_lookup(core->name)) { in __clk_core_init()
3436 __func__, core->name); in __clk_core_init()
3442 if (core->ops->set_rate && in __clk_core_init()
3443 !((core->ops->round_rate || core->ops->determine_rate) && in __clk_core_init()
3444 core->ops->recalc_rate)) { in __clk_core_init()
3446 __func__, core->name); in __clk_core_init()
3451 if (core->ops->set_parent && !core->ops->get_parent) { in __clk_core_init()
3453 __func__, core->name); in __clk_core_init()
3458 if (core->num_parents > 1 && !core->ops->get_parent) { in __clk_core_init()
3460 __func__, core->name); in __clk_core_init()
3465 if (core->ops->set_rate_and_parent && in __clk_core_init()
3466 !(core->ops->set_parent && core->ops->set_rate)) { in __clk_core_init()
3468 __func__, core->name); in __clk_core_init()
3487 if (core->ops->init) { in __clk_core_init()
3488 ret = core->ops->init(core->hw); in __clk_core_init()
3493 parent = core->parent = __clk_init_parent(core); in __clk_core_init()
3506 hlist_add_head(&core->child_node, &parent->children); in __clk_core_init()
3507 core->orphan = parent->orphan; in __clk_core_init()
3508 } else if (!core->num_parents) { in __clk_core_init()
3509 hlist_add_head(&core->child_node, &clk_root_list); in __clk_core_init()
3510 core->orphan = false; in __clk_core_init()
3512 hlist_add_head(&core->child_node, &clk_orphan_list); in __clk_core_init()
3513 core->orphan = true; in __clk_core_init()
3523 if (core->ops->recalc_accuracy) in __clk_core_init()
3524 core->accuracy = core->ops->recalc_accuracy(core->hw, in __clk_core_init()
3527 core->accuracy = parent->accuracy; in __clk_core_init()
3529 core->accuracy = 0; in __clk_core_init()
3536 phase = clk_core_get_phase(core); in __clk_core_init()
3540 core->name); in __clk_core_init()
3547 clk_core_update_duty_cycle_nolock(core); in __clk_core_init()
3555 if (core->ops->recalc_rate) in __clk_core_init()
3556 rate = core->ops->recalc_rate(core->hw, in __clk_core_init()
3562 core->rate = core->req_rate = rate; in __clk_core_init()
3569 if (core->flags & CLK_IS_CRITICAL) { in __clk_core_init()
3570 ret = clk_core_prepare(core); in __clk_core_init()
3573 __func__, core->name); in __clk_core_init()
3577 ret = clk_core_enable_lock(core); in __clk_core_init()
3580 __func__, core->name); in __clk_core_init()
3581 clk_core_unprepare(core); in __clk_core_init()
3589 kref_init(&core->ref); in __clk_core_init()
3591 clk_pm_runtime_put(core); in __clk_core_init()
3594 hlist_del_init(&core->child_node); in __clk_core_init()
3595 core->hw->core = NULL; in __clk_core_init()
3601 clk_debug_register(core); in __clk_core_init()
3611 static void clk_core_link_consumer(struct clk_core *core, struct clk *clk) in clk_core_link_consumer() argument
3614 hlist_add_head(&clk->clks_node, &core->clks); in clk_core_link_consumer()
3636 static struct clk *alloc_clk(struct clk_core *core, const char *dev_id, in alloc_clk() argument
3645 clk->core = core; in alloc_clk()
3682 struct clk_core *core; in clk_hw_create_clk() local
3688 core = hw->core; in clk_hw_create_clk()
3689 clk = alloc_clk(core, dev_id, con_id); in clk_hw_create_clk()
3694 if (!try_module_get(core->owner)) { in clk_hw_create_clk()
3699 kref_get(&core->ref); in clk_hw_create_clk()
3700 clk_core_link_consumer(core, clk); in clk_hw_create_clk()
3717 struct device *dev = hw->core->dev; in clk_hw_get_clk()
3740 static int clk_core_populate_parent_map(struct clk_core *core, in clk_core_populate_parent_map() argument
3758 core->parents = parents; in clk_core_populate_parent_map()
3769 __func__, core->name); in clk_core_populate_parent_map()
3802 static void clk_core_free_parent_map(struct clk_core *core) in clk_core_free_parent_map() argument
3804 int i = core->num_parents; in clk_core_free_parent_map()
3806 if (!core->num_parents) in clk_core_free_parent_map()
3810 kfree_const(core->parents[i].name); in clk_core_free_parent_map()
3811 kfree_const(core->parents[i].fw_name); in clk_core_free_parent_map()
3814 kfree(core->parents); in clk_core_free_parent_map()
3821 struct clk_core *core; in __clk_register() local
3831 core = kzalloc(sizeof(*core), GFP_KERNEL); in __clk_register()
3832 if (!core) { in __clk_register()
3837 core->name = kstrdup_const(init->name, GFP_KERNEL); in __clk_register()
3838 if (!core->name) { in __clk_register()
3847 core->ops = init->ops; in __clk_register()
3850 core->rpm_enabled = true; in __clk_register()
3851 core->dev = dev; in __clk_register()
3852 core->of_node = np; in __clk_register()
3854 core->owner = dev->driver->owner; in __clk_register()
3855 core->hw = hw; in __clk_register()
3856 core->flags = init->flags; in __clk_register()
3857 core->num_parents = init->num_parents; in __clk_register()
3858 core->min_rate = 0; in __clk_register()
3859 core->max_rate = ULONG_MAX; in __clk_register()
3861 ret = clk_core_populate_parent_map(core, init); in __clk_register()
3865 INIT_HLIST_HEAD(&core->clks); in __clk_register()
3871 hw->clk = alloc_clk(core, NULL, NULL); in __clk_register()
3877 clk_core_link_consumer(core, hw->clk); in __clk_register()
3879 ret = __clk_core_init(core); in __clk_register()
3891 clk_core_free_parent_map(core); in __clk_register()
3894 kfree_const(core->name); in __clk_register()
3896 kfree(core); in __clk_register()
3979 struct clk_core *core = container_of(ref, struct clk_core, ref); in __clk_release() local
3983 clk_core_free_parent_map(core); in __clk_release()
3984 kfree_const(core->name); in __clk_release()
3985 kfree(core); in __clk_release()
4030 if (root->parents[i].core == target) in clk_core_evict_parent_cache_subtree()
4031 root->parents[i].core = NULL; in clk_core_evict_parent_cache_subtree()
4038 static void clk_core_evict_parent_cache(struct clk_core *core) in clk_core_evict_parent_cache() argument
4047 clk_core_evict_parent_cache_subtree(root, core); in clk_core_evict_parent_cache()
4063 clk_debug_unregister(clk->core); in clk_unregister()
4067 ops = clk->core->ops; in clk_unregister()
4070 clk->core->name); in clk_unregister()
4078 clk->core->ops = &clk_nodrv_ops; in clk_unregister()
4082 ops->terminate(clk->core->hw); in clk_unregister()
4084 if (!hlist_empty(&clk->core->children)) { in clk_unregister()
4089 hlist_for_each_entry_safe(child, t, &clk->core->children, in clk_unregister()
4094 clk_core_evict_parent_cache(clk->core); in clk_unregister()
4096 hlist_del_init(&clk->core->child_node); in clk_unregister()
4098 if (clk->core->prepare_count) in clk_unregister()
4100 __func__, clk->core->name); in clk_unregister()
4102 if (clk->core->protect_count) in clk_unregister()
4104 __func__, clk->core->name); in clk_unregister()
4106 kref_put(&clk->core->ref, __clk_release); in clk_unregister()
4267 WARN_ON_ONCE(dev != hw->core->dev); in devm_clk_hw_get_clk()
4305 clk->core->protect_count -= (clk->exclusive_count - 1); in __clk_put()
4306 clk_core_rate_unprotect(clk->core); in __clk_put()
4311 if (clk->min_rate > clk->core->req_rate || in __clk_put()
4312 clk->max_rate < clk->core->req_rate) in __clk_put()
4313 clk_core_set_rate_nolock(clk->core, clk->core->req_rate); in __clk_put()
4315 owner = clk->core->owner; in __clk_put()
4316 kref_put(&clk->core->ref, __clk_release); in __clk_put()
4375 clk->core->notifier_count++; in clk_notifier_register()
4409 clk->core->notifier_count--; in clk_notifier_unregister()