Lines Matching +full:wakeup +full:- +full:parent

1 // SPDX-License-Identifier: GPL-2.0
5 * Copyright (C) 2015-2019 Xilinx, Inc.
20 #include <linux/firmware/xlnx-zynqmp.h>
27 * struct zynqmp_pm_domain - Wrapper around struct generic_pm_domain
42 * zynqmp_gpd_is_active_wakeup_path() - Check if device is in wakeup source
44 * @dev: Device to check for wakeup source path
48 * set as wakeup source.
50 * Return: 1 if device is in wakeup source path else 0
65 * zynqmp_gpd_power_on() - Power on PM domain
78 ret = zynqmp_pm_set_requirement(pd->node_id, in zynqmp_gpd_power_on()
83 dev_err(&domain->dev, in zynqmp_gpd_power_on()
85 ZYNQMP_PM_CAPABILITY_ACCESS, pd->node_id, ret); in zynqmp_gpd_power_on()
89 dev_dbg(&domain->dev, "set requirement to 0x%x for PM node id %d\n", in zynqmp_gpd_power_on()
90 ZYNQMP_PM_CAPABILITY_ACCESS, pd->node_id); in zynqmp_gpd_power_on()
96 * zynqmp_gpd_power_off() - Power off PM domain
113 if (!pd->requested) { in zynqmp_gpd_power_off()
114 dev_dbg(&domain->dev, "PM node id %d is already released\n", in zynqmp_gpd_power_off()
115 pd->node_id); in zynqmp_gpd_power_off()
119 list_for_each_entry_safe(pdd, tmp, &domain->dev_list, list_node) { in zynqmp_gpd_power_off()
120 /* If device is in wakeup path, set capability to WAKEUP */ in zynqmp_gpd_power_off()
121 may_wakeup = zynqmp_gpd_is_active_wakeup_path(pdd->dev, NULL); in zynqmp_gpd_power_off()
123 dev_dbg(pdd->dev, "device is in wakeup path in %s\n", in zynqmp_gpd_power_off()
124 domain->name); in zynqmp_gpd_power_off()
130 ret = zynqmp_pm_set_requirement(pd->node_id, capabilities, 0, in zynqmp_gpd_power_off()
133 dev_err(&domain->dev, in zynqmp_gpd_power_off()
135 capabilities, pd->node_id, ret); in zynqmp_gpd_power_off()
139 dev_dbg(&domain->dev, "set requirement to 0x%x for PM node id %d\n", in zynqmp_gpd_power_off()
140 capabilities, pd->node_id); in zynqmp_gpd_power_off()
146 * zynqmp_gpd_attach_dev() - Attach device to the PM domain
159 link = device_link_add(dev, &domain->dev, DL_FLAG_SYNC_STATE_ONLY); in zynqmp_gpd_attach_dev()
161 dev_dbg(&domain->dev, "failed to create device link for %s\n", in zynqmp_gpd_attach_dev()
165 if (domain->device_count) in zynqmp_gpd_attach_dev()
168 ret = zynqmp_pm_request_node(pd->node_id, 0, 0, in zynqmp_gpd_attach_dev()
171 dev_err(&domain->dev, "%s request failed for node %d: %d\n", in zynqmp_gpd_attach_dev()
172 domain->name, pd->node_id, ret); in zynqmp_gpd_attach_dev()
176 pd->requested = true; in zynqmp_gpd_attach_dev()
178 dev_dbg(&domain->dev, "%s requested PM node id %d\n", in zynqmp_gpd_attach_dev()
179 dev_name(dev), pd->node_id); in zynqmp_gpd_attach_dev()
185 * zynqmp_gpd_detach_dev() - Detach device from the PM domain
196 if (domain->device_count) in zynqmp_gpd_detach_dev()
199 ret = zynqmp_pm_release_node(pd->node_id); in zynqmp_gpd_detach_dev()
201 dev_err(&domain->dev, "failed to release PM node id %d: %d\n", in zynqmp_gpd_detach_dev()
202 pd->node_id, ret); in zynqmp_gpd_detach_dev()
206 pd->requested = false; in zynqmp_gpd_detach_dev()
208 dev_dbg(&domain->dev, "%s released PM node id %d\n", in zynqmp_gpd_detach_dev()
209 dev_name(dev), pd->node_id); in zynqmp_gpd_detach_dev()
216 unsigned int i, idx = genpdspec->args[0]; in zynqmp_gpd_xlate()
219 pd = to_zynqmp_pm_domain(genpd_data->domains[0]); in zynqmp_gpd_xlate()
221 if (genpdspec->args_count != 1) in zynqmp_gpd_xlate()
222 return ERR_PTR(-EINVAL); in zynqmp_gpd_xlate()
242 if (!genpd_data->domains[i] || i == ZYNQMP_NUM_DOMAINS) in zynqmp_gpd_xlate()
243 return ERR_PTR(-ENOENT); in zynqmp_gpd_xlate()
245 return genpd_data->domains[i]; in zynqmp_gpd_xlate()
254 struct device *dev = &pdev->dev; in zynqmp_gpd_probe()
258 return -ENOMEM; in zynqmp_gpd_probe()
262 return -ENOMEM; in zynqmp_gpd_probe()
264 zynqmp_pd_data->xlate = zynqmp_gpd_xlate; in zynqmp_gpd_probe()
269 return -ENOMEM; in zynqmp_gpd_probe()
271 if (!of_device_is_compatible(dev->parent->of_node, in zynqmp_gpd_probe()
272 "xlnx,zynqmp-firmware")) in zynqmp_gpd_probe()
276 pd->node_id = 0; in zynqmp_gpd_probe()
277 pd->gpd.name = kasprintf(GFP_KERNEL, "domain%d", i); in zynqmp_gpd_probe()
278 pd->gpd.power_off = zynqmp_gpd_power_off; in zynqmp_gpd_probe()
279 pd->gpd.power_on = zynqmp_gpd_power_on; in zynqmp_gpd_probe()
280 pd->gpd.attach_dev = zynqmp_gpd_attach_dev; in zynqmp_gpd_probe()
281 pd->gpd.detach_dev = zynqmp_gpd_detach_dev; in zynqmp_gpd_probe()
283 domains[i] = &pd->gpd; in zynqmp_gpd_probe()
286 pm_genpd_init(&pd->gpd, NULL, true); in zynqmp_gpd_probe()
289 zynqmp_pd_data->domains = domains; in zynqmp_gpd_probe()
290 zynqmp_pd_data->num_domains = ZYNQMP_NUM_DOMAINS; in zynqmp_gpd_probe()
291 of_genpd_add_provider_onecell(dev->parent->of_node, zynqmp_pd_data); in zynqmp_gpd_probe()
298 of_genpd_del_provider(pdev->dev.parent->of_node); in zynqmp_gpd_remove()