[PATCH 16/29] clk: clk-fixed-factor: add set_rate/round_rate callbacks
Sascha Hauer
s.hauer at pengutronix.de
Fri Mar 14 10:32:36 EDT 2014
Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
drivers/clk/clk-fixed-factor.c | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/drivers/clk/clk-fixed-factor.c b/drivers/clk/clk-fixed-factor.c
index df0d2f3..cb531b1 100644
--- a/drivers/clk/clk-fixed-factor.c
+++ b/drivers/clk/clk-fixed-factor.c
@@ -35,7 +35,37 @@ static unsigned long clk_fixed_factor_recalc_rate(struct clk *clk,
return (parent_rate / f->div) * f->mult;
}
+static long clk_factor_round_rate(struct clk *clk, unsigned long rate,
+ unsigned long *prate)
+{
+ struct clk_fixed_factor *fix = container_of(clk, struct clk_fixed_factor, clk);
+
+ if (clk->flags & CLK_SET_RATE_PARENT) {
+ unsigned long best_parent;
+
+ best_parent = (rate / fix->mult) * fix->div;
+ *prate = clk_round_rate(clk_get_parent(clk), best_parent);
+ }
+
+ return (*prate / fix->div) * fix->mult;
+}
+
+static int clk_factor_set_rate(struct clk *clk, unsigned long rate,
+ unsigned long parent_rate)
+{
+ struct clk_fixed_factor *fix = container_of(clk, struct clk_fixed_factor, clk);
+
+ if (clk->flags & CLK_SET_RATE_PARENT) {
+ printk("%s: %ld -> parent %ld\n", __func__, rate, rate * fix->div / fix->mult);
+ return clk_set_rate(clk_get_parent(clk), rate * fix->div / fix->mult);
+ }
+
+ return 0;
+}
+
static struct clk_ops clk_fixed_factor_ops = {
+ .set_rate = clk_factor_set_rate,
+ .round_rate = clk_factor_round_rate,
.recalc_rate = clk_fixed_factor_recalc_rate,
};
--
1.9.0
More information about the barebox
mailing list