Skip to content

Commit

Permalink
clk: mux core: allow setting the mux
Browse files Browse the repository at this point in the history
  • Loading branch information
fifteenhex committed Jul 19, 2021
1 parent e72ee99 commit 74407bf
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
19 changes: 18 additions & 1 deletion drivers/clk/mstar/clk-msc313-mux.c
Expand Up @@ -29,9 +29,17 @@ static u8 msc313_mux_mux_get_parent(struct clk_hw *hw)
return index;
}

static int msc313_mux_mux_determine_rate(struct clk_hw *hw, struct clk_rate_request *req)
{
struct msc313_mux *mux = mux_to_mux(hw);

return clk_mux_determine_rate_flags(hw, req, clk_hw_get_flags(&mux->mux_hw));
}

static const struct clk_ops msc313_mux_mux_ops = {
.set_parent = msc313_mux_mux_set_parent,
.get_parent = msc313_mux_mux_get_parent,
.determine_rate = msc313_mux_mux_determine_rate,
};

static int msc313_mux_deglitch_enable(struct clk_hw *hw)
Expand Down Expand Up @@ -87,12 +95,21 @@ static u8 msc313_mux_deglitch_get_parent(struct clk_hw *hw)
return index;
}

static int msc313_mux_deglitch_determine_rate(struct clk_hw *hw,
struct clk_rate_request *req)
{
struct msc313_mux *mux = deglitch_to_mux(hw);

return clk_mux_determine_rate_flags(hw, req, clk_hw_get_flags(&mux->deglitch_hw));
}

static const struct clk_ops msc313_mux_deglitch_ops = {
.enable = msc313_mux_deglitch_enable,
.disable = msc313_mux_deglitch_disable,
.is_enabled = msc313_mux_deglitch_is_enabled,
.set_parent = msc313_mux_deglitch_set_parent,
.get_parent = msc313_mux_deglitch_get_parent,
.determine_rate = msc313_mux_deglitch_determine_rate,
};

struct clk_hw *msc313_mux_xlate(struct of_phandle_args *clkspec, void *data)
Expand Down Expand Up @@ -202,7 +219,7 @@ struct msc313_muxes *msc313_mux_register_muxes(struct device *dev,
deglitch_init.name = mux_data->name;
deglitch_init.parent_data = mux->deglitch_parents;
deglitch_init.num_parents = mux->deglitch ? 2 : 1;
deglitch_init.flags = mux_data->flags;
deglitch_init.flags = mux_data->flags | CLK_SET_RATE_PARENT;
clk_hw = &mux->deglitch_hw;
clk_hw->init = &deglitch_init;

Expand Down
2 changes: 2 additions & 0 deletions drivers/clk/mstar/clk-msc313-mux.h
Expand Up @@ -63,6 +63,8 @@ struct msc313_mux_data {
.mux_shift = _mux_shift, \
.mux_width = _mux_width, \
.deglitch_shift = _deglitch_shift, \
.flags = _flags, \
.mux_flags = _mux_flags, \
}

#define MSC313_MUX_CLK_PARENT_DATA(_name, _parents, _offset, _gate_shift, _mux_shift, _mux_width, _deglitch_shift) \
Expand Down

0 comments on commit 74407bf

Please sign in to comment.