From: Akari Tsuyukusa <akkun11.open@gmail.com>
To: mturquette@baylibre.com, sboyd@kernel.org,
matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com
Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org,
Akari Tsuyukusa <akkun11.open@gmail.com>
Subject: [PATCH 3/3] clk: mediatek: mt7622-infracfg: Switch to common probe/remove helpers
Date: Thu, 5 Mar 2026 03:10:24 +0900 [thread overview]
Message-ID: <20260304181024.738391-4-akkun11.open@gmail.com> (raw)
In-Reply-To: <20260304181024.738391-1-akkun11.open@gmail.com>
The MT7622 infracfg driver can use the MediaTek clock framework's common
initialization sequence. Reduce the boilerplate code by creating
struct mtk_clk_desc and using the mtk_clk_simple_probe/remove helpers.
Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com>
---
drivers/clk/mediatek/clk-mt7622-infracfg.c | 70 ++++------------------
1 file changed, 11 insertions(+), 59 deletions(-)
diff --git a/drivers/clk/mediatek/clk-mt7622-infracfg.c b/drivers/clk/mediatek/clk-mt7622-infracfg.c
index cfdf3b07c3e0..2e463d1481d0 100644
--- a/drivers/clk/mediatek/clk-mt7622-infracfg.c
+++ b/drivers/clk/mediatek/clk-mt7622-infracfg.c
@@ -9,7 +9,6 @@
#include <linux/module.h>
#include <linux/platform_device.h>
-#include "clk-cpumux.h"
#include "clk-gate.h"
#include "clk-mtk.h"
#include "reset.h"
@@ -51,74 +50,27 @@ static const struct mtk_clk_rst_desc clk_rst_desc = {
.rst_bank_nr = ARRAY_SIZE(infrasys_rst_ofs),
};
+static const struct mtk_clk_desc infra_desc = {
+ .clks = infra_clks,
+ .num_clks = ARRAY_SIZE(infra_clks),
+ .cpumuxes = cpu_muxes,
+ .num_cpumuxes = ARRAY_SIZE(cpu_muxes),
+ .rst_desc = &clk_rst_desc,
+};
+
static const struct of_device_id of_match_clk_mt7622_infracfg[] = {
- { .compatible = "mediatek,mt7622-infracfg" },
+ { .compatible = "mediatek,mt7622-infracfg", .data = &infra_desc },
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, of_match_clk_mt7622_infracfg);
-static int clk_mt7622_infracfg_probe(struct platform_device *pdev)
-{
- struct clk_hw_onecell_data *clk_data;
- struct device_node *node = pdev->dev.of_node;
- void __iomem *base;
- int ret;
-
- base = devm_platform_ioremap_resource(pdev, 0);
- if (IS_ERR(base))
- return PTR_ERR(base);
-
- clk_data = mtk_alloc_clk_data(CLK_INFRA_NR_CLK);
- if (!clk_data)
- return -ENOMEM;
-
- ret = mtk_register_reset_controller_with_dev(&pdev->dev, &clk_rst_desc);
- if (ret)
- goto free_clk_data;
-
- ret = mtk_clk_register_gates(&pdev->dev, node, infra_clks,
- ARRAY_SIZE(infra_clks), clk_data);
- if (ret)
- goto free_clk_data;
-
- ret = mtk_clk_register_cpumuxes(&pdev->dev, node, cpu_muxes,
- ARRAY_SIZE(cpu_muxes), clk_data);
- if (ret)
- goto unregister_gates;
-
- ret = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
- if (ret)
- goto unregister_cpumuxes;
-
- return 0;
-
-unregister_cpumuxes:
- mtk_clk_unregister_cpumuxes(cpu_muxes, ARRAY_SIZE(cpu_muxes), clk_data);
-unregister_gates:
- mtk_clk_unregister_gates(infra_clks, ARRAY_SIZE(infra_clks), clk_data);
-free_clk_data:
- mtk_free_clk_data(clk_data);
- return ret;
-}
-
-static void clk_mt7622_infracfg_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_cpumuxes(cpu_muxes, ARRAY_SIZE(cpu_muxes), clk_data);
- mtk_clk_unregister_gates(infra_clks, ARRAY_SIZE(infra_clks), clk_data);
- mtk_free_clk_data(clk_data);
-}
-
static struct platform_driver clk_mt7622_infracfg_drv = {
.driver = {
.name = "clk-mt7622-infracfg",
.of_match_table = of_match_clk_mt7622_infracfg,
},
- .probe = clk_mt7622_infracfg_probe,
- .remove = clk_mt7622_infracfg_remove,
+ .probe = mtk_clk_simple_probe,
+ .remove = mtk_clk_simple_remove,
};
module_platform_driver(clk_mt7622_infracfg_drv);
--
2.52.0
prev parent reply other threads:[~2026-03-04 18:11 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-04 18:10 [PATCH 0/3] Refactor infracfg drivers to be able to use common helpers Akari Tsuyukusa
2026-03-04 18:10 ` [PATCH 1/3] clk: mediatek: clk-mtk: Add cpumux support to common probe/remove helpers Akari Tsuyukusa
2026-03-09 5:25 ` Chen-Yu Tsai
2026-03-04 18:10 ` [PATCH 2/3] clk: mediatek: mt6795-infracfg: Switch " Akari Tsuyukusa
2026-03-04 18:10 ` Akari Tsuyukusa [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260304181024.738391-4-akkun11.open@gmail.com \
--to=akkun11.open@gmail.com \
--cc=angelogioacchino.delregno@collabora.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=mturquette@baylibre.com \
--cc=sboyd@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox