1 From c26e28015b74af73e0b299f6ad3ff22931e600b4 Mon Sep 17 00:00:00 2001
2 From: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
3 Date: Fri, 20 Jan 2023 10:20:41 +0100
4 Subject: [PATCH 05/15] clk: mediatek: Switch to mtk_clk_simple_probe() where
7 mtk_clk_simple_probe() is a function that registers mtk gate clocks
8 and, if reset data is present, a reset controller and across all of
9 the MTK clock drivers, such a function is duplicated many times:
10 switch to the common mtk_clk_simple_probe() function for all of the
11 clock drivers that are registering as platform drivers.
13 Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
14 Reviewed-by: Miles Chen <miles.chen@mediatek.com>
15 Tested-by: Miles Chen <miles.chen@mediatek.com>
16 Link: https://lore.kernel.org/r/20230120092053.182923-12-angelogioacchino.delregno@collabora.com
17 Tested-by: Mingming Su <mingming.su@mediatek.com>
18 Signed-off-by: Stephen Boyd <sboyd@kernel.org>
20 [daniel@makrotopia.org: removed parts not relevant for OpenWrt]
22 drivers/clk/mediatek/clk-mt2701-aud.c | 31 ++++++----
23 drivers/clk/mediatek/clk-mt2701-eth.c | 36 ++++--------
24 drivers/clk/mediatek/clk-mt2701-g3d.c | 56 ++++--------------
25 drivers/clk/mediatek/clk-mt2701-hif.c | 38 ++++--------
26 drivers/clk/mediatek/clk-mt2712.c | 83 ++++++++++----------------
27 drivers/clk/mediatek/clk-mt7622-aud.c | 54 ++++++-----------
28 drivers/clk/mediatek/clk-mt7622-eth.c | 82 +++++---------------------
29 drivers/clk/mediatek/clk-mt7622-hif.c | 85 +++++----------------------
30 drivers/clk/mediatek/clk-mt7629-hif.c | 85 +++++----------------------
31 9 files changed, 144 insertions(+), 406 deletions(-)
33 --- a/drivers/clk/mediatek/clk-mt2701-aud.c
34 +++ b/drivers/clk/mediatek/clk-mt2701-aud.c
35 @@ -52,6 +52,7 @@ static const struct mtk_gate_regs audio3
38 static const struct mtk_gate audio_clks[] = {
39 + GATE_DUMMY(CLK_DUMMY, "aud_dummy"),
41 GATE_AUDIO0(CLK_AUD_AFE, "audio_afe", "aud_intbus_sel", 2),
42 GATE_AUDIO0(CLK_AUD_HDMI, "audio_hdmi", "audpll_sel", 20),
43 @@ -114,29 +115,27 @@ static const struct mtk_gate audio_clks[
44 GATE_AUDIO3(CLK_AUD_MEM_ASRC5, "audio_mem_asrc5", "asm_h_sel", 14),
47 +static const struct mtk_clk_desc audio_desc = {
49 + .num_clks = ARRAY_SIZE(audio_clks),
52 static const struct of_device_id of_match_clk_mt2701_aud[] = {
53 - { .compatible = "mediatek,mt2701-audsys", },
55 + { .compatible = "mediatek,mt2701-audsys", .data = &audio_desc },
59 static int clk_mt2701_aud_probe(struct platform_device *pdev)
61 - struct clk_hw_onecell_data *clk_data;
62 - struct device_node *node = pdev->dev.of_node;
65 - clk_data = mtk_alloc_clk_data(CLK_AUD_NR);
67 - mtk_clk_register_gates(&pdev->dev, node, audio_clks,
68 - ARRAY_SIZE(audio_clks), clk_data);
70 - r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
71 + r = mtk_clk_simple_probe(pdev);
74 "could not register clock provider: %s: %d\n",
77 - goto err_clk_provider;
81 r = devm_of_platform_populate(&pdev->dev);
82 @@ -146,13 +145,19 @@ static int clk_mt2701_aud_probe(struct p
86 - of_clk_del_provider(node);
88 + mtk_clk_simple_remove(pdev);
92 +static int clk_mt2701_aud_remove(struct platform_device *pdev)
94 + of_platform_depopulate(&pdev->dev);
95 + return mtk_clk_simple_remove(pdev);
98 static struct platform_driver clk_mt2701_aud_drv = {
99 .probe = clk_mt2701_aud_probe,
100 + .remove = clk_mt2701_aud_remove,
102 .name = "clk-mt2701-aud",
103 .of_match_table = of_match_clk_mt2701_aud,
104 --- a/drivers/clk/mediatek/clk-mt2701-eth.c
105 +++ b/drivers/clk/mediatek/clk-mt2701-eth.c
106 @@ -20,6 +20,7 @@ static const struct mtk_gate_regs eth_cg
107 GATE_MTK(_id, _name, _parent, ð_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr_inv)
109 static const struct mtk_gate eth_clks[] = {
110 + GATE_DUMMY(CLK_DUMMY, "eth_dummy"),
111 GATE_ETH(CLK_ETHSYS_HSDMA, "hsdma_clk", "ethif_sel", 5),
112 GATE_ETH(CLK_ETHSYS_ESW, "esw_clk", "ethpll_500m_ck", 6),
113 GATE_ETH(CLK_ETHSYS_GP2, "gp2_clk", "trgpll", 7),
114 @@ -38,35 +39,20 @@ static const struct mtk_clk_rst_desc clk
115 .rst_bank_nr = ARRAY_SIZE(rst_ofs),
118 -static const struct of_device_id of_match_clk_mt2701_eth[] = {
119 - { .compatible = "mediatek,mt2701-ethsys", },
121 +static const struct mtk_clk_desc eth_desc = {
123 + .num_clks = ARRAY_SIZE(eth_clks),
124 + .rst_desc = &clk_rst_desc,
127 -static int clk_mt2701_eth_probe(struct platform_device *pdev)
129 - struct clk_hw_onecell_data *clk_data;
131 - struct device_node *node = pdev->dev.of_node;
133 - clk_data = mtk_alloc_clk_data(CLK_ETHSYS_NR);
135 - mtk_clk_register_gates(&pdev->dev, node, eth_clks,
136 - ARRAY_SIZE(eth_clks), clk_data);
138 - r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
140 - dev_err(&pdev->dev,
141 - "could not register clock provider: %s: %d\n",
144 - mtk_register_reset_controller_with_dev(&pdev->dev, &clk_rst_desc);
148 +static const struct of_device_id of_match_clk_mt2701_eth[] = {
149 + { .compatible = "mediatek,mt2701-ethsys", .data = ð_desc },
153 static struct platform_driver clk_mt2701_eth_drv = {
154 - .probe = clk_mt2701_eth_probe,
155 + .probe = mtk_clk_simple_probe,
156 + .remove = mtk_clk_simple_remove,
158 .name = "clk-mt2701-eth",
159 .of_match_table = of_match_clk_mt2701_eth,
160 --- a/drivers/clk/mediatek/clk-mt2701-g3d.c
161 +++ b/drivers/clk/mediatek/clk-mt2701-g3d.c
162 @@ -26,6 +26,7 @@ static const struct mtk_gate_regs g3d_cg
165 static const struct mtk_gate g3d_clks[] = {
166 + GATE_DUMMY(CLK_DUMMY, "g3d_dummy"),
167 GATE_G3D(CLK_G3DSYS_CORE, "g3d_core", "mfg_sel", 0),
170 @@ -37,57 +38,20 @@ static const struct mtk_clk_rst_desc clk
171 .rst_bank_nr = ARRAY_SIZE(rst_ofs),
174 -static int clk_mt2701_g3dsys_init(struct platform_device *pdev)
176 - struct clk_hw_onecell_data *clk_data;
177 - struct device_node *node = pdev->dev.of_node;
180 - clk_data = mtk_alloc_clk_data(CLK_G3DSYS_NR);
182 - mtk_clk_register_gates(&pdev->dev, node, g3d_clks, ARRAY_SIZE(g3d_clks),
185 - r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
187 - dev_err(&pdev->dev,
188 - "could not register clock provider: %s: %d\n",
191 - mtk_register_reset_controller_with_dev(&pdev->dev, &clk_rst_desc);
195 +static const struct mtk_clk_desc g3d_desc = {
197 + .num_clks = ARRAY_SIZE(g3d_clks),
198 + .rst_desc = &clk_rst_desc,
201 static const struct of_device_id of_match_clk_mt2701_g3d[] = {
203 - .compatible = "mediatek,mt2701-g3dsys",
204 - .data = clk_mt2701_g3dsys_init,
208 + { .compatible = "mediatek,mt2701-g3dsys", .data = &g3d_desc },
212 -static int clk_mt2701_g3d_probe(struct platform_device *pdev)
214 - int (*clk_init)(struct platform_device *);
217 - clk_init = of_device_get_match_data(&pdev->dev);
221 - r = clk_init(pdev);
223 - dev_err(&pdev->dev,
224 - "could not register clock provider: %s: %d\n",
230 static struct platform_driver clk_mt2701_g3d_drv = {
231 - .probe = clk_mt2701_g3d_probe,
232 + .probe = mtk_clk_simple_probe,
233 + .remove = mtk_clk_simple_remove,
235 .name = "clk-mt2701-g3d",
236 .of_match_table = of_match_clk_mt2701_g3d,
237 --- a/drivers/clk/mediatek/clk-mt2701-hif.c
238 +++ b/drivers/clk/mediatek/clk-mt2701-hif.c
239 @@ -20,6 +20,7 @@ static const struct mtk_gate_regs hif_cg
240 GATE_MTK(_id, _name, _parent, &hif_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr_inv)
242 static const struct mtk_gate hif_clks[] = {
243 + GATE_DUMMY(CLK_DUMMY, "hif_dummy"),
244 GATE_HIF(CLK_HIFSYS_USB0PHY, "usb0_phy_clk", "ethpll_500m_ck", 21),
245 GATE_HIF(CLK_HIFSYS_USB1PHY, "usb1_phy_clk", "ethpll_500m_ck", 22),
246 GATE_HIF(CLK_HIFSYS_PCIE0, "pcie0_clk", "ethpll_500m_ck", 24),
247 @@ -35,37 +36,20 @@ static const struct mtk_clk_rst_desc clk
248 .rst_bank_nr = ARRAY_SIZE(rst_ofs),
251 -static const struct of_device_id of_match_clk_mt2701_hif[] = {
252 - { .compatible = "mediatek,mt2701-hifsys", },
254 +static const struct mtk_clk_desc hif_desc = {
256 + .num_clks = ARRAY_SIZE(hif_clks),
257 + .rst_desc = &clk_rst_desc,
260 -static int clk_mt2701_hif_probe(struct platform_device *pdev)
262 - struct clk_hw_onecell_data *clk_data;
264 - struct device_node *node = pdev->dev.of_node;
266 - clk_data = mtk_alloc_clk_data(CLK_HIFSYS_NR);
268 - mtk_clk_register_gates(&pdev->dev, node, hif_clks,
269 - ARRAY_SIZE(hif_clks), clk_data);
271 - r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
273 - dev_err(&pdev->dev,
274 - "could not register clock provider: %s: %d\n",
279 - mtk_register_reset_controller_with_dev(&pdev->dev, &clk_rst_desc);
283 +static const struct of_device_id of_match_clk_mt2701_hif[] = {
284 + { .compatible = "mediatek,mt2701-hifsys", .data = &hif_desc },
288 static struct platform_driver clk_mt2701_hif_drv = {
289 - .probe = clk_mt2701_hif_probe,
290 + .probe = mtk_clk_simple_probe,
291 + .remove = mtk_clk_simple_remove,
293 .name = "clk-mt2701-hif",
294 .of_match_table = of_match_clk_mt2701_hif,
295 --- a/drivers/clk/mediatek/clk-mt2712.c
296 +++ b/drivers/clk/mediatek/clk-mt2712.c
297 @@ -1337,50 +1337,6 @@ static int clk_mt2712_top_probe(struct p
301 -static int clk_mt2712_infra_probe(struct platform_device *pdev)
303 - struct clk_hw_onecell_data *clk_data;
305 - struct device_node *node = pdev->dev.of_node;
307 - clk_data = mtk_alloc_clk_data(CLK_INFRA_NR_CLK);
309 - mtk_clk_register_gates(&pdev->dev, node, infra_clks,
310 - ARRAY_SIZE(infra_clks), clk_data);
312 - r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
315 - pr_err("%s(): could not register clock provider: %d\n",
318 - mtk_register_reset_controller_with_dev(&pdev->dev, &clk_rst_desc[0]);
323 -static int clk_mt2712_peri_probe(struct platform_device *pdev)
325 - struct clk_hw_onecell_data *clk_data;
327 - struct device_node *node = pdev->dev.of_node;
329 - clk_data = mtk_alloc_clk_data(CLK_PERI_NR_CLK);
331 - mtk_clk_register_gates(&pdev->dev, node, peri_clks,
332 - ARRAY_SIZE(peri_clks), clk_data);
334 - r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
337 - pr_err("%s(): could not register clock provider: %d\n",
340 - mtk_register_reset_controller_with_dev(&pdev->dev, &clk_rst_desc[1]);
345 static int clk_mt2712_mcu_probe(struct platform_device *pdev)
347 struct clk_hw_onecell_data *clk_data;
348 @@ -1419,12 +1375,6 @@ static const struct of_device_id of_matc
349 .compatible = "mediatek,mt2712-topckgen",
350 .data = clk_mt2712_top_probe,
352 - .compatible = "mediatek,mt2712-infracfg",
353 - .data = clk_mt2712_infra_probe,
355 - .compatible = "mediatek,mt2712-pericfg",
356 - .data = clk_mt2712_peri_probe,
358 .compatible = "mediatek,mt2712-mcucfg",
359 .data = clk_mt2712_mcu_probe,
361 @@ -1450,6 +1400,33 @@ static int clk_mt2712_probe(struct platf
365 +static const struct mtk_clk_desc infra_desc = {
366 + .clks = infra_clks,
367 + .num_clks = ARRAY_SIZE(infra_clks),
368 + .rst_desc = &clk_rst_desc[0],
371 +static const struct mtk_clk_desc peri_desc = {
373 + .num_clks = ARRAY_SIZE(peri_clks),
374 + .rst_desc = &clk_rst_desc[1],
377 +static const struct of_device_id of_match_clk_mt2712_simple[] = {
378 + { .compatible = "mediatek,mt2712-infracfg", .data = &infra_desc },
379 + { .compatible = "mediatek,mt2712-pericfg", .data = &peri_desc, },
383 +static struct platform_driver clk_mt2712_simple_drv = {
384 + .probe = mtk_clk_simple_probe,
385 + .remove = mtk_clk_simple_remove,
387 + .name = "clk-mt2712-simple",
388 + .of_match_table = of_match_clk_mt2712_simple,
392 static struct platform_driver clk_mt2712_drv = {
393 .probe = clk_mt2712_probe,
395 @@ -1460,7 +1437,11 @@ static struct platform_driver clk_mt2712
397 static int __init clk_mt2712_init(void)
399 - return platform_driver_register(&clk_mt2712_drv);
400 + int ret = platform_driver_register(&clk_mt2712_drv);
404 + return platform_driver_register(&clk_mt2712_simple_drv);
407 arch_initcall(clk_mt2712_init);
408 --- a/drivers/clk/mediatek/clk-mt7622-aud.c
409 +++ b/drivers/clk/mediatek/clk-mt7622-aud.c
410 @@ -106,24 +106,22 @@ static const struct mtk_gate audio_clks[
411 GATE_AUDIO3(CLK_AUDIO_MEM_ASRC5, "audio_mem_asrc5", "asm_h_sel", 14),
414 -static int clk_mt7622_audiosys_init(struct platform_device *pdev)
415 +static const struct mtk_clk_desc audio_desc = {
416 + .clks = audio_clks,
417 + .num_clks = ARRAY_SIZE(audio_clks),
420 +static int clk_mt7622_aud_probe(struct platform_device *pdev)
422 - struct clk_hw_onecell_data *clk_data;
423 - struct device_node *node = pdev->dev.of_node;
426 - clk_data = mtk_alloc_clk_data(CLK_AUDIO_NR_CLK);
428 - mtk_clk_register_gates(&pdev->dev, node, audio_clks,
429 - ARRAY_SIZE(audio_clks), clk_data);
431 - r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
432 + r = mtk_clk_simple_probe(pdev);
435 "could not register clock provider: %s: %d\n",
438 - goto err_clk_provider;
442 r = devm_of_platform_populate(&pdev->dev);
443 @@ -133,40 +131,24 @@ static int clk_mt7622_audiosys_init(stru
447 - of_clk_del_provider(node);
449 + mtk_clk_simple_remove(pdev);
453 -static const struct of_device_id of_match_clk_mt7622_aud[] = {
455 - .compatible = "mediatek,mt7622-audsys",
456 - .data = clk_mt7622_audiosys_init,
462 -static int clk_mt7622_aud_probe(struct platform_device *pdev)
463 +static int clk_mt7622_aud_remove(struct platform_device *pdev)
465 - int (*clk_init)(struct platform_device *);
468 - clk_init = of_device_get_match_data(&pdev->dev);
472 - r = clk_init(pdev);
474 - dev_err(&pdev->dev,
475 - "could not register clock provider: %s: %d\n",
479 + of_platform_depopulate(&pdev->dev);
480 + return mtk_clk_simple_remove(pdev);
483 +static const struct of_device_id of_match_clk_mt7622_aud[] = {
484 + { .compatible = "mediatek,mt7622-audsys", .data = &audio_desc },
488 static struct platform_driver clk_mt7622_aud_drv = {
489 .probe = clk_mt7622_aud_probe,
490 + .remove = clk_mt7622_aud_remove,
492 .name = "clk-mt7622-aud",
493 .of_match_table = of_match_clk_mt7622_aud,
494 --- a/drivers/clk/mediatek/clk-mt7622-eth.c
495 +++ b/drivers/clk/mediatek/clk-mt7622-eth.c
496 @@ -61,80 +61,26 @@ static const struct mtk_clk_rst_desc clk
497 .rst_bank_nr = ARRAY_SIZE(rst_ofs),
500 -static int clk_mt7622_ethsys_init(struct platform_device *pdev)
502 - struct clk_hw_onecell_data *clk_data;
503 - struct device_node *node = pdev->dev.of_node;
506 - clk_data = mtk_alloc_clk_data(CLK_ETH_NR_CLK);
508 - mtk_clk_register_gates(&pdev->dev, node, eth_clks,
509 - ARRAY_SIZE(eth_clks), clk_data);
511 - r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
513 - dev_err(&pdev->dev,
514 - "could not register clock provider: %s: %d\n",
517 - mtk_register_reset_controller_with_dev(&pdev->dev, &clk_rst_desc);
522 -static int clk_mt7622_sgmiisys_init(struct platform_device *pdev)
524 - struct clk_hw_onecell_data *clk_data;
525 - struct device_node *node = pdev->dev.of_node;
528 - clk_data = mtk_alloc_clk_data(CLK_SGMII_NR_CLK);
530 - mtk_clk_register_gates(&pdev->dev, node, sgmii_clks,
531 - ARRAY_SIZE(sgmii_clks), clk_data);
533 - r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
535 - dev_err(&pdev->dev,
536 - "could not register clock provider: %s: %d\n",
538 +static const struct mtk_clk_desc eth_desc = {
540 + .num_clks = ARRAY_SIZE(eth_clks),
541 + .rst_desc = &clk_rst_desc,
546 +static const struct mtk_clk_desc sgmii_desc = {
547 + .clks = sgmii_clks,
548 + .num_clks = ARRAY_SIZE(sgmii_clks),
551 static const struct of_device_id of_match_clk_mt7622_eth[] = {
553 - .compatible = "mediatek,mt7622-ethsys",
554 - .data = clk_mt7622_ethsys_init,
556 - .compatible = "mediatek,mt7622-sgmiisys",
557 - .data = clk_mt7622_sgmiisys_init,
561 + { .compatible = "mediatek,mt7622-ethsys", .data = ð_desc },
562 + { .compatible = "mediatek,mt7622-sgmiisys", .data = &sgmii_desc },
566 -static int clk_mt7622_eth_probe(struct platform_device *pdev)
568 - int (*clk_init)(struct platform_device *);
571 - clk_init = of_device_get_match_data(&pdev->dev);
575 - r = clk_init(pdev);
577 - dev_err(&pdev->dev,
578 - "could not register clock provider: %s: %d\n",
584 static struct platform_driver clk_mt7622_eth_drv = {
585 - .probe = clk_mt7622_eth_probe,
586 + .probe = mtk_clk_simple_probe,
587 + .remove = mtk_clk_simple_remove,
589 .name = "clk-mt7622-eth",
590 .of_match_table = of_match_clk_mt7622_eth,
591 --- a/drivers/clk/mediatek/clk-mt7622-hif.c
592 +++ b/drivers/clk/mediatek/clk-mt7622-hif.c
593 @@ -72,82 +72,27 @@ static const struct mtk_clk_rst_desc clk
594 .rst_bank_nr = ARRAY_SIZE(rst_ofs),
597 -static int clk_mt7622_ssusbsys_init(struct platform_device *pdev)
599 - struct clk_hw_onecell_data *clk_data;
600 - struct device_node *node = pdev->dev.of_node;
603 - clk_data = mtk_alloc_clk_data(CLK_SSUSB_NR_CLK);
605 - mtk_clk_register_gates(&pdev->dev, node, ssusb_clks,
606 - ARRAY_SIZE(ssusb_clks), clk_data);
608 - r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
610 - dev_err(&pdev->dev,
611 - "could not register clock provider: %s: %d\n",
614 - mtk_register_reset_controller_with_dev(&pdev->dev, &clk_rst_desc);
619 -static int clk_mt7622_pciesys_init(struct platform_device *pdev)
621 - struct clk_hw_onecell_data *clk_data;
622 - struct device_node *node = pdev->dev.of_node;
625 - clk_data = mtk_alloc_clk_data(CLK_PCIE_NR_CLK);
627 - mtk_clk_register_gates(&pdev->dev, node, pcie_clks,
628 - ARRAY_SIZE(pcie_clks), clk_data);
630 - r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
632 - dev_err(&pdev->dev,
633 - "could not register clock provider: %s: %d\n",
636 - mtk_register_reset_controller_with_dev(&pdev->dev, &clk_rst_desc);
637 +static const struct mtk_clk_desc ssusb_desc = {
638 + .clks = ssusb_clks,
639 + .num_clks = ARRAY_SIZE(ssusb_clks),
640 + .rst_desc = &clk_rst_desc,
645 +static const struct mtk_clk_desc pcie_desc = {
647 + .num_clks = ARRAY_SIZE(pcie_clks),
648 + .rst_desc = &clk_rst_desc,
651 static const struct of_device_id of_match_clk_mt7622_hif[] = {
653 - .compatible = "mediatek,mt7622-pciesys",
654 - .data = clk_mt7622_pciesys_init,
656 - .compatible = "mediatek,mt7622-ssusbsys",
657 - .data = clk_mt7622_ssusbsys_init,
661 + { .compatible = "mediatek,mt7622-pciesys", .data = &pcie_desc },
662 + { .compatible = "mediatek,mt7622-ssusbsys", .data = &ssusb_desc },
666 -static int clk_mt7622_hif_probe(struct platform_device *pdev)
668 - int (*clk_init)(struct platform_device *);
671 - clk_init = of_device_get_match_data(&pdev->dev);
675 - r = clk_init(pdev);
677 - dev_err(&pdev->dev,
678 - "could not register clock provider: %s: %d\n",
684 static struct platform_driver clk_mt7622_hif_drv = {
685 - .probe = clk_mt7622_hif_probe,
686 + .probe = mtk_clk_simple_probe,
687 + .remove = mtk_clk_simple_remove,
689 .name = "clk-mt7622-hif",
690 .of_match_table = of_match_clk_mt7622_hif,
691 --- a/drivers/clk/mediatek/clk-mt7629-hif.c
692 +++ b/drivers/clk/mediatek/clk-mt7629-hif.c
693 @@ -67,82 +67,27 @@ static const struct mtk_clk_rst_desc clk
694 .rst_bank_nr = ARRAY_SIZE(rst_ofs),
697 -static int clk_mt7629_ssusbsys_init(struct platform_device *pdev)
699 - struct clk_hw_onecell_data *clk_data;
700 - struct device_node *node = pdev->dev.of_node;
703 - clk_data = mtk_alloc_clk_data(CLK_SSUSB_NR_CLK);
705 - mtk_clk_register_gates(&pdev->dev, node, ssusb_clks,
706 - ARRAY_SIZE(ssusb_clks), clk_data);
708 - r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
710 - dev_err(&pdev->dev,
711 - "could not register clock provider: %s: %d\n",
714 - mtk_register_reset_controller_with_dev(&pdev->dev, &clk_rst_desc);
719 -static int clk_mt7629_pciesys_init(struct platform_device *pdev)
721 - struct clk_hw_onecell_data *clk_data;
722 - struct device_node *node = pdev->dev.of_node;
725 - clk_data = mtk_alloc_clk_data(CLK_PCIE_NR_CLK);
727 - mtk_clk_register_gates(&pdev->dev, node, pcie_clks,
728 - ARRAY_SIZE(pcie_clks), clk_data);
730 - r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
732 - dev_err(&pdev->dev,
733 - "could not register clock provider: %s: %d\n",
736 - mtk_register_reset_controller_with_dev(&pdev->dev, &clk_rst_desc);
737 +static const struct mtk_clk_desc ssusb_desc = {
738 + .clks = ssusb_clks,
739 + .num_clks = ARRAY_SIZE(ssusb_clks),
740 + .rst_desc = &clk_rst_desc,
745 +static const struct mtk_clk_desc pcie_desc = {
747 + .num_clks = ARRAY_SIZE(pcie_clks),
748 + .rst_desc = &clk_rst_desc,
751 static const struct of_device_id of_match_clk_mt7629_hif[] = {
753 - .compatible = "mediatek,mt7629-pciesys",
754 - .data = clk_mt7629_pciesys_init,
756 - .compatible = "mediatek,mt7629-ssusbsys",
757 - .data = clk_mt7629_ssusbsys_init,
761 + { .compatible = "mediatek,mt7629-pciesys", .data = &pcie_desc },
762 + { .compatible = "mediatek,mt7629-ssusbsys", .data = &ssusb_desc },
766 -static int clk_mt7629_hif_probe(struct platform_device *pdev)
768 - int (*clk_init)(struct platform_device *);
771 - clk_init = of_device_get_match_data(&pdev->dev);
775 - r = clk_init(pdev);
777 - dev_err(&pdev->dev,
778 - "could not register clock provider: %s: %d\n",
784 static struct platform_driver clk_mt7629_hif_drv = {
785 - .probe = clk_mt7629_hif_probe,
786 + .probe = mtk_clk_simple_probe,
787 + .remove = mtk_clk_simple_remove,
789 .name = "clk-mt7629-hif",
790 .of_match_table = of_match_clk_mt7629_hif,