16 #include <linux/slab.h>
36 #define to_clk_ref(_hw) container_of(_hw, struct clk_ref, hw)
38 static int clk_ref_enable(
struct clk_hw *
hw)
42 writel_relaxed(1 << ((ref->
idx + 1) * 8 - 1), ref->
reg +
CLR);
47 static void clk_ref_disable(
struct clk_hw *
hw)
51 writel_relaxed(1 << ((ref->
idx + 1) * 8 - 1), ref->
reg +
SET);
54 static unsigned long clk_ref_recalc_rate(
struct clk_hw *hw,
55 unsigned long parent_rate)
67 static long clk_ref_round_rate(
struct clk_hw *hw,
unsigned long rate,
70 unsigned long parent_rate = *
prate;
74 tmp = tmp * 18 + rate / 2;
90 static int clk_ref_set_rate(
struct clk_hw *hw,
unsigned long rate,
91 unsigned long parent_rate)
95 u64 tmp = parent_rate;
99 tmp = tmp * 18 + rate / 2;
111 val &= ~(0x3f << shift);
112 val |= frac << shift;
113 writel_relaxed(val, ref->
reg);
115 spin_unlock_irqrestore(&mxs_lock, flags);
120 static const struct clk_ops clk_ref_ops = {
121 .enable = clk_ref_enable,
122 .disable = clk_ref_disable,
123 .recalc_rate = clk_ref_recalc_rate,
124 .round_rate = clk_ref_round_rate,
125 .set_rate = clk_ref_set_rate,
133 struct clk_init_data init;
140 init.ops = &clk_ref_ops;
142 init.parent_names = (parent_name ? &parent_name:
NULL);
143 init.num_parents = (parent_name ? 1 : 0);
147 ref->hw.init = &
init;