12 #define pr_fmt(fmt) "clk-gpt-synth: " fmt
15 #include <linux/slab.h>
20 #define GPT_MSCALE_MASK 0xFFF
21 #define GPT_NSCALE_SHIFT 12
22 #define GPT_NSCALE_MASK 0xF
32 #define to_clk_gpt(_hw) container_of(_hw, struct clk_gpt, hw)
34 static unsigned long gpt_calc_rate(
struct clk_hw *
hw,
unsigned long prate,
45 static long clk_gpt_round_rate(
struct clk_hw *
hw,
unsigned long drate,
55 static unsigned long clk_gpt_recalc_rate(
struct clk_hw *
hw,
56 unsigned long parent_rate)
59 unsigned long flags = 0;
68 spin_unlock_irqrestore(gpt->
lock, flags);
76 return parent_rate /
div;
80 static int clk_gpt_set_rate(
struct clk_hw *hw,
unsigned long drate,
85 unsigned long flags = 0,
val;
100 writel_relaxed(
val, gpt->
reg);
103 spin_unlock_irqrestore(gpt->
lock, flags);
108 static struct clk_ops clk_gpt_ops = {
109 .recalc_rate = clk_gpt_recalc_rate,
110 .round_rate = clk_gpt_round_rate,
111 .set_rate = clk_gpt_set_rate,
118 struct clk_init_data init;
122 if (!name || !parent_name || !reg || !rtbl || !rtbl_cnt) {
123 pr_err(
"Invalid arguments passed");
129 pr_err(
"could not allocate gpt clk\n");
141 init.ops = &clk_gpt_ops;
143 init.parent_names = &parent_name;
144 init.num_parents = 1;
147 if (!IS_ERR_OR_NULL(clk))
150 pr_err(
"clk register failed\n");