Skip to content

Commit

Permalink
clk: mediatek: clk-mux: Propagate struct device for mtk-mux
Browse files Browse the repository at this point in the history
Like done for other clocks, propagate struct device for mtk mux clocks
registered through clk-mux helpers to enable runtime pm support.

Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Tested-by: Miles Chen <miles.chen@mediatek.com>
Link: https://lore.kernel.org/r/20230120092053.182923-7-angelogioacchino.delregno@collabora.com
Tested-by: Mingming Su <mingming.su@mediatek.com>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
  • Loading branch information
AngeloGioacchino Del Regno authored and Stephen Boyd committed Jan 31, 2023
1 parent 01a6c1a commit d3d6bd5
Show file tree
Hide file tree
Showing 12 changed files with 32 additions and 19 deletions.
3 changes: 2 additions & 1 deletion drivers/clk/mediatek/clk-mt6765.c
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,8 @@ static int clk_mt6765_top_probe(struct platform_device *pdev)
clk_data);
mtk_clk_register_factors(top_divs, ARRAY_SIZE(top_divs),
clk_data);
mtk_clk_register_muxes(top_muxes, ARRAY_SIZE(top_muxes), node,
mtk_clk_register_muxes(&pdev->dev, top_muxes,
ARRAY_SIZE(top_muxes), node,
&mt6765_clk_lock, clk_data);
mtk_clk_register_gates(&pdev->dev, node, top_clks,
ARRAY_SIZE(top_clks), clk_data);
Expand Down
5 changes: 3 additions & 2 deletions drivers/clk/mediatek/clk-mt6779.c
Original file line number Diff line number Diff line change
Expand Up @@ -1244,8 +1244,9 @@ static int clk_mt6779_top_probe(struct platform_device *pdev)

mtk_clk_register_factors(top_divs, ARRAY_SIZE(top_divs), clk_data);

mtk_clk_register_muxes(top_muxes, ARRAY_SIZE(top_muxes),
node, &mt6779_clk_lock, clk_data);
mtk_clk_register_muxes(&pdev->dev, top_muxes,
ARRAY_SIZE(top_muxes), node,
&mt6779_clk_lock, clk_data);

mtk_clk_register_composites(&pdev->dev, top_aud_muxes,
ARRAY_SIZE(top_aud_muxes), base,
Expand Down
3 changes: 2 additions & 1 deletion drivers/clk/mediatek/clk-mt6795-topckgen.c
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,8 @@ static int clk_mt6795_topckgen_probe(struct platform_device *pdev)
if (ret)
goto unregister_fixed_clks;

ret = mtk_clk_register_muxes(top_muxes, ARRAY_SIZE(top_muxes), node,
ret = mtk_clk_register_muxes(&pdev->dev, top_muxes,
ARRAY_SIZE(top_muxes), node,
&mt6795_top_clk_lock, clk_data);
if (ret)
goto unregister_factors;
Expand Down
3 changes: 2 additions & 1 deletion drivers/clk/mediatek/clk-mt7986-infracfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,8 @@ static int clk_mt7986_infracfg_probe(struct platform_device *pdev)
return -ENOMEM;

mtk_clk_register_factors(infra_divs, ARRAY_SIZE(infra_divs), clk_data);
mtk_clk_register_muxes(infra_muxes, ARRAY_SIZE(infra_muxes), node,
mtk_clk_register_muxes(&pdev->dev, infra_muxes,
ARRAY_SIZE(infra_muxes), node,
&mt7986_clk_lock, clk_data);
mtk_clk_register_gates(&pdev->dev, node, infra_clks,
ARRAY_SIZE(infra_clks), clk_data);
Expand Down
3 changes: 2 additions & 1 deletion drivers/clk/mediatek/clk-mt7986-topckgen.c
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,8 @@ static int clk_mt7986_topckgen_probe(struct platform_device *pdev)
mtk_clk_register_fixed_clks(top_fixed_clks, ARRAY_SIZE(top_fixed_clks),
clk_data);
mtk_clk_register_factors(top_divs, ARRAY_SIZE(top_divs), clk_data);
mtk_clk_register_muxes(top_muxes, ARRAY_SIZE(top_muxes), node,
mtk_clk_register_muxes(&pdev->dev, top_muxes,
ARRAY_SIZE(top_muxes), node,
&mt7986_clk_lock, clk_data);

clk_prepare_enable(clk_data->hws[CLK_TOP_SYSAXI_SEL]->clk);
Expand Down
5 changes: 3 additions & 2 deletions drivers/clk/mediatek/clk-mt8183.c
Original file line number Diff line number Diff line change
Expand Up @@ -1166,8 +1166,9 @@ static int clk_mt8183_top_probe(struct platform_device *pdev)

mtk_clk_register_factors(top_divs, ARRAY_SIZE(top_divs), top_clk_data);

mtk_clk_register_muxes(top_muxes, ARRAY_SIZE(top_muxes),
node, &mt8183_clk_lock, top_clk_data);
mtk_clk_register_muxes(&pdev->dev, top_muxes,
ARRAY_SIZE(top_muxes), node,
&mt8183_clk_lock, top_clk_data);

mtk_clk_register_composites(&pdev->dev, top_aud_muxes,
ARRAY_SIZE(top_aud_muxes), base,
Expand Down
3 changes: 2 additions & 1 deletion drivers/clk/mediatek/clk-mt8186-topckgen.c
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,8 @@ static int clk_mt8186_topck_probe(struct platform_device *pdev)
if (r)
goto unregister_fixed_clks;

r = mtk_clk_register_muxes(top_mtk_muxes, ARRAY_SIZE(top_mtk_muxes), node,
r = mtk_clk_register_muxes(&pdev->dev, top_mtk_muxes,
ARRAY_SIZE(top_mtk_muxes), node,
&mt8186_clk_lock, clk_data);
if (r)
goto unregister_factors;
Expand Down
3 changes: 2 additions & 1 deletion drivers/clk/mediatek/clk-mt8192.c
Original file line number Diff line number Diff line change
Expand Up @@ -1112,7 +1112,8 @@ static int clk_mt8192_top_probe(struct platform_device *pdev)
if (r)
goto unregister_early_factors;

r = mtk_clk_register_muxes(top_mtk_muxes, ARRAY_SIZE(top_mtk_muxes), node,
r = mtk_clk_register_muxes(&pdev->dev, top_mtk_muxes,
ARRAY_SIZE(top_mtk_muxes), node,
&mt8192_clk_lock, top_clk_data);
if (r)
goto unregister_factors;
Expand Down
3 changes: 2 additions & 1 deletion drivers/clk/mediatek/clk-mt8195-topckgen.c
Original file line number Diff line number Diff line change
Expand Up @@ -1262,7 +1262,8 @@ static int clk_mt8195_topck_probe(struct platform_device *pdev)
if (r)
goto unregister_fixed_clks;

r = mtk_clk_register_muxes(top_mtk_muxes, ARRAY_SIZE(top_mtk_muxes), node,
r = mtk_clk_register_muxes(&pdev->dev, top_mtk_muxes,
ARRAY_SIZE(top_mtk_muxes), node,
&mt8195_clk_lock, top_clk_data);
if (r)
goto unregister_factors;
Expand Down
3 changes: 2 additions & 1 deletion drivers/clk/mediatek/clk-mt8365.c
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,8 @@ static int clk_mt8365_top_probe(struct platform_device *pdev)
if (ret)
goto unregister_fixed_clks;

ret = mtk_clk_register_muxes(top_muxes, ARRAY_SIZE(top_muxes), node,
ret = mtk_clk_register_muxes(&pdev->dev, top_muxes,
ARRAY_SIZE(top_muxes), node,
&mt8365_clk_lock, clk_data);
if (ret)
goto unregister_factors;
Expand Down
14 changes: 8 additions & 6 deletions drivers/clk/mediatek/clk-mux.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,10 @@ const struct clk_ops mtk_mux_gate_clr_set_upd_ops = {
};
EXPORT_SYMBOL_GPL(mtk_mux_gate_clr_set_upd_ops);

static struct clk_hw *mtk_clk_register_mux(const struct mtk_mux *mux,
struct regmap *regmap,
spinlock_t *lock)
static struct clk_hw *mtk_clk_register_mux(struct device *dev,
const struct mtk_mux *mux,
struct regmap *regmap,
spinlock_t *lock)
{
struct mtk_clk_mux *clk_mux;
struct clk_init_data init = {};
Expand All @@ -177,7 +178,7 @@ static struct clk_hw *mtk_clk_register_mux(const struct mtk_mux *mux,
clk_mux->lock = lock;
clk_mux->hw.init = &init;

ret = clk_hw_register(NULL, &clk_mux->hw);
ret = clk_hw_register(dev, &clk_mux->hw);
if (ret) {
kfree(clk_mux);
return ERR_PTR(ret);
Expand All @@ -198,7 +199,8 @@ static void mtk_clk_unregister_mux(struct clk_hw *hw)
kfree(mux);
}

int mtk_clk_register_muxes(const struct mtk_mux *muxes,
int mtk_clk_register_muxes(struct device *dev,
const struct mtk_mux *muxes,
int num, struct device_node *node,
spinlock_t *lock,
struct clk_hw_onecell_data *clk_data)
Expand All @@ -222,7 +224,7 @@ int mtk_clk_register_muxes(const struct mtk_mux *muxes,
continue;
}

hw = mtk_clk_register_mux(mux, regmap, lock);
hw = mtk_clk_register_mux(dev, mux, regmap, lock);

if (IS_ERR(hw)) {
pr_err("Failed to register clk %s: %pe\n", mux->name,
Expand Down
3 changes: 2 additions & 1 deletion drivers/clk/mediatek/clk-mux.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ extern const struct clk_ops mtk_mux_gate_clr_set_upd_ops;
0, _upd_ofs, _upd, CLK_SET_RATE_PARENT, \
mtk_mux_clr_set_upd_ops)

int mtk_clk_register_muxes(const struct mtk_mux *muxes,
int mtk_clk_register_muxes(struct device *dev,
const struct mtk_mux *muxes,
int num, struct device_node *node,
spinlock_t *lock,
struct clk_hw_onecell_data *clk_data);
Expand Down

0 comments on commit d3d6bd5

Please sign in to comment.