Lines Matching full:mux
18 #include "clk-mux.h"
35 struct mtk_clk_mux *mux = to_mtk_clk_mux(hw); in mtk_clk_mux_enable_setclr() local
38 if (mux->lock) in mtk_clk_mux_enable_setclr()
39 spin_lock_irqsave(mux->lock, flags); in mtk_clk_mux_enable_setclr()
41 __acquire(mux->lock); in mtk_clk_mux_enable_setclr()
43 regmap_write(mux->regmap, mux->data->clr_ofs, in mtk_clk_mux_enable_setclr()
44 BIT(mux->data->gate_shift)); in mtk_clk_mux_enable_setclr()
48 * not be effective yet. Set the update bit to ensure the mux gets in mtk_clk_mux_enable_setclr()
51 if (mux->reparent && mux->data->upd_shift >= 0) { in mtk_clk_mux_enable_setclr()
52 regmap_write(mux->regmap, mux->data->upd_ofs, in mtk_clk_mux_enable_setclr()
53 BIT(mux->data->upd_shift)); in mtk_clk_mux_enable_setclr()
54 mux->reparent = false; in mtk_clk_mux_enable_setclr()
57 if (mux->lock) in mtk_clk_mux_enable_setclr()
58 spin_unlock_irqrestore(mux->lock, flags); in mtk_clk_mux_enable_setclr()
60 __release(mux->lock); in mtk_clk_mux_enable_setclr()
67 struct mtk_clk_mux *mux = to_mtk_clk_mux(hw); in mtk_clk_mux_disable_setclr() local
69 regmap_write(mux->regmap, mux->data->set_ofs, in mtk_clk_mux_disable_setclr()
70 BIT(mux->data->gate_shift)); in mtk_clk_mux_disable_setclr()
75 struct mtk_clk_mux *mux = to_mtk_clk_mux(hw); in mtk_clk_mux_is_enabled() local
78 regmap_read(mux->regmap, mux->data->mux_ofs, &val); in mtk_clk_mux_is_enabled()
80 return (val & BIT(mux->data->gate_shift)) == 0; in mtk_clk_mux_is_enabled()
85 struct mtk_clk_mux *mux = to_mtk_clk_mux(hw); in mtk_clk_mux_get_parent() local
86 u32 mask = GENMASK(mux->data->mux_width - 1, 0); in mtk_clk_mux_get_parent()
89 regmap_read(mux->regmap, mux->data->mux_ofs, &val); in mtk_clk_mux_get_parent()
90 val = (val >> mux->data->mux_shift) & mask; in mtk_clk_mux_get_parent()
97 struct mtk_clk_mux *mux = to_mtk_clk_mux(hw); in mtk_clk_mux_set_parent_setclr_lock() local
98 u32 mask = GENMASK(mux->data->mux_width - 1, 0); in mtk_clk_mux_set_parent_setclr_lock()
102 if (mux->lock) in mtk_clk_mux_set_parent_setclr_lock()
103 spin_lock_irqsave(mux->lock, flags); in mtk_clk_mux_set_parent_setclr_lock()
105 __acquire(mux->lock); in mtk_clk_mux_set_parent_setclr_lock()
107 regmap_read(mux->regmap, mux->data->mux_ofs, &orig); in mtk_clk_mux_set_parent_setclr_lock()
108 val = (orig & ~(mask << mux->data->mux_shift)) in mtk_clk_mux_set_parent_setclr_lock()
109 | (index << mux->data->mux_shift); in mtk_clk_mux_set_parent_setclr_lock()
112 regmap_write(mux->regmap, mux->data->clr_ofs, in mtk_clk_mux_set_parent_setclr_lock()
113 mask << mux->data->mux_shift); in mtk_clk_mux_set_parent_setclr_lock()
114 regmap_write(mux->regmap, mux->data->set_ofs, in mtk_clk_mux_set_parent_setclr_lock()
115 index << mux->data->mux_shift); in mtk_clk_mux_set_parent_setclr_lock()
117 if (mux->data->upd_shift >= 0) { in mtk_clk_mux_set_parent_setclr_lock()
118 regmap_write(mux->regmap, mux->data->upd_ofs, in mtk_clk_mux_set_parent_setclr_lock()
119 BIT(mux->data->upd_shift)); in mtk_clk_mux_set_parent_setclr_lock()
120 mux->reparent = true; in mtk_clk_mux_set_parent_setclr_lock()
124 if (mux->lock) in mtk_clk_mux_set_parent_setclr_lock()
125 spin_unlock_irqrestore(mux->lock, flags); in mtk_clk_mux_set_parent_setclr_lock()
127 __release(mux->lock); in mtk_clk_mux_set_parent_setclr_lock()
135 struct mtk_clk_mux *mux = to_mtk_clk_mux(hw); in mtk_clk_mux_determine_rate() local
137 return clk_mux_determine_rate_flags(hw, req, mux->data->flags); in mtk_clk_mux_determine_rate()
157 static struct clk_hw *mtk_clk_register_mux(const struct mtk_mux *mux, in mtk_clk_register_mux() argument
169 init.name = mux->name; in mtk_clk_register_mux()
170 init.flags = mux->flags | CLK_SET_RATE_PARENT; in mtk_clk_register_mux()
171 init.parent_names = mux->parent_names; in mtk_clk_register_mux()
172 init.num_parents = mux->num_parents; in mtk_clk_register_mux()
173 init.ops = mux->ops; in mtk_clk_register_mux()
176 clk_mux->data = mux; in mtk_clk_register_mux()
191 struct mtk_clk_mux *mux; in mtk_clk_unregister_mux() local
195 mux = to_mtk_clk_mux(hw); in mtk_clk_unregister_mux()
198 kfree(mux); in mtk_clk_unregister_mux()
217 const struct mtk_mux *mux = &muxes[i]; in mtk_clk_register_muxes() local
219 if (!IS_ERR_OR_NULL(clk_data->hws[mux->id])) { in mtk_clk_register_muxes()
221 node, mux->id); in mtk_clk_register_muxes()
225 hw = mtk_clk_register_mux(mux, regmap, lock); in mtk_clk_register_muxes()
228 pr_err("Failed to register clk %s: %pe\n", mux->name, in mtk_clk_register_muxes()
233 clk_data->hws[mux->id] = hw; in mtk_clk_register_muxes()
240 const struct mtk_mux *mux = &muxes[i]; in mtk_clk_register_muxes() local
242 if (IS_ERR_OR_NULL(clk_data->hws[mux->id])) in mtk_clk_register_muxes()
245 mtk_clk_unregister_mux(clk_data->hws[mux->id]); in mtk_clk_register_muxes()
246 clk_data->hws[mux->id] = ERR_PTR(-ENOENT); in mtk_clk_register_muxes()
262 const struct mtk_mux *mux = &muxes[i - 1]; in mtk_clk_unregister_muxes() local
264 if (IS_ERR_OR_NULL(clk_data->hws[mux->id])) in mtk_clk_unregister_muxes()
267 mtk_clk_unregister_mux(clk_data->hws[mux->id]); in mtk_clk_unregister_muxes()
268 clk_data->hws[mux->id] = ERR_PTR(-ENOENT); in mtk_clk_unregister_muxes()