Lines Matching +full:clk +full:- +full:div

1 // SPDX-License-Identifier: GPL-2.0-only
17 #include "clk-mtk.h"
18 #include "clk-gate.h"
29 clk_data->clks = kcalloc(clk_num, sizeof(*clk_data->clks), GFP_KERNEL); in mtk_alloc_clk_data()
30 if (!clk_data->clks) in mtk_alloc_clk_data()
33 clk_data->clk_num = clk_num; in mtk_alloc_clk_data()
36 clk_data->clks[i] = ERR_PTR(-ENOENT); in mtk_alloc_clk_data()
49 struct clk *clk; in mtk_clk_register_fixed_clks() local
54 if (clk_data && !IS_ERR_OR_NULL(clk_data->clks[rc->id])) in mtk_clk_register_fixed_clks()
57 clk = clk_register_fixed_rate(NULL, rc->name, rc->parent, 0, in mtk_clk_register_fixed_clks()
58 rc->rate); in mtk_clk_register_fixed_clks()
60 if (IS_ERR(clk)) { in mtk_clk_register_fixed_clks()
61 pr_err("Failed to register clk %s: %ld\n", in mtk_clk_register_fixed_clks()
62 rc->name, PTR_ERR(clk)); in mtk_clk_register_fixed_clks()
67 clk_data->clks[rc->id] = clk; in mtk_clk_register_fixed_clks()
75 struct clk *clk; in mtk_clk_register_factors() local
80 if (clk_data && !IS_ERR_OR_NULL(clk_data->clks[ff->id])) in mtk_clk_register_factors()
83 clk = clk_register_fixed_factor(NULL, ff->name, ff->parent_name, in mtk_clk_register_factors()
84 CLK_SET_RATE_PARENT, ff->mult, ff->div); in mtk_clk_register_factors()
86 if (IS_ERR(clk)) { in mtk_clk_register_factors()
87 pr_err("Failed to register clk %s: %ld\n", in mtk_clk_register_factors()
88 ff->name, PTR_ERR(clk)); in mtk_clk_register_factors()
93 clk_data->clks[ff->id] = clk; in mtk_clk_register_factors()
103 struct clk *clk; in mtk_clk_register_gates_with_dev() local
107 return -ENOMEM; in mtk_clk_register_gates_with_dev()
119 if (!IS_ERR_OR_NULL(clk_data->clks[gate->id])) in mtk_clk_register_gates_with_dev()
122 clk = mtk_clk_register_gate(gate->name, gate->parent_name, in mtk_clk_register_gates_with_dev()
124 gate->regs->set_ofs, in mtk_clk_register_gates_with_dev()
125 gate->regs->clr_ofs, in mtk_clk_register_gates_with_dev()
126 gate->regs->sta_ofs, in mtk_clk_register_gates_with_dev()
127 gate->shift, gate->ops, gate->flags, dev); in mtk_clk_register_gates_with_dev()
129 if (IS_ERR(clk)) { in mtk_clk_register_gates_with_dev()
130 pr_err("Failed to register clk %s: %ld\n", in mtk_clk_register_gates_with_dev()
131 gate->name, PTR_ERR(clk)); in mtk_clk_register_gates_with_dev()
135 clk_data->clks[gate->id] = clk; in mtk_clk_register_gates_with_dev()
149 struct clk *mtk_clk_register_composite(const struct mtk_composite *mc, in mtk_clk_register_composite()
152 struct clk *clk; in mtk_clk_register_composite() local
155 struct clk_divider *div = NULL; in mtk_clk_register_composite() local
163 if (mc->mux_shift >= 0) { in mtk_clk_register_composite()
166 return ERR_PTR(-ENOMEM); in mtk_clk_register_composite()
168 mux->reg = base + mc->mux_reg; in mtk_clk_register_composite()
169 mux->mask = BIT(mc->mux_width) - 1; in mtk_clk_register_composite()
170 mux->shift = mc->mux_shift; in mtk_clk_register_composite()
171 mux->lock = lock; in mtk_clk_register_composite()
172 mux->flags = mc->mux_flags; in mtk_clk_register_composite()
173 mux_hw = &mux->hw; in mtk_clk_register_composite()
176 parent_names = mc->parent_names; in mtk_clk_register_composite()
177 num_parents = mc->num_parents; in mtk_clk_register_composite()
179 parent = mc->parent; in mtk_clk_register_composite()
184 if (mc->gate_shift >= 0) { in mtk_clk_register_composite()
187 ret = -ENOMEM; in mtk_clk_register_composite()
191 gate->reg = base + mc->gate_reg; in mtk_clk_register_composite()
192 gate->bit_idx = mc->gate_shift; in mtk_clk_register_composite()
193 gate->flags = CLK_GATE_SET_TO_DISABLE; in mtk_clk_register_composite()
194 gate->lock = lock; in mtk_clk_register_composite()
196 gate_hw = &gate->hw; in mtk_clk_register_composite()
200 if (mc->divider_shift >= 0) { in mtk_clk_register_composite()
201 div = kzalloc(sizeof(*div), GFP_KERNEL); in mtk_clk_register_composite()
202 if (!div) { in mtk_clk_register_composite()
203 ret = -ENOMEM; in mtk_clk_register_composite()
207 div->reg = base + mc->divider_reg; in mtk_clk_register_composite()
208 div->shift = mc->divider_shift; in mtk_clk_register_composite()
209 div->width = mc->divider_width; in mtk_clk_register_composite()
210 div->lock = lock; in mtk_clk_register_composite()
212 div_hw = &div->hw; in mtk_clk_register_composite()
216 clk = clk_register_composite(NULL, mc->name, parent_names, num_parents, in mtk_clk_register_composite()
220 mc->flags); in mtk_clk_register_composite()
222 if (IS_ERR(clk)) { in mtk_clk_register_composite()
223 ret = PTR_ERR(clk); in mtk_clk_register_composite()
227 return clk; in mtk_clk_register_composite()
229 kfree(div); in mtk_clk_register_composite()
240 struct clk *clk; in mtk_clk_register_composites() local
246 if (clk_data && !IS_ERR_OR_NULL(clk_data->clks[mc->id])) in mtk_clk_register_composites()
249 clk = mtk_clk_register_composite(mc, base, lock); in mtk_clk_register_composites()
251 if (IS_ERR(clk)) { in mtk_clk_register_composites()
252 pr_err("Failed to register clk %s: %ld\n", in mtk_clk_register_composites()
253 mc->name, PTR_ERR(clk)); in mtk_clk_register_composites()
258 clk_data->clks[mc->id] = clk; in mtk_clk_register_composites()
266 struct clk *clk; in mtk_clk_register_dividers() local
272 if (clk_data && !IS_ERR_OR_NULL(clk_data->clks[mcd->id])) in mtk_clk_register_dividers()
275 clk = clk_register_divider(NULL, mcd->name, mcd->parent_name, in mtk_clk_register_dividers()
276 mcd->flags, base + mcd->div_reg, mcd->div_shift, in mtk_clk_register_dividers()
277 mcd->div_width, mcd->clk_divider_flags, lock); in mtk_clk_register_dividers()
279 if (IS_ERR(clk)) { in mtk_clk_register_dividers()
280 pr_err("Failed to register clk %s: %ld\n", in mtk_clk_register_dividers()
281 mcd->name, PTR_ERR(clk)); in mtk_clk_register_dividers()
286 clk_data->clks[mcd->id] = clk; in mtk_clk_register_dividers()