clk: mediatek: Refactor pllfh registration to pass device
authorNicolas Frattaroli <nicolas.frattaroli@collabora.com>
Mon, 15 Dec 2025 10:24:01 +0000 (11:24 +0100)
committerStephen Boyd <sboyd@kernel.org>
Fri, 23 Jan 2026 01:44:34 +0000 (17:44 -0800)
After refactoring all of PLL to pass the device, it's now fairly easy to
refactor pllfh and its users, as pllfh registration wraps PLL
registration.

Do this refactor and move all of the pllfh users to pass the device as
well.

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
drivers/clk/mediatek/clk-mt6795-apmixedsys.c
drivers/clk/mediatek/clk-mt8173-apmixedsys.c
drivers/clk/mediatek/clk-mt8186-apmixedsys.c
drivers/clk/mediatek/clk-mt8192-apmixedsys.c
drivers/clk/mediatek/clk-mt8195-apmixedsys.c
drivers/clk/mediatek/clk-pllfh.c
drivers/clk/mediatek/clk-pllfh.h

index 91665d7..123d5d7 100644 (file)
@@ -152,7 +152,7 @@ static int clk_mt6795_apmixed_probe(struct platform_device *pdev)
                return -ENOMEM;
 
        fhctl_parse_dt(fhctl_node, pllfhs, ARRAY_SIZE(pllfhs));
