10 #include <linux/module.h>
12 #include <linux/slab.h>
25 #define to_clk_fixed_factor(_hw) container_of(_hw, struct clk_fixed_factor, hw)
27 static unsigned long clk_factor_recalc_rate(
struct clk_hw *
hw,
28 unsigned long parent_rate)
32 return parent_rate * fix->mult / fix->div;
35 static long clk_factor_round_rate(
struct clk_hw *
hw,
unsigned long rate,
41 unsigned long best_parent;
43 best_parent = (rate / fix->mult) * fix->div;
48 return (*prate / fix->div) * fix->mult;
51 static int clk_factor_set_rate(
struct clk_hw *hw,
unsigned long rate,
52 unsigned long parent_rate)
58 .round_rate = clk_factor_round_rate,
59 .set_rate = clk_factor_set_rate,
60 .recalc_rate = clk_factor_recalc_rate,
65 const char *parent_name,
unsigned long flags,
66 unsigned int mult,
unsigned int div)
68 struct clk_fixed_factor *fix;
69 struct clk_init_data init;
74 pr_err(
"%s: could not allocate fixed factor clk\n", __func__);
85 init.flags = flags | CLK_IS_BASIC;
86 init.parent_names = &parent_name;