Pass each controller's struct mtk_clk_tree through the driver data and use
the generic probe function for all the MT8512 clock drivers, instead of a
dedicated probe per controller.

The apmixedsys and topckgen controllers keep their own U_BOOT_DRIVER since
they rely on dedicated ops and on the parent bind() callback, but they now
get their tree from the compatible data.

No functional change intended.

Signed-off-by: Julien Stephan <[email protected]>
---
 drivers/clk/mediatek/clk-mt8512.c | 24 ++++++++++--------------
 1 file changed, 10 insertions(+), 14 deletions(-)

diff --git a/drivers/clk/mediatek/clk-mt8512.c 
b/drivers/clk/mediatek/clk-mt8512.c
index 5e61f80d37e..7895448f4e5 100644
--- a/drivers/clk/mediatek/clk-mt8512.c
+++ b/drivers/clk/mediatek/clk-mt8512.c
@@ -829,16 +829,6 @@ static const struct mtk_clk_tree mt8512_infracfg_tree = {
        .num_gates = ARRAY_SIZE(infra_clks),
 };
 
-static int mt8512_apmixedsys_probe(struct udevice *dev)
-{
-       return mtk_common_clk_init(dev, &mt8512_apmixed_clk_tree);
-}
-
-static int mt8512_topckgen_probe(struct udevice *dev)
-{
-       return mtk_common_clk_init(dev, &mt8512_topckgen_clk_tree);
-}
-
 static int mt8512_clk_probe(struct udevice *dev)
 {
        const struct mtk_clk_tree *tree = (void *)dev_get_driver_data(dev);
@@ -847,12 +837,18 @@ static int mt8512_clk_probe(struct udevice *dev)
 }
 
 static const struct udevice_id mt8512_apmixed_compat[] = {
-       { .compatible = "mediatek,mt8512-apmixedsys", },
+       {
+               .compatible = "mediatek,mt8512-apmixedsys",
+               .data = (ulong)&mt8512_apmixed_clk_tree
+       },
        { }
 };
 
 static const struct udevice_id mt8512_topckgen_compat[] = {
-       { .compatible = "mediatek,mt8512-topckgen", },
+       {
+               .compatible = "mediatek,mt8512-topckgen",
+               .data = (ulong)&mt8512_topckgen_clk_tree
+       },
        { }
 };
 
@@ -873,7 +869,7 @@ U_BOOT_DRIVER(mt8512_clk_apmixedsys) = {
        .id = UCLASS_CLK,
        .of_match = mt8512_apmixed_compat,
        .bind = mtk_common_clk_parent_bind,
-       .probe = mt8512_apmixedsys_probe,
+       .probe = mt8512_clk_probe,
        .priv_auto      = sizeof(struct mtk_clk_priv),
        .ops = &mtk_clk_apmixedsys_ops,
        .flags = DM_FLAG_PRE_RELOC,
@@ -884,7 +880,7 @@ U_BOOT_DRIVER(mt8512_clk_topckgen) = {
        .id = UCLASS_CLK,
        .of_match = mt8512_topckgen_compat,
        .bind = mtk_common_clk_parent_bind,
-       .probe = mt8512_topckgen_probe,
+       .probe = mt8512_clk_probe,
        .priv_auto      = sizeof(struct mtk_clk_priv),
        .ops = &mtk_clk_topckgen_ops,
        .flags = DM_FLAG_PRE_RELOC,

-- 
2.54.0

Reply via email to