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

Commit e820557c authored by Deepak Katragadda's avatar Deepak Katragadda Committed by Matt Wagantall
Browse files

clk: msm: clock-local: Add a new force_enable_md flag



In some cases, the RCG needs to be force enabled prior to
powering up the core. Add the force_enable_md flag to the
clock structure for which this is needed.

Change-Id: I66fc71aed18966e7a81a126eb04c6a369649330d
Signed-off-by: default avatarDeepak Katragadda <dkatraga@codeaurora.org>
parent 2c014ea4
Loading
Loading
Loading
Loading
+41 −0
Original line number Diff line number Diff line
@@ -1707,6 +1707,41 @@ static void rcg_get_src_div(struct mux_div_clk *md, u32 *src_sel, u32 *div)
	spin_unlock_irqrestore(&local_clock_reg_lock, flags);
}

static void mux_div_set_force_enable(struct mux_div_clk *md)
{
	u32 regval;
	unsigned long flags;
	int count;

	spin_lock_irqsave(&local_clock_reg_lock, flags);
	regval = readl_relaxed(RCGR_CMD_REG(md));
	regval |= CMD_RCGR_ROOT_ENABLE_BIT;
	writel_relaxed(regval, RCGR_CMD_REG(md));

	/* Wait for RCG to turn ON */
	for (count = UPDATE_CHECK_MAX_LOOPS; count > 0; count--) {
		if (!(readl_relaxed(RCGR_CMD_REG(md)) &
				CMD_RCGR_CONFIG_UPDATE_BIT))
			goto exit;
		udelay(1);
	}
	CLK_WARN(&md->c, count == 0, "rcg didn't turn on.");
exit:
	spin_unlock_irqrestore(&local_clock_reg_lock, flags);
}

static void mux_div_clear_force_enable(struct mux_div_clk *md)
{
	u32 regval;
	unsigned long flags;

	spin_lock_irqsave(&local_clock_reg_lock, flags);
	regval = readl_relaxed(RCGR_CMD_REG(md));
	regval &= ~CMD_RCGR_ROOT_ENABLE_BIT;
	writel_relaxed(regval, RCGR_CMD_REG(md));
	spin_unlock_irqrestore(&local_clock_reg_lock, flags);
}

static int rcg_set_src_div(struct mux_div_clk *md, u32 src_sel, u32 div)
{
	u32 regval;
@@ -1735,6 +1770,9 @@ static int rcg_set_src_div(struct mux_div_clk *md, u32 src_sel, u32 div)

static int rcg_enable(struct mux_div_clk *md)
{
	if (md->force_enable_md)
		mux_div_set_force_enable(md);

	return rcg_set_src_div(md, md->src_sel, md->data.div);
}

@@ -1742,6 +1780,9 @@ static void rcg_disable(struct mux_div_clk *md)
{
	u32 src_sel;

	if (md->force_enable_md)
		mux_div_clear_force_enable(md);

	if (!md->safe_freq)
		return;

+4 −0
Original line number Diff line number Diff line
@@ -258,6 +258,9 @@ struct mux_div_ops {
 * @try_get_rate
		Set if you need the mux to directly jump to a source
		that is at the desired rate currently.
 * @force_enable_md
		Set if the mux-div needs to be force enabled/disabled during
		clk_enable/disable.
 */

struct mux_div_clk {
@@ -288,6 +291,7 @@ struct mux_div_clk {
	struct clk			*safe_parent;
	unsigned long			safe_freq;
	bool				try_get_rate;
	bool				force_enable_md;
};

static inline struct mux_div_clk *to_mux_div_clk(struct clk *clk)