Lines Matching +full:omap5 +full:- +full:ipu

1 // SPDX-License-Identifier: GPL-2.0
5 * Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/
6 * Tero Kristo <t-kristo@ti.com>
20 #include <linux/reset-controller.h>
23 #include <linux/platform_data/ti-prm.h>
34 unsigned long statechange:1; /* Optional low-power state change */
140 { .rst = -1 },
146 { .rst = -1 },
153 { .rst = -1 },
248 .rstctrl = 0x210, .rstst = 0x214, .clkdm_name = "ipu",
303 .name = "ipu", .base = 0x4ae06500,
395 { .rst = -1 },
400 { .rst = -1 },
443 { .rst = -1 },
449 { .rst = -1 },
495 { .compatible = "ti,omap4-prm-inst", .data = omap4_prm_data },
496 { .compatible = "ti,omap5-prm-inst", .data = omap5_prm_data },
497 { .compatible = "ti,dra7-prm-inst", .data = dra7_prm_data },
498 { .compatible = "ti,am3-prm-inst", .data = am3_prm_data },
499 { .compatible = "ti,am4-prm-inst", .data = am4_prm_data },
507 dev_dbg(prmd->dev, "%s %s: %08x/%08x\n", in omap_prm_domain_show_state()
508 prmd->pd.name, desc, in omap_prm_domain_show_state()
509 readl_relaxed(prmd->prm->base + prmd->pwrstctrl), in omap_prm_domain_show_state()
510 readl_relaxed(prmd->prm->base + prmd->pwrstst)); in omap_prm_domain_show_state()
526 if (!prmd->cap) in omap_prm_domain_power_on()
531 if (prmd->pwrstctrl_saved) in omap_prm_domain_power_on()
532 v = prmd->pwrstctrl_saved; in omap_prm_domain_power_on()
534 v = readl_relaxed(prmd->prm->base + prmd->pwrstctrl); in omap_prm_domain_power_on()
536 if (prmd->prm->data->flags & OMAP_PRM_RET_WHEN_IDLE) in omap_prm_domain_power_on()
542 prmd->prm->base + prmd->pwrstctrl); in omap_prm_domain_power_on()
545 ret = readl_relaxed_poll_timeout(prmd->prm->base + prmd->pwrstst, in omap_prm_domain_power_on()
549 dev_err(prmd->dev, "%s: %s timed out\n", in omap_prm_domain_power_on()
550 prmd->pd.name, __func__); in omap_prm_domain_power_on()
560 return __ffs(prmd->cap->usable_modes); in omap_prm_domain_find_lowest()
570 if (!prmd->cap) in omap_prm_domain_power_off()
575 v = readl_relaxed(prmd->prm->base + prmd->pwrstctrl); in omap_prm_domain_power_off()
576 prmd->pwrstctrl_saved = v; in omap_prm_domain_power_off()
581 if (prmd->cap->statechange) in omap_prm_domain_power_off()
583 if (prmd->cap->logicretstate) in omap_prm_domain_power_off()
588 writel_relaxed(v, prmd->prm->base + prmd->pwrstctrl); in omap_prm_domain_power_off()
591 ret = readl_relaxed_poll_timeout(prmd->prm->base + prmd->pwrstst, in omap_prm_domain_power_off()
595 dev_warn(prmd->dev, "%s: %s timed out\n", in omap_prm_domain_power_off()
596 __func__, prmd->pd.name); in omap_prm_domain_power_off()
604 * Note that ti-sysc already manages the module clocks separately so
606 * for simple-pm-bus.
611 struct device_node *np = dev->of_node; in omap_prm_domain_attach_clock()
614 if (!of_device_is_compatible(np, "simple-pm-bus")) in omap_prm_domain_attach_clock()
630 prmd->uses_pm_clk = 1; in omap_prm_domain_attach_clock()
645 np = dev->of_node; in omap_prm_domain_attach_dev()
647 ret = of_parse_phandle_with_args(np, "power-domains", in omap_prm_domain_attach_dev()
648 "#power-domain-cells", 0, &pd_args); in omap_prm_domain_attach_dev()
653 dev_warn(dev, "%s: unusupported #power-domain-cells: %i\n", in omap_prm_domain_attach_dev()
654 prmd->pd.name, pd_args.args_count); in omap_prm_domain_attach_dev()
657 genpd_data->data = NULL; in omap_prm_domain_attach_dev()
673 if (prmd->uses_pm_clk) in omap_prm_domain_detach_dev()
676 genpd_data->data = NULL; in omap_prm_domain_detach_dev()
682 struct device_node *np = dev->of_node; in omap_prm_domain_init()
687 if (!of_find_property(dev->of_node, "#power-domain-cells", NULL)) in omap_prm_domain_init()
690 of_node_put(dev->of_node); in omap_prm_domain_init()
694 return -ENOMEM; in omap_prm_domain_init()
696 data = prm->data; in omap_prm_domain_init()
698 data->name); in omap_prm_domain_init()
700 prmd->dev = dev; in omap_prm_domain_init()
701 prmd->prm = prm; in omap_prm_domain_init()
702 prmd->cap = prmd->prm->data->dmap; in omap_prm_domain_init()
703 prmd->pwrstctrl = prmd->prm->data->pwrstctrl; in omap_prm_domain_init()
704 prmd->pwrstst = prmd->prm->data->pwrstst; in omap_prm_domain_init()
706 prmd->pd.name = name; in omap_prm_domain_init()
707 prmd->pd.power_on = omap_prm_domain_power_on; in omap_prm_domain_init()
708 prmd->pd.power_off = omap_prm_domain_power_off; in omap_prm_domain_init()
709 prmd->pd.attach_dev = omap_prm_domain_attach_dev; in omap_prm_domain_init()
710 prmd->pd.detach_dev = omap_prm_domain_detach_dev; in omap_prm_domain_init()
711 prmd->pd.flags = GENPD_FLAG_PM_CLK; in omap_prm_domain_init()
713 pm_genpd_init(&prmd->pd, NULL, true); in omap_prm_domain_init()
714 error = of_genpd_add_provider_simple(np, &prmd->pd); in omap_prm_domain_init()
716 pm_genpd_remove(&prmd->pd); in omap_prm_domain_init()
718 prm->prmd = prmd; in omap_prm_domain_init()
725 if (reset->mask & BIT(id)) in _is_valid_reset()
734 const struct omap_rst_map *map = reset->prm->data->rstmap; in omap_reset_get_st_bit()
736 while (map->rst >= 0) { in omap_reset_get_st_bit()
737 if (map->rst == id) in omap_reset_get_st_bit()
738 return map->st; in omap_reset_get_st_bit()
752 bool has_rstst = reset->prm->data->rstst || in omap_reset_status()
753 (reset->prm->data->flags & OMAP_PRM_HAS_RSTST); in omap_reset_status()
757 return -ENOTSUPP; in omap_reset_status()
760 v = readl_relaxed(reset->prm->base + reset->prm->data->rstctrl); in omap_reset_status()
768 v = readl_relaxed(reset->prm->base + reset->prm->data->rstst); in omap_reset_status()
783 spin_lock_irqsave(&reset->lock, flags); in omap_reset_assert()
784 v = readl_relaxed(reset->prm->base + reset->prm->data->rstctrl); in omap_reset_assert()
786 writel_relaxed(v, reset->prm->base + reset->prm->data->rstctrl); in omap_reset_assert()
787 spin_unlock_irqrestore(&reset->lock, flags); in omap_reset_assert()
800 struct ti_prm_platform_data *pdata = dev_get_platdata(reset->dev); in omap_reset_deassert()
807 has_rstst = reset->prm->data->rstst || in omap_reset_deassert()
808 (reset->prm->data->flags & OMAP_PRM_HAS_RSTST); in omap_reset_deassert()
815 writel_relaxed(v, reset->prm->base + reset->prm->data->rstst); in omap_reset_deassert()
818 if (reset->clkdm) in omap_reset_deassert()
819 pdata->clkdm_deny_idle(reset->clkdm); in omap_reset_deassert()
821 /* de-assert the reset control line */ in omap_reset_deassert()
822 spin_lock_irqsave(&reset->lock, flags); in omap_reset_deassert()
823 v = readl_relaxed(reset->prm->base + reset->prm->data->rstctrl); in omap_reset_deassert()
825 writel_relaxed(v, reset->prm->base + reset->prm->data->rstctrl); in omap_reset_deassert()
826 spin_unlock_irqrestore(&reset->lock, flags); in omap_reset_deassert()
829 ret = readl_relaxed_poll_timeout_atomic(reset->prm->base + in omap_reset_deassert()
830 reset->prm->data->rstctrl, in omap_reset_deassert()
835 reset->prm->data->name, id); in omap_reset_deassert()
839 ret = readl_relaxed_poll_timeout_atomic(reset->prm->base + in omap_reset_deassert()
840 reset->prm->data->rstst, in omap_reset_deassert()
845 reset->prm->data->name, id); in omap_reset_deassert()
848 if (reset->clkdm) in omap_reset_deassert()
849 pdata->clkdm_allow_idle(reset->clkdm); in omap_reset_deassert()
865 if (!_is_valid_reset(reset, reset_spec->args[0])) in omap_prm_reset_xlate()
866 return -EINVAL; in omap_prm_reset_xlate()
868 return reset_spec->args[0]; in omap_prm_reset_xlate()
876 struct ti_prm_platform_data *pdata = dev_get_platdata(&pdev->dev); in omap_prm_reset_init()
881 * Check if we have controllable resets. If either rstctrl is non-zero in omap_prm_reset_init()
885 if (!prm->data->rstctrl && !(prm->data->flags & OMAP_PRM_HAS_RSTCTRL)) in omap_prm_reset_init()
889 if (!pdata || !pdata->clkdm_lookup || !pdata->clkdm_deny_idle || in omap_prm_reset_init()
890 !pdata->clkdm_allow_idle) in omap_prm_reset_init()
891 return -EINVAL; in omap_prm_reset_init()
893 map = prm->data->rstmap; in omap_prm_reset_init()
895 return -EINVAL; in omap_prm_reset_init()
897 reset = devm_kzalloc(&pdev->dev, sizeof(*reset), GFP_KERNEL); in omap_prm_reset_init()
899 return -ENOMEM; in omap_prm_reset_init()
901 reset->rcdev.owner = THIS_MODULE; in omap_prm_reset_init()
902 reset->rcdev.ops = &omap_reset_ops; in omap_prm_reset_init()
903 reset->rcdev.of_node = pdev->dev.of_node; in omap_prm_reset_init()
904 reset->rcdev.nr_resets = OMAP_MAX_RESETS; in omap_prm_reset_init()
905 reset->rcdev.of_xlate = omap_prm_reset_xlate; in omap_prm_reset_init()
906 reset->rcdev.of_reset_n_cells = 1; in omap_prm_reset_init()
907 reset->dev = &pdev->dev; in omap_prm_reset_init()
908 spin_lock_init(&reset->lock); in omap_prm_reset_init()
910 reset->prm = prm; in omap_prm_reset_init()
912 sprintf(buf, "%s_clkdm", prm->data->clkdm_name ? prm->data->clkdm_name : in omap_prm_reset_init()
913 prm->data->name); in omap_prm_reset_init()
915 if (!(prm->data->flags & OMAP_PRM_HAS_NO_CLKDM)) { in omap_prm_reset_init()
916 reset->clkdm = pdata->clkdm_lookup(buf); in omap_prm_reset_init()
917 if (!reset->clkdm) in omap_prm_reset_init()
918 return -EINVAL; in omap_prm_reset_init()
921 while (map->rst >= 0) { in omap_prm_reset_init()
922 reset->mask |= BIT(map->rst); in omap_prm_reset_init()
927 if (prm->data->rstmap == rst_map_012) { in omap_prm_reset_init()
928 v = readl_relaxed(reset->prm->base + reset->prm->data->rstctrl); in omap_prm_reset_init()
929 if ((v & reset->mask) != reset->mask) { in omap_prm_reset_init()
930 dev_dbg(&pdev->dev, "Asserting all resets: %08x\n", v); in omap_prm_reset_init()
931 writel_relaxed(reset->mask, reset->prm->base + in omap_prm_reset_init()
932 reset->prm->data->rstctrl); in omap_prm_reset_init()
936 return devm_reset_controller_register(&pdev->dev, &reset->rcdev); in omap_prm_reset_init()
948 return -ENODEV; in omap_prm_probe()
950 data = of_device_get_match_data(&pdev->dev); in omap_prm_probe()
952 return -ENOTSUPP; in omap_prm_probe()
954 prm = devm_kzalloc(&pdev->dev, sizeof(*prm), GFP_KERNEL); in omap_prm_probe()
956 return -ENOMEM; in omap_prm_probe()
958 while (data->base != res->start) { in omap_prm_probe()
959 if (!data->base) in omap_prm_probe()
960 return -EINVAL; in omap_prm_probe()
964 prm->data = data; in omap_prm_probe()
966 prm->base = devm_ioremap_resource(&pdev->dev, res); in omap_prm_probe()
967 if (IS_ERR(prm->base)) in omap_prm_probe()
968 return PTR_ERR(prm->base); in omap_prm_probe()
970 ret = omap_prm_domain_init(&pdev->dev, prm); in omap_prm_probe()
981 of_genpd_del_provider(pdev->dev.of_node); in omap_prm_probe()
982 pm_genpd_remove(&prm->prmd->pd); in omap_prm_probe()