16 #include <linux/slab.h>
38 #define to_clk_frac(_hw) container_of(_hw, struct clk_frac, hw)
40 static unsigned long clk_frac_recalc_rate(
struct clk_hw *
hw,
41 unsigned long parent_rate)
47 div &= (1 << frac->
width) - 1;
49 return (parent_rate >> frac->
width) *
div;
52 static long clk_frac_round_rate(
struct clk_hw *
hw,
unsigned long rate,
56 unsigned long parent_rate = *
prate;
60 if (rate > parent_rate)
71 return (parent_rate >> frac->
width) *
div;
74 static int clk_frac_set_rate(
struct clk_hw *hw,
unsigned long rate,
75 unsigned long parent_rate)
82 if (rate > parent_rate)
96 val &= ~(((1 << frac->
width) - 1) << frac->
shift);
97 val |= div << frac->
shift;
98 writel_relaxed(val, frac->
reg);
100 spin_unlock_irqrestore(&mxs_lock, flags);
106 .recalc_rate = clk_frac_recalc_rate,
107 .round_rate = clk_frac_round_rate,
108 .set_rate = clk_frac_set_rate,
116 struct clk_init_data init;
124 init.flags = CLK_SET_RATE_PARENT;
125 init.parent_names = (parent_name ? &parent_name:
NULL);
126 init.num_parents = (parent_name ? 1 : 0);
132 frac->hw.init = &
init;