Unverified Commit 112104e2 authored by Stephen Boyd's avatar Stephen Boyd
Browse files

Merge branch 'clk-determine-rate' into clk-next

* clk-determine-rate: (120 commits)
  clk: microchip: core: remove duplicate roclk_determine_rate()
  clk: nxp: Fix pll0 rate check condition in LPC18xx CGU driver
  clk: scmi: migrate round_rate() to determine_rate()
  clk: ti: fapll: convert from round_rate() to determine_rate()
  clk: ti: dra7-atl: convert from round_rate() to determine_rate()
  clk: ti: divider: convert from round_rate() to determine_rate()
  clk: ti: composite: convert from round_rate() to determine_rate()
  clk: ti: dpll: convert from round_rate() to determine_rate()
  clk: ti: dpll: change error return from ~0 to -EINVAL
  clk: ti: dpll: remove round_rate() in favor of determine_rate()
  clk: tegra: tegra210-emc: convert from round_rate() to determine_rate()
  clk: tegra: super: convert from round_rate() to determine_rate()
  clk: tegra: pll: convert from round_rate() to determine_rate()
  clk: tegra: periph: divider: convert from round_rate() to determine_rate()
  clk: tegra: divider: convert from round_rate() to determine_rate()
  clk: tegra: audio-sync: convert from round_rate() to determine_rate()
  clk: fixed-factor: drop round_rate() clk ops
  clk: divider: remove round_rate() in favor of determine_rate()
  clk: visconti: pll: convert from round_rate() to determine_rate()
  clk: versatile: vexpress-osc: convert from round_rate() to determine_rate()
  ...
parents f35f8320 7d85cd87
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -122,13 +122,13 @@ static int owl_comp_fact_set_rate(struct clk_hw *hw, unsigned long rate,
					rate, parent_rate);
}

static long owl_comp_fix_fact_round_rate(struct clk_hw *hw, unsigned long rate,
			unsigned long *parent_rate)
static int owl_comp_fix_fact_determine_rate(struct clk_hw *hw,
					    struct clk_rate_request *req)
{
	struct owl_composite *comp = hw_to_owl_comp(hw);
	struct clk_fixed_factor *fix_fact_hw = &comp->rate.fix_fact_hw;

	return comp->fix_fact_ops->round_rate(&fix_fact_hw->hw, rate, parent_rate);
	return comp->fix_fact_ops->determine_rate(&fix_fact_hw->hw, req);
}

static unsigned long owl_comp_fix_fact_recalc_rate(struct clk_hw *hw,
@@ -193,7 +193,7 @@ const struct clk_ops owl_comp_fix_fact_ops = {
	.is_enabled	= owl_comp_is_enabled,

	/* fix_fact_ops */
	.round_rate	= owl_comp_fix_fact_round_rate,
	.determine_rate = owl_comp_fix_fact_determine_rate,
	.recalc_rate	= owl_comp_fix_fact_recalc_rate,
	.set_rate	= owl_comp_fix_fact_set_rate,
};
+8 −5
Original line number Diff line number Diff line
@@ -23,13 +23,16 @@ long owl_divider_helper_round_rate(struct owl_clk_common *common,
				  div_hw->div_flags);
}

static long owl_divider_round_rate(struct clk_hw *hw, unsigned long rate,
				unsigned long *parent_rate)
static int owl_divider_determine_rate(struct clk_hw *hw,
				      struct clk_rate_request *req)
{
	struct owl_divider *div = hw_to_owl_divider(hw);

	return owl_divider_helper_round_rate(&div->common, &div->div_hw,
					     rate, parent_rate);
	req->rate = owl_divider_helper_round_rate(&div->common, &div->div_hw,
						  req->rate,
						  &req->best_parent_rate);

	return 0;
}

