Skip to content

Commit 54b7026

Browse files
AngeloGioacchino Del Regnobebarino
authored andcommitted
clk: mediatek: mt8135-apmixedsys: Convert to platform_driver and module
Convert apmixedsys clocks to be a platform driver; while at it, also add necessary error handling to the probe function, add a remove callback and provide a MODULE_DESCRIPTION(). This driver is now compatible with an eventual module build. Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Reviewed-by: Chen-Yu Tsai <wenst@chromium.org> Link: https://lore.kernel.org/r/20230306140543.1813621-53-angelogioacchino.delregno@collabora.com Signed-off-by: Stephen Boyd <sboyd@kernel.org>
1 parent f4f9a9c commit 54b7026

1 file changed

Lines changed: 48 additions & 5 deletions

File tree

drivers/clk/mediatek/clk-mt8135-apmixedsys.c

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,59 @@ static const struct mtk_pll_data plls[] = {
4747
PLL(CLK_APMIXED_VDECPLL, "vdecpll", 0x304, 0x31c, 0x80000000, 0, 21, 0x2b0, 6, 0x0, 0x308, 0),
4848
};
4949

50-
static void __init mtk_apmixedsys_init(struct device_node *node)
50+
static int clk_mt8135_apmixed_probe(struct platform_device *pdev)
5151
{
5252
struct clk_hw_onecell_data *clk_data;
53+
struct device_node *node = pdev->dev.of_node;
54+
int ret;
5355

5456
clk_data = mtk_alloc_clk_data(CLK_APMIXED_NR_CLK);
5557
if (!clk_data)
56-
return;
58+
return -ENOMEM;
5759

58-
mtk_clk_register_plls(node, plls, ARRAY_SIZE(plls), clk_data);
60+
ret = mtk_clk_register_plls(node, plls, ARRAY_SIZE(plls), clk_data);
61+
if (ret)
62+
return ret;
63+
64+
ret = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
65+
if (ret)
66+
goto unregister_plls;
67+
68+
return 0;
69+
70+
unregister_plls:
71+
mtk_clk_unregister_plls(plls, ARRAY_SIZE(plls), clk_data);
72+
73+
return ret;
74+
}
75+
76+
static int clk_mt8135_apmixed_remove(struct platform_device *pdev)
77+
{
78+
struct device_node *node = pdev->dev.of_node;
79+
struct clk_hw_onecell_data *clk_data = platform_get_drvdata(pdev);
80+
81+
of_clk_del_provider(node);
82+
mtk_clk_unregister_plls(plls, ARRAY_SIZE(plls), clk_data);
83+
mtk_free_clk_data(clk_data);
84+
85+
return 0;
5986
}
60-
CLK_OF_DECLARE(mtk_apmixedsys, "mediatek,mt8135-apmixedsys",
61-
mtk_apmixedsys_init);
87+
88+
static const struct of_device_id of_match_clk_mt8135_apmixed[] = {
89+
{ .compatible = "mediatek,mt8135-apmixedsys" },
90+
{ /* sentinel */ }
91+
};
92+
MODULE_DEVICE_TABLE(of, of_match_clk_mt8135_apmixed);
93+
94+
static struct platform_driver clk_mt8135_apmixed_drv = {
95+
.probe = clk_mt8135_apmixed_probe,
96+
.remove = clk_mt8135_apmixed_remove,
97+
.driver = {
98+
.name = "clk-mt8135-apmixed",
99+
.of_match_table = of_match_clk_mt8135_apmixed,
100+
},
101+
};
102+
module_platform_driver(clk_mt8135_apmixed_drv)
103+
104+
MODULE_DESCRIPTION("MediaTek MT8135 apmixedsys clocks driver");
62105
MODULE_LICENSE("GPL");

0 commit comments

Comments
 (0)