xref: /openbmc/linux/arch/arm64/include/asm/cpu_ops.h (revision 819a88263d5dbe398edd59cc1cf725ed1fdcfd79)
1cd1aebf5SMark Rutland /*
2cd1aebf5SMark Rutland  * Copyright (C) 2013 ARM Ltd.
3cd1aebf5SMark Rutland  *
4cd1aebf5SMark Rutland  * This program is free software; you can redistribute it and/or modify
5cd1aebf5SMark Rutland  * it under the terms of the GNU General Public License version 2 as
6cd1aebf5SMark Rutland  * published by the Free Software Foundation.
7cd1aebf5SMark Rutland  *
8cd1aebf5SMark Rutland  * This program is distributed in the hope that it will be useful,
9cd1aebf5SMark Rutland  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10cd1aebf5SMark Rutland  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11cd1aebf5SMark Rutland  * GNU General Public License for more details.
12cd1aebf5SMark Rutland  *
13cd1aebf5SMark Rutland  * You should have received a copy of the GNU General Public License
14cd1aebf5SMark Rutland  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
15cd1aebf5SMark Rutland  */
16cd1aebf5SMark Rutland #ifndef __ASM_CPU_OPS_H
17cd1aebf5SMark Rutland #define __ASM_CPU_OPS_H
18cd1aebf5SMark Rutland 
19cd1aebf5SMark Rutland #include <linux/init.h>
20cd1aebf5SMark Rutland #include <linux/threads.h>
21cd1aebf5SMark Rutland 
22652af899SMark Rutland /**
23652af899SMark Rutland  * struct cpu_operations - Callback operations for hotplugging CPUs.
24652af899SMark Rutland  *
25652af899SMark Rutland  * @name:	Name of the property as appears in a devicetree cpu node's
26*819a8826SLorenzo Pieralisi  *		enable-method property. On systems booting with ACPI, @name
27*819a8826SLorenzo Pieralisi  *		identifies the struct cpu_operations entry corresponding to
28*819a8826SLorenzo Pieralisi  *		the boot protocol specified in the ACPI MADT table.
29*819a8826SLorenzo Pieralisi  * @cpu_init:	Reads any data necessary for a specific enable-method for a
30*819a8826SLorenzo Pieralisi  *		proposed logical id.
31652af899SMark Rutland  * @cpu_prepare: Early one-time preparation step for a cpu. If there is a
32652af899SMark Rutland  *		mechanism for doing so, tests whether it is possible to boot
33652af899SMark Rutland  *		the given CPU.
34652af899SMark Rutland  * @cpu_boot:	Boots a cpu into the kernel.
35652af899SMark Rutland  * @cpu_postboot: Optionally, perform any post-boot cleanup or necesary
36652af899SMark Rutland  *		synchronisation. Called from the cpu being booted.
379327e2c6SMark Rutland  * @cpu_disable: Prepares a cpu to die. May fail for some mechanism-specific
389327e2c6SMark Rutland  * 		reason, which will cause the hot unplug to be aborted. Called
399327e2c6SMark Rutland  * 		from the cpu to be killed.
409327e2c6SMark Rutland  * @cpu_die:	Makes a cpu leave the kernel. Must not fail. Called from the
419327e2c6SMark Rutland  *		cpu being killed.
42c814ca02SAshwin Chaugule  * @cpu_kill:  Ensures a cpu has left the kernel. Called from another cpu.
43*819a8826SLorenzo Pieralisi  * @cpu_init_idle: Reads any data necessary to initialize CPU idle states for
44*819a8826SLorenzo Pieralisi  *		   a proposed logical id.
4595322526SLorenzo Pieralisi  * @cpu_suspend: Suspends a cpu and saves the required context. May fail owing
4695322526SLorenzo Pieralisi  *               to wrong parameters or error conditions. Called from the
4795322526SLorenzo Pieralisi  *               CPU being suspended. Must be called with IRQs disabled.
48652af899SMark Rutland  */
49cd1aebf5SMark Rutland struct cpu_operations {
50cd1aebf5SMark Rutland 	const char	*name;
51*819a8826SLorenzo Pieralisi 	int		(*cpu_init)(unsigned int);
52cd1aebf5SMark Rutland 	int		(*cpu_prepare)(unsigned int);
53652af899SMark Rutland 	int		(*cpu_boot)(unsigned int);
54652af899SMark Rutland 	void		(*cpu_postboot)(void);
559327e2c6SMark Rutland #ifdef CONFIG_HOTPLUG_CPU
569327e2c6SMark Rutland 	int		(*cpu_disable)(unsigned int cpu);
579327e2c6SMark Rutland 	void		(*cpu_die)(unsigned int cpu);
58c814ca02SAshwin Chaugule 	int		(*cpu_kill)(unsigned int cpu);
599327e2c6SMark Rutland #endif
60af3cfdbfSLorenzo Pieralisi #ifdef CONFIG_CPU_IDLE
61*819a8826SLorenzo Pieralisi 	int		(*cpu_init_idle)(unsigned int);
6295322526SLorenzo Pieralisi 	int		(*cpu_suspend)(unsigned long);
6395322526SLorenzo Pieralisi #endif
64cd1aebf5SMark Rutland };
65cd1aebf5SMark Rutland 
66cd1aebf5SMark Rutland extern const struct cpu_operations *cpu_ops[NR_CPUS];
67*819a8826SLorenzo Pieralisi int __init cpu_read_ops(int cpu);
68fccb9a81SHanjun Guo const struct cpu_operations *cpu_get_ops(const char *name);
69cd1aebf5SMark Rutland 
70*819a8826SLorenzo Pieralisi static inline void __init cpu_read_bootcpu_ops(void)
71*819a8826SLorenzo Pieralisi {
72*819a8826SLorenzo Pieralisi 	cpu_read_ops(0);
73*819a8826SLorenzo Pieralisi }
74*819a8826SLorenzo Pieralisi 
75cd1aebf5SMark Rutland #endif /* ifndef __ASM_CPU_OPS_H */
76