xref: /openbmc/linux/arch/arm64/include/asm/cpu_ops.h (revision 95322526ef62b84adb469c27535ab0252a369a85)
1 cd1aebf5SMark Rutland /*
2 cd1aebf5SMark Rutland  * Copyright (C) 2013 ARM Ltd.
3 cd1aebf5SMark Rutland  *
4 cd1aebf5SMark Rutland  * This program is free software; you can redistribute it and/or modify
5 cd1aebf5SMark Rutland  * it under the terms of the GNU General Public License version 2 as
6 cd1aebf5SMark Rutland  * published by the Free Software Foundation.
7 cd1aebf5SMark Rutland  *
8 cd1aebf5SMark Rutland  * This program is distributed in the hope that it will be useful,
9 cd1aebf5SMark Rutland  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 cd1aebf5SMark Rutland  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 cd1aebf5SMark Rutland  * GNU General Public License for more details.
12 cd1aebf5SMark Rutland  *
13 cd1aebf5SMark Rutland  * You should have received a copy of the GNU General Public License
14 cd1aebf5SMark Rutland  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
15 cd1aebf5SMark Rutland  */
16 cd1aebf5SMark Rutland #ifndef __ASM_CPU_OPS_H
17 cd1aebf5SMark Rutland #define __ASM_CPU_OPS_H
18 cd1aebf5SMark Rutland 
19 cd1aebf5SMark Rutland #include <linux/init.h>
20 cd1aebf5SMark Rutland #include <linux/threads.h>
21 cd1aebf5SMark Rutland 
22 cd1aebf5SMark Rutland struct device_node;
23 cd1aebf5SMark Rutland 
24 652af899SMark Rutland /**
25 652af899SMark Rutland  * struct cpu_operations - Callback operations for hotplugging CPUs.
26 652af899SMark Rutland  *
27 652af899SMark Rutland  * @name:	Name of the property as appears in a devicetree cpu node's
28 652af899SMark Rutland  *		enable-method property.
29 652af899SMark Rutland  * @cpu_init:	Reads any data necessary for a specific enable-method from the
30 652af899SMark Rutland  *		devicetree, for a given cpu node and proposed logical id.
31 652af899SMark Rutland  * @cpu_prepare: Early one-time preparation step for a cpu. If there is a
32 652af899SMark Rutland  *		mechanism for doing so, tests whether it is possible to boot
33 652af899SMark Rutland  *		the given CPU.
34 652af899SMark Rutland  * @cpu_boot:	Boots a cpu into the kernel.
35 652af899SMark Rutland  * @cpu_postboot: Optionally, perform any post-boot cleanup or necesary
36 652af899SMark Rutland  *		synchronisation. Called from the cpu being booted.
37 9327e2c6SMark Rutland  * @cpu_disable: Prepares a cpu to die. May fail for some mechanism-specific
38 9327e2c6SMark Rutland  * 		reason, which will cause the hot unplug to be aborted. Called
39 9327e2c6SMark Rutland  * 		from the cpu to be killed.
40 9327e2c6SMark Rutland  * @cpu_die:	Makes a cpu leave the kernel. Must not fail. Called from the
41 9327e2c6SMark Rutland  *		cpu being killed.
42 *95322526SLorenzo Pieralisi  * @cpu_suspend: Suspends a cpu and saves the required context. May fail owing
43 *95322526SLorenzo Pieralisi  *               to wrong parameters or error conditions. Called from the
44 *95322526SLorenzo Pieralisi  *               CPU being suspended. Must be called with IRQs disabled.
45 652af899SMark Rutland  */
46 cd1aebf5SMark Rutland struct cpu_operations {
47 cd1aebf5SMark Rutland 	const char	*name;
48 cd1aebf5SMark Rutland 	int		(*cpu_init)(struct device_node *, unsigned int);
49 cd1aebf5SMark Rutland 	int		(*cpu_prepare)(unsigned int);
50 652af899SMark Rutland 	int		(*cpu_boot)(unsigned int);
51 652af899SMark Rutland 	void		(*cpu_postboot)(void);
52 9327e2c6SMark Rutland #ifdef CONFIG_HOTPLUG_CPU
53 9327e2c6SMark Rutland 	int		(*cpu_disable)(unsigned int cpu);
54 9327e2c6SMark Rutland 	void		(*cpu_die)(unsigned int cpu);
55 9327e2c6SMark Rutland #endif
56 *95322526SLorenzo Pieralisi #ifdef CONFIG_ARM64_CPU_SUSPEND
57 *95322526SLorenzo Pieralisi 	int		(*cpu_suspend)(unsigned long);
58 *95322526SLorenzo Pieralisi #endif
59 cd1aebf5SMark Rutland };
60 cd1aebf5SMark Rutland 
61 cd1aebf5SMark Rutland extern const struct cpu_operations *cpu_ops[NR_CPUS];
62 e8765b26SMark Rutland extern int __init cpu_read_ops(struct device_node *dn, int cpu);
63 e8765b26SMark Rutland extern void __init cpu_read_bootcpu_ops(void);
64 cd1aebf5SMark Rutland 
65 cd1aebf5SMark Rutland #endif /* ifndef __ASM_CPU_OPS_H */
66