2 * CPU kernel entry/exit control
4 * Copyright (C) 2013 ARM Ltd.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #include <linux/acpi.h>
20 #include <linux/cache.h>
21 #include <linux/errno.h>
23 #include <linux/string.h>
25 #include <asm/cpu_ops.h>
26 #include <asm/smp_plat.h>
28 extern const struct cpu_operations smp_spin_table_ops
;
29 extern const struct cpu_operations acpi_parking_protocol_ops
;
30 extern const struct cpu_operations cpu_psci_ops
;
32 const struct cpu_operations
*cpu_ops
[NR_CPUS
] __ro_after_init
;
34 static const struct cpu_operations
*dt_supported_cpu_ops
[] __initconst
= {
40 static const struct cpu_operations
*acpi_supported_cpu_ops
[] __initconst
= {
41 #ifdef CONFIG_ARM64_ACPI_PARKING_PROTOCOL
42 &acpi_parking_protocol_ops
,
48 static const struct cpu_operations
* __init
cpu_get_ops(const char *name
)
50 const struct cpu_operations
**ops
;
52 ops
= acpi_disabled
? dt_supported_cpu_ops
: acpi_supported_cpu_ops
;
55 if (!strcmp(name
, (*ops
)->name
))
64 static const char *__init
cpu_read_enable_method(int cpu
)
66 const char *enable_method
;
69 struct device_node
*dn
= of_get_cpu_node(cpu
, NULL
);
73 pr_err("Failed to find device node for boot cpu\n");
77 enable_method
= of_get_property(dn
, "enable-method", NULL
);
80 * The boot CPU may not have an enable method (e.g.
81 * when spin-table is used for secondaries).
82 * Don't warn spuriously.
85 pr_err("%s: missing enable-method property\n",
89 enable_method
= acpi_get_enable_method(cpu
);
92 * In ACPI systems the boot CPU does not require
93 * checking the enable method since for some
94 * boot protocol (ie parking protocol) it need not
95 * be initialized. Don't warn spuriously.
98 pr_err("Unsupported ACPI enable-method\n");
102 return enable_method
;
105 * Read a cpu's enable method and record it in cpu_ops.
107 int __init
cpu_read_ops(int cpu
)
109 const char *enable_method
= cpu_read_enable_method(cpu
);
114 cpu_ops
[cpu
] = cpu_get_ops(enable_method
);
116 pr_warn("Unsupported enable-method: %s\n", enable_method
);