xref: /openbmc/linux/arch/mips/include/asm/smp-ops.h (revision d7955ce4)
1 /*
2  * This file is subject to the terms and conditions of the GNU General
3  * Public License.  See the file "COPYING" in the main directory of this
4  * archive for more details.
5  *
6  * Copyright (C) 2000 - 2001 by Kanoj Sarcar (kanoj@sgi.com)
7  * Copyright (C) 2000 - 2001 by Silicon Graphics, Inc.
8  * Copyright (C) 2000, 2001, 2002 Ralf Baechle
9  * Copyright (C) 2000, 2001 Broadcom Corporation
10  */
11 #ifndef __ASM_SMP_OPS_H
12 #define __ASM_SMP_OPS_H
13 
14 #include <linux/errno.h>
15 
16 #include <asm/mips-cps.h>
17 
18 #ifdef CONFIG_SMP
19 
20 #include <linux/cpumask.h>
21 
22 struct task_struct;
23 
24 struct plat_smp_ops {
25 	void (*send_ipi_single)(int cpu, unsigned int action);
26 	void (*send_ipi_mask)(const struct cpumask *mask, unsigned int action);
27 	void (*init_secondary)(void);
28 	void (*smp_finish)(void);
29 	int (*boot_secondary)(int cpu, struct task_struct *idle);
30 	void (*smp_setup)(void);
31 	void (*prepare_cpus)(unsigned int max_cpus);
32 	void (*prepare_boot_cpu)(void);
33 #ifdef CONFIG_HOTPLUG_CPU
34 	int (*cpu_disable)(void);
35 	void (*cpu_die)(unsigned int cpu);
36 	void (*cleanup_dead_cpu)(unsigned cpu);
37 #endif
38 #ifdef CONFIG_KEXEC
39 	void (*kexec_nonboot_cpu)(void);
40 #endif
41 };
42 
43 extern void register_smp_ops(const struct plat_smp_ops *ops);
44 
45 static inline void plat_smp_setup(void)
46 {
47 	extern const struct plat_smp_ops *mp_ops;	/* private */
48 
49 	mp_ops->smp_setup();
50 }
51 
52 extern void mips_smp_send_ipi_single(int cpu, unsigned int action);
53 extern void mips_smp_send_ipi_mask(const struct cpumask *mask,
54 				      unsigned int action);
55 
56 #else /* !CONFIG_SMP */
57 
58 struct plat_smp_ops;
59 
60 static inline void plat_smp_setup(void)
61 {
62 	/* UP, nothing to do ...  */
63 }
64 
65 static inline void register_smp_ops(const struct plat_smp_ops *ops)
66 {
67 }
68 
69 #endif /* !CONFIG_SMP */
70 
71 static inline int register_up_smp_ops(void)
72 {
73 #ifdef CONFIG_SMP_UP
74 	extern const struct plat_smp_ops up_smp_ops;
75 
76 	register_smp_ops(&up_smp_ops);
77 
78 	return 0;
79 #else
80 	return -ENODEV;
81 #endif
82 }
83 
84 static inline int register_vsmp_smp_ops(void)
85 {
86 #ifdef CONFIG_MIPS_MT_SMP
87 	extern const struct plat_smp_ops vsmp_smp_ops;
88 
89 	if (!cpu_has_mipsmt)
90 		return -ENODEV;
91 
92 	register_smp_ops(&vsmp_smp_ops);
93 
94 	return 0;
95 #else
96 	return -ENODEV;
97 #endif
98 }
99 
100 #ifdef CONFIG_MIPS_CPS
101 extern int register_cps_smp_ops(void);
102 #else
103 static inline int register_cps_smp_ops(void)
104 {
105 	return -ENODEV;
106 }
107 #endif
108 
109 #endif /* __ASM_SMP_OPS_H */
110