1 // SPDX-License-Identifier: GPL-2.0-only
3 * CPU kernel entry/exit control
5 * Copyright (C) 2013 ARM Ltd.
8 #include <linux/acpi.h>
9 #include <linux/cache.h>
10 #include <linux/errno.h>
12 #include <linux/string.h>
14 #include <asm/cpu_ops.h>
15 #include <asm/smp_plat.h>
17 extern const struct cpu_operations smp_spin_table_ops;
18 #ifdef CONFIG_ARM64_ACPI_PARKING_PROTOCOL
19 extern const struct cpu_operations acpi_parking_protocol_ops;
21 extern const struct cpu_operations cpu_psci_ops;
23 static const struct cpu_operations *cpu_ops[NR_CPUS] __ro_after_init;
25 static const struct cpu_operations *const dt_supported_cpu_ops[] __initconst = {
31 static const struct cpu_operations *const acpi_supported_cpu_ops[] __initconst = {
32 #ifdef CONFIG_ARM64_ACPI_PARKING_PROTOCOL
33 &acpi_parking_protocol_ops,
39 static const struct cpu_operations * __init cpu_get_ops(const char *name)
41 const struct cpu_operations *const *ops;
43 ops = acpi_disabled ? dt_supported_cpu_ops : acpi_supported_cpu_ops;
46 if (!strcmp(name, (*ops)->name))
55 static const char *__init cpu_read_enable_method(int cpu)
57 const char *enable_method;
60 struct device_node *dn = of_get_cpu_node(cpu, NULL);
64 pr_err("Failed to find device node for boot cpu\n");
68 enable_method = of_get_property(dn, "enable-method", NULL);
71 * The boot CPU may not have an enable method (e.g.
72 * when spin-table is used for secondaries).
73 * Don't warn spuriously.
76 pr_err("%pOF: missing enable-method property\n",
81 enable_method = acpi_get_enable_method(cpu);
84 * In ACPI systems the boot CPU does not require
85 * checking the enable method since for some
86 * boot protocol (ie parking protocol) it need not
87 * be initialized. Don't warn spuriously.
90 pr_err("Unsupported ACPI enable-method\n");
97 * Read a cpu's enable method and record it in cpu_ops.
99 int __init init_cpu_ops(int cpu)
101 const char *enable_method = cpu_read_enable_method(cpu);
106 cpu_ops[cpu] = cpu_get_ops(enable_method);
108 pr_warn("Unsupported enable-method: %s\n", enable_method);
115 const struct cpu_operations *get_cpu_ops(int cpu)