]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/blame - arch/powerpc/include/asm/dbell.h
treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152
[mirror_ubuntu-eoan-kernel.git] / arch / powerpc / include / asm / dbell.h
CommitLineData
2874c5fd 1/* SPDX-License-Identifier: GPL-2.0-or-later */
620165f9 2/*
8a56e1ee 3 * Copyright 2009 Freescale Semiconductor, Inc.
620165f9 4 *
620165f9
KG
5 * provides masks and opcode images for use by code generation, emulation
6 * and for instructions that older assemblers might not know about
7 */
8#ifndef _ASM_POWERPC_DBELL_H
9#define _ASM_POWERPC_DBELL_H
10
11#include <linux/smp.h>
12#include <linux/threads.h>
13
14#include <asm/ppc-opcode.h>
2c86cd18 15#include <asm/feature-fixups.h>
620165f9
KG
16
17#define PPC_DBELL_MSG_BRDCAST (0x04000000)
dc28518f 18#define PPC_DBELL_TYPE(x) (((x) & 0xf) << (63-36))
4ab96919 19#define PPC_DBELL_TYPE_MASK PPC_DBELL_TYPE(0xf)
d30f6e48 20#define PPC_DBELL_LPID(x) ((x) << (63 - 49))
4ab96919 21#define PPC_DBELL_PIR_MASK 0x3fff
620165f9
KG
22enum ppc_dbell {
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 */
42d02b81 28 PPC_DBELL_SERVER = 5, /* doorbell on server */
620165f9
KG
29};
30
42d02b81
IM
31#ifdef CONFIG_PPC_BOOK3S
32
33#define PPC_DBELL_MSGTYPE PPC_DBELL_SERVER
42d02b81 34
919ca868
IM
35static inline void _ppc_msgsnd(u32 msg)
36{
a5adf282
NP
37 __asm__ __volatile__ (ASM_FTR_IFSET(PPC_MSGSND(%1), PPC_MSGSNDP(%1), %0)
38 : : "i" (CPU_FTR_HVMODE), "r" (msg));
919ca868
IM
39}
40
b87ac021
NP
41/* sync before sending message */
42static inline void ppc_msgsnd_sync(void)
43{
44 __asm__ __volatile__ ("sync" : : : "memory");
45}
46
47/* sync after taking message interrupt */
48static inline void ppc_msgsync(void)
49{
6b3edefe
NP
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));
b87ac021
NP
53}
54
a9af97aa
NP
55static inline void _ppc_msgclr(u32 msg)
56{
57 __asm__ __volatile__ (ASM_FTR_IFSET(PPC_MSGCLR(%1), PPC_MSGCLRP(%1), %0)
58 : : "i" (CPU_FTR_HVMODE), "r" (msg));
59}
60
61static inline void ppc_msgclr(enum ppc_dbell type)
62{
63 u32 msg = PPC_DBELL_TYPE(type);
64
65 _ppc_msgclr(msg);
66}
67
42d02b81
IM
68#else /* CONFIG_PPC_BOOK3S */
69
70#define PPC_DBELL_MSGTYPE PPC_DBELL
42d02b81 71
919ca868
IM
72static inline void _ppc_msgsnd(u32 msg)
73{
74 __asm__ __volatile__ (PPC_MSGSND(%0) : : "r" (msg));
75}
76
b87ac021
NP
77/* sync before sending message */
78static inline void ppc_msgsnd_sync(void)
79{
80 __asm__ __volatile__ ("sync" : : : "memory");
81}
82
83/* sync after taking message interrupt */
84static inline void ppc_msgsync(void)
85{
86}
87
42d02b81
IM
88#endif /* CONFIG_PPC_BOOK3S */
89
b866cc21
NP
90extern void doorbell_global_ipi(int cpu);
91extern void doorbell_core_ipi(int cpu);
92extern int doorbell_try_core_ipi(int cpu);
b9f1cd71 93extern void doorbell_exception(struct pt_regs *regs);
620165f9
KG
94
95static inline void ppc_msgsnd(enum ppc_dbell type, u32 flags, u32 tag)
96{
97 u32 msg = PPC_DBELL_TYPE(type) | (flags & PPC_DBELL_MSG_BRDCAST) |
98 (tag & 0x07ffffff);
99
919ca868 100 _ppc_msgsnd(msg);
620165f9
KG
101}
102
103#endif /* _ASM_POWERPC_DBELL_H */