xref: /OK3568_Linux_fs/kernel/arch/riscv/include/asm/cpu_ops.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0-only */
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  * Copyright (c) 2020 Western Digital Corporation or its affiliates.
4*4882a593Smuzhiyun  * Based on arch/arm64/include/asm/cpu_ops.h
5*4882a593Smuzhiyun  */
6*4882a593Smuzhiyun #ifndef __ASM_CPU_OPS_H
7*4882a593Smuzhiyun #define __ASM_CPU_OPS_H
8*4882a593Smuzhiyun 
9*4882a593Smuzhiyun #include <linux/init.h>
10*4882a593Smuzhiyun #include <linux/sched.h>
11*4882a593Smuzhiyun #include <linux/threads.h>
12*4882a593Smuzhiyun 
13*4882a593Smuzhiyun /**
14*4882a593Smuzhiyun  * struct cpu_operations - Callback operations for hotplugging CPUs.
15*4882a593Smuzhiyun  *
16*4882a593Smuzhiyun  * @name:		Name of the boot protocol.
17*4882a593Smuzhiyun  * @cpu_prepare:	Early one-time preparation step for a cpu. If there
18*4882a593Smuzhiyun  *			is a mechanism for doing so, tests whether it is
19*4882a593Smuzhiyun  *			possible to boot the given HART.
20*4882a593Smuzhiyun  * @cpu_start:		Boots a cpu into the kernel.
21*4882a593Smuzhiyun  * @cpu_disable:	Prepares a cpu to die. May fail for some
22*4882a593Smuzhiyun  *			mechanism-specific reason, which will cause the hot
23*4882a593Smuzhiyun  *			unplug to be aborted. Called from the cpu to be killed.
24*4882a593Smuzhiyun  * @cpu_stop:		Makes a cpu leave the kernel. Must not fail. Called from
25*4882a593Smuzhiyun  *			the cpu being stopped.
26*4882a593Smuzhiyun  * @cpu_is_stopped:	Ensures a cpu has left the kernel. Called from another
27*4882a593Smuzhiyun  *			cpu.
28*4882a593Smuzhiyun  */
29*4882a593Smuzhiyun struct cpu_operations {
30*4882a593Smuzhiyun 	const char	*name;
31*4882a593Smuzhiyun 	int		(*cpu_prepare)(unsigned int cpu);
32*4882a593Smuzhiyun 	int		(*cpu_start)(unsigned int cpu,
33*4882a593Smuzhiyun 				     struct task_struct *tidle);
34*4882a593Smuzhiyun #ifdef CONFIG_HOTPLUG_CPU
35*4882a593Smuzhiyun 	int		(*cpu_disable)(unsigned int cpu);
36*4882a593Smuzhiyun 	void		(*cpu_stop)(void);
37*4882a593Smuzhiyun 	int		(*cpu_is_stopped)(unsigned int cpu);
38*4882a593Smuzhiyun #endif
39*4882a593Smuzhiyun };
40*4882a593Smuzhiyun 
41*4882a593Smuzhiyun extern const struct cpu_operations *cpu_ops[NR_CPUS];
42*4882a593Smuzhiyun void __init cpu_set_ops(int cpu);
43*4882a593Smuzhiyun void cpu_update_secondary_bootdata(unsigned int cpuid,
44*4882a593Smuzhiyun 				   struct task_struct *tidle);
45*4882a593Smuzhiyun 
46*4882a593Smuzhiyun #endif /* ifndef __ASM_CPU_OPS_H */
47