From: Akari Tsuyukusa <akkun11.open@gmail.com>
To: Michael Turquette <mturquette@baylibre.com>,
Stephen Boyd <sboyd@kernel.org>,
Brian Masney <bmasney@redhat.com>,
Matthias Brugger <matthias.bgg@gmail.com>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>,
Yassine Oudjana <y.oudjana@protonmail.com>,
Richard Cochran <richardcochran@gmail.com>
Cc: "Laura Nao" <laura.nao@collabora.com>,
"Nícolas F. R. A. Prado" <nfraprado@collabora.com>,
"Chen-Yu Tsai" <wenst@chromium.org>,
"Akari Tsuyukusa" <akkun11.open@gmail.com>,
"Bartosz Golaszewski" <bartosz.golaszewski@oss.qualcomm.com>,
"Danilo Krummrich" <dakr@kernel.org>,
"Bjorn Helgaas" <bhelgaas@google.com>,
"Uwe Kleine-König (The Capable Hub)"
<u.kleine-koenig@baylibre.com>,
"Nicolas Frattaroli" <nicolas.frattaroli@collabora.com>,
"Takashi Sakamoto" <o-takashi@sakamocchi.jp>,
"Haotian Zhang" <vulab@iscas.ac.cn>,
"Kees Cook" <kees@kernel.org>,
"Miles Chen" <miles.chen@mediatek.com>,
"Daniel Golle" <daniel@makrotopia.org>,
"Sam Shih" <sam.shih@mediatek.com>,
linux-clk@vger.kernel.org (open list:COMMON CLK FRAMEWORK),
linux-kernel@vger.kernel.org (open list),
linux-arm-kernel@lists.infradead.org (moderated
list:ARM/Mediatek SoC support),
linux-mediatek@lists.infradead.org (moderated list:ARM/Mediatek
SoC support),
netdev@vger.kernel.org (open list:PTP HARDWARE CLOCK
SUPPORT:Keyword:(?:b|_)ptp(?:b|_)),
stable@vger.kernel.org
Subject: [PATCH 17/32] clk: mediatek: mt6795: Switch to common probe/remove helpers
Date: Mon, 3 Aug 2026 23:16:44 +0900 [thread overview]
Message-ID: <20260803141659.559129-18-akkun11.open@gmail.com> (raw)
In-Reply-To: <20260803141659.559129-1-akkun11.open@gmail.com>
The MT6795 infracfg and pericfg drivers 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.
Note that the apmixedsys driver is excluded from this conversion because
it requires ref2usb_tx clock handling, which is not currently supported
by the common simple probe helper.
Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com>
---
drivers/clk/mediatek/clk-mt6795-infracfg.c | 72 ++++-----------------
drivers/clk/mediatek/clk-mt6795-pericfg.c | 73 ++++------------------
2 files changed, 23 insertions(+), 122 deletions(-)
diff --git a/drivers/clk/mediatek/clk-mt6795-infracfg.c b/drivers/clk/mediatek/clk-mt6795-infracfg.c
index 914bb069aa85..6aefc577ece5 100644
--- a/drivers/clk/mediatek/clk-mt6795-infracfg.c
+++ b/drivers/clk/mediatek/clk-mt6795-infracfg.c
@@ -8,7 +8,6 @@
#include <dt-bindings/reset/mediatek,mt6795-resets.h>
#include <linux/module.h>
#include <linux/platform_device.h>
-#include "clk-cpumux.h"
#include "clk-gate.h"
#include "clk-mtk.h"
#include "reset.h"
@@ -77,76 +76,27 @@ static const struct mtk_clk_rst_desc clk_rst_desc = {
.rst_idx_map_nr = ARRAY_SIZE(infra_ao_idx_map),
};
+static const struct mtk_clk_desc infra_desc = {
+ .clks = infra_gates,
+ .num_clks = ARRAY_SIZE(infra_gates),
+ .cpumuxes = cpu_muxes,
+ .num_cpumuxes = ARRAY_SIZE(cpu_muxes),
+ .rst_desc = &clk_rst_desc,
+};
+
static const struct of_device_id of_match_clk_mt6795_infracfg[] = {
- { .compatible = "mediatek,mt6795-infracfg" },
+ { .compatible = "mediatek,mt6795-infracfg", .data = &infra_desc },
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, of_match_clk_mt6795_infracfg);
-static int clk_mt6795_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_gates,
- ARRAY_SIZE(infra_gates), 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;
-
- platform_set_drvdata(pdev, clk_data);
-
- return 0;
-
-unregister_cpumuxes:
- mtk_clk_unregister_cpumuxes(cpu_muxes, ARRAY_SIZE(cpu_muxes), clk_data);
-unregister_gates:
- mtk_clk_unregister_gates(infra_gates, ARRAY_SIZE(infra_gates), clk_data);
-free_clk_data:
- mtk_free_clk_data(clk_data);
- return ret;
-}
-
-static void clk_mt6795_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_gates, ARRAY_SIZE(infra_gates), clk_data);
- mtk_free_clk_data(clk_data);
-}
-
static struct platform_driver clk_mt6795_infracfg_drv = {
.driver = {
.name = "clk-mt6795-infracfg",
.of_match_table = of_match_clk_mt6795_infracfg,
},
- .probe = clk_mt6795_infracfg_probe,
- .remove = clk_mt6795_infracfg_remove,
+ .probe = mtk_clk_simple_probe,
+ .remove = mtk_clk_simple_remove,
};
module_platform_driver(clk_mt6795_infracfg_drv);
diff --git a/drivers/clk/mediatek/clk-mt6795-pericfg.c b/drivers/clk/mediatek/clk-mt6795-pericfg.c
index 27d0ef7d7b2f..53c79e830b6a 100644
--- a/drivers/clk/mediatek/clk-mt6795-pericfg.c
+++ b/drivers/clk/mediatek/clk-mt6795-pericfg.c
@@ -85,77 +85,28 @@ static const struct mtk_clk_rst_desc clk_rst_desc = {
.rst_idx_map_nr = ARRAY_SIZE(peri_idx_map),
};
+static const struct mtk_clk_desc pericfg_desc = {
+ .clks = peri_gates,
+ .num_clks = ARRAY_SIZE(peri_gates),
+ .composite_clks = peri_clks,
+ .num_composite_clks = ARRAY_SIZE(peri_clks),
+ .rst_desc = &clk_rst_desc,
+ .clk_lock = &mt6795_peri_clk_lock,
+};
+
static const struct of_device_id of_match_clk_mt6795_pericfg[] = {
- { .compatible = "mediatek,mt6795-pericfg" },
+ { .compatible = "mediatek,mt6795-pericfg", .data = &pericfg_desc },
{ /* sentinel */ }
};
MODULE_DEVICE_TABLE(of, of_match_clk_mt6795_pericfg);
-static int clk_mt6795_pericfg_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_PERI_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, peri_gates,
- ARRAY_SIZE(peri_gates), clk_data);
- if (ret)
- goto free_clk_data;
-
- ret = mtk_clk_register_composites(&pdev->dev, peri_clks,
- ARRAY_SIZE(peri_clks), base,
- &mt6795_peri_clk_lock, 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_composites;
-
- platform_set_drvdata(pdev, clk_data);
-
- return 0;
-
-unregister_composites:
- mtk_clk_unregister_composites(peri_clks, ARRAY_SIZE(peri_clks), clk_data);
-unregister_gates:
- mtk_clk_unregister_gates(peri_gates, ARRAY_SIZE(peri_gates), clk_data);
-free_clk_data:
- mtk_free_clk_data(clk_data);
- return ret;
-}
-
-static void clk_mt6795_pericfg_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_composites(peri_clks, ARRAY_SIZE(peri_clks), clk_data);
- mtk_clk_unregister_gates(peri_gates, ARRAY_SIZE(peri_gates), clk_data);
- mtk_free_clk_data(clk_data);
-}
-
static struct platform_driver clk_mt6795_pericfg_drv = {
.driver = {
.name = "clk-mt6795-pericfg",
.of_match_table = of_match_clk_mt6795_pericfg,
},
- .probe = clk_mt6795_pericfg_probe,
- .remove = clk_mt6795_pericfg_remove,
+ .probe = mtk_clk_simple_probe,
+ .remove = mtk_clk_simple_remove,
};
module_platform_driver(clk_mt6795_pericfg_drv);
--
2.55.0
next prev parent reply other threads:[~2026-08-03 14:18 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-03 14:16 [PATCH 00/32] clk: mediatek: Migrate to common probe/remove helpers and fix memory leaks Akari Tsuyukusa
2026-08-03 14:16 ` [PATCH 01/32] clk: mediatek: mt2712: fix memory leak on module removal Akari Tsuyukusa
2026-08-03 14:16 ` [PATCH 02/32] clk: mediatek: mt6795: " Akari Tsuyukusa
2026-08-03 14:16 ` [PATCH 03/32] clk: mediatek: mt7622: " Akari Tsuyukusa
2026-08-03 14:16 ` [PATCH 04/32] clk: mediatek: mt8135: " Akari Tsuyukusa
2026-08-03 14:16 ` [PATCH 05/32] clk: mediatek: mt8173: " Akari Tsuyukusa
2026-08-03 14:16 ` [PATCH 06/32] clk: mediatek: mt8192: " Akari Tsuyukusa
2026-08-03 14:16 ` [PATCH 07/32] clk: mediatek: mt6735: Add missing MODULE_DEVICE_TABLE() Akari Tsuyukusa
2026-08-03 14:16 ` [PATCH 08/32] clk: mediatek: mt7988-apmixed: " Akari Tsuyukusa
2026-08-03 14:16 ` [PATCH 09/32] clk: mediatek: Add cpumux support to common probe/remove helpers Akari Tsuyukusa
2026-08-03 14:16 ` [PATCH 10/32] clk: mediatek: Add PLL " Akari Tsuyukusa
2026-08-03 14:16 ` [PATCH 11/32] clk: mediatek: Add auto-population of sub-devices support in simple probe Akari Tsuyukusa
2026-08-04 2:43 ` Chen-Yu Tsai
2026-08-03 14:16 ` [PATCH 12/32] clk: mediatek: Add pllfh support to common probe/remove helpers Akari Tsuyukusa
2026-08-03 14:16 ` [PATCH 13/32] clk: mediatek: mt2701: Switch " Akari Tsuyukusa
2026-08-04 2:45 ` Chen-Yu Tsai
2026-08-03 14:16 ` [PATCH 14/32] clk: mediatek: mt2712-apmixedsys: " Akari Tsuyukusa
2026-08-03 14:16 ` [PATCH 15/32] clk: mediatek: mt6735-apmixedsys: " Akari Tsuyukusa
2026-08-03 14:16 ` [PATCH 16/32] clk: mediatek: mt6779: " Akari Tsuyukusa
2026-08-03 14:16 ` Akari Tsuyukusa [this message]
2026-08-03 14:16 ` [PATCH 18/32] clk: mediatek: mt6797: " Akari Tsuyukusa
2026-08-03 14:16 ` [PATCH 19/32] clk: mediatek: mt7622: " Akari Tsuyukusa
2026-08-03 14:16 ` [PATCH 20/32] clk: mediatek: mt7981-apmixed: " Akari Tsuyukusa
2026-08-03 14:16 ` [PATCH 21/32] clk: mediatek: mt7986-apmixed: " Akari Tsuyukusa
2026-08-03 14:16 ` [PATCH 22/32] clk: mediatek: mt7988-apmixed: " Akari Tsuyukusa
2026-08-03 14:16 ` [PATCH 23/32] clk: mediatek: mt8135-apmixedsys: " Akari Tsuyukusa
2026-08-03 14:16 ` [PATCH 24/32] clk: mediatek: mt8167-apmixedsys: " Akari Tsuyukusa
2026-08-03 14:16 ` [PATCH 25/32] clk: mediatek: mt8173-infracfg: " Akari Tsuyukusa
2026-08-03 14:16 ` [PATCH 26/32] clk: mediatek: mt8183: " Akari Tsuyukusa
2026-08-03 14:16 ` [PATCH 27/32] clk: mediatek: mt8186-apmixedsys: " Akari Tsuyukusa
2026-08-03 14:16 ` [PATCH 28/32] clk: mediatek: mt8188-apmixedsys: " Akari Tsuyukusa
2026-08-03 14:16 ` [PATCH 29/32] clk: mediatek: mt8192: " Akari Tsuyukusa
2026-08-03 14:16 ` [PATCH 30/32] clk: mediatek: mt8195: " Akari Tsuyukusa
2026-08-03 14:16 ` [PATCH 31/32] clk: mediatek: mt8196: " Akari Tsuyukusa
2026-08-03 14:16 ` [PATCH 32/32] clk: mediatek: mt8516-apmixedsys: " Akari Tsuyukusa
2026-08-03 19:50 ` [PATCH 00/32] clk: mediatek: Migrate to common probe/remove helpers and fix memory leaks Jakub Kicinski
2026-08-03 20:28 ` Brian Masney
2026-08-04 1:40 ` Jakub Kicinski
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=20260803141659.559129-18-akkun11.open@gmail.com \
--to=akkun11.open@gmail.com \
--cc=angelogioacchino.delregno@collabora.com \
--cc=bartosz.golaszewski@oss.qualcomm.com \
--cc=bhelgaas@google.com \
--cc=bmasney@redhat.com \
--cc=dakr@kernel.org \
--cc=daniel@makrotopia.org \
--cc=kees@kernel.org \
--cc=laura.nao@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=miles.chen@mediatek.com \
--cc=mturquette@baylibre.com \
--cc=netdev@vger.kernel.org \
--cc=nfraprado@collabora.com \
--cc=nicolas.frattaroli@collabora.com \
--cc=o-takashi@sakamocchi.jp \
--cc=richardcochran@gmail.com \
--cc=sam.shih@mediatek.com \
--cc=sboyd@kernel.org \
--cc=stable@vger.kernel.org \
--cc=u.kleine-koenig@baylibre.com \
--cc=vulab@iscas.ac.cn \
--cc=wenst@chromium.org \
--cc=y.oudjana@protonmail.com \
/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