* [PATCH 1/3] clk: mediatek: clk-mtk: Add cpumux support to common probe/remove helpers
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 ` 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 ` [PATCH 3/3] clk: mediatek: mt7622-infracfg: " Akari Tsuyukusa
2 siblings, 1 reply; 5+ messages in thread
From: Akari Tsuyukusa @ 2026-03-04 18:10 UTC (permalink / raw)
To: mturquette, sboyd, matthias.bgg, angelogioacchino.delregno
Cc: linux-clk, linux-kernel, linux-arm-kernel, linux-mediatek,
Akari Tsuyukusa
Extend __mtk_clk_simple_probe() and __mtk_clk_simple_remove() to support
cpumux clocks. This reduces boilerplate code in drivers for SoCs that
require cpumux registration, such as mt6795-infracfg.
Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com>
---
drivers/clk/mediatek/clk-mtk.c | 18 +++++++++++++++++-
drivers/clk/mediatek/clk-mtk.h | 2 ++
2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/drivers/clk/mediatek/clk-mtk.c b/drivers/clk/mediatek/clk-mtk.c
index 3dfdd3a422f8..8148c21e6099 100644
--- a/drivers/clk/mediatek/clk-mtk.c
+++ b/drivers/clk/mediatek/clk-mtk.c
@@ -19,6 +19,7 @@
#include "clk-mtk.h"
#include "clk-gate.h"
#include "clk-mux.h"
+#include "clk-cpumux.h"
const struct mtk_gate_regs cg_regs_dummy = { 0, 0, 0 };
EXPORT_SYMBOL_GPL(cg_regs_dummy);
@@ -513,6 +514,7 @@ static int __mtk_clk_simple_probe(struct platform_device *pdev,
num_clks = mcd->num_clks + mcd->num_composite_clks;
num_clks += mcd->num_fixed_clks + mcd->num_factor_clks;
num_clks += mcd->num_mux_clks + mcd->num_divider_clks;
+ num_clks += mcd->num_cpumuxes;
clk_data = mtk_alloc_clk_data(num_clks);
if (!clk_data) {
@@ -542,6 +544,13 @@ static int __mtk_clk_simple_probe(struct platform_device *pdev,
goto unregister_factors;
}
+ if (mcd->cpumuxes) {
+ r = mtk_clk_register_cpumuxes(&pdev->dev, node, mcd->cpumuxes,
+ mcd->num_cpumuxes, clk_data);
+ if (r)
+ goto unregister_muxes;
+ }
+
if (mcd->composite_clks) {
/* We don't check composite_lock because it's optional */
r = mtk_clk_register_composites(&pdev->dev,
@@ -549,7 +558,7 @@ static int __mtk_clk_simple_probe(struct platform_device *pdev,
mcd->num_composite_clks,
base, mcd->clk_lock, clk_data);
if (r)
- goto unregister_muxes;
+ goto unregister_cpumuxes;
}
if (mcd->divider_clks) {
@@ -605,6 +614,10 @@ static int __mtk_clk_simple_probe(struct platform_device *pdev,
if (mcd->composite_clks)
mtk_clk_unregister_composites(mcd->composite_clks,
mcd->num_composite_clks, clk_data);
+unregister_cpumuxes:
+ if (mcd->cpumuxes)
+ mtk_clk_unregister_cpumuxes(mcd->cpumuxes,
+ mcd->num_cpumuxes, clk_data);
unregister_muxes:
if (mcd->mux_clks)
mtk_clk_unregister_muxes(mcd->mux_clks,
@@ -643,6 +656,9 @@ static void __mtk_clk_simple_remove(struct platform_device *pdev,
if (mcd->composite_clks)
mtk_clk_unregister_composites(mcd->composite_clks,
mcd->num_composite_clks, clk_data);
+ if (mcd->cpumuxes)
+ mtk_clk_unregister_cpumuxes(mcd->cpumuxes,
+ mcd->num_cpumuxes, clk_data);
if (mcd->mux_clks)
mtk_clk_unregister_muxes(mcd->mux_clks,
mcd->num_mux_clks, clk_data);
diff --git a/drivers/clk/mediatek/clk-mtk.h b/drivers/clk/mediatek/clk-mtk.h
index 5417b9264e6d..02fab4b166f2 100644
--- a/drivers/clk/mediatek/clk-mtk.h
+++ b/drivers/clk/mediatek/clk-mtk.h
@@ -252,6 +252,8 @@ struct mtk_clk_desc {
size_t num_factor_clks;
const struct mtk_mux *mux_clks;
size_t num_mux_clks;
+ const struct mtk_composite *cpumuxes;
+ size_t num_cpumuxes;
const struct mtk_clk_rst_desc *rst_desc;
spinlock_t *clk_lock;
bool shared_io;
--
2.52.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH 1/3] clk: mediatek: clk-mtk: Add cpumux support to common probe/remove helpers
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
0 siblings, 0 replies; 5+ messages in thread
From: Chen-Yu Tsai @ 2026-03-09 5:25 UTC (permalink / raw)
To: Akari Tsuyukusa
Cc: mturquette, sboyd, matthias.bgg, angelogioacchino.delregno,
linux-clk, linux-kernel, linux-arm-kernel, linux-mediatek
On Thu, Mar 5, 2026 at 2:11 AM Akari Tsuyukusa <akkun11.open@gmail.com> wrote:
>
> Extend __mtk_clk_simple_probe() and __mtk_clk_simple_remove() to support
> cpumux clocks. This reduces boilerplate code in drivers for SoCs that
> require cpumux registration, such as mt6795-infracfg.
>
> Signed-off-by: Akari Tsuyukusa <akkun11.open@gmail.com>
Reviewed-by: Chen-Yu Tsai <wenst@chromium.org>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2/3] clk: mediatek: mt6795-infracfg: Switch to common probe/remove helpers
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-04 18:10 ` Akari Tsuyukusa
2026-03-04 18:10 ` [PATCH 3/3] clk: mediatek: mt7622-infracfg: " Akari Tsuyukusa
2 siblings, 0 replies; 5+ messages in thread
From: Akari Tsuyukusa @ 2026-03-04 18:10 UTC (permalink / raw)
To: mturquette, sboyd, matthias.bgg, angelogioacchino.delregno
Cc: linux-clk, linux-kernel, linux-arm-kernel, linux-mediatek,
Akari Tsuyukusa
The MT6795 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-mt6795-infracfg.c | 70 ++++------------------
1 file changed, 11 insertions(+), 59 deletions(-)
diff --git a/drivers/clk/mediatek/clk-mt6795-infracfg.c b/drivers/clk/mediatek/clk-mt6795-infracfg.c
index e4559569f5b0..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,74 +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;
-
- 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);
--
2.52.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH 3/3] clk: mediatek: mt7622-infracfg: Switch to common probe/remove helpers
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-04 18:10 ` [PATCH 2/3] clk: mediatek: mt6795-infracfg: Switch " Akari Tsuyukusa
@ 2026-03-04 18:10 ` Akari Tsuyukusa
2 siblings, 0 replies; 5+ messages in thread
From: Akari Tsuyukusa @ 2026-03-04 18:10 UTC (permalink / raw)
To: mturquette, sboyd, matthias.bgg, angelogioacchino.delregno
Cc: linux-clk, linux-kernel, linux-arm-kernel, linux-mediatek,
Akari Tsuyukusa
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
^ permalink raw reply related [flat|nested] 5+ messages in thread