• Home
  • Raw
  • Download

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>
85 unsigned long accuracy; member
118 if (!core->rpm_enabled) in clk_pm_runtime_get()
121 ret = pm_runtime_get_sync(core->dev); in clk_pm_runtime_get()
123 pm_runtime_put_noidle(core->dev); in clk_pm_runtime_get()
131 if (!core->rpm_enabled) in clk_pm_runtime_put()
134 pm_runtime_put_sync(core->dev); in clk_pm_runtime_put()
138 * clk_pm_runtime_get_all() - Runtime "get" all clk provider devices
173 dev_name(failed->dev), failed->name); in clk_pm_runtime_get_all()
193 * clk_pm_runtime_put_all() - Runtime "put" all clk provider devices
209 struct device *dev = core->dev; in clk_pm_runtime_init()
212 core->rpm_enabled = true; in clk_pm_runtime_init()
215 hlist_add_head(&core->rpm_node, &clk_rpm_list); in clk_pm_runtime_init()
241 if (--prepare_refcnt) in clk_prepare_unlock()
281 if (--enable_refcnt) { in clk_enable_unlock()
291 return core->protect_count; in clk_core_rate_is_protected()
302 if (!core->ops->is_prepared) in clk_core_is_prepared()
303 return core->prepare_count; in clk_core_is_prepared()
306 ret = core->ops->is_prepared(core->hw); in clk_core_is_prepared()
321 if (!core->ops->is_enabled) in clk_core_is_enabled()
322 return core->enable_count; in clk_core_is_enabled()
325 * Check if clock controller's device is runtime active before in clk_core_is_enabled()
326 * calling .is_enabled callback. If not, assume that clock is in clk_core_is_enabled()
334 if (core->rpm_enabled) { in clk_core_is_enabled()
335 pm_runtime_get_noresume(core->dev); in clk_core_is_enabled()
336 if (!pm_runtime_active(core->dev)) { in clk_core_is_enabled()
345 * anything here. We can also assume this clock isn't enabled. in clk_core_is_enabled()
347 if ((core->flags & CLK_OPS_PARENT_ENABLE) && core->parent) in clk_core_is_enabled()
348 if (!clk_core_is_enabled(core->parent)) { in clk_core_is_enabled()
353 ret = core->ops->is_enabled(core->hw); in clk_core_is_enabled()
355 if (core->rpm_enabled) in clk_core_is_enabled()
356 pm_runtime_put(core->dev); in clk_core_is_enabled()
365 return !clk ? NULL : clk->core->name; in __clk_get_name()
371 return hw->core->name; in clk_hw_get_name()
377 return !clk ? NULL : clk->core->hw; in __clk_get_hw()
383 return hw->core->num_parents; in clk_hw_get_num_parents()
389 return hw->core->parent ? hw->core->parent->hw : NULL; in clk_hw_get_parent()
399 if (!strcmp(core->name, name)) in __clk_lookup_subtree()
402 hlist_for_each_entry(child, &core->children, child_node) { in __clk_lookup_subtree()
446 return -ENOENT; in of_parse_clkspec()
451 return ERR_PTR(-ENOENT); in of_clk_get_hw_from_clkspec()
456 * clk_core_get - Find the clk_core parent of a clk
463 * node's 'clock-names' property or as the 'con_id' matching the device's
467 * For example the following DT snippet would allow a clock registered by the
468 * clock-controller@c001 that has a clk_init_data::parent_data array
469 * with 'xtal' in the 'name' member to find the clock provided by the
470 * clock-controller@f00abcd without needing to get the globally unique name of
473 * parent: clock-controller@f00abcd {
475 * #clock-cells = <0>;
478 * clock-controller@c001 {
481 * clock-names = "xtal";
482 * #clock-cells = <1>;
485 * Returns: -ENOENT when the provider can't be found or the clk doesn't
493 const char *name = core->parents[p_index].fw_name; in clk_core_get()
494 int index = core->parents[p_index].index; in clk_core_get()
495 struct clk_hw *hw = ERR_PTR(-ENOENT); in clk_core_get()
496 struct device *dev = core->dev; in clk_core_get()
498 struct device_node *np = core->of_node; in clk_core_get()
519 return hw->core; in clk_core_get()
524 struct clk_parent_map *entry = &core->parents[index]; in clk_core_fill_parent_index()
525 struct clk_core *parent = ERR_PTR(-ENOENT); in clk_core_fill_parent_index()
527 if (entry->hw) { in clk_core_fill_parent_index()
528 parent = entry->hw->core; in clk_core_fill_parent_index()
535 parent = ERR_PTR(-EPROBE_DEFER); in clk_core_fill_parent_index()
538 if (PTR_ERR(parent) == -ENOENT && entry->name) in clk_core_fill_parent_index()
539 parent = clk_core_lookup(entry->name); in clk_core_fill_parent_index()
544 entry->core = parent; in clk_core_fill_parent_index()
550 if (!core || index >= core->num_parents || !core->parents) in clk_core_get_parent_by_index()
553 if (!core->parents[index].core) in clk_core_get_parent_by_index()
556 return core->parents[index].core; in clk_core_get_parent_by_index()
564 parent = clk_core_get_parent_by_index(hw->core, index); in clk_hw_get_parent_by_index()
566 return !parent ? NULL : parent->hw; in clk_hw_get_parent_by_index()
572 return !clk ? 0 : clk->core->enable_count; in __clk_get_enable_count()
580 if (!core->num_parents || core->parent) in clk_core_get_rate_nolock()
581 return core->rate; in clk_core_get_rate_nolock()
593 return clk_core_get_rate_nolock(hw->core); in clk_hw_get_rate()
602 return core->accuracy; in clk_core_get_accuracy_no_lock()
607 return hw->core->flags; in clk_hw_get_flags()
613 return clk_core_is_prepared(hw->core); in clk_hw_is_prepared()
619 return clk_core_rate_is_protected(hw->core); in clk_hw_rate_is_protected()
625 return clk_core_is_enabled(hw->core); in clk_hw_is_enabled()
634 return clk_core_is_enabled(clk->core); in __clk_is_enabled()
642 return abs(now - rate) < abs(best - rate); in mux_is_better_rate()
651 struct clk_core *core = hw->core, *parent, *best_parent = NULL; in clk_mux_determine_rate_flags()
657 if (core->flags & CLK_SET_RATE_NO_REPARENT) { in clk_mux_determine_rate_flags()
658 parent = core->parent; in clk_mux_determine_rate_flags()
659 if (core->flags & CLK_SET_RATE_PARENT) { in clk_mux_determine_rate_flags()
660 ret = __clk_determine_rate(parent ? parent->hw : NULL, in clk_mux_determine_rate_flags()
676 num_parents = core->num_parents; in clk_mux_determine_rate_flags()
682 if (core->flags & CLK_SET_RATE_PARENT) { in clk_mux_determine_rate_flags()
684 ret = __clk_determine_rate(parent->hw, &parent_req); in clk_mux_determine_rate_flags()
691 if (mux_is_better_rate(req->rate, parent_req.rate, in clk_mux_determine_rate_flags()
699 return -EINVAL; in clk_mux_determine_rate_flags()
703 req->best_parent_hw = best_parent->hw; in clk_mux_determine_rate_flags()
704 req->best_parent_rate = best; in clk_mux_determine_rate_flags()
705 req->rate = best; in clk_mux_determine_rate_flags()
715 return !core ? NULL : core->hw->clk; in __clk_lookup()
726 *min_rate = core->min_rate; in clk_core_get_boundaries()
727 *max_rate = core->max_rate; in clk_core_get_boundaries()
729 hlist_for_each_entry(clk_user, &core->clks, clks_node) in clk_core_get_boundaries()
730 *min_rate = max(*min_rate, clk_user->min_rate); in clk_core_get_boundaries()
732 hlist_for_each_entry(clk_user, &core->clks, clks_node) in clk_core_get_boundaries()
733 *max_rate = min(*max_rate, clk_user->max_rate); in clk_core_get_boundaries()
744 if (min_rate > core->max_rate || max_rate < core->min_rate) in clk_core_check_boundaries()
747 hlist_for_each_entry(user, &core->clks, clks_node) in clk_core_check_boundaries()
748 if (min_rate > user->max_rate || max_rate < user->min_rate) in clk_core_check_boundaries()
757 hw->core->min_rate = min_rate; in clk_hw_set_rate_range()
758 hw->core->max_rate = max_rate; in clk_hw_set_rate_range()
763 * __clk_mux_determine_rate - clk_ops::determine_rate implementation for a mux type clk
769 * complex clock that may combine a mux with other operations.
771 * Returns: 0 on success, -EERROR value on error
796 if (WARN(core->protect_count == 0, in clk_core_rate_unprotect()
797 "%s already unprotected\n", core->name)) in clk_core_rate_unprotect()
800 if (--core->protect_count > 0) in clk_core_rate_unprotect()
803 clk_core_rate_unprotect(core->parent); in clk_core_rate_unprotect()
813 return -EINVAL; in clk_core_rate_nuke_protect()
815 if (core->protect_count == 0) in clk_core_rate_nuke_protect()
818 ret = core->protect_count; in clk_core_rate_nuke_protect()
819 core->protect_count = 1; in clk_core_rate_nuke_protect()
826 * clk_rate_exclusive_put - release exclusivity over clock rate control
829 * clk_rate_exclusive_put() completes a critical section during which a clock
831 * clock which could result in a rate change or rate glitch. Exclusive clocks
836 * If exlusivity is claimed more than once on clock, even by the same consumer,
854 if (WARN_ON(clk->exclusive_count <= 0)) in clk_rate_exclusive_put()
857 clk_core_rate_unprotect(clk->core); in clk_rate_exclusive_put()
858 clk->exclusive_count--; in clk_rate_exclusive_put()
871 if (core->protect_count == 0) in clk_core_rate_protect()
872 clk_core_rate_protect(core->parent); in clk_core_rate_protect()
874 core->protect_count++; in clk_core_rate_protect()
888 core->protect_count = count; in clk_core_rate_restore_protect()
892 * clk_rate_exclusive_get - get exclusivity over the clk rate control
895 * clk_rate_exclusive_get() begins a critical section during which a clock
897 * clock which could result in a rate change or rate glitch. Exclusive clocks
902 * If exlusivity is claimed more than once on clock, even by the same consumer,
907 * Returns 0 on success, -EERROR otherwise
915 clk_core_rate_protect(clk->core); in clk_rate_exclusive_get()
916 clk->exclusive_count++; in clk_rate_exclusive_get()
930 if (WARN(core->prepare_count == 0, in clk_core_unprepare()
931 "%s already unprepared\n", core->name)) in clk_core_unprepare()
934 if (WARN(core->prepare_count == 1 && core->flags & CLK_IS_CRITICAL, in clk_core_unprepare()
935 "Unpreparing critical %s\n", core->name)) in clk_core_unprepare()
938 if (core->flags & CLK_SET_RATE_GATE) in clk_core_unprepare()
941 if (--core->prepare_count > 0) in clk_core_unprepare()
944 WARN(core->enable_count > 0, "Unpreparing enabled %s\n", core->name); in clk_core_unprepare()
948 if (core->ops->unprepare) in clk_core_unprepare()
949 core->ops->unprepare(core->hw); in clk_core_unprepare()
952 clk_core_unprepare(core->parent); in clk_core_unprepare()
964 * clk_unprepare - undo preparation of a clock source
979 clk_core_unprepare_lock(clk->core); in clk_unprepare()
992 if (core->prepare_count == 0) { in clk_core_prepare()
997 ret = clk_core_prepare(core->parent); in clk_core_prepare()
1003 if (core->ops->prepare) in clk_core_prepare()
1004 ret = core->ops->prepare(core->hw); in clk_core_prepare()
1012 core->prepare_count++; in clk_core_prepare()
1015 * CLK_SET_RATE_GATE is a special case of clock protection in clk_core_prepare()
1019 * the clock is prepared. in clk_core_prepare()
1021 if (core->flags & CLK_SET_RATE_GATE) in clk_core_prepare()
1026 clk_core_unprepare(core->parent); in clk_core_prepare()
1044 * clk_prepare - prepare a clock source
1053 * Returns 0 on success, -EERROR otherwise.
1060 return clk_core_prepare_lock(clk->core); in clk_prepare()
1071 if (WARN(core->enable_count == 0, "%s already disabled\n", core->name)) in clk_core_disable()
1074 if (WARN(core->enable_count == 1 && core->flags & CLK_IS_CRITICAL, in clk_core_disable()
1075 "Disabling critical %s\n", core->name)) in clk_core_disable()
1078 if (--core->enable_count > 0) in clk_core_disable()
1083 if (core->ops->disable) in clk_core_disable()
1084 core->ops->disable(core->hw); in clk_core_disable()
1088 clk_core_disable(core->parent); in clk_core_disable()
1101 * clk_disable - gate a clock
1107 * SoC-internal clk which is controlled via simple register writes. In the
1117 clk_core_disable_lock(clk->core); in clk_disable()
1130 if (WARN(core->prepare_count == 0, in clk_core_enable()
1131 "Enabling unprepared %s\n", core->name)) in clk_core_enable()
1132 return -ESHUTDOWN; in clk_core_enable()
1134 if (core->enable_count == 0) { in clk_core_enable()
1135 ret = clk_core_enable(core->parent); in clk_core_enable()
1142 if (core->ops->enable) in clk_core_enable()
1143 ret = core->ops->enable(core->hw); in clk_core_enable()
1148 clk_core_disable(core->parent); in clk_core_enable()
1153 core->enable_count++; in clk_core_enable()
1170 * clk_gate_restore_context - restore context for poweroff
1171 * @hw: the clk_hw pointer of clock whose state is to be restored
1173 * The clock gate restore context function enables or disables
1175 * where the clock context is lost and based on the enable_count
1176 * the clock either needs to be enabled/disabled. This
1181 struct clk_core *core = hw->core; in clk_gate_restore_context()
1183 if (core->enable_count) in clk_gate_restore_context()
1184 core->ops->enable(hw); in clk_gate_restore_context()
1186 core->ops->disable(hw); in clk_gate_restore_context()
1195 hlist_for_each_entry(child, &core->children, child_node) { in clk_core_save_context()
1201 if (core->ops && core->ops->save_context) in clk_core_save_context()
1202 ret = core->ops->save_context(core->hw); in clk_core_save_context()
1211 if (core->ops && core->ops->restore_context) in clk_core_restore_context()
1212 core->ops->restore_context(core->hw); in clk_core_restore_context()
1214 hlist_for_each_entry(child, &core->children, child_node) in clk_core_restore_context()
1219 * clk_save_context - save clock context for poweroff
1221 * Saves the context of the clock register for powerstates in which the
1247 * clk_restore_context - restore clock context after poweroff
1249 * Restore the saved clock context upon resume.
1265 * clk_enable - ungate a clock
1270 * if the operation will never sleep. One example is a SoC-internal clk which
1274 * must be called before clk_enable. Returns 0 on success, -EERROR
1282 return clk_core_enable_lock(clk->core); in clk_enable()
1313 hlist_for_each_entry(child, &core->children, child_node) in clk_unprepare_unused_subtree()
1316 if (core->prepare_count) in clk_unprepare_unused_subtree()
1319 if (core->flags & CLK_IGNORE_UNUSED) in clk_unprepare_unused_subtree()
1324 if (core->ops->unprepare_unused) in clk_unprepare_unused_subtree()
1325 core->ops->unprepare_unused(core->hw); in clk_unprepare_unused_subtree()
1326 else if (core->ops->unprepare) in clk_unprepare_unused_subtree()
1327 core->ops->unprepare(core->hw); in clk_unprepare_unused_subtree()
1339 hlist_for_each_entry(child, &core->children, child_node) in clk_disable_unused_subtree()
1342 if (core->flags & CLK_OPS_PARENT_ENABLE) in clk_disable_unused_subtree()
1343 clk_core_prepare_enable(core->parent); in clk_disable_unused_subtree()
1347 if (core->enable_count) in clk_disable_unused_subtree()
1350 if (core->flags & CLK_IGNORE_UNUSED) in clk_disable_unused_subtree()
1354 * some gate clocks have special needs during the disable-unused in clk_disable_unused_subtree()
1360 if (core->ops->disable_unused) in clk_disable_unused_subtree()
1361 core->ops->disable_unused(core->hw); in clk_disable_unused_subtree()
1362 else if (core->ops->disable) in clk_disable_unused_subtree()
1363 core->ops->disable(core->hw); in clk_disable_unused_subtree()
1369 if (core->flags & CLK_OPS_PARENT_ENABLE) in clk_disable_unused_subtree()
1370 clk_core_disable_unprepare(core->parent); in clk_disable_unused_subtree()
1434 * - if the provider is not protected at all in clk_core_determine_round_nolock()
1435 * - if the calling consumer is the only one which has exclusivity in clk_core_determine_round_nolock()
1439 req->rate = core->rate; in clk_core_determine_round_nolock()
1440 } else if (core->ops->determine_rate) { in clk_core_determine_round_nolock()
1441 return core->ops->determine_rate(core->hw, req); in clk_core_determine_round_nolock()
1442 } else if (core->ops->round_rate) { in clk_core_determine_round_nolock()
1443 rate = core->ops->round_rate(core->hw, req->rate, in clk_core_determine_round_nolock()
1444 &req->best_parent_rate); in clk_core_determine_round_nolock()
1448 req->rate = rate; in clk_core_determine_round_nolock()
1450 return -EINVAL; in clk_core_determine_round_nolock()
1464 parent = core->parent; in clk_core_init_rate_req()
1466 req->best_parent_hw = parent->hw; in clk_core_init_rate_req()
1467 req->best_parent_rate = parent->rate; in clk_core_init_rate_req()
1469 req->best_parent_hw = NULL; in clk_core_init_rate_req()
1470 req->best_parent_rate = 0; in clk_core_init_rate_req()
1476 return core->ops->determine_rate || core->ops->round_rate; in clk_core_can_round()
1485 req->rate = 0; in clk_core_round_rate_nolock()
1493 else if (core->flags & CLK_SET_RATE_PARENT) in clk_core_round_rate_nolock()
1494 return clk_core_round_rate_nolock(core->parent, req); in clk_core_round_rate_nolock()
1496 req->rate = core->rate; in clk_core_round_rate_nolock()
1501 * __clk_determine_rate - get the closest rate actually supported by a clock
1502 * @hw: determine the rate of this clock
1510 req->rate = 0; in __clk_determine_rate()
1514 return clk_core_round_rate_nolock(hw->core, req); in __clk_determine_rate()
1519 * clk_hw_round_rate() - round the given rate for a hw clk
1538 clk_core_get_boundaries(hw->core, &req.min_rate, &req.max_rate); in clk_hw_round_rate()
1541 ret = clk_core_round_rate_nolock(hw->core, &req); in clk_hw_round_rate()
1550 * clk_round_rate - round the given rate for a clk
1568 if (clk->exclusive_count) in clk_round_rate()
1569 clk_core_rate_unprotect(clk->core); in clk_round_rate()
1571 clk_core_get_boundaries(clk->core, &req.min_rate, &req.max_rate); in clk_round_rate()
1574 ret = clk_core_round_rate_nolock(clk->core, &req); in clk_round_rate()
1576 if (clk->exclusive_count) in clk_round_rate()
1577 clk_core_rate_protect(clk->core); in clk_round_rate()
1589 * __clk_notify - call clk notifier chain
1595 * Triggers a notifier call chain on the clk rate-change notification
1598 * internal clock code only. Returns NOTIFY_DONE from the last driver
1613 if (cn->clk->core == core) { in __clk_notify()
1614 cnd.clk = cn->clk; in __clk_notify()
1615 ret = srcu_notifier_call_chain(&cn->notifier_head, msg, in __clk_notify()
1631 * callback then it is assumed that the clock will take on the accuracy of its
1641 if (core->parent) in __clk_recalc_accuracies()
1642 parent_accuracy = core->parent->accuracy; in __clk_recalc_accuracies()
1644 if (core->ops->recalc_accuracy) in __clk_recalc_accuracies()
1645 core->accuracy = core->ops->recalc_accuracy(core->hw, in __clk_recalc_accuracies()
1648 core->accuracy = parent_accuracy; in __clk_recalc_accuracies()
1650 hlist_for_each_entry(child, &core->children, child_node) in __clk_recalc_accuracies()
1656 if (core && (core->flags & CLK_GET_ACCURACY_NOCACHE)) in clk_core_get_accuracy_recalc()
1663 * clk_get_accuracy - return the accuracy of clk
1664 * @clk: the clk whose accuracy is being returned
1666 * Simply returns the cached accuracy of the clk, unless
1673 long accuracy; in clk_get_accuracy() local
1679 accuracy = clk_core_get_accuracy_recalc(clk->core); in clk_get_accuracy()
1682 return accuracy; in clk_get_accuracy()
1691 if (core->ops->recalc_rate && !clk_pm_runtime_get(core)) { in clk_recalc()
1692 rate = core->ops->recalc_rate(core->hw, parent_rate); in clk_recalc()
1705 * it is assumed that the clock will take on the rate of its parent.
1718 old_rate = core->rate; in __clk_recalc_rates()
1720 if (core->parent) in __clk_recalc_rates()
1721 parent_rate = core->parent->rate; in __clk_recalc_rates()
1723 core->rate = clk_recalc(core, parent_rate); in __clk_recalc_rates()
1729 if (core->notifier_count && msg) in __clk_recalc_rates()
1730 __clk_notify(core, msg, old_rate, core->rate); in __clk_recalc_rates()
1732 hlist_for_each_entry(child, &core->children, child_node) in __clk_recalc_rates()
1738 if (core && (core->flags & CLK_GET_RATE_NOCACHE)) in clk_core_get_rate_recalc()
1745 * clk_get_rate - return the rate of clk
1760 rate = clk_core_get_rate_recalc(clk->core); in clk_get_rate()
1773 return -EINVAL; in clk_fetch_parent_index()
1775 for (i = 0; i < core->num_parents; i++) { in clk_fetch_parent_index()
1777 if (core->parents[i].core == parent) in clk_fetch_parent_index()
1781 if (core->parents[i].core) in clk_fetch_parent_index()
1785 if (core->parents[i].hw) { in clk_fetch_parent_index()
1786 if (core->parents[i].hw == parent->hw) in clk_fetch_parent_index()
1798 if (core->parents[i].name && in clk_fetch_parent_index()
1799 !strcmp(parent->name, core->parents[i].name)) in clk_fetch_parent_index()
1803 if (i == core->num_parents) in clk_fetch_parent_index()
1804 return -EINVAL; in clk_fetch_parent_index()
1806 core->parents[i].core = parent; in clk_fetch_parent_index()
1811 * clk_hw_get_parent_index - return the index of the parent clock
1814 * Fetches and returns the index of parent clock. Returns -EINVAL if the given
1815 * clock does not have a current parent.
1822 return -EINVAL; in clk_hw_get_parent_index()
1824 return clk_fetch_parent_index(hw->core, parent->core); in clk_hw_get_parent_index()
1835 core->orphan = is_orphan; in clk_core_update_orphan_status()
1837 hlist_for_each_entry(child, &core->children, child_node) in clk_core_update_orphan_status()
1843 bool was_orphan = core->orphan; in clk_reparent()
1845 hlist_del(&core->child_node); in clk_reparent()
1848 bool becomes_orphan = new_parent->orphan; in clk_reparent()
1851 if (new_parent->new_child == core) in clk_reparent()
1852 new_parent->new_child = NULL; in clk_reparent()
1854 hlist_add_head(&core->child_node, &new_parent->children); in clk_reparent()
1859 hlist_add_head(&core->child_node, &clk_orphan_list); in clk_reparent()
1864 core->parent = new_parent; in clk_reparent()
1871 struct clk_core *old_parent = core->parent; in __clk_set_parent_before()
1874 * 1. enable parents for CLK_OPS_PARENT_ENABLE clock in __clk_set_parent_before()
1879 * If the clock is not prepared, then a race with in __clk_set_parent_before()
1884 * If the clock is prepared, migrate the prepared state to the new in __clk_set_parent_before()
1886 * forcing the clock and the new parent on. This ensures that all in __clk_set_parent_before()
1894 if (core->flags & CLK_OPS_PARENT_ENABLE) { in __clk_set_parent_before()
1900 if (core->prepare_count) { in __clk_set_parent_before()
1921 if (core->prepare_count) { in __clk_set_parent_after()
1926 /* re-balance ref counting if CLK_OPS_PARENT_ENABLE is set */ in __clk_set_parent_after()
1927 if (core->flags & CLK_OPS_PARENT_ENABLE) { in __clk_set_parent_after()
1944 /* change clock input source */ in __clk_set_parent()
1945 if (parent && core->ops->set_parent) in __clk_set_parent()
1946 ret = core->ops->set_parent(core->hw, p_index); in __clk_set_parent()
1973 * pre-rate change notifications and returns early if no clks in the
1975 * implement the .recalc_rate callback then it is assumed that the clock will
1990 if (core->notifier_count) in __clk_speculate_rates()
1991 ret = __clk_notify(core, PRE_RATE_CHANGE, core->rate, new_rate); in __clk_speculate_rates()
1994 pr_debug("%s: clk notifier callback for clock %s aborted with error %d\n", in __clk_speculate_rates()
1995 __func__, core->name, ret); in __clk_speculate_rates()
1999 hlist_for_each_entry(child, &core->children, child_node) { in __clk_speculate_rates()
2014 core->new_rate = new_rate; in clk_calc_subtree()
2015 core->new_parent = new_parent; in clk_calc_subtree()
2016 core->new_parent_index = p_index; in clk_calc_subtree()
2018 core->new_child = NULL; in clk_calc_subtree()
2019 if (new_parent && new_parent != core->parent) in clk_calc_subtree()
2020 new_parent->new_child = core; in clk_calc_subtree()
2022 hlist_for_each_entry(child, &core->children, child_node) { in clk_calc_subtree()
2023 child->new_rate = clk_recalc(child, new_rate); in clk_calc_subtree()
2024 clk_calc_subtree(child, child->new_rate, NULL, 0); in clk_calc_subtree()
2029 * calculate the new rates returning the topmost clock that has to be
2049 parent = old_parent = core->parent; in clk_calc_new_rates()
2051 best_parent_rate = parent->rate; in clk_calc_new_rates()
2071 parent = req.best_parent_hw ? req.best_parent_hw->core : NULL; in clk_calc_new_rates()
2075 } else if (!parent || !(core->flags & CLK_SET_RATE_PARENT)) { in clk_calc_new_rates()
2076 /* pass-through clock without adjustable parent */ in clk_calc_new_rates()
2077 core->new_rate = core->rate; in clk_calc_new_rates()
2080 /* pass-through clock with adjustable parent */ in clk_calc_new_rates()
2082 new_rate = parent->new_rate; in clk_calc_new_rates()
2088 (core->flags & CLK_SET_PARENT_GATE) && core->prepare_count) { in clk_calc_new_rates()
2090 __func__, core->name); in clk_calc_new_rates()
2095 if (parent && core->num_parents > 1) { in clk_calc_new_rates()
2099 __func__, parent->name, core->name); in clk_calc_new_rates()
2104 if ((core->flags & CLK_SET_RATE_PARENT) && parent && in clk_calc_new_rates()
2105 best_parent_rate != parent->rate) in clk_calc_new_rates()
2125 if (core->rate == core->new_rate) in clk_propagate_rate_change()
2128 if (core->notifier_count) { in clk_propagate_rate_change()
2129 ret = __clk_notify(core, event, core->rate, core->new_rate); in clk_propagate_rate_change()
2134 hlist_for_each_entry(child, &core->children, child_node) { in clk_propagate_rate_change()
2135 /* Skip children who will be reparented to another clock */ in clk_propagate_rate_change()
2136 if (child->new_parent && child->new_parent != core) in clk_propagate_rate_change()
2143 /* handle the new child who might not be in core->children yet */ in clk_propagate_rate_change()
2144 if (core->new_child) { in clk_propagate_rate_change()
2145 tmp_clk = clk_propagate_rate_change(core->new_child, event); in clk_propagate_rate_change()
2167 old_rate = core->rate; in clk_change_rate()
2169 if (core->new_parent) { in clk_change_rate()
2170 parent = core->new_parent; in clk_change_rate()
2171 best_parent_rate = core->new_parent->rate; in clk_change_rate()
2172 } else if (core->parent) { in clk_change_rate()
2173 parent = core->parent; in clk_change_rate()
2174 best_parent_rate = core->parent->rate; in clk_change_rate()
2180 if (core->flags & CLK_SET_RATE_UNGATE) { in clk_change_rate()
2189 if (core->new_parent && core->new_parent != core->parent) { in clk_change_rate()
2190 old_parent = __clk_set_parent_before(core, core->new_parent); in clk_change_rate()
2191 trace_clk_set_parent(core, core->new_parent); in clk_change_rate()
2193 if (core->ops->set_rate_and_parent) { in clk_change_rate()
2195 core->ops->set_rate_and_parent(core->hw, core->new_rate, in clk_change_rate()
2197 core->new_parent_index); in clk_change_rate()
2198 } else if (core->ops->set_parent) { in clk_change_rate()
2199 core->ops->set_parent(core->hw, core->new_parent_index); in clk_change_rate()
2202 trace_clk_set_parent_complete(core, core->new_parent); in clk_change_rate()
2203 __clk_set_parent_after(core, core->new_parent, old_parent); in clk_change_rate()
2206 if (core->flags & CLK_OPS_PARENT_ENABLE) in clk_change_rate()
2209 trace_clk_set_rate(core, core->new_rate); in clk_change_rate()
2211 if (!skip_set_rate && core->ops->set_rate) in clk_change_rate()
2212 core->ops->set_rate(core->hw, core->new_rate, best_parent_rate); in clk_change_rate()
2214 trace_clk_set_rate_complete(core, core->new_rate); in clk_change_rate()
2216 core->rate = clk_recalc(core, best_parent_rate); in clk_change_rate()
2218 if (core->flags & CLK_SET_RATE_UNGATE) { in clk_change_rate()
2227 if (core->flags & CLK_OPS_PARENT_ENABLE) in clk_change_rate()
2230 if (core->notifier_count && old_rate != core->rate) in clk_change_rate()
2231 __clk_notify(core, POST_RATE_CHANGE, old_rate, core->rate); in clk_change_rate()
2233 if (core->flags & CLK_RECALC_NEW_RATES) in clk_change_rate()
2234 (void)clk_calc_new_rates(core, core->new_rate); in clk_change_rate()
2238 * for certain clock types. in clk_change_rate()
2240 hlist_for_each_entry_safe(child, tmp, &core->children, child_node) { in clk_change_rate()
2241 /* Skip children who will be reparented to another clock */ in clk_change_rate()
2242 if (child->new_parent && child->new_parent != core) in clk_change_rate()
2247 /* handle the new child who might not be in core->children yet */ in clk_change_rate()
2248 if (core->new_child) in clk_change_rate()
2249 clk_change_rate(core->new_child); in clk_change_rate()
2299 return -EBUSY; in clk_core_set_rate_nolock()
2301 /* calculate new rates and get the topmost changed clock */ in clk_core_set_rate_nolock()
2304 return -EINVAL; in clk_core_set_rate_nolock()
2314 fail_clk->name); in clk_core_set_rate_nolock()
2316 ret = -EBUSY; in clk_core_set_rate_nolock()
2323 core->req_rate = req_rate; in clk_core_set_rate_nolock()
2331 * clk_set_rate - specify a new rate for clk
2349 * Returns 0 on success, -EERROR otherwise.
2358 /* prevent racing with updates to the clock topology */ in clk_set_rate()
2361 if (clk->exclusive_count) in clk_set_rate()
2362 clk_core_rate_unprotect(clk->core); in clk_set_rate()
2364 ret = clk_core_set_rate_nolock(clk->core, rate); in clk_set_rate()
2366 if (clk->exclusive_count) in clk_set_rate()
2367 clk_core_rate_protect(clk->core); in clk_set_rate()
2376 * clk_set_rate_exclusive - specify a new rate and get exclusive control
2385 * same clock provider.
2392 * Returns 0 on success, -EERROR otherwise.
2401 /* prevent racing with updates to the clock topology */ in clk_set_rate_exclusive()
2407 * so before the consumer code path protect the clock provider in clk_set_rate_exclusive()
2410 ret = clk_core_set_rate_nolock(clk->core, rate); in clk_set_rate_exclusive()
2412 clk_core_rate_protect(clk->core); in clk_set_rate_exclusive()
2413 clk->exclusive_count++; in clk_set_rate_exclusive()
2423 * clk_set_rate_range - set a rate range for a clock source
2424 * @clk: clock source
2425 * @min: desired minimum clock rate in Hz, inclusive
2426 * @max: desired maximum clock rate in Hz, inclusive
2440 __func__, clk->core->name, clk->dev_id, clk->con_id, in clk_set_rate_range()
2442 return -EINVAL; in clk_set_rate_range()
2447 if (clk->exclusive_count) in clk_set_rate_range()
2448 clk_core_rate_unprotect(clk->core); in clk_set_rate_range()
2451 old_min = clk->min_rate; in clk_set_rate_range()
2452 old_max = clk->max_rate; in clk_set_rate_range()
2453 clk->min_rate = min; in clk_set_rate_range()
2454 clk->max_rate = max; in clk_set_rate_range()
2456 if (!clk_core_check_boundaries(clk->core, min, max)) { in clk_set_rate_range()
2457 ret = -EINVAL; in clk_set_rate_range()
2461 rate = clk_core_get_rate_nolock(clk->core); in clk_set_rate_range()
2468 * usual reason (clock broken, clock protected, etc) but also in clk_set_rate_range()
2470 * - round_rate() was not favorable and fell on the wrong in clk_set_rate_range()
2472 * - the determine_rate() callback does not really check for in clk_set_rate_range()
2481 ret = clk_core_set_rate_nolock(clk->core, rate); in clk_set_rate_range()
2484 clk->min_rate = old_min; in clk_set_rate_range()
2485 clk->max_rate = old_max; in clk_set_rate_range()
2490 if (clk->exclusive_count) in clk_set_rate_range()
2491 clk_core_rate_protect(clk->core); in clk_set_rate_range()
2500 * clk_set_min_rate - set a minimum clock rate for a clock source
2501 * @clk: clock source
2502 * @rate: desired minimum clock rate in Hz, inclusive
2511 return clk_set_rate_range(clk, rate, clk->max_rate); in clk_set_min_rate()
2516 * clk_set_max_rate - set a maximum clock rate for a clock source
2517 * @clk: clock source
2518 * @rate: desired maximum clock rate in Hz, inclusive
2527 return clk_set_rate_range(clk, clk->min_rate, rate); in clk_set_max_rate()
2532 * clk_get_parent - return the parent of a clk
2535 * Simply returns clk->parent. Returns NULL if clk is NULL.
2545 /* TODO: Create a per-user clk and change callers to call clk_put */ in clk_get_parent()
2546 parent = !clk->core->parent ? NULL : clk->core->parent->hw->clk; in clk_get_parent()
2557 if (core->num_parents > 1 && core->ops->get_parent) in __clk_init_parent()
2558 index = core->ops->get_parent(core->hw); in __clk_init_parent()
2576 clk_core_reparent(hw->core, !new_parent ? NULL : new_parent->core); in clk_hw_reparent()
2580 * clk_has_parent - check if a clock is a possible parent for another
2581 * @clk: clock source
2582 * @parent: parent clock source
2584 * This function can be used in drivers that need to check that a clock can be
2598 core = clk->core; in clk_has_parent()
2599 parent_core = parent->core; in clk_has_parent()
2602 if (core->parent == parent_core) in clk_has_parent()
2605 for (i = 0; i < core->num_parents; i++) in clk_has_parent()
2606 if (!strcmp(core->parents[i].name, parent_core->name)) in clk_has_parent()
2625 if (core->parent == parent) in clk_core_set_parent_nolock()
2628 /* verify ops for multi-parent clks */ in clk_core_set_parent_nolock()
2629 if (core->num_parents > 1 && !core->ops->set_parent) in clk_core_set_parent_nolock()
2630 return -EPERM; in clk_core_set_parent_nolock()
2632 /* check that we are allowed to re-parent if the clock is in use */ in clk_core_set_parent_nolock()
2633 if ((core->flags & CLK_SET_PARENT_GATE) && core->prepare_count) in clk_core_set_parent_nolock()
2634 return -EBUSY; in clk_core_set_parent_nolock()
2637 return -EBUSY; in clk_core_set_parent_nolock()
2644 __func__, parent->name, core->name); in clk_core_set_parent_nolock()
2647 p_rate = parent->rate; in clk_core_set_parent_nolock()
2661 /* do the re-parent */ in clk_core_set_parent_nolock()
2664 /* propagate rate an accuracy recalculation accordingly */ in clk_core_set_parent_nolock()
2680 return clk_core_set_parent_nolock(hw->core, parent->core); in clk_hw_set_parent()
2685 * clk_set_parent - switch the parent of a mux clk
2689 * Re-parent clk to use parent as its new input source. If clk is in
2699 * Returns 0 on success, -EERROR otherwise.
2710 if (clk->exclusive_count) in clk_set_parent()
2711 clk_core_rate_unprotect(clk->core); in clk_set_parent()
2713 ret = clk_core_set_parent_nolock(clk->core, in clk_set_parent()
2714 parent ? parent->core : NULL); in clk_set_parent()
2716 if (clk->exclusive_count) in clk_set_parent()
2717 clk_core_rate_protect(clk->core); in clk_set_parent()
2727 int ret = -EINVAL; in clk_core_set_phase_nolock()
2735 return -EBUSY; in clk_core_set_phase_nolock()
2739 if (core->ops->set_phase) { in clk_core_set_phase_nolock()
2740 ret = core->ops->set_phase(core->hw, degrees); in clk_core_set_phase_nolock()
2742 core->phase = degrees; in clk_core_set_phase_nolock()
2751 * clk_set_phase - adjust the phase shift of a clock signal
2752 * @clk: clock signal source
2755 * Shifts the phase of a clock signal by the specified
2756 * degrees. Returns 0 on success, -EERROR otherwise.
2759 * signal that we adjust the clock signal phase against. For example
2760 * phase locked-loop clock signal generators we may shift phase with
2761 * respect to feedback clock signal input, but for other cases the
2762 * clock phase may be shifted with respect to some other, unspecified
2766 * the clock tree hierarchy, which sets it apart from clock rates and
2767 * clock accuracy. A parent clock phase attribute does not have an
2768 * impact on the phase attribute of a child clock.
2784 if (clk->exclusive_count) in clk_set_phase()
2785 clk_core_rate_unprotect(clk->core); in clk_set_phase()
2787 ret = clk_core_set_phase_nolock(clk->core, degrees); in clk_set_phase()
2789 if (clk->exclusive_count) in clk_set_phase()
2790 clk_core_rate_protect(clk->core); in clk_set_phase()
2803 if (!core->ops->get_phase) in clk_core_get_phase()
2807 ret = core->ops->get_phase(core->hw); in clk_core_get_phase()
2809 core->phase = ret; in clk_core_get_phase()
2815 * clk_get_phase - return the phase shift of a clock signal
2816 * @clk: clock signal source
2818 * Returns the phase shift of a clock node in degrees, otherwise returns
2819 * -EERROR.
2829 ret = clk_core_get_phase(clk->core); in clk_get_phase()
2839 core->duty.num = 1; in clk_core_reset_duty_cycle_nolock()
2840 core->duty.den = 2; in clk_core_reset_duty_cycle_nolock()
2847 struct clk_duty *duty = &core->duty; in clk_core_update_duty_cycle_nolock()
2850 if (!core->ops->get_duty_cycle) in clk_core_update_duty_cycle_nolock()
2853 ret = core->ops->get_duty_cycle(core->hw, duty); in clk_core_update_duty_cycle_nolock()
2857 /* Don't trust the clock provider too much */ in clk_core_update_duty_cycle_nolock()
2858 if (duty->den == 0 || duty->num > duty->den) { in clk_core_update_duty_cycle_nolock()
2859 ret = -EINVAL; in clk_core_update_duty_cycle_nolock()
2874 if (core->parent && in clk_core_update_duty_cycle_parent_nolock()
2875 core->flags & CLK_DUTY_CYCLE_PARENT) { in clk_core_update_duty_cycle_parent_nolock()
2876 ret = clk_core_update_duty_cycle_nolock(core->parent); in clk_core_update_duty_cycle_parent_nolock()
2877 memcpy(&core->duty, &core->parent->duty, sizeof(core->duty)); in clk_core_update_duty_cycle_parent_nolock()
2896 return -EBUSY; in clk_core_set_duty_cycle_nolock()
2900 if (!core->ops->set_duty_cycle) in clk_core_set_duty_cycle_nolock()
2903 ret = core->ops->set_duty_cycle(core->hw, duty); in clk_core_set_duty_cycle_nolock()
2905 memcpy(&core->duty, duty, sizeof(*duty)); in clk_core_set_duty_cycle_nolock()
2917 if (core->parent && in clk_core_set_duty_cycle_parent_nolock()
2918 core->flags & (CLK_DUTY_CYCLE_PARENT | CLK_SET_RATE_PARENT)) { in clk_core_set_duty_cycle_parent_nolock()
2919 ret = clk_core_set_duty_cycle_nolock(core->parent, duty); in clk_core_set_duty_cycle_parent_nolock()
2920 memcpy(&core->duty, &core->parent->duty, sizeof(core->duty)); in clk_core_set_duty_cycle_parent_nolock()
2927 * clk_set_duty_cycle - adjust the duty cycle ratio of a clock signal
2928 * @clk: clock signal source
2932 * Apply the duty cycle ratio if the ratio is valid and the clock can
2947 return -EINVAL; in clk_set_duty_cycle()
2954 if (clk->exclusive_count) in clk_set_duty_cycle()
2955 clk_core_rate_unprotect(clk->core); in clk_set_duty_cycle()
2957 ret = clk_core_set_duty_cycle_nolock(clk->core, &duty); in clk_set_duty_cycle()
2959 if (clk->exclusive_count) in clk_set_duty_cycle()
2960 clk_core_rate_protect(clk->core); in clk_set_duty_cycle()
2971 struct clk_duty *duty = &core->duty; in clk_core_get_scaled_duty_cycle()
2978 ret = mult_frac(scale, duty->num, duty->den); in clk_core_get_scaled_duty_cycle()
2986 * clk_get_scaled_duty_cycle - return the duty cycle ratio of a clock signal
2987 * @clk: clock signal source
2990 * Returns the duty cycle ratio of a clock node multiplied by the provided
2998 return clk_core_get_scaled_duty_cycle(clk->core, scale); in clk_get_scaled_duty_cycle()
3003 * clk_is_match - check if two clk's point to the same hardware clock
3008 * clock node. Put differently, returns true if struct clk *p and struct clk *q
3019 /* true if clk->core pointers match. Avoid dereferencing garbage */ in clk_is_match()
3021 if (p->core == q->core) in clk_is_match()
3048 seq_printf(s, "%*s%-*s %7d %8d %8d %11lu %10lu ", in clk_summary_show_one()
3050 30 - level * 3, c->name, in clk_summary_show_one()
3051 c->enable_count, c->prepare_count, c->protect_count, in clk_summary_show_one()
3059 seq_puts(s, "-----"); in clk_summary_show_one()
3071 hlist_for_each_entry(child, &c->children, child_node) in clk_summary_show_subtree()
3078 struct hlist_head **lists = (struct hlist_head **)s->private; in clk_summary_show()
3081 …seq_puts(s, " clock count count count rate accuracy phas… in clk_summary_show()
3082 …seq_puts(s, "-------------------------------------------------------------------------------------… in clk_summary_show()
3104 seq_printf(s, "\"%s\": { ", c->name); in clk_dump_one()
3105 seq_printf(s, "\"enable_count\": %d,", c->enable_count); in clk_dump_one()
3106 seq_printf(s, "\"prepare_count\": %d,", c->prepare_count); in clk_dump_one()
3107 seq_printf(s, "\"protect_count\": %d,", c->protect_count); in clk_dump_one()
3111 seq_printf(s, "\"accuracy\": %lu,", clk_core_get_accuracy_recalc(c)); in clk_dump_one()
3125 hlist_for_each_entry(child, &c->children, child_node) { in clk_dump_subtree()
3137 struct hlist_head **lists = (struct hlist_head **)s->private; in clk_dump_show()
3185 ret = clk_prepare_enable(core->hw->clk); in clk_prepare_enable_set()
3187 clk_disable_unprepare(core->hw->clk); in clk_prepare_enable_set()
3196 *val = core->enable_count && core->prepare_count; in clk_prepare_enable_get()
3212 *val = core->rate; in clk_rate_get()
3240 struct clk_core *core = s->private; in clk_flags_show()
3241 unsigned long flags = core->flags; in clk_flags_show()
3268 * 1. Fetch the registered parent clock and use its name in possible_parent_show()
3271 * 4. Fetch parent clock's clock-output-name if DT index was set in possible_parent_show()
3279 seq_puts(s, parent->name); in possible_parent_show()
3280 } else if (core->parents[i].name) { in possible_parent_show()
3281 seq_puts(s, core->parents[i].name); in possible_parent_show()
3282 } else if (core->parents[i].fw_name) { in possible_parent_show()
3283 seq_printf(s, "<%s>(fw)", core->parents[i].fw_name); in possible_parent_show()
3285 if (core->parents[i].index >= 0) in possible_parent_show()
3286 name = of_clk_get_parent_name(core->of_node, core->parents[i].index); in possible_parent_show()
3298 struct clk_core *core = s->private; in possible_parents_show()
3301 for (i = 0; i < core->num_parents - 1; i++) in possible_parents_show()
3312 struct clk_core *core = s->private; in current_parent_show()
3314 if (core->parent) in current_parent_show()
3315 seq_printf(s, "%s\n", core->parent->name); in current_parent_show()
3323 struct clk_core *core = s->private; in clk_duty_cycle_show()
3324 struct clk_duty *duty = &core->duty; in clk_duty_cycle_show()
3326 seq_printf(s, "%u/%u\n", duty->num, duty->den); in clk_duty_cycle_show()
3334 struct clk_core *core = s->private; in clk_min_rate_show()
3348 struct clk_core *core = s->private; in clk_max_rate_show()
3367 root = debugfs_create_dir(core->name, pdentry); in clk_debug_create_one()
3368 core->dentry = root; in clk_debug_create_one()
3374 debugfs_create_ulong("clk_accuracy", 0444, root, &core->accuracy); in clk_debug_create_one()
3375 debugfs_create_u32("clk_phase", 0444, root, &core->phase); in clk_debug_create_one()
3377 debugfs_create_u32("clk_prepare_count", 0444, root, &core->prepare_count); in clk_debug_create_one()
3378 debugfs_create_u32("clk_enable_count", 0444, root, &core->enable_count); in clk_debug_create_one()
3379 debugfs_create_u32("clk_protect_count", 0444, root, &core->protect_count); in clk_debug_create_one()
3380 debugfs_create_u32("clk_notifier_count", 0444, root, &core->notifier_count); in clk_debug_create_one()
3388 if (core->num_parents > 0) in clk_debug_create_one()
3392 if (core->num_parents > 1) in clk_debug_create_one()
3396 if (core->ops->debug_init) in clk_debug_create_one()
3397 core->ops->debug_init(core->hw, core->dentry); in clk_debug_create_one()
3401 * clk_debug_register - add a clk node to the debugfs clk directory
3411 hlist_add_head(&core->debug_node, &clk_debug_list); in clk_debug_register()
3418 * clk_debug_unregister - remove a clk node from the debugfs clk directory
3422 * debugfs clk directory if clk->dentry points to debugfs created by
3428 hlist_del_init(&core->debug_node); in clk_debug_unregister()
3429 debugfs_remove_recursive(core->dentry); in clk_debug_unregister()
3430 core->dentry = NULL; in clk_debug_unregister()
3435 * clk_debug_init - lazily populate the debugfs clk directory
3439 * populates the debugfs clk directory once at boot-time when we know that
3440 * debugfs is setup. It should only be called once at boot-time, all other clks
3508 * clock. This is important for CLK_IS_CRITICAL clocks, which in clk_core_reparent_orphans_nolock()
3520 * 0 if the clock doesn't have clk_ops::recalc_rate and in clk_core_reparent_orphans_nolock()
3526 * 'req_rate' is set to something non-zero so that in clk_core_reparent_orphans_nolock()
3529 orphan->req_rate = orphan->rate; in clk_core_reparent_orphans_nolock()
3535 * __clk_core_init - initialize the data structures in a struct clk_core
3549 return -EINVAL; in __clk_core_init()
3554 * Set hw->core after grabbing the prepare_lock to synchronize with in __clk_core_init()
3555 * callers of clk_core_fill_parent_index() where we treat hw->core in __clk_core_init()
3559 core->hw->core = core; in __clk_core_init()
3565 /* check to see if a clock with this name is already registered */ in __clk_core_init()
3566 if (clk_core_lookup(core->name)) { in __clk_core_init()
3568 __func__, core->name); in __clk_core_init()
3569 ret = -EEXIST; in __clk_core_init()
3573 /* check that clk_ops are sane. See Documentation/driver-api/clk.rst */ in __clk_core_init()
3574 if (core->ops->set_rate && in __clk_core_init()
3575 !((core->ops->round_rate || core->ops->determine_rate) && in __clk_core_init()
3576 core->ops->recalc_rate)) { in __clk_core_init()
3578 __func__, core->name); in __clk_core_init()
3579 ret = -EINVAL; in __clk_core_init()
3583 if (core->ops->set_parent && !core->ops->get_parent) { in __clk_core_init()
3585 __func__, core->name); in __clk_core_init()
3586 ret = -EINVAL; in __clk_core_init()
3590 if (core->num_parents > 1 && !core->ops->get_parent) { in __clk_core_init()
3592 __func__, core->name); in __clk_core_init()
3593 ret = -EINVAL; in __clk_core_init()
3597 if (core->ops->set_rate_and_parent && in __clk_core_init()
3598 !(core->ops->set_parent && core->ops->set_rate)) { in __clk_core_init()
3600 __func__, core->name); in __clk_core_init()
3601 ret = -EINVAL; in __clk_core_init()
3606 * optional platform-specific magic in __clk_core_init()
3608 * The .init callback is not used by any of the basic clock types, but in __clk_core_init()
3610 * CCF to get an accurate view of clock for any other callbacks. It may in __clk_core_init()
3617 * the clock in __clk_core_init()
3619 if (core->ops->init) { in __clk_core_init()
3620 ret = core->ops->init(core->hw); in __clk_core_init()
3625 parent = core->parent = __clk_init_parent(core); in __clk_core_init()
3628 * Populate core->parent if parent has already been clk_core_init'd. If in __clk_core_init()
3634 * clocks and re-parent any that are children of the clock currently in __clk_core_init()
3638 hlist_add_head(&core->child_node, &parent->children); in __clk_core_init()
3639 core->orphan = parent->orphan; in __clk_core_init()
3640 } else if (!core->num_parents) { in __clk_core_init()
3641 hlist_add_head(&core->child_node, &clk_root_list); in __clk_core_init()
3642 core->orphan = false; in __clk_core_init()
3644 hlist_add_head(&core->child_node, &clk_orphan_list); in __clk_core_init()
3645 core->orphan = true; in __clk_core_init()
3649 * Set clk's accuracy. The preferred method is to use in __clk_core_init()
3651 * fallback is to use the parent's accuracy. If a clock doesn't have a in __clk_core_init()
3652 * parent (or is orphaned) then accuracy is set to zero (perfect in __clk_core_init()
3653 * clock). in __clk_core_init()
3655 if (core->ops->recalc_accuracy) in __clk_core_init()
3656 core->accuracy = core->ops->recalc_accuracy(core->hw, in __clk_core_init()
3659 core->accuracy = parent->accuracy; in __clk_core_init()
3661 core->accuracy = 0; in __clk_core_init()
3666 * query the current clock phase, or just assume it's in phase. in __clk_core_init()
3672 core->name); in __clk_core_init()
3684 * parent's rate. If a clock doesn't have a parent (or is orphaned) in __clk_core_init()
3687 if (core->ops->recalc_rate) in __clk_core_init()
3688 rate = core->ops->recalc_rate(core->hw, in __clk_core_init()
3691 rate = parent->rate; in __clk_core_init()
3694 core->rate = core->req_rate = rate; in __clk_core_init()
3701 if (core->flags & CLK_IS_CRITICAL) { in __clk_core_init()
3707 __func__, core->name); in __clk_core_init()
3716 __func__, core->name); in __clk_core_init()
3727 hlist_del_init(&core->child_node); in __clk_core_init()
3728 core->hw->core = NULL; in __clk_core_init()
3740 * clk_core_link_consumer - Add a clk consumer to the list of consumers in a clk_core
3747 hlist_add_head(&clk->clks_node, &core->clks); in clk_core_link_consumer()
3752 * clk_core_unlink_consumer - Remove a clk consumer from the list of consumers in a clk_core
3758 hlist_del(&clk->clks_node); in clk_core_unlink_consumer()
3762 * alloc_clk - Allocate a clk consumer, but leave it unlinked to the clk_core
3776 return ERR_PTR(-ENOMEM); in alloc_clk()
3778 clk->core = core; in alloc_clk()
3779 clk->dev_id = dev_id; in alloc_clk()
3780 clk->con_id = kstrdup_const(con_id, GFP_KERNEL); in alloc_clk()
3781 clk->max_rate = ULONG_MAX; in alloc_clk()
3787 * free_clk - Free a clk consumer
3795 kfree_const(clk->con_id); in free_clk()
3821 core = hw->core; in clk_hw_create_clk()
3825 clk->dev = dev; in clk_hw_create_clk()
3827 if (!try_module_get(core->owner)) { in clk_hw_create_clk()
3829 return ERR_PTR(-ENOENT); in clk_hw_create_clk()
3832 kref_get(&core->ref); in clk_hw_create_clk()
3844 return -EINVAL; in clk_cpy_name()
3850 return -ENOMEM; in clk_cpy_name()
3858 u8 num_parents = init->num_parents; in clk_core_populate_parent_map()
3859 const char * const *parent_names = init->parent_names; in clk_core_populate_parent_map()
3860 const struct clk_hw **parent_hws = init->parent_hws; in clk_core_populate_parent_map()
3861 const struct clk_parent_data *parent_data = init->parent_data; in clk_core_populate_parent_map()
3869 * Avoid unnecessary string look-ups of clk_core's possible parents by in clk_core_populate_parent_map()
3873 core->parents = parents; in clk_core_populate_parent_map()
3875 return -ENOMEM; in clk_core_populate_parent_map()
3879 parent->index = -1; in clk_core_populate_parent_map()
3884 __func__, core->name); in clk_core_populate_parent_map()
3885 ret = clk_cpy_name(&parent->name, parent_names[i], in clk_core_populate_parent_map()
3888 parent->hw = parent_data[i].hw; in clk_core_populate_parent_map()
3889 parent->index = parent_data[i].index; in clk_core_populate_parent_map()
3890 ret = clk_cpy_name(&parent->fw_name, in clk_core_populate_parent_map()
3893 ret = clk_cpy_name(&parent->name, in clk_core_populate_parent_map()
3897 parent->hw = parent_hws[i]; in clk_core_populate_parent_map()
3899 ret = -EINVAL; in clk_core_populate_parent_map()
3907 } while (--i >= 0); in clk_core_populate_parent_map()
3919 int i = core->num_parents; in clk_core_free_parent_map()
3921 if (!core->num_parents) in clk_core_free_parent_map()
3924 while (--i >= 0) { in clk_core_free_parent_map()
3925 kfree_const(core->parents[i].name); in clk_core_free_parent_map()
3926 kfree_const(core->parents[i].fw_name); in clk_core_free_parent_map()
3929 kfree(core->parents); in clk_core_free_parent_map()
3937 if (core->rpm_enabled) { in __clk_release()
3939 hlist_del(&core->rpm_node); in __clk_release()
3944 kfree_const(core->name); in __clk_release()
3953 const struct clk_init_data *init = hw->init; in __clk_register()
3958 * we catch use of hw->init early on in the core. in __clk_register()
3960 hw->init = NULL; in __clk_register()
3964 ret = -ENOMEM; in __clk_register()
3968 kref_init(&core->ref); in __clk_register()
3970 core->name = kstrdup_const(init->name, GFP_KERNEL); in __clk_register()
3971 if (!core->name) { in __clk_register()
3972 ret = -ENOMEM; in __clk_register()
3976 if (WARN_ON(!init->ops)) { in __clk_register()
3977 ret = -EINVAL; in __clk_register()
3980 core->ops = init->ops; in __clk_register()
3982 core->dev = dev; in __clk_register()
3984 core->of_node = np; in __clk_register()
3985 if (dev && dev->driver) in __clk_register()
3986 core->owner = dev->driver->owner; in __clk_register()
3987 core->hw = hw; in __clk_register()
3988 core->flags = init->flags; in __clk_register()
3989 core->num_parents = init->num_parents; in __clk_register()
3990 core->min_rate = 0; in __clk_register()
3991 core->max_rate = ULONG_MAX; in __clk_register()
3997 INIT_HLIST_HEAD(&core->clks); in __clk_register()
4003 hw->clk = alloc_clk(core, NULL, NULL); in __clk_register()
4004 if (IS_ERR(hw->clk)) { in __clk_register()
4005 ret = PTR_ERR(hw->clk); in __clk_register()
4009 clk_core_link_consumer(core, hw->clk); in __clk_register()
4013 return hw->clk; in __clk_register()
4016 clk_core_unlink_consumer(hw->clk); in __clk_register()
4019 free_clk(hw->clk); in __clk_register()
4020 hw->clk = NULL; in __clk_register()
4026 kref_put(&core->ref, __clk_release); in __clk_register()
4032 * dev_or_parent_of_node() - Get device node of @dev or @dev's parent
4036 * @dev->parent if dev doesn't have a device node, or NULL if neither
4037 * @dev or @dev->parent have a device node.
4048 np = dev_of_node(dev->parent); in dev_or_parent_of_node()
4054 * clk_register - allocate a new clock, register it and return an opaque cookie
4055 * @dev: device that is registering this clock
4056 * @hw: link to hardware-specific clock data
4058 * clk_register is the *deprecated* interface for populating the clock tree with
4059 * new clock nodes. Use clk_hw_register() instead.
4063 * rest of the clock API. In the event of an error clk_register will return an
4073 * clk_hw_register - register a clk_hw and return an error code
4074 * @dev: device that is registering this clock
4075 * @hw: link to hardware-specific clock data
4077 * clk_hw_register is the primary interface for populating the clock tree with
4078 * new clock nodes. It returns an integer equal to zero indicating success or
4090 * of_clk_hw_register - register a clk_hw and return an error code
4091 * @node: device_node of device that is registering this clock
4092 * @hw: link to hardware-specific clock data
4094 * of_clk_hw_register() is the primary interface for populating the clock tree
4095 * with new clock nodes when a struct device is not available, but a struct
4108 * after clk_unregister() was called on a clock and until last clock
4113 return -ENXIO; in clk_nodrv_prepare_enable()
4124 return -ENXIO; in clk_nodrv_set_rate()
4129 return -ENXIO; in clk_nodrv_set_parent()
4147 for (i = 0; i < root->num_parents; i++) in clk_core_evict_parent_cache_subtree()
4148 if (root->parents[i].core == target) in clk_core_evict_parent_cache_subtree()
4149 root->parents[i].core = NULL; in clk_core_evict_parent_cache_subtree()
4151 hlist_for_each_entry(child, &root->children, child_node) in clk_core_evict_parent_cache_subtree()
4170 * clk_unregister - unregister a currently registered clock
4171 * @clk: clock to unregister
4181 clk_debug_unregister(clk->core); in clk_unregister()
4185 ops = clk->core->ops; in clk_unregister()
4187 pr_err("%s: unregistered clock: %s\n", __func__, in clk_unregister()
4188 clk->core->name); in clk_unregister()
4192 * Assign empty clock ops for consumers that might still hold in clk_unregister()
4193 * a reference to this clock. in clk_unregister()
4196 clk->core->ops = &clk_nodrv_ops; in clk_unregister()
4199 if (ops->terminate) in clk_unregister()
4200 ops->terminate(clk->core->hw); in clk_unregister()
4202 if (!hlist_empty(&clk->core->children)) { in clk_unregister()
4207 hlist_for_each_entry_safe(child, t, &clk->core->children, in clk_unregister()
4212 clk_core_evict_parent_cache(clk->core); in clk_unregister()
4214 hlist_del_init(&clk->core->child_node); in clk_unregister()
4216 if (clk->core->prepare_count) in clk_unregister()
4217 pr_warn("%s: unregistering prepared clock: %s\n", in clk_unregister()
4218 __func__, clk->core->name); in clk_unregister()
4220 if (clk->core->protect_count) in clk_unregister()
4221 pr_warn("%s: unregistering protected clock: %s\n", in clk_unregister()
4222 __func__, clk->core->name); in clk_unregister()
4224 kref_put(&clk->core->ref, __clk_release); in clk_unregister()
4232 * clk_hw_unregister - unregister a currently registered clk_hw
4233 * @hw: hardware-specific clock data to unregister
4237 clk_unregister(hw->clk); in clk_hw_unregister()
4252 * devm_clk_register - resource managed clk_register()
4253 * @dev: device that is registering this clock
4254 * @hw: link to hardware-specific clock data
4268 return ERR_PTR(-ENOMEM); in devm_clk_register()
4283 * devm_clk_hw_register - resource managed clk_hw_register()
4284 * @dev: device that is registering this clock
4285 * @hw: link to hardware-specific clock data
4298 return -ENOMEM; in devm_clk_hw_register()
4330 * devm_clk_unregister - resource managed clk_unregister()
4331 * @dev: device that is unregistering the clock data
4332 * @clk: clock to unregister
4334 * Deallocate a clock allocated with devm_clk_register(). Normally
4345 * devm_clk_hw_unregister - resource managed clk_hw_unregister()
4346 * @dev: device that is unregistering the hardware-specific clock data
4347 * @hw: link to hardware-specific clock data
4378 if (WARN_ON(clk->exclusive_count)) { in __clk_put()
4380 clk->core->protect_count -= (clk->exclusive_count - 1); in __clk_put()
4381 clk_core_rate_unprotect(clk->core); in __clk_put()
4382 clk->exclusive_count = 0; in __clk_put()
4385 hlist_del(&clk->clks_node); in __clk_put()
4386 if (clk->min_rate > clk->core->req_rate || in __clk_put()
4387 clk->max_rate < clk->core->req_rate) in __clk_put()
4388 clk_core_set_rate_nolock(clk->core, clk->core->req_rate); in __clk_put()
4390 owner = clk->core->owner; in __clk_put()
4391 kref_put(&clk->core->ref, __clk_release); in __clk_put()
4403 * clk_notifier_register - add a clk rate change notifier
4410 * re-enter into the clk framework by calling any top-level clk APIs;
4414 * clock rate is passed to the callback via struct clk_notifier_data.old_rate
4417 * clk_notifier_register() must be called from non-atomic context.
4418 * Returns -EINVAL if called with null arguments, -ENOMEM upon
4425 int ret = -ENOMEM; in clk_notifier_register()
4428 return -EINVAL; in clk_notifier_register()
4434 if (cn->clk == clk) in clk_notifier_register()
4442 cn->clk = clk; in clk_notifier_register()
4443 srcu_init_notifier_head(&cn->notifier_head); in clk_notifier_register()
4445 list_add(&cn->node, &clk_notifier_list); in clk_notifier_register()
4448 ret = srcu_notifier_chain_register(&cn->notifier_head, nb); in clk_notifier_register()
4450 clk->core->notifier_count++; in clk_notifier_register()
4460 * clk_notifier_unregister - remove a clk rate change notifier
4467 * Returns -EINVAL if called with null arguments; otherwise, passes
4473 int ret = -ENOENT; in clk_notifier_unregister()
4476 return -EINVAL; in clk_notifier_unregister()
4481 if (cn->clk == clk) { in clk_notifier_unregister()
4482 ret = srcu_notifier_chain_unregister(&cn->notifier_head, nb); in clk_notifier_unregister()
4484 clk->core->notifier_count--; in clk_notifier_unregister()
4487 if (!cn->notifier_head.head) { in clk_notifier_unregister()
4488 srcu_cleanup_notifier_head(&cn->notifier_head); in clk_notifier_unregister()
4489 list_del(&cn->node); in clk_notifier_unregister()
4511 * struct of_clk_provider - Clock provider registration structure
4512 * @link: Entry in global list of clock providers
4513 * @node: Pointer to device tree node of clock provider
4514 * @get: Get clock callback. Returns NULL or a struct clk for the
4515 * given clock specifier
4517 * struct clk_hw for the given clock specifier
4552 unsigned int idx = clkspec->args[0]; in of_clk_src_onecell_get()
4554 if (idx >= clk_data->clk_num) { in of_clk_src_onecell_get()
4555 pr_err("%s: invalid clock index %u\n", __func__, idx); in of_clk_src_onecell_get()
4556 return ERR_PTR(-EINVAL); in of_clk_src_onecell_get()
4559 return clk_data->clks[idx]; in of_clk_src_onecell_get()
4567 unsigned int idx = clkspec->args[0]; in of_clk_hw_onecell_get()
4569 if (idx >= hw_data->num) { in of_clk_hw_onecell_get()
4571 return ERR_PTR(-EINVAL); in of_clk_hw_onecell_get()
4574 return hw_data->hws[idx]; in of_clk_hw_onecell_get()
4579 * of_clk_add_provider() - Register a clock provider for a node
4580 * @np: Device node pointer associated with clock provider
4581 * @clk_src_get: callback for decoding clock
4596 return -ENOMEM; in of_clk_add_provider()
4598 cp->node = of_node_get(np); in of_clk_add_provider()
4599 cp->data = data; in of_clk_add_provider()
4600 cp->get = clk_src_get; in of_clk_add_provider()
4603 list_add(&cp->link, &of_clk_providers); in of_clk_add_provider()
4605 pr_debug("Added clock from %pOF\n", np); in of_clk_add_provider()
4618 * of_clk_add_hw_provider() - Register a clock provider for a node
4619 * @np: Device node pointer associated with clock provider
4633 return -ENOMEM; in of_clk_add_hw_provider()
4635 cp->node = of_node_get(np); in of_clk_add_hw_provider()
4636 cp->data = data; in of_clk_add_hw_provider()
4637 cp->get_hw = get; in of_clk_add_hw_provider()
4640 list_add(&cp->link, &of_clk_providers); in of_clk_add_hw_provider()
4660 * We allow a child device to use its parent device as the clock provider node
4661 * for cases like MFD sub-devices where the child device driver wants to use
4662 * devm_*() APIs but not list the device in DT as a sub-node.
4668 np = dev->of_node; in get_clk_provider_node()
4669 parent_np = dev->parent ? dev->parent->of_node : NULL; in get_clk_provider_node()
4671 if (!of_find_property(np, "#clock-cells", NULL)) in get_clk_provider_node()
4672 if (of_find_property(parent_np, "#clock-cells", NULL)) in get_clk_provider_node()
4679 * devm_of_clk_add_hw_provider() - Managed clk provider node registration
4680 * @dev: Device acting as the clock provider (used for DT node and lifetime)
4684 * Registers clock provider for given device's node. If the device has no DT
4685 * node or if the device node lacks of clock provider information (#clock-cells)
4687 * has the #clock-cells then it is used in registration. Provider is
4703 return -ENOMEM; in devm_of_clk_add_hw_provider()
4719 * of_clk_del_provider() - Remove a previously registered clock provider
4720 * @np: Device node pointer associated with clock provider
4728 if (cp->node == np) { in of_clk_del_provider()
4729 list_del(&cp->link); in of_clk_del_provider()
4730 of_node_put(cp->node); in of_clk_del_provider()
4750 * devm_of_clk_del_provider() - Remove clock provider registered using devm
4751 * @dev: Device to whose lifetime the clock provider was bound
4766 * of_parse_clkspec() - Parse a DT clock specifier for a given device node
4767 * @np: device node to parse clock specifier from
4768 * @index: index of phandle to parse clock out of. If index < 0, @name is used
4769 * @name: clock name to find and parse. If name is NULL, the index is used
4770 * @out_args: Result of parsing the clock specifier
4772 * Parses a device node's "clocks" and "clock-names" properties to find the
4773 * phandle and cells for the index or name that is desired. The resulting clock
4775 * parsing error. The @index argument is ignored if @name is non-NULL.
4779 * phandle1: clock-controller@1 {
4780 * #clock-cells = <2>;
4783 * phandle2: clock-controller@2 {
4784 * #clock-cells = <1>;
4787 * clock-consumer@3 {
4789 * clock-names = "name1", "name2";
4792 * To get a device_node for `clock-controller@2' node you may call this
4795 * of_parse_clkspec(clock-consumer@3, -1, "name2", &args);
4796 * of_parse_clkspec(clock-consumer@3, 1, NULL, &args);
4797 * of_parse_clkspec(clock-consumer@3, 1, "name2", &args);
4799 * Return: 0 upon successfully parsing the clock specifier. Otherwise, -ENOENT
4800 * if @name is NULL or -EINVAL if @name is non-NULL and it can't be found in
4801 * the "clock-names" property of @np.
4806 int ret = -ENOENT; in of_parse_clkspec()
4808 /* Walk up the tree of devices looking for a clock property that matches */ in of_parse_clkspec()
4812 * "clock-names" property. If it cannot be found, then index in of_parse_clkspec()
4814 * return -EINVAL. in of_parse_clkspec()
4817 index = of_property_match_string(np, "clock-names", name); in of_parse_clkspec()
4818 ret = of_parse_phandle_with_args(np, "clocks", "#clock-cells", in of_parse_clkspec()
4826 * No matching clock found on this node. If the parent node in of_parse_clkspec()
4827 * has a "clock-ranges" property, then we can try one of its in of_parse_clkspec()
4830 np = np->parent; in of_parse_clkspec()
4831 if (np && !of_get_property(np, "clock-ranges", NULL)) in of_parse_clkspec()
4845 if (provider->get_hw) in __of_clk_get_hw_from_provider()
4846 return provider->get_hw(clkspec, provider->data); in __of_clk_get_hw_from_provider()
4848 clk = provider->get(clkspec, provider->data); in __of_clk_get_hw_from_provider()
4858 struct clk_hw *hw = ERR_PTR(-EPROBE_DEFER); in of_clk_get_hw_from_clkspec()
4861 return ERR_PTR(-EINVAL); in of_clk_get_hw_from_clkspec()
4865 if (provider->node == clkspec->np) { in of_clk_get_hw_from_clkspec()
4877 * of_clk_get_from_provider() - Lookup a clock from a clock provider
4878 * @clkspec: pointer to a clock specifier data structure
4880 * This function looks up a struct clk from the registered list of clock
4881 * providers, an input is a clock specifier data structure as returned
4920 return __of_clk_get(np, index, np->full_name, NULL); in of_clk_get()
4925 * of_clk_get_by_name() - Parse and lookup a clock referenced by a device node
4926 * @np: pointer to clock consumer node
4927 * @name: name of consumer's clock input, or NULL for the first clock reference
4929 * This function parses the clocks and clock-names properties,
4930 * and uses them to look up the struct clk from the registered list of clock
4936 return ERR_PTR(-ENOENT); in of_clk_get_by_name()
4938 return __of_clk_get(np, 0, np->full_name, name); in of_clk_get_by_name()
4943 * of_clk_get_parent_count() - Count the number of clocks a device node has
4952 count = of_count_phandle_with_args(np, "clocks", "#clock-cells"); in of_clk_get_parent_count()
4971 rc = of_parse_phandle_with_args(np, "clocks", "#clock-cells", index, in of_clk_get_parent_name()
4980 * specified into an array offset for the clock-output-names property. in of_clk_get_parent_name()
4982 of_property_for_each_u32(clkspec.np, "clock-indices", prop, vp, pv) { in of_clk_get_parent_name()
4989 /* We went off the end of 'clock-indices' without finding it */ in of_clk_get_parent_name()
4993 if (of_property_read_string_index(clkspec.np, "clock-output-names", in of_clk_get_parent_name()
4997 * Best effort to get the name if the clock has been in of_clk_get_parent_name()
4998 * registered with the framework. If the clock isn't in of_clk_get_parent_name()
5000 * the clock as long as #clock-cells = 0. in of_clk_get_parent_name()
5005 clk_name = clkspec.np->name; in of_clk_get_parent_name()
5021 * of_clk_parent_fill() - Fill @parents with names of @np's parents and return
5023 * @np: Device node pointer associated with clock provider
5027 * Return: number of parents for the clock node.
5048 * This function looks for a parent clock. If there is one, then it
5049 * checks that the provider for this parent clock was initialized, in
5050 * this case the parent clock will be ready.
5067 if (PTR_ERR(clk) == -EPROBE_DEFER) in parent_ready()
5074 * previous parent are ready. If there is no clock in parent_ready()
5083 * of_clk_detect_critical() - set CLK_IS_CRITICAL flag from Device Tree
5084 * @np: Device node pointer associated with clock provider
5085 * @index: clock index
5086 * @flags: pointer to top-level framework flags
5088 * Detects if the clock-critical property exists and, if so, sets the
5092 * bindings, such as the one-clock-per-node style that are outdated.
5093 * Those bindings typically put all clock data into .dts and the Linux
5094 * driver has no clock data, thus making it impossible to set this flag
5108 return -EINVAL; in of_clk_detect_critical()
5110 of_property_for_each_u32(np, "clock-critical", prop, cur, idx) in of_clk_detect_critical()
5118 * of_clk_init() - Scan and init clock providers from the DT
5121 * This function scans the device tree for matching clock providers
5148 list_del(&clk_provider->node); in of_clk_init()
5149 of_node_put(clk_provider->np); in of_clk_init()
5156 parent->clk_init_cb = match->data; in of_clk_init()
5157 parent->np = of_node_get(np); in of_clk_init()
5158 list_add_tail(&parent->node, &clk_provider_list); in of_clk_init()
5165 if (force || parent_ready(clk_provider->np)) { in of_clk_init()
5168 of_node_set_flag(clk_provider->np, in of_clk_init()
5171 clk_provider->clk_init_cb(clk_provider->np); in of_clk_init()
5172 of_clk_set_defaults(clk_provider->np, true); in of_clk_init()
5174 list_del(&clk_provider->node); in of_clk_init()
5175 of_node_put(clk_provider->np); in of_clk_init()
5185 * in case the clock parent was not mandatory in of_clk_init()