Lines Matching +full:clock +full:- +full:accuracy

1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (C) 2010-2011 Canonical Ltd <jeremy.kerr@canonical.com>
4 * Copyright (C) 2011-2012 Linaro Ltd <mturquette@linaro.org>
6 * Standard functionality for the common clock API. See Documentation/driver-api/clk.rst
10 #include <linux/clk-provider.h>
11 #include <linux/clk/clk-conf.h>
80 unsigned long accuracy; member
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()
126 if (!core->rpm_enabled) in clk_pm_runtime_put()
129 pm_runtime_put_sync(core->dev); in clk_pm_runtime_put()
153 if (--prepare_refcnt) in clk_prepare_unlock()
193 if (--enable_refcnt) { in clk_enable_unlock()
203 return core->protect_count; in clk_core_rate_is_protected()
214 if (!core->ops->is_prepared) in clk_core_is_prepared()
215 return core->prepare_count; in clk_core_is_prepared()
218 ret = core->ops->is_prepared(core->hw); in clk_core_is_prepared()
233 if (!core->ops->is_enabled) in clk_core_is_enabled()
234 return core->enable_count; in clk_core_is_enabled()
237 * Check if clock controller's device is runtime active before in clk_core_is_enabled()
238 * calling .is_enabled callback. If not, assume that clock is 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()
300 if (!strcmp(core->name, name)) in __clk_lookup_subtree()
303 hlist_for_each_entry(child, &core->children, child_node) { in __clk_lookup_subtree()
347 return -ENOENT; in of_parse_clkspec()
352 return ERR_PTR(-ENOENT); in of_clk_get_hw_from_clkspec()
357 * clk_core_get - Find the clk_core parent of a clk
364 * node's 'clock-names' property or as the 'con_id' matching the device's
368 * For example the following DT snippet would allow a clock registered by the
369 * clock-controller@c001 that has a clk_init_data::parent_data array
370 * with 'xtal' in the 'name' member to find the clock provided by the
371 * clock-controller@f00abcd without needing to get the globally unique name of
374 * parent: clock-controller@f00abcd {
376 * #clock-cells = <0>;
379 * clock-controller@c001 {
382 * clock-names = "xtal";
383 * #clock-cells = <1>;
386 * Returns: -ENOENT when the provider can't be found or the clk doesn't
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()
396 struct clk_hw *hw = ERR_PTR(-ENOENT); 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()
422 struct clk_parent_map *entry = &core->parents[index]; in clk_core_fill_parent_index()
425 if (entry->hw) { in clk_core_fill_parent_index()
426 parent = entry->hw->core; in clk_core_fill_parent_index()
433 parent = ERR_PTR(-EPROBE_DEFER); in clk_core_fill_parent_index()
436 if (PTR_ERR(parent) == -ENOENT && entry->name) in clk_core_fill_parent_index()
437 parent = clk_core_lookup(entry->name); in clk_core_fill_parent_index()
442 entry->core = parent; in clk_core_fill_parent_index()
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()
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()
464 return !parent ? NULL : parent->hw; in clk_hw_get_parent_by_index()
470 return !clk ? 0 : clk->core->enable_count; in __clk_get_enable_count()
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()
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()
540 return abs(now - rate) < abs(best - rate); in mux_is_better_rate()
549 struct clk_core *core = hw->core, *parent, *best_parent = NULL; in clk_mux_determine_rate_flags()
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()
558 ret = __clk_determine_rate(parent ? parent->hw : NULL, in clk_mux_determine_rate_flags()
574 num_parents = core->num_parents; in clk_mux_determine_rate_flags()
580 if (core->flags & CLK_SET_RATE_PARENT) { in clk_mux_determine_rate_flags()
582 ret = __clk_determine_rate(parent->hw, &parent_req); in clk_mux_determine_rate_flags()
589 if (mux_is_better_rate(req->rate, parent_req.rate, in clk_mux_determine_rate_flags()
597 return -EINVAL; in clk_mux_determine_rate_flags()
601 req->best_parent_hw = best_parent->hw; in clk_mux_determine_rate_flags()
602 req->best_parent_rate = best; in clk_mux_determine_rate_flags()
603 req->rate = best; in clk_mux_determine_rate_flags()
613 return !core ? NULL : core->hw->clk; in __clk_lookup()
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()
628 *min_rate = max(*min_rate, clk_user->min_rate); in clk_core_get_boundaries()
630 hlist_for_each_entry(clk_user, &core->clks, clks_node) in clk_core_get_boundaries()
631 *max_rate = min(*max_rate, clk_user->max_rate); 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()
643 * __clk_mux_determine_rate - clk_ops::determine_rate implementation for a mux type clk
649 * complex clock that may combine a mux with other operations.
651 * Returns: 0 on success, -EERROR value on error
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()
693 return -EINVAL; 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()
706 * clk_rate_exclusive_put - release exclusivity over clock rate control
709 * clk_rate_exclusive_put() completes a critical section during which a clock
711 * clock which could result in a rate change or rate glitch. Exclusive clocks
716 * If exlusivity is claimed more than once on clock, even by the same consumer,
734 if (WARN_ON(clk->exclusive_count <= 0)) in clk_rate_exclusive_put()
737 clk_core_rate_unprotect(clk->core); in clk_rate_exclusive_put()
738 clk->exclusive_count--; in clk_rate_exclusive_put()
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()
768 core->protect_count = count; in clk_core_rate_restore_protect()
772 * clk_rate_exclusive_get - get exclusivity over the clk rate control
775 * clk_rate_exclusive_get() begins a critical section during which a clock
777 * clock which could result in a rate change or rate glitch. Exclusive clocks
782 * If exlusivity is claimed more than once on clock, even by the same consumer,
787 * Returns 0 on success, -EERROR otherwise
795 clk_core_rate_protect(clk->core); in clk_rate_exclusive_get()
796 clk->exclusive_count++; in clk_rate_exclusive_get()
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()
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()
828 if (core->ops->unprepare) in clk_core_unprepare()
829 core->ops->unprepare(core->hw); in clk_core_unprepare()
834 clk_core_unprepare(core->parent); in clk_core_unprepare()
845 * clk_unprepare - undo preparation of a clock source
860 clk_core_unprepare_lock(clk->core); in clk_unprepare()
873 if (core->prepare_count == 0) { in clk_core_prepare()
878 ret = clk_core_prepare(core->parent); in clk_core_prepare()
884 if (core->ops->prepare) in clk_core_prepare()
885 ret = core->ops->prepare(core->hw); in clk_core_prepare()
893 core->prepare_count++; in clk_core_prepare()
896 * CLK_SET_RATE_GATE is a special case of clock protection in clk_core_prepare()
900 * the clock is prepared. in clk_core_prepare()
902 if (core->flags & CLK_SET_RATE_GATE) in clk_core_prepare()
907 clk_core_unprepare(core->parent); in clk_core_prepare()
925 * clk_prepare - prepare a clock source
934 * Returns 0 on success, -EERROR otherwise.
941 return clk_core_prepare_lock(clk->core); in clk_prepare()
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()
964 if (core->ops->disable) in clk_core_disable()
965 core->ops->disable(core->hw); in clk_core_disable()
969 clk_core_disable(core->parent); in clk_core_disable()
982 * clk_disable - gate a clock
988 * SoC-internal clk which is controlled via simple register writes. In the
998 clk_core_disable_lock(clk->core); in clk_disable()
1011 if (WARN(core->prepare_count == 0, in clk_core_enable()
1012 "Enabling unprepared %s\n", core->name)) in clk_core_enable()
1013 return -ESHUTDOWN; 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()
1023 if (core->ops->enable) in clk_core_enable()
1024 ret = core->ops->enable(core->hw); in clk_core_enable()
1029 clk_core_disable(core->parent); in clk_core_enable()
1034 core->enable_count++; in clk_core_enable()
1051 * clk_gate_restore_context - restore context for poweroff
1052 * @hw: the clk_hw pointer of clock whose state is to be restored
1054 * The clock gate restore context function enables or disables
1056 * where the clock context is lost and based on the enable_count
1057 * the clock either needs to be enabled/disabled. This
1062 struct clk_core *core = hw->core; in clk_gate_restore_context()
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()
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()
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()
1100 * clk_save_context - save clock context for poweroff
1102 * Saves the context of the clock register for powerstates in which the
1128 * clk_restore_context - restore clock context after poweroff
1130 * Restore the saved clock context upon resume.
1146 * clk_enable - ungate a clock
1151 * if the operation will never sleep. One example is a SoC-internal clk which
1155 * must be called before clk_enable. Returns 0 on success, -EERROR
1163 return clk_core_enable_lock(clk->core); in clk_enable()
1168 * clk_is_enabled_when_prepared - indicate if preparing a clock also enables it.
1169 * @clk: clock source
1171 * Returns true if clk_prepare() implicitly enables the clock, effectively
1172 * making clk_enable()/clk_disable() no-ops, false otherwise.
1175 * disabling the clock also requires unpreparing it to have any material
1184 return clk && !(clk->core->ops->enable && clk->core->ops->disable); in clk_is_enabled_when_prepared()
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()
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()
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()
1257 if (core->enable_count) in clk_disable_unused_subtree()
1260 if (core->flags & CLK_IGNORE_UNUSED) in clk_disable_unused_subtree()
1264 * some gate clocks have special needs during the disable-unused 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()
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()
1334 * - if the provider is not protected at all in clk_core_determine_round_nolock()
1335 * - if the calling consumer is the only one which has exclusivity 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()
1344 &req->best_parent_rate); in clk_core_determine_round_nolock()
1348 req->rate = rate; in clk_core_determine_round_nolock()
1350 return -EINVAL; in clk_core_determine_round_nolock()
1364 parent = core->parent; in clk_core_init_rate_req()
1366 req->best_parent_hw = parent->hw; in clk_core_init_rate_req()
1367 req->best_parent_rate = parent->rate; in clk_core_init_rate_req()
1369 req->best_parent_hw = NULL; in clk_core_init_rate_req()
1370 req->best_parent_rate = 0; in clk_core_init_rate_req()
1376 return core->ops->determine_rate || core->ops->round_rate; in clk_core_can_round()
1385 req->rate = 0; 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()
1401 * __clk_determine_rate - get the closest rate actually supported by a clock
1402 * @hw: determine the rate of this clock
1410 req->rate = 0; in __clk_determine_rate()
1414 return clk_core_round_rate_nolock(hw->core, req); in __clk_determine_rate()
1419 * clk_hw_round_rate() - round the given rate for a hw clk
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()
1450 * clk_round_rate - round the given rate for a clk
1468 if (clk->exclusive_count) in clk_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()
1476 if (clk->exclusive_count) in clk_round_rate()
1477 clk_core_rate_protect(clk->core); in clk_round_rate()
1489 * __clk_notify - call clk notifier chain
1495 * Triggers a notifier call chain on the clk rate-change notification
1498 * internal clock code only. Returns NOTIFY_DONE from the last driver
1513 if (cn->clk->core == core) { in __clk_notify()
1514 cnd.clk = cn->clk; in __clk_notify()
1515 ret = srcu_notifier_call_chain(&cn->notifier_head, msg, in __clk_notify()
1531 * callback then it is assumed that the clock will take on the accuracy of its
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()
1556 if (core && (core->flags & CLK_GET_ACCURACY_NOCACHE)) in clk_core_get_accuracy_recalc()
1563 * clk_get_accuracy - return the accuracy of clk
1564 * @clk: the clk whose accuracy is being returned
1566 * Simply returns the cached accuracy of the clk, unless
1573 long accuracy; in clk_get_accuracy() local
1579 accuracy = clk_core_get_accuracy_recalc(clk->core); in clk_get_accuracy()
1582 return accuracy; in clk_get_accuracy()
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()
1605 * it is assumed that the clock will take on the rate of its parent.
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()
1638 if (core && (core->flags & CLK_GET_RATE_NOCACHE)) in clk_core_get_rate_recalc()
1645 * clk_get_rate - return the rate of clk
1660 rate = clk_core_get_rate_recalc(clk->core); in clk_get_rate()
1673 return -EINVAL; in clk_fetch_parent_index()
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()
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()
1704 return -EINVAL; in clk_fetch_parent_index()
1706 core->parents[i].core = parent; in clk_fetch_parent_index()
1711 * clk_hw_get_parent_index - return the index of the parent clock
1714 * Fetches and returns the index of parent clock. Returns -EINVAL if the given
1715 * clock does not have a current parent.
1722 return -EINVAL; in clk_hw_get_parent_index()
1724 return clk_fetch_parent_index(hw->core, parent->core); in clk_hw_get_parent_index()
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()
1743 bool was_orphan = core->orphan; in clk_reparent()
1745 hlist_del(&core->child_node); in clk_reparent()
1748 bool becomes_orphan = new_parent->orphan; in clk_reparent()
1751 if (new_parent->new_child == core) in clk_reparent()
1752 new_parent->new_child = NULL; in clk_reparent()
1754 hlist_add_head(&core->child_node, &new_parent->children); in clk_reparent()
1759 hlist_add_head(&core->child_node, &clk_orphan_list); in clk_reparent()
1764 core->parent = new_parent; in clk_reparent()
1771 struct clk_core *old_parent = core->parent; in __clk_set_parent_before()
1774 * 1. enable parents for CLK_OPS_PARENT_ENABLE clock in __clk_set_parent_before()
1779 * If the clock is not prepared, then a race with in __clk_set_parent_before()
1784 * If the clock is prepared, migrate the prepared state to the new in __clk_set_parent_before()
1786 * forcing the clock and the new parent on. This ensures that all 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()
1821 if (core->prepare_count) { in __clk_set_parent_after()
1826 /* re-balance ref counting if CLK_OPS_PARENT_ENABLE is set */ in __clk_set_parent_after()
1827 if (core->flags & CLK_OPS_PARENT_ENABLE) { in __clk_set_parent_after()
1844 /* change clock input source */ 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()
1873 * pre-rate change notifications and returns early if no clks in the
1875 * implement the .recalc_rate callback then it is assumed that the clock will
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()
1894 pr_debug("%s: clk notifier callback for clock %s aborted with error %d\n", 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()
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()
1923 child->new_rate = clk_recalc(child, new_rate); in clk_calc_subtree()
1924 clk_calc_subtree(child, child->new_rate, NULL, 0); in clk_calc_subtree()
1929 * calculate the new rates returning the topmost clock that has to be
1949 parent = old_parent = core->parent; in clk_calc_new_rates()
1951 best_parent_rate = parent->rate; 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()
1976 /* pass-through clock without adjustable parent */ in clk_calc_new_rates()
1977 core->new_rate = core->rate; in clk_calc_new_rates()
1980 /* pass-through clock with adjustable parent */ in clk_calc_new_rates()
1982 new_rate = parent->new_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()
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()
2005 best_parent_rate != parent->rate) in clk_calc_new_rates()
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()
2034 hlist_for_each_entry(child, &core->children, child_node) { in clk_propagate_rate_change()
2035 /* Skip children who will be reparented to another clock */ in clk_propagate_rate_change()
2036 if (child->new_parent && child->new_parent != core) in clk_propagate_rate_change()
2043 /* handle the new child who might not be in core->children yet */ 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()
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()
2080 if (core->flags & CLK_SET_RATE_UNGATE) { 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()
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()
2130 * for certain clock types. in clk_change_rate()
2132 hlist_for_each_entry_safe(child, tmp, &core->children, child_node) { in clk_change_rate()
2133 /* Skip children who will be reparented to another clock */ in clk_change_rate()
2134 if (child->new_parent && child->new_parent != core) in clk_change_rate()
2139 /* handle the new child who might not be in core->children yet */ in clk_change_rate()
2140 if (core->new_child) in clk_change_rate()
2141 clk_change_rate(core->new_child); in clk_change_rate()
2191 return -EBUSY; in clk_core_set_rate_nolock()
2193 /* calculate new rates and get the topmost changed clock */ in clk_core_set_rate_nolock()
2196 return -EINVAL; in clk_core_set_rate_nolock()
2206 fail_clk->name); in clk_core_set_rate_nolock()
2208 ret = -EBUSY; in clk_core_set_rate_nolock()
2215 core->req_rate = req_rate; in clk_core_set_rate_nolock()
2223 * clk_set_rate - specify a new rate for clk
2241 * Returns 0 on success, -EERROR otherwise.
2250 /* prevent racing with updates to the clock topology */ in clk_set_rate()
2253 if (clk->exclusive_count) in clk_set_rate()
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()
2258 if (clk->exclusive_count) in clk_set_rate()
2259 clk_core_rate_protect(clk->core); in clk_set_rate()
2268 * clk_set_rate_exclusive - specify a new rate and get exclusive control
2277 * same clock provider.
2284 * Returns 0 on success, -EERROR otherwise.
2293 /* prevent racing with updates to the clock topology */ in clk_set_rate_exclusive()
2299 * so before the consumer code path protect the clock provider in clk_set_rate_exclusive()
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()
2305 clk->exclusive_count++; in clk_set_rate_exclusive()
2315 * clk_set_rate_range - set a rate range for a clock source
2316 * @clk: clock source
2317 * @min: desired minimum clock rate in Hz, inclusive
2318 * @max: desired maximum clock rate in Hz, inclusive
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()
2336 return -EINVAL; in clk_set_rate_range()
2341 if (clk->exclusive_count) in clk_set_rate_range()
2342 clk_core_rate_unprotect(clk->core); in clk_set_rate_range()
2345 old_min = clk->min_rate; in clk_set_rate_range()
2346 old_max = clk->max_rate; in clk_set_rate_range()
2347 clk->min_rate = min; in clk_set_rate_range()
2348 clk->max_rate = max; in clk_set_rate_range()
2350 rate = clk_core_get_rate_nolock(clk->core); in clk_set_rate_range()
2357 * usual reason (clock broken, clock protected, etc) but also in clk_set_rate_range()
2359 * - round_rate() was not favorable and fell on the wrong in clk_set_rate_range()
2361 * - the determine_rate() callback does not really check for in clk_set_rate_range()
2370 ret = clk_core_set_rate_nolock(clk->core, rate); in clk_set_rate_range()
2373 clk->min_rate = old_min; in clk_set_rate_range()
2374 clk->max_rate = old_max; in clk_set_rate_range()
2378 if (clk->exclusive_count) in clk_set_rate_range()
2379 clk_core_rate_protect(clk->core); in clk_set_rate_range()
2388 * clk_set_min_rate - set a minimum clock rate for a clock source
2389 * @clk: clock source
2390 * @rate: desired minimum clock rate in Hz, inclusive
2399 trace_clk_set_min_rate(clk->core, rate); in clk_set_min_rate()
2401 return clk_set_rate_range(clk, rate, clk->max_rate); in clk_set_min_rate()
2406 * clk_set_max_rate - set a maximum clock rate for a clock source
2407 * @clk: clock source
2408 * @rate: desired maximum clock rate in Hz, inclusive
2417 trace_clk_set_max_rate(clk->core, rate); in clk_set_max_rate()
2419 return clk_set_rate_range(clk, clk->min_rate, rate); in clk_set_max_rate()
2424 * clk_get_parent - return the parent of a clk
2427 * Simply returns clk->parent. Returns NULL if clk is NULL.
2437 /* TODO: Create a per-user clk and change callers to call clk_put */ in clk_get_parent()
2438 parent = !clk->core->parent ? NULL : clk->core->parent->hw->clk; in clk_get_parent()
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()
2468 clk_core_reparent(hw->core, !new_parent ? NULL : new_parent->core); in clk_hw_reparent()
2472 * clk_has_parent - check if a clock is a possible parent for another
2473 * @clk: clock source
2474 * @parent: parent clock source
2476 * This function can be used in drivers that need to check that a clock can be
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()
2517 if (core->parent == parent) in clk_core_set_parent_nolock()
2520 /* verify ops for multi-parent clks */ in clk_core_set_parent_nolock()
2521 if (core->num_parents > 1 && !core->ops->set_parent) in clk_core_set_parent_nolock()
2522 return -EPERM; in clk_core_set_parent_nolock()
2524 /* check that we are allowed to re-parent if the clock is in use */ in clk_core_set_parent_nolock()
2525 if ((core->flags & CLK_SET_PARENT_GATE) && core->prepare_count) in clk_core_set_parent_nolock()
2526 return -EBUSY; in clk_core_set_parent_nolock()
2529 return -EBUSY; in clk_core_set_parent_nolock()
2536 __func__, parent->name, core->name); in clk_core_set_parent_nolock()
2539 p_rate = parent->rate; in clk_core_set_parent_nolock()
2553 /* do the re-parent */ in clk_core_set_parent_nolock()
2556 /* propagate rate an accuracy recalculation accordingly */ in clk_core_set_parent_nolock()
2572 return clk_core_set_parent_nolock(hw->core, parent->core); in clk_hw_set_parent()
2577 * clk_set_parent - switch the parent of a mux clk
2581 * Re-parent clk to use parent as its new input source. If clk is in
2591 * Returns 0 on success, -EERROR otherwise.
2602 if (clk->exclusive_count) in clk_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()
2608 if (clk->exclusive_count) in clk_set_parent()
2609 clk_core_rate_protect(clk->core); in clk_set_parent()
2619 int ret = -EINVAL; in clk_core_set_phase_nolock()
2627 return -EBUSY; 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()
2643 * clk_set_phase - adjust the phase shift of a clock signal
2644 * @clk: clock signal source
2647 * Shifts the phase of a clock signal by the specified
2648 * degrees. Returns 0 on success, -EERROR otherwise.
2651 * signal that we adjust the clock signal phase against. For example
2652 * phase locked-loop clock signal generators we may shift phase with
2653 * respect to feedback clock signal input, but for other cases the
2654 * clock phase may be shifted with respect to some other, unspecified
2658 * the clock tree hierarchy, which sets it apart from clock rates and
2659 * clock accuracy. A parent clock phase attribute does not have an
2660 * impact on the phase attribute of a child clock.
2676 if (clk->exclusive_count) in clk_set_phase()
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()
2681 if (clk->exclusive_count) in clk_set_phase()
2682 clk_core_rate_protect(clk->core); in clk_set_phase()
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()
2707 * clk_get_phase - return the phase shift of a clock signal
2708 * @clk: clock signal source
2710 * Returns the phase shift of a clock node in degrees, otherwise returns
2711 * -EERROR.
2721 ret = clk_core_get_phase(clk->core); in clk_get_phase()
2731 core->duty.num = 1; in clk_core_reset_duty_cycle_nolock()
2732 core->duty.den = 2; in clk_core_reset_duty_cycle_nolock()
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()
2745 ret = core->ops->get_duty_cycle(core->hw, duty); in clk_core_update_duty_cycle_nolock()
2749 /* Don't trust the clock provider too much */ in clk_core_update_duty_cycle_nolock()
2750 if (duty->den == 0 || duty->num > duty->den) { in clk_core_update_duty_cycle_nolock()
2751 ret = -EINVAL; in clk_core_update_duty_cycle_nolock()
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()
2788 return -EBUSY; in clk_core_set_duty_cycle_nolock()
2792 if (!core->ops->set_duty_cycle) 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()
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()
2819 * clk_set_duty_cycle - adjust the duty cycle ratio of a clock signal
2820 * @clk: clock signal source
2824 * Apply the duty cycle ratio if the ratio is valid and the clock can
2839 return -EINVAL; in clk_set_duty_cycle()
2846 if (clk->exclusive_count) in clk_set_duty_cycle()
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()
2851 if (clk->exclusive_count) in clk_set_duty_cycle()
2852 clk_core_rate_protect(clk->core); in clk_set_duty_cycle()
2863 struct clk_duty *duty = &core->duty; in clk_core_get_scaled_duty_cycle()
2870 ret = mult_frac(scale, duty->num, duty->den); in clk_core_get_scaled_duty_cycle()
2878 * clk_get_scaled_duty_cycle - return the duty cycle ratio of a clock signal
2879 * @clk: clock signal source
2882 * Returns the duty cycle ratio of a clock node multiplied by the provided
2890 return clk_core_get_scaled_duty_cycle(clk->core, scale); in clk_get_scaled_duty_cycle()
2895 * clk_is_match - check if two clk's point to the same hardware clock
2900 * clock node. Put differently, returns true if struct clk *p and struct clk *q
2911 /* true if clk->core pointers match. Avoid dereferencing garbage */ in clk_is_match()
2913 if (p->core == q->core) in clk_is_match()
2940 seq_printf(s, "%*s%-*s %7d %8d %8d %11lu %10lu ", in clk_summary_show_one()
2942 30 - level * 3, c->name, in clk_summary_show_one()
2943 c->enable_count, c->prepare_count, c->protect_count, in clk_summary_show_one()
2951 seq_puts(s, "-----"); in clk_summary_show_one()
2955 if (c->ops->is_enabled) in clk_summary_show_one()
2957 else if (!c->ops->enable) in clk_summary_show_one()
2970 hlist_for_each_entry(child, &c->children, child_node) in clk_summary_show_subtree()
2977 struct hlist_head **lists = (struct hlist_head **)s->private; in clk_summary_show()
2980 …seq_puts(s, " clock count count count rate accuracy phas… in clk_summary_show()
2981 …seq_puts(s, "-------------------------------------------------------------------------------------… in clk_summary_show()
3003 seq_printf(s, "\"%s\": { ", c->name); in clk_dump_one()
3004 seq_printf(s, "\"enable_count\": %d,", c->enable_count); in clk_dump_one()
3005 seq_printf(s, "\"prepare_count\": %d,", c->prepare_count); in clk_dump_one()
3006 seq_printf(s, "\"protect_count\": %d,", c->protect_count); in clk_dump_one()
3010 seq_printf(s, "\"accuracy\": %lu,", clk_core_get_accuracy_recalc(c)); in clk_dump_one()
3024 hlist_for_each_entry(child, &c->children, child_node) { in clk_dump_subtree()
3036 struct hlist_head **lists = (struct hlist_head **)s->private; in clk_dump_show()
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()
3095 *val = core->enable_count && core->prepare_count; in clk_prepare_enable_get()
3111 *val = core->rate; in clk_rate_get()
3139 struct clk_core *core = s->private; in clk_flags_show()
3140 unsigned long flags = core->flags; in clk_flags_show()
3166 * 1. Fetch the registered parent clock and use its name in possible_parent_show()
3169 * 4. Fetch parent clock's clock-output-name if DT index was set in possible_parent_show()
3177 seq_puts(s, parent->name); in possible_parent_show()
3178 else if (core->parents[i].name) in possible_parent_show()
3179 seq_puts(s, core->parents[i].name); in possible_parent_show()
3180 else if (core->parents[i].fw_name) in possible_parent_show()
3181 seq_printf(s, "<%s>(fw)", core->parents[i].fw_name); in possible_parent_show()
3182 else if (core->parents[i].index >= 0) in possible_parent_show()
3184 of_clk_get_parent_name(core->of_node, in possible_parent_show()
3185 core->parents[i].index)); in possible_parent_show()
3194 struct clk_core *core = s->private; in possible_parents_show()
3197 for (i = 0; i < core->num_parents - 1; i++) in possible_parents_show()
3208 struct clk_core *core = s->private; in current_parent_show()
3210 if (core->parent) in current_parent_show()
3211 seq_printf(s, "%s\n", core->parent->name); in current_parent_show()
3219 struct clk_core *core = s->private; in clk_duty_cycle_show()
3220 struct clk_duty *duty = &core->duty; in clk_duty_cycle_show()
3222 seq_printf(s, "%u/%u\n", duty->num, duty->den); in clk_duty_cycle_show()
3230 struct clk_core *core = s->private; in clk_min_rate_show()
3244 struct clk_core *core = s->private; in clk_max_rate_show()
3263 root = debugfs_create_dir(core->name, pdentry); in clk_debug_create_one()
3264 core->dentry = root; in clk_debug_create_one()
3270 debugfs_create_ulong("clk_accuracy", 0444, root, &core->accuracy); in clk_debug_create_one()
3271 debugfs_create_u32("clk_phase", 0444, root, &core->phase); in clk_debug_create_one()
3273 debugfs_create_u32("clk_prepare_count", 0444, root, &core->prepare_count); in clk_debug_create_one()
3274 debugfs_create_u32("clk_enable_count", 0444, root, &core->enable_count); in clk_debug_create_one()
3275 debugfs_create_u32("clk_protect_count", 0444, root, &core->protect_count); in clk_debug_create_one()
3276 debugfs_create_u32("clk_notifier_count", 0444, root, &core->notifier_count); in clk_debug_create_one()
3284 if (core->num_parents > 0) in clk_debug_create_one()
3288 if (core->num_parents > 1) in clk_debug_create_one()
3292 if (core->ops->debug_init) in clk_debug_create_one()
3293 core->ops->debug_init(core->hw, core->dentry); in clk_debug_create_one()
3297 * clk_debug_register - add a clk node to the debugfs clk directory
3307 hlist_add_head(&core->debug_node, &clk_debug_list); in clk_debug_register()
3314 * clk_debug_unregister - remove a clk node from the debugfs clk directory
3318 * debugfs clk directory if clk->dentry points to debugfs created by
3324 hlist_del_init(&core->debug_node); in clk_debug_unregister()
3325 debugfs_remove_recursive(core->dentry); in clk_debug_unregister()
3326 core->dentry = NULL; in clk_debug_unregister()
3331 * clk_debug_init - lazily populate the debugfs clk directory
3335 * populates the debugfs clk directory once at boot-time when we know that
3336 * debugfs is setup. It should only be called once at boot-time, all other clks
3386 * clock. This is important for CLK_IS_CRITICAL clocks, which in clk_core_reparent_orphans_nolock()
3400 * __clk_core_init - initialize the data structures in a struct clk_core
3414 return -EINVAL; in __clk_core_init()
3422 /* check to see if a clock with this name is already registered */ in __clk_core_init()
3423 if (clk_core_lookup(core->name)) { in __clk_core_init()
3425 __func__, core->name); in __clk_core_init()
3426 ret = -EEXIST; in __clk_core_init()
3430 /* check that clk_ops are sane. See Documentation/driver-api/clk.rst */ in __clk_core_init()
3431 if (core->ops->set_rate && in __clk_core_init()
3432 !((core->ops->round_rate || core->ops->determine_rate) && in __clk_core_init()
3433 core->ops->recalc_rate)) { in __clk_core_init()
3435 __func__, core->name); in __clk_core_init()
3436 ret = -EINVAL; in __clk_core_init()
3440 if (core->ops->set_parent && !core->ops->get_parent) { in __clk_core_init()
3442 __func__, core->name); in __clk_core_init()
3443 ret = -EINVAL; in __clk_core_init()
3447 if (core->num_parents > 1 && !core->ops->get_parent) { in __clk_core_init()
3449 __func__, core->name); in __clk_core_init()
3450 ret = -EINVAL; in __clk_core_init()
3454 if (core->ops->set_rate_and_parent && in __clk_core_init()
3455 !(core->ops->set_parent && core->ops->set_rate)) { in __clk_core_init()
3457 __func__, core->name); in __clk_core_init()
3458 ret = -EINVAL; in __clk_core_init()
3463 * optional platform-specific magic in __clk_core_init()
3465 * The .init callback is not used by any of the basic clock types, but in __clk_core_init()
3467 * CCF to get an accurate view of clock for any other callbacks. It may in __clk_core_init()
3474 * the clock in __clk_core_init()
3476 if (core->ops->init) { in __clk_core_init()
3477 ret = core->ops->init(core->hw); in __clk_core_init()
3482 parent = core->parent = __clk_init_parent(core); in __clk_core_init()
3485 * Populate core->parent if parent has already been clk_core_init'd. If in __clk_core_init()
3491 * clocks and re-parent any that are children of the clock currently in __clk_core_init()
3495 hlist_add_head(&core->child_node, &parent->children); in __clk_core_init()
3496 core->orphan = parent->orphan; in __clk_core_init()
3497 } else if (!core->num_parents) { in __clk_core_init()
3498 hlist_add_head(&core->child_node, &clk_root_list); in __clk_core_init()
3499 core->orphan = false; in __clk_core_init()
3501 hlist_add_head(&core->child_node, &clk_orphan_list); in __clk_core_init()
3502 core->orphan = true; in __clk_core_init()
3506 * Set clk's accuracy. The preferred method is to use in __clk_core_init()
3508 * fallback is to use the parent's accuracy. If a clock doesn't have a in __clk_core_init()
3509 * parent (or is orphaned) then accuracy is set to zero (perfect in __clk_core_init()
3510 * clock). in __clk_core_init()
3512 if (core->ops->recalc_accuracy) in __clk_core_init()
3513 core->accuracy = core->ops->recalc_accuracy(core->hw, in __clk_core_init()
3516 core->accuracy = parent->accuracy; in __clk_core_init()
3518 core->accuracy = 0; in __clk_core_init()
3523 * query the current clock phase, or just assume it's in phase. in __clk_core_init()
3529 core->name); in __clk_core_init()
3541 * parent's rate. If a clock doesn't have a parent (or is orphaned) in __clk_core_init()
3544 if (core->ops->recalc_rate) in __clk_core_init()
3545 rate = core->ops->recalc_rate(core->hw, in __clk_core_init()
3548 rate = parent->rate; in __clk_core_init()
3551 core->rate = core->req_rate = rate; in __clk_core_init()
3558 if (core->flags & CLK_IS_CRITICAL) { in __clk_core_init()
3562 __func__, core->name); in __clk_core_init()
3569 __func__, core->name); in __clk_core_init()
3578 kref_init(&core->ref); in __clk_core_init()
3583 hlist_del_init(&core->child_node); in __clk_core_init()
3594 * clk_core_link_consumer - Add a clk consumer to the list of consumers in a clk_core
3601 hlist_add_head(&clk->clks_node, &core->clks); in clk_core_link_consumer()
3606 * clk_core_unlink_consumer - Remove a clk consumer from the list of consumers in a clk_core
3612 hlist_del(&clk->clks_node); in clk_core_unlink_consumer()
3616 * alloc_clk - Allocate a clk consumer, but leave it unlinked to the clk_core
3630 return ERR_PTR(-ENOMEM); in alloc_clk()
3632 clk->core = core; in alloc_clk()
3633 clk->dev_id = dev_id; in alloc_clk()
3634 clk->con_id = kstrdup_const(con_id, GFP_KERNEL); in alloc_clk()
3635 clk->max_rate = ULONG_MAX; in alloc_clk()
3641 * free_clk - Free a clk consumer
3649 kfree_const(clk->con_id); in free_clk()
3675 core = hw->core; in clk_hw_create_clk()
3679 clk->dev = dev; in clk_hw_create_clk()
3681 if (!try_module_get(core->owner)) { in clk_hw_create_clk()
3683 return ERR_PTR(-ENOENT); in clk_hw_create_clk()
3686 kref_get(&core->ref); in clk_hw_create_clk()
3693 * clk_hw_get_clk - get clk consumer given an clk_hw
3699 * to get a consumer clk and act on the clock element
3704 struct device *dev = hw->core->dev; in clk_hw_get_clk()
3716 return -EINVAL; in clk_cpy_name()
3722 return -ENOMEM; in clk_cpy_name()
3730 u8 num_parents = init->num_parents; in clk_core_populate_parent_map()
3731 const char * const *parent_names = init->parent_names; in clk_core_populate_parent_map()
3732 const struct clk_hw **parent_hws = init->parent_hws; in clk_core_populate_parent_map()
3733 const struct clk_parent_data *parent_data = init->parent_data; in clk_core_populate_parent_map()
3741 * Avoid unnecessary string look-ups of clk_core's possible parents by in clk_core_populate_parent_map()
3745 core->parents = parents; in clk_core_populate_parent_map()
3747 return -ENOMEM; in clk_core_populate_parent_map()
3751 parent->index = -1; in clk_core_populate_parent_map()
3756 __func__, core->name); in clk_core_populate_parent_map()
3757 ret = clk_cpy_name(&parent->name, parent_names[i], in clk_core_populate_parent_map()
3760 parent->hw = parent_data[i].hw; in clk_core_populate_parent_map()
3761 parent->index = parent_data[i].index; in clk_core_populate_parent_map()
3762 ret = clk_cpy_name(&parent->fw_name, in clk_core_populate_parent_map()
3765 ret = clk_cpy_name(&parent->name, in clk_core_populate_parent_map()
3769 parent->hw = parent_hws[i]; in clk_core_populate_parent_map()
3771 ret = -EINVAL; in clk_core_populate_parent_map()
3779 } while (--i >= 0); in clk_core_populate_parent_map()
3791 int i = core->num_parents; in clk_core_free_parent_map()
3793 if (!core->num_parents) in clk_core_free_parent_map()
3796 while (--i >= 0) { in clk_core_free_parent_map()
3797 kfree_const(core->parents[i].name); in clk_core_free_parent_map()
3798 kfree_const(core->parents[i].fw_name); in clk_core_free_parent_map()
3801 kfree(core->parents); in clk_core_free_parent_map()
3809 const struct clk_init_data *init = hw->init; in __clk_register()
3814 * we catch use of hw->init early on in the core. in __clk_register()
3816 hw->init = NULL; in __clk_register()
3820 ret = -ENOMEM; in __clk_register()
3824 core->name = kstrdup_const(init->name, GFP_KERNEL); in __clk_register()
3825 if (!core->name) { in __clk_register()
3826 ret = -ENOMEM; in __clk_register()
3830 if (WARN_ON(!init->ops)) { in __clk_register()
3831 ret = -EINVAL; in __clk_register()
3834 core->ops = init->ops; in __clk_register()
3837 core->rpm_enabled = true; in __clk_register()
3838 core->dev = dev; in __clk_register()
3839 core->of_node = np; in __clk_register()
3840 if (dev && dev->driver) in __clk_register()
3841 core->owner = dev->driver->owner; in __clk_register()
3842 core->hw = hw; in __clk_register()
3843 core->flags = init->flags; in __clk_register()
3844 core->num_parents = init->num_parents; in __clk_register()
3845 core->min_rate = 0; in __clk_register()
3846 core->max_rate = ULONG_MAX; in __clk_register()
3847 hw->core = core; in __clk_register()
3853 INIT_HLIST_HEAD(&core->clks); in __clk_register()
3859 hw->clk = alloc_clk(core, NULL, NULL); in __clk_register()
3860 if (IS_ERR(hw->clk)) { in __clk_register()
3861 ret = PTR_ERR(hw->clk); in __clk_register()
3865 clk_core_link_consumer(hw->core, hw->clk); in __clk_register()
3869 return hw->clk; in __clk_register()
3872 clk_core_unlink_consumer(hw->clk); in __clk_register()
3875 free_clk(hw->clk); in __clk_register()
3876 hw->clk = NULL; in __clk_register()
3882 kfree_const(core->name); in __clk_register()
3890 * dev_or_parent_of_node() - Get device node of @dev or @dev's parent
3894 * @dev->parent if dev doesn't have a device node, or NULL if neither
3895 * @dev or @dev->parent have a device node.
3906 np = dev_of_node(dev->parent); in dev_or_parent_of_node()
3912 * clk_register - allocate a new clock, register it and return an opaque cookie
3913 * @dev: device that is registering this clock
3914 * @hw: link to hardware-specific clock data
3916 * clk_register is the *deprecated* interface for populating the clock tree with
3917 * new clock nodes. Use clk_hw_register() instead.
3921 * rest of the clock API. In the event of an error clk_register will return an
3931 * clk_hw_register - register a clk_hw and return an error code
3932 * @dev: device that is registering this clock
3933 * @hw: link to hardware-specific clock data
3935 * clk_hw_register is the primary interface for populating the clock tree with
3936 * new clock nodes. It returns an integer equal to zero indicating success or
3948 * of_clk_hw_register - register a clk_hw and return an error code
3949 * @node: device_node of device that is registering this clock
3950 * @hw: link to hardware-specific clock data
3952 * of_clk_hw_register() is the primary interface for populating the clock tree
3953 * with new clock nodes when a struct device is not available, but a struct
3964 /* Free memory allocated for a clock. */
3972 kfree_const(core->name); in __clk_release()
3978 * after clk_unregister() was called on a clock and until last clock
3983 return -ENXIO; in clk_nodrv_prepare_enable()
3994 return -ENXIO; in clk_nodrv_set_rate()
3999 return -ENXIO; in clk_nodrv_set_parent()
4017 for (i = 0; i < root->num_parents; i++) in clk_core_evict_parent_cache_subtree()
4018 if (root->parents[i].core == target) in clk_core_evict_parent_cache_subtree()
4019 root->parents[i].core = NULL; in clk_core_evict_parent_cache_subtree()
4021 hlist_for_each_entry(child, &root->children, child_node) in clk_core_evict_parent_cache_subtree()
4040 * clk_unregister - unregister a currently registered clock
4041 * @clk: clock to unregister
4051 clk_debug_unregister(clk->core); in clk_unregister()
4055 ops = clk->core->ops; in clk_unregister()
4057 pr_err("%s: unregistered clock: %s\n", __func__, in clk_unregister()
4058 clk->core->name); in clk_unregister()
4062 * Assign empty clock ops for consumers that might still hold in clk_unregister()
4063 * a reference to this clock. in clk_unregister()
4066 clk->core->ops = &clk_nodrv_ops; in clk_unregister()
4069 if (ops->terminate) in clk_unregister()
4070 ops->terminate(clk->core->hw); in clk_unregister()
4072 if (!hlist_empty(&clk->core->children)) { in clk_unregister()
4077 hlist_for_each_entry_safe(child, t, &clk->core->children, in clk_unregister()
4082 clk_core_evict_parent_cache(clk->core); in clk_unregister()
4084 hlist_del_init(&clk->core->child_node); in clk_unregister()
4086 if (clk->core->prepare_count) in clk_unregister()
4087 pr_warn("%s: unregistering prepared clock: %s\n", in clk_unregister()
4088 __func__, clk->core->name); in clk_unregister()
4090 if (clk->core->protect_count) in clk_unregister()
4091 pr_warn("%s: unregistering protected clock: %s\n", in clk_unregister()
4092 __func__, clk->core->name); in clk_unregister()
4094 kref_put(&clk->core->ref, __clk_release); in clk_unregister()
4102 * clk_hw_unregister - unregister a currently registered clk_hw
4103 * @hw: hardware-specific clock data to unregister
4107 clk_unregister(hw->clk); in clk_hw_unregister()
4122 * devm_clk_register - resource managed clk_register()
4123 * @dev: device that is registering this clock
4124 * @hw: link to hardware-specific clock data
4138 return ERR_PTR(-ENOMEM); in devm_clk_register()
4153 * devm_clk_hw_register - resource managed clk_hw_register()
4154 * @dev: device that is registering this clock
4155 * @hw: link to hardware-specific clock data
4168 return -ENOMEM; in devm_clk_hw_register()
4200 * devm_clk_unregister - resource managed clk_unregister()
4201 * @dev: device that is unregistering the clock data
4202 * @clk: clock to unregister
4204 * Deallocate a clock allocated with devm_clk_register(). Normally
4215 * devm_clk_hw_unregister - resource managed clk_hw_unregister()
4216 * @dev: device that is unregistering the hardware-specific clock data
4217 * @hw: link to hardware-specific clock data
4236 * devm_clk_hw_get_clk - resource managed clk_hw_get_clk()
4237 * @dev: device that is registering this clock
4255 WARN_ON_ONCE(dev != hw->core->dev); in devm_clk_hw_get_clk()
4259 return ERR_PTR(-ENOMEM); in devm_clk_hw_get_clk()
4291 if (WARN_ON(clk->exclusive_count)) { in __clk_put()
4293 clk->core->protect_count -= (clk->exclusive_count - 1); in __clk_put()
4294 clk_core_rate_unprotect(clk->core); in __clk_put()
4295 clk->exclusive_count = 0; in __clk_put()
4298 hlist_del(&clk->clks_node); in __clk_put()
4299 if (clk->min_rate > clk->core->req_rate || in __clk_put()
4300 clk->max_rate < clk->core->req_rate) in __clk_put()
4301 clk_core_set_rate_nolock(clk->core, clk->core->req_rate); in __clk_put()
4303 owner = clk->core->owner; in __clk_put()
4304 kref_put(&clk->core->ref, __clk_release); in __clk_put()
4316 * clk_notifier_register - add a clk rate change notifier
4323 * re-enter into the clk framework by calling any top-level clk APIs;
4327 * clock rate is passed to the callback via struct clk_notifier_data.old_rate
4330 * clk_notifier_register() must be called from non-atomic context.
4331 * Returns -EINVAL if called with null arguments, -ENOMEM upon
4338 int ret = -ENOMEM; in clk_notifier_register()
4341 return -EINVAL; in clk_notifier_register()
4347 if (cn->clk == clk) in clk_notifier_register()
4355 cn->clk = clk; in clk_notifier_register()
4356 srcu_init_notifier_head(&cn->notifier_head); in clk_notifier_register()
4358 list_add(&cn->node, &clk_notifier_list); in clk_notifier_register()
4361 ret = srcu_notifier_chain_register(&cn->notifier_head, nb); in clk_notifier_register()
4363 clk->core->notifier_count++; in clk_notifier_register()
4373 * clk_notifier_unregister - remove a clk rate change notifier
4380 * Returns -EINVAL if called with null arguments; otherwise, passes
4386 int ret = -ENOENT; in clk_notifier_unregister()
4389 return -EINVAL; in clk_notifier_unregister()
4394 if (cn->clk == clk) { in clk_notifier_unregister()
4395 ret = srcu_notifier_chain_unregister(&cn->notifier_head, nb); in clk_notifier_unregister()
4397 clk->core->notifier_count--; in clk_notifier_unregister()
4400 if (!cn->notifier_head.head) { in clk_notifier_unregister()
4401 srcu_cleanup_notifier_head(&cn->notifier_head); in clk_notifier_unregister()
4402 list_del(&cn->node); in clk_notifier_unregister()
4424 clk_notifier_unregister(devres->clk, devres->nb); in devm_clk_notifier_release()
4437 return -ENOMEM; in devm_clk_notifier_register()
4441 devres->clk = clk; in devm_clk_notifier_register()
4442 devres->nb = nb; in devm_clk_notifier_register()
4460 * struct of_clk_provider - Clock provider registration structure
4461 * @link: Entry in global list of clock providers
4462 * @node: Pointer to device tree node of clock provider
4463 * @get: Get clock callback. Returns NULL or a struct clk for the
4464 * given clock specifier
4466 * struct clk_hw for the given clock specifier
4501 unsigned int idx = clkspec->args[0]; in of_clk_src_onecell_get()
4503 if (idx >= clk_data->clk_num) { in of_clk_src_onecell_get()
4504 pr_err("%s: invalid clock index %u\n", __func__, idx); in of_clk_src_onecell_get()
4505 return ERR_PTR(-EINVAL); in of_clk_src_onecell_get()
4508 return clk_data->clks[idx]; in of_clk_src_onecell_get()
4516 unsigned int idx = clkspec->args[0]; in of_clk_hw_onecell_get()
4518 if (idx >= hw_data->num) { in of_clk_hw_onecell_get()
4520 return ERR_PTR(-EINVAL); in of_clk_hw_onecell_get()
4523 return hw_data->hws[idx]; in of_clk_hw_onecell_get()
4528 * of_clk_add_provider() - Register a clock provider for a node
4529 * @np: Device node pointer associated with clock provider
4530 * @clk_src_get: callback for decoding clock
4548 return -ENOMEM; in of_clk_add_provider()
4550 cp->node = of_node_get(np); in of_clk_add_provider()
4551 cp->data = data; in of_clk_add_provider()
4552 cp->get = clk_src_get; in of_clk_add_provider()
4555 list_add(&cp->link, &of_clk_providers); in of_clk_add_provider()
4557 pr_debug("Added clock from %pOF\n", np); in of_clk_add_provider()
4565 fwnode_dev_initialized(&np->fwnode, true); in of_clk_add_provider()
4572 * of_clk_add_hw_provider() - Register a clock provider for a node
4573 * @np: Device node pointer associated with clock provider
4590 return -ENOMEM; in of_clk_add_hw_provider()
4592 cp->node = of_node_get(np); in of_clk_add_hw_provider()
4593 cp->data = data; in of_clk_add_hw_provider()
4594 cp->get_hw = get; in of_clk_add_hw_provider()
4597 list_add(&cp->link, &of_clk_providers); in of_clk_add_hw_provider()
4607 fwnode_dev_initialized(&np->fwnode, true); in of_clk_add_hw_provider()
4619 * We allow a child device to use its parent device as the clock provider node
4620 * for cases like MFD sub-devices where the child device driver wants to use
4621 * devm_*() APIs but not list the device in DT as a sub-node.
4627 np = dev->of_node; in get_clk_provider_node()
4628 parent_np = dev->parent ? dev->parent->of_node : NULL; in get_clk_provider_node()
4630 if (!of_find_property(np, "#clock-cells", NULL)) in get_clk_provider_node()
4631 if (of_find_property(parent_np, "#clock-cells", NULL)) in get_clk_provider_node()
4638 * devm_of_clk_add_hw_provider() - Managed clk provider node registration
4639 * @dev: Device acting as the clock provider (used for DT node and lifetime)
4643 * Registers clock provider for given device's node. If the device has no DT
4644 * node or if the device node lacks of clock provider information (#clock-cells)
4646 * has the #clock-cells then it is used in registration. Provider is
4662 return -ENOMEM; in devm_of_clk_add_hw_provider()
4678 * of_clk_del_provider() - Remove a previously registered clock provider
4679 * @np: Device node pointer associated with clock provider
4690 if (cp->node == np) { in of_clk_del_provider()
4691 list_del(&cp->link); in of_clk_del_provider()
4692 fwnode_dev_initialized(&np->fwnode, false); in of_clk_del_provider()
4693 of_node_put(cp->node); in of_clk_del_provider()
4713 * devm_of_clk_del_provider() - Remove clock provider registered using devm
4714 * @dev: Device to whose lifetime the clock provider was bound
4729 * of_parse_clkspec() - Parse a DT clock specifier for a given device node
4730 * @np: device node to parse clock specifier from
4731 * @index: index of phandle to parse clock out of. If index < 0, @name is used
4732 * @name: clock name to find and parse. If name is NULL, the index is used
4733 * @out_args: Result of parsing the clock specifier
4735 * Parses a device node's "clocks" and "clock-names" properties to find the
4736 * phandle and cells for the index or name that is desired. The resulting clock
4738 * parsing error. The @index argument is ignored if @name is non-NULL.
4742 * phandle1: clock-controller@1 {
4743 * #clock-cells = <2>;
4746 * phandle2: clock-controller@2 {
4747 * #clock-cells = <1>;
4750 * clock-consumer@3 {
4752 * clock-names = "name1", "name2";
4755 * To get a device_node for `clock-controller@2' node you may call this
4758 * of_parse_clkspec(clock-consumer@3, -1, "name2", &args);
4759 * of_parse_clkspec(clock-consumer@3, 1, NULL, &args);
4760 * of_parse_clkspec(clock-consumer@3, 1, "name2", &args);
4762 * Return: 0 upon successfully parsing the clock specifier. Otherwise, -ENOENT
4763 * if @name is NULL or -EINVAL if @name is non-NULL and it can't be found in
4764 * the "clock-names" property of @np.
4769 int ret = -ENOENT; in of_parse_clkspec()
4771 /* Walk up the tree of devices looking for a clock property that matches */ in of_parse_clkspec()
4775 * "clock-names" property. If it cannot be found, then index in of_parse_clkspec()
4777 * return -EINVAL. in of_parse_clkspec()
4780 index = of_property_match_string(np, "clock-names", name); in of_parse_clkspec()
4781 ret = of_parse_phandle_with_args(np, "clocks", "#clock-cells", in of_parse_clkspec()
4789 * No matching clock found on this node. If the parent node in of_parse_clkspec()
4790 * has a "clock-ranges" property, then we can try one of its in of_parse_clkspec()
4793 np = np->parent; in of_parse_clkspec()
4794 if (np && !of_get_property(np, "clock-ranges", NULL)) in of_parse_clkspec()
4808 if (provider->get_hw) in __of_clk_get_hw_from_provider()
4809 return provider->get_hw(clkspec, provider->data); in __of_clk_get_hw_from_provider()
4811 clk = provider->get(clkspec, provider->data); in __of_clk_get_hw_from_provider()
4821 struct clk_hw *hw = ERR_PTR(-EPROBE_DEFER); in of_clk_get_hw_from_clkspec()
4824 return ERR_PTR(-EINVAL); in of_clk_get_hw_from_clkspec()
4828 if (provider->node == clkspec->np) { in of_clk_get_hw_from_clkspec()
4840 * of_clk_get_from_provider() - Lookup a clock from a clock provider
4841 * @clkspec: pointer to a clock specifier data structure
4843 * This function looks up a struct clk from the registered list of clock
4844 * providers, an input is a clock specifier data structure as returned
4883 return __of_clk_get(np, index, np->full_name, NULL); in of_clk_get()
4888 * of_clk_get_by_name() - Parse and lookup a clock referenced by a device node
4889 * @np: pointer to clock consumer node
4890 * @name: name of consumer's clock input, or NULL for the first clock reference
4892 * This function parses the clocks and clock-names properties,
4893 * and uses them to look up the struct clk from the registered list of clock
4899 return ERR_PTR(-ENOENT); in of_clk_get_by_name()
4901 return __of_clk_get(np, 0, np->full_name, name); in of_clk_get_by_name()
4906 * of_clk_get_parent_count() - Count the number of clocks a device node has
4915 count = of_count_phandle_with_args(np, "clocks", "#clock-cells"); in of_clk_get_parent_count()
4934 rc = of_parse_phandle_with_args(np, "clocks", "#clock-cells", index, in of_clk_get_parent_name()
4943 * specified into an array offset for the clock-output-names property. in of_clk_get_parent_name()
4945 of_property_for_each_u32(clkspec.np, "clock-indices", prop, vp, pv) { in of_clk_get_parent_name()
4952 /* We went off the end of 'clock-indices' without finding it */ in of_clk_get_parent_name()
4956 if (of_property_read_string_index(clkspec.np, "clock-output-names", in of_clk_get_parent_name()
4960 * Best effort to get the name if the clock has been in of_clk_get_parent_name()
4961 * registered with the framework. If the clock isn't in of_clk_get_parent_name()
4963 * the clock as long as #clock-cells = 0. in of_clk_get_parent_name()
4968 clk_name = clkspec.np->name; in of_clk_get_parent_name()
4984 * of_clk_parent_fill() - Fill @parents with names of @np's parents and return
4986 * @np: Device node pointer associated with clock provider
4990 * Return: number of parents for the clock node.
5011 * This function looks for a parent clock. If there is one, then it
5012 * checks that the provider for this parent clock was initialized, in
5013 * this case the parent clock will be ready.
5030 if (PTR_ERR(clk) == -EPROBE_DEFER) in parent_ready()
5037 * previous parent are ready. If there is no clock in parent_ready()
5046 * of_clk_detect_critical() - set CLK_IS_CRITICAL flag from Device Tree
5047 * @np: Device node pointer associated with clock provider
5048 * @index: clock index
5049 * @flags: pointer to top-level framework flags
5051 * Detects if the clock-critical property exists and, if so, sets the
5055 * bindings, such as the one-clock-per-node style that are outdated.
5056 * Those bindings typically put all clock data into .dts and the Linux
5057 * driver has no clock data, thus making it impossible to set this flag
5071 return -EINVAL; in of_clk_detect_critical()
5073 of_property_for_each_u32(np, "clock-critical", prop, cur, idx) in of_clk_detect_critical()
5081 * of_clk_init() - Scan and init clock providers from the DT
5084 * This function scans the device tree for matching clock providers
5111 list_del(&clk_provider->node); in of_clk_init()
5112 of_node_put(clk_provider->np); in of_clk_init()
5119 parent->clk_init_cb = match->data; in of_clk_init()
5120 parent->np = of_node_get(np); in of_clk_init()
5121 list_add_tail(&parent->node, &clk_provider_list); in of_clk_init()
5128 if (force || parent_ready(clk_provider->np)) { in of_clk_init()
5131 of_node_set_flag(clk_provider->np, in of_clk_init()
5134 clk_provider->clk_init_cb(clk_provider->np); in of_clk_init()
5135 of_clk_set_defaults(clk_provider->np, true); in of_clk_init()
5137 list_del(&clk_provider->node); in of_clk_init()
5138 of_node_put(clk_provider->np); in of_clk_init()
5148 * in case the clock parent was not mandatory in of_clk_init()