Lines Matching +full:mt7622 +full:- +full:eth

1 // SPDX-License-Identifier: GPL-2.0-only
16 #include <dt-bindings/power/mt2701-power.h>
17 #include <dt-bindings/power/mt2712-power.h>
18 #include <dt-bindings/power/mt6797-power.h>
19 #include <dt-bindings/power/mt7622-power.h>
20 #include <dt-bindings/power/mt7623a-power.h>
21 #include <dt-bindings/power/mt8173-power.h>
28 #define MTK_SCPD_CAPS(_scpd, _x) ((_scpd)->data->caps & (_x))
46 #define SPM_ETHSYS_PWR_CON 0x02e0 /* MT7622 */
47 #define SPM_HIF0_PWR_CON 0x02e4 /* MT7622 */
48 #define SPM_HIF1_PWR_CON 0x02e8 /* MT7622 */
49 #define SPM_WB_PWR_CON 0x02ec /* MT7622 */
76 #define PWR_STATUS_ETHSYS BIT(24) /* MT7622 */
77 #define PWR_STATUS_HIF0 BIT(25) /* MT7622 */
78 #define PWR_STATUS_HIF1 BIT(26) /* MT7622 */
79 #define PWR_STATUS_WB BIT(27) /* MT7622 */
112 * struct scp_domain_data - scp domain data for power on/off flow
120 * @caps: The flag for active wake-up action.
174 struct scp *scp = scpd->scp; in scpsys_domain_is_on()
176 u32 status = readl(scp->base + scp->ctrl_reg.pwr_sta_offs) & in scpsys_domain_is_on()
177 scpd->data->sta_mask; in scpsys_domain_is_on()
178 u32 status2 = readl(scp->base + scp->ctrl_reg.pwr_sta2nd_offs) & in scpsys_domain_is_on()
179 scpd->data->sta_mask; in scpsys_domain_is_on()
191 return -EINVAL; in scpsys_domain_is_on()
196 if (!scpd->supply) in scpsys_regulator_enable()
199 return regulator_enable(scpd->supply); in scpsys_regulator_enable()
204 if (!scpd->supply) in scpsys_regulator_disable()
207 return regulator_disable(scpd->supply); in scpsys_regulator_disable()
214 for (i = max_num - 1; i >= 0; i--) in scpsys_clk_disable()
236 u32 pdn_ack = scpd->data->sram_pdn_ack_bits; in scpsys_sram_enable()
240 val &= ~scpd->data->sram_pdn_bits; in scpsys_sram_enable()
266 u32 pdn_ack = scpd->data->sram_pdn_ack_bits; in scpsys_sram_disable()
270 val |= scpd->data->sram_pdn_bits; in scpsys_sram_disable()
281 struct scp *scp = scpd->scp; in scpsys_bus_protect_enable()
283 if (!scpd->data->bus_prot_mask) in scpsys_bus_protect_enable()
286 return mtk_infracfg_set_bus_protection(scp->infracfg, in scpsys_bus_protect_enable()
287 scpd->data->bus_prot_mask, in scpsys_bus_protect_enable()
288 scp->bus_prot_reg_update); in scpsys_bus_protect_enable()
293 struct scp *scp = scpd->scp; in scpsys_bus_protect_disable()
295 if (!scpd->data->bus_prot_mask) in scpsys_bus_protect_disable()
298 return mtk_infracfg_clear_bus_protection(scp->infracfg, in scpsys_bus_protect_disable()
299 scpd->data->bus_prot_mask, in scpsys_bus_protect_disable()
300 scp->bus_prot_reg_update); in scpsys_bus_protect_disable()
306 struct scp *scp = scpd->scp; in scpsys_power_on()
307 void __iomem *ctl_addr = scp->base + scpd->data->ctl_offs; in scpsys_power_on()
315 ret = scpsys_clk_enable(scpd->clk, MAX_CLKS); in scpsys_power_on()
352 scpsys_clk_disable(scpd->clk, MAX_CLKS); in scpsys_power_on()
356 dev_err(scp->dev, "Failed to power on domain %s\n", genpd->name); in scpsys_power_on()
364 struct scp *scp = scpd->scp; in scpsys_power_off()
365 void __iomem *ctl_addr = scp->base + scpd->data->ctl_offs; in scpsys_power_off()
400 scpsys_clk_disable(scpd->clk, MAX_CLKS); in scpsys_power_off()
409 dev_err(scp->dev, "Failed to power off domain %s\n", genpd->name); in scpsys_power_off()
419 clk[i] = devm_clk_get(&pdev->dev, clk_names[i]); in init_clks()
432 scp = devm_kzalloc(&pdev->dev, sizeof(*scp), GFP_KERNEL); in init_scp()
434 return ERR_PTR(-ENOMEM); in init_scp()
436 scp->ctrl_reg.pwr_sta_offs = scp_ctrl_reg->pwr_sta_offs; in init_scp()
437 scp->ctrl_reg.pwr_sta2nd_offs = scp_ctrl_reg->pwr_sta2nd_offs; in init_scp()
439 scp->bus_prot_reg_update = bus_prot_reg_update; in init_scp()
441 scp->dev = &pdev->dev; in init_scp()
443 scp->base = devm_platform_ioremap_resource(pdev, 0); in init_scp()
444 if (IS_ERR(scp->base)) in init_scp()
445 return ERR_CAST(scp->base); in init_scp()
447 scp->domains = devm_kcalloc(&pdev->dev, in init_scp()
448 num, sizeof(*scp->domains), GFP_KERNEL); in init_scp()
449 if (!scp->domains) in init_scp()
450 return ERR_PTR(-ENOMEM); in init_scp()
452 pd_data = &scp->pd_data; in init_scp()
454 pd_data->domains = devm_kcalloc(&pdev->dev, in init_scp()
455 num, sizeof(*pd_data->domains), GFP_KERNEL); in init_scp()
456 if (!pd_data->domains) in init_scp()
457 return ERR_PTR(-ENOMEM); in init_scp()
459 scp->infracfg = syscon_regmap_lookup_by_phandle(pdev->dev.of_node, in init_scp()
461 if (IS_ERR(scp->infracfg)) { in init_scp()
462 dev_err(&pdev->dev, "Cannot find infracfg controller: %ld\n", in init_scp()
463 PTR_ERR(scp->infracfg)); in init_scp()
464 return ERR_CAST(scp->infracfg); in init_scp()
468 struct scp_domain *scpd = &scp->domains[i]; in init_scp()
471 scpd->supply = devm_regulator_get_optional(&pdev->dev, data->name); in init_scp()
472 if (IS_ERR(scpd->supply)) { in init_scp()
473 if (PTR_ERR(scpd->supply) == -ENODEV) in init_scp()
474 scpd->supply = NULL; in init_scp()
476 return ERR_CAST(scpd->supply); in init_scp()
480 pd_data->num_domains = num; in init_scp()
485 struct scp_domain *scpd = &scp->domains[i]; in init_scp()
486 struct generic_pm_domain *genpd = &scpd->genpd; in init_scp()
489 pd_data->domains[i] = genpd; in init_scp()
490 scpd->scp = scp; in init_scp()
492 scpd->data = data; in init_scp()
494 for (j = 0; j < MAX_CLKS && data->clk_id[j]; j++) { in init_scp()
495 struct clk *c = clk[data->clk_id[j]]; in init_scp()
498 dev_err(&pdev->dev, "%s: clk unavailable\n", in init_scp()
499 data->name); in init_scp()
503 scpd->clk[j] = c; in init_scp()
506 genpd->name = data->name; in init_scp()
507 genpd->power_off = scpsys_power_off; in init_scp()
508 genpd->power_on = scpsys_power_on; in init_scp()
510 genpd->flags |= GENPD_FLAG_ACTIVE_WAKEUP; in init_scp()
523 struct scp_domain *scpd = &scp->domains[i]; in mtk_register_power_domains()
524 struct generic_pm_domain *genpd = &scpd->genpd; in mtk_register_power_domains()
533 on = !WARN_ON(genpd->power_on(genpd) < 0); in mtk_register_power_domains()
544 pd_data = &scp->pd_data; in mtk_register_power_domains()
546 ret = of_genpd_add_provider_onecell(pdev->dev.of_node, pd_data); in mtk_register_power_domains()
548 dev_err(&pdev->dev, "Failed to add OF provider: %d\n", ret); in mtk_register_power_domains()
610 .name = "eth",
826 * MT7622 power domain support
887 .name = "eth",
1084 .compatible = "mediatek,mt2701-scpsys",
1087 .compatible = "mediatek,mt2712-scpsys",
1090 .compatible = "mediatek,mt6797-scpsys",
1093 .compatible = "mediatek,mt7622-scpsys",
1096 .compatible = "mediatek,mt7623a-scpsys",
1099 .compatible = "mediatek,mt8173-scpsys",
1114 soc = of_device_get_match_data(&pdev->dev); in scpsys_probe()
1116 scp = init_scp(pdev, soc->domains, soc->num_domains, &soc->regs, in scpsys_probe()
1117 soc->bus_prot_reg_update); in scpsys_probe()
1121 mtk_register_power_domains(pdev, scp, soc->num_domains); in scpsys_probe()
1123 pd_data = &scp->pd_data; in scpsys_probe()
1125 for (i = 0, sd = soc->subdomains; i < soc->num_subdomains; i++, sd++) { in scpsys_probe()
1126 ret = pm_genpd_add_subdomain(pd_data->domains[sd->origin], in scpsys_probe()
1127 pd_data->domains[sd->subdomain]); in scpsys_probe()
1129 dev_err(&pdev->dev, "Failed to add subdomain: %d\n", in scpsys_probe()
1139 .name = "mtk-scpsys",