Lines Matching +full:psci +full:- +full:0
1 // SPDX-License-Identifier: GPL-2.0-only
7 #define pr_fmt(fmt) "psci: " fmt
10 #include <linux/arm-smccc.h>
18 #include <linux/psci.h>
23 #include <uapi/linux/psci.h>
33 * While a 64-bit OS can make calls with SMC32 calling conventions, for some
34 * calls it is necessary to use SMC64 to pass or return 64-bit values.
36 * (native-width) function ID.
47 * a Trusted OS even if it claims to be capable of migration -- doing so will
50 static int resident_cpu = -1;
118 arm_smccc_hvc(function_id, arg0, arg1, arg2, 0, 0, 0, 0, &res); in __invoke_psci_fn_hvc()
129 arm_smccc_smc(function_id, arg0, arg1, arg2, 0, 0, 0, 0, &res); in __invoke_psci_fn_smc()
137 return 0; in psci_to_linux_errno()
139 return -EOPNOTSUPP; in psci_to_linux_errno()
142 return -EINVAL; in psci_to_linux_errno()
144 return -EPERM; in psci_to_linux_errno()
147 return -EINVAL; in psci_to_linux_errno()
152 return PSCI_VERSION(0, 1); in psci_0_1_get_version()
157 return invoke_psci_fn(PSCI_0_2_FN_PSCI_VERSION, 0, 0, 0); in psci_0_2_get_version()
168 err = invoke_psci_fn(PSCI_1_0_FN_SET_SUSPEND_MODE, suspend_mode, 0, 0); in psci_set_osi_mode()
169 if (err < 0) in psci_set_osi_mode()
180 err = invoke_psci_fn(fn, state, entry_point, 0); in __psci_cpu_suspend()
194 return __psci_cpu_suspend(PSCI_FN_NATIVE(0_2, CPU_SUSPEND), in psci_0_2_cpu_suspend()
202 err = invoke_psci_fn(fn, state, 0, 0); in __psci_cpu_off()
220 err = invoke_psci_fn(fn, cpuid, entry_point, 0); in __psci_cpu_on()
231 return __psci_cpu_on(PSCI_FN_NATIVE(0_2, CPU_ON), cpuid, entry_point); in psci_0_2_cpu_on()
238 err = invoke_psci_fn(fn, cpuid, 0, 0); in __psci_migrate()
249 return __psci_migrate(PSCI_FN_NATIVE(0_2, MIGRATE), cpuid); in psci_0_2_migrate()
255 return invoke_psci_fn(PSCI_FN_NATIVE(0_2, AFFINITY_INFO), in psci_affinity_info()
256 target_affinity, lowest_affinity_level, 0); in psci_affinity_info()
261 return invoke_psci_fn(PSCI_0_2_FN_MIGRATE_INFO_TYPE, 0, 0, 0); in psci_migrate_info_type()
266 return invoke_psci_fn(PSCI_FN_NATIVE(0_2, MIGRATE_INFO_UP_CPU), in psci_migrate_info_up_cpu()
267 0, 0, 0); in psci_migrate_info_up_cpu()
280 WARN(1, "Unexpected PSCI conduit %d\n", conduit); in set_conduit()
294 return -ENXIO; in get_set_conduit_method()
303 return -EINVAL; in get_set_conduit_method()
305 return 0; in get_set_conduit_method()
314 * reset_type[31] = 0 (architectural) in psci_sys_reset()
315 * reset_type[30:0] = 0 (SYSTEM_WARM_RESET) in psci_sys_reset()
316 * cookie = 0 (ignored by the implementation) in psci_sys_reset()
318 invoke_psci_fn(PSCI_FN_NATIVE(1_1, SYSTEM_RESET2), 0, 0, 0); in psci_sys_reset()
320 invoke_psci_fn(PSCI_0_2_FN_SYSTEM_RESET, 0, 0, 0); in psci_sys_reset()
333 invoke_psci_fn(PSCI_0_2_FN_SYSTEM_OFF, 0, 0, 0); in psci_sys_poweroff()
339 psci_func_id, 0, 0); in psci_features()
354 PSCI_ID_NATIVE(0_2, MIGRATE),
355 PSCI_ID(0_2, MIGRATE_INFO_TYPE),
356 PSCI_ID_NATIVE(0_2, MIGRATE_INFO_UP_CPU),
381 return 0; in psci_debugfs_read()
385 ver = invoke_psci_fn(ARM_SMCCC_VERSION_FUNC_ID, 0, 0, 0); in psci_debugfs_read()
390 seq_puts(s, "SMC Calling Convention v1.0 is assumed\n"); in psci_debugfs_read()
393 feature = psci_features(PSCI_FN_NATIVE(0_2, CPU_SUSPEND)); in psci_debugfs_read()
394 if (feature < 0) { in psci_debugfs_read()
398 (feature & BIT(0)) ? "" : "not "); in psci_debugfs_read()
411 seq_printf(s, "Trusted OS resident on physical CPU 0x%lx (#%d)\n", in psci_debugfs_read()
420 for (i = 0; i < ARRAY_SIZE(psci_fn_ids); i++) { in psci_debugfs_read()
424 if (feature < 0) in psci_debugfs_read()
431 return 0; in psci_debugfs_read()
450 return 0; in psci_debugfs_init()
452 return PTR_ERR_OR_ZERO(debugfs_create_file("psci", 0444, NULL, NULL, in psci_debugfs_init()
478 ret = psci_ops.cpu_suspend(state, 0); in psci_cpu_suspend_enter()
504 pa_cpu_resume, 0, 0); in psci_system_suspend()
510 return cpu_suspend(0, psci_system_suspend); in psci_system_suspend_enter()
543 int feature = psci_features(PSCI_FN_NATIVE(0_2, CPU_SUSPEND)); in psci_init_cpu_suspend()
556 int type, cpu = -1; in psci_init_migrate()
578 pr_warn("MIGRATE_INFO_UP_CPU reported invalid physical ID (0x%lx)\n", in psci_init_migrate()
584 resident_cpu = cpu >= 0 ? cpu : -1; in psci_init_migrate()
586 pr_info("Trusted OS resident on physical CPU 0x%lx\n", cpuid); in psci_init_migrate()
598 ret = invoke_psci_fn(ARM_SMCCC_VERSION_FUNC_ID, 0, 0, 0); in psci_init_smccc()
606 * Conveniently, the SMCCC and PSCI versions are encoded the in psci_init_smccc()
616 pr_info("Using standard PSCI v0.2 function IDs\n"); in psci_0_2_set_functions()
634 * Probe function for PSCI firmware versions >= 0.2
644 if (PSCI_VERSION_MAJOR(ver) == 0 && PSCI_VERSION_MINOR(ver) < 2) { in psci_probe()
645 pr_err("Conflicting PSCI version detected.\n"); in psci_probe()
646 return -EINVAL; in psci_probe()
661 return 0; in psci_probe()
667 * PSCI init function for PSCI versions >=0.2
669 * Probe based on PSCI PSCI_VERSION function
680 * Starting with v0.2, the PSCI specification introduced a call in psci_0_2_init()
682 * that PSCI function IDs and version specific initialization in psci_0_2_init()
690 * PSCI < v0.2 get PSCI Function IDs via DT.
701 pr_info("Using PSCI v0.1 Function IDs from DT\n"); in psci_0_1_init()
725 return 0; in psci_0_1_init()
743 return 0; in psci_1_0_init()
747 { .compatible = "arm,psci", .data = psci_0_1_init},
748 { .compatible = "arm,psci-0.2", .data = psci_0_2_init},
749 { .compatible = "arm,psci-1.0", .data = psci_1_0_init},
763 return -ENODEV; in psci_dt_init()
765 init_fn = (psci_initcall_t)matched_np->data; in psci_dt_init()
774 * We use PSCI 0.2+ when ACPI is deployed on ARM64 and it's
781 return -EOPNOTSUPP; in psci_acpi_init()