12 #define pr_fmt(fmt) "clk-frac-synth: " fmt
15 #include <linux/slab.h>
20 #define DIV_FACTOR_MASK 0x1FFFF
42 #define to_clk_frac(_hw) container_of(_hw, struct clk_frac, hw)
44 static unsigned long frac_calc_rate(
struct clk_hw *
hw,
unsigned long prate,
58 static long clk_frac_round_rate(
struct clk_hw *
hw,
unsigned long drate,
68 static unsigned long clk_frac_recalc_rate(
struct clk_hw *
hw,
69 unsigned long parent_rate)
72 unsigned long flags = 0;
81 spin_unlock_irqrestore(frac->
lock, flags);
88 parent_rate = parent_rate / 10000;
90 parent_rate = (parent_rate << 14) / (2 * div);
91 return parent_rate * 10000;
95 static int clk_frac_set_rate(
struct clk_hw *hw,
unsigned long drate,
100 unsigned long flags = 0,
val;
111 writel_relaxed(
val, frac->
reg);
114 spin_unlock_irqrestore(frac->
lock, flags);
120 .recalc_rate = clk_frac_recalc_rate,
121 .round_rate = clk_frac_round_rate,
122 .set_rate = clk_frac_set_rate,
129 struct clk_init_data init;
133 if (!name || !parent_name || !reg || !rtbl || !rtbl_cnt) {
134 pr_err(
"Invalid arguments passed");
140 pr_err(
"could not allocate frac clk\n");
154 init.parent_names = &parent_name;
155 init.num_parents = 1;
158 if (!IS_ERR_OR_NULL(clk))
161 pr_err(
"clk register failed\n");