Lines Matching defs:rate
72 unsigned long rate;
575 return core->rate;
579 * known yet. Best to return 0 as the rate of this clk until we can
580 * properly recalc the rate based on the parent's rate.
632 static bool mux_is_better_rate(unsigned long rate, unsigned long now,
636 return abs(now - rate) < abs(best - rate);
638 return now <= rate && now > best;
643 unsigned long rate);
701 req->rate = 0;
706 req->rate);
716 best = parent_req.rate;
724 req->rate = best;
741 /* find the parent that can provide the fastest rate <= rate */
753 clk_core_forward_rate_req(core, req, parent, &parent_req, req->rate);
763 parent_rate = parent_req.rate;
768 if (mux_is_better_rate(req->rate, parent_rate,
780 req->rate = best;
812 * clk_hw_get_rate_range() - returns the clock rate range for a hw clk
855 * @hw: mux type clk to determine rate on
856 * @req: rate request, also used to return preferred parent and frequencies
880 * @hw: mux type clk to determine rate on
881 * @req: rate request, also used to return preferred frequency
883 * Helper for finding best parent rate to provide a given frequency.
936 * clk_rate_exclusive_put - release exclusivity over clock rate control
941 * clock which could result in a rate change or rate glitch. Exclusive clocks
942 * cannot have their rate changed, either directly or indirectly due to changes
947 * the rate effectively gets locked as exclusivity can't be preempted.
1002 * clk_rate_exclusive_get - get exclusivity over the clk rate control
1003 * @clk: the clk over which the exclusity of rate control is requested
1007 * clock which could result in a rate change or rate glitch. Exclusive clocks
1008 * cannot have their rate changed, either directly or indirectly due to changes
1013 * the rate effectively gets locked as exclusivity can't be preempted.
1126 * Instead of a consumer claiming exclusive rate control, it is
1128 * operation which could result in a rate change or rate glitch while
1556 long rate;
1567 * If it's the case, clamping the rate is equivalent to setting
1568 * the rate to 0 which is bad. Skip the clamping but complain so
1572 pr_warn("%s: %s: clk_rate_request has initialized min or max rate.\n",
1575 req->rate = clamp(req->rate, req->min_rate, req->max_rate);
1584 req->rate = core->rate;
1588 rate = core->ops->round_rate(core->hw, req->rate,
1590 if (rate < 0)
1591 return rate;
1593 req->rate = rate;
1603 unsigned long rate)
1617 req->rate = rate;
1623 req->best_parent_rate = parent->rate;
1632 * @hw: the clk for which we want to submit a rate request
1634 * @rate: the rate which is to be requested
1641 unsigned long rate)
1646 clk_core_init_rate_req(hw->core, req, rate);
1652 * @hw: the original clock that got the rate request
1656 * @parent_rate: The rate which is to be requested to @parent
1689 req->rate = 0;
1699 clk_core_forward_rate_req(core, req, core->parent, &parent_req, req->rate);
1709 req->best_parent_rate = parent_req.rate;
1710 req->rate = parent_req.rate;
1715 req->rate = core->rate;
1720 * __clk_determine_rate - get the closest rate actually supported by a clock
1721 * @hw: determine the rate of this clock
1722 * @req: target rate request
1729 req->rate = 0;
1738 * clk_hw_round_rate() - round the given rate for a hw clk
1739 * @hw: the hw clk for which we are rounding a rate
1740 * @rate: the rate which is to be rounded
1742 * Takes in a rate as input and rounds it to a rate that the clk can actually
1749 * Return: returns rounded rate of hw clk if clk supports round_rate operation
1750 * else returns the parent rate.
1752 unsigned long clk_hw_round_rate(struct clk_hw *hw, unsigned long rate)
1757 clk_core_init_rate_req(hw->core, &req, rate);
1767 return req.rate;
1772 * clk_round_rate - round the given rate for a clk
1773 * @clk: the clk for which we are rounding a rate
1774 * @rate: the rate which is to be rounded
1776 * Takes in a rate as input and rounds it to a rate that the clk can actually
1778 * then the parent rate is returned.
1780 long clk_round_rate(struct clk *clk, unsigned long rate)
1793 clk_core_init_rate_req(clk->core, &req, rate);
1809 return req.rate;
1815 * @core: clk that is changing rate
1817 * @old_rate: old clk rate
1818 * @new_rate: new clk rate
1820 * Triggers a notifier call chain on the clk rate-change notification
1914 unsigned long rate = parent_rate;
1917 rate = core->ops->recalc_rate(core->hw, parent_rate);
1920 return rate;
1926 * @update_req: Whether req_rate should be updated with the new rate
1931 * it is assumed that the clock will take on the rate of its parent.
1945 old_rate = core->rate;
1948 parent_rate = core->parent->rate;
1950 core->rate = clk_recalc(core, parent_rate);
1952 core->req_rate = core->rate;
1959 __clk_notify(core, msg, old_rate, core->rate);
1974 * clk_get_rate - return the rate of clk
1975 * @clk: the clk whose rate is being returned
1977 * Simply returns the cached rate of the clk, unless CLK_GET_RATE_NOCACHE flag
1984 unsigned long rate;
1990 rate = clk_core_get_rate_recalc(clk->core);
1993 return rate;
2198 * @parent_rate: the "future" rate of clk's parent
2204 * pre-rate change notifications and returns early if no clks in the
2207 * take on the rate of its parent.
2220 /* abort rate change if a driver returns NOTIFY_BAD or NOTIFY_STOP */
2222 ret = __clk_notify(core, PRE_RATE_CHANGE, core->rate, new_rate);
2264 unsigned long rate)
2279 /* save parent rate, if it exists */
2282 best_parent_rate = parent->rate;
2286 /* find the closest rate and parent clk/rate */
2290 clk_core_init_rate_req(core, &req, rate);
2301 new_rate = req.rate;
2308 core->new_rate = core->rate;
2312 top = clk_calc_new_rates(parent, rate);
2336 best_parent_rate != parent->rate)
2346 * Notify about rate changes in a subtree. Always walk down the whole tree
2356 if (core->rate == core->new_rate)
2360 ret = __clk_notify(core, event, core->rate, core->new_rate);
2385 * walk down a subtree and set the new rates notifying the rate
2398 old_rate = core->rate;
2402 best_parent_rate = core->new_parent->rate;
2405 best_parent_rate = core->parent->rate;
2443 core->rate = clk_recalc(core, best_parent_rate);
2453 if (core->notifier_count && old_rate != core->rate)
2454 __clk_notify(core, POST_RATE_CHANGE, old_rate, core->rate);
2488 /* simulate what the rate would be if it could be freely set */
2504 return ret ? 0 : req.rate;
2511 unsigned long rate;
2517 rate = clk_core_req_round_rate_nolock(core, req_rate);
2520 if (rate == clk_core_get_rate_nolock(core))
2523 /* fail on a direct rate set of a protected provider */
2539 pr_debug("%s: failed to set %s rate\n", __func__,
2557 * clk_set_rate - specify a new rate for clk
2558 * @clk: the clk whose rate is being changed
2559 * @rate: the new rate for clk
2561 * In the simplest case clk_set_rate will only adjust the rate of clk.
2563 * Setting the CLK_SET_RATE_PARENT flag allows the rate change operation to
2567 * *parent_rate comes back with a new rate for clk's parent then we propagate
2568 * up to clk's parent and set its rate. Upward propagation will continue
2577 int clk_set_rate(struct clk *clk, unsigned long rate)
2590 ret = clk_core_set_rate_nolock(clk->core, rate);
2602 * clk_set_rate_exclusive - specify a new rate and get exclusive control
2603 * @clk: the clk whose rate is being changed
2604 * @rate: the new rate for clk
2613 * The exclusivity is not applied if setting the rate failed.
2620 int clk_set_rate_exclusive(struct clk *clk, unsigned long rate)
2636 ret = clk_core_set_rate_nolock(clk->core, rate);
2653 unsigned long old_min, old_max, rate;
2683 rate = clk->core->req_rate;
2685 rate = clk_core_get_rate_recalc(clk->core);
2689 * opportunity to the provider to adjust the clock rate based on
2693 * outside of the boundaries. Clamping the last requested rate
2702 * this corner case when determining the rate
2704 rate = clamp(rate, min, max);
2705 ret = clk_core_set_rate_nolock(clk->core, rate);
2720 * clk_set_rate_range - set a rate range for a clock source
2722 * @min: desired minimum clock rate in Hz, inclusive
2723 * @max: desired maximum clock rate in Hz, inclusive
2745 * clk_set_min_rate - set a minimum clock rate for a clock source
2747 * @rate: desired minimum clock rate in Hz, inclusive
2751 int clk_set_min_rate(struct clk *clk, unsigned long rate)
2756 trace_clk_set_min_rate(clk->core, rate);
2758 return clk_set_rate_range(clk, rate, clk->max_rate);
2763 * clk_set_max_rate - set a maximum clock rate for a clock source
2765 * @rate: desired maximum clock rate in Hz, inclusive
2769 int clk_set_max_rate(struct clk *clk, unsigned long rate)
2774 trace_clk_set_max_rate(clk->core, rate);
2776 return clk_set_rate_range(clk, clk->min_rate, rate);
2882 p_rate = parent->rate;
2899 /* propagate rate an accuracy recalculation accordingly */
2931 * clk topology, sysfs topology and propagate rate recalculation via
3337 seq_puts(s, " clock count count count rate accuracy phase cycle enable consumer id\n");
3369 seq_printf(s, "\"rate\": %lu,", clk_core_get_rate_recalc(c));
3766 pr_warn("** such as parent or rate setting, enabling, disabling, etc. **\n");
3840 orphan->req_rate = orphan->rate;
3850 * parent and rate and sets them both.
3856 unsigned long rate;
3929 * such as rate, parent, etc ...
3997 * Set clk's rate. The preferred method is to use .recalc_rate. For
3999 * parent's rate. If a clock doesn't have a parent (or is orphaned)
4000 * then rate is set to zero.
4003 rate = core->ops->recalc_rate(core->hw,
4006 rate = parent->rate;
4008 rate = 0;
4009 core->rate = core->req_rate = rate;
4451 static int clk_nodrv_set_rate(struct clk_hw *hw, unsigned long rate,
4731 /*** clk rate change notifiers ***/
4734 * clk_notifier_register - add a clk rate change notifier
4738 * Request notification when clk's rate changes. This uses an SRCU
4744 * In all notification cases (pre, post and abort rate change) the original
4745 * clock rate is passed to the callback via struct clk_notifier_data.old_rate
4791 * clk_notifier_unregister - remove a clk rate change notifier