Skip to content

Commit 72feb6f

Browse files
AngeloGioacchino Del Regnobebarino
authored andcommitted
clk: mediatek: clk-mt6795-topckgen: Migrate to mtk_clk_simple_probe()
Migrate away from custom probe functions and use the commonized 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-22-angelogioacchino.delregno@collabora.com Tested-by: Mingming Su <mingming.su@mediatek.com> Signed-off-by: Stephen Boyd <sboyd@kernel.org>
1 parent 75c12ea commit 72feb6f

1 file changed

Lines changed: 14 additions & 72 deletions

File tree

drivers/clk/mediatek/clk-mt6795-topckgen.c

Lines changed: 14 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -523,88 +523,30 @@ static struct mtk_composite top_aud_divs[] = {
523523
DIV_GATE(CLK_TOP_APLL2_DIV5, "apll2_div5", "apll2_div4", 0x12c, 21, 0x12c, 4, 4),
524524
};
525525

526+
static const struct mtk_clk_desc topck_desc = {
527+
.fixed_clks = fixed_clks,
528+
.num_fixed_clks = ARRAY_SIZE(fixed_clks),
529+
.factor_clks = top_divs,
530+
.num_factor_clks = ARRAY_SIZE(top_divs),
531+
.mux_clks = top_muxes,
532+
.num_mux_clks = ARRAY_SIZE(top_muxes),
533+
.composite_clks = top_aud_divs,
534+
.num_composite_clks = ARRAY_SIZE(top_aud_divs),
535+
.clk_lock = &mt6795_top_clk_lock,
536+
};
526537

527538
static const struct of_device_id of_match_clk_mt6795_topckgen[] = {
528-
{ .compatible = "mediatek,mt6795-topckgen" },
539+
{ .compatible = "mediatek,mt6795-topckgen", .data = &topck_desc },
529540
{ /* sentinel */ }
530541
};
531542

532-
static int clk_mt6795_topckgen_probe(struct platform_device *pdev)
533-
{
534-
struct clk_hw_onecell_data *clk_data;
535-
struct device_node *node = pdev->dev.of_node;
536-
void __iomem *base;
537-
int ret;
538-
539-
base = devm_platform_ioremap_resource(pdev, 0);
540-
if (IS_ERR(base))
541-
return PTR_ERR(base);
542-
543-
clk_data = mtk_alloc_clk_data(CLK_TOP_NR_CLK);
544-
if (!clk_data)
545-
return -ENOMEM;
546-
547-
ret = mtk_clk_register_fixed_clks(fixed_clks, ARRAY_SIZE(fixed_clks), clk_data);
548-
if (ret)
549-
goto free_clk_data;
550-
551-
ret = mtk_clk_register_factors(top_divs, ARRAY_SIZE(top_divs), clk_data);
552-
if (ret)
553-
goto unregister_fixed_clks;
554-
555-
ret = mtk_clk_register_muxes(&pdev->dev, top_muxes,
556-
ARRAY_SIZE(top_muxes), node,
557-
&mt6795_top_clk_lock, clk_data);
558-
if (ret)
559-
goto unregister_factors;
560-
561-
ret = mtk_clk_register_composites(&pdev->dev, top_aud_divs,
562-
ARRAY_SIZE(top_aud_divs), base,
563-
&mt6795_top_clk_lock, clk_data);
564-
if (ret)
565-
goto unregister_muxes;
566-
567-
ret = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
568-
if (ret)
569-
goto unregister_composites;
570-
571-
return 0;
572-
573-
unregister_composites:
574-
mtk_clk_unregister_composites(top_aud_divs, ARRAY_SIZE(top_aud_divs), clk_data);
575-
unregister_muxes:
576-
mtk_clk_unregister_muxes(top_muxes, ARRAY_SIZE(top_muxes), clk_data);
577-
unregister_factors:
578-
mtk_clk_unregister_factors(top_divs, ARRAY_SIZE(top_divs), clk_data);
579-
unregister_fixed_clks:
580-
mtk_clk_unregister_fixed_clks(fixed_clks, ARRAY_SIZE(fixed_clks), clk_data);
581-
free_clk_data:
582-
mtk_free_clk_data(clk_data);
583-
return ret;
584-
}
585-
586-
static int clk_mt6795_topckgen_remove(struct platform_device *pdev)
587-
{
588-
struct device_node *node = pdev->dev.of_node;
589-
struct clk_hw_onecell_data *clk_data = platform_get_drvdata(pdev);
590-
591-
of_clk_del_provider(node);
592-
mtk_clk_unregister_composites(top_aud_divs, ARRAY_SIZE(top_aud_divs), clk_data);
593-
mtk_clk_unregister_muxes(top_muxes, ARRAY_SIZE(top_muxes), clk_data);
594-
mtk_clk_unregister_factors(top_divs, ARRAY_SIZE(top_divs), clk_data);
595-
mtk_clk_unregister_fixed_clks(fixed_clks, ARRAY_SIZE(fixed_clks), clk_data);
596-
mtk_free_clk_data(clk_data);
597-
598-
return 0;
599-
}
600-
601543
static struct platform_driver clk_mt6795_topckgen_drv = {
602544
.driver = {
603545
.name = "clk-mt6795-topckgen",
604546
.of_match_table = of_match_clk_mt6795_topckgen,
605547
},
606-
.probe = clk_mt6795_topckgen_probe,
607-
.remove = clk_mt6795_topckgen_remove,
548+
.probe = mtk_clk_simple_probe,
549+
.remove = mtk_clk_simple_remove,
608550
};
609551
module_platform_driver(clk_mt6795_topckgen_drv);
610552

0 commit comments

Comments
 (0)