-       ret = mtk_clk_register_pllfhs(node, plls, ARRAY_SIZE(plls),
+       ret = mtk_clk_register_pllfhs(dev, plls, ARRAY_SIZE(plls),
                                      pllfhs, ARRAY_SIZE(pllfhs), clk_data);
        if (ret)
                goto free_clk_data;
index 95385bb..d7d4161 100644 (file)
@@ -140,13 +140,13 @@ MODULE_DEVICE_TABLE(of, of_match_clk_mt8173_apmixed);
 static int clk_mt8173_apmixed_probe(struct platform_device *pdev)
 {
        const u8 *fhctl_node = "mediatek,mt8173-fhctl";
-       struct device_node *node = pdev->dev.of_node;
        struct clk_hw_onecell_data *clk_data;
+       struct device *dev = &pdev->dev;
        void __iomem *base;
        struct clk_hw *hw;
        int r;
 
-       base = of_iomap(node, 0);
+       base = of_iomap(dev->of_node, 0);
        if (!base)
                return -ENOMEM;
 
@@ -157,25 +157,25 @@ static int clk_mt8173_apmixed_probe(struct platform_device *pdev)
        }
 
        fhctl_parse_dt(fhctl_node, pllfhs, ARRAY_SIZE(pllfhs));
-       r = mtk_clk_register_pllfhs(node, plls, ARRAY_SIZE(plls),
-                                   pllfhs, ARRAY_SIZE(pllfhs), clk_data);
+       r = mtk_clk_register_pllfhs(dev, plls, ARRAY_SIZE(plls), pllfhs,
+                                   ARRAY_SIZE(pllfhs), clk_data);
        if (r)
                goto free_clk_data;
 
        hw = mtk_clk_register_ref2usb_tx("ref2usb_tx", "clk26m", base + REGOFF_REF2USB);
        if (IS_ERR(hw)) {
                r = PTR_ERR(hw);
-               dev_err(&pdev->dev, "Failed to register ref2usb_tx: %d\n", r);
+               dev_err(dev, "Failed to register ref2usb_tx: %d\n", r);
                goto unregister_plls;
        }
        clk_data->hws[CLK_APMIXED_REF2USB_TX] = hw;
 
-       hw = devm_clk_hw_register_divider(&pdev->dev, "hdmi_ref", "tvdpll_594m", 0,
+       hw = devm_clk_hw_register_divider(dev, "hdmi_ref", "tvdpll_594m", 0,
                                          base + REGOFF_HDMI_REF, 16, 3,
                                          CLK_DIVIDER_POWER_OF_TWO, NULL);
        clk_data->hws[CLK_APMIXED_HDMI_REF] = hw;
 
-       r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
+       r = of_clk_add_hw_provider(dev->of_node, of_clk_hw_onecell_get, clk_data);
        if (r)
                goto unregister_ref2usb;
 
index 4b2b165..d35dd26 100644 (file)
@@ -151,7 +151,7 @@ static int clk_mt8186_apmixed_probe(struct platform_device *pdev)
 
        fhctl_parse_dt(fhctl_node, pllfhs, ARRAY_SIZE(pllfhs));
 
-       r = mtk_clk_register_pllfhs(node, plls, ARRAY_SIZE(plls),
+       r = mtk_clk_register_pllfhs(&pdev->dev, plls, ARRAY_SIZE(plls),
                                    pllfhs, ARRAY_SIZE(pllfhs), clk_data);
        if (r)
                goto free_apmixed_data;
index 0b66a27..b0563a2 100644 (file)
@@ -162,7 +162,7 @@ static int clk_mt8192_apmixed_probe(struct platform_device *pdev)
 
        fhctl_parse_dt(fhctl_node, pllfhs, ARRAY_SIZE(pllfhs));
 
-       r = mtk_clk_register_pllfhs(node, plls, ARRAY_SIZE(plls),
+       r = mtk_clk_register_pllfhs(&pdev->dev, plls, ARRAY_SIZE(plls),
                                    pllfhs, ARRAY_SIZE(pllfhs), clk_data);
        if (r)
                goto free_clk_data;
index 282a313..44917ab 100644 (file)
@@ -181,7 +181,7 @@ static int clk_mt8195_apmixed_probe(struct platform_device *pdev)
 
        fhctl_parse_dt(fhctl_node, pllfhs, ARRAY_SIZE(pllfhs));
 
-       r = mtk_clk_register_pllfhs(node, plls, ARRAY_SIZE(plls),
+       r = mtk_clk_register_pllfhs(&pdev->dev, plls, ARRAY_SIZE(plls),
                                    pllfhs, ARRAY_SIZE(pllfhs), clk_data);
        if (r)
                goto free_apmixed_data;
index 62bfe4a..8ad1102 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/slab.h>
 #include <linux/clkdev.h>
 #include <linux/delay.h>
+#include <linux/device.h>
 
 #include "clk-mtk.h"
 #include "clk-pllfh.h"
@@ -149,7 +150,7 @@ static bool fhctl_is_supported_and_enabled(const struct mtk_pllfh_data *pllfh)
 }
 
 static struct clk_hw *
-mtk_clk_register_pllfh(const struct mtk_pll_data *pll_data,
+mtk_clk_register_pllfh(struct device *dev, const struct mtk_pll_data *pll_data,
                       struct mtk_pllfh_data *pllfh_data, void __iomem *base)
 {
        struct clk_hw *hw;
@@ -166,6 +167,8 @@ mtk_clk_register_pllfh(const struct mtk_pll_data *pll_data,
                goto out;
        }
 
+       fh->clk_pll.dev = dev;
+
        hw = mtk_clk_register_pll_ops(&fh->clk_pll, pll_data, base,
                                      &mtk_pllfh_ops);
 
@@ -194,7 +197,7 @@ static void mtk_clk_unregister_pllfh(struct clk_hw *hw)
        kfree(fh);
 }
 
-int mtk_clk_register_pllfhs(struct device_node *node,
+int mtk_clk_register_pllfhs(struct device *dev,
                            const struct mtk_pll_data *plls, int num_plls,
                            struct mtk_pllfh_data *pllfhs, int num_fhs,
                            struct clk_hw_onecell_data *clk_data)
@@ -203,7 +206,7 @@ int mtk_clk_register_pllfhs(struct device_node *node,
        int i;
        struct clk_hw *hw;
 
-       base = of_iomap(node, 0);
+       base = of_iomap(dev->of_node, 0);
        if (!base) {
                pr_err("%s(): ioremap failed\n", __func__);
                return -EINVAL;
@@ -218,9 +221,9 @@ int mtk_clk_register_pllfhs(struct device_node *node,
                use_fhctl = fhctl_is_supported_and_enabled(pllfh);
 
                if (use_fhctl)
-                       hw = mtk_clk_register_pllfh(pll, pllfh, base);
+                       hw = mtk_clk_register_pllfh(dev, pll, pllfh, base);
                else
-                       hw = mtk_clk_register_pll(NULL, pll, base);
+                       hw = mtk_clk_register_pll(dev, pll, base);
 
                if (IS_ERR(hw)) {
                        pr_err("Failed to register %s clk %s: %ld\n",
index 5f419c2..a4f337a 100644 (file)
@@ -68,7 +68,7 @@ struct fh_operation {
        int (*ssc_enable)(struct mtk_fh *fh, u32 rate);
 };
 
-int mtk_clk_register_pllfhs(struct device_node *node,
+int mtk_clk_register_pllfhs(struct device *dev,
                            const struct mtk_pll_data *plls, int num_plls,
                            struct mtk_pllfh_data *pllfhs, int num_pllfhs,
                            struct clk_hw_onecell_data *clk_data);