Lines Matching refs:rate
67 unsigned long rate;
487 return core->rate;
491 * known yet. Best to return 0 as the rate of this clk until we can
492 * properly recalc the rate based on the parent's rate.
544 static bool mux_is_better_rate(unsigned long rate, unsigned long now,
548 return abs(now - rate) < abs(best - rate);
550 return now <= rate && now > best;
555 unsigned long rate);
613 req->rate = 0;
618 req->rate);
628 best = parent_req.rate;
636 req->rate = best;
653 /* find the parent that can provide the fastest rate <= rate */
665 clk_core_forward_rate_req(core, req, parent, &parent_req, req->rate);
675 parent_rate = parent_req.rate;
680 if (mux_is_better_rate(req->rate, parent_rate,
692 req->rate = best;
724 * clk_hw_get_rate_range() - returns the clock rate range for a hw clk
767 * @hw: mux type clk to determine rate on
768 * @req: rate request, also used to return preferred parent and frequencies
792 * @hw: mux type clk to determine rate on
793 * @req: rate request, also used to return preferred frequency
795 * Helper for finding best parent rate to provide a given frequency.
848 * clk_rate_exclusive_put - release exclusivity over clock rate control
853 * clock which could result in a rate change or rate glitch. Exclusive clocks
854 * cannot have their rate changed, either directly or indirectly due to changes
859 * the rate effectively gets locked as exclusivity can't be preempted.
914 * clk_rate_exclusive_get - get exclusivity over the clk rate control
915 * @clk: the clk over which the exclusity of rate control is requested
919 * clock which could result in a rate change or rate glitch. Exclusive clocks
920 * cannot have their rate changed, either directly or indirectly due to changes
925 * the rate effectively gets locked as exclusivity can't be preempted.
1038 * Instead of a consumer claiming exclusive rate control, it is
1040 * operation which could result in a rate change or rate glitch while
1468 long rate;
1479 * If it's the case, clamping the rate is equivalent to setting
1480 * the rate to 0 which is bad. Skip the clamping but complain so
1484 pr_warn("%s: %s: clk_rate_request has initialized min or max rate.\n",
1487 req->rate = clamp(req->rate, req->min_rate, req->max_rate);
1496 req->rate = core->rate;
1500 rate = core->ops->round_rate(core->hw, req->rate,
1502 if (rate < 0)
1503 return rate;
1505 req->rate = rate;
1515 unsigned long rate)
1529 req->rate = rate;
1535 req->best_parent_rate = parent->rate;
1544 * @hw: the clk for which we want to submit a rate request
1546 * @rate: the rate which is to be requested
1553 unsigned long rate)
1558 clk_core_init_rate_req(hw->core, req, rate);
1564 * @hw: the original clock that got the rate request
1568 * @parent_rate: The rate which is to be requested to @parent
1601 req->rate = 0;
1611 clk_core_forward_rate_req(core, req, core->parent, &parent_req, req->rate);
1621 req->best_parent_rate = parent_req.rate;
1622 req->rate = parent_req.rate;
1627 req->rate = core->rate;
1632 * __clk_determine_rate - get the closest rate actually supported by a clock
1633 * @hw: determine the rate of this clock
1634 * @req: target rate request
1641 req->rate = 0;
1650 * clk_hw_round_rate() - round the given rate for a hw clk
1651 * @hw: the hw clk for which we are rounding a rate
1652 * @rate: the rate which is to be rounded
1654 * Takes in a rate as input and rounds it to a rate that the clk can actually
1661 * Return: returns rounded rate of hw clk if clk supports round_rate operation
1662 * else returns the parent rate.
1664 unsigned long clk_hw_round_rate(struct clk_hw *hw, unsigned long rate)
1669 clk_core_init_rate_req(hw->core, &req, rate);
1679 return req.rate;
1684 * clk_round_rate - round the given rate for a clk
1685 * @clk: the clk for which we are rounding a rate
1686 * @rate: the rate which is to be rounded
1688 * Takes in a rate as input and rounds it to a rate that the clk can actually
1690 * then the parent rate is returned.
1692 long clk_round_rate(struct clk *clk, unsigned long rate)
1705 clk_core_init_rate_req(clk->core, &req, rate);
1721 return req.rate;
1727 * @core: clk that is changing rate
1729 * @old_rate: old clk rate
1730 * @new_rate: new clk rate
1732 * Triggers a notifier call chain on the clk rate-change notification
1826 unsigned long rate = parent_rate;
1829 rate = core->ops->recalc_rate(core->hw, parent_rate);
1832 return rate;
1838 * @update_req: Whether req_rate should be updated with the new rate
1843 * it is assumed that the clock will take on the rate of its parent.
1857 old_rate = core->rate;
1860 parent_rate = core->parent->rate;
1862 core->rate = clk_recalc(core, parent_rate);
1864 core->req_rate = core->rate;
1871 __clk_notify(core, msg, old_rate, core->rate);
1886 * clk_get_rate - return the rate of clk
1887 * @clk: the clk whose rate is being returned
1889 * Simply returns the cached rate of the clk, unless CLK_GET_RATE_NOCACHE flag
1896 unsigned long rate;
1902 rate = clk_core_get_rate_recalc(clk->core);
1905 return rate;
2110 * @parent_rate: the "future" rate of clk's parent
2116 * pre-rate change notifications and returns early if no clks in the
2119 * take on the rate of its parent.
2132 /* abort rate change if a driver returns NOTIFY_BAD or NOTIFY_STOP */
2134 ret = __clk_notify(core, PRE_RATE_CHANGE, core->rate, new_rate);
2176 unsigned long rate)
2191 /* save parent rate, if it exists */
2194 best_parent_rate = parent->rate;
2198 /* find the closest rate and parent clk/rate */
2202 clk_core_init_rate_req(core, &req, rate);
2213 new_rate = req.rate;
2220 core->new_rate = core->rate;
2224 top = clk_calc_new_rates(parent, rate);
2248 best_parent_rate != parent->rate)
2258 * Notify about rate changes in a subtree. Always walk down the whole tree
2268 if (core->rate == core->new_rate)
2272 ret = __clk_notify(core, event, core->rate, core->new_rate);
2297 * walk down a subtree and set the new rates notifying the rate
2310 old_rate = core->rate;
2314 best_parent_rate = core->new_parent->rate;
2317 best_parent_rate = core->parent->rate;
2355 core->rate = clk_recalc(core, best_parent_rate);
2365 if (core->notifier_count && old_rate != core->rate)
2366 __clk_notify(core, POST_RATE_CHANGE, old_rate, core->rate);
2400 /* simulate what the rate would be if it could be freely set */
2416 return ret ? 0 : req.rate;
2423 unsigned long rate;
2429 rate = clk_core_req_round_rate_nolock(core, req_rate);
2432 if (rate == clk_core_get_rate_nolock(core))
2435 /* fail on a direct rate set of a protected provider */
2451 pr_debug("%s: failed to set %s rate\n", __func__,
2469 * clk_set_rate - specify a new rate for clk
2470 * @clk: the clk whose rate is being changed
2471 * @rate: the new rate for clk
2473 * In the simplest case clk_set_rate will only adjust the rate of clk.
2475 * Setting the CLK_SET_RATE_PARENT flag allows the rate change operation to
2479 * *parent_rate comes back with a new rate for clk's parent then we propagate
2480 * up to clk's parent and set its rate. Upward propagation will continue
2489 int clk_set_rate(struct clk *clk, unsigned long rate)
2502 ret = clk_core_set_rate_nolock(clk->core, rate);
2514 * clk_set_rate_exclusive - specify a new rate and get exclusive control
2515 * @clk: the clk whose rate is being changed
2516 * @rate: the new rate for clk
2525 * The exclusivity is not applied if setting the rate failed.
2532 int clk_set_rate_exclusive(struct clk *clk, unsigned long rate)
2548 ret = clk_core_set_rate_nolock(clk->core, rate);
2565 unsigned long old_min, old_max, rate;
2595 rate = clk->core->req_rate;
2597 rate = clk_core_get_rate_recalc(clk->core);
2601 * opportunity to the provider to adjust the clock rate based on
2605 * outside of the boundaries. Clamping the last requested rate
2614 * this corner case when determining the rate
2616 rate = clamp(rate, min, max);
2617 ret = clk_core_set_rate_nolock(clk->core, rate);
2632 * clk_set_rate_range - set a rate range for a clock source
2634 * @min: desired minimum clock rate in Hz, inclusive
2635 * @max: desired maximum clock rate in Hz, inclusive
2657 * clk_set_min_rate - set a minimum clock rate for a clock source
2659 * @rate: desired minimum clock rate in Hz, inclusive
2663 int clk_set_min_rate(struct clk *clk, unsigned long rate)
2668 trace_clk_set_min_rate(clk->core, rate);
2670 return clk_set_rate_range(clk, rate, clk->max_rate);
2675 * clk_set_max_rate - set a maximum clock rate for a clock source
2677 * @rate: desired maximum clock rate in Hz, inclusive
2681 int clk_set_max_rate(struct clk *clk, unsigned long rate)
2686 trace_clk_set_max_rate(clk->core, rate);
2688 return clk_set_rate_range(clk, clk->min_rate, rate);
2794 p_rate = parent->rate;
2811 /* propagate rate an accuracy recalculation accordingly */
2843 * clk topology, sysfs topology and propagate rate recalculation via
3237 seq_puts(s, " clock count count count rate accuracy phase cycle enable\n");
3264 seq_printf(s, "\"rate\": %lu,", clk_core_get_rate_recalc(c));
3654 pr_warn("** such as parent or rate setting, enabling, disabling, etc. **\n");
3728 orphan->req_rate = orphan->rate;
3738 * parent and rate and sets them both.
3744 unsigned long rate;
3817 * such as rate, parent, etc ...
3885 * Set clk's rate. The preferred method is to use .recalc_rate. For
3887 * parent's rate. If a clock doesn't have a parent (or is orphaned)
3888 * then rate is set to zero.
3891 rate = core->ops->recalc_rate(core->hw,
3894 rate = parent->rate;
3896 rate = 0;
3897 core->rate = core->req_rate = rate;
4338 static int clk_nodrv_set_rate(struct clk_hw *hw, unsigned long rate,
4620 /*** clk rate change notifiers ***/
4623 * clk_notifier_register - add a clk rate change notifier
4627 * Request notification when clk's rate changes. This uses an SRCU
4633 * In all notification cases (pre, post and abort rate change) the original
4634 * clock rate is passed to the callback via struct clk_notifier_data.old_rate
4680 * clk_notifier_unregister - remove a clk rate change notifier