Lines Matching defs:rate
67 unsigned long rate;
484 return core->rate;
488 * known yet. Best to return 0 as the rate of this clk until we can
489 * properly recalc the rate based on the parent's rate.
541 static bool mux_is_better_rate(unsigned long rate, unsigned long now,
545 return abs(now - rate) < abs(best - rate);
547 return now <= rate && now > best;
552 unsigned long rate);
610 req->rate = 0;
615 req->rate);
625 best = parent_req.rate;
633 req->rate = best;
650 /* find the parent that can provide the fastest rate <= rate */
662 clk_core_forward_rate_req(core, req, parent, &parent_req, req->rate);
672 parent_rate = parent_req.rate;
677 if (mux_is_better_rate(req->rate, parent_rate,
689 req->rate = best;
721 * clk_hw_get_rate_range() - returns the clock rate range for a hw clk
764 * @hw: mux type clk to determine rate on
765 * @req: rate request, also used to return preferred parent and frequencies
789 * @hw: mux type clk to determine rate on
790 * @req: rate request, also used to return preferred frequency
792 * Helper for finding best parent rate to provide a given frequency.
845 * clk_rate_exclusive_put - release exclusivity over clock rate control
850 * clock which could result in a rate change or rate glitch. Exclusive clocks
851 * cannot have their rate changed, either directly or indirectly due to changes
856 * the rate effectively gets locked as exclusivity can't be preempted.
911 * clk_rate_exclusive_get - get exclusivity over the clk rate control
912 * @clk: the clk over which the exclusity of rate control is requested
916 * clock which could result in a rate change or rate glitch. Exclusive clocks
917 * cannot have their rate changed, either directly or indirectly due to changes
922 * the rate effectively gets locked as exclusivity can't be preempted.
1035 * Instead of a consumer claiming exclusive rate control, it is
1037 * operation which could result in a rate change or rate glitch while
1465 long rate;
1476 * If it's the case, clamping the rate is equivalent to setting
1477 * the rate to 0 which is bad. Skip the clamping but complain so
1481 pr_warn("%s: %s: clk_rate_request has initialized min or max rate.\n",
1484 req->rate = clamp(req->rate, req->min_rate, req->max_rate);
1493 req->rate = core->rate;
1497 rate = core->ops->round_rate(core->hw, req->rate,
1499 if (rate < 0)
1500 return rate;
1502 req->rate = rate;
1512 unsigned long rate)
1526 req->rate = rate;
1532 req->best_parent_rate = parent->rate;
1541 * @hw: the clk for which we want to submit a rate request
1543 * @rate: the rate which is to be requested
1550 unsigned long rate)
1555 clk_core_init_rate_req(hw->core, req, rate);
1561 * @hw: the original clock that got the rate request
1565 * @parent_rate: The rate which is to be requested to @parent
1598 req->rate = 0;
1608 clk_core_forward_rate_req(core, req, core->parent, &parent_req, req->rate);
1618 req->best_parent_rate = parent_req.rate;
1619 req->rate = parent_req.rate;
1624 req->rate = core->rate;
1629 * __clk_determine_rate - get the closest rate actually supported by a clock
1630 * @hw: determine the rate of this clock
1631 * @req: target rate request
1638 req->rate = 0;
1647 * clk_hw_round_rate() - round the given rate for a hw clk
1648 * @hw: the hw clk for which we are rounding a rate
1649 * @rate: the rate which is to be rounded
1651 * Takes in a rate as input and rounds it to a rate that the clk can actually
1658 * Return: returns rounded rate of hw clk if clk supports round_rate operation
1659 * else returns the parent rate.
1661 unsigned long clk_hw_round_rate(struct clk_hw *hw, unsigned long rate)
1666 clk_core_init_rate_req(hw->core, &req, rate);
1676 return req.rate;
1681 * clk_round_rate - round the given rate for a clk
1682 * @clk: the clk for which we are rounding a rate
1683 * @rate: the rate which is to be rounded
1685 * Takes in a rate as input and rounds it to a rate that the clk can actually
1687 * then the parent rate is returned.
1689 long clk_round_rate(struct clk *clk, unsigned long rate)
1702 clk_core_init_rate_req(clk->core, &req, rate);
1718 return req.rate;
1724 * @core: clk that is changing rate
1726 * @old_rate: old clk rate
1727 * @new_rate: new clk rate
1729 * Triggers a notifier call chain on the clk rate-change notification
1823 unsigned long rate = parent_rate;
1826 rate = core->ops->recalc_rate(core->hw, parent_rate);
1829 return rate;
1835 * @update_req: Whether req_rate should be updated with the new rate
1840 * it is assumed that the clock will take on the rate of its parent.
1854 old_rate = core->rate;
1857 parent_rate = core->parent->rate;
1859 core->rate = clk_recalc(core, parent_rate);
1861 core->req_rate = core->rate;
1868 __clk_notify(core, msg, old_rate, core->rate);
1883 * clk_get_rate - return the rate of clk
1884 * @clk: the clk whose rate is being returned
1886 * Simply returns the cached rate of the clk, unless CLK_GET_RATE_NOCACHE flag
1893 unsigned long rate;
1899 rate = clk_core_get_rate_recalc(clk->core);
1902 return rate;
2107 * @parent_rate: the "future" rate of clk's parent
2113 * pre-rate change notifications and returns early if no clks in the
2116 * take on the rate of its parent.
2129 /* abort rate change if a driver returns NOTIFY_BAD or NOTIFY_STOP */
2131 ret = __clk_notify(core, PRE_RATE_CHANGE, core->rate, new_rate);
2173 unsigned long rate)
2188 /* save parent rate, if it exists */
2191 best_parent_rate = parent->rate;
2195 /* find the closest rate and parent clk/rate */
2199 clk_core_init_rate_req(core, &req, rate);
2210 new_rate = req.rate;
2217 core->new_rate = core->rate;
2221 top = clk_calc_new_rates(parent, rate);
2245 best_parent_rate != parent->rate)
2255 * Notify about rate changes in a subtree. Always walk down the whole tree
2265 if (core->rate == core->new_rate)
2269 ret = __clk_notify(core, event, core->rate, core->new_rate);
2294 * walk down a subtree and set the new rates notifying the rate
2307 old_rate = core->rate;
2311 best_parent_rate = core->new_parent->rate;
2314 best_parent_rate = core->parent->rate;
2352 core->rate = clk_recalc(core, best_parent_rate);
2362 if (core->notifier_count && old_rate != core->rate)
2363 __clk_notify(core, POST_RATE_CHANGE, old_rate, core->rate);
2397 /* simulate what the rate would be if it could be freely set */
2413 return ret ? 0 : req.rate;
2420 unsigned long rate;
2426 rate = clk_core_req_round_rate_nolock(core, req_rate);
2429 if (rate == clk_core_get_rate_nolock(core))
2432 /* fail on a direct rate set of a protected provider */
2448 pr_debug("%s: failed to set %s rate\n", __func__,
2466 * clk_set_rate - specify a new rate for clk
2467 * @clk: the clk whose rate is being changed
2468 * @rate: the new rate for clk
2470 * In the simplest case clk_set_rate will only adjust the rate of clk.
2472 * Setting the CLK_SET_RATE_PARENT flag allows the rate change operation to
2476 * *parent_rate comes back with a new rate for clk's parent then we propagate
2477 * up to clk's parent and set its rate. Upward propagation will continue
2486 int clk_set_rate(struct clk *clk, unsigned long rate)
2499 ret = clk_core_set_rate_nolock(clk->core, rate);
2511 * clk_set_rate_exclusive - specify a new rate and get exclusive control
2512 * @clk: the clk whose rate is being changed
2513 * @rate: the new rate for clk
2522 * The exclusivity is not applied if setting the rate failed.
2529 int clk_set_rate_exclusive(struct clk *clk, unsigned long rate)
2545 ret = clk_core_set_rate_nolock(clk->core, rate);
2562 unsigned long old_min, old_max, rate;
2592 rate = clk->core->req_rate;
2594 rate = clk_core_get_rate_recalc(clk->core);
2598 * opportunity to the provider to adjust the clock rate based on
2602 * outside of the boundaries. Clamping the last requested rate
2611 * this corner case when determining the rate
2613 rate = clamp(rate, min, max);
2614 ret = clk_core_set_rate_nolock(clk->core, rate);
2629 * clk_set_rate_range - set a rate range for a clock source
2631 * @min: desired minimum clock rate in Hz, inclusive
2632 * @max: desired maximum clock rate in Hz, inclusive
2654 * clk_set_min_rate - set a minimum clock rate for a clock source
2656 * @rate: desired minimum clock rate in Hz, inclusive
2660 int clk_set_min_rate(struct clk *clk, unsigned long rate)
2665 trace_clk_set_min_rate(clk->core, rate);
2667 return clk_set_rate_range(clk, rate, clk->max_rate);
2672 * clk_set_max_rate - set a maximum clock rate for a clock source
2674 * @rate: desired maximum clock rate in Hz, inclusive
2678 int clk_set_max_rate(struct clk *clk, unsigned long rate)
2683 trace_clk_set_max_rate(clk->core, rate);
2685 return clk_set_rate_range(clk, clk->min_rate, rate);
2791 p_rate = parent->rate;
2808 /* propagate rate an accuracy recalculation accordingly */
2840 * clk topology, sysfs topology and propagate rate recalculation via
3234 seq_puts(s, " clock count count count rate accuracy phase cycle enable\n");
3261 seq_printf(s, "\"rate\": %lu,", clk_core_get_rate_recalc(c));
3651 pr_warn("** such as parent or rate setting, enabling, disabling, etc. **\n");
3725 orphan->req_rate = orphan->rate;
3735 * parent and rate and sets them both.
3741 unsigned long rate;
3814 * such as rate, parent, etc ...
3882 * Set clk's rate. The preferred method is to use .recalc_rate. For
3884 * parent's rate. If a clock doesn't have a parent (or is orphaned)
3885 * then rate is set to zero.
3888 rate = core->ops->recalc_rate(core->hw,
3891 rate = parent->rate;
3893 rate = 0;
3894 core->rate = core->req_rate = rate;
4335 static int clk_nodrv_set_rate(struct clk_hw *hw, unsigned long rate,
4617 /*** clk rate change notifiers ***/
4620 * clk_notifier_register - add a clk rate change notifier
4624 * Request notification when clk's rate changes. This uses an SRCU
4630 * In all notification cases (pre, post and abort rate change) the original
4631 * clock rate is passed to the callback via struct clk_notifier_data.old_rate
4677 * clk_notifier_unregister - remove a clk rate change notifier