.. | .. |
---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-only */ |
---|
1 | 2 | /* |
---|
2 | 3 | * arch/arm64/include/asm/arch_gicv3.h |
---|
3 | 4 | * |
---|
4 | 5 | * 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/>. |
---|
17 | 6 | */ |
---|
18 | 7 | #ifndef __ASM_ARCH_GICV3_H |
---|
19 | 8 | #define __ASM_ARCH_GICV3_H |
---|
.. | .. |
---|
22 | 11 | |
---|
23 | 12 | #ifndef __ASSEMBLY__ |
---|
24 | 13 | |
---|
| 14 | +#include <linux/irqchip/arm-gic-common.h> |
---|
25 | 15 | #include <linux/stringify.h> |
---|
26 | 16 | #include <asm/barrier.h> |
---|
27 | 17 | #include <asm/cacheflush.h> |
---|
.. | .. |
---|
42 | 32 | isb(); |
---|
43 | 33 | } |
---|
44 | 34 | |
---|
45 | | -static inline void gic_write_dir(u32 irq) |
---|
| 35 | +static __always_inline void gic_write_dir(u32 irq) |
---|
46 | 36 | { |
---|
47 | 37 | write_sysreg_s(irq, SYS_ICC_DIR_EL1); |
---|
48 | 38 | isb(); |
---|
.. | .. |
---|
114 | 104 | write_sysreg_s(val, SYS_ICC_BPR1_EL1); |
---|
115 | 105 | } |
---|
116 | 106 | |
---|
| 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 | + |
---|
117 | 122 | #define gic_read_typer(c) readq_relaxed(c) |
---|
118 | 123 | #define gic_write_irouter(v, c) writeq_relaxed(v, c) |
---|
119 | 124 | #define gic_read_lpir(c) readq_relaxed(c) |
---|
.. | .. |
---|
135 | 140 | #define gicr_write_pendbaser(v, c) writeq_relaxed(v, c) |
---|
136 | 141 | #define gicr_read_pendbaser(c) readq_relaxed(c) |
---|
137 | 142 | |
---|
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) |
---|
139 | 145 | |
---|
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 | +} |
---|
142 | 178 | |
---|
143 | 179 | #endif /* __ASSEMBLY__ */ |
---|
144 | 180 | #endif /* __ASM_ARCH_GICV3_H */ |
---|