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

Commit 1922db84 authored by Deepak Katragadda's avatar Deepak Katragadda Committed by Vikram Mulukutla
Browse files

qcom: clock-generic: Allow mux source switching without using safe parent



There are muxes that allow for changing sources without
having to use the intermediate safe parent. Add support
for the same.

CRs-Fixed: 690648
Change-Id: If0ffafaadeb9c5fc5647741e1e25e70d6ed8d40f
Signed-off-by: default avatarDeepak Katragadda <dkatraga@codeaurora.org>
parent 169417fe
Loading
Loading
Loading
Loading
+12 −5
Original line number Diff line number Diff line
@@ -115,6 +115,9 @@ static int mux_set_rate(struct clk *c, unsigned long rate)
	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;
			if (!mux->try_new_parent)
				break;
			if (mux->try_new_parent && new_parent != c->parent)
				break;
		}
	}
@@ -125,9 +128,12 @@ static int mux_set_rate(struct clk *c, unsigned long rate)
	/*
	 * Switch to safe parent since the old and new parent might be the
	 * same and the parent might temporarily turn off while switching
	 * rates.
	 * rates. If the mux can switch between distinct sources safely
	 * (indicated by try_new_parent), and the new source is not the current
	 * parent, do not switch to the safe parent.
	 */
	if (mux->safe_sel >= 0) {
	if (mux->safe_sel >= 0 &&
		!(mux->try_new_parent && (new_parent != c->parent))) {
		/*
		 * The safe parent might be a clock with multiple sources;
		 * to select the "safe" source, set a safe frequency.
@@ -149,10 +155,11 @@ static int mux_set_rate(struct clk *c, unsigned long rate)
		spin_lock_irqsave(&c->lock, flags);
		rc = mux->ops->set_mux_sel(mux, mux->safe_sel);
		spin_unlock_irqrestore(&c->lock, flags);
	}
		if (rc)
			return rc;

	}

	new_par_curr_rate = clk_get_rate(new_parent);
	rc = clk_set_rate(new_parent, rate);
	if (rc)
+7 −0
Original line number Diff line number Diff line
@@ -66,6 +66,13 @@ struct mux_clk {
	 */
	bool		try_get_rate;
	struct clk_mux_ops *ops;
	/*
	 * Set if you need the mux to try a new parent before falling back to
	 * the current parent. If the safe_parent field above is set, then the
	 * safe_sel intermediate source will only be used if we fall back to
	 * to the current parent during mux_set_rate.
	 */
	bool		try_new_parent;

	/* Fields not used by helper function. */
	void *const __iomem *base;