[PATCH 14/14] clk: mediatek: refactor duplicate *_mux_get_rate()
Macpaul Lin (林智斌)
Macpaul.Lin at mediatek.com
Thu Mar 5 15:03:39 CET 2026
On Mon, 2026-03-02 at 18:03 -0600, David Lechner wrote:
> Refactor two identical functions for getting mux clock rates. The
> functions are renamed and moved to the section of the code that
> contains
> other common functions.
>
> Signed-off-by: David Lechner <dlechner at baylibre.com>
> ---
> drivers/clk/mediatek/clk-mtk.c | 50 ++++++++++++++------------------
> ----------
> 1 file changed, 17 insertions(+), 33 deletions(-)
>
> diff --git a/drivers/clk/mediatek/clk-mtk.c
> b/drivers/clk/mediatek/clk-mtk.c
> index c65230a7f9b..c5f6d45fd67 100644
> --- a/drivers/clk/mediatek/clk-mtk.c
> +++ b/drivers/clk/mediatek/clk-mtk.c
> @@ -253,6 +253,21 @@ static ulong mtk_find_parent_rate(struct
> mtk_clk_priv *priv, struct clk *clk,
> return mtk_clk_find_parent_rate(clk, parent, parent_dev);
> }
>
> +static ulong mtk_clk_mux_get_rate(struct clk *clk, u32 off)
> +{
> + struct mtk_clk_priv *priv = dev_get_priv(clk->dev);
> + const struct mtk_composite *mux = &priv->tree->muxes[off];
> + const struct mtk_parent *parent;
> + u32 index;
> +
> + index = readl(priv->base + mux->mux_reg);
> + index &= mux->mux_mask << mux->mux_shift;
> + index = index >> mux->mux_shift;
> + parent = &mux->parent[index];
> +
> + return mtk_find_parent_rate(priv, clk, parent->id, parent-
> >flags);
> +}
> +
> static int mtk_clk_mux_set_parent(void __iomem *base, u32 parent,
> u32 parent_type,
> const struct mtk_composite *mux)
[snip...]
Reviewed-by: Macpaul Lin <macpaul.lin at mediatek.com>
Thanks,
Macpaul Lin
More information about the U-Boot
mailing list