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

Commit dd2c0ca1 authored by Kuninori Morimoto's avatar Kuninori Morimoto Committed by Paul Mundt
Browse files

sh: clkfwk: add clk_rate_mult_range_round()



This provides a clk_rate_mult_range_round() helper for use by some of the
CPG PLL ranged multipliers, following the same approach as used by the
div ranges.

Signed-off-by: default avatarKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: default avatarPaul Mundt <lethal@linux-sh.org>
parent 1a67a573
Loading
Loading
Loading
Loading
+20 −0
Original line number Original line Diff line number Diff line
@@ -173,6 +173,26 @@ long clk_rate_div_range_round(struct clk *clk, unsigned int div_min,
	return clk_rate_round_helper(&div_range_round);
	return clk_rate_round_helper(&div_range_round);
}
}


static long clk_rate_mult_range_iter(unsigned int pos,
				      struct clk_rate_round_data *rounder)
{
	return clk_get_rate(rounder->arg) * pos;
}

long clk_rate_mult_range_round(struct clk *clk, unsigned int mult_min,
			       unsigned int mult_max, unsigned long rate)
{
	struct clk_rate_round_data mult_range_round = {
		.min	= mult_min,
		.max	= mult_max,
		.func	= clk_rate_mult_range_iter,
		.arg	= clk_get_parent(clk),
		.rate	= rate,
	};

	return clk_rate_round_helper(&mult_range_round);
}

int clk_rate_table_find(struct clk *clk,
int clk_rate_table_find(struct clk *clk,
			struct cpufreq_frequency_table *freq_table,
			struct cpufreq_frequency_table *freq_table,
			unsigned long rate)
			unsigned long rate)
+3 −0
Original line number Original line Diff line number Diff line
@@ -94,6 +94,9 @@ int clk_rate_table_find(struct clk *clk,
long clk_rate_div_range_round(struct clk *clk, unsigned int div_min,
long clk_rate_div_range_round(struct clk *clk, unsigned int div_min,
			      unsigned int div_max, unsigned long rate);
			      unsigned int div_max, unsigned long rate);


long clk_rate_mult_range_round(struct clk *clk, unsigned int mult_min,
			       unsigned int mult_max, unsigned long rate);

long clk_round_parent(struct clk *clk, unsigned long target,
long clk_round_parent(struct clk *clk, unsigned long target,
		      unsigned long *best_freq, unsigned long *parent_freq,
		      unsigned long *best_freq, unsigned long *parent_freq,
		      unsigned int div_min, unsigned int div_max);
		      unsigned int div_min, unsigned int div_max);