diff options
| author | Tom Rini <[email protected]> | 2026-08-06 14:12:46 -0600 |
|---|---|---|
| committer | Tom Rini <[email protected]> | 2026-08-06 19:36:40 -0600 |
| commit | f2dcc47efc4ffabb4080967279822bb4f3901937 (patch) | |
| tree | 1c30ee4da13a9d330b69a6890c767a05a1201a86 | |
| parent | fce4beb533674318de796eac9b4f1a49ded7bef6 (diff) | |
| parent | 6a77840b2f01e98bbad157fd1984a2dce2a3eecd (diff) | |
Merge tag 'mediatek-for-main-2026-08-05' of https://git.u-boot-project.org/u-boot/custodians/u-boot-mediatek
* Clock fix for MT8188 (Genio 700/520)
* SPL support preparatory patch for MT8188.
* Compile error fix for when enabling LWIP network stack on some MediaTek targets.
* Fix a regression in clock driver binding from the previous PR.
* Add display-related clocks on MT8188.
* Another wave of clock driver refactoring and de-duplication.
| -rw-r--r-- | arch/arm/mach-mediatek/mt8188/init.c | 2 | ||||
| -rw-r--r-- | cmd/ufetch.c | 4 | ||||
| -rw-r--r-- | drivers/clk/mediatek/clk-mt7622.c | 208 | ||||
| -rw-r--r-- | drivers/clk/mediatek/clk-mt7623.c | 117 | ||||
| -rw-r--r-- | drivers/clk/mediatek/clk-mt7629.c | 167 | ||||
| -rw-r--r-- | drivers/clk/mediatek/clk-mt7981.c | 123 | ||||
| -rw-r--r-- | drivers/clk/mediatek/clk-mt7986.c | 66 | ||||
| -rw-r--r-- | drivers/clk/mediatek/clk-mt7987.c | 67 | ||||
| -rw-r--r-- | drivers/clk/mediatek/clk-mt7988.c | 138 | ||||
| -rw-r--r-- | drivers/clk/mediatek/clk-mt8183.c | 51 | ||||
| -rw-r--r-- | drivers/clk/mediatek/clk-mt8188.c | 546 | ||||
| -rw-r--r-- | drivers/clk/mediatek/clk-mt8189.c | 104 | ||||
| -rw-r--r-- | drivers/clk/mediatek/clk-mt8195.c | 46 | ||||
| -rw-r--r-- | drivers/clk/mediatek/clk-mt8365.c | 45 | ||||
| -rw-r--r-- | drivers/clk/mediatek/clk-mt8512.c | 85 | ||||
| -rw-r--r-- | drivers/clk/mediatek/clk-mt8516.c | 45 | ||||
| -rw-r--r-- | drivers/clk/mediatek/clk-mt8518.c | 45 | ||||
| -rw-r--r-- | drivers/clk/mediatek/clk-mtk.c | 162 | ||||
| -rw-r--r-- | drivers/clk/mediatek/clk-mtk.h | 24 |
19 files changed, 1051 insertions, 994 deletions
diff --git a/arch/arm/mach-mediatek/mt8188/init.c b/arch/arm/mach-mediatek/mt8188/init.c index 1108bc19373..b2cdec8c218 100644 --- a/arch/arm/mach-mediatek/mt8188/init.c +++ b/arch/arm/mach-mediatek/mt8188/init.c @@ -33,7 +33,7 @@ void reset_cpu(void) { struct udevice *wdt; - if (IS_ENABLED(CONFIG_PSCI_RESET)) { + if (CONFIG_IS_ENABLED(PSCI_RESET)) { psci_system_reset(); } else { uclass_first_device(UCLASS_WDT, &wdt); diff --git a/cmd/ufetch.c b/cmd/ufetch.c index 763ab42c48a..d4b54f77b7b 100644 --- a/cmd/ufetch.c +++ b/cmd/ufetch.c @@ -60,7 +60,9 @@ enum output_lines { FIRST, SECOND, KERNEL, +#ifdef CONFIG_SYS_CONFIG_NAME SYSINFO, +#endif HOST, UPTIME, IP, @@ -125,9 +127,11 @@ static int do_ufetch(struct cmd_tbl *cmdtp, int flag, int argc, case KERNEL: printf("Kernel:" RESET " %s\n", U_BOOT_VERSION); break; +#ifdef CONFIG_SYS_CONFIG_NAME case SYSINFO: printf("Config:" RESET " %s_defconfig\n", CONFIG_SYS_CONFIG_NAME); break; +#endif case HOST: model = ofnode_read_string(ofnode_root(), "model"); if (model) diff --git a/drivers/clk/mediatek/clk-mt7622.c b/drivers/clk/mediatek/clk-mt7622.c index 76bc31f06d2..d66200f1938 100644 --- a/drivers/clk/mediatek/clk-mt7622.c +++ b/drivers/clk/mediatek/clk-mt7622.c @@ -652,9 +652,32 @@ static const struct mtk_clk_tree mt7622_peri_clk_tree = { .num_gates = ARRAY_SIZE(peri_cgs), }; -static const struct mtk_clk_tree mt7622_clk_tree = { +static const struct mtk_clk_tree mt7622_pcie_clk_tree = { .ext_clk_rates = ext_clock_rates, .num_ext_clks = ARRAY_SIZE(ext_clock_rates), + .gates = pcie_cgs, + .num_gates = ARRAY_SIZE(pcie_cgs), +}; + +static const struct mtk_clk_tree mt7622_eth_clk_tree = { + .ext_clk_rates = ext_clock_rates, + .num_ext_clks = ARRAY_SIZE(ext_clock_rates), + .gates = eth_cgs, + .num_gates = ARRAY_SIZE(eth_cgs), +}; + +static const struct mtk_clk_tree mt7622_sgmii_clk_tree = { + .ext_clk_rates = ext_clock_rates, + .num_ext_clks = ARRAY_SIZE(ext_clock_rates), + .gates = sgmii_cgs, + .num_gates = ARRAY_SIZE(sgmii_cgs), +}; + +static const struct mtk_clk_tree mt7622_ssusb_clk_tree = { + .ext_clk_rates = ext_clock_rates, + .num_ext_clks = ARRAY_SIZE(ext_clock_rates), + .gates = ssusb_cgs, + .num_gates = ARRAY_SIZE(ssusb_cgs), }; static int mt7622_mcucfg_probe(struct udevice *dev) @@ -678,7 +701,7 @@ static int mt7622_apmixedsys_probe(struct udevice *dev) struct mtk_clk_priv *priv = dev_get_priv(dev); int ret; - ret = mtk_common_clk_init(dev, &mt7622_apmixed_clk_tree); + ret = mtk_clk_probe(dev); if (ret) return ret; @@ -692,103 +715,68 @@ static int mt7622_apmixedsys_probe(struct udevice *dev) return 0; } -static int mt7622_topckgen_probe(struct udevice *dev) -{ - return mtk_common_clk_init(dev, &mt7622_topckgen_clk_tree); -} - -static int mt7622_infracfg_probe(struct udevice *dev) -{ - return mtk_common_clk_init(dev, &mt7622_infra_clk_tree); -} - -static int mt7622_pericfg_probe(struct udevice *dev) -{ - return mtk_common_clk_init(dev, &mt7622_peri_clk_tree); -} - -static int mt7622_pciesys_probe(struct udevice *dev) -{ - return mtk_common_clk_gate_init(dev, &mt7622_clk_tree, pcie_cgs, - ARRAY_SIZE(pcie_cgs), 0); -} - -static int mt7622_pciesys_bind(struct udevice *dev) +static int mt7622_reset_bind(struct udevice *dev) { int ret = 0; - if (IS_ENABLED(CONFIG_RESET_MEDIATEK)) { - ret = mediatek_reset_bind(dev, ETHSYS_HIFSYS_RST_CTRL_OFS, 1); - if (ret) - debug("Warning: failed to bind reset controller\n"); + if (CONFIG_IS_ENABLED(RESET_MEDIATEK)) { + ret = mediatek_reset_bind(dev, ETHSYS_HIFSYS_RST_CTRL_OFS, 1); + if (ret) + debug("Warning: failed to bind reset controller\n"); } return ret; } -static int mt7622_ethsys_probe(struct udevice *dev) -{ - return mtk_common_clk_gate_init(dev, &mt7622_clk_tree, eth_cgs, - ARRAY_SIZE(eth_cgs), 0); -} - -static int mt7622_ethsys_bind(struct udevice *dev) -{ - int ret = 0; - -#if CONFIG_IS_ENABLED(RESET_MEDIATEK) - ret = mediatek_reset_bind(dev, ETHSYS_HIFSYS_RST_CTRL_OFS, 1); - if (ret) - debug("Warning: failed to bind reset controller\n"); -#endif - - return ret; -} - -static int mt7622_sgmiisys_probe(struct udevice *dev) -{ - return mtk_common_clk_gate_init(dev, &mt7622_clk_tree, sgmii_cgs, - ARRAY_SIZE(sgmii_cgs), 0); -} - -static int mt7622_ssusbsys_probe(struct udevice *dev) -{ - return mtk_common_clk_gate_init(dev, &mt7622_clk_tree, ssusb_cgs, - ARRAY_SIZE(ssusb_cgs), 0); -} - static const struct udevice_id mt7622_apmixed_compat[] = { - { .compatible = "mediatek,mt7622-apmixedsys" }, + { + .compatible = "mediatek,mt7622-apmixedsys", + .data = (ulong)&mt7622_apmixed_clk_tree, + }, { } }; static const struct udevice_id mt7622_topckgen_compat[] = { - { .compatible = "mediatek,mt7622-topckgen" }, - { } -}; - -static const struct udevice_id mt7622_infracfg_compat[] = { - { .compatible = "mediatek,mt7622-infracfg", }, + { + .compatible = "mediatek,mt7622-topckgen", + .data = (ulong)&mt7622_topckgen_clk_tree, + }, { } }; -static const struct udevice_id mt7622_pericfg_compat[] = { - { .compatible = "mediatek,mt7622-pericfg", }, +static const struct udevice_id of_match_mt7622_infracfg[] = { + { + .compatible = "mediatek,mt7622-infracfg", + .data = (ulong)&mt7622_infra_clk_tree, + }, + { + .compatible = "mediatek,mt7622-pericfg", + .data = (ulong)&mt7622_peri_clk_tree, + }, { } }; -static const struct udevice_id mt7622_pciesys_compat[] = { - { .compatible = "mediatek,mt7622-pciesys", }, +static const struct udevice_id of_match_mt7622_clk_eth[] = { + { + .compatible = "mediatek,mt7622-pciesys", + .data = (ulong)&mt7622_pcie_clk_tree, + }, + { + .compatible = "mediatek,mt7622-ethsys", + .data = (ulong)&mt7622_eth_clk_tree, + }, { } }; -static const struct udevice_id mt7622_ethsys_compat[] = { - { .compatible = "mediatek,mt7622-ethsys", }, - { } -}; - -static const struct udevice_id mt7622_sgmiisys_compat[] = { - { .compatible = "mediatek,mt7622-sgmiisys", }, +static const struct udevice_id of_match_mt7622_clk[] = { + { + .compatible = "mediatek,mt7622-sgmiisys", + .data = (ulong)&mt7622_sgmii_clk_tree, + }, + { + .compatible = "mediatek,mt7622-ssusbsys", + .data = (ulong)&mt7622_ssusb_clk_tree, + }, { } }; @@ -797,11 +785,6 @@ static const struct udevice_id mt7622_mcucfg_compat[] = { { } }; -static const struct udevice_id mt7622_ssusbsys_compat[] = { - { .compatible = "mediatek,mt7622-ssusbsys" }, - { } -}; - U_BOOT_DRIVER(mt7622_mcucfg) = { .name = "mt7622-mcucfg", .id = UCLASS_SYSCON, @@ -814,7 +797,6 @@ U_BOOT_DRIVER(mt7622_clk_apmixedsys) = { .name = "mt7622-clock-apmixedsys", .id = UCLASS_CLK, .of_match = mt7622_apmixed_compat, - .bind = mtk_common_clk_parent_bind, .probe = mt7622_apmixedsys_probe, .priv_auto = sizeof(struct mtk_clk_priv), .ops = &mtk_clk_apmixedsys_ops, @@ -825,8 +807,7 @@ U_BOOT_DRIVER(mt7622_clk_topckgen) = { .name = "mt7622-clock-topckgen", .id = UCLASS_CLK, .of_match = mt7622_topckgen_compat, - .bind = mtk_common_clk_parent_bind, - .probe = mt7622_topckgen_probe, + .probe = mtk_clk_probe, .priv_auto = sizeof(struct mtk_clk_priv), .ops = &mtk_clk_topckgen_ops, .flags = DM_FLAG_PRE_RELOC, @@ -835,57 +816,28 @@ U_BOOT_DRIVER(mt7622_clk_topckgen) = { U_BOOT_DRIVER(mt7622_clk_infracfg) = { .name = "mt7622-clock-infracfg", .id = UCLASS_CLK, - .of_match = mt7622_infracfg_compat, - .probe = mt7622_infracfg_probe, + .of_match = of_match_mt7622_infracfg, + .probe = mtk_clk_probe, .priv_auto = sizeof(struct mtk_clk_priv), .ops = &mtk_clk_infrasys_ops, .flags = DM_FLAG_PRE_RELOC, }; -U_BOOT_DRIVER(mt7622_clk_pericfg) = { - .name = "mt7622-clock-pericfg", +U_BOOT_DRIVER(mt7622_clk_eth) = { + .name = "mt7622-clk-eth", .id = UCLASS_CLK, - .of_match = mt7622_pericfg_compat, - .probe = mt7622_pericfg_probe, + .of_match = of_match_mt7622_clk_eth, + .probe = mtk_clk_probe, + .bind = mt7622_reset_bind, .priv_auto = sizeof(struct mtk_clk_priv), - .ops = &mtk_clk_infrasys_ops, - .flags = DM_FLAG_PRE_RELOC, -}; - -U_BOOT_DRIVER(mt7622_clk_pciesys) = { - .name = "mt7622-clock-pciesys", - .id = UCLASS_CLK, - .of_match = mt7622_pciesys_compat, - .probe = mt7622_pciesys_probe, - .bind = mt7622_pciesys_bind, - .priv_auto = sizeof(struct mtk_cg_priv), - .ops = &mtk_clk_gate_ops, -}; - -U_BOOT_DRIVER(mt7622_clk_ethsys) = { - .name = "mt7622-clock-ethsys", - .id = UCLASS_CLK, - .of_match = mt7622_ethsys_compat, - .probe = mt7622_ethsys_probe, - .bind = mt7622_ethsys_bind, - .priv_auto = sizeof(struct mtk_cg_priv), - .ops = &mtk_clk_gate_ops, -}; - -U_BOOT_DRIVER(mt7622_clk_sgmiisys) = { - .name = "mt7622-clock-sgmiisys", - .id = UCLASS_CLK, - .of_match = mt7622_sgmiisys_compat, - .probe = mt7622_sgmiisys_probe, - .priv_auto = sizeof(struct mtk_cg_priv), - .ops = &mtk_clk_gate_ops, + .ops = &mtk_clk_topckgen_ops, }; -U_BOOT_DRIVER(mt7622_clk_ssusbsys) = { - .name = "mt7622-clock-ssusbsys", +U_BOOT_DRIVER(mt7622_clk) = { + .name = "mt7622-clk", .id = UCLASS_CLK, - .of_match = mt7622_ssusbsys_compat, - .probe = mt7622_ssusbsys_probe, - .priv_auto = sizeof(struct mtk_cg_priv), - .ops = &mtk_clk_gate_ops, + .of_match = of_match_mt7622_clk, + .probe = mtk_clk_probe, + .priv_auto = sizeof(struct mtk_clk_priv), + .ops = &mtk_clk_topckgen_ops, }; diff --git a/drivers/clk/mediatek/clk-mt7623.c b/drivers/clk/mediatek/clk-mt7623.c index 56912ebdb53..cc075495b09 100644 --- a/drivers/clk/mediatek/clk-mt7623.c +++ b/drivers/clk/mediatek/clk-mt7623.c @@ -1047,7 +1047,7 @@ static int mt7623_apmixedsys_probe(struct udevice *dev) struct mtk_clk_priv *priv = dev_get_priv(dev); int ret; - ret = mtk_common_clk_init(dev, &mt7623_apmixedsys_clk_tree); + ret = mtk_clk_probe(dev); if (ret) return ret; @@ -1059,21 +1059,29 @@ static int mt7623_apmixedsys_probe(struct udevice *dev) return 0; } -static int mt7623_topckgen_probe(struct udevice *dev) -{ - return mtk_common_clk_init(dev, &mt7623_topckgen_clk_tree); -} +static const struct mtk_clk_tree mt7623_infracfg_tree = { + .ext_clk_rates = ext_clock_rates, + .num_ext_clks = ARRAY_SIZE(ext_clock_rates), + .gates_offs = 1, + .gates = infra_cgs, + .num_gates = ARRAY_SIZE(infra_cgs), +}; -static const struct mtk_clk_tree mt7623_clk_gate_tree = { +static const struct mtk_clk_tree mt7623_hifsys_tree = { .ext_clk_rates = ext_clock_rates, .num_ext_clks = ARRAY_SIZE(ext_clock_rates), + .gates_offs = 1, + .gates = hif_cgs, + .num_gates = ARRAY_SIZE(hif_cgs), }; -static int mt7623_infracfg_probe(struct udevice *dev) -{ - return mtk_common_clk_gate_init(dev, &mt7623_clk_gate_tree, infra_cgs, - ARRAY_SIZE(infra_cgs), 1); -} +static const struct mtk_clk_tree mt7623_ethsys_tree = { + .ext_clk_rates = ext_clock_rates, + .num_ext_clks = ARRAY_SIZE(ext_clock_rates), + .gates_offs = 1, + .gates = eth_cgs, + .num_gates = ARRAY_SIZE(eth_cgs), +}; static const struct mtk_clk_tree mt7623_clk_peri_tree = { .ext_clk_rates = ext_clock_rates, @@ -1088,23 +1096,6 @@ static const struct mtk_clk_tree mt7623_clk_peri_tree = { .num_gates = ARRAY_SIZE(peri_cgs), }; -static int mt7623_pericfg_probe(struct udevice *dev) -{ - return mtk_common_clk_init(dev, &mt7623_clk_peri_tree); -} - -static int mt7623_hifsys_probe(struct udevice *dev) -{ - return mtk_common_clk_gate_init(dev, &mt7623_clk_gate_tree, hif_cgs, - ARRAY_SIZE(hif_cgs), 1); -} - -static int mt7623_ethsys_probe(struct udevice *dev) -{ - return mtk_common_clk_gate_init(dev, &mt7623_clk_gate_tree, eth_cgs, - ARRAY_SIZE(eth_cgs), 1); -} - static int mt7623_ethsys_hifsys_bind(struct udevice *dev) { int ret = 0; @@ -1119,32 +1110,46 @@ static int mt7623_ethsys_hifsys_bind(struct udevice *dev) } static const struct udevice_id mt7623_apmixed_compat[] = { - { .compatible = "mediatek,mt7623-apmixedsys" }, + { + .compatible = "mediatek,mt7623-apmixedsys", + .data = (ulong)&mt7623_apmixedsys_clk_tree, + }, { } }; static const struct udevice_id mt7623_topckgen_compat[] = { - { .compatible = "mediatek,mt7623-topckgen" }, + { + .compatible = "mediatek,mt7623-topckgen", + .data = (ulong)&mt7623_topckgen_clk_tree, + }, { } }; static const struct udevice_id mt7623_infracfg_compat[] = { - { .compatible = "mediatek,mt7623-infracfg", }, + { + .compatible = "mediatek,mt7623-infracfg", + .data = (ulong)&mt7623_infracfg_tree, + }, { } }; static const struct udevice_id mt7623_pericfg_compat[] = { - { .compatible = "mediatek,mt7623-pericfg", }, + { + .compatible = "mediatek,mt7623-pericfg", + .data = (ulong)&mt7623_clk_peri_tree, + }, { } }; -static const struct udevice_id mt7623_ethsys_compat[] = { - { .compatible = "mediatek,mt7623-ethsys" }, - { } -}; - -static const struct udevice_id mt7623_hifsys_compat[] = { - { .compatible = "mediatek,mt7623-hifsys" }, +static const struct udevice_id of_match_mt7623_clk_eth[] = { + { + .compatible = "mediatek,mt7623-ethsys", + .data = (ulong)&mt7623_ethsys_tree, + }, + { + .compatible = "mediatek,mt7623-hifsys", + .data = (ulong)&mt7623_hifsys_tree, + }, { } }; @@ -1165,7 +1170,6 @@ U_BOOT_DRIVER(mt7623_clk_apmixedsys) = { .name = "mt7623-clock-apmixedsys", .id = UCLASS_CLK, .of_match = mt7623_apmixed_compat, - .bind = mtk_common_clk_parent_bind, .probe = mt7623_apmixedsys_probe, .priv_auto = sizeof(struct mtk_clk_priv), .ops = &mtk_clk_apmixedsys_ops, @@ -1176,8 +1180,7 @@ U_BOOT_DRIVER(mt7623_clk_topckgen) = { .name = "mt7623-clock-topckgen", .id = UCLASS_CLK, .of_match = mt7623_topckgen_compat, - .bind = mtk_common_clk_parent_bind, - .probe = mt7623_topckgen_probe, + .probe = mtk_clk_probe, .priv_auto = sizeof(struct mtk_clk_priv), .ops = &mtk_clk_topckgen_ops, .flags = DM_FLAG_PRE_RELOC, @@ -1187,9 +1190,9 @@ U_BOOT_DRIVER(mt7623_clk_infracfg) = { .name = "mt7623-infracfg", .id = UCLASS_CLK, .of_match = mt7623_infracfg_compat, - .probe = mt7623_infracfg_probe, - .priv_auto = sizeof(struct mtk_cg_priv), - .ops = &mtk_clk_gate_ops, + .probe = mtk_clk_probe, + .priv_auto = sizeof(struct mtk_clk_priv), + .ops = &mtk_clk_topckgen_ops, .flags = DM_FLAG_PRE_RELOC, }; @@ -1197,28 +1200,18 @@ U_BOOT_DRIVER(mt7623_clk_pericfg) = { .name = "mt7623-pericfg", .id = UCLASS_CLK, .of_match = mt7623_pericfg_compat, - .probe = mt7623_pericfg_probe, + .probe = mtk_clk_probe, .priv_auto = sizeof(struct mtk_clk_priv), .ops = &mtk_clk_infrasys_ops, .flags = DM_FLAG_PRE_RELOC, }; -U_BOOT_DRIVER(mt7623_clk_hifsys) = { - .name = "mt7623-clock-hifsys", +U_BOOT_DRIVER(mt7623_clk_eth) = { + .name = "mt7623-clk-eth", .id = UCLASS_CLK, - .of_match = mt7623_hifsys_compat, - .probe = mt7623_hifsys_probe, + .of_match = of_match_mt7623_clk_eth, + .probe = mtk_clk_probe, .bind = mt7623_ethsys_hifsys_bind, - .priv_auto = sizeof(struct mtk_cg_priv), - .ops = &mtk_clk_gate_ops, -}; - -U_BOOT_DRIVER(mt7623_clk_ethsys) = { - .name = "mt7623-clock-ethsys", - .id = UCLASS_CLK, - .of_match = mt7623_ethsys_compat, - .probe = mt7623_ethsys_probe, - .bind = mt7623_ethsys_hifsys_bind, - .priv_auto = sizeof(struct mtk_cg_priv), - .ops = &mtk_clk_gate_ops, + .priv_auto = sizeof(struct mtk_clk_priv), + .ops = &mtk_clk_topckgen_ops, }; diff --git a/drivers/clk/mediatek/clk-mt7629.c b/drivers/clk/mediatek/clk-mt7629.c index aee340aeb37..b271b96ebf3 100644 --- a/drivers/clk/mediatek/clk-mt7629.c +++ b/drivers/clk/mediatek/clk-mt7629.c @@ -598,9 +598,41 @@ static const struct mtk_clk_tree mt7629_topckgen_clk_tree = { .type = MTK_CLK_TREE_TOPCKGEN, }; -static const struct mtk_clk_tree mt7629_clk_tree = { +static const struct mtk_clk_tree mt7629_infracfg_tree = { .ext_clk_rates = ext_clock_rates, .num_ext_clks = ARRAY_SIZE(ext_clock_rates), + .gates_offs = CLK_INFRA_DBGCLK_PD, + .gates = infra_cgs, + .num_gates = ARRAY_SIZE(infra_cgs), +}; + +static const struct mtk_clk_tree mt7629_pericfg_tree = { + .ext_clk_rates = ext_clock_rates, + .num_ext_clks = ARRAY_SIZE(ext_clock_rates), + .gates_offs = CLK_PERI_PWM1_PD, + .gates = peri_cgs, + .num_gates = ARRAY_SIZE(peri_cgs), +}; + +static const struct mtk_clk_tree mt7629_ethsys_tree = { + .ext_clk_rates = ext_clock_rates, + .num_ext_clks = ARRAY_SIZE(ext_clock_rates), + .gates = eth_cgs, + .num_gates = ARRAY_SIZE(eth_cgs), +}; + +static const struct mtk_clk_tree mt7629_sgmii_clk_tree = { + .ext_clk_rates = ext_clock_rates, + .num_ext_clks = ARRAY_SIZE(ext_clock_rates), + .gates = sgmii_cgs, + .num_gates = ARRAY_SIZE(sgmii_cgs), +}; + +static const struct mtk_clk_tree mt7629_ssusb_clk_tree = { + .ext_clk_rates = ext_clock_rates, + .num_ext_clks = ARRAY_SIZE(ext_clock_rates), + .gates = ssusb_cgs, + .num_gates = ARRAY_SIZE(ssusb_cgs), }; static int mt7629_mcucfg_probe(struct udevice *dev) @@ -624,7 +656,7 @@ static int mt7629_apmixedsys_probe(struct udevice *dev) struct mtk_clk_priv *priv = dev_get_priv(dev); int ret; - ret = mtk_common_clk_init(dev, &mt7629_apmixed_clk_tree); + ret = mtk_clk_probe(dev); if (ret) return ret; @@ -636,29 +668,6 @@ static int mt7629_apmixedsys_probe(struct udevice *dev) return 0; } -static int mt7629_topckgen_probe(struct udevice *dev) -{ - return mtk_common_clk_init(dev, &mt7629_topckgen_clk_tree); -} - -static int mt7629_infracfg_probe(struct udevice *dev) -{ - return mtk_common_clk_gate_init(dev, &mt7629_clk_tree, infra_cgs, - ARRAY_SIZE(infra_cgs), 0); -} - -static int mt7629_pericfg_probe(struct udevice *dev) -{ - return mtk_common_clk_gate_init(dev, &mt7629_clk_tree, peri_cgs, - ARRAY_SIZE(peri_cgs), CLK_PERI_PWM1_PD); -} - -static int mt7629_ethsys_probe(struct udevice *dev) -{ - return mtk_common_clk_gate_init(dev, &mt7629_clk_tree, eth_cgs, - ARRAY_SIZE(eth_cgs), 0); -} - static int mt7629_ethsys_bind(struct udevice *dev) { int ret = 0; @@ -672,50 +681,51 @@ static int mt7629_ethsys_bind(struct udevice *dev) return ret; } -static int mt7629_sgmiisys_probe(struct udevice *dev) -{ - return mtk_common_clk_gate_init(dev, &mt7629_clk_tree, sgmii_cgs, - ARRAY_SIZE(sgmii_cgs), 0); -} - -static int mt7629_ssusbsys_probe(struct udevice *dev) -{ - return mtk_common_clk_gate_init(dev, &mt7629_clk_tree, ssusb_cgs, - ARRAY_SIZE(ssusb_cgs), 0); -} - static const struct udevice_id mt7629_apmixed_compat[] = { - { .compatible = "mediatek,mt7629-apmixedsys" }, + { + .compatible = "mediatek,mt7629-apmixedsys", + .data = (ulong)&mt7629_apmixed_clk_tree, + }, { } }; static const struct udevice_id mt7629_topckgen_compat[] = { - { .compatible = "mediatek,mt7629-topckgen" }, - { } -}; - -static const struct udevice_id mt7629_infracfg_compat[] = { - { .compatible = "mediatek,mt7629-infracfg", }, + { + .compatible = "mediatek,mt7629-topckgen", + .data = (ulong)&mt7629_topckgen_clk_tree, + }, { } }; -static const struct udevice_id mt7629_pericfg_compat[] = { - { .compatible = "mediatek,mt7629-pericfg", }, +static const struct udevice_id of_match_mt7629_infracfg[] = { + { + .compatible = "mediatek,mt7629-infracfg", + .data = (ulong)&mt7629_infracfg_tree, + }, + { + .compatible = "mediatek,mt7629-pericfg", + .data = (ulong)&mt7629_pericfg_tree, + }, { } }; static const struct udevice_id mt7629_ethsys_compat[] = { - { .compatible = "mediatek,mt7629-ethsys", }, + { + .compatible = "mediatek,mt7629-ethsys", + .data = (ulong)&mt7629_ethsys_tree, + }, { } }; -static const struct udevice_id mt7629_sgmiisys_compat[] = { - { .compatible = "mediatek,mt7629-sgmiisys", }, - { } -}; - -static const struct udevice_id mt7629_ssusbsys_compat[] = { - { .compatible = "mediatek,mt7629-ssusbsys" }, +static const struct udevice_id of_match_mt7629_clk[] = { + { + .compatible = "mediatek,mt7629-sgmiisys", + .data = (ulong)&mt7629_sgmii_clk_tree, + }, + { + .compatible = "mediatek,mt7629-ssusbsys", + .data = (ulong)&mt7629_ssusb_clk_tree, + }, { } }; @@ -736,7 +746,6 @@ U_BOOT_DRIVER(mt7629_clk_apmixedsys) = { .name = "mt7629-clock-apmixedsys", .id = UCLASS_CLK, .of_match = mt7629_apmixed_compat, - .bind = mtk_common_clk_parent_bind, .probe = mt7629_apmixedsys_probe, .priv_auto = sizeof(struct mtk_clk_priv), .ops = &mtk_clk_apmixedsys_ops, @@ -747,8 +756,7 @@ U_BOOT_DRIVER(mt7629_clk_topckgen) = { .name = "mt7629-clock-topckgen", .id = UCLASS_CLK, .of_match = mt7629_topckgen_compat, - .bind = mtk_common_clk_parent_bind, - .probe = mt7629_topckgen_probe, + .probe = mtk_clk_probe, .priv_auto = sizeof(struct mtk_clk_priv), .ops = &mtk_clk_topckgen_ops, .flags = DM_FLAG_PRE_RELOC, @@ -757,20 +765,10 @@ U_BOOT_DRIVER(mt7629_clk_topckgen) = { U_BOOT_DRIVER(mt7629_clk_infracfg) = { .name = "mt7629-clock-infracfg", .id = UCLASS_CLK, - .of_match = mt7629_infracfg_compat, - .probe = mt7629_infracfg_probe, - .priv_auto = sizeof(struct mtk_cg_priv), - .ops = &mtk_clk_gate_ops, - .flags = DM_FLAG_PRE_RELOC, -}; - -U_BOOT_DRIVER(mt7629_clk_pericfg) = { - .name = "mt7629-clock-pericfg", - .id = UCLASS_CLK, - .of_match = mt7629_pericfg_compat, - .probe = mt7629_pericfg_probe, - .priv_auto = sizeof(struct mtk_cg_priv), - .ops = &mtk_clk_gate_ops, + .of_match = of_match_mt7629_infracfg, + .probe = mtk_clk_probe, + .priv_auto = sizeof(struct mtk_clk_priv), + .ops = &mtk_clk_topckgen_ops, .flags = DM_FLAG_PRE_RELOC, }; @@ -778,26 +776,17 @@ U_BOOT_DRIVER(mt7629_clk_ethsys) = { .name = "mt7629-clock-ethsys", .id = UCLASS_CLK, .of_match = mt7629_ethsys_compat, - .probe = mt7629_ethsys_probe, + .probe = mtk_clk_probe, .bind = mt7629_ethsys_bind, - .priv_auto = sizeof(struct mtk_cg_priv), - .ops = &mtk_clk_gate_ops, -}; - -U_BOOT_DRIVER(mt7629_clk_sgmiisys) = { - .name = "mt7629-clock-sgmiisys", - .id = UCLASS_CLK, - .of_match = mt7629_sgmiisys_compat, - .probe = mt7629_sgmiisys_probe, - .priv_auto = sizeof(struct mtk_cg_priv), - .ops = &mtk_clk_gate_ops, + .priv_auto = sizeof(struct mtk_clk_priv), + .ops = &mtk_clk_topckgen_ops, }; -U_BOOT_DRIVER(mt7629_clk_ssusbsys) = { - .name = "mt7629-clock-ssusbsys", +U_BOOT_DRIVER(mt7629_clk) = { + .name = "mt7629-clk", .id = UCLASS_CLK, - .of_match = mt7629_ssusbsys_compat, - .probe = mt7629_ssusbsys_probe, - .priv_auto = sizeof(struct mtk_cg_priv), - .ops = &mtk_clk_gate_ops, + .of_match = of_match_mt7629_clk, + .probe = mtk_clk_probe, + .priv_auto = sizeof(struct mtk_clk_priv), + .ops = &mtk_clk_topckgen_ops, }; diff --git a/drivers/clk/mediatek/clk-mt7981.c b/drivers/clk/mediatek/clk-mt7981.c index 4e3a1c9d835..7e3e60477d9 100644 --- a/drivers/clk/mediatek/clk-mt7981.c +++ b/drivers/clk/mediatek/clk-mt7981.c @@ -656,27 +656,26 @@ static const struct mtk_clk_tree mt7981_infracfg_clk_tree = { .type = MTK_CLK_TREE_INFRASYS, }; -static const struct mtk_clk_tree mt7981_clk_tree = { - .ext_clk_rates = ext_clock_rates, - .num_ext_clks = ARRAY_SIZE(ext_clock_rates), -}; - static const struct udevice_id mt7981_fixed_pll_compat[] = { - { .compatible = "mediatek,mt7981-fixed-plls" }, - { .compatible = "mediatek,mt7981-apmixedsys" }, + { + .compatible = "mediatek,mt7981-fixed-plls", + .data = (ulong)&mt7981_fixed_pll_clk_tree, + }, + { + .compatible = "mediatek,mt7981-apmixedsys", + .data = (ulong)&mt7981_fixed_pll_clk_tree, + }, {} }; static const struct udevice_id mt7981_topckgen_compat[] = { - { .compatible = "mediatek,mt7981-topckgen" }, + { + .compatible = "mediatek,mt7981-topckgen", + .data = (ulong)&mt7981_topckgen_clk_tree, + }, {} }; -static int mt7981_fixed_pll_probe(struct udevice *dev) -{ - return mtk_common_clk_init(dev, &mt7981_fixed_pll_clk_tree); -} - static int mt7981_topckgen_probe(struct udevice *dev) { struct mtk_clk_priv *priv = dev_get_priv(dev); @@ -684,15 +683,14 @@ static int mt7981_topckgen_probe(struct udevice *dev) priv->base = dev_read_addr_ptr(dev); writel(MT7981_CLK_PDN_EN_WRITE, priv->base + MT7981_CLK_PDN); - return mtk_common_clk_init(dev, &mt7981_topckgen_clk_tree); + return mtk_clk_probe(dev); } U_BOOT_DRIVER(mt7981_clk_apmixedsys) = { .name = "mt7981-clock-fixed-pll", .id = UCLASS_CLK, .of_match = mt7981_fixed_pll_compat, - .bind = mtk_common_clk_parent_bind, - .probe = mt7981_fixed_pll_probe, + .probe = mtk_clk_probe, .priv_auto = sizeof(struct mtk_clk_priv), .ops = &mtk_clk_fixed_pll_ops, .flags = DM_FLAG_PRE_RELOC, @@ -702,7 +700,6 @@ U_BOOT_DRIVER(mt7981_clk_topckgen) = { .name = "mt7981-clock-topckgen", .id = UCLASS_CLK, .of_match = mt7981_topckgen_compat, - .bind = mtk_common_clk_parent_bind, .probe = mt7981_topckgen_probe, .priv_auto = sizeof(struct mtk_clk_priv), .ops = &mtk_clk_topckgen_ops, @@ -710,21 +707,18 @@ U_BOOT_DRIVER(mt7981_clk_topckgen) = { }; static const struct udevice_id mt7981_infracfg_compat[] = { - { .compatible = "mediatek,mt7981-infracfg" }, + { + .compatible = "mediatek,mt7981-infracfg", + .data = (ulong)&mt7981_infracfg_clk_tree, + }, {} }; -static int mt7981_infracfg_probe(struct udevice *dev) -{ - return mtk_common_clk_init(dev, &mt7981_infracfg_clk_tree); -} - U_BOOT_DRIVER(mt7981_clk_infracfg) = { .name = "mt7981-clock-infracfg", .id = UCLASS_CLK, .of_match = mt7981_infracfg_compat, - .bind = mtk_common_clk_parent_bind, - .probe = mt7981_infracfg_probe, + .probe = mtk_clk_probe, .priv_auto = sizeof(struct mtk_clk_priv), .ops = &mtk_clk_infrasys_ops, .flags = DM_FLAG_PRE_RELOC, @@ -751,24 +745,11 @@ static const struct mtk_gate sgmii0_cgs[] = { GATE_SGMII(CLK_SGM0_CDR_CK0_EN, "sgm0_cdr_ck0_en", CLK_TOP_USB_CDR_CK, 5), }; -static int mt7981_sgmii0sys_probe(struct udevice *dev) -{ - return mtk_common_clk_gate_init(dev, &mt7981_clk_tree, - sgmii0_cgs, ARRAY_SIZE(sgmii0_cgs), 0); -} - -static const struct udevice_id mt7981_sgmii0sys_compat[] = { - { .compatible = "mediatek,mt7981-sgmiisys_0", }, - {} -}; - -U_BOOT_DRIVER(mt7981_clk_sgmii0sys) = { - .name = "mt7981-clock-sgmii0sys", - .id = UCLASS_CLK, - .of_match = mt7981_sgmii0sys_compat, - .probe = mt7981_sgmii0sys_probe, - .priv_auto = sizeof(struct mtk_cg_priv), - .ops = &mtk_clk_gate_ops, +static const struct mtk_clk_tree mt7981_sgmii0_clk_tree = { + .ext_clk_rates = ext_clock_rates, + .num_ext_clks = ARRAY_SIZE(ext_clock_rates), + .gates = sgmii0_cgs, + .num_gates = ARRAY_SIZE(sgmii0_cgs), }; static const struct mtk_gate sgmii1_cgs[] = { @@ -778,24 +759,32 @@ static const struct mtk_gate sgmii1_cgs[] = { GATE_SGMII(CLK_SGM1_CDR_CK1_EN, "sgm1_cdr_ck1_en", CLK_TOP_USB_CDR_CK, 5), }; -static int mt7981_sgmii1sys_probe(struct udevice *dev) -{ - return mtk_common_clk_gate_init(dev, &mt7981_clk_tree, - sgmii1_cgs, ARRAY_SIZE(sgmii1_cgs), 0); -} +static const struct mtk_clk_tree mt7981_sgmii1_clk_tree = { + .ext_clk_rates = ext_clock_rates, + .num_ext_clks = ARRAY_SIZE(ext_clock_rates), + .gates = sgmii1_cgs, + .num_gates = ARRAY_SIZE(sgmii1_cgs), +}; -static const struct udevice_id mt7981_sgmii1sys_compat[] = { - { .compatible = "mediatek,mt7981-sgmiisys_1", }, +static const struct udevice_id of_match_mt7981_sgmiisys[] = { + { + .compatible = "mediatek,mt7981-sgmiisys_0", + .data = (ulong)&mt7981_sgmii0_clk_tree, + }, + { + .compatible = "mediatek,mt7981-sgmiisys_1", + .data = (ulong)&mt7981_sgmii1_clk_tree, + }, {} }; -U_BOOT_DRIVER(mt7981_clk_sgmii1sys) = { - .name = "mt7981-clock-sgmii1sys", +U_BOOT_DRIVER(mt7981_clk_sgmiisys) = { + .name = "mt7981-clock-sgmiisys", .id = UCLASS_CLK, - .of_match = mt7981_sgmii1sys_compat, - .probe = mt7981_sgmii1sys_probe, - .priv_auto = sizeof(struct mtk_cg_priv), - .ops = &mtk_clk_gate_ops, + .of_match = of_match_mt7981_sgmiisys, + .probe = mtk_clk_probe, + .priv_auto = sizeof(struct mtk_clk_priv), + .ops = &mtk_clk_topckgen_ops, }; /* ethsys */ @@ -819,11 +808,12 @@ static const struct mtk_gate eth_cgs[] = { GATE_ETH(CLK_ETH_WOCPU0_EN, "eth_wocpu0_en", CLK_TOP_NETSYS_WED_MCU, 15), }; -static int mt7981_ethsys_probe(struct udevice *dev) -{ - return mtk_common_clk_gate_init(dev, &mt7981_clk_tree, - eth_cgs, ARRAY_SIZE(eth_cgs), 0); -} +static const struct mtk_clk_tree mt7981_eth_clk_tree = { + .ext_clk_rates = ext_clock_rates, + .num_ext_clks = ARRAY_SIZE(ext_clock_rates), + .gates = eth_cgs, + .num_gates = ARRAY_SIZE(eth_cgs), +}; static int mt7981_ethsys_bind(struct udevice *dev) { @@ -839,7 +829,10 @@ static int mt7981_ethsys_bind(struct udevice *dev) } static const struct udevice_id mt7981_ethsys_compat[] = { - { .compatible = "mediatek,mt7981-ethsys", }, + { + .compatible = "mediatek,mt7981-ethsys", + .data = (ulong)&mt7981_eth_clk_tree, + }, {} }; @@ -847,8 +840,8 @@ U_BOOT_DRIVER(mt7981_clk_ethsys) = { .name = "mt7981-clock-ethsys", .id = UCLASS_CLK, .of_match = mt7981_ethsys_compat, - .probe = mt7981_ethsys_probe, + .probe = mtk_clk_probe, .bind = mt7981_ethsys_bind, - .priv_auto = sizeof(struct mtk_cg_priv), - .ops = &mtk_clk_gate_ops, + .priv_auto = sizeof(struct mtk_clk_priv), + .ops = &mtk_clk_topckgen_ops, }; diff --git a/drivers/clk/mediatek/clk-mt7986.c b/drivers/clk/mediatek/clk-mt7986.c index 56e18d403c8..e4abddbd515 100644 --- a/drivers/clk/mediatek/clk-mt7986.c +++ b/drivers/clk/mediatek/clk-mt7986.c @@ -564,27 +564,26 @@ static const struct mtk_clk_tree mt7986_infracfg_clk_tree = { .type = MTK_CLK_TREE_INFRASYS, }; -static const struct mtk_clk_tree mt7986_clk_tree = { - .ext_clk_rates = ext_clock_rates, - .num_ext_clks = ARRAY_SIZE(ext_clock_rates), -}; - static const struct udevice_id mt7986_fixed_pll_compat[] = { - { .compatible = "mediatek,mt7986-fixed-plls" }, - { .compatible = "mediatek,mt7986-apmixedsys" }, + { + .compatible = "mediatek,mt7986-fixed-plls", + .data = (ulong)&mt7986_fixed_pll_clk_tree, + }, + { + .compatible = "mediatek,mt7986-apmixedsys", + .data = (ulong)&mt7986_fixed_pll_clk_tree, + }, {} }; static const struct udevice_id mt7986_topckgen_compat[] = { - { .compatible = "mediatek,mt7986-topckgen" }, + { + .compatible = "mediatek,mt7986-topckgen", + .data = (ulong)&mt7986_topckgen_clk_tree, + }, {} }; -static int mt7986_fixed_pll_probe(struct udevice *dev) -{ - return mtk_common_clk_init(dev, &mt7986_fixed_pll_clk_tree); -} - static int mt7986_topckgen_probe(struct udevice *dev) { struct mtk_clk_priv *priv = dev_get_priv(dev); @@ -592,15 +591,14 @@ static int mt7986_topckgen_probe(struct udevice *dev) priv->base = dev_read_addr_ptr(dev); writel(MT7986_CLK_PDN_EN_WRITE, priv->base + MT7986_CLK_PDN); - return mtk_common_clk_init(dev, &mt7986_topckgen_clk_tree); + return mtk_clk_probe(dev); } U_BOOT_DRIVER(mt7986_clk_apmixedsys) = { .name = "mt7986-clock-fixed-pll", .id = UCLASS_CLK, .of_match = mt7986_fixed_pll_compat, - .bind = mtk_common_clk_parent_bind, - .probe = mt7986_fixed_pll_probe, + .probe = mtk_clk_probe, .priv_auto = sizeof(struct mtk_clk_priv), .ops = &mtk_clk_fixed_pll_ops, .flags = DM_FLAG_PRE_RELOC, @@ -610,7 +608,6 @@ U_BOOT_DRIVER(mt7986_clk_topckgen) = { .name = "mt7986-clock-topckgen", .id = UCLASS_CLK, .of_match = mt7986_topckgen_compat, - .bind = mtk_common_clk_parent_bind, .probe = mt7986_topckgen_probe, .priv_auto = sizeof(struct mtk_clk_priv), .ops = &mtk_clk_topckgen_ops, @@ -618,21 +615,18 @@ U_BOOT_DRIVER(mt7986_clk_topckgen) = { }; static const struct udevice_id mt7986_infracfg_compat[] = { - { .compatible = "mediatek,mt7986-infracfg" }, + { + .compatible = "mediatek,mt7986-infracfg", + .data = (ulong)&mt7986_infracfg_clk_tree, + }, {} }; -static int mt7986_infracfg_probe(struct udevice *dev) -{ - return mtk_common_clk_init(dev, &mt7986_infracfg_clk_tree); -} - U_BOOT_DRIVER(mt7986_clk_infracfg) = { .name = "mt7986-clock-infracfg", .id = UCLASS_CLK, .of_match = mt7986_infracfg_compat, - .bind = mtk_common_clk_parent_bind, - .probe = mt7986_infracfg_probe, + .probe = mtk_clk_probe, .priv_auto = sizeof(struct mtk_clk_priv), .ops = &mtk_clk_infrasys_ops, .flags = DM_FLAG_PRE_RELOC, @@ -658,11 +652,12 @@ static const struct mtk_gate eth_cgs[] = { GATE_ETH(CLK_ETH_WOCPU0_EN, "eth_wocpu0_en", CLK_TOP_NETSYS_MCU_SEL, 15), }; -static int mt7986_ethsys_probe(struct udevice *dev) -{ - return mtk_common_clk_gate_init(dev, &mt7986_clk_tree, eth_cgs, - ARRAY_SIZE(eth_cgs), 0); -} +static const struct mtk_clk_tree mt7986_eth_clk_tree = { + .ext_clk_rates = ext_clock_rates, + .num_ext_clks = ARRAY_SIZE(ext_clock_rates), + .gates = eth_cgs, + .num_gates = ARRAY_SIZE(eth_cgs), +}; static int mt7986_ethsys_bind(struct udevice *dev) { @@ -678,7 +673,10 @@ static int mt7986_ethsys_bind(struct udevice *dev) } static const struct udevice_id mt7986_ethsys_compat[] = { - { .compatible = "mediatek,mt7986-ethsys" }, + { + .compatible = "mediatek,mt7986-ethsys", + .data = (ulong)&mt7986_eth_clk_tree, + }, { } }; @@ -686,8 +684,8 @@ U_BOOT_DRIVER(mt7986_clk_ethsys) = { .name = "mt7986-clock-ethsys", .id = UCLASS_CLK, .of_match = mt7986_ethsys_compat, - .probe = mt7986_ethsys_probe, + .probe = mtk_clk_probe, .bind = mt7986_ethsys_bind, - .priv_auto = sizeof(struct mtk_cg_priv), - .ops = &mtk_clk_gate_ops, + .priv_auto = sizeof(struct mtk_clk_priv), + .ops = &mtk_clk_topckgen_ops, }; diff --git a/drivers/clk/mediatek/clk-mt7987.c b/drivers/clk/mediatek/clk-mt7987.c index 4ac0c6faa94..6f2fe12a186 100644 --- a/drivers/clk/mediatek/clk-mt7987.c +++ b/drivers/clk/mediatek/clk-mt7987.c @@ -64,22 +64,22 @@ static const struct mtk_clk_tree mt7987_fixed_pll_clk_tree = { }; static const struct udevice_id mt7987_fixed_pll_compat[] = { - { .compatible = "mediatek,mt7987-fixed-plls" }, - { .compatible = "mediatek,mt7987-apmixedsys" }, + { + .compatible = "mediatek,mt7987-fixed-plls", + .data = (ulong)&mt7987_fixed_pll_clk_tree, + }, + { + .compatible = "mediatek,mt7987-apmixedsys", + .data = (ulong)&mt7987_fixed_pll_clk_tree, + }, {} }; -static int mt7987_fixed_pll_probe(struct udevice *dev) -{ - return mtk_common_clk_init(dev, &mt7987_fixed_pll_clk_tree); -} - U_BOOT_DRIVER(mt7987_clk_apmixedsys) = { .name = "mt7987-clock-fixed-pll", .id = UCLASS_CLK, .of_match = mt7987_fixed_pll_compat, - .bind = mtk_common_clk_parent_bind, - .probe = mt7987_fixed_pll_probe, + .probe = mtk_clk_probe, .priv_auto = sizeof(struct mtk_clk_priv), .ops = &mtk_clk_fixed_pll_ops, .flags = DM_FLAG_PRE_RELOC, @@ -462,13 +462,11 @@ static const struct mtk_clk_tree mt7987_topckgen_clk_tree = { .type = MTK_CLK_TREE_TOPCKGEN, }; -static const struct mtk_clk_tree mt7987_clk_tree = { - .ext_clk_rates = ext_clock_rates, - .num_ext_clks = ARRAY_SIZE(ext_clock_rates), -}; - static const struct udevice_id mt7987_topckgen_compat[] = { - { .compatible = "mediatek,mt7987-topckgen" }, + { + .compatible = "mediatek,mt7987-topckgen", + .data = (ulong)&mt7987_topckgen_clk_tree, + }, {} }; @@ -481,14 +479,13 @@ static int mt7987_topckgen_probe(struct udevice *dev) return -ENOENT; writel(MT7987_CLK_PDN_EN_WRITE, priv->base + MT7987_CLK_PDN); - return mtk_common_clk_init(dev, &mt7987_topckgen_clk_tree); + return mtk_clk_probe(dev); } U_BOOT_DRIVER(mt7987_clk_topckgen) = { .name = "mt7987-clock-topckgen", .id = UCLASS_CLK, .of_match = mt7987_topckgen_compat, - .bind = mtk_common_clk_parent_bind, .probe = mt7987_topckgen_probe, .priv_auto = sizeof(struct mtk_clk_priv), .ops = &mtk_clk_topckgen_ops, @@ -796,22 +793,22 @@ static const struct mtk_clk_tree mt7987_infracfg_clk_tree = { }; static const struct udevice_id mt7987_infracfg_compat[] = { - { .compatible = "mediatek,mt7987-infracfg_ao" }, - { .compatible = "mediatek,mt7987-infracfg" }, + { + .compatible = "mediatek,mt7987-infracfg_ao", + .data = (ulong)&mt7987_infracfg_clk_tree, + }, + { + .compatible = "mediatek,mt7987-infracfg", + .data = (ulong)&mt7987_infracfg_clk_tree, + }, {} }; -static int mt7987_infracfg_probe(struct udevice *dev) -{ - return mtk_common_clk_init(dev, &mt7987_infracfg_clk_tree); -} - U_BOOT_DRIVER(mt7987_clk_infracfg) = { .name = "mt7987-clock-infracfg", .id = UCLASS_CLK, .of_match = mt7987_infracfg_compat, - .bind = mtk_common_clk_parent_bind, - .probe = mt7987_infracfg_probe, + .probe = mtk_clk_probe, .priv_auto = sizeof(struct mtk_clk_priv), .ops = &mtk_clk_infrasys_ops, .flags = DM_FLAG_PRE_RELOC, @@ -838,11 +835,12 @@ static const struct mtk_gate eth_cgs[] = { GATE_ETH_TOP(CLK_ETHDMA_GP3_EN, "ethdma_gp3_en", CLK_TOP_NETSYS_500M_SEL, 10), }; -static int mt7987_ethsys_probe(struct udevice *dev) -{ - return mtk_common_clk_gate_init(dev, &mt7987_clk_tree, eth_cgs, - ARRAY_SIZE(eth_cgs), 0); -} +static const struct mtk_clk_tree mt7987_eth_clk_tree = { + .ext_clk_rates = ext_clock_rates, + .num_ext_clks = ARRAY_SIZE(ext_clock_rates), + .gates = eth_cgs, + .num_gates = ARRAY_SIZE(eth_cgs), +}; static int mt7987_ethsys_bind(struct udevice *dev) { @@ -860,6 +858,7 @@ static int mt7987_ethsys_bind(struct udevice *dev) static const struct udevice_id mt7987_ethsys_compat[] = { { .compatible = "mediatek,mt7987-ethsys", + .data = (ulong)&mt7987_eth_clk_tree, }, {} }; @@ -868,8 +867,8 @@ U_BOOT_DRIVER(mt7987_clk_ethsys) = { .name = "mt7987-clock-ethsys", .id = UCLASS_CLK, .of_match = mt7987_ethsys_compat, - .probe = mt7987_ethsys_probe, + .probe = mtk_clk_probe, .bind = mt7987_ethsys_bind, - .priv_auto = sizeof(struct mtk_cg_priv), - .ops = &mtk_clk_gate_ops, + .priv_auto = sizeof(struct mtk_clk_priv), + .ops = &mtk_clk_topckgen_ops, }; diff --git a/drivers/clk/mediatek/clk-mt7988.c b/drivers/clk/mediatek/clk-mt7988.c index ebad78a9151..4728ca3e25a 100644 --- a/drivers/clk/mediatek/clk-mt7988.c +++ b/drivers/clk/mediatek/clk-mt7988.c @@ -838,27 +838,26 @@ static const struct mtk_clk_tree mt7988_infracfg_clk_tree = { .type = MTK_CLK_TREE_INFRASYS, }; -static const struct mtk_clk_tree mt7988_clk_tree = { - .ext_clk_rates = ext_clock_rates, - .num_ext_clks = ARRAY_SIZE(ext_clock_rates), -}; - static const struct udevice_id mt7988_fixed_pll_compat[] = { - { .compatible = "mediatek,mt7988-fixed-plls" }, - { .compatible = "mediatek,mt7988-apmixedsys" }, + { + .compatible = "mediatek,mt7988-fixed-plls", + .data = (ulong)&mt7988_fixed_pll_clk_tree, + }, + { + .compatible = "mediatek,mt7988-apmixedsys", + .data = (ulong)&mt7988_fixed_pll_clk_tree, + }, {} }; static const struct udevice_id mt7988_topckgen_compat[] = { - { .compatible = "mediatek,mt7988-topckgen" }, + { + .compatible = "mediatek,mt7988-topckgen", + .data = (ulong)&mt7988_topckgen_clk_tree, + }, {} }; -static int mt7988_fixed_pll_probe(struct udevice *dev) -{ - return mtk_common_clk_init(dev, &mt7988_fixed_pll_clk_tree); -} - static int mt7988_topckgen_probe(struct udevice *dev) { struct mtk_clk_priv *priv = dev_get_priv(dev); @@ -868,15 +867,14 @@ static int mt7988_topckgen_probe(struct udevice *dev) return -ENOENT; writel(MT7988_CLK_PDN_EN_WRITE, priv->base + MT7988_CLK_PDN); - return mtk_common_clk_init(dev, &mt7988_topckgen_clk_tree); + return mtk_clk_probe(dev); } U_BOOT_DRIVER(mt7988_clk_apmixedsys) = { .name = "mt7988-clock-fixed-pll", .id = UCLASS_CLK, .of_match = mt7988_fixed_pll_compat, - .bind = mtk_common_clk_parent_bind, - .probe = mt7988_fixed_pll_probe, + .probe = mtk_clk_probe, .priv_auto = sizeof(struct mtk_clk_priv), .ops = &mtk_clk_fixed_pll_ops, .flags = DM_FLAG_PRE_RELOC, @@ -886,7 +884,6 @@ U_BOOT_DRIVER(mt7988_clk_topckgen) = { .name = "mt7988-clock-topckgen", .id = UCLASS_CLK, .of_match = mt7988_topckgen_compat, - .bind = mtk_common_clk_parent_bind, .probe = mt7988_topckgen_probe, .priv_auto = sizeof(struct mtk_clk_priv), .ops = &mtk_clk_topckgen_ops, @@ -894,21 +891,18 @@ U_BOOT_DRIVER(mt7988_clk_topckgen) = { }; static const struct udevice_id mt7988_infracfg_compat[] = { - { .compatible = "mediatek,mt7988-infracfg" }, + { + .compatible = "mediatek,mt7988-infracfg", + .data = (ulong)&mt7988_infracfg_clk_tree, + }, {} }; -static int mt7988_infracfg_probe(struct udevice *dev) -{ - return mtk_common_clk_init(dev, &mt7988_infracfg_clk_tree); -} - U_BOOT_DRIVER(mt7988_clk_infracfg) = { .name = "mt7988-clock-infracfg", .id = UCLASS_CLK, .of_match = mt7988_infracfg_compat, - .bind = mtk_common_clk_parent_bind, - .probe = mt7988_infracfg_probe, + .probe = mtk_clk_probe, .priv_auto = sizeof(struct mtk_clk_priv), .ops = &mtk_clk_infrasys_ops, .flags = DM_FLAG_PRE_RELOC, @@ -933,11 +927,12 @@ static const struct mtk_gate ethdma_mtk_gate[] = { GATE_ETHDMA(CLK_ETHDMA_FE_EN, "ethdma_fe_en", CLK_TOP_NETSYS_2X_SEL, 6), }; -static int mt7988_ethdma_probe(struct udevice *dev) -{ - return mtk_common_clk_gate_init(dev, &mt7988_clk_tree, ethdma_mtk_gate, - ARRAY_SIZE(ethdma_mtk_gate), 0); -} +static const struct mtk_clk_tree mt7988_ethdma_clk_tree = { + .ext_clk_rates = ext_clock_rates, + .num_ext_clks = ARRAY_SIZE(ext_clock_rates), + .gates = ethdma_mtk_gate, + .num_gates = ARRAY_SIZE(ethdma_mtk_gate), +}; static int mt7988_ethdma_bind(struct udevice *dev) { @@ -955,6 +950,7 @@ static int mt7988_ethdma_bind(struct udevice *dev) static const struct udevice_id mt7988_ethdma_compat[] = { { .compatible = "mediatek,mt7988-ethdma", + .data = (ulong)&mt7988_ethdma_clk_tree, }, {} }; @@ -963,10 +959,10 @@ U_BOOT_DRIVER(mt7988_clk_ethdma) = { .name = "mt7988-clock-ethdma", .id = UCLASS_CLK, .of_match = mt7988_ethdma_compat, - .probe = mt7988_ethdma_probe, + .probe = mtk_clk_probe, .bind = mt7988_ethdma_bind, - .priv_auto = sizeof(struct mtk_cg_priv), - .ops = &mtk_clk_gate_ops, + .priv_auto = sizeof(struct mtk_clk_priv), + .ops = &mtk_clk_topckgen_ops, }; /* SGMIISYS_0 */ @@ -991,27 +987,11 @@ static const struct mtk_gate sgmiisys_0_mtk_gate[] = { GATE_SGMII0(CLK_SGM0_RX_EN, "sgm0_rx_en", CLK_TOP_XTAL, 3), }; -static int mt7988_sgmiisys_0_probe(struct udevice *dev) -{ - return mtk_common_clk_gate_init(dev, &mt7988_clk_tree, - sgmiisys_0_mtk_gate, - ARRAY_SIZE(sgmiisys_0_mtk_gate), 0); -} - -static const struct udevice_id mt7988_sgmiisys_0_compat[] = { - { - .compatible = "mediatek,mt7988-sgmiisys_0", - }, - {} -}; - -U_BOOT_DRIVER(mt7988_clk_sgmiisys_0) = { - .name = "mt7988-clock-sgmiisys_0", - .id = UCLASS_CLK, - .of_match = mt7988_sgmiisys_0_compat, - .probe = mt7988_sgmiisys_0_probe, - .priv_auto = sizeof(struct mtk_cg_priv), - .ops = &mtk_clk_gate_ops, +static const struct mtk_clk_tree mt7988_sgmiisys_0_clk_tree = { + .ext_clk_rates = ext_clock_rates, + .num_ext_clks = ARRAY_SIZE(ext_clock_rates), + .gates = sgmiisys_0_mtk_gate, + .num_gates = ARRAY_SIZE(sgmiisys_0_mtk_gate), }; /* SGMIISYS_1 */ @@ -1036,27 +1016,32 @@ static const struct mtk_gate sgmiisys_1_mtk_gate[] = { GATE_SGMII1(CLK_SGM1_RX_EN, "sgm1_rx_en", CLK_TOP_XTAL, 3), }; -static int mt7988_sgmiisys_1_probe(struct udevice *dev) -{ - return mtk_common_clk_gate_init(dev, &mt7988_clk_tree, - sgmiisys_1_mtk_gate, - ARRAY_SIZE(sgmiisys_1_mtk_gate), 0); -} +static const struct mtk_clk_tree mt7988_sgmiisys_1_clk_tree = { + .ext_clk_rates = ext_clock_rates, + .num_ext_clks = ARRAY_SIZE(ext_clock_rates), + .gates = sgmiisys_1_mtk_gate, + .num_gates = ARRAY_SIZE(sgmiisys_1_mtk_gate), +}; -static const struct udevice_id mt7988_sgmiisys_1_compat[] = { +static const struct udevice_id of_match_mt7988_sgmiisys[] = { + { + .compatible = "mediatek,mt7988-sgmiisys_0", + .data = (ulong)&mt7988_sgmiisys_0_clk_tree, + }, { .compatible = "mediatek,mt7988-sgmiisys_1", + .data = (ulong)&mt7988_sgmiisys_1_clk_tree, }, {} }; -U_BOOT_DRIVER(mt7988_clk_sgmiisys_1) = { - .name = "mt7988-clock-sgmiisys_1", +U_BOOT_DRIVER(mt7988_clk_sgmiisys) = { + .name = "mt7988-clock-sgmiisys", .id = UCLASS_CLK, - .of_match = mt7988_sgmiisys_1_compat, - .probe = mt7988_sgmiisys_1_probe, - .priv_auto = sizeof(struct mtk_cg_priv), - .ops = &mtk_clk_gate_ops, + .of_match = of_match_mt7988_sgmiisys, + .probe = mtk_clk_probe, + .priv_auto = sizeof(struct mtk_clk_priv), + .ops = &mtk_clk_topckgen_ops, }; /* ETHWARP */ @@ -1083,12 +1068,12 @@ static const struct mtk_gate ethwarp_mtk_gate[] = { CLK_TOP_NETSYS_MCU_SEL, 15), }; -static int mt7988_ethwarp_probe(struct udevice *dev) -{ - return mtk_common_clk_gate_init(dev, &mt7988_clk_tree, - ethwarp_mtk_gate, - ARRAY_SIZE(ethwarp_mtk_gate), 0); -} +static const struct mtk_clk_tree mt7988_ethwarp_clk_tree = { + .ext_clk_rates = ext_clock_rates, + .num_ext_clks = ARRAY_SIZE(ext_clock_rates), + .gates = ethwarp_mtk_gate, + .num_gates = ARRAY_SIZE(ethwarp_mtk_gate), +}; static int mt7988_ethwarp_bind(struct udevice *dev) { @@ -1106,6 +1091,7 @@ static int mt7988_ethwarp_bind(struct udevice *dev) static const struct udevice_id mt7988_ethwarp_compat[] = { { .compatible = "mediatek,mt7988-ethwarp", + .data = (ulong)&mt7988_ethwarp_clk_tree, }, {} }; @@ -1114,8 +1100,8 @@ U_BOOT_DRIVER(mt7988_clk_ethwarp) = { .name = "mt7988-clock-ethwarp", .id = UCLASS_CLK, .of_match = mt7988_ethwarp_compat, - .probe = mt7988_ethwarp_probe, + .probe = mtk_clk_probe, .bind = mt7988_ethwarp_bind, - .priv_auto = sizeof(struct mtk_cg_priv), - .ops = &mtk_clk_gate_ops, + .priv_auto = sizeof(struct mtk_clk_priv), + .ops = &mtk_clk_topckgen_ops, }; diff --git a/drivers/clk/mediatek/clk-mt8183.c b/drivers/clk/mediatek/clk-mt8183.c index a619dce5ca3..5a4863049c5 100644 --- a/drivers/clk/mediatek/clk-mt8183.c +++ b/drivers/clk/mediatek/clk-mt8183.c @@ -627,11 +627,6 @@ static const struct mtk_clk_tree mt8183_topckgen_clk_tree = { .type = MTK_CLK_TREE_TOPCKGEN, }; -static const struct mtk_clk_tree mt8183_clk_tree = { - .ext_clk_rates = ext_clock_rates, - .num_ext_clks = ARRAY_SIZE(ext_clock_rates), -}; - static const struct mtk_gate_regs infra0_cg_regs = { .set_ofs = 0x80, .clr_ofs = 0x84, @@ -792,34 +787,34 @@ static const struct mtk_gate infra_clks[] = { GATE_INFRA3(CLK_INFRA_FBIST2FPC, CLK_TOP_MUX_MSDC50_0, 24), }; -static int mt8183_apmixedsys_probe(struct udevice *dev) -{ - return mtk_common_clk_init(dev, &mt8183_apmixed_clk_tree); -} - -static int mt8183_topckgen_probe(struct udevice *dev) -{ - return mtk_common_clk_init(dev, &mt8183_topckgen_clk_tree); -} - -static int mt8183_infracfg_probe(struct udevice *dev) -{ - return mtk_common_clk_gate_init(dev, &mt8183_clk_tree, infra_clks, - ARRAY_SIZE(infra_clks), 0); -} +static const struct mtk_clk_tree mt8183_infracfg_tree = { + .ext_clk_rates = ext_clock_rates, + .num_ext_clks = ARRAY_SIZE(ext_clock_rates), + .gates = infra_clks, + .num_gates = ARRAY_SIZE(infra_clks), +}; static const struct udevice_id mt8183_apmixed_compat[] = { - { .compatible = "mediatek,mt8183-apmixedsys", }, + { + .compatible = "mediatek,mt8183-apmixedsys", + .data = (ulong)&mt8183_apmixed_clk_tree, + }, { } }; static const struct udevice_id mt8183_topckgen_compat[] = { - { .compatible = "mediatek,mt8183-topckgen", }, + { + .compatible = "mediatek,mt8183-topckgen", + .data = (ulong)&mt8183_topckgen_clk_tree, + }, { } }; static const struct udevice_id mt8183_infracfg_compat[] = { - { .compatible = "mediatek,mt8183-infracfg", }, + { + .compatible = "mediatek,mt8183-infracfg", + .data = (ulong)&mt8183_infracfg_tree, + }, { } }; @@ -827,8 +822,7 @@ U_BOOT_DRIVER(mt8183_clk_apmixedsys) = { .name = "mt8183-apmixedsys", .id = UCLASS_CLK, .of_match = mt8183_apmixed_compat, - .bind = mtk_common_clk_parent_bind, - .probe = mt8183_apmixedsys_probe, + .probe = mtk_clk_probe, .priv_auto = sizeof(struct mtk_clk_priv), .ops = &mtk_clk_apmixedsys_ops, .flags = DM_FLAG_PRE_RELOC, @@ -838,8 +832,7 @@ U_BOOT_DRIVER(mt8183_clk_topckgen) = { .name = "mt8183-topckgen", .id = UCLASS_CLK, .of_match = mt8183_topckgen_compat, - .bind = mtk_common_clk_parent_bind, - .probe = mt8183_topckgen_probe, + .probe = mtk_clk_probe, .priv_auto = sizeof(struct mtk_clk_priv), .ops = &mtk_clk_topckgen_ops, .flags = DM_FLAG_PRE_RELOC, @@ -849,8 +842,8 @@ U_BOOT_DRIVER(mt8183_clk_infracfg) = { .name = "mt8183-infracfg", .id = UCLASS_CLK, .of_match = mt8183_infracfg_compat, - .probe = mt8183_infracfg_probe, + .probe = mtk_clk_probe, .priv_auto = sizeof(struct mtk_clk_priv), - .ops = &mtk_clk_gate_ops, + .ops = &mtk_clk_topckgen_ops, .flags = DM_FLAG_PRE_RELOC, }; diff --git a/drivers/clk/mediatek/clk-mt8188.c b/drivers/clk/mediatek/clk-mt8188.c index f73fa1fce95..0829ebf4f9a 100644 --- a/drivers/clk/mediatek/clk-mt8188.c +++ b/drivers/clk/mediatek/clk-mt8188.c @@ -1363,7 +1363,7 @@ static const struct mtk_gate_regs top1_cg_regs = { .parent = _parent, \ .regs = &top0_cg_regs, \ .shift = _shift, \ - .flags = CLK_GATE_NO_SETCLR | CLK_PARENT_TOPCKGEN, \ + .flags = CLK_GATE_NO_SETCLR_INV | CLK_PARENT_TOPCKGEN, \ } #define GATE_TOP0E(_id, _parent, _shift) { \ @@ -1371,7 +1371,7 @@ static const struct mtk_gate_regs top1_cg_regs = { .parent = _parent, \ .regs = &top0_cg_regs, \ .shift = _shift, \ - .flags = CLK_GATE_NO_SETCLR | CLK_PARENT_EXT, \ + .flags = CLK_GATE_NO_SETCLR_INV | CLK_PARENT_EXT, \ } #define GATE_TOP1(_id, _parent, _shift) { \ @@ -1622,6 +1622,8 @@ static const struct mtk_gate infracfg_ao_clks[] = { static const struct mtk_clk_tree mt8188_infracfg_ao_clk_tree = { .ext_clk_rates = ext_clock_rates, .num_ext_clks = ARRAY_SIZE(ext_clock_rates), + .gates = infracfg_ao_clks, + .num_gates = ARRAY_SIZE(infracfg_ao_clks), }; static const struct mtk_gate_regs peri_ao_cg_regs = { @@ -1665,6 +1667,8 @@ static const struct mtk_gate pericfg_ao_clks[] = { static const struct mtk_clk_tree mt8188_pericfg_ao_clk_tree = { .ext_clk_rates = ext_clock_rates, .num_ext_clks = ARRAY_SIZE(ext_clock_rates), + .gates = pericfg_ao_clks, + .num_gates = ARRAY_SIZE(pericfg_ao_clks), }; static const struct mtk_gate_regs imp_iic_wrap_cg_regs = { @@ -1700,95 +1704,463 @@ static const struct mtk_gate imp_iic_wrap_en_clks[] = { const struct mtk_clk_tree mt8188_imp_iic_wrap_c_clk_tree = { .ext_clk_rates = ext_clock_rates, .num_ext_clks = ARRAY_SIZE(ext_clock_rates), + .gates = imp_iic_wrap_c_clks, + .num_gates = ARRAY_SIZE(imp_iic_wrap_c_clks), }; const struct mtk_clk_tree mt8188_imp_iic_wrap_w_clk_tree = { .ext_clk_rates = ext_clock_rates, .num_ext_clks = ARRAY_SIZE(ext_clock_rates), + .gates = imp_iic_wrap_w_clks, + .num_gates = ARRAY_SIZE(imp_iic_wrap_w_clks), }; const struct mtk_clk_tree mt8188_imp_iic_wrap_en_clk_tree = { .ext_clk_rates = ext_clock_rates, .num_ext_clks = ARRAY_SIZE(ext_clock_rates), + .gates = imp_iic_wrap_en_clks, + .num_gates = ARRAY_SIZE(imp_iic_wrap_en_clks), }; -static int mt8188_apmixedsys_probe(struct udevice *dev) -{ - return mtk_common_clk_init(dev, &mt8188_apmixedsys_clk_tree); -} +static const struct mtk_gate_regs vdo0_0_cg_regs = { + .set_ofs = 0x104, + .clr_ofs = 0x108, + .sta_ofs = 0x100, +}; -static int mt8188_topckgen_probe(struct udevice *dev) -{ - return mtk_common_clk_init(dev, &mt8188_topckgen_clk_tree); -} +static const struct mtk_gate_regs vdo0_1_cg_regs = { + .set_ofs = 0x114, + .clr_ofs = 0x118, + .sta_ofs = 0x110, +}; -static int mt8188_infracfg_ao_probe(struct udevice *dev) -{ - return mtk_common_clk_gate_init(dev, &mt8188_infracfg_ao_clk_tree, - infracfg_ao_clks, - ARRAY_SIZE(infracfg_ao_clks), 0); -} +static const struct mtk_gate_regs vdo0_2_cg_regs = { + .set_ofs = 0x124, + .clr_ofs = 0x128, + .sta_ofs = 0x120, +}; -static int mt8188_pericfg_ao_probe(struct udevice *dev) -{ - return mtk_common_clk_gate_init(dev, &mt8188_pericfg_ao_clk_tree, - pericfg_ao_clks, - ARRAY_SIZE(pericfg_ao_clks), 0); -} +static const struct mtk_gate_regs vpp0_0_cg_regs = { + .set_ofs = 0x24, + .clr_ofs = 0x28, + .sta_ofs = 0x20, +}; -static int mt8188_imp_iic_wrap_c_probe(struct udevice *dev) -{ - return mtk_common_clk_gate_init(dev, &mt8188_imp_iic_wrap_c_clk_tree, - imp_iic_wrap_c_clks, - ARRAY_SIZE(imp_iic_wrap_c_clks), 0); -} +static const struct mtk_gate_regs vpp0_1_cg_regs = { + .set_ofs = 0x30, + .clr_ofs = 0x34, + .sta_ofs = 0x2c, +}; -static int mt8188_imp_iic_wrap_w_probe(struct udevice *dev) -{ - return mtk_common_clk_gate_init(dev, &mt8188_imp_iic_wrap_w_clk_tree, - imp_iic_wrap_w_clks, - ARRAY_SIZE(imp_iic_wrap_w_clks), 0); -} +static const struct mtk_gate_regs vpp0_2_cg_regs = { + .set_ofs = 0x3c, + .clr_ofs = 0x40, + .sta_ofs = 0x38, +}; -static int mt8188_imp_iic_wrap_en_probe(struct udevice *dev) -{ - return mtk_common_clk_gate_init(dev, &mt8188_imp_iic_wrap_en_clk_tree, - imp_iic_wrap_en_clks, - ARRAY_SIZE(imp_iic_wrap_en_clks), 0); -} +#define GATE_VPP0_0(_id, _parent, _shift) \ + GATE_FLAGS(_id, _parent, &vpp0_0_cg_regs, _shift, \ + CLK_PARENT_TOPCKGEN | CLK_GATE_SETCLR) -static const struct udevice_id mt8188_apmixed_compat[] = { - { .compatible = "mediatek,mt8188-apmixedsys", }, - { } +#define GATE_VPP0_1(_id, _parent, _shift) \ + GATE_FLAGS(_id, _parent, &vpp0_1_cg_regs, _shift, \ + CLK_PARENT_TOPCKGEN | CLK_GATE_SETCLR) + +#define GATE_VPP0_2(_id, _parent, _shift) \ + GATE_FLAGS(_id, _parent, &vpp0_2_cg_regs, _shift, \ + CLK_PARENT_TOPCKGEN | CLK_GATE_SETCLR) + +static const struct mtk_gate vpp0_clks[] = { + /* VPP0_0 */ + GATE_VPP0_0(CLK_VPP0_MDP_FG, CLK_TOP_VPP, 1), + GATE_VPP0_0(CLK_VPP0_STITCH, CLK_TOP_VPP, 2), + GATE_VPP0_0(CLK_VPP0_PADDING, CLK_TOP_VPP, 7), + GATE_VPP0_0(CLK_VPP0_MDP_TCC, CLK_TOP_VPP, 8), + GATE_VPP0_0(CLK_VPP0_WARP0_ASYNC_TX, CLK_TOP_VPP, 10), + GATE_VPP0_0(CLK_VPP0_WARP1_ASYNC_TX, CLK_TOP_VPP, 11), + GATE_VPP0_0(CLK_VPP0_MUTEX, CLK_TOP_VPP, 13), + GATE_VPP0_0(CLK_VPP02VPP1_RELAY, CLK_TOP_VPP, 14), + GATE_VPP0_0(CLK_VPP0_VPP12VPP0_ASYNC, CLK_TOP_VPP, 15), + GATE_VPP0_0(CLK_VPP0_MMSYSRAM_TOP, CLK_TOP_VPP, 16), + GATE_VPP0_0(CLK_VPP0_MDP_AAL, CLK_TOP_VPP, 17), + GATE_VPP0_0(CLK_VPP0_MDP_RSZ, CLK_TOP_VPP, 18), + /* VPP0_1 */ + GATE_VPP0_1(CLK_VPP0_SMI_COMMON_MMSRAM, CLK_TOP_VPP, 0), + GATE_VPP0_1(CLK_VPP0_GALS_VDO0_LARB0_MMSRAM, CLK_TOP_VPP, 1), + GATE_VPP0_1(CLK_VPP0_GALS_VDO0_LARB1_MMSRAM, CLK_TOP_VPP, 2), + GATE_VPP0_1(CLK_VPP0_GALS_VENCSYS_MMSRAM, CLK_TOP_VPP, 3), + GATE_VPP0_1(CLK_VPP0_GALS_VENCSYS_CORE1_MMSRAM, CLK_TOP_VPP, 4), + GATE_VPP0_1(CLK_VPP0_GALS_INFRA_MMSRAM, CLK_TOP_VPP, 5), + GATE_VPP0_1(CLK_VPP0_GALS_CAMSYS_MMSRAM, CLK_TOP_VPP, 6), + GATE_VPP0_1(CLK_VPP0_GALS_VPP1_LARB5_MMSRAM, CLK_TOP_VPP, 7), + GATE_VPP0_1(CLK_VPP0_GALS_VPP1_LARB6_MMSRAM, CLK_TOP_VPP, 8), + GATE_VPP0_1(CLK_VPP0_SMI_REORDER_MMSRAM, CLK_TOP_VPP, 9), + GATE_VPP0_1(CLK_VPP0_SMI_IOMMU, CLK_TOP_VPP, 10), + GATE_VPP0_1(CLK_VPP0_GALS_IMGSYS_CAMSYS, CLK_TOP_VPP, 11), + GATE_VPP0_1(CLK_VPP0_MDP_RDMA, CLK_TOP_VPP, 12), + GATE_VPP0_1(CLK_VPP0_MDP_WROT, CLK_TOP_VPP, 13), + GATE_VPP0_1(CLK_VPP0_GALS_EMI0_EMI1, CLK_TOP_VPP, 16), + GATE_VPP0_1(CLK_VPP0_SMI_SUB_COMMON_REORDER, CLK_TOP_VPP, 17), + GATE_VPP0_1(CLK_VPP0_SMI_RSI, CLK_TOP_VPP, 18), + GATE_VPP0_1(CLK_VPP0_SMI_COMMON_LARB4, CLK_TOP_VPP, 19), + GATE_VPP0_1(CLK_VPP0_GALS_VDEC_VDEC_CORE1, CLK_TOP_VPP, 20), + GATE_VPP0_1(CLK_VPP0_GALS_VPP1_WPESYS, CLK_TOP_VPP, 21), + GATE_VPP0_1(CLK_VPP0_GALS_VDO0_VDO1_VENCSYS_CORE1, CLK_TOP_VPP, 22), + GATE_VPP0_1(CLK_VPP0_FAKE_ENG, CLK_TOP_VPP, 23), + GATE_VPP0_1(CLK_VPP0_MDP_HDR, CLK_TOP_VPP, 24), + GATE_VPP0_1(CLK_VPP0_MDP_TDSHP, CLK_TOP_VPP, 25), + GATE_VPP0_1(CLK_VPP0_MDP_COLOR, CLK_TOP_VPP, 26), + GATE_VPP0_1(CLK_VPP0_MDP_OVL, CLK_TOP_VPP, 27), + GATE_VPP0_1(CLK_VPP0_DSIP_RDMA, CLK_TOP_VPP, 28), + GATE_VPP0_1(CLK_VPP0_DISP_WDMA, CLK_TOP_VPP, 29), + GATE_VPP0_1(CLK_VPP0_MDP_HMS, CLK_TOP_VPP, 30), + /* VPP0_2 */ + GATE_VPP0_2(CLK_VPP0_WARP0_RELAY, CLK_TOP_WPE_VPP, 0), + GATE_VPP0_2(CLK_VPP0_WARP0_ASYNC, CLK_TOP_WPE_VPP, 1), + GATE_VPP0_2(CLK_VPP0_WARP1_RELAY, CLK_TOP_WPE_VPP, 2), + GATE_VPP0_2(CLK_VPP0_WARP1_ASYNC, CLK_TOP_WPE_VPP, 3), }; -static const struct udevice_id mt8188_topckgen_compat[] = { - { .compatible = "mediatek,mt8188-topckgen", }, - { } +static const struct mtk_gate_regs vpp1_0_cg_regs = { + .set_ofs = 0x104, + .clr_ofs = 0x108, + .sta_ofs = 0x100, }; -static const struct udevice_id mt8188_infracfg_ao_compat[] = { - { .compatible = "mediatek,mt8188-infracfg-ao", }, - { } +static const struct mtk_gate_regs vpp1_1_cg_regs = { + .set_ofs = 0x114, + .clr_ofs = 0x118, + .sta_ofs = 0x110, }; -static const struct udevice_id mt8188_pericfg_ao_compat[] = { - { .compatible = "mediatek,mt8188-pericfg-ao", }, - { } +#define GATE_VPP1_0(_id, _parent, _shift) \ + GATE_FLAGS(_id, _parent, &vpp1_0_cg_regs, _shift, \ + CLK_PARENT_TOPCKGEN | CLK_GATE_SETCLR) + +#define GATE_VPP1_1(_id, _parent, _shift) \ + GATE_FLAGS(_id, _parent, &vpp1_1_cg_regs, _shift, \ + CLK_PARENT_TOPCKGEN | CLK_GATE_SETCLR) + +static const struct mtk_gate vpp1_clks[] = { + /* VPP1_0 */ + GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_OVL, CLK_TOP_VPP, 0), + GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_TCC, CLK_TOP_VPP, 1), + GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_WROT, CLK_TOP_VPP, 2), + GATE_VPP1_0(CLK_VPP1_SVPP1_VPP_PAD, CLK_TOP_VPP, 3), + GATE_VPP1_0(CLK_VPP1_SVPP2_MDP_WROT, CLK_TOP_VPP, 4), + GATE_VPP1_0(CLK_VPP1_SVPP2_VPP_PAD, CLK_TOP_VPP, 5), + GATE_VPP1_0(CLK_VPP1_SVPP3_MDP_WROT, CLK_TOP_VPP, 6), + GATE_VPP1_0(CLK_VPP1_SVPP3_VPP_PAD, CLK_TOP_VPP, 7), + GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_RDMA, CLK_TOP_VPP, 8), + GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_FG, CLK_TOP_VPP, 9), + GATE_VPP1_0(CLK_VPP1_SVPP2_MDP_RDMA, CLK_TOP_VPP, 10), + GATE_VPP1_0(CLK_VPP1_SVPP2_MDP_FG, CLK_TOP_VPP, 11), + GATE_VPP1_0(CLK_VPP1_SVPP3_MDP_RDMA, CLK_TOP_VPP, 12), + GATE_VPP1_0(CLK_VPP1_SVPP3_MDP_FG, CLK_TOP_VPP, 13), + GATE_VPP1_0(CLK_VPP1_VPP_SPLIT, CLK_TOP_VPP, 14), + GATE_VPP1_0(CLK_VPP1_SVPP2_VDO0_DL_RELAY, CLK_TOP_VPP, 15), + GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_RSZ, CLK_TOP_VPP, 16), + GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_TDSHP, CLK_TOP_VPP, 17), + GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_COLOR, CLK_TOP_VPP, 18), + GATE_VPP1_0(CLK_VPP1_SVPP3_VDO1_DL_RELAY, CLK_TOP_VPP, 19), + GATE_VPP1_0(CLK_VPP1_SVPP2_MDP_RSZ, CLK_TOP_VPP, 20), + GATE_VPP1_0(CLK_VPP1_SVPP2_VPP_MERGE, CLK_TOP_VPP, 21), + GATE_VPP1_0(CLK_VPP1_SVPP2_MDP_TDSHP, CLK_TOP_VPP, 22), + GATE_VPP1_0(CLK_VPP1_SVPP2_MDP_COLOR, CLK_TOP_VPP, 23), + GATE_VPP1_0(CLK_VPP1_SVPP3_MDP_RSZ, CLK_TOP_VPP, 24), + GATE_VPP1_0(CLK_VPP1_SVPP3_VPP_MERGE, CLK_TOP_VPP, 25), + GATE_VPP1_0(CLK_VPP1_SVPP3_MDP_TDSHP, CLK_TOP_VPP, 26), + GATE_VPP1_0(CLK_VPP1_SVPP3_MDP_COLOR, CLK_TOP_VPP, 27), + GATE_VPP1_0(CLK_VPP1_GALS5, CLK_TOP_VPP, 28), + GATE_VPP1_0(CLK_VPP1_GALS6, CLK_TOP_VPP, 29), + GATE_VPP1_0(CLK_VPP1_LARB5, CLK_TOP_VPP, 30), + GATE_VPP1_0(CLK_VPP1_LARB6, CLK_TOP_VPP, 31), + /* VPP1_1 */ + GATE_VPP1_1(CLK_VPP1_SVPP1_MDP_HDR, CLK_TOP_VPP, 0), + GATE_VPP1_1(CLK_VPP1_SVPP1_MDP_AAL, CLK_TOP_VPP, 1), + GATE_VPP1_1(CLK_VPP1_SVPP2_MDP_HDR, CLK_TOP_VPP, 2), + GATE_VPP1_1(CLK_VPP1_SVPP2_MDP_AAL, CLK_TOP_VPP, 3), + GATE_VPP1_1(CLK_VPP1_SVPP3_MDP_HDR, CLK_TOP_VPP, 4), + GATE_VPP1_1(CLK_VPP1_SVPP3_MDP_AAL, CLK_TOP_VPP, 5), + GATE_VPP1_1(CLK_VPP1_DISP_MUTEX, CLK_TOP_VPP, 7), + GATE_VPP1_1(CLK_VPP1_SVPP2_VDO1_DL_RELAY, CLK_TOP_VPP, 8), + GATE_VPP1_1(CLK_VPP1_SVPP3_VDO0_DL_RELAY, CLK_TOP_VPP, 9), + GATE_VPP1_1(CLK_VPP1_VPP0_DL_ASYNC, CLK_TOP_VPP, 10), + GATE_VPP1_1(CLK_VPP1_VPP0_DL1_RELAY, CLK_TOP_VPP, 11), + GATE_VPP1_1(CLK_VPP1_LARB5_FAKE_ENG, CLK_TOP_VPP, 12), + GATE_VPP1_1(CLK_VPP1_LARB6_FAKE_ENG, CLK_TOP_VPP, 13), + GATE_VPP1_1(CLK_VPP1_HDMI_META, CLK_TOP_VPP, 16), + GATE_VPP1_1(CLK_VPP1_VPP_SPLIT_HDMI, CLK_TOP_VPP, 17), + GATE_VPP1_1(CLK_VPP1_DGI_IN, CLK_TOP_VPP, 18), + GATE_VPP1_1(CLK_VPP1_DGI_OUT, CLK_TOP_VPP, 19), + GATE_VPP1_1(CLK_VPP1_VPP_SPLIT_DGI, CLK_TOP_VPP, 20), + GATE_VPP1_1(CLK_VPP1_DL_CON_OCC, CLK_TOP_VPP, 21), + GATE_VPP1_1(CLK_VPP1_VPP_SPLIT_26M, CLK_TOP_VPP, 26), +}; + +#define GATE_VDO0_0(_id, _parent, _shift) \ + GATE_FLAGS(_id, _parent, &vdo0_0_cg_regs, _shift, \ + CLK_PARENT_TOPCKGEN | CLK_GATE_SETCLR) + +#define GATE_VDO0_1(_id, _parent, _shift) \ + GATE_FLAGS(_id, _parent, &vdo0_1_cg_regs, _shift, \ + CLK_PARENT_TOPCKGEN | CLK_GATE_SETCLR) + +#define GATE_VDO0_2(_id, _parent, _shift) \ + GATE_FLAGS(_id, _parent, &vdo0_2_cg_regs, _shift, \ + CLK_PARENT_TOPCKGEN | CLK_GATE_SETCLR) + +static const struct mtk_gate vdo0_clks[] = { + /* VDO0_0 */ + GATE_VDO0_0(CLK_VDO0_DISP_OVL0, CLK_TOP_VPP, 0), + GATE_VDO0_0(CLK_VDO0_FAKE_ENG0, CLK_TOP_VPP, 2), + GATE_VDO0_0(CLK_VDO0_DISP_CCORR0, CLK_TOP_VPP, 4), + GATE_VDO0_0(CLK_VDO0_DISP_MUTEX0, CLK_TOP_VPP, 6), + GATE_VDO0_0(CLK_VDO0_DISP_GAMMA0, CLK_TOP_VPP, 8), + GATE_VDO0_0(CLK_VDO0_DISP_DITHER0, CLK_TOP_VPP, 10), + GATE_VDO0_0(CLK_VDO0_DISP_WDMA0, CLK_TOP_VPP, 17), + GATE_VDO0_0(CLK_VDO0_DISP_RDMA0, CLK_TOP_VPP, 19), + GATE_VDO0_0(CLK_VDO0_DSI0, CLK_TOP_VPP, 21), + GATE_VDO0_0(CLK_VDO0_DSI1, CLK_TOP_VPP, 22), + GATE_VDO0_0(CLK_VDO0_DSC_WRAP0, CLK_TOP_VPP, 23), + GATE_VDO0_0(CLK_VDO0_VPP_MERGE0, CLK_TOP_VPP, 24), + GATE_VDO0_0(CLK_VDO0_DP_INTF0, CLK_TOP_VPP, 25), + GATE_VDO0_0(CLK_VDO0_DISP_AAL0, CLK_TOP_VPP, 26), + GATE_VDO0_0(CLK_VDO0_INLINEROT0, CLK_TOP_VPP, 27), + GATE_VDO0_0(CLK_VDO0_APB_BUS, CLK_TOP_VPP, 28), + GATE_VDO0_0(CLK_VDO0_DISP_COLOR0, CLK_TOP_VPP, 29), + GATE_VDO0_0(CLK_VDO0_MDP_WROT0, CLK_TOP_VPP, 30), + GATE_VDO0_0(CLK_VDO0_DISP_RSZ0, CLK_TOP_VPP, 31), + /* VDO0_1 */ + GATE_VDO0_1(CLK_VDO0_DISP_POSTMASK0, CLK_TOP_VPP, 0), + GATE_VDO0_1(CLK_VDO0_FAKE_ENG1, CLK_TOP_VPP, 1), + GATE_VDO0_1(CLK_VDO0_DL_ASYNC2, CLK_TOP_VPP, 5), + GATE_VDO0_1(CLK_VDO0_DL_RELAY3, CLK_TOP_VPP, 6), + GATE_VDO0_1(CLK_VDO0_DL_RELAY4, CLK_TOP_VPP, 7), + GATE_VDO0_1(CLK_VDO0_SMI_GALS, CLK_TOP_VPP, 10), + GATE_VDO0_1(CLK_VDO0_SMI_COMMON, CLK_TOP_VPP, 11), + GATE_VDO0_1(CLK_VDO0_SMI_EMI, CLK_TOP_VPP, 12), + GATE_VDO0_1(CLK_VDO0_SMI_IOMMU, CLK_TOP_VPP, 13), + GATE_VDO0_1(CLK_VDO0_SMI_LARB, CLK_TOP_VPP, 14), + GATE_VDO0_1(CLK_VDO0_SMI_RSI, CLK_TOP_VPP, 15), + /* VDO0_2 */ + GATE_VDO0_2(CLK_VDO0_DSI0_DSI, CLK_TOP_DSI_OCC, 0), + GATE_VDO0_2(CLK_VDO0_DSI1_DSI, CLK_TOP_DSI_OCC, 8), + GATE_VDO0_2(CLK_VDO0_DP_INTF0_DP_INTF, CLK_TOP_EDP, 16), +}; + +static const struct mtk_gate_regs vdo1_0_cg_regs = { + .set_ofs = 0x104, + .clr_ofs = 0x108, + .sta_ofs = 0x100, +}; + +static const struct mtk_gate_regs vdo1_1_cg_regs = { + .set_ofs = 0x114, + .clr_ofs = 0x118, + .sta_ofs = 0x110, +}; + +static const struct mtk_gate_regs vdo1_2_cg_regs = { + .set_ofs = 0x124, + .clr_ofs = 0x128, + .sta_ofs = 0x120, +}; + +static const struct mtk_gate_regs vdo1_3_cg_regs = { + .set_ofs = 0x134, + .clr_ofs = 0x138, + .sta_ofs = 0x130, +}; + +static const struct mtk_gate_regs vdo1_4_cg_regs = { + .set_ofs = 0x144, + .clr_ofs = 0x148, + .sta_ofs = 0x140, +}; + +static const struct mtk_gate_regs vdo1_5_cg_regs = { + .set_ofs = 0x400, + .clr_ofs = 0x400, + .sta_ofs = 0x400, +}; + +#define GATE_VDO1_0(_id, _parent, _shift) \ + GATE_FLAGS(_id, _parent, &vdo1_0_cg_regs, _shift, \ + CLK_PARENT_TOPCKGEN | CLK_GATE_SETCLR) + +#define GATE_VDO1_1(_id, _parent, _shift) \ + GATE_FLAGS(_id, _parent, &vdo1_1_cg_regs, _shift, \ + CLK_PARENT_TOPCKGEN | CLK_GATE_SETCLR) + +#define GATE_VDO1_2(_id, _parent, _shift) \ + GATE_FLAGS(_id, _parent, &vdo1_2_cg_regs, _shift, \ + CLK_PARENT_TOPCKGEN | CLK_GATE_SETCLR) + +#define GATE_VDO1_3(_id, _parent, _shift) \ + GATE_FLAGS(_id, _parent, &vdo1_3_cg_regs, _shift, \ + CLK_PARENT_TOPCKGEN | CLK_GATE_SETCLR) + +#define GATE_VDO1_4(_id, _parent, _shift) \ + GATE_FLAGS(_id, _parent, &vdo1_4_cg_regs, _shift, \ + CLK_PARENT_TOPCKGEN | CLK_GATE_SETCLR) + +#define GATE_VDO1_5(_id, _parent, _shift) \ + GATE_FLAGS(_id, _parent, &vdo1_5_cg_regs, _shift, \ + CLK_PARENT_TOPCKGEN | CLK_GATE_SETCLR) + +static const struct mtk_gate vdo1_clks[] = { + /* VDO1_0 */ + GATE_VDO1_0(CLK_VDO1_SMI_LARB2, CLK_TOP_VPP, 0), + GATE_VDO1_0(CLK_VDO1_SMI_LARB3, CLK_TOP_VPP, 1), + GATE_VDO1_0(CLK_VDO1_GALS, CLK_TOP_VPP, 2), + GATE_VDO1_0(CLK_VDO1_FAKE_ENG0, CLK_TOP_VPP, 3), + GATE_VDO1_0(CLK_VDO1_FAKE_ENG1, CLK_TOP_VPP, 4), + GATE_VDO1_0(CLK_VDO1_MDP_RDMA0, CLK_TOP_VPP, 5), + GATE_VDO1_0(CLK_VDO1_MDP_RDMA1, CLK_TOP_VPP, 6), + GATE_VDO1_0(CLK_VDO1_MDP_RDMA2, CLK_TOP_VPP, 7), + GATE_VDO1_0(CLK_VDO1_MDP_RDMA3, CLK_TOP_VPP, 8), + GATE_VDO1_0(CLK_VDO1_VPP_MERGE0, CLK_TOP_VPP, 9), + GATE_VDO1_0(CLK_VDO1_VPP_MERGE1, CLK_TOP_VPP, 10), + GATE_VDO1_0(CLK_VDO1_VPP_MERGE2, CLK_TOP_VPP, 11), + /* VDO1_1 */ + GATE_VDO1_1(CLK_VDO1_VPP_MERGE3, CLK_TOP_VPP, 0), + GATE_VDO1_1(CLK_VDO1_VPP_MERGE4, CLK_TOP_VPP, 1), + GATE_VDO1_1(CLK_VDO1_VPP2_TO_VDO1_DL_ASYNC, CLK_TOP_VPP, 2), + GATE_VDO1_1(CLK_VDO1_VPP3_TO_VDO1_DL_ASYNC, CLK_TOP_VPP, 3), + GATE_VDO1_1(CLK_VDO1_DISP_MUTEX, CLK_TOP_VPP, 4), + GATE_VDO1_1(CLK_VDO1_MDP_RDMA4, CLK_TOP_VPP, 5), + GATE_VDO1_1(CLK_VDO1_MDP_RDMA5, CLK_TOP_VPP, 6), + GATE_VDO1_1(CLK_VDO1_MDP_RDMA6, CLK_TOP_VPP, 7), + GATE_VDO1_1(CLK_VDO1_MDP_RDMA7, CLK_TOP_VPP, 8), + GATE_VDO1_1(CLK_VDO1_DP_INTF0_MMCK, CLK_TOP_VPP, 9), + GATE_VDO1_1(CLK_VDO1_DPI0_MM, CLK_TOP_VPP, 10), + GATE_VDO1_1(CLK_VDO1_DPI1_MM, CLK_TOP_VPP, 11), + GATE_VDO1_1(CLK_VDO1_MERGE0_DL_ASYNC, CLK_TOP_VPP, 13), + GATE_VDO1_1(CLK_VDO1_MERGE1_DL_ASYNC, CLK_TOP_VPP, 14), + GATE_VDO1_1(CLK_VDO1_MERGE2_DL_ASYNC, CLK_TOP_VPP, 15), + GATE_VDO1_1(CLK_VDO1_MERGE3_DL_ASYNC, CLK_TOP_VPP, 16), + GATE_VDO1_1(CLK_VDO1_MERGE4_DL_ASYNC, CLK_TOP_VPP, 17), + GATE_VDO1_1(CLK_VDO1_DSC_VDO1_DL_ASYNC, CLK_TOP_VPP, 18), + GATE_VDO1_1(CLK_VDO1_MERGE_VDO1_DL_ASYNC, CLK_TOP_VPP, 19), + GATE_VDO1_1(CLK_VDO1_PADDING0, CLK_TOP_VPP, 20), + GATE_VDO1_1(CLK_VDO1_PADDING1, CLK_TOP_VPP, 21), + GATE_VDO1_1(CLK_VDO1_PADDING2, CLK_TOP_VPP, 22), + GATE_VDO1_1(CLK_VDO1_PADDING3, CLK_TOP_VPP, 23), + GATE_VDO1_1(CLK_VDO1_PADDING4, CLK_TOP_VPP, 24), + GATE_VDO1_1(CLK_VDO1_PADDING5, CLK_TOP_VPP, 25), + GATE_VDO1_1(CLK_VDO1_PADDING6, CLK_TOP_VPP, 26), + GATE_VDO1_1(CLK_VDO1_PADDING7, CLK_TOP_VPP, 27), + GATE_VDO1_1(CLK_VDO1_DISP_RSZ0, CLK_TOP_VPP, 28), + GATE_VDO1_1(CLK_VDO1_DISP_RSZ1, CLK_TOP_VPP, 29), + GATE_VDO1_1(CLK_VDO1_DISP_RSZ2, CLK_TOP_VPP, 30), + GATE_VDO1_1(CLK_VDO1_DISP_RSZ3, CLK_TOP_VPP, 31), + /* VDO1_2 */ + GATE_VDO1_2(CLK_VDO1_HDR_VDO_FE0, CLK_TOP_VPP, 0), + GATE_VDO1_2(CLK_VDO1_HDR_GFX_FE0, CLK_TOP_VPP, 1), + GATE_VDO1_2(CLK_VDO1_HDR_VDO_BE, CLK_TOP_VPP, 2), + GATE_VDO1_2(CLK_VDO1_HDR_VDO_FE1, CLK_TOP_VPP, 16), + GATE_VDO1_2(CLK_VDO1_HDR_GFX_FE1, CLK_TOP_VPP, 17), + GATE_VDO1_2(CLK_VDO1_DISP_MIXER, CLK_TOP_VPP, 18), + GATE_VDO1_2(CLK_VDO1_HDR_VDO_FE0_DL_ASYNC, CLK_TOP_VPP, 19), + GATE_VDO1_2(CLK_VDO1_HDR_VDO_FE1_DL_ASYNC, CLK_TOP_VPP, 20), + GATE_VDO1_2(CLK_VDO1_HDR_GFX_FE0_DL_ASYNC, CLK_TOP_VPP, 21), + GATE_VDO1_2(CLK_VDO1_HDR_GFX_FE1_DL_ASYNC, CLK_TOP_VPP, 22), + GATE_VDO1_2(CLK_VDO1_HDR_VDO_BE_DL_ASYNC, CLK_TOP_VPP, 23), + /* VDO1_3 */ + GATE_VDO1_3(CLK_VDO1_DPI0, CLK_TOP_VPP, 0), + GATE_VDO1_3(CLK_VDO1_DISP_MONITOR_DPI0, CLK_TOP_VPP, 1), + GATE_VDO1_3(CLK_VDO1_DPI1, CLK_TOP_VPP, 8), + GATE_VDO1_3(CLK_VDO1_DISP_MONITOR_DPI1, CLK_TOP_VPP, 9), + GATE_VDO1_3(CLK_VDO1_DPINTF, CLK_TOP_VPP, 16), + GATE_VDO1_3(CLK_VDO1_DISP_MONITOR_DPINTF, CLK_TOP_VPP, 17), + /* VDO1_4 */ + GATE_VDO1_4(CLK_VDO1_26M_SLOW, CLK_PAD_CLK26M, 8), + /* VDO1_5 */ + GATE_VDO1_5(CLK_VDO1_DPI1_HDMI, CLK_TOP_VPP, 0), +}; + +const struct mtk_clk_tree mt8188_vpp0_clk_tree = { + .ext_clk_rates = ext_clock_rates, + .num_ext_clks = ARRAY_SIZE(ext_clock_rates), + .gates = vpp0_clks, + .num_gates = ARRAY_SIZE(vpp0_clks), +}; + +const struct mtk_clk_tree mt8188_vpp1_clk_tree = { + .ext_clk_rates = ext_clock_rates, + .num_ext_clks = ARRAY_SIZE(ext_clock_rates), + .gates = vpp1_clks, + .num_gates = ARRAY_SIZE(vpp1_clks), +}; + +const struct mtk_clk_tree mt8188_vdo0_clk_tree = { + .ext_clk_rates = ext_clock_rates, + .num_ext_clks = ARRAY_SIZE(ext_clock_rates), + .gates = vdo0_clks, + .num_gates = ARRAY_SIZE(vdo0_clks), +}; + +const struct mtk_clk_tree mt8188_vdo1_clk_tree = { + .ext_clk_rates = ext_clock_rates, + .num_ext_clks = ARRAY_SIZE(ext_clock_rates), + .gates = vdo1_clks, + .num_gates = ARRAY_SIZE(vdo1_clks), }; -static const struct udevice_id mt8188_imp_iic_wrap_c_compat[] = { - { .compatible = "mediatek,mt8188-imp-iic-wrap-c", }, +static const struct udevice_id mt8188_apmixed_compat[] = { + { + .compatible = "mediatek,mt8188-apmixedsys", + .data = (ulong)&mt8188_apmixedsys_clk_tree, + }, { } }; -static const struct udevice_id mt8188_imp_iic_wrap_w_compat[] = { - { .compatible = "mediatek,mt8188-imp-iic-wrap-w", }, +static const struct udevice_id mt8188_topckgen_compat[] = { + { + .compatible = "mediatek,mt8188-topckgen", + .data = (ulong)&mt8188_topckgen_clk_tree, + }, { } }; -static const struct udevice_id mt8188_imp_iic_wrap_en_compat[] = { - { .compatible = "mediatek,mt8188-imp-iic-wrap-en", }, +static const struct udevice_id of_match_mt8188_clk[] = { + { + .compatible = "mediatek,mt8188-infracfg-ao", + .data = (ulong)&mt8188_infracfg_ao_clk_tree, + }, + { + .compatible = "mediatek,mt8188-pericfg-ao", + .data = (ulong)&mt8188_pericfg_ao_clk_tree, + }, + { + .compatible = "mediatek,mt8188-imp-iic-wrap-c", + .data = (ulong)&mt8188_imp_iic_wrap_c_clk_tree, + }, + { + .compatible = "mediatek,mt8188-imp-iic-wrap-w", + .data = (ulong)&mt8188_imp_iic_wrap_w_clk_tree, + }, + { + .compatible = "mediatek,mt8188-imp-iic-wrap-en", + .data = (ulong)&mt8188_imp_iic_wrap_en_clk_tree, + }, + { + .compatible = "mediatek,mt8188-vppsys0", + .data = (ulong)&mt8188_vpp0_clk_tree, + }, + { + .compatible = "mediatek,mt8188-vppsys1", + .data = (ulong)&mt8188_vpp1_clk_tree, + }, + { + .compatible = "mediatek,mt8188-vdosys0", + .data = (ulong)&mt8188_vdo0_clk_tree, + }, + { + .compatible = "mediatek,mt8188-vdosys1", + .data = (ulong)&mt8188_vdo1_clk_tree, + }, { } }; @@ -1796,8 +2168,7 @@ U_BOOT_DRIVER(mt8188_clk_apmixedsys) = { .name = "mt8188-apmixedsys", .id = UCLASS_CLK, .of_match = mt8188_apmixed_compat, - .bind = mtk_common_clk_parent_bind, - .probe = mt8188_apmixedsys_probe, + .probe = mtk_clk_probe, .priv_auto = sizeof(struct mtk_clk_priv), .ops = &mtk_clk_apmixedsys_ops, .flags = DM_FLAG_PRE_RELOC, @@ -1807,59 +2178,18 @@ U_BOOT_DRIVER(mt8188_clk_topckgen) = { .name = "mt8188-topckgen", .id = UCLASS_CLK, .of_match = mt8188_topckgen_compat, - .bind = mtk_common_clk_parent_bind, - .probe = mt8188_topckgen_probe, + .probe = mtk_clk_probe, .priv_auto = sizeof(struct mtk_clk_priv), .ops = &mtk_clk_topckgen_ops, .flags = DM_FLAG_PRE_RELOC, }; -U_BOOT_DRIVER(mt8188_clk_infracfg_ao) = { - .name = "mt8188-infracfg-ao", - .id = UCLASS_CLK, - .of_match = mt8188_infracfg_ao_compat, - .probe = mt8188_infracfg_ao_probe, - .priv_auto = sizeof(struct mtk_cg_priv), - .ops = &mtk_clk_gate_ops, - .flags = DM_FLAG_PRE_RELOC, -}; - -U_BOOT_DRIVER(mt8188_clk_pericfg_ao) = { - .name = "mt8188-pericfg-ao", - .id = UCLASS_CLK, - .of_match = mt8188_pericfg_ao_compat, - .probe = mt8188_pericfg_ao_probe, - .priv_auto = sizeof(struct mtk_cg_priv), - .ops = &mtk_clk_gate_ops, - .flags = DM_FLAG_PRE_RELOC, -}; - -U_BOOT_DRIVER(mt8188_clk_imp_iic_wrap_c) = { - .name = "mt8188-imp_iic_wrap_c", +U_BOOT_DRIVER(mt8188_clk) = { + .name = "mt8188-clk", .id = UCLASS_CLK, - .of_match = mt8188_imp_iic_wrap_c_compat, - .probe = mt8188_imp_iic_wrap_c_probe, - .priv_auto = sizeof(struct mtk_cg_priv), - .ops = &mtk_clk_gate_ops, - .flags = DM_FLAG_PRE_RELOC, -}; - -U_BOOT_DRIVER(mt8188_clk_imp_iic_wrap_w) = { - .name = "mt8188-imp_iic_wrap_w", - .id = UCLASS_CLK, - .of_match = mt8188_imp_iic_wrap_w_compat, - .probe = mt8188_imp_iic_wrap_w_probe, - .priv_auto = sizeof(struct mtk_cg_priv), - .ops = &mtk_clk_gate_ops, - .flags = DM_FLAG_PRE_RELOC, -}; - -U_BOOT_DRIVER(mt8188_clk_imp_iic_wrap_en) = { - .name = "mt8188-imp_iic_wrap_en", - .id = UCLASS_CLK, - .of_match = mt8188_imp_iic_wrap_en_compat, - .probe = mt8188_imp_iic_wrap_en_probe, - .priv_auto = sizeof(struct mtk_cg_priv), - .ops = &mtk_clk_gate_ops, + .of_match = of_match_mt8188_clk, + .probe = mtk_clk_probe, + .priv_auto = sizeof(struct mtk_clk_priv), + .ops = &mtk_clk_topckgen_ops, .flags = DM_FLAG_PRE_RELOC, }; diff --git a/drivers/clk/mediatek/clk-mt8189.c b/drivers/clk/mediatek/clk-mt8189.c index 3093fac23ce..15e040569e7 100644 --- a/drivers/clk/mediatek/clk-mt8189.c +++ b/drivers/clk/mediatek/clk-mt8189.c @@ -1970,87 +1970,63 @@ static const struct mtk_clk_tree mt8189_vlpckgen_clk_tree = { .type = MTK_CLK_TREE_VLP_CK, }; -static const struct mtk_clk_tree mt8189_clk_tree = { - .ext_clk_rates = ext_clock_rates, - .num_ext_clks = ARRAY_SIZE(ext_clock_rates), -}; - static const struct udevice_id mt8189_apmixed[] = { - { .compatible = "mediatek,mt8189-apmixedsys", }, + { + .compatible = "mediatek,mt8189-apmixedsys", + .data = (ulong)&mt8189_apmixedsys_clk_tree, + }, { } }; static const struct udevice_id mt8189_topckgen_compat[] = { - { .compatible = "mediatek,mt8189-topckgen", }, + { + .compatible = "mediatek,mt8189-topckgen", + .data = (ulong)&mt8189_topckgen_clk_tree, + }, { } }; static const struct udevice_id mt8189_vlpckgen[] = { - { .compatible = "mediatek,mt8189-vlpckgen", }, + { + .compatible = "mediatek,mt8189-vlpckgen", + .data = (ulong)&mt8189_vlpckgen_clk_tree, + }, { } }; -struct mt8189_gate_clk_data { - const struct mtk_gate *gates; - int num_gates; -}; - -#define GATE_CLK_DATA(name) \ -static const struct mt8189_gate_clk_data name##_data = { \ - .gates = name, .num_gates = ARRAY_SIZE(name) \ +#define GATE_CLK_TREE(_name) \ +static const struct mtk_clk_tree _name##_tree = { \ + .ext_clk_rates = ext_clock_rates, \ + .num_ext_clks = ARRAY_SIZE(ext_clock_rates), \ + .gates = _name, \ + .num_gates = ARRAY_SIZE(_name), \ + .gates_offs = _name[0].id, \ } -GATE_CLK_DATA(perao_clks); -GATE_CLK_DATA(imp_clks); -GATE_CLK_DATA(mm_clks); -GATE_CLK_DATA(mminfra_config_clks); -GATE_CLK_DATA(ufs_config_ao_clks); -GATE_CLK_DATA(ufs_config_pdn_clks); -GATE_CLK_DATA(vlpcfg_ao_clks); +GATE_CLK_TREE(perao_clks); +GATE_CLK_TREE(imp_clks); +GATE_CLK_TREE(mm_clks); +GATE_CLK_TREE(mminfra_config_clks); +GATE_CLK_TREE(ufs_config_ao_clks); +GATE_CLK_TREE(ufs_config_pdn_clks); +GATE_CLK_TREE(vlpcfg_ao_clks); static const struct udevice_id of_match_mt8189_clk_gate[] = { - { .compatible = "mediatek,mt8189-peri-ao", .data = (ulong)&perao_clks_data }, - { .compatible = "mediatek,mt8189-iic-wrap", .data = (ulong)&imp_clks_data }, - { .compatible = "mediatek,mt8189-dispsys", .data = (ulong)&mm_clks_data }, - { .compatible = "mediatek,mt8189-mm-infra", .data = (ulong)&mminfra_config_clks_data }, - { .compatible = "mediatek,mt8189-ufscfg-ao", .data = (ulong)&ufs_config_ao_clks_data }, - { .compatible = "mediatek,mt8189-ufscfg-pdn", .data = (ulong)&ufs_config_pdn_clks_data }, - { .compatible = "mediatek,mt8189-vlpcfg-ao", .data = (ulong)&vlpcfg_ao_clks_data }, + { .compatible = "mediatek,mt8189-peri-ao", .data = (ulong)&perao_clks_tree }, + { .compatible = "mediatek,mt8189-iic-wrap", .data = (ulong)&imp_clks_tree }, + { .compatible = "mediatek,mt8189-dispsys", .data = (ulong)&mm_clks_tree }, + { .compatible = "mediatek,mt8189-mm-infra", .data = (ulong)&mminfra_config_clks_tree }, + { .compatible = "mediatek,mt8189-ufscfg-ao", .data = (ulong)&ufs_config_ao_clks_tree }, + { .compatible = "mediatek,mt8189-ufscfg-pdn", .data = (ulong)&ufs_config_pdn_clks_tree }, + { .compatible = "mediatek,mt8189-vlpcfg-ao", .data = (ulong)&vlpcfg_ao_clks_tree }, { } }; -static int mt8189_apmixedsys_probe(struct udevice *dev) -{ - return mtk_common_clk_init(dev, &mt8189_apmixedsys_clk_tree); -} - -static int mt8189_topckgen_probe(struct udevice *dev) -{ - return mtk_common_clk_init(dev, &mt8189_topckgen_clk_tree); -} - -static int mt8189_infrasys_probe(struct udevice *dev) -{ - return mtk_common_clk_init(dev, &mt8189_vlpckgen_clk_tree); -} - -static int mt8189_clk_gate_probe(struct udevice *dev) -{ - struct mt8189_gate_clk_data *data; - - data = (void *)dev_get_driver_data(dev); - - return mtk_common_clk_gate_init(dev, &mt8189_clk_tree, - data->gates, data->num_gates, - data->gates[0].id); -} - U_BOOT_DRIVER(mt8189_clk_apmixedsys) = { .name = "mt8189-apmixedsys", .id = UCLASS_CLK, .of_match = mt8189_apmixed, - .bind = mtk_common_clk_parent_bind, - .probe = mt8189_apmixedsys_probe, + .probe = mtk_clk_probe, .priv_auto = sizeof(struct mtk_clk_priv), .ops = &mtk_clk_apmixedsys_ops, .flags = DM_FLAG_PRE_RELOC, @@ -2060,8 +2036,7 @@ U_BOOT_DRIVER(mt8189_clk_topckgen) = { .name = "mt8189-topckgen", .id = UCLASS_CLK, .of_match = mt8189_topckgen_compat, - .bind = mtk_common_clk_parent_bind, - .probe = mt8189_topckgen_probe, + .probe = mtk_clk_probe, .priv_auto = sizeof(struct mtk_clk_priv), .ops = &mtk_clk_topckgen_ops, .flags = DM_FLAG_PRE_RELOC, @@ -2071,8 +2046,7 @@ U_BOOT_DRIVER(mt8189_clk_vlpckgen) = { .name = "mt8189-vlpckgen", .id = UCLASS_CLK, .of_match = mt8189_vlpckgen, - .bind = mtk_common_clk_parent_bind, - .probe = mt8189_infrasys_probe, + .probe = mtk_clk_probe, .priv_auto = sizeof(struct mtk_clk_priv), .ops = &mtk_clk_infrasys_ops, .flags = DM_FLAG_PRE_RELOC, @@ -2082,8 +2056,8 @@ U_BOOT_DRIVER(mt8189_clk_gate) = { .name = "mt8189-gate-clk", .id = UCLASS_CLK, .of_match = of_match_mt8189_clk_gate, - .probe = mt8189_clk_gate_probe, - .priv_auto = sizeof(struct mtk_cg_priv), - .ops = &mtk_clk_gate_ops, + .probe = mtk_clk_probe, + .priv_auto = sizeof(struct mtk_clk_priv), + .ops = &mtk_clk_topckgen_ops, .flags = DM_FLAG_PRE_RELOC, }; diff --git a/drivers/clk/mediatek/clk-mt8195.c b/drivers/clk/mediatek/clk-mt8195.c index c12463cc616..de40821100e 100644 --- a/drivers/clk/mediatek/clk-mt8195.c +++ b/drivers/clk/mediatek/clk-mt8195.c @@ -1599,37 +1599,31 @@ static const struct mtk_gate infra_ao_clks[] = { static const struct mtk_clk_tree mt8195_infracfg_ao_clk_tree = { .ext_clk_rates = ext_clock_rates, .num_ext_clks = ARRAY_SIZE(ext_clock_rates), + .gates = infra_ao_clks, + .num_gates = ARRAY_SIZE(infra_ao_clks), }; -static int mt8195_apmixedsys_probe(struct udevice *dev) -{ - return mtk_common_clk_init(dev, &mt8195_apmixedsys_clk_tree); -} - -static int mt8195_topckgen_probe(struct udevice *dev) -{ - return mtk_common_clk_init(dev, &mt8195_topckgen_clk_tree); -} - -static int mt8195_infra_ao_probe(struct udevice *dev) -{ - return mtk_common_clk_gate_init(dev, &mt8195_infracfg_ao_clk_tree, - infra_ao_clks, - ARRAY_SIZE(infra_ao_clks), 0); -} - static const struct udevice_id mt8195_apmixed[] = { - { .compatible = "mediatek,mt8195-apmixedsys", }, + { + .compatible = "mediatek,mt8195-apmixedsys", + .data = (ulong)&mt8195_apmixedsys_clk_tree, + }, { } }; static const struct udevice_id mt8195_topckgen_compat[] = { - { .compatible = "mediatek,mt8195-topckgen", }, + { + .compatible = "mediatek,mt8195-topckgen", + .data = (ulong)&mt8195_topckgen_clk_tree, + }, { } }; static const struct udevice_id of_match_clk_mt8195_infra_ao[] = { - { .compatible = "mediatek,mt8195-infracfg_ao", }, + { + .compatible = "mediatek,mt8195-infracfg_ao", + .data = (ulong)&mt8195_infracfg_ao_clk_tree, + }, { } }; @@ -1637,8 +1631,7 @@ U_BOOT_DRIVER(mt8195_clk_apmixedsys) = { .name = "mt8195-apmixedsys", .id = UCLASS_CLK, .of_match = mt8195_apmixed, - .bind = mtk_common_clk_parent_bind, - .probe = mt8195_apmixedsys_probe, + .probe = mtk_clk_probe, .priv_auto = sizeof(struct mtk_clk_priv), .ops = &mtk_clk_apmixedsys_ops, .flags = DM_FLAG_PRE_RELOC, @@ -1648,8 +1641,7 @@ U_BOOT_DRIVER(mt8195_clk_topckgen) = { .name = "mt8195-topckgen", .id = UCLASS_CLK, .of_match = mt8195_topckgen_compat, - .bind = mtk_common_clk_parent_bind, - .probe = mt8195_topckgen_probe, + .probe = mtk_clk_probe, .priv_auto = sizeof(struct mtk_clk_priv), .ops = &mtk_clk_topckgen_ops, .flags = DM_FLAG_PRE_RELOC, @@ -1659,8 +1651,8 @@ U_BOOT_DRIVER(mt8195_clk_infra_ao) = { .name = "mt8195-infra_ao", .id = UCLASS_CLK, .of_match = of_match_clk_mt8195_infra_ao, - .probe = mt8195_infra_ao_probe, - .priv_auto = sizeof(struct mtk_cg_priv), - .ops = &mtk_clk_gate_ops, + .probe = mtk_clk_probe, + .priv_auto = sizeof(struct mtk_clk_priv), + .ops = &mtk_clk_topckgen_ops, .flags = DM_FLAG_PRE_RELOC, }; diff --git a/drivers/clk/mediatek/clk-mt8365.c b/drivers/clk/mediatek/clk-mt8365.c index bb00d6154e1..3fa030d7218 100644 --- a/drivers/clk/mediatek/clk-mt8365.c +++ b/drivers/clk/mediatek/clk-mt8365.c @@ -757,36 +757,31 @@ static const struct mtk_gate ifr_clks[] = { static const struct mtk_clk_tree mt8365_infracfg_tree = { .ext_clk_rates = ext_clock_rates, .num_ext_clks = ARRAY_SIZE(ext_clock_rates), + .gates = ifr_clks, + .num_gates = ARRAY_SIZE(ifr_clks), }; -static int mt8365_apmixedsys_probe(struct udevice *dev) -{ - return mtk_common_clk_init(dev, &mt8365_apmixed_tree); -} - -static int mt8365_topckgen_probe(struct udevice *dev) -{ - return mtk_common_clk_init(dev, &mt8365_topckgen_tree); -} - -static int mt8365_infracfg_probe(struct udevice *dev) -{ - return mtk_common_clk_gate_init(dev, &mt8365_infracfg_tree, ifr_clks, - ARRAY_SIZE(ifr_clks), 0); -} - static const struct udevice_id mt8365_apmixed_compat[] = { - { .compatible = "mediatek,mt8365-apmixedsys", }, + { + .compatible = "mediatek,mt8365-apmixedsys", + .data = (ulong)&mt8365_apmixed_tree, + }, { } }; static const struct udevice_id mt8365_topckgen_compat[] = { - { .compatible = "mediatek,mt8365-topckgen", }, + { + .compatible = "mediatek,mt8365-topckgen", + .data = (ulong)&mt8365_topckgen_tree, + }, { } }; static const struct udevice_id mt8365_infracfg_compat[] = { - { .compatible = "mediatek,mt8365-infracfg", }, + { + .compatible = "mediatek,mt8365-infracfg", + .data = (ulong)&mt8365_infracfg_tree, + }, { } }; @@ -794,8 +789,7 @@ U_BOOT_DRIVER(mt8365_clk_apmixedsys) = { .name = "mt8365-apmixedsys", .id = UCLASS_CLK, .of_match = mt8365_apmixed_compat, - .bind = mtk_common_clk_parent_bind, - .probe = mt8365_apmixedsys_probe, + .probe = mtk_clk_probe, .priv_auto = sizeof(struct mtk_clk_priv), .ops = &mtk_clk_apmixedsys_ops, .flags = DM_FLAG_PRE_RELOC, @@ -805,8 +799,7 @@ U_BOOT_DRIVER(mt8365_clk_topckgen) = { .name = "mt8365-topckgen", .id = UCLASS_CLK, .of_match = mt8365_topckgen_compat, - .bind = mtk_common_clk_parent_bind, - .probe = mt8365_topckgen_probe, + .probe = mtk_clk_probe, .priv_auto = sizeof(struct mtk_clk_priv), .ops = &mtk_clk_topckgen_ops, .flags = DM_FLAG_PRE_RELOC, @@ -816,8 +809,8 @@ U_BOOT_DRIVER(mt8365_clk_infracfg) = { .name = "mt8365-infracfg", .id = UCLASS_CLK, .of_match = mt8365_infracfg_compat, - .probe = mt8365_infracfg_probe, - .priv_auto = sizeof(struct mtk_cg_priv), - .ops = &mtk_clk_gate_ops, + .probe = mtk_clk_probe, + .priv_auto = sizeof(struct mtk_clk_priv), + .ops = &mtk_clk_topckgen_ops, .flags = DM_FLAG_PRE_RELOC, }; diff --git a/drivers/clk/mediatek/clk-mt8512.c b/drivers/clk/mediatek/clk-mt8512.c index 88c55e5ac6c..a0beae8fa5f 100644 --- a/drivers/clk/mediatek/clk-mt8512.c +++ b/drivers/clk/mediatek/clk-mt8512.c @@ -815,50 +815,45 @@ static const struct mtk_clk_tree mt8512_topckgen_clk_tree = { .type = MTK_CLK_TREE_TOPCKGEN, }; -static const struct mtk_clk_tree mt8512_clk_tree = { +static const struct mtk_clk_tree mt8512_topckgen_cg_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 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_topckgen_cg_probe(struct udevice *dev) -{ - return mtk_common_clk_gate_init(dev, &mt8512_clk_tree, top_clks, - ARRAY_SIZE(top_clks), 0); -} - -static int mt8512_infracfg_probe(struct udevice *dev) -{ - return mtk_common_clk_gate_init(dev, &mt8512_clk_tree, infra_clks, - ARRAY_SIZE(infra_clks), 0); -} +static const struct mtk_clk_tree mt8512_infracfg_tree = { + .ext_clk_rates = ext_clock_rates, + .num_ext_clks = ARRAY_SIZE(ext_clock_rates), + .gates = infra_clks, + .num_gates = ARRAY_SIZE(infra_clks), +}; 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", }, - { } -}; - -static const struct udevice_id mt8512_topckgen_cg_compat[] = { - { .compatible = "mediatek,mt8512-topckgen-cg", }, + { + .compatible = "mediatek,mt8512-topckgen", + .data = (ulong)&mt8512_topckgen_clk_tree, + }, { } }; -static const struct udevice_id mt8512_infracfg_compat[] = { - { .compatible = "mediatek,mt8512-infracfg", }, +static const struct udevice_id of_match_mt8512_clk_gate[] = { + { + .compatible = "mediatek,mt8512-topckgen-cg", + .data = (ulong)&mt8512_topckgen_cg_tree, + }, + { + .compatible = "mediatek,mt8512-infracfg", + .data = (ulong)&mt8512_infracfg_tree, + }, { } }; @@ -866,8 +861,7 @@ U_BOOT_DRIVER(mt8512_clk_apmixedsys) = { .name = "mt8512-apmixedsys", .id = UCLASS_CLK, .of_match = mt8512_apmixed_compat, - .bind = mtk_common_clk_parent_bind, - .probe = mt8512_apmixedsys_probe, + .probe = mtk_clk_probe, .priv_auto = sizeof(struct mtk_clk_priv), .ops = &mtk_clk_apmixedsys_ops, .flags = DM_FLAG_PRE_RELOC, @@ -877,29 +871,18 @@ U_BOOT_DRIVER(mt8512_clk_topckgen) = { .name = "mt8512-topckgen", .id = UCLASS_CLK, .of_match = mt8512_topckgen_compat, - .bind = mtk_common_clk_parent_bind, - .probe = mt8512_topckgen_probe, + .probe = mtk_clk_probe, .priv_auto = sizeof(struct mtk_clk_priv), .ops = &mtk_clk_topckgen_ops, .flags = DM_FLAG_PRE_RELOC, }; -U_BOOT_DRIVER(mt8512_clk_topckgen_cg) = { - .name = "mt8512-topckgen-cg", +U_BOOT_DRIVER(mt8512_clk_gate) = { + .name = "mt8512-clk-gate", .id = UCLASS_CLK, - .of_match = mt8512_topckgen_cg_compat, - .probe = mt8512_topckgen_cg_probe, - .priv_auto = sizeof(struct mtk_cg_priv), - .ops = &mtk_clk_gate_ops, - .flags = DM_FLAG_PRE_RELOC, -}; - -U_BOOT_DRIVER(mt8512_clk_infracfg) = { - .name = "mt8512-infracfg", - .id = UCLASS_CLK, - .of_match = mt8512_infracfg_compat, - .probe = mt8512_infracfg_probe, - .priv_auto = sizeof(struct mtk_cg_priv), - .ops = &mtk_clk_gate_ops, + .of_match = of_match_mt8512_clk_gate, + .probe = mtk_clk_probe, + .priv_auto = sizeof(struct mtk_clk_priv), + .ops = &mtk_clk_topckgen_ops, .flags = DM_FLAG_PRE_RELOC, }; diff --git a/drivers/clk/mediatek/clk-mt8516.c b/drivers/clk/mediatek/clk-mt8516.c index 9c510005b42..ea00b8dbca1 100644 --- a/drivers/clk/mediatek/clk-mt8516.c +++ b/drivers/clk/mediatek/clk-mt8516.c @@ -770,36 +770,31 @@ static const struct mtk_clk_tree mt8516_topckgen_clk_tree = { static const struct mtk_clk_tree mt8516_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 mt8516_apmixedsys_probe(struct udevice *dev) -{ - return mtk_common_clk_init(dev, &mt8516_apmixed_clk_tree); -} - -static int mt8516_topckgen_probe(struct udevice *dev) -{ - return mtk_common_clk_init(dev, &mt8516_topckgen_clk_tree); -} - -static int mt8516_topckgen_cg_probe(struct udevice *dev) -{ - return mtk_common_clk_gate_init(dev, &mt8516_clk_tree, top_clks, - ARRAY_SIZE(top_clks), 0); -} - static const struct udevice_id mt8516_apmixed_compat[] = { - { .compatible = "mediatek,mt8516-apmixedsys", }, + { + .compatible = "mediatek,mt8516-apmixedsys", + .data = (ulong)&mt8516_apmixed_clk_tree, + }, { } }; static const struct udevice_id mt8516_topckgen_compat[] = { - { .compatible = "mediatek,mt8516-topckgen", }, + { + .compatible = "mediatek,mt8516-topckgen", + .data = (ulong)&mt8516_topckgen_clk_tree, + }, { } }; static const struct udevice_id mt8516_topckgen_cg_compat[] = { - { .compatible = "mediatek,mt8516-topckgen-cg", }, + { + .compatible = "mediatek,mt8516-topckgen-cg", + .data = (ulong)&mt8516_clk_tree, + }, { } }; @@ -807,8 +802,7 @@ U_BOOT_DRIVER(mt8516_clk_apmixedsys) = { .name = "mt8516-apmixedsys", .id = UCLASS_CLK, .of_match = mt8516_apmixed_compat, - .bind = mtk_common_clk_parent_bind, - .probe = mt8516_apmixedsys_probe, + .probe = mtk_clk_probe, .priv_auto = sizeof(struct mtk_clk_priv), .ops = &mtk_clk_apmixedsys_ops, .flags = DM_FLAG_PRE_RELOC, @@ -818,8 +812,7 @@ U_BOOT_DRIVER(mt8516_clk_topckgen) = { .name = "mt8516-topckgen", .id = UCLASS_CLK, .of_match = mt8516_topckgen_compat, - .bind = mtk_common_clk_parent_bind, - .probe = mt8516_topckgen_probe, + .probe = mtk_clk_probe, .priv_auto = sizeof(struct mtk_clk_priv), .ops = &mtk_clk_topckgen_ops, .flags = DM_FLAG_PRE_RELOC, @@ -829,8 +822,8 @@ U_BOOT_DRIVER(mt8516_clk_topckgen_cg) = { .name = "mt8516-topckgen-cg", .id = UCLASS_CLK, .of_match = mt8516_topckgen_cg_compat, - .probe = mt8516_topckgen_cg_probe, - .priv_auto = sizeof(struct mtk_cg_priv), - .ops = &mtk_clk_gate_ops, + .probe = mtk_clk_probe, + .priv_auto = sizeof(struct mtk_clk_priv), + .ops = &mtk_clk_topckgen_ops, .flags = DM_FLAG_PRE_RELOC, }; diff --git a/drivers/clk/mediatek/clk-mt8518.c b/drivers/clk/mediatek/clk-mt8518.c index 1033ecae187..4fef36f458a 100644 --- a/drivers/clk/mediatek/clk-mt8518.c +++ b/drivers/clk/mediatek/clk-mt8518.c @@ -1526,36 +1526,31 @@ 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) -{ - return mtk_common_clk_init(dev, &mt8518_apmixed_clk_tree); -} - -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) -{ - return mtk_common_clk_gate_init(dev, &mt8518_clk_tree, top_clks, - ARRAY_SIZE(top_clks), 0); -} - static const struct udevice_id mt8518_apmixed_compat[] = { - { .compatible = "mediatek,mt8518-apmixedsys", }, + { + .compatible = "mediatek,mt8518-apmixedsys", + .data = (ulong)&mt8518_apmixed_clk_tree, + }, { } }; static const struct udevice_id mt8518_topckgen_compat[] = { - { .compatible = "mediatek,mt8518-topckgen", }, + { + .compatible = "mediatek,mt8518-topckgen", + .data = (ulong)&mt8518_topckgen_clk_tree, + }, { } }; static const struct udevice_id mt8518_topckgen_cg_compat[] = { - { .compatible = "mediatek,mt8518-topckgen-cg", }, + { + .compatible = "mediatek,mt8518-topckgen-cg", + .data = (ulong)&mt8518_clk_tree, + }, { } }; @@ -1563,8 +1558,7 @@ U_BOOT_DRIVER(mt8518_clk_apmixedsys) = { .name = "mt8518-apmixedsys", .id = UCLASS_CLK, .of_match = mt8518_apmixed_compat, - .bind = mtk_common_clk_parent_bind, - .probe = mt8518_apmixedsys_probe, + .probe = mtk_clk_probe, .priv_auto = sizeof(struct mtk_clk_priv), .ops = &mtk_clk_apmixedsys_ops, .flags = DM_FLAG_PRE_RELOC, @@ -1574,8 +1568,7 @@ U_BOOT_DRIVER(mt8518_clk_topckgen) = { .name = "mt8518-topckgen", .id = UCLASS_CLK, .of_match = mt8518_topckgen_compat, - .bind = mtk_common_clk_parent_bind, - .probe = mt8518_topckgen_probe, + .probe = mtk_clk_probe, .priv_auto = sizeof(struct mtk_clk_priv), .ops = &mtk_clk_topckgen_ops, .flags = DM_FLAG_PRE_RELOC, @@ -1585,8 +1578,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 = mtk_clk_probe, + .priv_auto = sizeof(struct mtk_clk_priv), + .ops = &mtk_clk_topckgen_ops, .flags = DM_FLAG_PRE_RELOC, }; diff --git a/drivers/clk/mediatek/clk-mtk.c b/drivers/clk/mediatek/clk-mtk.c index 61d718f162d..13c248c93a6 100644 --- a/drivers/clk/mediatek/clk-mtk.c +++ b/drivers/clk/mediatek/clk-mtk.c @@ -9,6 +9,7 @@ #include <clk-uclass.h> #include <div64.h> #include <dm.h> +#include <dm/device-internal.h> #include <asm/io.h> #include <linux/bitops.h> #include <linux/delay.h> @@ -60,6 +61,40 @@ static struct udevice *mtk_clk_tree_get_provider(enum mtk_clk_tree_type type) if (!mtk_clk_tree_type_is_provider(type)) return NULL; + if (!mtk_clk_providers[type]) { + struct udevice *dev; + struct uclass *uc; + int ret; + + /* Lazily probe and register the requested provider. */ + ret = uclass_get(UCLASS_CLK, &uc); + if (ret) + return ERR_PTR(ret); + + uclass_foreach_dev(dev, uc) { + const struct mtk_clk_tree *tree; + const void *ops; + + ops = dev_get_driver_ops(dev); + if (ops != &mtk_clk_apmixedsys_ops && + ops != &mtk_clk_fixed_pll_ops && + ops != &mtk_clk_topckgen_ops && + ops != &mtk_clk_infrasys_ops) + continue; + + tree = (const void *)dev_get_driver_data(dev); + if (tree->type != type) + continue; + + /* Probe will add it to mtk_clk_providers[type]. */ + ret = device_probe(dev); + if (ret) + return ERR_PTR(ret); + + break; + } + } + return mtk_clk_providers[type] ?: ERR_PTR(-ENOENT); } @@ -1039,90 +1074,6 @@ static void mtk_infrasys_dump(struct udevice *dev) } #endif -/* CG functions */ - -static const int mtk_clk_gate_of_xlate(struct clk *clk, - struct ofnode_phandle_args *args) -{ - struct mtk_cg_priv *priv = dev_get_priv(clk->dev); - const struct mtk_clk_tree *tree = priv->tree; - int ret; - - ret = mtk_common_clk_of_xlate(clk, args, tree); - if (ret) - return ret; - - if (clk->id >= priv->gates_offs && - clk->id < priv->gates_offs + priv->num_gates) - return 0; - - return -ENOENT; -} - -static int mtk_clk_gate_enable(struct clk *clk) -{ - struct mtk_cg_priv *priv = dev_get_priv(clk->dev); - const struct mtk_gate *gate; - - if (clk->id < priv->gates_offs) - return -EINVAL; - - gate = &priv->gates[clk->id - priv->gates_offs]; - return mtk_gate_enable(priv->base, gate); -} - -static int mtk_clk_gate_disable(struct clk *clk) -{ - struct mtk_cg_priv *priv = dev_get_priv(clk->dev); - const struct mtk_gate *gate; - - if (clk->id < priv->gates_offs) - return -EINVAL; - - gate = &priv->gates[clk->id - priv->gates_offs]; - return mtk_gate_disable(priv->base, gate); -} - -static ulong mtk_clk_gate_get_rate(struct clk *clk) -{ - struct mtk_cg_priv *priv = dev_get_priv(clk->dev); - const struct mtk_gate *gate; - struct udevice *pdev; - - if (clk->id < priv->gates_offs) - return -EINVAL; - - gate = &priv->gates[clk->id - priv->gates_offs]; - - if (gate->flags & CLK_PARENT_EXT) - return mtk_ext_clock_get_rate(priv->tree, gate->parent); - - pdev = mtk_clk_parent_get_provider(gate->flags); - if (IS_ERR(pdev)) - return -ENOENT; - - return mtk_clk_find_parent_rate(clk, gate->parent, pdev); -} - -#if CONFIG_IS_ENABLED(CMD_CLK) -static void mtk_clk_gate_dump(struct udevice *dev) -{ - struct mtk_cg_priv *priv = dev_get_priv(dev); - const struct mtk_clk_tree *tree = priv->tree; - u32 i; - - for (i = 0; i < priv->num_gates; i++) { - const struct mtk_gate *gate = &priv->gates[i]; - - printf("[GATE%u] DT: %u", i, gate->id); - mtk_clk_print_mapped_id(gate->id, i + priv->gates_offs, tree->id_offs_map); - mtk_clk_print_rate(dev, i + priv->gates_offs); - mtk_clk_print_single_parent(gate->parent, gate->flags); - printf("\n"); - } -} -#endif - const struct clk_ops mtk_clk_apmixedsys_ops = { .of_xlate = mtk_apmixedsys_of_xlate, .enable = mtk_apmixedsys_enable, @@ -1166,30 +1117,10 @@ const struct clk_ops mtk_clk_infrasys_ops = { #endif }; -const struct clk_ops mtk_clk_gate_ops = { - .of_xlate = mtk_clk_gate_of_xlate, - .enable = mtk_clk_gate_enable, - .disable = mtk_clk_gate_disable, - .get_rate = mtk_clk_gate_get_rate, -#if CONFIG_IS_ENABLED(CMD_CLK) - .dump = mtk_clk_gate_dump, -#endif -}; - -int mtk_common_clk_parent_bind(struct udevice *dev) -{ - /* - * Clock trees that provide parent clocks need to be probed right away - * so that any clock depending on them will work correctly. - */ - dev_or_flags(dev, DM_FLAG_PROBE_AFTER_BIND); - - return 0; -} - -int mtk_common_clk_init(struct udevice *dev, const struct mtk_clk_tree *tree) +int mtk_clk_probe(struct udevice *dev) { struct mtk_clk_priv *priv = dev_get_priv(dev); + const struct mtk_clk_tree *tree = (void *)dev_get_driver_data(dev); priv->base = dev_read_addr_ptr(dev); if (!priv->base) @@ -1199,22 +1130,3 @@ int mtk_common_clk_init(struct udevice *dev, const struct mtk_clk_tree *tree) return mtk_clk_tree_register_provider(dev, tree); } - -int mtk_common_clk_gate_init(struct udevice *dev, - const struct mtk_clk_tree *tree, - const struct mtk_gate *gates, int num_gates, - int gates_offs) -{ - struct mtk_cg_priv *priv = dev_get_priv(dev); - - priv->base = dev_read_addr_ptr(dev); - if (!priv->base) - return -ENOENT; - - priv->tree = tree; - priv->gates = gates; - priv->num_gates = num_gates; - priv->gates_offs = gates_offs; - - return 0; -} diff --git a/drivers/clk/mediatek/clk-mtk.h b/drivers/clk/mediatek/clk-mtk.h index 437797dd0df..9244542a2a5 100644 --- a/drivers/clk/mediatek/clk-mtk.h +++ b/drivers/clk/mediatek/clk-mtk.h @@ -270,12 +270,7 @@ struct mtk_clk_tree { const int num_muxes; const int num_gates; u32 flags; - /* - * Set this if this tree provides a specific type for parent lookup. - * Devices that set this should also include mtk_common_clk_parent_bind() - * in the driver bind function to ensure that it will be registered as - * a provider. - */ + /* Set this if this tree provides a specific type for parent lookup. */ enum mtk_clk_tree_type type; }; @@ -284,26 +279,11 @@ struct mtk_clk_priv { const struct mtk_clk_tree *tree; }; -struct mtk_cg_priv { - void __iomem *base; - const struct mtk_clk_tree *tree; - const struct mtk_gate *gates; - int num_gates; - int gates_offs; -}; - extern const struct clk_ops mtk_clk_apmixedsys_ops; extern const struct clk_ops mtk_clk_fixed_pll_ops; extern const struct clk_ops mtk_clk_topckgen_ops; extern const struct clk_ops mtk_clk_infrasys_ops; -extern const struct clk_ops mtk_clk_gate_ops; -int mtk_common_clk_parent_bind(struct udevice *dev); -int mtk_common_clk_init(struct udevice *dev, - const struct mtk_clk_tree *tree); -int mtk_common_clk_gate_init(struct udevice *dev, - const struct mtk_clk_tree *tree, - const struct mtk_gate *gates, int num_gates, - int gates_offs); +int mtk_clk_probe(struct udevice *dev); #endif /* __DRV_CLK_MTK_H */ |
