• 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>
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()
257 * anything here. We can also assume this clock isn't enabled. in clk_core_is_enabled()
259 if ((core->flags & CLK_OPS_PARENT_ENABLE) && core->parent) in clk_core_is_enabled()
260 if (!clk_core_is_enabled(core->parent)) { in clk_core_is_enabled()
265 ret = core->ops->is_enabled(core->hw); in clk_core_is_enabled()
267 if (core->rpm_enabled) in clk_core_is_enabled()
268 pm_runtime_put(core->dev); in clk_core_is_enabled()
277 return !clk ? NULL : clk->core->name; in __clk_get_name()
283 return hw->core->name; in clk_hw_get_name()
289 return !clk ? NULL : clk->core->hw; in __clk_get_hw()
295 return hw->core->num_parents; in clk_hw_get_num_parents()
301 return hw->core->parent ? hw->core->parent->hw : NULL; in clk_hw_get_parent()
311 if (!strcmp(core->name, name)) in __clk_lookup_subtree()
314 hlist_for_each_entry(child, &core->children, child_node) { in __clk_lookup_subtree()
358 return -ENOENT; in of_parse_clkspec()
363 return ERR_PTR(-ENOENT); in of_clk_get_hw_from_clkspec()
368 * clk_core_get - Find the clk_core parent of a clk
375 * node's 'clock-names' property or as the 'con_id' matching the device's
379 * For example the following DT snippet would allow a clock registered by the
380 * clock-controller@c001 that has a clk_init_data::parent_data array
381 * with 'xtal' in the 'name' member to find the clock provided by the
382 * clock-controller@f00abcd without needing to get the globally unique name of
385 * parent: clock-controller@f00abcd {
387 * #clock-cells = <0>;
390 * clock-controller@c001 {
393 * clock-names = "xtal";
394 * #clock-cells = <1>;
397 * Returns: -ENOENT when the provider can't be found or the clk doesn't
405 const char *name = core->parents[p_index].fw_name; in clk_core_get()
406 int index = core->parents[p_index].index; in clk_core_get()
407 struct clk_hw *hw = ERR_PTR(-ENOENT); in clk_core_get()
408 struct device *dev = core->dev; in clk_core_get()
410 struct device_node *np = core->of_node; in clk_core_get()
428 return hw->core; in clk_core_get()
433 struct clk_parent_map *entry = &core->parents[index]; in clk_core_fill_parent_index()
434 struct clk_core *parent = ERR_PTR(-ENOENT); in clk_core_fill_parent_index()
436 if (entry->hw) { in clk_core_fill_parent_index()
437 parent = entry->hw->core; in clk_core_fill_parent_index()
444 parent = ERR_PTR(-EPROBE_DEFER); in clk_core_fill_parent_index()
447 if (PTR_ERR(parent) == -ENOENT && entry->name) in clk_core_fill_parent_index()
448 parent = clk_core_lookup(entry->name); in clk_core_fill_parent_index()
453 entry->core = parent; in clk_core_fill_parent_index()
459 if (!core || index >= core->num_parents || !core->parents) in clk_core_get_parent_by_index()
462 if (!core->parents[index].core) in clk_core_get_parent_by_index()
465 return core->parents[index].core; in clk_core_get_parent_by_index()
473 parent = clk_core_get_parent_by_index(hw->core, index); in clk_hw_get_parent_by_index()
475 return !parent ? NULL : parent->hw; in clk_hw_get_parent_by_index()
481 return !clk ? 0 : clk->core->enable_count; in __clk_get_enable_count()
489 if (!core->num_parents || core->parent) in clk_core_get_rate_nolock()
490 return core->rate; in clk_core_get_rate_nolock()
502 return clk_core_get_rate_nolock(hw->core); in clk_hw_get_rate()
511 return core->accuracy; in clk_core_get_accuracy_no_lock()
516 return hw->core->flags; in clk_hw_get_flags()
522 return clk_core_is_prepared(hw->core); in clk_hw_is_prepared()
528 return clk_core_rate_is_protected(hw->core); in clk_hw_rate_is_protected()
534 return clk_core_is_enabled(hw->core); in clk_hw_is_enabled()
543 return clk_core_is_enabled(clk->core); in __clk_is_enabled()
551 return abs(now - rate) < abs(best - rate); in mux_is_better_rate()
560 struct clk_core *core = hw->core, *parent, *best_parent = NULL; in clk_mux_determine_rate_flags()
566 if (core->flags & CLK_SET_RATE_NO_REPARENT) { in clk_mux_determine_rate_flags()
567 parent = core->parent; in clk_mux_determine_rate_flags()
568 if (core->flags & CLK_SET_RATE_PARENT) { in clk_mux_determine_rate_flags()
569 ret = __clk_determine_rate(parent ? parent->hw : NULL, in clk_mux_determine_rate_flags()
585 num_parents = core->num_parents; in clk_mux_determine_rate_flags()
591 if (core->flags & CLK_SET_RATE_PARENT) { in clk_mux_determine_rate_flags()
593 ret = __clk_determine_rate(parent->hw, &parent_req); in clk_mux_determine_rate_flags()
600 if (mux_is_better_rate(req->rate, parent_req.rate, in clk_mux_determine_rate_flags()
608 return -EINVAL; in clk_mux_determine_rate_flags()
612 req->best_parent_hw = best_parent->hw; in clk_mux_determine_rate_flags()
613 req->best_parent_rate = best; in clk_mux_determine_rate_flags()
614 req->rate = best; in clk_mux_determine_rate_flags()
624 return !core ? NULL : core->hw->clk; in __clk_lookup()
635 *min_rate = core->min_rate; in clk_core_get_boundaries()
636 *max_rate = core->max_rate; in clk_core_get_boundaries()
638 hlist_for_each_entry(clk_user, &core->clks, clks_node) in clk_core_get_boundaries()
639 *min_rate = max(*min_rate, clk_user->min_rate); in clk_core_get_boundaries()
641 hlist_for_each_entry(clk_user, &core->clks, clks_node) in clk_core_get_boundaries()
642 *max_rate = min(*max_rate, clk_user->max_rate); in clk_core_get_boundaries()
653 if (min_rate > core->max_rate || max_rate < core->min_rate) in clk_core_check_boundaries()
656 hlist_for_each_entry(user, &core->clks, clks_node) in clk_core_check_boundaries()
657 if (min_rate > user->max_rate || max_rate < user->min_rate) in clk_core_check_boundaries()
666 hw->core->min_rate = min_rate; in clk_hw_set_rate_range()
667 hw->core->max_rate = max_rate; in clk_hw_set_rate_range()
672 * __clk_mux_determine_rate - clk_ops::determine_rate implementation for a mux type clk
678 * complex clock that may combine a mux with other operations.
680 * Returns: 0 on success, -EERROR value on error
705 if (WARN(core->protect_count == 0, in clk_core_rate_unprotect()
706 "%s already unprotected\n", core->name)) in clk_core_rate_unprotect()
709 if (--core->protect_count > 0) in clk_core_rate_unprotect()
712 clk_core_rate_unprotect(core->parent); in clk_core_rate_unprotect()
722 return -EINVAL; in clk_core_rate_nuke_protect()
724 if (core->protect_count == 0) in clk_core_rate_nuke_protect()
727 ret = core->protect_count; in clk_core_rate_nuke_protect()
728 core->protect_count = 1; in clk_core_rate_nuke_protect()
735 * clk_rate_exclusive_put - release exclusivity over clock rate control
738 * clk_rate_exclusive_put() completes a critical section during which a clock
740 * clock which could result in a rate change or rate glitch. Exclusive clocks
745 * If exlusivity is claimed more than once on clock, even by the same consumer,
763 if (WARN_ON(clk->exclusive_count <= 0)) in clk_rate_exclusive_put()
766 clk_core_rate_unprotect(clk->core); in clk_rate_exclusive_put()
767 clk->exclusive_count--; in clk_rate_exclusive_put()
780 if (core->protect_count == 0) in clk_core_rate_protect()
781 clk_core_rate_protect(core->parent); in clk_core_rate_protect()
783 core->protect_count++; in clk_core_rate_protect()
797 core->protect_count = count; in clk_core_rate_restore_protect()
801 * clk_rate_exclusive_get - get exclusivity over the clk rate control
804 * clk_rate_exclusive_get() begins a critical section during which a clock
806 * clock which could result in a rate change or rate glitch. Exclusive clocks
811 * If exlusivity is claimed more than once on clock, even by the same consumer,
816 * Returns 0 on success, -EERROR otherwise
824 clk_core_rate_protect(clk->core); in clk_rate_exclusive_get()
825 clk->exclusive_count++; in clk_rate_exclusive_get()
839 if (WARN(core->prepare_count == 0, in clk_core_unprepare()
840 "%s already unprepared\n", core->name)) in clk_core_unprepare()
843 if (WARN(core->prepare_count == 1 && core->flags & CLK_IS_CRITICAL, in clk_core_unprepare()
844 "Unpreparing critical %s\n", core->name)) in clk_core_unprepare()
847 if (core->flags & CLK_SET_RATE_GATE) in clk_core_unprepare()
850 if (--core->prepare_count > 0) in clk_core_unprepare()
853 WARN(core->enable_count > 0, "Unpreparing enabled %s\n", core->name); in clk_core_unprepare()
857 if (core->ops->unprepare) in clk_core_unprepare()
858 core->ops->unprepare(core->hw); in clk_core_unprepare()
861 clk_core_unprepare(core->parent); in clk_core_unprepare()
873 * clk_unprepare - undo preparation of a clock source
888 clk_core_unprepare_lock(clk->core); in clk_unprepare()
901 if (core->prepare_count == 0) { in clk_core_prepare()
906 ret = clk_core_prepare(core->parent); in clk_core_prepare()
912 if (core->ops->prepare) in clk_core_prepare()
913 ret = core->ops->prepare(core->hw); in clk_core_prepare()
921 core->prepare_count++; in clk_core_prepare()
924 * CLK_SET_RATE_GATE is a special case of clock protection in clk_core_prepare()
928 * the clock is prepared. in clk_core_prepare()
930 if (core->flags & CLK_SET_RATE_GATE) in clk_core_prepare()
935 clk_core_unprepare(core->parent); in clk_core_prepare()
953 * clk_prepare - prepare a clock source
962 * Returns 0 on success, -EERROR otherwise.
969 return clk_core_prepare_lock(clk->core); in clk_prepare()
980 if (WARN(core->enable_count == 0, "%s already disabled\n", core->name)) in clk_core_disable()
983 if (WARN(core->enable_count == 1 && core->flags & CLK_IS_CRITICAL, in clk_core_disable()
984 "Disabling critical %s\n", core->name)) in clk_core_disable()
987 if (--core->enable_count > 0) in clk_core_disable()
992 if (core->ops->disable) in clk_core_disable()
993 core->ops->disable(core->hw); in clk_core_disable()
997 clk_core_disable(core->parent); in clk_core_disable()
1010 * clk_disable - gate a clock
1016 * SoC-internal clk which is controlled via simple register writes. In the
1026 clk_core_disable_lock(clk->core); in clk_disable()
1039 if (WARN(core->prepare_count == 0, in clk_core_enable()
1040 "Enabling unprepared %s\n", core->name)) in clk_core_enable()
1041 return -ESHUTDOWN; in clk_core_enable()
1043 if (core->enable_count == 0) { in clk_core_enable()
1044 ret = clk_core_enable(core->parent); in clk_core_enable()
1051 if (core->ops->enable) in clk_core_enable()
1052 ret = core->ops->enable(core->hw); in clk_core_enable()
1057 clk_core_disable(core->parent); in clk_core_enable()
1062 core->enable_count++; in clk_core_enable()
1079 * clk_gate_restore_context - restore context for poweroff
1080 * @hw: the clk_hw pointer of clock whose state is to be restored
1082 * The clock gate restore context function enables or disables
1084 * where the clock context is lost and based on the enable_count
1085 * the clock either needs to be enabled/disabled. This
1090 struct clk_core *core = hw->core; in clk_gate_restore_context()
1092 if (core->enable_count) in clk_gate_restore_context()
1093 core->ops->enable(hw); in clk_gate_restore_context()
1095 core->ops->disable(hw); in clk_gate_restore_context()
1104 hlist_for_each_entry(child, &core->children, child_node) { in clk_core_save_context()
1110 if (core->ops && core->ops->save_context) in clk_core_save_context()
1111 ret = core->ops->save_context(core->hw); in clk_core_save_context()
1120 if (core->ops && core->ops->restore_context) in clk_core_restore_context()
1121 core->ops->restore_context(core->hw); in clk_core_restore_context()
1123 hlist_for_each_entry(child, &core->children, child_node) in clk_core_restore_context()
1128 * clk_save_context - save clock context for poweroff
1130 * Saves the context of the clock register for powerstates in which the
1156 * clk_restore_context - restore clock context after poweroff
1158 * Restore the saved clock context upon resume.
1174 * clk_enable - ungate a clock
1179 * if the operation will never sleep. One example is a SoC-internal clk which
1183 * must be called before clk_enable. Returns 0 on success, -EERROR
1191 return clk_core_enable_lock(clk->core); in clk_enable()
1222 hlist_for_each_entry(child, &core->children, child_node) in clk_unprepare_unused_subtree()
1225 if (core->prepare_count) in clk_unprepare_unused_subtree()
1228 if (core->flags & CLK_IGNORE_UNUSED) in clk_unprepare_unused_subtree()
1236 if (core->ops->unprepare_unused) in clk_unprepare_unused_subtree()
1237 core->ops->unprepare_unused(core->hw); in clk_unprepare_unused_subtree()
1238 else if (core->ops->unprepare) in clk_unprepare_unused_subtree()
1239 core->ops->unprepare(core->hw); in clk_unprepare_unused_subtree()
1253 hlist_for_each_entry(child, &core->children, child_node) in clk_disable_unused_subtree()
1256 if (core->flags & CLK_OPS_PARENT_ENABLE) in clk_disable_unused_subtree()
1257 clk_core_prepare_enable(core->parent); in clk_disable_unused_subtree()
1264 if (core->enable_count) in clk_disable_unused_subtree()
1267 if (core->flags & CLK_IGNORE_UNUSED) in clk_disable_unused_subtree()
1271 * some gate clocks have special needs during the disable-unused in clk_disable_unused_subtree()
1277 if (core->ops->disable_unused) in clk_disable_unused_subtree()
1278 core->ops->disable_unused(core->hw); in clk_disable_unused_subtree()
1279 else if (core->ops->disable) in clk_disable_unused_subtree()
1280 core->ops->disable(core->hw); in clk_disable_unused_subtree()
1288 if (core->flags & CLK_OPS_PARENT_ENABLE) in clk_disable_unused_subtree()
1289 clk_core_disable_unprepare(core->parent); in clk_disable_unused_subtree()
1341 * - if the provider is not protected at all in clk_core_determine_round_nolock()
1342 * - if the calling consumer is the only one which has exclusivity in clk_core_determine_round_nolock()
1346 req->rate = core->rate; in clk_core_determine_round_nolock()
1347 } else if (core->ops->determine_rate) { in clk_core_determine_round_nolock()
1348 return core->ops->determine_rate(core->hw, req); in clk_core_determine_round_nolock()
1349 } else if (core->ops->round_rate) { in clk_core_determine_round_nolock()
1350 rate = core->ops->round_rate(core->hw, req->rate, in clk_core_determine_round_nolock()
1351 &req->best_parent_rate); in clk_core_determine_round_nolock()
1355 req->rate = rate; in clk_core_determine_round_nolock()
1357 return -EINVAL; in clk_core_determine_round_nolock()
1371 parent = core->parent; in clk_core_init_rate_req()
1373 req->best_parent_hw = parent->hw; in clk_core_init_rate_req()
1374 req->best_parent_rate = parent->rate; in clk_core_init_rate_req()
1376 req->best_parent_hw = NULL; in clk_core_init_rate_req()
1377 req->best_parent_rate = 0; in clk_core_init_rate_req()
1383 return core->ops->determine_rate || core->ops->round_rate; in clk_core_can_round()
1392 req->rate = 0; in clk_core_round_rate_nolock()
1400 else if (core->flags & CLK_SET_RATE_PARENT) in clk_core_round_rate_nolock()
1401 return clk_core_round_rate_nolock(core->parent, req); in clk_core_round_rate_nolock()
1403 req->rate = core->rate; in clk_core_round_rate_nolock()
1408 * __clk_determine_rate - get the closest rate actually supported by a clock
1409 * @hw: determine the rate of this clock
1417 req->rate = 0; in __clk_determine_rate()
1421 return clk_core_round_rate_nolock(hw->core, req); in __clk_determine_rate()
1426 * clk_hw_round_rate() - round the given rate for a hw clk
1445 clk_core_get_boundaries(hw->core, &req.min_rate, &req.max_rate); in clk_hw_round_rate()
1448 ret = clk_core_round_rate_nolock(hw->core, &req); in clk_hw_round_rate()
1457 * clk_round_rate - round the given rate for a clk
1475 if (clk->exclusive_count) in clk_round_rate()
1476 clk_core_rate_unprotect(clk->core); in clk_round_rate()
1478 clk_core_get_boundaries(clk->core, &req.min_rate, &req.max_rate); in clk_round_rate()
1481 ret = clk_core_round_rate_nolock(clk->core, &req); in clk_round_rate()
1483 if (clk->exclusive_count) in clk_round_rate()
1484 clk_core_rate_protect(clk->core); in clk_round_rate()
1496 * __clk_notify - call clk notifier chain
1502 * Triggers a notifier call chain on the clk rate-change notification
1505 * internal clock code only. Returns NOTIFY_DONE from the last driver
1520 if (cn->clk->core == core) { in __clk_notify()
1521 cnd.clk = cn->clk; in __clk_notify()
1522 ret = srcu_notifier_call_chain(&cn->notifier_head, msg, in __clk_notify()
1538 * callback then it is assumed that the clock will take on the accuracy of its
1548 if (core->parent) in __clk_recalc_accuracies()
1549 parent_accuracy = core->parent->accuracy; in __clk_recalc_accuracies()
1551 if (core->ops->recalc_accuracy) in __clk_recalc_accuracies()
1552 core->accuracy = core->ops->recalc_accuracy(core->hw, in __clk_recalc_accuracies()
1555 core->accuracy = parent_accuracy; in __clk_recalc_accuracies()
1557 hlist_for_each_entry(child, &core->children, child_node) in __clk_recalc_accuracies()
1563 if (core && (core->flags & CLK_GET_ACCURACY_NOCACHE)) in clk_core_get_accuracy_recalc()
1570 * clk_get_accuracy - return the accuracy of clk
1571 * @clk: the clk whose accuracy is being returned
1573 * Simply returns the cached accuracy of the clk, unless
1580 long accuracy; in clk_get_accuracy() local
1586 accuracy = clk_core_get_accuracy_recalc(clk->core); in clk_get_accuracy()
1589 return accuracy; in clk_get_accuracy()
1598 if (core->ops->recalc_rate && !clk_pm_runtime_get(core)) { in clk_recalc()
1599 rate = core->ops->recalc_rate(core->hw, parent_rate); in clk_recalc()
1612 * it is assumed that the clock will take on the rate of its parent.
1625 old_rate = core->rate; in __clk_recalc_rates()
1627 if (core->parent) in __clk_recalc_rates()
1628 parent_rate = core->parent->rate; in __clk_recalc_rates()
1630 core->rate = clk_recalc(core, parent_rate); in __clk_recalc_rates()
1636 if (core->notifier_count && msg) in __clk_recalc_rates()
1637 __clk_notify(core, msg, old_rate, core->rate); in __clk_recalc_rates()
1639 hlist_for_each_entry(child, &core->children, child_node) in __clk_recalc_rates()
1645 if (core && (core->flags & CLK_GET_RATE_NOCACHE)) in clk_core_get_rate_recalc()
1652 * clk_get_rate - return the rate of clk
1667 rate = clk_core_get_rate_recalc(clk->core); in clk_get_rate()
1680 return -EINVAL; in clk_fetch_parent_index()
1682 for (i = 0; i < core->num_parents; i++) { in clk_fetch_parent_index()
1684 if (core->parents[i].core == parent) in clk_fetch_parent_index()
1688 if (core->parents[i].core) in clk_fetch_parent_index()
1692 if (core->parents[i].hw) { in clk_fetch_parent_index()
1693 if (core->parents[i].hw == parent->hw) in clk_fetch_parent_index()
1705 if (core->parents[i].name && in clk_fetch_parent_index()
1706 !strcmp(parent->name, core->parents[i].name)) in clk_fetch_parent_index()
1710 if (i == core->num_parents) in clk_fetch_parent_index()
1711 return -EINVAL; in clk_fetch_parent_index()
1713 core->parents[i].core = parent; in clk_fetch_parent_index()
1718 * clk_hw_get_parent_index - return the index of the parent clock
1721 * Fetches and returns the index of parent clock. Returns -EINVAL if the given
1722 * clock does not have a current parent.
1729 return -EINVAL; in clk_hw_get_parent_index()
1731 return clk_fetch_parent_index(hw->core, parent->core); in clk_hw_get_parent_index()
1742 core->orphan = is_orphan; in clk_core_update_orphan_status()
1744 hlist_for_each_entry(child, &core->children, child_node) in clk_core_update_orphan_status()
1750 bool was_orphan = core->orphan; in clk_reparent()
1752 hlist_del(&core->child_node); in clk_reparent()
1755 bool becomes_orphan = new_parent->orphan; in clk_reparent()
1758 if (new_parent->new_child == core) in clk_reparent()
1759 new_parent->new_child = NULL; in clk_reparent()
1761 hlist_add_head(&core->child_node, &new_parent->children); in clk_reparent()
1766 hlist_add_head(&core->child_node, &clk_orphan_list); in clk_reparent()
1771 core->parent = new_parent; in clk_reparent()
1778 struct clk_core *old_parent = core->parent; in __clk_set_parent_before()
1781 * 1. enable parents for CLK_OPS_PARENT_ENABLE clock in __clk_set_parent_before()
1786 * If the clock is not prepared, then a race with in __clk_set_parent_before()
1791 * If the clock is prepared, migrate the prepared state to the new in __clk_set_parent_before()
1793 * forcing the clock and the new parent on. This ensures that all in __clk_set_parent_before()
1801 if (core->flags & CLK_OPS_PARENT_ENABLE) { in __clk_set_parent_before()
1807 if (core->prepare_count) { in __clk_set_parent_before()
1828 if (core->prepare_count) { in __clk_set_parent_after()
1833 /* re-balance ref counting if CLK_OPS_PARENT_ENABLE is set */ in __clk_set_parent_after()
1834 if (core->flags & CLK_OPS_PARENT_ENABLE) { in __clk_set_parent_after()
1851 /* change clock input source */ in __clk_set_parent()
1852 if (parent && core->ops->set_parent) in __clk_set_parent()
1853 ret = core->ops->set_parent(core->hw, p_index); in __clk_set_parent()
1880 * pre-rate change notifications and returns early if no clks in the
1882 * implement the .recalc_rate callback then it is assumed that the clock will
1897 if (core->notifier_count) in __clk_speculate_rates()
1898 ret = __clk_notify(core, PRE_RATE_CHANGE, core->rate, new_rate); in __clk_speculate_rates()
1901 pr_debug("%s: clk notifier callback for clock %s aborted with error %d\n", in __clk_speculate_rates()
1902 __func__, core->name, ret); in __clk_speculate_rates()
1906 hlist_for_each_entry(child, &core->children, child_node) { in __clk_speculate_rates()
1921 core->new_rate = new_rate; in clk_calc_subtree()
1922 core->new_parent = new_parent; in clk_calc_subtree()
1923 core->new_parent_index = p_index; in clk_calc_subtree()
1925 core->new_child = NULL; in clk_calc_subtree()
1926 if (new_parent && new_parent != core->parent) in clk_calc_subtree()
1927 new_parent->new_child = core; in clk_calc_subtree()
1929 hlist_for_each_entry(child, &core->children, child_node) { in clk_calc_subtree()
1930 child->new_rate = clk_recalc(child, new_rate); in clk_calc_subtree()
1931 clk_calc_subtree(child, child->new_rate, NULL, 0); in clk_calc_subtree()
1936 * calculate the new rates returning the topmost clock that has to be
1956 parent = old_parent = core->parent; in clk_calc_new_rates()
1958 best_parent_rate = parent->rate; in clk_calc_new_rates()
1978 parent = req.best_parent_hw ? req.best_parent_hw->core : NULL; in clk_calc_new_rates()
1982 } else if (!parent || !(core->flags & CLK_SET_RATE_PARENT)) { in clk_calc_new_rates()
1983 /* pass-through clock without adjustable parent */ in clk_calc_new_rates()
1984 core->new_rate = core->rate; in clk_calc_new_rates()
1987 /* pass-through clock with adjustable parent */ in clk_calc_new_rates()
1989 new_rate = parent->new_rate; in clk_calc_new_rates()
1995 (core->flags & CLK_SET_PARENT_GATE) && core->prepare_count) { in clk_calc_new_rates()
1997 __func__, core->name); in clk_calc_new_rates()
2002 if (parent && core->num_parents > 1) { in clk_calc_new_rates()
2006 __func__, parent->name, core->name); in clk_calc_new_rates()
2011 if ((core->flags & CLK_SET_RATE_PARENT) && parent && in clk_calc_new_rates()
2012 best_parent_rate != parent->rate) in clk_calc_new_rates()
2032 if (core->rate == core->new_rate) in clk_propagate_rate_change()
2035 if (core->notifier_count) { in clk_propagate_rate_change()
2036 ret = __clk_notify(core, event, core->rate, core->new_rate); in clk_propagate_rate_change()
2041 hlist_for_each_entry(child, &core->children, child_node) { in clk_propagate_rate_change()
2042 /* Skip children who will be reparented to another clock */ in clk_propagate_rate_change()
2043 if (child->new_parent && child->new_parent != core) in clk_propagate_rate_change()
2050 /* handle the new child who might not be in core->children yet */ in clk_propagate_rate_change()
2051 if (core->new_child) { in clk_propagate_rate_change()
2052 tmp_clk = clk_propagate_rate_change(core->new_child, event); in clk_propagate_rate_change()
2074 old_rate = core->rate; in clk_change_rate()
2076 if (core->new_parent) { in clk_change_rate()
2077 parent = core->new_parent; in clk_change_rate()
2078 best_parent_rate = core->new_parent->rate; in clk_change_rate()
2079 } else if (core->parent) { in clk_change_rate()
2080 parent = core->parent; in clk_change_rate()
2081 best_parent_rate = core->parent->rate; in clk_change_rate()
2087 if (core->flags & CLK_SET_RATE_UNGATE) { in clk_change_rate()
2096 if (core->new_parent && core->new_parent != core->parent) { in clk_change_rate()
2097 old_parent = __clk_set_parent_before(core, core->new_parent); in clk_change_rate()
2098 trace_clk_set_parent(core, core->new_parent); in clk_change_rate()
2100 if (core->ops->set_rate_and_parent) { in clk_change_rate()
2102 core->ops->set_rate_and_parent(core->hw, core->new_rate, in clk_change_rate()
2104 core->new_parent_index); in clk_change_rate()
2105 } else if (core->ops->set_parent) { in clk_change_rate()
2106 core->ops->set_parent(core->hw, core->new_parent_index); in clk_change_rate()
2109 trace_clk_set_parent_complete(core, core->new_parent); in clk_change_rate()
2110 __clk_set_parent_after(core, core->new_parent, old_parent); in clk_change_rate()
2113 if (core->flags & CLK_OPS_PARENT_ENABLE) in clk_change_rate()
2116 trace_clk_set_rate(core, core->new_rate); in clk_change_rate()
2118 if (!skip_set_rate && core->ops->set_rate) in clk_change_rate()
2119 core->ops->set_rate(core->hw, core->new_rate, best_parent_rate); in clk_change_rate()
2121 trace_clk_set_rate_complete(core, core->new_rate); in clk_change_rate()
2123 core->rate = clk_recalc(core, best_parent_rate); in clk_change_rate()
2125 if (core->flags & CLK_SET_RATE_UNGATE) { in clk_change_rate()
2134 if (core->flags & CLK_OPS_PARENT_ENABLE) in clk_change_rate()
2137 if (core->notifier_count && old_rate != core->rate) in clk_change_rate()
2138 __clk_notify(core, POST_RATE_CHANGE, old_rate, core->rate); in clk_change_rate()
2140 if (core->flags & CLK_RECALC_NEW_RATES) in clk_change_rate()
2141 (void)clk_calc_new_rates(core, core->new_rate); in clk_change_rate()
2145 * for certain clock types. in clk_change_rate()
2147 hlist_for_each_entry_safe(child, tmp, &core->children, child_node) { in clk_change_rate()
2148 /* Skip children who will be reparented to another clock */ in clk_change_rate()
2149 if (child->new_parent && child->new_parent != core) in clk_change_rate()
2154 /* handle the new child who might not be in core->children yet */ in clk_change_rate()
2155 if (core->new_child) in clk_change_rate()
2156 clk_change_rate(core->new_child); in clk_change_rate()
2206 return -EBUSY; in clk_core_set_rate_nolock()
2208 /* calculate new rates and get the topmost changed clock */ in clk_core_set_rate_nolock()
2211 return -EINVAL; in clk_core_set_rate_nolock()
2221 fail_clk->name); in clk_core_set_rate_nolock()
2223 ret = -EBUSY; in clk_core_set_rate_nolock()
2230 core->req_rate = req_rate; in clk_core_set_rate_nolock()
2238 * clk_set_rate - specify a new rate for clk
2256 * Returns 0 on success, -EERROR otherwise.
2265 /* prevent racing with updates to the clock topology */ in clk_set_rate()
2268 if (clk->exclusive_count) in clk_set_rate()
2269 clk_core_rate_unprotect(clk->core); in clk_set_rate()
2271 ret = clk_core_set_rate_nolock(clk->core, rate); in clk_set_rate()
2273 if (clk->exclusive_count) in clk_set_rate()
2274 clk_core_rate_protect(clk->core); in clk_set_rate()
2283 * clk_set_rate_exclusive - specify a new rate and get exclusive control
2292 * same clock provider.
2299 * Returns 0 on success, -EERROR otherwise.
2308 /* prevent racing with updates to the clock topology */ in clk_set_rate_exclusive()
2314 * so before the consumer code path protect the clock provider in clk_set_rate_exclusive()
2317 ret = clk_core_set_rate_nolock(clk->core, rate); in clk_set_rate_exclusive()
2319 clk_core_rate_protect(clk->core); in clk_set_rate_exclusive()
2320 clk->exclusive_count++; in clk_set_rate_exclusive()
2330 * clk_set_rate_range - set a rate range for a clock source
2331 * @clk: clock source
2332 * @min: desired minimum clock rate in Hz, inclusive
2333 * @max: desired maximum clock rate in Hz, inclusive
2347 __func__, clk->core->name, clk->dev_id, clk->con_id, in clk_set_rate_range()
2349 return -EINVAL; in clk_set_rate_range()
2354 if (clk->exclusive_count) in clk_set_rate_range()
2355 clk_core_rate_unprotect(clk->core); in clk_set_rate_range()
2358 old_min = clk->min_rate; in clk_set_rate_range()
2359 old_max = clk->max_rate; in clk_set_rate_range()
2360 clk->min_rate = min; in clk_set_rate_range()
2361 clk->max_rate = max; in clk_set_rate_range()
2363 if (!clk_core_check_boundaries(clk->core, min, max)) { in clk_set_rate_range()
2364 ret = -EINVAL; in clk_set_rate_range()
2368 rate = clk_core_get_rate_nolock(clk->core); in clk_set_rate_range()
2375 * usual reason (clock broken, clock protected, etc) but also in clk_set_rate_range()
2377 * - round_rate() was not favorable and fell on the wrong in clk_set_rate_range()
2379 * - the determine_rate() callback does not really check for in clk_set_rate_range()
2388 ret = clk_core_set_rate_nolock(clk->core, rate); in clk_set_rate_range()
2391 clk->min_rate = old_min; in clk_set_rate_range()
2392 clk->max_rate = old_max; in clk_set_rate_range()
2397 if (clk->exclusive_count) in clk_set_rate_range()
2398 clk_core_rate_protect(clk->core); in clk_set_rate_range()
2407 * clk_set_min_rate - set a minimum clock rate for a clock source
2408 * @clk: clock source
2409 * @rate: desired minimum clock rate in Hz, inclusive
2418 return clk_set_rate_range(clk, rate, clk->max_rate); in clk_set_min_rate()
2423 * clk_set_max_rate - set a maximum clock rate for a clock source
2424 * @clk: clock source
2425 * @rate: desired maximum clock rate in Hz, inclusive
2434 return clk_set_rate_range(clk, clk->min_rate, rate); in clk_set_max_rate()
2439 * clk_get_parent - return the parent of a clk
2442 * Simply returns clk->parent. Returns NULL if clk is NULL.
2452 /* TODO: Create a per-user clk and change callers to call clk_put */ in clk_get_parent()
2453 parent = !clk->core->parent ? NULL : clk->core->parent->hw->clk; in clk_get_parent()
2464 if (core->num_parents > 1 && core->ops->get_parent) in __clk_init_parent()
2465 index = core->ops->get_parent(core->hw); in __clk_init_parent()
2483 clk_core_reparent(hw->core, !new_parent ? NULL : new_parent->core); in clk_hw_reparent()
2487 * clk_has_parent - check if a clock is a possible parent for another
2488 * @clk: clock source
2489 * @parent: parent clock source
2491 * This function can be used in drivers that need to check that a clock can be
2505 core = clk->core; in clk_has_parent()
2506 parent_core = parent->core; in clk_has_parent()
2509 if (core->parent == parent_core) in clk_has_parent()
2512 for (i = 0; i < core->num_parents; i++) in clk_has_parent()
2513 if (!strcmp(core->parents[i].name, parent_core->name)) in clk_has_parent()
2532 if (core->parent == parent) in clk_core_set_parent_nolock()
2535 /* verify ops for multi-parent clks */ in clk_core_set_parent_nolock()
2536 if (core->num_parents > 1 && !core->ops->set_parent) in clk_core_set_parent_nolock()
2537 return -EPERM; in clk_core_set_parent_nolock()
2539 /* check that we are allowed to re-parent if the clock is in use */ in clk_core_set_parent_nolock()
2540 if ((core->flags & CLK_SET_PARENT_GATE) && core->prepare_count) in clk_core_set_parent_nolock()
2541 return -EBUSY; in clk_core_set_parent_nolock()
2544 return -EBUSY; in clk_core_set_parent_nolock()
2551 __func__, parent->name, core->name); in clk_core_set_parent_nolock()
2554 p_rate = parent->rate; in clk_core_set_parent_nolock()
2568 /* do the re-parent */ in clk_core_set_parent_nolock()
2571 /* propagate rate an accuracy recalculation accordingly */ in clk_core_set_parent_nolock()
2587 return clk_core_set_parent_nolock(hw->core, parent->core); in clk_hw_set_parent()
2592 * clk_set_parent - switch the parent of a mux clk
2596 * Re-parent clk to use parent as its new input source. If clk is in
2606 * Returns 0 on success, -EERROR otherwise.
2617 if (clk->exclusive_count) in clk_set_parent()
2618 clk_core_rate_unprotect(clk->core); in clk_set_parent()
2620 ret = clk_core_set_parent_nolock(clk->core, in clk_set_parent()
2621 parent ? parent->core : NULL); in clk_set_parent()
2623 if (clk->exclusive_count) in clk_set_parent()
2624 clk_core_rate_protect(clk->core); in clk_set_parent()
2634 int ret = -EINVAL; in clk_core_set_phase_nolock()
2642 return -EBUSY; in clk_core_set_phase_nolock()
2646 if (core->ops->set_phase) { in clk_core_set_phase_nolock()
2647 ret = core->ops->set_phase(core->hw, degrees); in clk_core_set_phase_nolock()
2649 core->phase = degrees; in clk_core_set_phase_nolock()
2658 * clk_set_phase - adjust the phase shift of a clock signal
2659 * @clk: clock signal source
2662 * Shifts the phase of a clock signal by the specified
2663 * degrees. Returns 0 on success, -EERROR otherwise.
2666 * signal that we adjust the clock signal phase against. For example
2667 * phase locked-loop clock signal generators we may shift phase with
2668 * respect to feedback clock signal input, but for other cases the
2669 * clock phase may be shifted with respect to some other, unspecified
2673 * the clock tree hierarchy, which sets it apart from clock rates and
2674 * clock accuracy. A parent clock phase attribute does not have an
2675 * impact on the phase attribute of a child clock.
2691 if (clk->exclusive_count) in clk_set_phase()
2692 clk_core_rate_unprotect(clk->core); in clk_set_phase()
2694 ret = clk_core_set_phase_nolock(clk->core, degrees); in clk_set_phase()
2696 if (clk->exclusive_count) in clk_set_phase()
2697 clk_core_rate_protect(clk->core); in clk_set_phase()
2710 if (!core->ops->get_phase) in clk_core_get_phase()
2714 ret = core->ops->get_phase(core->hw); in clk_core_get_phase()
2716 core->phase = ret; in clk_core_get_phase()
2722 * clk_get_phase - return the phase shift of a clock signal
2723 * @clk: clock signal source
2725 * Returns the phase shift of a clock node in degrees, otherwise returns
2726 * -EERROR.
2736 ret = clk_core_get_phase(clk->core); in clk_get_phase()
2746 core->duty.num = 1; in clk_core_reset_duty_cycle_nolock()
2747 core->duty.den = 2; in clk_core_reset_duty_cycle_nolock()
2754 struct clk_duty *duty = &core->duty; in clk_core_update_duty_cycle_nolock()
2757 if (!core->ops->get_duty_cycle) in clk_core_update_duty_cycle_nolock()
2760 ret = core->ops->get_duty_cycle(core->hw, duty); in clk_core_update_duty_cycle_nolock()
2764 /* Don't trust the clock provider too much */ in clk_core_update_duty_cycle_nolock()
2765 if (duty->den == 0 || duty->num > duty->den) { in clk_core_update_duty_cycle_nolock()
2766 ret = -EINVAL; in clk_core_update_duty_cycle_nolock()
2781 if (core->parent && in clk_core_update_duty_cycle_parent_nolock()
2782 core->flags & CLK_DUTY_CYCLE_PARENT) { in clk_core_update_duty_cycle_parent_nolock()
2783 ret = clk_core_update_duty_cycle_nolock(core->parent); in clk_core_update_duty_cycle_parent_nolock()
2784 memcpy(&core->duty, &core->parent->duty, sizeof(core->duty)); in clk_core_update_duty_cycle_parent_nolock()
2803 return -EBUSY; in clk_core_set_duty_cycle_nolock()
2807 if (!core->ops->set_duty_cycle) in clk_core_set_duty_cycle_nolock()
2810 ret = core->ops->set_duty_cycle(core->hw, duty); in clk_core_set_duty_cycle_nolock()
2812 memcpy(&core->duty, duty, sizeof(*duty)); in clk_core_set_duty_cycle_nolock()
2824 if (core->parent && in clk_core_set_duty_cycle_parent_nolock()
2825 core->flags & (CLK_DUTY_CYCLE_PARENT | CLK_SET_RATE_PARENT)) { in clk_core_set_duty_cycle_parent_nolock()
2826 ret = clk_core_set_duty_cycle_nolock(core->parent, duty); in clk_core_set_duty_cycle_parent_nolock()
2827 memcpy(&core->duty, &core->parent->duty, sizeof(core->duty)); in clk_core_set_duty_cycle_parent_nolock()
2834 * clk_set_duty_cycle - adjust the duty cycle ratio of a clock signal
2835 * @clk: clock signal source
2839 * Apply the duty cycle ratio if the ratio is valid and the clock can
2854 return -EINVAL; in clk_set_duty_cycle()
2861 if (clk->exclusive_count) in clk_set_duty_cycle()
2862 clk_core_rate_unprotect(clk->core); in clk_set_duty_cycle()
2864 ret = clk_core_set_duty_cycle_nolock(clk->core, &duty); in clk_set_duty_cycle()
2866 if (clk->exclusive_count) in clk_set_duty_cycle()
2867 clk_core_rate_protect(clk->core); in clk_set_duty_cycle()
2878 struct clk_duty *duty = &core->duty; in clk_core_get_scaled_duty_cycle()
2885 ret = mult_frac(scale, duty->num, duty->den); in clk_core_get_scaled_duty_cycle()
2893 * clk_get_scaled_duty_cycle - return the duty cycle ratio of a clock signal
2894 * @clk: clock signal source
2897 * Returns the duty cycle ratio of a clock node multiplied by the provided
2905 return clk_core_get_scaled_duty_cycle(clk->core, scale); in clk_get_scaled_duty_cycle()
2910 * clk_is_match - check if two clk's point to the same hardware clock
2915 * clock node. Put differently, returns true if struct clk *p and struct clk *q
2926 /* true if clk->core pointers match. Avoid dereferencing garbage */ in clk_is_match()
2928 if (p->core == q->core) in clk_is_match()
2955 seq_printf(s, "%*s%-*s %7d %8d %8d %11lu %10lu ", in clk_summary_show_one()
2957 30 - level * 3, c->name, in clk_summary_show_one()
2958 c->enable_count, c->prepare_count, c->protect_count, in clk_summary_show_one()
2966 seq_puts(s, "-----"); in clk_summary_show_one()
2978 hlist_for_each_entry(child, &c->children, child_node) in clk_summary_show_subtree()
2985 struct hlist_head **lists = (struct hlist_head **)s->private; in clk_summary_show()
2988 …seq_puts(s, " clock count count count rate accuracy phas… in clk_summary_show()
2989 …seq_puts(s, "-------------------------------------------------------------------------------------… in clk_summary_show()
3011 seq_printf(s, "\"%s\": { ", c->name); in clk_dump_one()
3012 seq_printf(s, "\"enable_count\": %d,", c->enable_count); in clk_dump_one()
3013 seq_printf(s, "\"prepare_count\": %d,", c->prepare_count); in clk_dump_one()
3014 seq_printf(s, "\"protect_count\": %d,", c->protect_count); in clk_dump_one()
3018 seq_printf(s, "\"accuracy\": %lu,", clk_core_get_accuracy_recalc(c)); in clk_dump_one()
3032 hlist_for_each_entry(child, &c->children, child_node) { in clk_dump_subtree()
3044 struct hlist_head **lists = (struct hlist_head **)s->private; in clk_dump_show()
3092 ret = clk_prepare_enable(core->hw->clk); in clk_prepare_enable_set()
3094 clk_disable_unprepare(core->hw->clk); in clk_prepare_enable_set()
3103 *val = core->enable_count && core->prepare_count; in clk_prepare_enable_get()
3119 *val = core->rate; in clk_rate_get()
3147 struct clk_core *core = s->private; in clk_flags_show()
3148 unsigned long flags = core->flags; in clk_flags_show()
3174 * 1. Fetch the registered parent clock and use its name in possible_parent_show()
3177 * 4. Fetch parent clock's clock-output-name if DT index was set in possible_parent_show()
3185 seq_puts(s, parent->name); in possible_parent_show()
3186 else if (core->parents[i].name) in possible_parent_show()
3187 seq_puts(s, core->parents[i].name); in possible_parent_show()
3188 else if (core->parents[i].fw_name) in possible_parent_show()
3189 seq_printf(s, "<%s>(fw)", core->parents[i].fw_name); in possible_parent_show()
3190 else if (core->parents[i].index >= 0) in possible_parent_show()
3192 of_clk_get_parent_name(core->of_node, in possible_parent_show()
3193 core->parents[i].index)); in possible_parent_show()
3202 struct clk_core *core = s->private; in possible_parents_show()
3205 for (i = 0; i < core->num_parents - 1; i++) in possible_parents_show()
3216 struct clk_core *core = s->private; in current_parent_show()
3218 if (core->parent) in current_parent_show()
3219 seq_printf(s, "%s\n", core->parent->name); in current_parent_show()
3227 struct clk_core *core = s->private; in clk_duty_cycle_show()
3228 struct clk_duty *duty = &core->duty; in clk_duty_cycle_show()
3230 seq_printf(s, "%u/%u\n", duty->num, duty->den); in clk_duty_cycle_show()
3238 struct clk_core *core = s->private; in clk_min_rate_show()
3252 struct clk_core *core = s->private; in clk_max_rate_show()
3271 root = debugfs_create_dir(core->name, pdentry); in clk_debug_create_one()
3272 core->dentry = root; in clk_debug_create_one()
3278 debugfs_create_ulong("clk_accuracy", 0444, root, &core->accuracy); in clk_debug_create_one()
3279 debugfs_create_u32("clk_phase", 0444, root, &core->phase); in clk_debug_create_one()
3281 debugfs_create_u32("clk_prepare_count", 0444, root, &core->prepare_count); in clk_debug_create_one()
3282 debugfs_create_u32("clk_enable_count", 0444, root, &core->enable_count); in clk_debug_create_one()
3283 debugfs_create_u32("clk_protect_count", 0444, root, &core->protect_count); in clk_debug_create_one()
3284 debugfs_create_u32("clk_notifier_count", 0444, root, &core->notifier_count); in clk_debug_create_one()
3292 if (core->num_parents > 0) in clk_debug_create_one()
3296 if (core->num_parents > 1) in clk_debug_create_one()
3300 if (core->ops->debug_init) in clk_debug_create_one()
3301 core->ops->debug_init(core->hw, core->dentry); in clk_debug_create_one()
3305 * clk_debug_register - add a clk node to the debugfs clk directory
3315 hlist_add_head(&core->debug_node, &clk_debug_list); in clk_debug_register()
3322 * clk_debug_unregister - remove a clk node from the debugfs clk directory
3326 * debugfs clk directory if clk->dentry points to debugfs created by
3332 hlist_del_init(&core->debug_node); in clk_debug_unregister()
3333 debugfs_remove_recursive(core->dentry); in clk_debug_unregister()
3334 core->dentry = NULL; in clk_debug_unregister()
3339 * clk_debug_init - lazily populate the debugfs clk directory
3343 * populates the debugfs clk directory once at boot-time when we know that
3344 * debugfs is setup. It should only be called once at boot-time, all other clks
3412 * clock. This is important for CLK_IS_CRITICAL clocks, which in clk_core_reparent_orphans_nolock()
3424 * 0 if the clock doesn't have clk_ops::recalc_rate and in clk_core_reparent_orphans_nolock()
3430 * 'req_rate' is set to something non-zero so that in clk_core_reparent_orphans_nolock()
3433 orphan->req_rate = orphan->rate; in clk_core_reparent_orphans_nolock()
3439 * __clk_core_init - initialize the data structures in a struct clk_core
3453 return -EINVAL; in __clk_core_init()
3458 * Set hw->core after grabbing the prepare_lock to synchronize with in __clk_core_init()
3459 * callers of clk_core_fill_parent_index() where we treat hw->core in __clk_core_init()
3463 core->hw->core = core; in __clk_core_init()
3469 /* check to see if a clock with this name is already registered */ in __clk_core_init()
3470 if (clk_core_lookup(core->name)) { in __clk_core_init()
3472 __func__, core->name); in __clk_core_init()
3473 ret = -EEXIST; in __clk_core_init()
3477 /* check that clk_ops are sane. See Documentation/driver-api/clk.rst */ in __clk_core_init()
3478 if (core->ops->set_rate && in __clk_core_init()
3479 !((core->ops->round_rate || core->ops->determine_rate) && in __clk_core_init()
3480 core->ops->recalc_rate)) { in __clk_core_init()
3482 __func__, core->name); in __clk_core_init()
3483 ret = -EINVAL; in __clk_core_init()
3487 if (core->ops->set_parent && !core->ops->get_parent) { in __clk_core_init()
3489 __func__, core->name); in __clk_core_init()
3490 ret = -EINVAL; in __clk_core_init()
3494 if (core->num_parents > 1 && !core->ops->get_parent) { in __clk_core_init()
3496 __func__, core->name); in __clk_core_init()
3497 ret = -EINVAL; in __clk_core_init()
3501 if (core->ops->set_rate_and_parent && in __clk_core_init()
3502 !(core->ops->set_parent && core->ops->set_rate)) { in __clk_core_init()
3504 __func__, core->name); in __clk_core_init()
3505 ret = -EINVAL; in __clk_core_init()
3510 * optional platform-specific magic in __clk_core_init()
3512 * The .init callback is not used by any of the basic clock types, but in __clk_core_init()
3514 * CCF to get an accurate view of clock for any other callbacks. It may in __clk_core_init()
3521 * the clock in __clk_core_init()
3523 if (core->ops->init) { in __clk_core_init()
3524 ret = core->ops->init(core->hw); in __clk_core_init()
3529 parent = core->parent = __clk_init_parent(core); in __clk_core_init()
3532 * Populate core->parent if parent has already been clk_core_init'd. If in __clk_core_init()
3538 * clocks and re-parent any that are children of the clock currently in __clk_core_init()
3542 hlist_add_head(&core->child_node, &parent->children); in __clk_core_init()
3543 core->orphan = parent->orphan; in __clk_core_init()
3544 } else if (!core->num_parents) { in __clk_core_init()
3545 hlist_add_head(&core->child_node, &clk_root_list); in __clk_core_init()
3546 core->orphan = false; in __clk_core_init()
3548 hlist_add_head(&core->child_node, &clk_orphan_list); in __clk_core_init()
3549 core->orphan = true; in __clk_core_init()
3553 * Set clk's accuracy. The preferred method is to use in __clk_core_init()
3555 * fallback is to use the parent's accuracy. If a clock doesn't have a in __clk_core_init()
3556 * parent (or is orphaned) then accuracy is set to zero (perfect in __clk_core_init()
3557 * clock). in __clk_core_init()
3559 if (core->ops->recalc_accuracy) in __clk_core_init()
3560 core->accuracy = core->ops->recalc_accuracy(core->hw, in __clk_core_init()
3563 core->accuracy = parent->accuracy; in __clk_core_init()
3565 core->accuracy = 0; in __clk_core_init()
3570 * query the current clock phase, or just assume it's in phase. in __clk_core_init()
3576 core->name); in __clk_core_init()
3588 * parent's rate. If a clock doesn't have a parent (or is orphaned) in __clk_core_init()
3591 if (core->ops->recalc_rate) in __clk_core_init()
3592 rate = core->ops->recalc_rate(core->hw, in __clk_core_init()
3595 rate = parent->rate; in __clk_core_init()
3598 core->rate = core->req_rate = rate; in __clk_core_init()
3605 if (core->flags & CLK_IS_CRITICAL) { in __clk_core_init()
3611 __func__, core->name); in __clk_core_init()
3620 __func__, core->name); in __clk_core_init()
3629 kref_init(&core->ref); in __clk_core_init()
3634 hlist_del_init(&core->child_node); in __clk_core_init()
3635 core->hw->core = NULL; in __clk_core_init()
3647 * clk_core_link_consumer - Add a clk consumer to the list of consumers in a clk_core
3654 hlist_add_head(&clk->clks_node, &core->clks); in clk_core_link_consumer()
3659 * clk_core_unlink_consumer - Remove a clk consumer from the list of consumers in a clk_core
3665 hlist_del(&clk->clks_node); in clk_core_unlink_consumer()
3669 * alloc_clk - Allocate a clk consumer, but leave it unlinked to the clk_core
3683 return ERR_PTR(-ENOMEM); in alloc_clk()
3685 clk->core = core; in alloc_clk()
3686 clk->dev_id = dev_id; in alloc_clk()
3687 clk->con_id = kstrdup_const(con_id, GFP_KERNEL); in alloc_clk()
3688 clk->max_rate = ULONG_MAX; in alloc_clk()
3694 * free_clk - Free a clk consumer
3702 kfree_const(clk->con_id); in free_clk()
3728 core = hw->core; in clk_hw_create_clk()
3732 clk->dev = dev; in clk_hw_create_clk()
3734 if (!try_module_get(core->owner)) { in clk_hw_create_clk()
3736 return ERR_PTR(-ENOENT); in clk_hw_create_clk()
3739 kref_get(&core->ref); in clk_hw_create_clk()
3751 return -EINVAL; in clk_cpy_name()
3757 return -ENOMEM; in clk_cpy_name()
3765 u8 num_parents = init->num_parents; in clk_core_populate_parent_map()
3766 const char * const *parent_names = init->parent_names; in clk_core_populate_parent_map()
3767 const struct clk_hw **parent_hws = init->parent_hws; in clk_core_populate_parent_map()
3768 const struct clk_parent_data *parent_data = init->parent_data; in clk_core_populate_parent_map()
3776 * Avoid unnecessary string look-ups of clk_core's possible parents by in clk_core_populate_parent_map()
3780 core->parents = parents; in clk_core_populate_parent_map()
3782 return -ENOMEM; in clk_core_populate_parent_map()
3786 parent->index = -1; in clk_core_populate_parent_map()
3791 __func__, core->name); in clk_core_populate_parent_map()
3792 ret = clk_cpy_name(&parent->name, parent_names[i], in clk_core_populate_parent_map()
3795 parent->hw = parent_data[i].hw; in clk_core_populate_parent_map()
3796 parent->index = parent_data[i].index; in clk_core_populate_parent_map()
3797 ret = clk_cpy_name(&parent->fw_name, in clk_core_populate_parent_map()
3800 ret = clk_cpy_name(&parent->name, in clk_core_populate_parent_map()
3804 parent->hw = parent_hws[i]; in clk_core_populate_parent_map()
3806 ret = -EINVAL; in clk_core_populate_parent_map()
3814 } while (--i >= 0); in clk_core_populate_parent_map()
3826 int i = core->num_parents; in clk_core_free_parent_map()
3828 if (!core->num_parents) in clk_core_free_parent_map()
3831 while (--i >= 0) { in clk_core_free_parent_map()
3832 kfree_const(core->parents[i].name); in clk_core_free_parent_map()
3833 kfree_const(core->parents[i].fw_name); in clk_core_free_parent_map()
3836 kfree(core->parents); in clk_core_free_parent_map()
3844 const struct clk_init_data *init = hw->init; in __clk_register()
3849 * we catch use of hw->init early on in the core. in __clk_register()
3851 hw->init = NULL; in __clk_register()
3855 ret = -ENOMEM; in __clk_register()
3859 core->name = kstrdup_const(init->name, GFP_KERNEL); in __clk_register()
3860 if (!core->name) { in __clk_register()
3861 ret = -ENOMEM; in __clk_register()
3865 if (WARN_ON(!init->ops)) { in __clk_register()
3866 ret = -EINVAL; in __clk_register()
3869 core->ops = init->ops; in __clk_register()
3872 core->rpm_enabled = true; in __clk_register()
3873 core->dev = dev; in __clk_register()
3874 core->of_node = np; in __clk_register()
3875 if (dev && dev->driver) in __clk_register()
3876 core->owner = dev->driver->owner; in __clk_register()
3877 core->hw = hw; in __clk_register()
3878 core->flags = init->flags; in __clk_register()
3879 core->num_parents = init->num_parents; in __clk_register()
3880 core->min_rate = 0; in __clk_register()
3881 core->max_rate = ULONG_MAX; in __clk_register()
3887 INIT_HLIST_HEAD(&core->clks); in __clk_register()
3893 hw->clk = alloc_clk(core, NULL, NULL); in __clk_register()
3894 if (IS_ERR(hw->clk)) { in __clk_register()
3895 ret = PTR_ERR(hw->clk); in __clk_register()
3899 clk_core_link_consumer(core, hw->clk); in __clk_register()
3903 return hw->clk; in __clk_register()
3906 clk_core_unlink_consumer(hw->clk); in __clk_register()
3909 free_clk(hw->clk); in __clk_register()
3910 hw->clk = NULL; in __clk_register()
3916 kfree_const(core->name); in __clk_register()
3924 * dev_or_parent_of_node() - Get device node of @dev or @dev's parent
3928 * @dev->parent if dev doesn't have a device node, or NULL if neither
3929 * @dev or @dev->parent have a device node.
3940 np = dev_of_node(dev->parent); in dev_or_parent_of_node()
3946 * clk_register - allocate a new clock, register it and return an opaque cookie
3947 * @dev: device that is registering this clock
3948 * @hw: link to hardware-specific clock data
3950 * clk_register is the *deprecated* interface for populating the clock tree with
3951 * new clock nodes. Use clk_hw_register() instead.
3955 * rest of the clock API. In the event of an error clk_register will return an
3965 * clk_hw_register - register a clk_hw and return an error code
3966 * @dev: device that is registering this clock
3967 * @hw: link to hardware-specific clock data
3969 * clk_hw_register is the primary interface for populating the clock tree with
3970 * new clock nodes. It returns an integer equal to zero indicating success or
3982 * of_clk_hw_register - register a clk_hw and return an error code
3983 * @node: device_node of device that is registering this clock
3984 * @hw: link to hardware-specific clock data
3986 * of_clk_hw_register() is the primary interface for populating the clock tree
3987 * with new clock nodes when a struct device is not available, but a struct
3998 /* Free memory allocated for a clock. */
4006 kfree_const(core->name); in __clk_release()
4012 * after clk_unregister() was called on a clock and until last clock
4017 return -ENXIO; in clk_nodrv_prepare_enable()
4028 return -ENXIO; in clk_nodrv_set_rate()
4033 return -ENXIO; in clk_nodrv_set_parent()
4051 for (i = 0; i < root->num_parents; i++) in clk_core_evict_parent_cache_subtree()
4052 if (root->parents[i].core == target) in clk_core_evict_parent_cache_subtree()
4053 root->parents[i].core = NULL; in clk_core_evict_parent_cache_subtree()
4055 hlist_for_each_entry(child, &root->children, child_node) in clk_core_evict_parent_cache_subtree()
4074 * clk_unregister - unregister a currently registered clock
4075 * @clk: clock to unregister
4085 clk_debug_unregister(clk->core); in clk_unregister()
4089 ops = clk->core->ops; in clk_unregister()
4091 pr_err("%s: unregistered clock: %s\n", __func__, in clk_unregister()
4092 clk->core->name); in clk_unregister()
4096 * Assign empty clock ops for consumers that might still hold in clk_unregister()
4097 * a reference to this clock. in clk_unregister()
4100 clk->core->ops = &clk_nodrv_ops; in clk_unregister()
4103 if (ops->terminate) in clk_unregister()
4104 ops->terminate(clk->core->hw); in clk_unregister()
4106 if (!hlist_empty(&clk->core->children)) { in clk_unregister()
4111 hlist_for_each_entry_safe(child, t, &clk->core->children, in clk_unregister()
4116 clk_core_evict_parent_cache(clk->core); in clk_unregister()
4118 hlist_del_init(&clk->core->child_node); in clk_unregister()
4120 if (clk->core->prepare_count) in clk_unregister()
4121 pr_warn("%s: unregistering prepared clock: %s\n", in clk_unregister()
4122 __func__, clk->core->name); in clk_unregister()
4124 if (clk->core->protect_count) in clk_unregister()
4125 pr_warn("%s: unregistering protected clock: %s\n", in clk_unregister()
4126 __func__, clk->core->name); in clk_unregister()
4128 kref_put(&clk->core->ref, __clk_release); in clk_unregister()
4136 * clk_hw_unregister - unregister a currently registered clk_hw
4137 * @hw: hardware-specific clock data to unregister
4141 clk_unregister(hw->clk); in clk_hw_unregister()
4156 * devm_clk_register - resource managed clk_register()
4157 * @dev: device that is registering this clock
4158 * @hw: link to hardware-specific clock data
4172 return ERR_PTR(-ENOMEM); in devm_clk_register()
4187 * devm_clk_hw_register - resource managed clk_hw_register()
4188 * @dev: device that is registering this clock
4189 * @hw: link to hardware-specific clock data
4202 return -ENOMEM; in devm_clk_hw_register()
4234 * devm_clk_unregister - resource managed clk_unregister()
4235 * @dev: device that is unregistering the clock data
4236 * @clk: clock to unregister
4238 * Deallocate a clock allocated with devm_clk_register(). Normally
4249 * devm_clk_hw_unregister - resource managed clk_hw_unregister()
4250 * @dev: device that is unregistering the hardware-specific clock data
4251 * @hw: link to hardware-specific clock data
4282 if (WARN_ON(clk->exclusive_count)) { in __clk_put()
4284 clk->core->protect_count -= (clk->exclusive_count - 1); in __clk_put()
4285 clk_core_rate_unprotect(clk->core); in __clk_put()
4286 clk->exclusive_count = 0; in __clk_put()
4289 hlist_del(&clk->clks_node); in __clk_put()
4290 if (clk->min_rate > clk->core->req_rate || in __clk_put()
4291 clk->max_rate < clk->core->req_rate) in __clk_put()
4292 clk_core_set_rate_nolock(clk->core, clk->core->req_rate); in __clk_put()
4294 owner = clk->core->owner; in __clk_put()
4295 kref_put(&clk->core->ref, __clk_release); in __clk_put()
4307 * clk_notifier_register - add a clk rate change notifier
4314 * re-enter into the clk framework by calling any top-level clk APIs;
4318 * clock rate is passed to the callback via struct clk_notifier_data.old_rate
4321 * clk_notifier_register() must be called from non-atomic context.
4322 * Returns -EINVAL if called with null arguments, -ENOMEM upon
4329 int ret = -ENOMEM; in clk_notifier_register()
4332 return -EINVAL; in clk_notifier_register()
4338 if (cn->clk == clk) in clk_notifier_register()
4346 cn->clk = clk; in clk_notifier_register()
4347 srcu_init_notifier_head(&cn->notifier_head); in clk_notifier_register()
4349 list_add(&cn->node, &clk_notifier_list); in clk_notifier_register()
4352 ret = srcu_notifier_chain_register(&cn->notifier_head, nb); in clk_notifier_register()
4354 clk->core->notifier_count++; in clk_notifier_register()
4364 * clk_notifier_unregister - remove a clk rate change notifier
4371 * Returns -EINVAL if called with null arguments; otherwise, passes
4377 int ret = -ENOENT; in clk_notifier_unregister()
4380 return -EINVAL; in clk_notifier_unregister()
4385 if (cn->clk == clk) { in clk_notifier_unregister()
4386 ret = srcu_notifier_chain_unregister(&cn->notifier_head, nb); in clk_notifier_unregister()
4388 clk->core->notifier_count--; in clk_notifier_unregister()
4391 if (!cn->notifier_head.head) { in clk_notifier_unregister()
4392 srcu_cleanup_notifier_head(&cn->notifier_head); in clk_notifier_unregister()
4393 list_del(&cn->node); in clk_notifier_unregister()
4415 * struct of_clk_provider - Clock provider registration structure
4416 * @link: Entry in global list of clock providers
4417 * @node: Pointer to device tree node of clock provider
4418 * @get: Get clock callback. Returns NULL or a struct clk for the
4419 * given clock specifier
4421 * struct clk_hw for the given clock specifier
4456 unsigned int idx = clkspec->args[0]; in of_clk_src_onecell_get()
4458 if (idx >= clk_data->clk_num) { in of_clk_src_onecell_get()
4459 pr_err("%s: invalid clock index %u\n", __func__, idx); in of_clk_src_onecell_get()
4460 return ERR_PTR(-EINVAL); in of_clk_src_onecell_get()
4463 return clk_data->clks[idx]; in of_clk_src_onecell_get()
4471 unsigned int idx = clkspec->args[0]; in of_clk_hw_onecell_get()
4473 if (idx >= hw_data->num) { in of_clk_hw_onecell_get()
4475 return ERR_PTR(-EINVAL); in of_clk_hw_onecell_get()
4478 return hw_data->hws[idx]; in of_clk_hw_onecell_get()
4483 * of_clk_add_provider() - Register a clock provider for a node
4484 * @np: Device node pointer associated with clock provider
4485 * @clk_src_get: callback for decoding clock
4500 return -ENOMEM; in of_clk_add_provider()
4502 cp->node = of_node_get(np); in of_clk_add_provider()
4503 cp->data = data; in of_clk_add_provider()
4504 cp->get = clk_src_get; in of_clk_add_provider()
4507 list_add(&cp->link, &of_clk_providers); in of_clk_add_provider()
4509 pr_debug("Added clock from %pOF\n", np); in of_clk_add_provider()
4522 * of_clk_add_hw_provider() - Register a clock provider for a node
4523 * @np: Device node pointer associated with clock provider
4537 return -ENOMEM; in of_clk_add_hw_provider()
4539 cp->node = of_node_get(np); in of_clk_add_hw_provider()
4540 cp->data = data; in of_clk_add_hw_provider()
4541 cp->get_hw = get; in of_clk_add_hw_provider()
4544 list_add(&cp->link, &of_clk_providers); in of_clk_add_hw_provider()
4564 * We allow a child device to use its parent device as the clock provider node
4565 * for cases like MFD sub-devices where the child device driver wants to use
4566 * devm_*() APIs but not list the device in DT as a sub-node.
4572 np = dev->of_node; in get_clk_provider_node()
4573 parent_np = dev->parent ? dev->parent->of_node : NULL; in get_clk_provider_node()
4575 if (!of_find_property(np, "#clock-cells", NULL)) in get_clk_provider_node()
4576 if (of_find_property(parent_np, "#clock-cells", NULL)) in get_clk_provider_node()
4583 * devm_of_clk_add_hw_provider() - Managed clk provider node registration
4584 * @dev: Device acting as the clock provider (used for DT node and lifetime)
4588 * Registers clock provider for given device's node. If the device has no DT
4589 * node or if the device node lacks of clock provider information (#clock-cells)
4591 * has the #clock-cells then it is used in registration. Provider is
4607 return -ENOMEM; in devm_of_clk_add_hw_provider()
4623 * of_clk_del_provider() - Remove a previously registered clock provider
4624 * @np: Device node pointer associated with clock provider
4632 if (cp->node == np) { in of_clk_del_provider()
4633 list_del(&cp->link); in of_clk_del_provider()
4634 of_node_put(cp->node); in of_clk_del_provider()
4654 * devm_of_clk_del_provider() - Remove clock provider registered using devm
4655 * @dev: Device to whose lifetime the clock provider was bound
4670 * of_parse_clkspec() - Parse a DT clock specifier for a given device node
4671 * @np: device node to parse clock specifier from
4672 * @index: index of phandle to parse clock out of. If index < 0, @name is used
4673 * @name: clock name to find and parse. If name is NULL, the index is used
4674 * @out_args: Result of parsing the clock specifier
4676 * Parses a device node's "clocks" and "clock-names" properties to find the
4677 * phandle and cells for the index or name that is desired. The resulting clock
4679 * parsing error. The @index argument is ignored if @name is non-NULL.
4683 * phandle1: clock-controller@1 {
4684 * #clock-cells = <2>;
4687 * phandle2: clock-controller@2 {
4688 * #clock-cells = <1>;
4691 * clock-consumer@3 {
4693 * clock-names = "name1", "name2";
4696 * To get a device_node for `clock-controller@2' node you may call this
4699 * of_parse_clkspec(clock-consumer@3, -1, "name2", &args);
4700 * of_parse_clkspec(clock-consumer@3, 1, NULL, &args);
4701 * of_parse_clkspec(clock-consumer@3, 1, "name2", &args);
4703 * Return: 0 upon successfully parsing the clock specifier. Otherwise, -ENOENT
4704 * if @name is NULL or -EINVAL if @name is non-NULL and it can't be found in
4705 * the "clock-names" property of @np.
4710 int ret = -ENOENT; in of_parse_clkspec()
4712 /* Walk up the tree of devices looking for a clock property that matches */ in of_parse_clkspec()
4716 * "clock-names" property. If it cannot be found, then index in of_parse_clkspec()
4718 * return -EINVAL. in of_parse_clkspec()
4721 index = of_property_match_string(np, "clock-names", name); in of_parse_clkspec()
4722 ret = of_parse_phandle_with_args(np, "clocks", "#clock-cells", in of_parse_clkspec()
4730 * No matching clock found on this node. If the parent node in of_parse_clkspec()
4731 * has a "clock-ranges" property, then we can try one of its in of_parse_clkspec()
4734 np = np->parent; in of_parse_clkspec()
4735 if (np && !of_get_property(np, "clock-ranges", NULL)) in of_parse_clkspec()
4749 if (provider->get_hw) in __of_clk_get_hw_from_provider()
4750 return provider->get_hw(clkspec, provider->data); in __of_clk_get_hw_from_provider()
4752 clk = provider->get(clkspec, provider->data); in __of_clk_get_hw_from_provider()
4762 struct clk_hw *hw = ERR_PTR(-EPROBE_DEFER); in of_clk_get_hw_from_clkspec()
4765 return ERR_PTR(-EINVAL); in of_clk_get_hw_from_clkspec()
4769 if (provider->node == clkspec->np) { in of_clk_get_hw_from_clkspec()
4781 * of_clk_get_from_provider() - Lookup a clock from a clock provider
4782 * @clkspec: pointer to a clock specifier data structure
4784 * This function looks up a struct clk from the registered list of clock
4785 * providers, an input is a clock specifier data structure as returned
4824 return __of_clk_get(np, index, np->full_name, NULL); in of_clk_get()
4829 * of_clk_get_by_name() - Parse and lookup a clock referenced by a device node
4830 * @np: pointer to clock consumer node
4831 * @name: name of consumer's clock input, or NULL for the first clock reference
4833 * This function parses the clocks and clock-names properties,
4834 * and uses them to look up the struct clk from the registered list of clock
4840 return ERR_PTR(-ENOENT); in of_clk_get_by_name()
4842 return __of_clk_get(np, 0, np->full_name, name); in of_clk_get_by_name()
4847 * of_clk_get_parent_count() - Count the number of clocks a device node has
4856 count = of_count_phandle_with_args(np, "clocks", "#clock-cells"); in of_clk_get_parent_count()
4875 rc = of_parse_phandle_with_args(np, "clocks", "#clock-cells", index, in of_clk_get_parent_name()
4884 * specified into an array offset for the clock-output-names property. in of_clk_get_parent_name()
4886 of_property_for_each_u32(clkspec.np, "clock-indices", prop, vp, pv) { in of_clk_get_parent_name()
4893 /* We went off the end of 'clock-indices' without finding it */ in of_clk_get_parent_name()
4897 if (of_property_read_string_index(clkspec.np, "clock-output-names", in of_clk_get_parent_name()
4901 * Best effort to get the name if the clock has been in of_clk_get_parent_name()
4902 * registered with the framework. If the clock isn't in of_clk_get_parent_name()
4904 * the clock as long as #clock-cells = 0. in of_clk_get_parent_name()
4909 clk_name = clkspec.np->name; in of_clk_get_parent_name()
4925 * of_clk_parent_fill() - Fill @parents with names of @np's parents and return
4927 * @np: Device node pointer associated with clock provider
4931 * Return: number of parents for the clock node.
4952 * This function looks for a parent clock. If there is one, then it
4953 * checks that the provider for this parent clock was initialized, in
4954 * this case the parent clock will be ready.
4971 if (PTR_ERR(clk) == -EPROBE_DEFER) in parent_ready()
4978 * previous parent are ready. If there is no clock in parent_ready()
4987 * of_clk_detect_critical() - set CLK_IS_CRITICAL flag from Device Tree
4988 * @np: Device node pointer associated with clock provider
4989 * @index: clock index
4990 * @flags: pointer to top-level framework flags
4992 * Detects if the clock-critical property exists and, if so, sets the
4996 * bindings, such as the one-clock-per-node style that are outdated.
4997 * Those bindings typically put all clock data into .dts and the Linux
4998 * driver has no clock data, thus making it impossible to set this flag
5012 return -EINVAL; in of_clk_detect_critical()
5014 of_property_for_each_u32(np, "clock-critical", prop, cur, idx) in of_clk_detect_critical()
5022 * of_clk_init() - Scan and init clock providers from the DT
5025 * This function scans the device tree for matching clock providers
5052 list_del(&clk_provider->node); in of_clk_init()
5053 of_node_put(clk_provider->np); in of_clk_init()
5060 parent->clk_init_cb = match->data; in of_clk_init()
5061 parent->np = of_node_get(np); in of_clk_init()
5062 list_add_tail(&parent->node, &clk_provider_list); in of_clk_init()
5069 if (force || parent_ready(clk_provider->np)) { in of_clk_init()
5072 of_node_set_flag(clk_provider->np, in of_clk_init()
5075 clk_provider->clk_init_cb(clk_provider->np); in of_clk_init()
5076 of_clk_set_defaults(clk_provider->np, true); in of_clk_init()
5078 list_del(&clk_provider->node); in of_clk_init()
5079 of_node_put(clk_provider->np); in of_clk_init()
5089 * in case the clock parent was not mandatory in of_clk_init()