forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/arch/arm64/include/asm/arch_gicv3.h
....@@ -1,19 +1,8 @@
1
+/* SPDX-License-Identifier: GPL-2.0-only */
12 /*
23 * arch/arm64/include/asm/arch_gicv3.h
34 *
45 * Copyright (C) 2015 ARM Ltd.
5
- *
6
- * This program is free software: you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License version 2 as
8
- * published by the Free Software Foundation.
9
- *
10
- * This program is distributed in the hope that it will be useful,
11
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
- * GNU General Public License for more details.
14
- *
15
- * You should have received a copy of the GNU General Public License
16
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
176 */
187 #ifndef __ASM_ARCH_GICV3_H
198 #define __ASM_ARCH_GICV3_H
....@@ -22,6 +11,7 @@
2211
2312 #ifndef __ASSEMBLY__
2413
14
+#include <linux/irqchip/arm-gic-common.h>
2515 #include <linux/stringify.h>
2616 #include <asm/barrier.h>
2717 #include <asm/cacheflush.h>
....@@ -42,7 +32,7 @@
4232 isb();
4333 }
4434
45
-static inline void gic_write_dir(u32 irq)
35
+static __always_inline void gic_write_dir(u32 irq)
4636 {
4737 write_sysreg_s(irq, SYS_ICC_DIR_EL1);
4838 isb();
....@@ -114,6 +104,21 @@
114104 write_sysreg_s(val, SYS_ICC_BPR1_EL1);
115105 }
116106
107
+static inline u32 gic_read_pmr(void)
108
+{
109
+ return read_sysreg_s(SYS_ICC_PMR_EL1);
110
+}
111
+
112
+static __always_inline void gic_write_pmr(u32 val)
113
+{
114
+ write_sysreg_s(val, SYS_ICC_PMR_EL1);
115
+}
116
+
117
+static inline u32 gic_read_rpr(void)
118
+{
119
+ return read_sysreg_s(SYS_ICC_RPR_EL1);
120
+}
121
+
117122 #define gic_read_typer(c) readq_relaxed(c)
118123 #define gic_write_irouter(v, c) writeq_relaxed(v, c)
119124 #define gic_read_lpir(c) readq_relaxed(c)
....@@ -135,10 +140,41 @@
135140 #define gicr_write_pendbaser(v, c) writeq_relaxed(v, c)
136141 #define gicr_read_pendbaser(c) readq_relaxed(c)
137142
138
-#define gits_write_vpropbaser(v, c) writeq_relaxed(v, c)
143
+#define gicr_write_vpropbaser(v, c) writeq_relaxed(v, c)
144
+#define gicr_read_vpropbaser(c) readq_relaxed(c)
139145
140
-#define gits_write_vpendbaser(v, c) writeq_relaxed(v, c)
141
-#define gits_read_vpendbaser(c) readq_relaxed(c)
146
+#define gicr_write_vpendbaser(v, c) writeq_relaxed(v, c)
147
+#define gicr_read_vpendbaser(c) readq_relaxed(c)
148
+
149
+static inline bool gic_prio_masking_enabled(void)
150
+{
151
+ return system_uses_irq_prio_masking();
152
+}
153
+
154
+static inline void gic_pmr_mask_irqs(void)
155
+{
156
+ BUILD_BUG_ON(GICD_INT_DEF_PRI < (__GIC_PRIO_IRQOFF |
157
+ GIC_PRIO_PSR_I_SET));
158
+ BUILD_BUG_ON(GICD_INT_DEF_PRI >= GIC_PRIO_IRQON);
159
+ /*
160
+ * Need to make sure IRQON allows IRQs when SCR_EL3.FIQ is cleared
161
+ * and non-secure PMR accesses are not subject to the shifts that
162
+ * are applied to IRQ priorities
163
+ */
164
+ BUILD_BUG_ON((0x80 | (GICD_INT_DEF_PRI >> 1)) >= GIC_PRIO_IRQON);
165
+ /*
166
+ * Same situation as above, but now we make sure that we can mask
167
+ * regular interrupts.
168
+ */
169
+ BUILD_BUG_ON((0x80 | (GICD_INT_DEF_PRI >> 1)) < (__GIC_PRIO_IRQOFF_NS |
170
+ GIC_PRIO_PSR_I_SET));
171
+ gic_write_pmr(GIC_PRIO_IRQOFF);
172
+}
173
+
174
+static inline void gic_arch_enable_irqs(void)
175
+{
176
+ asm volatile ("msr daifclr, #2" : : : "memory");
177
+}
142178
143179 #endif /* __ASSEMBLY__ */
144180 #endif /* __ASM_ARCH_GICV3_H */