unsigned long owl_divider_helper_recalc_rate(struct owl_clk_common *common,
@@ -89,6 +92,6 @@ static int owl_divider_set_rate(struct clk_hw *hw, unsigned long rate,

const struct clk_ops owl_divider_ops = {
	.recalc_rate = owl_divider_recalc_rate,
	.round_rate = owl_divider_round_rate,
	.determine_rate = owl_divider_determine_rate,
	.set_rate = owl_divider_set_rate,
};
+7 −5
Original line number Diff line number Diff line
@@ -130,14 +130,16 @@ long owl_factor_helper_round_rate(struct owl_clk_common *common,
	return *parent_rate * mul / div;
}

static long owl_factor_round_rate(struct clk_hw *hw, unsigned long rate,
			unsigned long *parent_rate)
static int owl_factor_determine_rate(struct clk_hw *hw,
				     struct clk_rate_request *req)
{
	struct owl_factor *factor = hw_to_owl_factor(hw);
	struct owl_factor_hw *factor_hw = &factor->factor_hw;

	return owl_factor_helper_round_rate(&factor->common, factor_hw,
					rate, parent_rate);
	req->rate = owl_factor_helper_round_rate(&factor->common, factor_hw,
						 req->rate, &req->best_parent_rate);

	return 0;
}

unsigned long owl_factor_helper_recalc_rate(struct owl_clk_common *common,
@@ -214,7 +216,7 @@ static int owl_factor_set_rate(struct clk_hw *hw, unsigned long rate,
}

const struct clk_ops owl_factor_ops = {
	.round_rate	= owl_factor_round_rate,
	.determine_rate = owl_factor_determine_rate,
	.recalc_rate	= owl_factor_recalc_rate,
	.set_rate	= owl_factor_set_rate,
};
+16 −9
Original line number Diff line number Diff line
@@ -56,8 +56,8 @@ static const struct clk_pll_table *_get_pll_table(
	return table;
}

static long owl_pll_round_rate(struct clk_hw *hw, unsigned long rate,
		unsigned long *parent_rate)
static int owl_pll_determine_rate(struct clk_hw *hw,
				  struct clk_rate_request *req)
{
	struct owl_pll *pll = hw_to_owl_pll(hw);
	struct owl_pll_hw *pll_hw = &pll->pll_hw;
@@ -65,17 +65,24 @@ static long owl_pll_round_rate(struct clk_hw *hw, unsigned long rate,
	u32 mul;

	if (pll_hw->table) {
		clkt = _get_pll_table(pll_hw->table, rate);
		return clkt->rate;
		clkt = _get_pll_table(pll_hw->table, req->rate);
		req->rate = clkt->rate;

		return 0;
	}

	/* fixed frequency */
	if (pll_hw->width == 0)
		return pll_hw->bfreq;
	if (pll_hw->width == 0) {
		req->rate = pll_hw->bfreq;

	mul = owl_pll_calculate_mul(pll_hw, rate);
		return 0;
	}

	mul = owl_pll_calculate_mul(pll_hw, req->rate);

	return pll_hw->bfreq * mul;
	req->rate = pll_hw->bfreq * mul;

	return 0;
}

static unsigned long owl_pll_recalc_rate(struct clk_hw *hw,
@@ -188,7 +195,7 @@ const struct clk_ops owl_pll_ops = {
	.enable = owl_pll_enable,
	.disable = owl_pll_disable,
	.is_enabled = owl_pll_is_enabled,
	.round_rate = owl_pll_round_rate,
	.determine_rate = owl_pll_determine_rate,
	.recalc_rate = owl_pll_recalc_rate,
	.set_rate = owl_pll_set_rate,
};
+23 −19
Original line number Diff line number Diff line
@@ -270,8 +270,8 @@ static int clk_audio_pll_frac_determine_rate(struct clk_hw *hw,
	return 0;
}

static long clk_audio_pll_pad_round_rate(struct clk_hw *hw, unsigned long rate,
					 unsigned long *parent_rate)
static int clk_audio_pll_pad_determine_rate(struct clk_hw *hw,
					    struct clk_rate_request *req)
{
	struct clk_hw *pclk = clk_hw_get_parent(hw);
	long best_rate = -EINVAL;
@@ -283,7 +283,7 @@ static long clk_audio_pll_pad_round_rate(struct clk_hw *hw, unsigned long rate,
	int best_diff = -1;

	pr_debug("A PLL/PAD: %s, rate = %lu (parent_rate = %lu)\n", __func__,
		 rate, *parent_rate);
		 req->rate, req->best_parent_rate);

	/*
	 * Rate divisor is actually made of two different divisors, multiplied
@@ -304,12 +304,12 @@ static long clk_audio_pll_pad_round_rate(struct clk_hw *hw, unsigned long rate,
				continue;

			best_parent_rate = clk_hw_round_rate(pclk,
							rate * tmp_qd * div);
							req->rate * tmp_qd * div);
			tmp_rate = best_parent_rate / (div * tmp_qd);
			tmp_diff = abs(rate - tmp_rate);
			tmp_diff = abs(req->rate - tmp_rate);

			if (best_diff < 0 || best_diff > tmp_diff) {
				*parent_rate = best_parent_rate;
				req->best_parent_rate = best_parent_rate;
				best_rate = tmp_rate;
				best_diff = tmp_diff;
			}
@@ -318,11 +318,13 @@ static long clk_audio_pll_pad_round_rate(struct clk_hw *hw, unsigned long rate,
	pr_debug("A PLL/PAD: %s, best_rate = %ld, best_parent_rate = %lu\n",
		 __func__, best_rate, best_parent_rate);

	return best_rate;
	req->rate = best_rate;

	return 0;
}

static long clk_audio_pll_pmc_round_rate(struct clk_hw *hw, unsigned long rate,
					 unsigned long *parent_rate)
static int clk_audio_pll_pmc_determine_rate(struct clk_hw *hw,
					    struct clk_rate_request *req)
{
	struct clk_hw *pclk = clk_hw_get_parent(hw);
	long best_rate = -EINVAL;
@@ -333,20 +335,20 @@ static long clk_audio_pll_pmc_round_rate(struct clk_hw *hw, unsigned long rate,
	int best_diff = -1;

	pr_debug("A PLL/PMC: %s, rate = %lu (parent_rate = %lu)\n", __func__,
		 rate, *parent_rate);
		 req->rate, req->best_parent_rate);

	if (!rate)
	if (!req->rate)
		return 0;

	best_parent_rate = clk_round_rate(pclk->clk, 1);
	div = max(best_parent_rate / rate, 1UL);
	div = max(best_parent_rate / req->rate, 1UL);
	for (; div <= AUDIO_PLL_QDPMC_MAX; div++) {
		best_parent_rate = clk_round_rate(pclk->clk, rate * div);
		best_parent_rate = clk_round_rate(pclk->clk, req->rate * div);
		tmp_rate = best_parent_rate / div;
		tmp_diff = abs(rate - tmp_rate);
		tmp_diff = abs(req->rate - tmp_rate);

		if (best_diff < 0 || best_diff > tmp_diff) {
			*parent_rate = best_parent_rate;
			req->best_parent_rate = best_parent_rate;
			best_rate = tmp_rate;
			best_diff = tmp_diff;
			tmp_qd = div;
@@ -356,9 +358,11 @@ static long clk_audio_pll_pmc_round_rate(struct clk_hw *hw, unsigned long rate,
	}

	pr_debug("A PLL/PMC: %s, best_rate = %ld, best_parent_rate = %lu (qd = %d)\n",
		 __func__, best_rate, *parent_rate, tmp_qd - 1);
		 __func__, best_rate, req->best_parent_rate, tmp_qd - 1);

	return best_rate;
	req->rate = best_rate;

	return 0;
}

static int clk_audio_pll_frac_set_rate(struct clk_hw *hw, unsigned long rate,
@@ -436,7 +440,7 @@ static const struct clk_ops audio_pll_pad_ops = {
	.enable = clk_audio_pll_pad_enable,
	.disable = clk_audio_pll_pad_disable,
	.recalc_rate = clk_audio_pll_pad_recalc_rate,
	.round_rate = clk_audio_pll_pad_round_rate,
	.determine_rate = clk_audio_pll_pad_determine_rate,
	.set_rate = clk_audio_pll_pad_set_rate,
};

@@ -444,7 +448,7 @@ static const struct clk_ops audio_pll_pmc_ops = {
	.enable = clk_audio_pll_pmc_enable,
	.disable = clk_audio_pll_pmc_disable,
	.recalc_rate = clk_audio_pll_pmc_recalc_rate,
	.round_rate = clk_audio_pll_pmc_round_rate,
	.determine_rate = clk_audio_pll_pmc_determine_rate,
	.set_rate = clk_audio_pll_pmc_set_rate,
};

Loading