Lines Matching +full:cpu +full:- +full:idle +full:- +full:states
1 // SPDX-License-Identifier: GPL-2.0-only
3 * PSCI CPU idle driver.
29 #include "cpuidle-psci.h"
56 u32 *states = data->psci_states; in __psci_enter_domain_idle_state() local
57 struct device *pd_dev = data->dev; in __psci_enter_domain_idle_state()
63 return -1; in __psci_enter_domain_idle_state()
65 /* 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()
84 /* Clear the domain state to start fresh when back from idle. */ in __psci_enter_domain_idle_state()
102 static int psci_idle_cpuhp_up(unsigned int cpu) in psci_idle_cpuhp_up() argument
112 static int psci_idle_cpuhp_down(unsigned int cpu) in psci_idle_cpuhp_down() argument
129 int cpu; in psci_idle_syscore_switch() local
131 for_each_possible_cpu(cpu) { in psci_idle_syscore_switch()
132 dev = per_cpu_ptr(&psci_cpuidle_data, cpu)->dev; in psci_idle_syscore_switch()
139 /* Account for userspace having offlined a CPU. */ in psci_idle_syscore_switch()
143 /* Clear domain state to re-start fresh. */ in psci_idle_syscore_switch()
194 { .compatible = "arm,idle-state",
201 int err = of_property_read_u32(np, "arm,psci-suspend-param", state); in psci_dt_parse_state_node()
204 pr_warn("%pOF missing arm,psci-suspend-param property\n", np); in psci_dt_parse_state_node()
210 return -EINVAL; in psci_dt_parse_state_node()
218 unsigned int state_count, int cpu) in psci_dt_cpu_init_topology() argument
227 data->dev = psci_dt_attach_cpu(cpu); in psci_dt_cpu_init_topology()
228 if (IS_ERR_OR_NULL(data->dev)) in psci_dt_cpu_init_topology()
229 return PTR_ERR_OR_ZERO(data->dev); in psci_dt_cpu_init_topology()
232 * Using the deepest state for the CPU to trigger a potential selection in psci_dt_cpu_init_topology()
233 * of a shared state for the domain, assumes the domain states are all in psci_dt_cpu_init_topology()
234 * deeper states. in psci_dt_cpu_init_topology()
236 drv->states[state_count - 1].flags |= CPUIDLE_FLAG_RCU_IDLE; in psci_dt_cpu_init_topology()
237 drv->states[state_count - 1].enter = psci_enter_domain_idle_state; in psci_dt_cpu_init_topology()
238 drv->states[state_count - 1].enter_s2idle = psci_enter_s2idle_domain_idle_state; in psci_dt_cpu_init_topology()
246 unsigned int state_count, int cpu) in psci_dt_cpu_init_idle() argument
251 struct psci_cpuidle_data *data = per_cpu_ptr(&psci_cpuidle_data, cpu); in psci_dt_cpu_init_idle()
257 return -ENOMEM; in psci_dt_cpu_init_idle()
260 state_node = of_get_cpu_state_node(cpu_node, i - 1); in psci_dt_cpu_init_idle()
270 pr_debug("psci-power-state %#x index %d\n", psci_states[i], i); in psci_dt_cpu_init_idle()
274 return -ENODEV; in psci_dt_cpu_init_idle()
277 ret = psci_dt_cpu_init_topology(drv, data, state_count, cpu); in psci_dt_cpu_init_idle()
281 /* Idle states parsed correctly, store them in the per-cpu struct. */ in psci_dt_cpu_init_idle()
282 data->psci_states = psci_states; in psci_dt_cpu_init_idle()
287 unsigned int cpu, unsigned int state_count) in psci_cpu_init_idle() argument
294 * idle states must not be enabled, so bail out in psci_cpu_init_idle()
297 return -EOPNOTSUPP; in psci_cpu_init_idle()
299 cpu_node = of_cpu_device_node_get(cpu); in psci_cpu_init_idle()
301 return -ENODEV; in psci_cpu_init_idle()
303 ret = psci_dt_cpu_init_idle(dev, drv, cpu_node, state_count, cpu); in psci_cpu_init_idle()
310 static void psci_cpu_deinit_idle(int cpu) in psci_cpu_deinit_idle() argument
312 struct psci_cpuidle_data *data = per_cpu_ptr(&psci_cpuidle_data, cpu); in psci_cpu_deinit_idle()
314 psci_dt_detach_cpu(data->dev); in psci_cpu_deinit_idle()
318 static int psci_idle_init_cpu(struct device *dev, int cpu) in psci_idle_init_cpu() argument
325 cpu_node = of_cpu_device_node_get(cpu); in psci_idle_init_cpu()
327 return -ENODEV; in psci_idle_init_cpu()
330 * Check whether the enable-method for the cpu is PSCI, fail in psci_idle_init_cpu()
333 enable_method = of_get_property(cpu_node, "enable-method", NULL); in psci_idle_init_cpu()
335 ret = -ENODEV; in psci_idle_init_cpu()
343 return -ENOMEM; in psci_idle_init_cpu()
345 drv->name = "psci_idle"; in psci_idle_init_cpu()
346 drv->owner = THIS_MODULE; in psci_idle_init_cpu()
347 drv->cpumask = (struct cpumask *)cpumask_of(cpu); in psci_idle_init_cpu()
350 * PSCI idle states relies on architectural WFI to be represented as in psci_idle_init_cpu()
353 drv->states[0].enter = psci_enter_idle_state; in psci_idle_init_cpu()
354 drv->states[0].exit_latency = 1; in psci_idle_init_cpu()
355 drv->states[0].target_residency = 1; in psci_idle_init_cpu()
356 drv->states[0].power_usage = UINT_MAX; in psci_idle_init_cpu()
357 strcpy(drv->states[0].name, "WFI"); in psci_idle_init_cpu()
358 strcpy(drv->states[0].desc, "ARM WFI"); in psci_idle_init_cpu()
361 * If no DT idle states are detected (ret == 0) let the driver in psci_idle_init_cpu()
363 * initialize the idle driver if only wfi is supported, the in psci_idle_init_cpu()
364 * default archictectural back-end already executes wfi in psci_idle_init_cpu()
365 * on idle entry. in psci_idle_init_cpu()
369 return ret ? : -ENODEV; in psci_idle_init_cpu()
372 * Initialize PSCI idle states. in psci_idle_init_cpu()
374 ret = psci_cpu_init_idle(dev, drv, cpu, ret); in psci_idle_init_cpu()
376 pr_err("CPU %d failed to PSCI idle\n", cpu); in psci_idle_init_cpu()
388 psci_cpu_deinit_idle(cpu); in psci_idle_init_cpu()
393 * psci_idle_probe - Initializes PSCI cpuidle driver
395 * Initializes PSCI cpuidle driver for all CPUs, if any CPU fails
401 int cpu, ret; in psci_cpuidle_probe() local
405 for_each_possible_cpu(cpu) { in psci_cpuidle_probe()
406 ret = psci_idle_init_cpu(&pdev->dev, cpu); in psci_cpuidle_probe()
415 while (--cpu >= 0) { in psci_cpuidle_probe()
416 dev = per_cpu(cpuidle_devices, cpu); in psci_cpuidle_probe()
419 psci_cpu_deinit_idle(cpu); in psci_cpuidle_probe()
428 .name = "psci-cpuidle",
441 pdev = platform_device_register_simple("psci-cpuidle", -1, NULL, 0); in psci_idle_init()