Lines Matching +full:mux +full:-

1 // SPDX-License-Identifier: GPL-2.0-only
4 * Author: Pi-Cheng Chen <pi-[email protected]>
7 #include <linux/clk-provider.h>
15 #include "clk-mtk.h"
16 #include "clk-cpumux.h"
33 struct mtk_clk_cpumux *mux = to_mtk_clk_cpumux(hw); in clk_cpumux_get_parent() local
36 regmap_read(mux->regmap, mux->reg, &val); in clk_cpumux_get_parent()
38 val >>= mux->shift; in clk_cpumux_get_parent()
39 val &= mux->mask; in clk_cpumux_get_parent()
46 struct mtk_clk_cpumux *mux = to_mtk_clk_cpumux(hw); in clk_cpumux_set_parent() local
49 val = index << mux->shift; in clk_cpumux_set_parent()
50 mask = mux->mask << mux->shift; in clk_cpumux_set_parent()
52 return regmap_update_bits(mux->regmap, mux->reg, mask, val); in clk_cpumux_set_parent()
62 mtk_clk_register_cpumux(struct device *dev, const struct mtk_composite *mux, in mtk_clk_register_cpumux() argument
71 return ERR_PTR(-ENOMEM); in mtk_clk_register_cpumux()
73 init.name = mux->name; in mtk_clk_register_cpumux()
75 init.parent_names = mux->parent_names; in mtk_clk_register_cpumux()
76 init.num_parents = mux->num_parents; in mtk_clk_register_cpumux()
77 init.flags = mux->flags; in mtk_clk_register_cpumux()
79 cpumux->reg = mux->mux_reg; in mtk_clk_register_cpumux()
80 cpumux->shift = mux->mux_shift; in mtk_clk_register_cpumux()
81 cpumux->mask = BIT(mux->mux_width) - 1; in mtk_clk_register_cpumux()
82 cpumux->regmap = regmap; in mtk_clk_register_cpumux()
83 cpumux->hw.init = &init; in mtk_clk_register_cpumux()
85 ret = clk_hw_register(dev, &cpumux->hw); in mtk_clk_register_cpumux()
91 return &cpumux->hw; in mtk_clk_register_cpumux()
121 const struct mtk_composite *mux = &clks[i]; in mtk_clk_register_cpumuxes() local
123 if (!IS_ERR_OR_NULL(clk_data->hws[mux->id])) { in mtk_clk_register_cpumuxes()
125 node, mux->id); in mtk_clk_register_cpumuxes()
129 hw = mtk_clk_register_cpumux(dev, mux, regmap); in mtk_clk_register_cpumuxes()
131 pr_err("Failed to register clk %s: %pe\n", mux->name, in mtk_clk_register_cpumuxes()
136 clk_data->hws[mux->id] = hw; in mtk_clk_register_cpumuxes()
142 while (--i >= 0) { in mtk_clk_register_cpumuxes()
143 const struct mtk_composite *mux = &clks[i]; in mtk_clk_register_cpumuxes() local
145 if (IS_ERR_OR_NULL(clk_data->hws[mux->id])) in mtk_clk_register_cpumuxes()
148 mtk_clk_unregister_cpumux(clk_data->hws[mux->id]); in mtk_clk_register_cpumuxes()
149 clk_data->hws[mux->id] = ERR_PTR(-ENOENT); in mtk_clk_register_cpumuxes()
161 for (i = num; i > 0; i--) { in mtk_clk_unregister_cpumuxes()
162 const struct mtk_composite *mux = &clks[i - 1]; in mtk_clk_unregister_cpumuxes() local
164 if (IS_ERR_OR_NULL(clk_data->hws[mux->id])) in mtk_clk_unregister_cpumuxes()
167 mtk_clk_unregister_cpumux(clk_data->hws[mux->id]); in mtk_clk_unregister_cpumuxes()
168 clk_data->hws[mux->id] = ERR_PTR(-ENOENT); in mtk_clk_unregister_cpumuxes()