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

Commit 2108110f authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge changes I5db4141f,I855ef1d8 into msm-next

* changes:
  clk: qcom: clk-rcg2: Clear the HW_CLK_CONTROL bit of the RCG
  clk: Add additional checking to some clock driver functions
parents 43adfd14 d5ea1177
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -285,6 +285,9 @@ static int clk_divider_bestdiv(struct clk_hw *hw, struct clk_hw *parent,
	unsigned long parent_rate, best = 0, now, maxdiv;
	unsigned long parent_rate_saved = *best_parent_rate;

	if (!hw || !parent)
		return -EINVAL;

	if (!rate)
		rate = 1;

+28 −13
Original line number Diff line number Diff line
@@ -253,13 +253,18 @@ static int clk_branch2_enable(struct clk_hw *hw)

static int clk_branch2_prepare(struct clk_hw *hw)
{
	struct clk_branch *branch = to_clk_branch(hw);
	struct clk_hw *parent = clk_hw_get_parent(hw);
	unsigned long curr_rate, branch_rate = branch->rate;
	struct clk_branch *branch;
	struct clk_hw *parent;
	unsigned long curr_rate;
	int ret = 0;

	if (!parent)
		return -EPERM;
	if (!hw)
		return -EINVAL;

	branch = to_clk_branch(hw);
	parent = clk_hw_get_parent(hw);
	if (!branch)
		return -EINVAL;

	/*
	 * Do the rate aggregation and scaling of the RCG in the prepare/
@@ -267,12 +272,15 @@ static int clk_branch2_prepare(struct clk_hw *hw)
	 * votes on the voltage rails.
	 */
	if (branch->aggr_sibling_rates) {
		if (!parent)
			return -EINVAL;
		curr_rate = clk_aggregate_rate(hw, parent->core);
		if (branch_rate > curr_rate) {
			ret = clk_set_rate(parent->clk, branch_rate);

		if (branch->rate > curr_rate) {
			ret = clk_set_rate(parent->clk, branch->rate);
			if (ret) {
				pr_err("Failed to scale %s to %lu\n",
					clk_hw_get_name(parent), branch_rate);
					clk_hw_get_name(parent), branch->rate);
				goto exit;
			}
		}
@@ -288,16 +296,23 @@ static void clk_branch2_disable(struct clk_hw *hw)

static void clk_branch2_unprepare(struct clk_hw *hw)
{
	struct clk_branch *branch = to_clk_branch(hw);
	struct clk_hw *parent = clk_hw_get_parent(hw);
	unsigned long curr_rate, new_rate, branch_rate = branch->rate;
	struct clk_branch *branch;
	struct clk_hw *parent;
	unsigned long curr_rate, new_rate;

	if (!parent)
	if (!hw)
		return;

	branch = to_clk_branch(hw);
	parent = clk_hw_get_parent(hw);
	if (!branch)
		return;

	if (branch->aggr_sibling_rates) {
		if (!parent)
			return;
		new_rate = clk_aggregate_rate(hw, parent->core);
		curr_rate = max(new_rate, branch_rate);
		curr_rate = max(new_rate, branch->rate);
		if (new_rate < curr_rate)
			if (clk_set_rate(parent->clk, new_rate))
				pr_err("Failed to scale %s to %lu\n",
+12 −3
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@
#define CFG_MODE_SHIFT		12
#define CFG_MODE_MASK		(0x3 << CFG_MODE_SHIFT)
#define CFG_MODE_DUAL_EDGE	(0x2 << CFG_MODE_SHIFT)
#define CFG_HW_CLK_CTRL_MASK	BIT(20)

#define M_REG			0x8
#define N_REG			0xc
@@ -396,7 +397,7 @@ static int clk_rcg2_configure(struct clk_rcg2 *rcg, const struct freq_tbl *f)
	}

	mask = BIT(rcg->hid_width) - 1;
	mask |= CFG_SRC_SEL_MASK | CFG_MODE_MASK;
	mask |= CFG_SRC_SEL_MASK | CFG_MODE_MASK | CFG_HW_CLK_CTRL_MASK;
	cfg = f->pre_div << CFG_SRC_DIV_SHIFT;
	cfg |= rcg->parent_map[index].cfg << CFG_SRC_SEL_SHIFT;
	if (rcg->mnd_width && f->n && (f->m != f->n))
@@ -1085,6 +1086,7 @@ static int clk_dp_set_rate(struct clk_hw *hw, unsigned long rate,
			unsigned long parent_rate)
{
	struct clk_rcg2 *rcg = to_clk_rcg2(hw);
	struct clk_hw *parent = clk_hw_get_parent(hw);
	struct freq_tbl f = { 0 };
	unsigned long src_rate;
	unsigned long num, den;
@@ -1092,7 +1094,12 @@ static int clk_dp_set_rate(struct clk_hw *hw, unsigned long rate,
	u32 hid_div, cfg;
	int i, num_parents = clk_hw_get_num_parents(hw);

	src_rate = clk_get_rate(clk_hw_get_parent(hw)->clk);
	if (!parent) {
		pr_err("RCG parent isn't initialized\n");
		return -EINVAL;
	}

	src_rate = clk_get_rate(parent->clk);
	if (src_rate <= 0) {
		pr_err("Invalid RCG parent rate\n");
		return -EINVAL;
@@ -1253,13 +1260,15 @@ static u8 clk_parent_index_pre_div_and_mode(struct clk_hw *hw, u32 offset,
		u32 *mode, u32 *pre_div)
{
	struct clk_rcg2 *rcg;
	int num_parents = clk_hw_get_num_parents(hw);
	int num_parents;
	u32 cfg, mask;
	int i, ret;

	if (!hw)
		return -EINVAL;

	num_parents = clk_hw_get_num_parents(hw);

	rcg = to_clk_rcg2(hw);

	ret = regmap_read(rcg->clkr.regmap, rcg->cmd_rcgr + offset, &cfg);