summaryrefslogtreecommitdiffstats
path: root/drivers/sh/clk.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/sh/clk.c')
-rw-r--r--drivers/sh/clk.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/drivers/sh/clk.c b/drivers/sh/clk.c
index 3ac6fa0005b9..018be37ef339 100644
--- a/drivers/sh/clk.c
+++ b/drivers/sh/clk.c
@@ -76,7 +76,7 @@ struct clk_rate_round_data;
struct clk_rate_round_data {
unsigned long rate;
unsigned int min, max;
- long (*func)(unsigned int pos, struct clk_rate_round_data *arg);
+ long (*func)(unsigned int, struct clk_rate_round_data *);
void *arg;
};
@@ -148,6 +148,26 @@ long clk_rate_table_round(struct clk *clk,
return clk_rate_round_helper(&table_round);
}
+static long clk_rate_div_range_iter(unsigned int pos,
+ struct clk_rate_round_data *rounder)
+{
+ return clk_get_rate(rounder->arg) / pos;
+}
+
+long clk_rate_div_range_round(struct clk *clk, unsigned int div_min,
+ unsigned int div_max, unsigned long rate)
+{
+ struct clk_rate_round_data div_range_round = {
+ .min = div_min,
+ .max = div_max,
+ .func = clk_rate_div_range_iter,
+ .arg = clk_get_parent(clk),
+ .rate = rate,
+ };
+
+ return clk_rate_round_helper(&div_range_round);
+}
+
int clk_rate_table_find(struct clk *clk,
struct cpufreq_frequency_table *freq_table,
unsigned long rate)
OpenPOWER on IntegriCloud