Lines Matching +full:clk +full:- +full:gate

1 // SPDX-License-Identifier: GPL-2.0-only
6 #include <linux/clk.h>
7 #include <linux/clk-provider.h>
12 #include "clk.h"
17 const struct clk_ops *mux_ops = periph->mux_ops; in clk_periph_get_parent()
18 struct clk_hw *mux_hw = &periph->mux.hw; in clk_periph_get_parent()
22 return mux_ops->get_parent(mux_hw); in clk_periph_get_parent()
28 const struct clk_ops *mux_ops = periph->mux_ops; in clk_periph_set_parent()
29 struct clk_hw *mux_hw = &periph->mux.hw; in clk_periph_set_parent()
33 return mux_ops->set_parent(mux_hw, index); in clk_periph_set_parent()
40 const struct clk_ops *div_ops = periph->div_ops; in clk_periph_recalc_rate()
41 struct clk_hw *div_hw = &periph->divider.hw; in clk_periph_recalc_rate()
45 return div_ops->recalc_rate(div_hw, parent_rate); in clk_periph_recalc_rate()
52 const struct clk_ops *div_ops = periph->div_ops; in clk_periph_determine_rate()
53 struct clk_hw *div_hw = &periph->divider.hw; in clk_periph_determine_rate()
57 return div_ops->determine_rate(div_hw, req); in clk_periph_determine_rate()
64 const struct clk_ops *div_ops = periph->div_ops; in clk_periph_set_rate()
65 struct clk_hw *div_hw = &periph->divider.hw; in clk_periph_set_rate()
69 return div_ops->set_rate(div_hw, rate, parent_rate); in clk_periph_set_rate()
75 const struct clk_ops *gate_ops = periph->gate_ops; in clk_periph_is_enabled()
76 struct clk_hw *gate_hw = &periph->gate.hw; in clk_periph_is_enabled()
80 return gate_ops->is_enabled(gate_hw); in clk_periph_is_enabled()
86 const struct clk_ops *gate_ops = periph->gate_ops; in clk_periph_enable()
87 struct clk_hw *gate_hw = &periph->gate.hw; in clk_periph_enable()
91 return gate_ops->enable(gate_hw); in clk_periph_enable()
97 const struct clk_ops *gate_ops = periph->gate_ops; in clk_periph_disable()
98 struct clk_hw *gate_hw = &periph->gate.hw; in clk_periph_disable()
100 gate_ops->disable(gate_hw); in clk_periph_disable()
106 const struct clk_ops *gate_ops = periph->gate_ops; in clk_periph_disable_unused()
107 struct clk_hw *gate_hw = &periph->gate.hw; in clk_periph_disable_unused()
109 gate_ops->disable_unused(gate_hw); in clk_periph_disable_unused()
115 const struct clk_ops *div_ops = periph->div_ops; in clk_periph_restore_context()
116 struct clk_hw *div_hw = &periph->divider.hw; in clk_periph_restore_context()
123 if (!(periph->gate.flags & TEGRA_PERIPH_NO_DIV)) in clk_periph_restore_context()
124 div_ops->restore_context(div_hw); in clk_periph_restore_context()
162 static struct clk *_tegra_clk_register_periph(const char *name, in _tegra_clk_register_periph()
168 struct clk *clk; in _tegra_clk_register_periph() local
171 bool div = !(periph->gate.flags & TEGRA_PERIPH_NO_DIV); in _tegra_clk_register_periph()
173 if (periph->gate.flags & TEGRA_PERIPH_NO_DIV) { in _tegra_clk_register_periph()
176 } else if (periph->gate.flags & TEGRA_PERIPH_NO_GATE) in _tegra_clk_register_periph()
186 bank = get_reg_bank(periph->gate.clk_num); in _tegra_clk_register_periph()
188 return ERR_PTR(-EINVAL); in _tegra_clk_register_periph()
191 periph->hw.init = &init; in _tegra_clk_register_periph()
192 periph->magic = TEGRA_CLK_PERIPH_MAGIC; in _tegra_clk_register_periph()
193 periph->mux.reg = clk_base + offset; in _tegra_clk_register_periph()
194 periph->divider.reg = div ? (clk_base + offset) : NULL; in _tegra_clk_register_periph()
195 periph->gate.clk_base = clk_base; in _tegra_clk_register_periph()
196 periph->gate.regs = bank; in _tegra_clk_register_periph()
197 periph->gate.enable_refcnt = periph_clk_enb_refcnt; in _tegra_clk_register_periph()
199 clk = clk_register(NULL, &periph->hw); in _tegra_clk_register_periph()
200 if (IS_ERR(clk)) in _tegra_clk_register_periph()
201 return clk; in _tegra_clk_register_periph()
203 periph->mux.hw.clk = clk; in _tegra_clk_register_periph()
204 periph->divider.hw.clk = div ? clk : NULL; in _tegra_clk_register_periph()
205 periph->gate.hw.clk = clk; in _tegra_clk_register_periph()
207 return clk; in _tegra_clk_register_periph()
210 struct clk *tegra_clk_register_periph(const char *name, in tegra_clk_register_periph()
219 struct clk *tegra_clk_register_periph_nodiv(const char *name, in tegra_clk_register_periph_nodiv()
224 periph->gate.flags |= TEGRA_PERIPH_NO_DIV; in tegra_clk_register_periph_nodiv()
229 struct clk *tegra_clk_register_periph_data(void __iomem *clk_base, in tegra_clk_register_periph_data()
232 return _tegra_clk_register_periph(init->name, init->p.parent_names, in tegra_clk_register_periph_data()
233 init->num_parents, &init->periph, in tegra_clk_register_periph_data()
234 clk_base, init->offset, init->flags); in tegra_clk_register_periph_data()