[PATCH 27/32] clk: mediatek: mt8186-apmixedsys: Switch to common probe/remove helpers
From: Akari Tsuyukusa
Date: Mon Aug 03 2026 - 10:58:27 EST
The MT8186 apmixedsys driver can use the MediaTek clock framework
common initialization sequence. Reduce boilerplate code by creating
struct mtk_clk_desc and using the mtk_clk_simple_probe/remove helpers.
Signed-off-by: Akari Tsuyukusa <akkun11.open@xxxxxxxxx>
---
drivers/clk/mediatek/clk-mt8186-apmixedsys.c | 59 ++++----------------
1 file changed, 11 insertions(+), 48 deletions(-)
diff --git a/drivers/clk/mediatek/clk-mt8186-apmixedsys.c b/drivers/clk/mediatek/clk-mt8186-apmixedsys.c
index d35dd2632e43..b674b1e581a5 100644
--- a/drivers/clk/mediatek/clk-mt8186-apmixedsys.c
+++ b/drivers/clk/mediatek/clk-mt8186-apmixedsys.c
@@ -132,60 +132,23 @@ static struct mtk_pllfh_data pllfhs[] = {
FH(CLK_APMIXED_MSDCPLL, FH_MSDCPLL, 0x0118),
};
+static const struct mtk_clk_desc apmixed_desc = {
+ .plls = plls,
+ .num_plls = ARRAY_SIZE(plls),
+ .fhctl_node = "mediatek,mt8186-fhctl",
+ .pllfhs = pllfhs,
+ .num_pllfhs = ARRAY_SIZE(pllfhs),
+};
+
static const struct of_device_id of_match_clk_mt8186_apmixed[] = {
- { .compatible = "mediatek,mt8186-apmixedsys", },
+ { .compatible = "mediatek,mt8186-apmixedsys", .data = &apmixed_desc },
{}
};
MODULE_DEVICE_TABLE(of, of_match_clk_mt8186_apmixed);
-static int clk_mt8186_apmixed_probe(struct platform_device *pdev)
-{
- struct clk_hw_onecell_data *clk_data;
- struct device_node *node = pdev->dev.of_node;
- const u8 *fhctl_node = "mediatek,mt8186-fhctl";
- int r;
-
- clk_data = mtk_alloc_clk_data(CLK_APMIXED_NR_CLK);
- if (!clk_data)
- return -ENOMEM;
-
- fhctl_parse_dt(fhctl_node, pllfhs, ARRAY_SIZE(pllfhs));
-
- r = mtk_clk_register_pllfhs(&pdev->dev, plls, ARRAY_SIZE(plls),
- pllfhs, ARRAY_SIZE(pllfhs), clk_data);
- if (r)
- goto free_apmixed_data;
-
- r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
- if (r)
- goto unregister_plls;
-
- platform_set_drvdata(pdev, clk_data);
-
- return r;
-
-unregister_plls:
- mtk_clk_unregister_pllfhs(plls, ARRAY_SIZE(plls), pllfhs,
- ARRAY_SIZE(pllfhs), clk_data);
-free_apmixed_data:
- mtk_free_clk_data(clk_data);
- return r;
-}
-
-static void clk_mt8186_apmixed_remove(struct platform_device *pdev)
-{
- struct device_node *node = pdev->dev.of_node;
- struct clk_hw_onecell_data *clk_data = platform_get_drvdata(pdev);
-
- of_clk_del_provider(node);
- mtk_clk_unregister_pllfhs(plls, ARRAY_SIZE(plls), pllfhs,
- ARRAY_SIZE(pllfhs), clk_data);
- mtk_free_clk_data(clk_data);
-}
-
static struct platform_driver clk_mt8186_apmixed_drv = {
- .probe = clk_mt8186_apmixed_probe,
- .remove = clk_mt8186_apmixed_remove,
+ .probe = mtk_clk_simple_probe,
+ .remove = mtk_clk_simple_remove,
.driver = {
.name = "clk-mt8186-apmixed",
.of_match_table = of_match_clk_mt8186_apmixed,
--
2.55.0