Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2ee4021c authored by Vikram Mulukutla's avatar Vikram Mulukutla
Browse files

qcom: clock-generic: Check if a parent is already at a requested rate



If it is guaranteed that taking the prepare lock of a
clock ensures that the rate of downstream sources cannot
change, a mux between that clock and those downstream sources
can safely check the rate of those sources using clk_get_rate
and use clk_round_rate to request new rates.

Sometimes, the first source on a mux may be able to support a
requested rate, but a subsequent source may already be at that
rate. Use clk_get_rate instead of clk_round_rate to find the
latter source instead of reprogramming the former.

Change-Id: I950a04e005c413559b392d847ef3dff4f7d61ef5
Signed-off-by: default avatarVikram Mulukutla <markivx@codeaurora.org>
parent 3511ae2a
Loading
Loading
Loading
Loading
+16 −1
Original line number Diff line number Diff line
@@ -98,12 +98,27 @@ static int mux_set_rate(struct clk *c, unsigned long rate)
	unsigned long new_par_curr_rate;
	unsigned long flags;

	for (i = 0; i < mux->num_parents; i++) {
	/*
	 * Check if one of the possible parents is already at the requested
	 * rate.
	 */
	for (i = 0; i < mux->num_parents && mux->try_get_rate; i++) {
		if (mux->parents[i].src->rate == rate) {
			new_parent = mux->parents[i].src;
			break;
		}
	}

	if (new_parent == c->parent && rate == c->rate)
		return 0;

	for (i = 0; i < mux->num_parents && !new_parent; i++) {
		if (clk_round_rate(mux->parents[i].src, rate) == rate) {
			new_parent = mux->parents[i].src;
			break;
		}
	}

	if (new_parent == NULL)
		return -EINVAL;

+6 −0
Original line number Diff line number Diff line
@@ -59,6 +59,12 @@ struct mux_clk {
	struct clk	*safe_parent;
	int		safe_sel;
	unsigned long	safe_freq;
	/*
	 * Before attempting a clk_round_rate on available sources, attempt a
	 * clk_get_rate on all those sources. If one of them is already at the
	 * necessary rate, that source will be used.
	 */
	bool		try_get_rate;
	struct clk_mux_ops *ops;

	/* Fields not used by helper function. */