clk: mediatek: clk-mt8186-topckgen: Migrate to mtk_clk_simple_probe()
As done with MT8192, migrate MT8186 topckgen away from a custom probe function and use mtk_clk_simple_{probe, remove}(). Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Reviewed-by: Miles Chen <miles.chen@mediatek.com> Reviewed-by: Chen-Yu Tsai <wenst@chromium.org> Link: https://lore.kernel.org/r/20230120092053.182923-21-angelogioacchino.delregno@collabora.com Tested-by: Mingming Su <mingming.su@mediatek.com> Signed-off-by: Stephen Boyd <sboyd@kernel.org>
This commit is contained in:
parent
e09eb9d240
commit
75c12ea37a
|
@ -681,11 +681,6 @@ static struct mtk_composite top_muxes[] = {
|
|||
0x0320, 4, 0x0334, 8, 0),
|
||||
};
|
||||
|
||||
static const struct of_device_id of_match_clk_mt8186_topck[] = {
|
||||
{ .compatible = "mediatek,mt8186-topckgen", },
|
||||
{}
|
||||
};
|
||||
|
||||
/* Register mux notifier for MFG mux */
|
||||
static int clk_mt8186_reg_mfg_mux_notifier(struct device *dev, struct clk *clk)
|
||||
{
|
||||
|
@ -708,88 +703,28 @@ static int clk_mt8186_reg_mfg_mux_notifier(struct device *dev, struct clk *clk)
|
|||
return devm_mtk_clk_mux_notifier_register(dev, clk, mfg_mux_nb);
|
||||
}
|
||||
|
||||
static int clk_mt8186_topck_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct clk_hw_onecell_data *clk_data;
|
||||
struct device_node *node = pdev->dev.of_node;
|
||||
int r;
|
||||
void __iomem *base;
|
||||
static const struct mtk_clk_desc topck_desc = {
|
||||
.fixed_clks = top_fixed_clks,
|
||||
.num_fixed_clks = ARRAY_SIZE(top_fixed_clks),
|
||||
.factor_clks = top_divs,
|
||||
.num_factor_clks = ARRAY_SIZE(top_divs),
|
||||
.mux_clks = top_mtk_muxes,
|
||||
.num_mux_clks = ARRAY_SIZE(top_mtk_muxes),
|
||||
.composite_clks = top_muxes,
|
||||
.num_composite_clks = ARRAY_SIZE(top_muxes),
|
||||
.clk_lock = &mt8186_clk_lock,
|
||||
.clk_notifier_func = clk_mt8186_reg_mfg_mux_notifier,
|
||||
.mfg_clk_idx = CLK_TOP_MFG,
|
||||
};
|
||||
|
||||
clk_data = mtk_alloc_clk_data(CLK_TOP_NR_CLK);
|
||||
if (!clk_data)
|
||||
return -ENOMEM;
|
||||
|
||||
base = devm_platform_ioremap_resource(pdev, 0);
|
||||
if (IS_ERR(base)) {
|
||||
r = PTR_ERR(base);
|
||||
goto free_top_data;
|
||||
}
|
||||
|
||||
r = mtk_clk_register_fixed_clks(top_fixed_clks, ARRAY_SIZE(top_fixed_clks),
|
||||
clk_data);
|
||||
if (r)
|
||||
goto free_top_data;
|
||||
|
||||
r = mtk_clk_register_factors(top_divs, ARRAY_SIZE(top_divs), clk_data);
|
||||
if (r)
|
||||
goto unregister_fixed_clks;
|
||||
|
||||
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;
|
||||
|
||||
r = mtk_clk_register_composites(&pdev->dev, top_muxes,
|
||||
ARRAY_SIZE(top_muxes), base,
|
||||
&mt8186_clk_lock, clk_data);
|
||||
if (r)
|
||||
goto unregister_muxes;
|
||||
|
||||
r = clk_mt8186_reg_mfg_mux_notifier(&pdev->dev,
|
||||
clk_data->hws[CLK_TOP_MFG]->clk);
|
||||
if (r)
|
||||
goto unregister_composite_muxes;
|
||||
|
||||
r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
|
||||
if (r)
|
||||
goto unregister_composite_muxes;
|
||||
|
||||
platform_set_drvdata(pdev, clk_data);
|
||||
|
||||
return r;
|
||||
|
||||
unregister_composite_muxes:
|
||||
mtk_clk_unregister_composites(top_muxes, ARRAY_SIZE(top_muxes), clk_data);
|
||||
unregister_muxes:
|
||||
mtk_clk_unregister_muxes(top_mtk_muxes, ARRAY_SIZE(top_mtk_muxes), clk_data);
|
||||
unregister_factors:
|
||||
mtk_clk_unregister_factors(top_divs, ARRAY_SIZE(top_divs), clk_data);
|
||||
unregister_fixed_clks:
|
||||
mtk_clk_unregister_fixed_clks(top_fixed_clks, ARRAY_SIZE(top_fixed_clks), clk_data);
|
||||
free_top_data:
|
||||
mtk_free_clk_data(clk_data);
|
||||
return r;
|
||||
}
|
||||
|
||||
static int clk_mt8186_topck_remove(struct platform_device *pdev)
|
||||
{
|
||||
struct clk_hw_onecell_data *clk_data = platform_get_drvdata(pdev);
|
||||
struct device_node *node = pdev->dev.of_node;
|
||||
|
||||
of_clk_del_provider(node);
|
||||
mtk_clk_unregister_composites(top_muxes, ARRAY_SIZE(top_muxes), clk_data);
|
||||
mtk_clk_unregister_muxes(top_mtk_muxes, ARRAY_SIZE(top_mtk_muxes), clk_data);
|
||||
mtk_clk_unregister_factors(top_divs, ARRAY_SIZE(top_divs), clk_data);
|
||||
mtk_clk_unregister_fixed_clks(top_fixed_clks, ARRAY_SIZE(top_fixed_clks), clk_data);
|
||||
mtk_free_clk_data(clk_data);
|
||||
|
||||
return 0;
|
||||
}
|
||||
static const struct of_device_id of_match_clk_mt8186_topck[] = {
|
||||
{ .compatible = "mediatek,mt8186-topckgen", .data = &topck_desc },
|
||||
{ /* sentinel */ }
|
||||
};
|
||||
|
||||
static struct platform_driver clk_mt8186_topck_drv = {
|
||||
.probe = clk_mt8186_topck_probe,
|
||||
.remove = clk_mt8186_topck_remove,
|
||||
.probe = mtk_clk_simple_probe,
|
||||
.remove = mtk_clk_simple_remove,
|
||||
.driver = {
|
||||
.name = "clk-mt8186-topck",
|
||||
.of_match_table = of_match_clk_mt8186_topck,
|
||||
|
|
Loading…
Reference in New Issue