diff options
Diffstat (limited to 'drivers/clk/mmp')
-rw-r--r-- | drivers/clk/mmp/clk-apbc.c | 1 | ||||
-rw-r--r-- | drivers/clk/mmp/clk-apmu.c | 1 | ||||
-rw-r--r-- | drivers/clk/mmp/clk-gate.c | 3 | ||||
-rw-r--r-- | drivers/clk/mmp/clk-mix.c | 71 | ||||
-rw-r--r-- | drivers/clk/mmp/clk.c | 3 |
5 files changed, 36 insertions, 43 deletions
diff --git a/drivers/clk/mmp/clk-apbc.c b/drivers/clk/mmp/clk-apbc.c index 09d41c717..4c717db05 100644 --- a/drivers/clk/mmp/clk-apbc.c +++ b/drivers/clk/mmp/clk-apbc.c @@ -10,7 +10,6 @@ */ #include <linux/kernel.h> -#include <linux/clk.h> #include <linux/io.h> #include <linux/err.h> #include <linux/delay.h> diff --git a/drivers/clk/mmp/clk-apmu.c b/drivers/clk/mmp/clk-apmu.c index cdcf2d7f3..47b5542ce 100644 --- a/drivers/clk/mmp/clk-apmu.c +++ b/drivers/clk/mmp/clk-apmu.c @@ -10,7 +10,6 @@ */ #include <linux/kernel.h> -#include <linux/clk.h> #include <linux/io.h> #include <linux/err.h> #include <linux/delay.h> diff --git a/drivers/clk/mmp/clk-gate.c b/drivers/clk/mmp/clk-gate.c index adbd9d64d..d20cd3431 100644 --- a/drivers/clk/mmp/clk-gate.c +++ b/drivers/clk/mmp/clk-gate.c @@ -27,7 +27,6 @@ static int mmp_clk_gate_enable(struct clk_hw *hw) { struct mmp_clk_gate *gate = to_clk_mmp_gate(hw); - struct clk *clk = hw->clk; unsigned long flags = 0; unsigned long rate; u32 tmp; @@ -44,7 +43,7 @@ static int mmp_clk_gate_enable(struct clk_hw *hw) spin_unlock_irqrestore(gate->lock, flags); if (gate->flags & MMP_CLK_GATE_NEED_DELAY) { - rate = __clk_get_rate(clk); + rate = clk_hw_get_rate(hw); /* Need delay 2 cycles. */ udelay(2000000/rate); } diff --git a/drivers/clk/mmp/clk-mix.c b/drivers/clk/mmp/clk-mix.c index de6a87317..c554833cf 100644 --- a/drivers/clk/mmp/clk-mix.c +++ b/drivers/clk/mmp/clk-mix.c @@ -63,7 +63,7 @@ static unsigned int _get_div(struct mmp_clk_mix *mix, unsigned int val) static unsigned int _get_mux(struct mmp_clk_mix *mix, unsigned int val) { - int num_parents = __clk_get_num_parents(mix->hw.clk); + int num_parents = clk_hw_get_num_parents(&mix->hw); int i; if (mix->mux_flags & CLK_MUX_INDEX_BIT) @@ -113,15 +113,15 @@ static void _filter_clk_table(struct mmp_clk_mix *mix, { int i; struct mmp_clk_mix_clk_table *item; - struct clk *parent, *clk; + struct clk_hw *parent, *hw; unsigned long parent_rate; - clk = mix->hw.clk; + hw = &mix->hw; for (i = 0; i < table_size; i++) { item = &table[i]; - parent = clk_get_parent_by_index(clk, item->parent_index); - parent_rate = __clk_get_rate(parent); + parent = clk_hw_get_parent_by_index(hw, item->parent_index); + parent_rate = clk_hw_get_rate(parent); if (parent_rate % item->rate) { item->valid = 0; } else { @@ -181,7 +181,7 @@ static int _set_rate(struct mmp_clk_mix *mix, u32 mux_val, u32 div_val, if (timeout == 0) { pr_err("%s:%s cannot do frequency change\n", - __func__, __clk_get_name(mix->hw.clk)); + __func__, clk_hw_get_name(&mix->hw)); ret = -EBUSY; goto error; } @@ -201,27 +201,22 @@ error: return ret; } -static long mmp_clk_mix_determine_rate(struct clk_hw *hw, unsigned long rate, - unsigned long min_rate, - unsigned long max_rate, - unsigned long *best_parent_rate, - struct clk_hw **best_parent_clk) +static int mmp_clk_mix_determine_rate(struct clk_hw *hw, + struct clk_rate_request *req) { struct mmp_clk_mix *mix = to_clk_mix(hw); struct mmp_clk_mix_clk_table *item; - struct clk *parent, *parent_best, *mix_clk; + struct clk_hw *parent, *parent_best; unsigned long parent_rate, mix_rate, mix_rate_best, parent_rate_best; unsigned long gap, gap_best; u32 div_val_max; unsigned int div; int i, j; - mix_clk = hw->clk; - parent = NULL; mix_rate_best = 0; parent_rate_best = 0; - gap_best = rate; + gap_best = ULONG_MAX; parent_best = NULL; if (mix->table) { @@ -229,11 +224,11 @@ static long mmp_clk_mix_determine_rate(struct clk_hw *hw, unsigned long rate, item = &mix->table[i]; if (item->valid == 0) continue; - parent = clk_get_parent_by_index(mix_clk, + parent = clk_hw_get_parent_by_index(hw, item->parent_index); - parent_rate = __clk_get_rate(parent); + parent_rate = clk_hw_get_rate(parent); mix_rate = parent_rate / item->divisor; - gap = abs(mix_rate - rate); + gap = abs(mix_rate - req->rate); if (parent_best == NULL || gap < gap_best) { parent_best = parent; parent_rate_best = parent_rate; @@ -244,14 +239,14 @@ static long mmp_clk_mix_determine_rate(struct clk_hw *hw, unsigned long rate, } } } else { - for (i = 0; i < __clk_get_num_parents(mix_clk); i++) { - parent = clk_get_parent_by_index(mix_clk, i); - parent_rate = __clk_get_rate(parent); + for (i = 0; i < clk_hw_get_num_parents(hw); i++) { + parent = clk_hw_get_parent_by_index(hw, i); + parent_rate = clk_hw_get_rate(parent); div_val_max = _get_maxdiv(mix); for (j = 0; j < div_val_max; j++) { div = _get_div(mix, j); mix_rate = parent_rate / div; - gap = abs(mix_rate - rate); + gap = abs(mix_rate - req->rate); if (parent_best == NULL || gap < gap_best) { parent_best = parent; parent_rate_best = parent_rate; @@ -265,10 +260,14 @@ static long mmp_clk_mix_determine_rate(struct clk_hw *hw, unsigned long rate, } found: - *best_parent_rate = parent_rate_best; - *best_parent_clk = __clk_get_hw(parent_best); + if (!parent_best) + return -EINVAL; + + req->best_parent_rate = parent_rate_best; + req->best_parent_hw = parent_best; + req->rate = mix_rate_best; - return mix_rate_best; + return 0; } static int mmp_clk_mix_set_rate_and_parent(struct clk_hw *hw, @@ -381,20 +380,19 @@ static int mmp_clk_set_rate(struct clk_hw *hw, unsigned long rate, struct mmp_clk_mix_clk_table *item; unsigned long parent_rate; unsigned int best_divisor; - struct clk *mix_clk, *parent; + struct clk_hw *parent; int i; best_divisor = best_parent_rate / rate; - mix_clk = hw->clk; if (mix->table) { for (i = 0; i < mix->table_size; i++) { item = &mix->table[i]; if (item->valid == 0) continue; - parent = clk_get_parent_by_index(mix_clk, + parent = clk_hw_get_parent_by_index(hw, item->parent_index); - parent_rate = __clk_get_rate(parent); + parent_rate = clk_hw_get_rate(parent); if (parent_rate == best_parent_rate && item->divisor == best_divisor) break; @@ -407,13 +405,13 @@ static int mmp_clk_set_rate(struct clk_hw *hw, unsigned long rate, else return -EINVAL; } else { - for (i = 0; i < __clk_get_num_parents(mix_clk); i++) { - parent = clk_get_parent_by_index(mix_clk, i); - parent_rate = __clk_get_rate(parent); + for (i = 0; i < clk_hw_get_num_parents(hw); i++) { + parent = clk_hw_get_parent_by_index(hw, i); + parent_rate = clk_hw_get_rate(parent); if (parent_rate == best_parent_rate) break; } - if (i < __clk_get_num_parents(mix_clk)) + if (i < clk_hw_get_num_parents(hw)) return _set_rate(mix, _get_mux_val(mix, i), _get_div_val(mix, best_divisor), 1, 1); else @@ -468,20 +466,20 @@ struct clk *mmp_clk_register_mix(struct device *dev, memcpy(&mix->reg_info, &config->reg_info, sizeof(config->reg_info)); if (config->table) { table_bytes = sizeof(*config->table) * config->table_size; - mix->table = kzalloc(table_bytes, GFP_KERNEL); + mix->table = kmemdup(config->table, table_bytes, GFP_KERNEL); if (!mix->table) { pr_err("%s:%s: could not allocate mmp mix table\n", __func__, name); kfree(mix); return ERR_PTR(-ENOMEM); } - memcpy(mix->table, config->table, table_bytes); mix->table_size = config->table_size; } if (config->mux_table) { table_bytes = sizeof(u32) * num_parents; - mix->mux_table = kzalloc(table_bytes, GFP_KERNEL); + mix->mux_table = kmemdup(config->mux_table, table_bytes, + GFP_KERNEL); if (!mix->mux_table) { pr_err("%s:%s: could not allocate mmp mix mux-table\n", __func__, name); @@ -489,7 +487,6 @@ struct clk *mmp_clk_register_mix(struct device *dev, kfree(mix); return ERR_PTR(-ENOMEM); } - memcpy(mix->mux_table, config->mux_table, table_bytes); } mix->div_flags = config->div_flags; diff --git a/drivers/clk/mmp/clk.c b/drivers/clk/mmp/clk.c index cf038ef54..61893fe73 100644 --- a/drivers/clk/mmp/clk.c +++ b/drivers/clk/mmp/clk.c @@ -1,7 +1,6 @@ #include <linux/io.h> -#include <linux/clk.h> #include <linux/clk-provider.h> -#include <linux/clkdev.h> +#include <linux/slab.h> #include <linux/of.h> #include <linux/of_address.h> |