Lines Matching +full:cpu +full:- +full:idle +full:- +full:states

1 // SPDX-License-Identifier: GPL-2.0-only
3 * PSCI CPU idle driver.
28 #include "cpuidle-psci.h"
59 u32 *states = data->psci_states; in psci_enter_domain_idle_state() local
60 struct device *pd_dev = data->dev; in psci_enter_domain_idle_state()
66 return -1; in psci_enter_domain_idle_state()
68 /* Do runtime PM to manage a hierarchical CPU toplogy. */ in psci_enter_domain_idle_state()
73 state = states[idx]; in psci_enter_domain_idle_state()
75 ret = psci_cpu_suspend_enter(state) ? -1 : idx; in psci_enter_domain_idle_state()
81 /* Clear the domain state to start fresh when back from idle. */ in psci_enter_domain_idle_state()
86 static int psci_idle_cpuhp_up(unsigned int cpu) in psci_idle_cpuhp_up() argument
96 static int psci_idle_cpuhp_down(unsigned int cpu) in psci_idle_cpuhp_down() argument
133 { .compatible = "arm,idle-state",
140 int err = of_property_read_u32(np, "arm,psci-suspend-param", state); in psci_dt_parse_state_node()
143 pr_warn("%pOF missing arm,psci-suspend-param property\n", np); in psci_dt_parse_state_node()
149 return -EINVAL; in psci_dt_parse_state_node()
157 unsigned int state_count, int cpu) in psci_dt_cpu_init_topology() argument
163 data->dev = psci_dt_attach_cpu(cpu); in psci_dt_cpu_init_topology()
164 if (IS_ERR_OR_NULL(data->dev)) in psci_dt_cpu_init_topology()
165 return PTR_ERR_OR_ZERO(data->dev); in psci_dt_cpu_init_topology()
168 * Using the deepest state for the CPU to trigger a potential selection in psci_dt_cpu_init_topology()
169 * of a shared state for the domain, assumes the domain states are all in psci_dt_cpu_init_topology()
170 * deeper states. in psci_dt_cpu_init_topology()
172 drv->states[state_count - 1].enter = psci_enter_domain_idle_state; in psci_dt_cpu_init_topology()
180 unsigned int state_count, int cpu) in psci_dt_cpu_init_idle() argument
185 struct psci_cpuidle_data *data = per_cpu_ptr(&psci_cpuidle_data, cpu); in psci_dt_cpu_init_idle()
191 return -ENOMEM; in psci_dt_cpu_init_idle()
194 state_node = of_get_cpu_state_node(cpu_node, i - 1); in psci_dt_cpu_init_idle()
204 pr_debug("psci-power-state %#x index %d\n", psci_states[i], i); in psci_dt_cpu_init_idle()
208 return -ENODEV; in psci_dt_cpu_init_idle()
211 ret = psci_dt_cpu_init_topology(drv, data, state_count, cpu); in psci_dt_cpu_init_idle()
215 /* Idle states parsed correctly, store them in the per-cpu struct. */ in psci_dt_cpu_init_idle()
216 data->psci_states = psci_states; in psci_dt_cpu_init_idle()
221 unsigned int cpu, unsigned int state_count) in psci_cpu_init_idle() argument
228 * idle states must not be enabled, so bail out in psci_cpu_init_idle()
231 return -EOPNOTSUPP; in psci_cpu_init_idle()
233 cpu_node = of_cpu_device_node_get(cpu); in psci_cpu_init_idle()
235 return -ENODEV; in psci_cpu_init_idle()
237 ret = psci_dt_cpu_init_idle(dev, drv, cpu_node, state_count, cpu); in psci_cpu_init_idle()
244 static void psci_cpu_deinit_idle(int cpu) in psci_cpu_deinit_idle() argument
246 struct psci_cpuidle_data *data = per_cpu_ptr(&psci_cpuidle_data, cpu); in psci_cpu_deinit_idle()
248 psci_dt_detach_cpu(data->dev); in psci_cpu_deinit_idle()
252 static int psci_idle_init_cpu(struct device *dev, int cpu) in psci_idle_init_cpu() argument
259 cpu_node = of_cpu_device_node_get(cpu); in psci_idle_init_cpu()
261 return -ENODEV; in psci_idle_init_cpu()
264 * Check whether the enable-method for the cpu is PSCI, fail in psci_idle_init_cpu()
267 enable_method = of_get_property(cpu_node, "enable-method", NULL); in psci_idle_init_cpu()
269 ret = -ENODEV; in psci_idle_init_cpu()
277 return -ENOMEM; in psci_idle_init_cpu()
279 drv->name = "psci_idle"; in psci_idle_init_cpu()
280 drv->owner = THIS_MODULE; in psci_idle_init_cpu()
281 drv->cpumask = (struct cpumask *)cpumask_of(cpu); in psci_idle_init_cpu()
284 * PSCI idle states relies on architectural WFI to be represented as in psci_idle_init_cpu()
287 drv->states[0].enter = psci_enter_idle_state; in psci_idle_init_cpu()
288 drv->states[0].exit_latency = 1; in psci_idle_init_cpu()
289 drv->states[0].target_residency = 1; in psci_idle_init_cpu()
290 drv->states[0].power_usage = UINT_MAX; in psci_idle_init_cpu()
291 strcpy(drv->states[0].name, "WFI"); in psci_idle_init_cpu()
292 strcpy(drv->states[0].desc, "ARM WFI"); in psci_idle_init_cpu()
295 * If no DT idle states are detected (ret == 0) let the driver in psci_idle_init_cpu()
297 * initialize the idle driver if only wfi is supported, the in psci_idle_init_cpu()
298 * default archictectural back-end already executes wfi in psci_idle_init_cpu()
299 * on idle entry. in psci_idle_init_cpu()
303 return ret ? : -ENODEV; in psci_idle_init_cpu()
306 * Initialize PSCI idle states. in psci_idle_init_cpu()
308 ret = psci_cpu_init_idle(dev, drv, cpu, ret); in psci_idle_init_cpu()
310 pr_err("CPU %d failed to PSCI idle\n", cpu); in psci_idle_init_cpu()
322 psci_cpu_deinit_idle(cpu); in psci_idle_init_cpu()
327 * psci_idle_probe - Initializes PSCI cpuidle driver
329 * Initializes PSCI cpuidle driver for all CPUs, if any CPU fails
335 int cpu, ret; in psci_cpuidle_probe() local
339 for_each_possible_cpu(cpu) { in psci_cpuidle_probe()
340 ret = psci_idle_init_cpu(&pdev->dev, cpu); in psci_cpuidle_probe()
349 while (--cpu >= 0) { in psci_cpuidle_probe()
350 dev = per_cpu(cpuidle_devices, cpu); in psci_cpuidle_probe()
353 psci_cpu_deinit_idle(cpu); in psci_cpuidle_probe()
362 .name = "psci-cpuidle",
375 pdev = platform_device_register_simple("psci-cpuidle", -1, NULL, 0); in psci_idle_init()