Lines Matching +full:dc +full:- +full:dc
1 // SPDX-License-Identifier: GPL-2.0
8 #include <linux/clk-provider.h>
15 #include "dove-divider.h"
51 static unsigned int dove_get_divider(struct dove_clk *dc) in dove_get_divider() argument
56 val = readl_relaxed(dc->base + DIV_CTRL0); in dove_get_divider()
57 val >>= dc->div_bit_start; in dove_get_divider()
59 divider = val & ~(~0 << dc->div_bit_size); in dove_get_divider()
61 if (dc->divider_table) in dove_get_divider()
62 divider = dc->divider_table[divider]; in dove_get_divider()
67 static int dove_calc_divider(const struct dove_clk *dc, unsigned long rate, in dove_calc_divider() argument
74 if (dc->divider_table) { in dove_calc_divider()
77 for (i = 0; dc->divider_table[i]; i++) in dove_calc_divider()
78 if (divider == dc->divider_table[i]) { in dove_calc_divider()
83 if (!dc->divider_table[i]) in dove_calc_divider()
84 return -EINVAL; in dove_calc_divider()
86 max = 1 << dc->div_bit_size; in dove_calc_divider()
89 return -EINVAL; in dove_calc_divider()
91 divider = max - 1; in dove_calc_divider()
101 struct dove_clk *dc = to_dove_clk(hw); in dove_recalc_rate() local
102 unsigned int divider = dove_get_divider(dc); in dove_recalc_rate()
106 __func__, dc->name, divider, parent, rate); in dove_recalc_rate()
114 struct dove_clk *dc = to_dove_clk(hw); in dove_round_rate() local
118 divider = dove_calc_divider(dc, rate, parent_rate, false); in dove_round_rate()
125 __func__, dc->name, divider, parent_rate, rate); in dove_round_rate()
133 struct dove_clk *dc = to_dove_clk(hw); in dove_set_clock() local
137 divider = dove_calc_divider(dc, rate, parent_rate, true); in dove_set_clock()
142 __func__, dc->name, divider, parent_rate, rate); in dove_set_clock()
144 div = (u32)divider << dc->div_bit_start; in dove_set_clock()
145 mask = ~(~0 << dc->div_bit_size) << dc->div_bit_start; in dove_set_clock()
146 load = BIT(dc->div_bit_load); in dove_set_clock()
148 spin_lock(dc->lock); in dove_set_clock()
149 dove_load_divider(dc->base, div, mask, load); in dove_set_clock()
150 spin_unlock(dc->lock); in dove_set_clock()
162 struct dove_clk *dc, const char **parent_names, size_t num_parents, in clk_register_dove_divider() argument
173 strscpy(name, dc->name, sizeof(name)); in clk_register_dove_divider()
175 dc->hw.init = &init; in clk_register_dove_divider()
176 dc->base = base; in clk_register_dove_divider()
177 dc->div_bit_size = dc->div_bit_end - dc->div_bit_start + 1; in clk_register_dove_divider()
179 return clk_register(dev, &dc->hw); in clk_register_dove_divider()
184 static u32 axi_divider[] = {-1, 2, 1, 3, 4, 6, 5, 7, 8, 10, 9, 0};
216 "core-pll",