1/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef __ASM_SH_SMP_H
3#define __ASM_SH_SMP_H
4
5#include <linux/bitops.h>
6#include <linux/cpumask.h>
7#include <asm/smp-ops.h>
8
9#ifdef CONFIG_SMP
10
11#include <linux/atomic.h>
12#include <asm/current.h>
13#include <asm/percpu.h>
14
15#define raw_smp_processor_id()	(current_thread_info()->cpu)
16
17/* Map from cpu id to sequential logical cpu number. */
18extern int __cpu_number_map[NR_CPUS];
19#define cpu_number_map(cpu)  __cpu_number_map[cpu]
20
21/* The reverse map from sequential logical cpu number to cpu id.  */
22extern int __cpu_logical_map[NR_CPUS];
23#define cpu_logical_map(cpu)  __cpu_logical_map[cpu]
24
25enum {
26	SMP_MSG_FUNCTION,
27	SMP_MSG_RESCHEDULE,
28	SMP_MSG_FUNCTION_SINGLE,
29	SMP_MSG_TIMER,
30
31	SMP_MSG_NR,	/* must be last */
32};
33
34DECLARE_PER_CPU(int, cpu_state);
35
36void smp_message_recv(unsigned int msg);
37
38void arch_send_call_function_single_ipi(int cpu);
39void arch_send_call_function_ipi_mask(const struct cpumask *mask);
40
41void native_play_dead(void);
42void native_cpu_die(unsigned int cpu);
43int native_cpu_disable(unsigned int cpu);
44
45#ifdef CONFIG_HOTPLUG_CPU
46void play_dead_common(void);
47extern int __cpu_disable(void);
48
49static inline void __cpu_die(unsigned int cpu)
50{
51	extern struct plat_smp_ops *mp_ops;     /* private */
52
53	mp_ops->cpu_die(cpu);
54}
55#endif
56
57static inline int hard_smp_processor_id(void)
58{
59	extern struct plat_smp_ops *mp_ops;	/* private */
60
61	if (!mp_ops)
62		return 0;	/* boot CPU */
63
64	return mp_ops->smp_processor_id();
65}
66
67struct of_cpu_method {
68	const char *method;
69	struct plat_smp_ops *ops;
70};
71
72#define CPU_METHOD_OF_DECLARE(name, _method, _ops)			\
73	static const struct of_cpu_method __cpu_method_of_table_##name	\
74		__used __section("__cpu_method_of_table")		\
75		= { .method = _method, .ops = _ops }
76
77#else
78
79#define hard_smp_processor_id()	(0)
80
81#endif /* CONFIG_SMP */
82
83#endif /* __ASM_SH_SMP_H */
84