Lines Matching +full:pd +full:- +full:node
1 // SPDX-License-Identifier: GPL-2.0-only
5 * Copyright (C) 2015-2017 Texas Instruments Incorporated - http://www.ti.com/
6 * J Keerthy <j-keerthy@ti.com>
7 * Dave Gerlach <d-gerlach@ti.com>
17 #include <dt-bindings/soc/ti,sci_pm_domain.h>
40 * @pd: generic_pm_domain for use with the genpd framework
41 * @node: link for the genpd list
47 struct generic_pm_domain pd; member
48 struct list_head node; member
52 #define genpd_to_ti_sci_pd(gpd) container_of(gpd, struct ti_sci_pm_domain, pd)
60 struct ti_sci_pm_domain *pd = genpd_to_ti_sci_pd(domain); in ti_sci_pd_power_off() local
61 const struct ti_sci_handle *ti_sci = pd->parent->ti_sci; in ti_sci_pd_power_off()
63 return ti_sci->ops.dev_ops.put_device(ti_sci, pd->idx); in ti_sci_pd_power_off()
72 struct ti_sci_pm_domain *pd = genpd_to_ti_sci_pd(domain); in ti_sci_pd_power_on() local
73 const struct ti_sci_handle *ti_sci = pd->parent->ti_sci; in ti_sci_pd_power_on()
75 if (pd->exclusive) in ti_sci_pd_power_on()
76 return ti_sci->ops.dev_ops.get_device_exclusive(ti_sci, in ti_sci_pd_power_on()
77 pd->idx); in ti_sci_pd_power_on()
79 return ti_sci->ops.dev_ops.get_device(ti_sci, pd->idx); in ti_sci_pd_power_on()
92 unsigned int idx = genpdspec->args[0]; in ti_sci_pd_xlate()
94 if (genpdspec->args_count != 1 && genpdspec->args_count != 2) in ti_sci_pd_xlate()
95 return ERR_PTR(-EINVAL); in ti_sci_pd_xlate()
97 if (idx >= genpd_data->num_domains) { in ti_sci_pd_xlate()
99 return ERR_PTR(-EINVAL); in ti_sci_pd_xlate()
102 if (!genpd_data->domains[idx]) in ti_sci_pd_xlate()
103 return ERR_PTR(-ENOENT); in ti_sci_pd_xlate()
105 genpd_to_ti_sci_pd(genpd_data->domains[idx])->exclusive = in ti_sci_pd_xlate()
106 genpdspec->args[1]; in ti_sci_pd_xlate()
108 return genpd_data->domains[idx]; in ti_sci_pd_xlate()
112 { .compatible = "ti,sci-pm-domain", },
119 struct device *dev = &pdev->dev; in ti_sci_pm_domain_probe()
121 struct ti_sci_pm_domain *pd; in ti_sci_pm_domain_probe() local
130 return -ENOMEM; in ti_sci_pm_domain_probe()
132 pd_provider->ti_sci = devm_ti_sci_get_handle(dev); in ti_sci_pm_domain_probe()
133 if (IS_ERR(pd_provider->ti_sci)) in ti_sci_pm_domain_probe()
134 return PTR_ERR(pd_provider->ti_sci); in ti_sci_pm_domain_probe()
136 pd_provider->dev = dev; in ti_sci_pm_domain_probe()
138 INIT_LIST_HEAD(&pd_provider->pd_list); in ti_sci_pm_domain_probe()
142 np = of_find_node_with_property(np, "power-domains"); in ti_sci_pm_domain_probe()
149 ret = of_parse_phandle_with_args(np, "power-domains", in ti_sci_pm_domain_probe()
150 "#power-domain-cells", in ti_sci_pm_domain_probe()
155 if (args.args_count >= 1 && args.np == dev->of_node) { in ti_sci_pm_domain_probe()
159 pd = devm_kzalloc(dev, sizeof(*pd), GFP_KERNEL); in ti_sci_pm_domain_probe()
160 if (!pd) in ti_sci_pm_domain_probe()
161 return -ENOMEM; in ti_sci_pm_domain_probe()
163 pd->pd.name = devm_kasprintf(dev, GFP_KERNEL, in ti_sci_pm_domain_probe()
164 "pd:%d", in ti_sci_pm_domain_probe()
166 if (!pd->pd.name) in ti_sci_pm_domain_probe()
167 return -ENOMEM; in ti_sci_pm_domain_probe()
169 pd->pd.power_off = ti_sci_pd_power_off; in ti_sci_pm_domain_probe()
170 pd->pd.power_on = ti_sci_pd_power_on; in ti_sci_pm_domain_probe()
171 pd->idx = args.args[0]; in ti_sci_pm_domain_probe()
172 pd->parent = pd_provider; in ti_sci_pm_domain_probe()
174 pm_genpd_init(&pd->pd, NULL, true); in ti_sci_pm_domain_probe()
176 list_add(&pd->node, &pd_provider->pd_list); in ti_sci_pm_domain_probe()
182 pd_provider->data.domains = in ti_sci_pm_domain_probe()
184 sizeof(*pd_provider->data.domains), in ti_sci_pm_domain_probe()
187 pd_provider->data.num_domains = max_id + 1; in ti_sci_pm_domain_probe()
188 pd_provider->data.xlate = ti_sci_pd_xlate; in ti_sci_pm_domain_probe()
190 list_for_each_entry(pd, &pd_provider->pd_list, node) in ti_sci_pm_domain_probe()
191 pd_provider->data.domains[pd->idx] = &pd->pd; in ti_sci_pm_domain_probe()
193 return of_genpd_add_provider_onecell(dev->of_node, &pd_provider->data); in ti_sci_pm_domain_probe()