Lines Matching +full:sci +full:- +full:dev +full:- +full:id
1 // SPDX-License-Identifier: GPL-2.0-only
3 * TI SCI Generic Power Domain Driver
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>
20 * struct ti_sci_genpd_provider: holds common TI SCI genpd provider data
21 * @ti_sci: handle to TI SCI protocol driver that provides ops to
23 * @dev: pointer to dev for the driver for devm allocs
29 struct device *dev; member
42 * @parent: link to the parent TI SCI genpd provider
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()
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()
83 * ti_sci_pd_xlate(): translation service for TI SCI genpds
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() local
128 pd_provider = devm_kzalloc(dev, sizeof(*pd_provider), GFP_KERNEL); in ti_sci_pm_domain_probe()
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()
140 /* Find highest device ID used for power domains */ 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()
161 return -ENOMEM; in ti_sci_pm_domain_probe()
163 pd->pd.name = devm_kasprintf(dev, GFP_KERNEL, 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()
183 devm_kcalloc(dev, max_id + 1, 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()
205 MODULE_DESCRIPTION("TI System Control Interface (SCI) Power Domain driver");