Describe the topckgen clock gates directly in a struct mtk_clk_tree,
reference the tree from the driver data and use the generic
mtk_clk_topckgen_ops instead of the dedicated clock gate ops.

This stops using mtk_common_clk_gate_init() and struct mtk_cg_priv, which
are scheduled for removal.

No functional change intended.

Signed-off-by: Julien Stephan <[email protected]>
---
 drivers/clk/mediatek/clk-mt8518.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/drivers/clk/mediatek/clk-mt8518.c 
b/drivers/clk/mediatek/clk-mt8518.c
index 1033ecae187..1c8a8c70956 100644
--- a/drivers/clk/mediatek/clk-mt8518.c
+++ b/drivers/clk/mediatek/clk-mt8518.c
@@ -1526,6 +1526,8 @@ static const struct mtk_clk_tree mt8518_topckgen_clk_tree 
= {
 static const struct mtk_clk_tree mt8518_clk_tree = {
        .ext_clk_rates = ext_clock_rates,
        .num_ext_clks = ARRAY_SIZE(ext_clock_rates),
+       .gates = top_clks,
+       .num_gates = ARRAY_SIZE(top_clks),
 };
 
 static int mt8518_apmixedsys_probe(struct udevice *dev)
@@ -1538,10 +1540,11 @@ static int mt8518_topckgen_probe(struct udevice *dev)
        return mtk_common_clk_init(dev, &mt8518_topckgen_clk_tree);
 }
 
-static int mt8518_topckgen_cg_probe(struct udevice *dev)
+static int mt8518_clk_probe(struct udevice *dev)
 {
-       return mtk_common_clk_gate_init(dev, &mt8518_clk_tree, top_clks,
-                                       ARRAY_SIZE(top_clks), 0);
+       const struct mtk_clk_tree *tree = (void *)dev_get_driver_data(dev);
+
+       return mtk_common_clk_init(dev, tree);
 }
 
 static const struct udevice_id mt8518_apmixed_compat[] = {
@@ -1555,7 +1558,10 @@ static const struct udevice_id mt8518_topckgen_compat[] 
= {
 };
 
 static const struct udevice_id mt8518_topckgen_cg_compat[] = {
-       { .compatible = "mediatek,mt8518-topckgen-cg", },
+       {
+               .compatible = "mediatek,mt8518-topckgen-cg",
+               .data = (ulong)&mt8518_clk_tree
+       },
        { }
 };
 
@@ -1585,8 +1591,8 @@ U_BOOT_DRIVER(mt8518_clk_topckgen_cg) = {
        .name = "mt8518-topckgen-cg",
        .id = UCLASS_CLK,
        .of_match = mt8518_topckgen_cg_compat,
-       .probe = mt8518_topckgen_cg_probe,
-       .priv_auto      = sizeof(struct mtk_cg_priv),
-       .ops = &mtk_clk_gate_ops,
+       .probe = mt8518_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