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

Commit b7a7e662 authored by Saravana Kannan's avatar Saravana Kannan Committed by Stephen Boyd
Browse files

msm: clock-generic: Add support for recursive set parent to mux_clk



When there are a bunch of nested muxes and a consumer calls
clk_set_parent() on the top level mux, it's possible that the consumer
doesn't care if the new parent is an immediate parent to the top level mux
and just wants the output from the new parent. So, recursively search for
the new parent (if recursive set parent is enabled for the mux) and get the
output of the new parent even if it has to go through multiple levels of
consecutive muxes.

Change-Id: Ibf76f11587e7c00fe1d34ce956e5a73c8db73e65
Signed-off-by: default avatarSaravana Kannan <skannan@codeaurora.org>
parent c2d6a213
Loading
Loading
Loading
Loading
+16 −1
Original line number Diff line number Diff line
@@ -39,9 +39,24 @@ static int mux_set_parent(struct clk *c, struct clk *p)
	struct mux_clk *mux = to_mux_clk(c);
	int sel = parent_to_src_sel(mux, p);
	struct clk *old_parent;
	int rc = 0;
	int rc = 0, i;
	unsigned long flags;

	if (sel < 0 && mux->rec_set_par) {
		for (i = 0; i < mux->num_parents; i++) {
			rc = clk_set_parent(mux->parents[i].src, p);
			if (!rc) {
				sel = mux->parents[i].sel;
				/*
				 * This is necessary to ensure prepare/enable
				 * counts get propagated correctly.
				 */
				p = mux->parents[i].src;
				break;
			}
		}
	}

	if (sel < 0)
		return sel;

+2 −0
Original line number Diff line number Diff line
@@ -46,6 +46,8 @@ struct mux_clk {
	struct clk	*safe_parent;
	int		safe_sel;
	struct clk_mux_ops *ops;
	/* Recursively search for the requested parent. */
	bool		rec_set_par;

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