blob: 65618ff1280c9687e0eeeb9aa14ac90311a88915 [file] [log] [blame]
Ralf Baechle87353d82007-11-19 12:23:51 +00001/*
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
Ralf Baechle4f55fd72011-06-01 14:20:09 +010014#include <linux/errno.h>
15
Paul Burtone83f7e02017-08-12 19:49:41 -070016#include <asm/mips-cps.h>
Paul Burton237036d2014-01-15 10:31:54 +000017
Ralf Baechle87353d82007-11-19 12:23:51 +000018#ifdef CONFIG_SMP
19
20#include <linux/cpumask.h>
21
Ralf Baechlef5fd02a2009-03-25 14:41:09 +010022struct task_struct;
23
Ralf Baechle87353d82007-11-19 12:23:51 +000024struct plat_smp_ops {
25 void (*send_ipi_single)(int cpu, unsigned int action);
Rusty Russell48a048f2009-09-24 09:34:44 -060026 void (*send_ipi_mask)(const struct cpumask *mask, unsigned int action);
Ralf Baechle87353d82007-11-19 12:23:51 +000027 void (*init_secondary)(void);
28 void (*smp_finish)(void);
Paul Burtond595d422017-08-12 19:49:40 -070029 int (*boot_secondary)(int cpu, struct task_struct *idle);
Ralf Baechle87353d82007-11-19 12:23:51 +000030 void (*smp_setup)(void);
31 void (*prepare_cpus)(unsigned int max_cpus);
Thomas Bogendoerfer2c865622019-02-19 16:57:19 +010032 void (*prepare_boot_cpu)(void);
Ralf Baechle1b2bc752009-06-23 10:00:31 +010033#ifdef CONFIG_HOTPLUG_CPU
34 int (*cpu_disable)(void);
35 void (*cpu_die)(unsigned int cpu);
36#endif
Dengcheng Zhu62cac482018-09-11 14:49:21 -070037#ifdef CONFIG_KEXEC
38 void (*kexec_nonboot_cpu)(void);
39#endif
Ralf Baechle87353d82007-11-19 12:23:51 +000040};
41
Matt Redfearnff2c8252017-07-19 09:21:03 +010042extern void register_smp_ops(const struct plat_smp_ops *ops);
Ralf Baechle87353d82007-11-19 12:23:51 +000043
44static inline void plat_smp_setup(void)
45{
Matt Redfearnff2c8252017-07-19 09:21:03 +010046 extern const struct plat_smp_ops *mp_ops; /* private */
Ralf Baechle87353d82007-11-19 12:23:51 +000047
48 mp_ops->smp_setup();
49}
50
Qais Yousefbb11cff2015-12-08 13:20:28 +000051extern void mips_smp_send_ipi_single(int cpu, unsigned int action);
52extern void mips_smp_send_ipi_mask(const struct cpumask *mask,
53 unsigned int action);
Paul Burtonb9660872014-03-24 10:19:33 +000054
Ralf Baechle87353d82007-11-19 12:23:51 +000055#else /* !CONFIG_SMP */
56
57struct plat_smp_ops;
58
59static inline void plat_smp_setup(void)
60{
61 /* UP, nothing to do ... */
62}
63
Matt Redfearnff2c8252017-07-19 09:21:03 +010064static inline void register_smp_ops(const struct plat_smp_ops *ops)
Ralf Baechle87353d82007-11-19 12:23:51 +000065{
66}
67
68#endif /* !CONFIG_SMP */
69
Ralf Baechle852fe312011-05-28 15:27:59 +010070static inline int register_up_smp_ops(void)
71{
72#ifdef CONFIG_SMP_UP
Matt Redfearnff2c8252017-07-19 09:21:03 +010073 extern const struct plat_smp_ops up_smp_ops;
Ralf Baechle852fe312011-05-28 15:27:59 +010074
75 register_smp_ops(&up_smp_ops);
76
77 return 0;
78#else
79 return -ENODEV;
80#endif
81}
82
83static inline int register_cmp_smp_ops(void)
84{
85#ifdef CONFIG_MIPS_CMP
Matt Redfearnff2c8252017-07-19 09:21:03 +010086 extern const struct plat_smp_ops cmp_smp_ops;
Ralf Baechle852fe312011-05-28 15:27:59 +010087
Paul Burton237036d2014-01-15 10:31:54 +000088 if (!mips_cm_present())
89 return -ENODEV;
90
Ralf Baechle852fe312011-05-28 15:27:59 +010091 register_smp_ops(&cmp_smp_ops);
92
93 return 0;
94#else
95 return -ENODEV;
96#endif
97}
98
99static inline int register_vsmp_smp_ops(void)
100{
101#ifdef CONFIG_MIPS_MT_SMP
Matt Redfearnff2c8252017-07-19 09:21:03 +0100102 extern const struct plat_smp_ops vsmp_smp_ops;
Ralf Baechle852fe312011-05-28 15:27:59 +0100103
104 register_smp_ops(&vsmp_smp_ops);
105
106 return 0;
107#else
108 return -ENODEV;
109#endif
110}
Ralf Baechle87353d82007-11-19 12:23:51 +0000111
Paul Burton0ee958e2014-01-15 10:31:53 +0000112#ifdef CONFIG_MIPS_CPS
113extern int register_cps_smp_ops(void);
114#else
115static inline int register_cps_smp_ops(void)
116{
117 return -ENODEV;
118}
119#endif
120
Ralf Baechle87353d82007-11-19 12:23:51 +0000121#endif /* __ASM_SMP_OPS_H */