1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * Copyright 2009 Freescale Semiconductor, Inc.
5 * provides masks and opcode images for use by code generation, emulation
6 * and for instructions that older assemblers might not know about
8 #ifndef _ASM_POWERPC_DBELL_H
9 #define _ASM_POWERPC_DBELL_H
11 #include <linux/smp.h>
12 #include <linux/threads.h>
14 #include <asm/ppc-opcode.h>
15 #include <asm/feature-fixups.h>
17 #define PPC_DBELL_MSG_BRDCAST (0x04000000)
18 #define PPC_DBELL_TYPE(x) (((x) & 0xf) << (63-36))
19 #define PPC_DBELL_TYPE_MASK PPC_DBELL_TYPE(0xf)
20 #define PPC_DBELL_LPID(x) ((x) << (63 - 49))
21 #define PPC_DBELL_PIR_MASK 0x3fff
23 PPC_DBELL
= 0, /* doorbell */
24 PPC_DBELL_CRIT
= 1, /* critical doorbell */
25 PPC_G_DBELL
= 2, /* guest doorbell */
26 PPC_G_DBELL_CRIT
= 3, /* guest critical doorbell */
27 PPC_G_DBELL_MC
= 4, /* guest mcheck doorbell */
28 PPC_DBELL_SERVER
= 5, /* doorbell on server */
31 #ifdef CONFIG_PPC_BOOK3S
33 #define PPC_DBELL_MSGTYPE PPC_DBELL_SERVER
35 static inline void _ppc_msgsnd(u32 msg
)
37 __asm__
__volatile__ (ASM_FTR_IFSET(PPC_MSGSND(%1), PPC_MSGSNDP(%1), %0)
38 : : "i" (CPU_FTR_HVMODE
), "r" (msg
));
41 /* sync before sending message */
42 static inline void ppc_msgsnd_sync(void)
44 __asm__
__volatile__ ("sync" : : : "memory");
47 /* sync after taking message interrupt */
48 static inline void ppc_msgsync(void)
50 /* sync is not required when taking messages from the same core */
51 __asm__
__volatile__ (ASM_FTR_IFSET(PPC_MSGSYNC
" ; lwsync", "", %0)
52 : : "i" (CPU_FTR_HVMODE
|CPU_FTR_ARCH_300
));
55 static inline void _ppc_msgclr(u32 msg
)
57 __asm__
__volatile__ (ASM_FTR_IFSET(PPC_MSGCLR(%1), PPC_MSGCLRP(%1), %0)
58 : : "i" (CPU_FTR_HVMODE
), "r" (msg
));
61 static inline void ppc_msgclr(enum ppc_dbell type
)
63 u32 msg
= PPC_DBELL_TYPE(type
);
68 #else /* CONFIG_PPC_BOOK3S */
70 #define PPC_DBELL_MSGTYPE PPC_DBELL
72 static inline void _ppc_msgsnd(u32 msg
)
74 __asm__
__volatile__ (PPC_MSGSND(%0) : : "r" (msg
));
77 /* sync before sending message */
78 static inline void ppc_msgsnd_sync(void)
80 __asm__
__volatile__ ("sync" : : : "memory");
83 /* sync after taking message interrupt */
84 static inline void ppc_msgsync(void)
88 #endif /* CONFIG_PPC_BOOK3S */
90 extern void doorbell_global_ipi(int cpu
);
91 extern void doorbell_core_ipi(int cpu
);
92 extern int doorbell_try_core_ipi(int cpu
);
93 extern void doorbell_exception(struct pt_regs
*regs
);
95 static inline void ppc_msgsnd(enum ppc_dbell type
, u32 flags
, u32 tag
)
97 u32 msg
= PPC_DBELL_TYPE(type
) | (flags
& PPC_DBELL_MSG_BRDCAST
) |
103 #endif /* _ASM_POWERPC_DBELL_H */