Lines Matching +full:domain +full:- +full:idle +full:- +full:state
1 // SPDX-License-Identifier: GPL-2.0-only
3 * PSCI CPU idle driver.
29 #include "cpuidle-psci.h"
41 void psci_set_domain_state(u32 state) in psci_set_domain_state() argument
43 __this_cpu_write(domain_state, state); in psci_set_domain_state()
56 u32 *states = data->psci_states; in __psci_enter_domain_idle_state()
57 struct device *pd_dev = data->dev; in __psci_enter_domain_idle_state()
58 u32 state; in __psci_enter_domain_idle_state() local
63 return -1; in __psci_enter_domain_idle_state()
71 state = psci_get_domain_state(); in __psci_enter_domain_idle_state()
72 if (!state) 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()
118 /* Clear domain state to start fresh at next online. */ in psci_idle_cpuhp_down()
132 dev = per_cpu_ptr(&psci_cpuidle_data, cpu)->dev; in psci_idle_syscore_switch()
143 /* Clear domain state to re-start fresh. */ in psci_idle_syscore_switch()
182 pr_warn("Failed %d while setup cpuhp state\n", err); in psci_idle_init_cpuhp()
188 u32 *state = __this_cpu_read(psci_cpuidle_data.psci_states); in psci_enter_idle_state() local
190 return CPU_PM_CPU_IDLE_ENTER_PARAM_RCU(psci_cpu_suspend_enter, idx, state[idx]); in psci_enter_idle_state()
194 { .compatible = "arm,idle-state",
199 int psci_dt_parse_state_node(struct device_node *np, u32 *state) in psci_dt_parse_state_node() argument
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()
208 if (!psci_power_state_is_valid(*state)) { in psci_dt_parse_state_node()
209 pr_warn("Invalid PSCI power state %#x\n", *state); in psci_dt_parse_state_node()
210 return -EINVAL; in psci_dt_parse_state_node()
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()
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()
253 state_count++; /* Add WFI state too */ 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()
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()
294 * idle states must not be enabled, so bail out in psci_cpu_init_idle()
297 return -EOPNOTSUPP; in psci_cpu_init_idle()
301 return -ENODEV; in psci_cpu_init_idle()
314 psci_dt_detach_cpu(data->dev); in psci_cpu_deinit_idle()
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()
351 * state index 0. 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()
376 pr_err("CPU %d failed to PSCI idle\n", cpu); in psci_idle_init_cpu()
393 * psci_idle_probe - Initializes PSCI cpuidle driver
406 ret = psci_idle_init_cpu(&pdev->dev, cpu); in psci_cpuidle_probe()
415 while (--cpu >= 0) { in psci_cpuidle_probe()
428 .name = "psci-cpuidle",
441 pdev = platform_device_register_simple("psci-cpuidle", -1, NULL, 0); in psci_idle_init()