Lines Matching full:mux
13 #include "clk-mux.h"
22 struct mtk_clk_mux *mux = to_mtk_clk_mux(hw); in mtk_clk_mux_enable() local
23 u32 mask = BIT(mux->data->gate_shift); in mtk_clk_mux_enable()
25 return regmap_update_bits(mux->regmap, mux->data->mux_ofs, in mtk_clk_mux_enable()
31 struct mtk_clk_mux *mux = to_mtk_clk_mux(hw); in mtk_clk_mux_disable() local
32 u32 mask = BIT(mux->data->gate_shift); in mtk_clk_mux_disable()
34 regmap_update_bits(mux->regmap, mux->data->mux_ofs, mask, mask); in mtk_clk_mux_disable()
39 struct mtk_clk_mux *mux = to_mtk_clk_mux(hw); in mtk_clk_mux_enable_setclr() local
41 return regmap_write(mux->regmap, mux->data->clr_ofs, in mtk_clk_mux_enable_setclr()
42 BIT(mux->data->gate_shift)); in mtk_clk_mux_enable_setclr()
47 struct mtk_clk_mux *mux = to_mtk_clk_mux(hw); in mtk_clk_mux_disable_setclr() local
49 regmap_write(mux->regmap, mux->data->set_ofs, in mtk_clk_mux_disable_setclr()
50 BIT(mux->data->gate_shift)); in mtk_clk_mux_disable_setclr()
55 struct mtk_clk_mux *mux = to_mtk_clk_mux(hw); in mtk_clk_mux_is_enabled() local
58 regmap_read(mux->regmap, mux->data->mux_ofs, &val); in mtk_clk_mux_is_enabled()
60 return (val & BIT(mux->data->gate_shift)) == 0; in mtk_clk_mux_is_enabled()
65 struct mtk_clk_mux *mux = to_mtk_clk_mux(hw); in mtk_clk_mux_get_parent() local
66 u32 mask = GENMASK(mux->data->mux_width - 1, 0); in mtk_clk_mux_get_parent()
69 regmap_read(mux->regmap, mux->data->mux_ofs, &val); in mtk_clk_mux_get_parent()
70 val = (val >> mux->data->mux_shift) & mask; in mtk_clk_mux_get_parent()
77 struct mtk_clk_mux *mux = to_mtk_clk_mux(hw); in mtk_clk_mux_set_parent_lock() local
78 u32 mask = GENMASK(mux->data->mux_width - 1, 0); in mtk_clk_mux_set_parent_lock()
81 if (mux->lock) in mtk_clk_mux_set_parent_lock()
82 spin_lock_irqsave(mux->lock, flags); in mtk_clk_mux_set_parent_lock()
84 __acquire(mux->lock); in mtk_clk_mux_set_parent_lock()
86 regmap_update_bits(mux->regmap, mux->data->mux_ofs, mask, in mtk_clk_mux_set_parent_lock()
87 index << mux->data->mux_shift); in mtk_clk_mux_set_parent_lock()
89 if (mux->lock) in mtk_clk_mux_set_parent_lock()
90 spin_unlock_irqrestore(mux->lock, flags); in mtk_clk_mux_set_parent_lock()
92 __release(mux->lock); in mtk_clk_mux_set_parent_lock()
99 struct mtk_clk_mux *mux = to_mtk_clk_mux(hw); in mtk_clk_mux_set_parent_setclr_lock() local
100 u32 mask = GENMASK(mux->data->mux_width - 1, 0); in mtk_clk_mux_set_parent_setclr_lock()
104 if (mux->lock) in mtk_clk_mux_set_parent_setclr_lock()
105 spin_lock_irqsave(mux->lock, flags); in mtk_clk_mux_set_parent_setclr_lock()
107 __acquire(mux->lock); in mtk_clk_mux_set_parent_setclr_lock()
109 regmap_read(mux->regmap, mux->data->mux_ofs, &orig); in mtk_clk_mux_set_parent_setclr_lock()
110 val = (orig & ~(mask << mux->data->mux_shift)) in mtk_clk_mux_set_parent_setclr_lock()
111 | (index << mux->data->mux_shift); in mtk_clk_mux_set_parent_setclr_lock()
114 regmap_write(mux->regmap, mux->data->clr_ofs, in mtk_clk_mux_set_parent_setclr_lock()
115 mask << mux->data->mux_shift); in mtk_clk_mux_set_parent_setclr_lock()
116 regmap_write(mux->regmap, mux->data->set_ofs, in mtk_clk_mux_set_parent_setclr_lock()
117 index << mux->data->mux_shift); in mtk_clk_mux_set_parent_setclr_lock()
119 if (mux->data->upd_shift >= 0) in mtk_clk_mux_set_parent_setclr_lock()
120 regmap_write(mux->regmap, mux->data->upd_ofs, in mtk_clk_mux_set_parent_setclr_lock()
121 BIT(mux->data->upd_shift)); 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()
158 struct clk *mtk_clk_register_mux(const struct mtk_mux *mux, in mtk_clk_register_mux() argument
170 init.name = mux->name; in mtk_clk_register_mux()
171 init.flags = mux->flags | CLK_SET_RATE_PARENT; in mtk_clk_register_mux()
172 init.parent_names = mux->parent_names; in mtk_clk_register_mux()
173 init.num_parents = mux->num_parents; in mtk_clk_register_mux()
174 init.ops = mux->ops; in mtk_clk_register_mux()
177 clk_mux->data = mux; in mtk_clk_register_mux()
207 const struct mtk_mux *mux = &muxes[i]; in mtk_clk_register_muxes() local
209 if (IS_ERR_OR_NULL(clk_data->clks[mux->id])) { in mtk_clk_register_muxes()
210 clk = mtk_clk_register_mux(mux, regmap, lock); in mtk_clk_register_muxes()
214 mux->name, PTR_ERR(clk)); in mtk_clk_register_muxes()
218 clk_data->clks[mux->id] = clk; in mtk_clk_register_muxes()