xref: /openbmc/linux/arch/sh/include/asm/smp.h (revision cbecf716ca618fd44feda6bd9a64a8179d031fc5)
1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
2f15cbe6fSPaul Mundt #ifndef __ASM_SH_SMP_H
3f15cbe6fSPaul Mundt #define __ASM_SH_SMP_H
4f15cbe6fSPaul Mundt 
5f15cbe6fSPaul Mundt #include <linux/bitops.h>
6f15cbe6fSPaul Mundt #include <linux/cpumask.h>
73366e358SPaul Mundt #include <asm/smp-ops.h>
8f15cbe6fSPaul Mundt 
9f15cbe6fSPaul Mundt #ifdef CONFIG_SMP
10f15cbe6fSPaul Mundt 
1160063497SArun Sharma #include <linux/atomic.h>
12f15cbe6fSPaul Mundt #include <asm/current.h>
139715b8c7SPaul Mundt #include <asm/percpu.h>
14f15cbe6fSPaul Mundt 
15f15cbe6fSPaul Mundt #define raw_smp_processor_id()	(current_thread_info()->cpu)
16f15cbe6fSPaul Mundt 
17f15cbe6fSPaul Mundt /* Map from cpu id to sequential logical cpu number. */
18f15cbe6fSPaul Mundt extern int __cpu_number_map[NR_CPUS];
19f15cbe6fSPaul Mundt #define cpu_number_map(cpu)  __cpu_number_map[cpu]
20f15cbe6fSPaul Mundt 
21f15cbe6fSPaul Mundt /* The reverse map from sequential logical cpu number to cpu id.  */
22f15cbe6fSPaul Mundt extern int __cpu_logical_map[NR_CPUS];
23f15cbe6fSPaul Mundt #define cpu_logical_map(cpu)  __cpu_logical_map[cpu]
24f15cbe6fSPaul Mundt 
256f52707eSPaul Mundt enum {
266f52707eSPaul Mundt 	SMP_MSG_FUNCTION,
276f52707eSPaul Mundt 	SMP_MSG_RESCHEDULE,
286f52707eSPaul Mundt 	SMP_MSG_FUNCTION_SINGLE,
296f52707eSPaul Mundt 	SMP_MSG_TIMER,
306f52707eSPaul Mundt 
316f52707eSPaul Mundt 	SMP_MSG_NR,	/* must be last */
326f52707eSPaul Mundt };
33f15cbe6fSPaul Mundt 
349715b8c7SPaul Mundt DECLARE_PER_CPU(int, cpu_state);
359715b8c7SPaul Mundt 
36173a44ddSPaul Mundt void smp_message_recv(unsigned int msg);
378c24594dSPaul Mundt 
386f52707eSPaul Mundt void arch_send_call_function_single_ipi(int cpu);
39763142d1SPaul Mundt void arch_send_call_function_ipi_mask(const struct cpumask *mask);
40763142d1SPaul Mundt 
41763142d1SPaul Mundt void native_play_dead(void);
42763142d1SPaul Mundt void native_cpu_die(unsigned int cpu);
43763142d1SPaul Mundt int native_cpu_disable(unsigned int cpu);
44763142d1SPaul Mundt 
45763142d1SPaul Mundt #ifdef CONFIG_HOTPLUG_CPU
46763142d1SPaul Mundt void play_dead_common(void);
47763142d1SPaul Mundt extern int __cpu_disable(void);
48763142d1SPaul Mundt 
__cpu_die(unsigned int cpu)49763142d1SPaul Mundt static inline void __cpu_die(unsigned int cpu)
50763142d1SPaul Mundt {
51763142d1SPaul Mundt 	extern struct plat_smp_ops *mp_ops;     /* private */
52763142d1SPaul Mundt 
53763142d1SPaul Mundt 	mp_ops->cpu_die(cpu);
54763142d1SPaul Mundt }
55763142d1SPaul Mundt #endif
56f15cbe6fSPaul Mundt 
hard_smp_processor_id(void)573366e358SPaul Mundt static inline int hard_smp_processor_id(void)
583366e358SPaul Mundt {
593366e358SPaul Mundt 	extern struct plat_smp_ops *mp_ops;	/* private */
603366e358SPaul Mundt 
613366e358SPaul Mundt 	if (!mp_ops)
623366e358SPaul Mundt 		return 0;	/* boot CPU */
633366e358SPaul Mundt 
643366e358SPaul Mundt 	return mp_ops->smp_processor_id();
653366e358SPaul Mundt }
663366e358SPaul Mundt 
67044b81f8SRich Felker struct of_cpu_method {
68044b81f8SRich Felker 	const char *method;
69044b81f8SRich Felker 	struct plat_smp_ops *ops;
70044b81f8SRich Felker };
71044b81f8SRich Felker 
72044b81f8SRich Felker #define CPU_METHOD_OF_DECLARE(name, _method, _ops)			\
73044b81f8SRich Felker 	static const struct of_cpu_method __cpu_method_of_table_##name	\
74*33def849SJoe Perches 		__used __section("__cpu_method_of_table")		\
75044b81f8SRich Felker 		= { .method = _method, .ops = _ops }
76044b81f8SRich Felker 
77f15cbe6fSPaul Mundt #else
78f15cbe6fSPaul Mundt 
79f15cbe6fSPaul Mundt #define hard_smp_processor_id()	(0)
80f15cbe6fSPaul Mundt 
81f15cbe6fSPaul Mundt #endif /* CONFIG_SMP */
82f15cbe6fSPaul Mundt 
83f15cbe6fSPaul Mundt #endif /* __ASM_SH_SMP_H */
84