Marc Zyngier | 021f653 | 2014-06-30 16:01:31 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2013, 2014 ARM Limited, All Rights Reserved. |
| 3 | * Author: Marc Zyngier <marc.zyngier@arm.com> |
| 4 | * |
| 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 | */ |
| 18 | #ifndef __LINUX_IRQCHIP_ARM_GIC_V3_H |
| 19 | #define __LINUX_IRQCHIP_ARM_GIC_V3_H |
| 20 | |
| 21 | /* |
| 22 | * Distributor registers. We assume we're running non-secure, with ARE |
| 23 | * being set. Secure-only and non-ARE registers are not described. |
| 24 | */ |
| 25 | #define GICD_CTLR 0x0000 |
| 26 | #define GICD_TYPER 0x0004 |
| 27 | #define GICD_IIDR 0x0008 |
| 28 | #define GICD_STATUSR 0x0010 |
| 29 | #define GICD_SETSPI_NSR 0x0040 |
| 30 | #define GICD_CLRSPI_NSR 0x0048 |
| 31 | #define GICD_SETSPI_SR 0x0050 |
| 32 | #define GICD_CLRSPI_SR 0x0058 |
| 33 | #define GICD_SEIR 0x0068 |
Andre Przywara | a0675c2 | 2014-06-07 00:54:51 +0200 | [diff] [blame] | 34 | #define GICD_IGROUPR 0x0080 |
Marc Zyngier | 021f653 | 2014-06-30 16:01:31 +0100 | [diff] [blame] | 35 | #define GICD_ISENABLER 0x0100 |
| 36 | #define GICD_ICENABLER 0x0180 |
| 37 | #define GICD_ISPENDR 0x0200 |
| 38 | #define GICD_ICPENDR 0x0280 |
| 39 | #define GICD_ISACTIVER 0x0300 |
| 40 | #define GICD_ICACTIVER 0x0380 |
| 41 | #define GICD_IPRIORITYR 0x0400 |
| 42 | #define GICD_ICFGR 0x0C00 |
Andre Przywara | a0675c2 | 2014-06-07 00:54:51 +0200 | [diff] [blame] | 43 | #define GICD_IGRPMODR 0x0D00 |
| 44 | #define GICD_NSACR 0x0E00 |
Marc Zyngier | 021f653 | 2014-06-30 16:01:31 +0100 | [diff] [blame] | 45 | #define GICD_IROUTER 0x6000 |
Andre Przywara | a0675c2 | 2014-06-07 00:54:51 +0200 | [diff] [blame] | 46 | #define GICD_IDREGS 0xFFD0 |
Marc Zyngier | 021f653 | 2014-06-30 16:01:31 +0100 | [diff] [blame] | 47 | #define GICD_PIDR2 0xFFE8 |
| 48 | |
Andre Przywara | a0675c2 | 2014-06-07 00:54:51 +0200 | [diff] [blame] | 49 | /* |
| 50 | * Those registers are actually from GICv2, but the spec demands that they |
| 51 | * are implemented as RES0 if ARE is 1 (which we do in KVM's emulated GICv3). |
| 52 | */ |
| 53 | #define GICD_ITARGETSR 0x0800 |
| 54 | #define GICD_SGIR 0x0F00 |
| 55 | #define GICD_CPENDSGIR 0x0F10 |
| 56 | #define GICD_SPENDSGIR 0x0F20 |
| 57 | |
Marc Zyngier | 021f653 | 2014-06-30 16:01:31 +0100 | [diff] [blame] | 58 | #define GICD_CTLR_RWP (1U << 31) |
Andre Przywara | a0675c2 | 2014-06-07 00:54:51 +0200 | [diff] [blame] | 59 | #define GICD_CTLR_DS (1U << 6) |
Marc Zyngier | 021f653 | 2014-06-30 16:01:31 +0100 | [diff] [blame] | 60 | #define GICD_CTLR_ARE_NS (1U << 4) |
| 61 | #define GICD_CTLR_ENABLE_G1A (1U << 1) |
| 62 | #define GICD_CTLR_ENABLE_G1 (1U << 0) |
| 63 | |
Christoffer Dall | a2dca21 | 2018-07-16 15:06:18 +0200 | [diff] [blame^] | 64 | #define GICD_IIDR_IMPLEMENTER_SHIFT 0 |
| 65 | #define GICD_IIDR_IMPLEMENTER_MASK (0xfff << GICD_IIDR_IMPLEMENTER_SHIFT) |
| 66 | #define GICD_IIDR_REVISION_SHIFT 12 |
| 67 | #define GICD_IIDR_REVISION_MASK (0xf << GICD_IIDR_REVISION_SHIFT) |
| 68 | #define GICD_IIDR_VARIANT_SHIFT 16 |
| 69 | #define GICD_IIDR_VARIANT_MASK (0xf << GICD_IIDR_VARIANT_SHIFT) |
| 70 | #define GICD_IIDR_PRODUCT_ID_SHIFT 24 |
| 71 | #define GICD_IIDR_PRODUCT_ID_MASK (0xff << GICD_IIDR_PRODUCT_ID_SHIFT) |
| 72 | |
| 73 | |
Andre Przywara | a0675c2 | 2014-06-07 00:54:51 +0200 | [diff] [blame] | 74 | /* |
| 75 | * In systems with a single security state (what we emulate in KVM) |
| 76 | * the meaning of the interrupt group enable bits is slightly different |
| 77 | */ |
| 78 | #define GICD_CTLR_ENABLE_SS_G1 (1U << 1) |
| 79 | #define GICD_CTLR_ENABLE_SS_G0 (1U << 0) |
| 80 | |
Shanker Donthineni | eda0d04 | 2017-10-06 10:24:00 -0500 | [diff] [blame] | 81 | #define GICD_TYPER_RSS (1U << 26) |
Andre Przywara | a0675c2 | 2014-06-07 00:54:51 +0200 | [diff] [blame] | 82 | #define GICD_TYPER_LPIS (1U << 17) |
| 83 | #define GICD_TYPER_MBIS (1U << 16) |
| 84 | |
Marc Zyngier | f5c1434 | 2014-11-24 14:35:10 +0000 | [diff] [blame] | 85 | #define GICD_TYPER_ID_BITS(typer) ((((typer) >> 19) & 0x1f) + 1) |
| 86 | #define GICD_TYPER_IRQS(typer) ((((typer) & 0x1f) + 1) * 32) |
Marc Zyngier | f5c1434 | 2014-11-24 14:35:10 +0000 | [diff] [blame] | 87 | |
Marc Zyngier | 021f653 | 2014-06-30 16:01:31 +0100 | [diff] [blame] | 88 | #define GICD_IROUTER_SPI_MODE_ONE (0U << 31) |
| 89 | #define GICD_IROUTER_SPI_MODE_ANY (1U << 31) |
| 90 | |
| 91 | #define GIC_PIDR2_ARCH_MASK 0xf0 |
| 92 | #define GIC_PIDR2_ARCH_GICv3 0x30 |
| 93 | #define GIC_PIDR2_ARCH_GICv4 0x40 |
| 94 | |
Andre Przywara | a0675c2 | 2014-06-07 00:54:51 +0200 | [diff] [blame] | 95 | #define GIC_V3_DIST_SIZE 0x10000 |
| 96 | |
Marc Zyngier | 021f653 | 2014-06-30 16:01:31 +0100 | [diff] [blame] | 97 | /* |
| 98 | * Re-Distributor registers, offsets from RD_base |
| 99 | */ |
| 100 | #define GICR_CTLR GICD_CTLR |
| 101 | #define GICR_IIDR 0x0004 |
| 102 | #define GICR_TYPER 0x0008 |
| 103 | #define GICR_STATUSR GICD_STATUSR |
| 104 | #define GICR_WAKER 0x0014 |
| 105 | #define GICR_SETLPIR 0x0040 |
| 106 | #define GICR_CLRLPIR 0x0048 |
| 107 | #define GICR_SEIR GICD_SEIR |
| 108 | #define GICR_PROPBASER 0x0070 |
| 109 | #define GICR_PENDBASER 0x0078 |
| 110 | #define GICR_INVLPIR 0x00A0 |
| 111 | #define GICR_INVALLR 0x00B0 |
| 112 | #define GICR_SYNCR 0x00C0 |
| 113 | #define GICR_MOVLPIR 0x0100 |
| 114 | #define GICR_MOVALLR 0x0110 |
Andre Przywara | a0675c2 | 2014-06-07 00:54:51 +0200 | [diff] [blame] | 115 | #define GICR_IDREGS GICD_IDREGS |
Marc Zyngier | 021f653 | 2014-06-30 16:01:31 +0100 | [diff] [blame] | 116 | #define GICR_PIDR2 GICD_PIDR2 |
| 117 | |
Marc Zyngier | cc2d321 | 2014-11-24 14:35:11 +0000 | [diff] [blame] | 118 | #define GICR_CTLR_ENABLE_LPIS (1UL << 0) |
Shanker Donthineni | 6eb486b | 2018-03-21 20:58:49 -0500 | [diff] [blame] | 119 | #define GICR_CTLR_RWP (1UL << 3) |
Marc Zyngier | cc2d321 | 2014-11-24 14:35:11 +0000 | [diff] [blame] | 120 | |
| 121 | #define GICR_TYPER_CPU_NUMBER(r) (((r) >> 8) & 0xffff) |
| 122 | |
Marc Zyngier | 021f653 | 2014-06-30 16:01:31 +0100 | [diff] [blame] | 123 | #define GICR_WAKER_ProcessorSleep (1U << 1) |
| 124 | #define GICR_WAKER_ChildrenAsleep (1U << 2) |
| 125 | |
Andre Przywara | 645b9e4 | 2016-07-15 12:43:28 +0100 | [diff] [blame] | 126 | #define GIC_BASER_CACHE_nCnB 0ULL |
| 127 | #define GIC_BASER_CACHE_SameAsInner 0ULL |
| 128 | #define GIC_BASER_CACHE_nC 1ULL |
| 129 | #define GIC_BASER_CACHE_RaWt 2ULL |
| 130 | #define GIC_BASER_CACHE_RaWb 3ULL |
| 131 | #define GIC_BASER_CACHE_WaWt 4ULL |
| 132 | #define GIC_BASER_CACHE_WaWb 5ULL |
| 133 | #define GIC_BASER_CACHE_RaWaWt 6ULL |
| 134 | #define GIC_BASER_CACHE_RaWaWb 7ULL |
| 135 | #define GIC_BASER_CACHE_MASK 7ULL |
| 136 | #define GIC_BASER_NonShareable 0ULL |
| 137 | #define GIC_BASER_InnerShareable 1ULL |
| 138 | #define GIC_BASER_OuterShareable 2ULL |
| 139 | #define GIC_BASER_SHAREABILITY_MASK 3ULL |
Marc Zyngier | cc2d321 | 2014-11-24 14:35:11 +0000 | [diff] [blame] | 140 | |
Andre Przywara | 645b9e4 | 2016-07-15 12:43:28 +0100 | [diff] [blame] | 141 | #define GIC_BASER_CACHEABILITY(reg, inner_outer, type) \ |
| 142 | (GIC_BASER_CACHE_##type << reg##_##inner_outer##_CACHEABILITY_SHIFT) |
| 143 | |
| 144 | #define GIC_BASER_SHAREABILITY(reg, type) \ |
| 145 | (GIC_BASER_##type << reg##_SHAREABILITY_SHIFT) |
| 146 | |
Eric Auger | 71afe47 | 2017-04-13 09:06:20 +0200 | [diff] [blame] | 147 | /* encode a size field of width @w containing @n - 1 units */ |
| 148 | #define GIC_ENCODE_SZ(n, w) (((unsigned long)(n) - 1) & GENMASK_ULL(((w) - 1), 0)) |
| 149 | |
Andre Przywara | 645b9e4 | 2016-07-15 12:43:28 +0100 | [diff] [blame] | 150 | #define GICR_PROPBASER_SHAREABILITY_SHIFT (10) |
| 151 | #define GICR_PROPBASER_INNER_CACHEABILITY_SHIFT (7) |
| 152 | #define GICR_PROPBASER_OUTER_CACHEABILITY_SHIFT (56) |
| 153 | #define GICR_PROPBASER_SHAREABILITY_MASK \ |
| 154 | GIC_BASER_SHAREABILITY(GICR_PROPBASER, SHAREABILITY_MASK) |
| 155 | #define GICR_PROPBASER_INNER_CACHEABILITY_MASK \ |
| 156 | GIC_BASER_CACHEABILITY(GICR_PROPBASER, INNER, MASK) |
| 157 | #define GICR_PROPBASER_OUTER_CACHEABILITY_MASK \ |
| 158 | GIC_BASER_CACHEABILITY(GICR_PROPBASER, OUTER, MASK) |
| 159 | #define GICR_PROPBASER_CACHEABILITY_MASK GICR_PROPBASER_INNER_CACHEABILITY_MASK |
| 160 | |
| 161 | #define GICR_PROPBASER_InnerShareable \ |
| 162 | GIC_BASER_SHAREABILITY(GICR_PROPBASER, InnerShareable) |
Marc Zyngier | 8c828a5 | 2016-07-18 15:28:52 +0100 | [diff] [blame] | 163 | |
| 164 | #define GICR_PROPBASER_nCnB GIC_BASER_CACHEABILITY(GICR_PROPBASER, INNER, nCnB) |
| 165 | #define GICR_PROPBASER_nC GIC_BASER_CACHEABILITY(GICR_PROPBASER, INNER, nC) |
| 166 | #define GICR_PROPBASER_RaWt GIC_BASER_CACHEABILITY(GICR_PROPBASER, INNER, RaWt) |
| 167 | #define GICR_PROPBASER_RaWb GIC_BASER_CACHEABILITY(GICR_PROPBASER, INNER, RaWt) |
| 168 | #define GICR_PROPBASER_WaWt GIC_BASER_CACHEABILITY(GICR_PROPBASER, INNER, WaWt) |
| 169 | #define GICR_PROPBASER_WaWb GIC_BASER_CACHEABILITY(GICR_PROPBASER, INNER, WaWb) |
| 170 | #define GICR_PROPBASER_RaWaWt GIC_BASER_CACHEABILITY(GICR_PROPBASER, INNER, RaWaWt) |
| 171 | #define GICR_PROPBASER_RaWaWb GIC_BASER_CACHEABILITY(GICR_PROPBASER, INNER, RaWaWb) |
| 172 | |
Andre Przywara | 645b9e4 | 2016-07-15 12:43:28 +0100 | [diff] [blame] | 173 | #define GICR_PROPBASER_IDBITS_MASK (0x1f) |
Eric Auger | 44de9d6 | 2017-05-04 11:19:52 +0200 | [diff] [blame] | 174 | #define GICR_PROPBASER_ADDRESS(x) ((x) & GENMASK_ULL(51, 12)) |
| 175 | #define GICR_PENDBASER_ADDRESS(x) ((x) & GENMASK_ULL(51, 16)) |
Andre Przywara | 645b9e4 | 2016-07-15 12:43:28 +0100 | [diff] [blame] | 176 | |
| 177 | #define GICR_PENDBASER_SHAREABILITY_SHIFT (10) |
| 178 | #define GICR_PENDBASER_INNER_CACHEABILITY_SHIFT (7) |
| 179 | #define GICR_PENDBASER_OUTER_CACHEABILITY_SHIFT (56) |
| 180 | #define GICR_PENDBASER_SHAREABILITY_MASK \ |
| 181 | GIC_BASER_SHAREABILITY(GICR_PENDBASER, SHAREABILITY_MASK) |
| 182 | #define GICR_PENDBASER_INNER_CACHEABILITY_MASK \ |
| 183 | GIC_BASER_CACHEABILITY(GICR_PENDBASER, INNER, MASK) |
| 184 | #define GICR_PENDBASER_OUTER_CACHEABILITY_MASK \ |
| 185 | GIC_BASER_CACHEABILITY(GICR_PENDBASER, OUTER, MASK) |
| 186 | #define GICR_PENDBASER_CACHEABILITY_MASK GICR_PENDBASER_INNER_CACHEABILITY_MASK |
| 187 | |
| 188 | #define GICR_PENDBASER_InnerShareable \ |
| 189 | GIC_BASER_SHAREABILITY(GICR_PENDBASER, InnerShareable) |
Marc Zyngier | 8c828a5 | 2016-07-18 15:28:52 +0100 | [diff] [blame] | 190 | |
| 191 | #define GICR_PENDBASER_nCnB GIC_BASER_CACHEABILITY(GICR_PENDBASER, INNER, nCnB) |
| 192 | #define GICR_PENDBASER_nC GIC_BASER_CACHEABILITY(GICR_PENDBASER, INNER, nC) |
| 193 | #define GICR_PENDBASER_RaWt GIC_BASER_CACHEABILITY(GICR_PENDBASER, INNER, RaWt) |
| 194 | #define GICR_PENDBASER_RaWb GIC_BASER_CACHEABILITY(GICR_PENDBASER, INNER, RaWt) |
| 195 | #define GICR_PENDBASER_WaWt GIC_BASER_CACHEABILITY(GICR_PENDBASER, INNER, WaWt) |
| 196 | #define GICR_PENDBASER_WaWb GIC_BASER_CACHEABILITY(GICR_PENDBASER, INNER, WaWb) |
| 197 | #define GICR_PENDBASER_RaWaWt GIC_BASER_CACHEABILITY(GICR_PENDBASER, INNER, RaWaWt) |
| 198 | #define GICR_PENDBASER_RaWaWb GIC_BASER_CACHEABILITY(GICR_PENDBASER, INNER, RaWaWb) |
| 199 | |
Andre Przywara | 645b9e4 | 2016-07-15 12:43:28 +0100 | [diff] [blame] | 200 | #define GICR_PENDBASER_PTZ BIT_ULL(62) |
Marc Zyngier | 4ad3e36 | 2015-03-27 14:15:04 +0000 | [diff] [blame] | 201 | |
Marc Zyngier | 021f653 | 2014-06-30 16:01:31 +0100 | [diff] [blame] | 202 | /* |
| 203 | * Re-Distributor registers, offsets from SGI_base |
| 204 | */ |
Andre Przywara | a0675c2 | 2014-06-07 00:54:51 +0200 | [diff] [blame] | 205 | #define GICR_IGROUPR0 GICD_IGROUPR |
Marc Zyngier | 021f653 | 2014-06-30 16:01:31 +0100 | [diff] [blame] | 206 | #define GICR_ISENABLER0 GICD_ISENABLER |
| 207 | #define GICR_ICENABLER0 GICD_ICENABLER |
| 208 | #define GICR_ISPENDR0 GICD_ISPENDR |
| 209 | #define GICR_ICPENDR0 GICD_ICPENDR |
| 210 | #define GICR_ISACTIVER0 GICD_ISACTIVER |
| 211 | #define GICR_ICACTIVER0 GICD_ICACTIVER |
| 212 | #define GICR_IPRIORITYR0 GICD_IPRIORITYR |
| 213 | #define GICR_ICFGR0 GICD_ICFGR |
Andre Przywara | a0675c2 | 2014-06-07 00:54:51 +0200 | [diff] [blame] | 214 | #define GICR_IGRPMODR0 GICD_IGRPMODR |
| 215 | #define GICR_NSACR GICD_NSACR |
Marc Zyngier | 021f653 | 2014-06-30 16:01:31 +0100 | [diff] [blame] | 216 | |
Marc Zyngier | cc2d321 | 2014-11-24 14:35:11 +0000 | [diff] [blame] | 217 | #define GICR_TYPER_PLPIS (1U << 0) |
Marc Zyngier | 021f653 | 2014-06-30 16:01:31 +0100 | [diff] [blame] | 218 | #define GICR_TYPER_VLPIS (1U << 1) |
Marc Zyngier | 0edc23e | 2016-12-19 17:01:52 +0000 | [diff] [blame] | 219 | #define GICR_TYPER_DirectLPIS (1U << 3) |
Marc Zyngier | 021f653 | 2014-06-30 16:01:31 +0100 | [diff] [blame] | 220 | #define GICR_TYPER_LAST (1U << 4) |
| 221 | |
Andre Przywara | a0675c2 | 2014-06-07 00:54:51 +0200 | [diff] [blame] | 222 | #define GIC_V3_REDIST_SIZE 0x20000 |
| 223 | |
Marc Zyngier | cc2d321 | 2014-11-24 14:35:11 +0000 | [diff] [blame] | 224 | #define LPI_PROP_GROUP1 (1 << 1) |
| 225 | #define LPI_PROP_ENABLED (1 << 0) |
| 226 | |
Marc Zyngier | e643d80 | 2016-12-20 15:09:31 +0000 | [diff] [blame] | 227 | /* |
| 228 | * Re-Distributor registers, offsets from VLPI_base |
| 229 | */ |
| 230 | #define GICR_VPROPBASER 0x0070 |
| 231 | |
| 232 | #define GICR_VPROPBASER_IDBITS_MASK 0x1f |
| 233 | |
| 234 | #define GICR_VPROPBASER_SHAREABILITY_SHIFT (10) |
| 235 | #define GICR_VPROPBASER_INNER_CACHEABILITY_SHIFT (7) |
| 236 | #define GICR_VPROPBASER_OUTER_CACHEABILITY_SHIFT (56) |
| 237 | |
| 238 | #define GICR_VPROPBASER_SHAREABILITY_MASK \ |
| 239 | GIC_BASER_SHAREABILITY(GICR_VPROPBASER, SHAREABILITY_MASK) |
| 240 | #define GICR_VPROPBASER_INNER_CACHEABILITY_MASK \ |
| 241 | GIC_BASER_CACHEABILITY(GICR_VPROPBASER, INNER, MASK) |
| 242 | #define GICR_VPROPBASER_OUTER_CACHEABILITY_MASK \ |
| 243 | GIC_BASER_CACHEABILITY(GICR_VPROPBASER, OUTER, MASK) |
| 244 | #define GICR_VPROPBASER_CACHEABILITY_MASK \ |
| 245 | GICR_VPROPBASER_INNER_CACHEABILITY_MASK |
| 246 | |
| 247 | #define GICR_VPROPBASER_InnerShareable \ |
| 248 | GIC_BASER_SHAREABILITY(GICR_VPROPBASER, InnerShareable) |
| 249 | |
| 250 | #define GICR_VPROPBASER_nCnB GIC_BASER_CACHEABILITY(GICR_VPROPBASER, INNER, nCnB) |
| 251 | #define GICR_VPROPBASER_nC GIC_BASER_CACHEABILITY(GICR_VPROPBASER, INNER, nC) |
| 252 | #define GICR_VPROPBASER_RaWt GIC_BASER_CACHEABILITY(GICR_VPROPBASER, INNER, RaWt) |
| 253 | #define GICR_VPROPBASER_RaWb GIC_BASER_CACHEABILITY(GICR_VPROPBASER, INNER, RaWt) |
| 254 | #define GICR_VPROPBASER_WaWt GIC_BASER_CACHEABILITY(GICR_VPROPBASER, INNER, WaWt) |
| 255 | #define GICR_VPROPBASER_WaWb GIC_BASER_CACHEABILITY(GICR_VPROPBASER, INNER, WaWb) |
| 256 | #define GICR_VPROPBASER_RaWaWt GIC_BASER_CACHEABILITY(GICR_VPROPBASER, INNER, RaWaWt) |
| 257 | #define GICR_VPROPBASER_RaWaWb GIC_BASER_CACHEABILITY(GICR_VPROPBASER, INNER, RaWaWb) |
| 258 | |
| 259 | #define GICR_VPENDBASER 0x0078 |
| 260 | |
| 261 | #define GICR_VPENDBASER_SHAREABILITY_SHIFT (10) |
| 262 | #define GICR_VPENDBASER_INNER_CACHEABILITY_SHIFT (7) |
| 263 | #define GICR_VPENDBASER_OUTER_CACHEABILITY_SHIFT (56) |
| 264 | #define GICR_VPENDBASER_SHAREABILITY_MASK \ |
| 265 | GIC_BASER_SHAREABILITY(GICR_VPENDBASER, SHAREABILITY_MASK) |
| 266 | #define GICR_VPENDBASER_INNER_CACHEABILITY_MASK \ |
| 267 | GIC_BASER_CACHEABILITY(GICR_VPENDBASER, INNER, MASK) |
| 268 | #define GICR_VPENDBASER_OUTER_CACHEABILITY_MASK \ |
| 269 | GIC_BASER_CACHEABILITY(GICR_VPENDBASER, OUTER, MASK) |
| 270 | #define GICR_VPENDBASER_CACHEABILITY_MASK \ |
| 271 | GICR_VPENDBASER_INNER_CACHEABILITY_MASK |
| 272 | |
| 273 | #define GICR_VPENDBASER_NonShareable \ |
| 274 | GIC_BASER_SHAREABILITY(GICR_VPENDBASER, NonShareable) |
| 275 | |
| 276 | #define GICR_VPENDBASER_nCnB GIC_BASER_CACHEABILITY(GICR_VPENDBASER, INNER, nCnB) |
| 277 | #define GICR_VPENDBASER_nC GIC_BASER_CACHEABILITY(GICR_VPENDBASER, INNER, nC) |
| 278 | #define GICR_VPENDBASER_RaWt GIC_BASER_CACHEABILITY(GICR_VPENDBASER, INNER, RaWt) |
| 279 | #define GICR_VPENDBASER_RaWb GIC_BASER_CACHEABILITY(GICR_VPENDBASER, INNER, RaWt) |
| 280 | #define GICR_VPENDBASER_WaWt GIC_BASER_CACHEABILITY(GICR_VPENDBASER, INNER, WaWt) |
| 281 | #define GICR_VPENDBASER_WaWb GIC_BASER_CACHEABILITY(GICR_VPENDBASER, INNER, WaWb) |
| 282 | #define GICR_VPENDBASER_RaWaWt GIC_BASER_CACHEABILITY(GICR_VPENDBASER, INNER, RaWaWt) |
| 283 | #define GICR_VPENDBASER_RaWaWb GIC_BASER_CACHEABILITY(GICR_VPENDBASER, INNER, RaWaWb) |
| 284 | |
Marc Zyngier | 3ca63f3 | 2017-01-03 13:39:52 +0000 | [diff] [blame] | 285 | #define GICR_VPENDBASER_Dirty (1ULL << 60) |
| 286 | #define GICR_VPENDBASER_PendingLast (1ULL << 61) |
| 287 | #define GICR_VPENDBASER_IDAI (1ULL << 62) |
| 288 | #define GICR_VPENDBASER_Valid (1ULL << 63) |
| 289 | |
Marc Zyngier | cc2d321 | 2014-11-24 14:35:11 +0000 | [diff] [blame] | 290 | /* |
| 291 | * ITS registers, offsets from ITS_base |
| 292 | */ |
| 293 | #define GITS_CTLR 0x0000 |
| 294 | #define GITS_IIDR 0x0004 |
| 295 | #define GITS_TYPER 0x0008 |
| 296 | #define GITS_CBASER 0x0080 |
| 297 | #define GITS_CWRITER 0x0088 |
| 298 | #define GITS_CREADR 0x0090 |
| 299 | #define GITS_BASER 0x0100 |
Andre Przywara | 645b9e4 | 2016-07-15 12:43:28 +0100 | [diff] [blame] | 300 | #define GITS_IDREGS_BASE 0xffd0 |
| 301 | #define GITS_PIDR0 0xffe0 |
| 302 | #define GITS_PIDR1 0xffe4 |
Marc Zyngier | cc2d321 | 2014-11-24 14:35:11 +0000 | [diff] [blame] | 303 | #define GITS_PIDR2 GICR_PIDR2 |
Andre Przywara | 645b9e4 | 2016-07-15 12:43:28 +0100 | [diff] [blame] | 304 | #define GITS_PIDR4 0xffd0 |
| 305 | #define GITS_CIDR0 0xfff0 |
| 306 | #define GITS_CIDR1 0xfff4 |
| 307 | #define GITS_CIDR2 0xfff8 |
| 308 | #define GITS_CIDR3 0xfffc |
Marc Zyngier | cc2d321 | 2014-11-24 14:35:11 +0000 | [diff] [blame] | 309 | |
| 310 | #define GITS_TRANSLATER 0x10040 |
| 311 | |
Yun Wu | 7cb9911 | 2015-03-06 16:37:49 +0000 | [diff] [blame] | 312 | #define GITS_CTLR_ENABLE (1U << 0) |
Marc Zyngier | d51c4b4 | 2017-06-27 21:24:25 +0100 | [diff] [blame] | 313 | #define GITS_CTLR_ImDe (1U << 1) |
Marc Zyngier | 3dfa576 | 2016-12-19 17:25:54 +0000 | [diff] [blame] | 314 | #define GITS_CTLR_ITS_NUMBER_SHIFT 4 |
| 315 | #define GITS_CTLR_ITS_NUMBER (0xFU << GITS_CTLR_ITS_NUMBER_SHIFT) |
Yun Wu | 7cb9911 | 2015-03-06 16:37:49 +0000 | [diff] [blame] | 316 | #define GITS_CTLR_QUIESCENT (1U << 31) |
| 317 | |
Andre Przywara | 645b9e4 | 2016-07-15 12:43:28 +0100 | [diff] [blame] | 318 | #define GITS_TYPER_PLPIS (1UL << 0) |
Marc Zyngier | 3dfa576 | 2016-12-19 17:25:54 +0000 | [diff] [blame] | 319 | #define GITS_TYPER_VLPIS (1UL << 1) |
Eric Auger | 71afe47 | 2017-04-13 09:06:20 +0200 | [diff] [blame] | 320 | #define GITS_TYPER_ITT_ENTRY_SIZE_SHIFT 4 |
Marc Zyngier | 3dfa576 | 2016-12-19 17:25:54 +0000 | [diff] [blame] | 321 | #define GITS_TYPER_ITT_ENTRY_SIZE(r) ((((r) >> GITS_TYPER_ITT_ENTRY_SIZE_SHIFT) & 0x1f) + 1) |
Andre Przywara | 645b9e4 | 2016-07-15 12:43:28 +0100 | [diff] [blame] | 322 | #define GITS_TYPER_IDBITS_SHIFT 8 |
Marc Zyngier | f54b97e | 2015-03-06 16:37:41 +0000 | [diff] [blame] | 323 | #define GITS_TYPER_DEVBITS_SHIFT 13 |
| 324 | #define GITS_TYPER_DEVBITS(r) ((((r) >> GITS_TYPER_DEVBITS_SHIFT) & 0x1f) + 1) |
Marc Zyngier | cc2d321 | 2014-11-24 14:35:11 +0000 | [diff] [blame] | 325 | #define GITS_TYPER_PTA (1UL << 19) |
Derek Basehore | dba0bc7 | 2018-02-28 21:48:18 -0800 | [diff] [blame] | 326 | #define GITS_TYPER_HCC_SHIFT 24 |
| 327 | #define GITS_TYPER_HCC(r) (((r) >> GITS_TYPER_HCC_SHIFT) & 0xff) |
Marc Zyngier | 3dfa576 | 2016-12-19 17:25:54 +0000 | [diff] [blame] | 328 | #define GITS_TYPER_VMOVP (1ULL << 37) |
Marc Zyngier | cc2d321 | 2014-11-24 14:35:11 +0000 | [diff] [blame] | 329 | |
Eric Auger | ab01c6b | 2017-03-23 15:14:00 +0100 | [diff] [blame] | 330 | #define GITS_IIDR_REV_SHIFT 12 |
| 331 | #define GITS_IIDR_REV_MASK (0xf << GITS_IIDR_REV_SHIFT) |
| 332 | #define GITS_IIDR_REV(r) (((r) >> GITS_IIDR_REV_SHIFT) & 0xf) |
| 333 | #define GITS_IIDR_PRODUCTID_SHIFT 24 |
| 334 | |
Vladimir Murzin | b11283e | 2016-11-02 11:54:03 +0000 | [diff] [blame] | 335 | #define GITS_CBASER_VALID (1ULL << 63) |
Andre Przywara | 645b9e4 | 2016-07-15 12:43:28 +0100 | [diff] [blame] | 336 | #define GITS_CBASER_SHAREABILITY_SHIFT (10) |
| 337 | #define GITS_CBASER_INNER_CACHEABILITY_SHIFT (59) |
| 338 | #define GITS_CBASER_OUTER_CACHEABILITY_SHIFT (53) |
| 339 | #define GITS_CBASER_SHAREABILITY_MASK \ |
| 340 | GIC_BASER_SHAREABILITY(GITS_CBASER, SHAREABILITY_MASK) |
| 341 | #define GITS_CBASER_INNER_CACHEABILITY_MASK \ |
| 342 | GIC_BASER_CACHEABILITY(GITS_CBASER, INNER, MASK) |
| 343 | #define GITS_CBASER_OUTER_CACHEABILITY_MASK \ |
| 344 | GIC_BASER_CACHEABILITY(GITS_CBASER, OUTER, MASK) |
| 345 | #define GITS_CBASER_CACHEABILITY_MASK GITS_CBASER_INNER_CACHEABILITY_MASK |
| 346 | |
| 347 | #define GITS_CBASER_InnerShareable \ |
| 348 | GIC_BASER_SHAREABILITY(GITS_CBASER, InnerShareable) |
Marc Zyngier | 8c828a5 | 2016-07-18 15:28:52 +0100 | [diff] [blame] | 349 | |
| 350 | #define GITS_CBASER_nCnB GIC_BASER_CACHEABILITY(GITS_CBASER, INNER, nCnB) |
| 351 | #define GITS_CBASER_nC GIC_BASER_CACHEABILITY(GITS_CBASER, INNER, nC) |
| 352 | #define GITS_CBASER_RaWt GIC_BASER_CACHEABILITY(GITS_CBASER, INNER, RaWt) |
| 353 | #define GITS_CBASER_RaWb GIC_BASER_CACHEABILITY(GITS_CBASER, INNER, RaWt) |
| 354 | #define GITS_CBASER_WaWt GIC_BASER_CACHEABILITY(GITS_CBASER, INNER, WaWt) |
| 355 | #define GITS_CBASER_WaWb GIC_BASER_CACHEABILITY(GITS_CBASER, INNER, WaWb) |
| 356 | #define GITS_CBASER_RaWaWt GIC_BASER_CACHEABILITY(GITS_CBASER, INNER, RaWaWt) |
| 357 | #define GITS_CBASER_RaWaWb GIC_BASER_CACHEABILITY(GITS_CBASER, INNER, RaWaWb) |
Marc Zyngier | cc2d321 | 2014-11-24 14:35:11 +0000 | [diff] [blame] | 358 | |
| 359 | #define GITS_BASER_NR_REGS 8 |
| 360 | |
Vladimir Murzin | b11283e | 2016-11-02 11:54:03 +0000 | [diff] [blame] | 361 | #define GITS_BASER_VALID (1ULL << 63) |
Andre Przywara | 645b9e4 | 2016-07-15 12:43:28 +0100 | [diff] [blame] | 362 | #define GITS_BASER_INDIRECT (1ULL << 62) |
Marc Zyngier | 8c828a5 | 2016-07-18 15:28:52 +0100 | [diff] [blame] | 363 | |
Andre Przywara | 645b9e4 | 2016-07-15 12:43:28 +0100 | [diff] [blame] | 364 | #define GITS_BASER_INNER_CACHEABILITY_SHIFT (59) |
| 365 | #define GITS_BASER_OUTER_CACHEABILITY_SHIFT (53) |
| 366 | #define GITS_BASER_INNER_CACHEABILITY_MASK \ |
| 367 | GIC_BASER_CACHEABILITY(GITS_BASER, INNER, MASK) |
Marc Zyngier | 8c828a5 | 2016-07-18 15:28:52 +0100 | [diff] [blame] | 368 | #define GITS_BASER_CACHEABILITY_MASK GITS_BASER_INNER_CACHEABILITY_MASK |
Andre Przywara | 645b9e4 | 2016-07-15 12:43:28 +0100 | [diff] [blame] | 369 | #define GITS_BASER_OUTER_CACHEABILITY_MASK \ |
| 370 | GIC_BASER_CACHEABILITY(GITS_BASER, OUTER, MASK) |
| 371 | #define GITS_BASER_SHAREABILITY_MASK \ |
| 372 | GIC_BASER_SHAREABILITY(GITS_BASER, SHAREABILITY_MASK) |
| 373 | |
Marc Zyngier | 8c828a5 | 2016-07-18 15:28:52 +0100 | [diff] [blame] | 374 | #define GITS_BASER_nCnB GIC_BASER_CACHEABILITY(GITS_BASER, INNER, nCnB) |
| 375 | #define GITS_BASER_nC GIC_BASER_CACHEABILITY(GITS_BASER, INNER, nC) |
| 376 | #define GITS_BASER_RaWt GIC_BASER_CACHEABILITY(GITS_BASER, INNER, RaWt) |
| 377 | #define GITS_BASER_RaWb GIC_BASER_CACHEABILITY(GITS_BASER, INNER, RaWt) |
| 378 | #define GITS_BASER_WaWt GIC_BASER_CACHEABILITY(GITS_BASER, INNER, WaWt) |
| 379 | #define GITS_BASER_WaWb GIC_BASER_CACHEABILITY(GITS_BASER, INNER, WaWb) |
| 380 | #define GITS_BASER_RaWaWt GIC_BASER_CACHEABILITY(GITS_BASER, INNER, RaWaWt) |
| 381 | #define GITS_BASER_RaWaWb GIC_BASER_CACHEABILITY(GITS_BASER, INNER, RaWaWb) |
| 382 | |
Andre Przywara | 645b9e4 | 2016-07-15 12:43:28 +0100 | [diff] [blame] | 383 | #define GITS_BASER_TYPE_SHIFT (56) |
Marc Zyngier | cc2d321 | 2014-11-24 14:35:11 +0000 | [diff] [blame] | 384 | #define GITS_BASER_TYPE(r) (((r) >> GITS_BASER_TYPE_SHIFT) & 7) |
Andre Przywara | 645b9e4 | 2016-07-15 12:43:28 +0100 | [diff] [blame] | 385 | #define GITS_BASER_ENTRY_SIZE_SHIFT (48) |
Vladimir Murzin | 9224eb7 | 2016-10-17 16:00:46 +0100 | [diff] [blame] | 386 | #define GITS_BASER_ENTRY_SIZE(r) ((((r) >> GITS_BASER_ENTRY_SIZE_SHIFT) & 0x1f) + 1) |
Eric Auger | 71afe47 | 2017-04-13 09:06:20 +0200 | [diff] [blame] | 387 | #define GITS_BASER_ENTRY_SIZE_MASK GENMASK_ULL(52, 48) |
Shanker Donthineni | 30ae961 | 2017-10-09 11:46:55 -0500 | [diff] [blame] | 388 | #define GITS_BASER_PHYS_52_to_48(phys) \ |
| 389 | (((phys) & GENMASK_ULL(47, 16)) | (((phys) >> 48) & 0xf) << 12) |
Marc Zyngier | cc2d321 | 2014-11-24 14:35:11 +0000 | [diff] [blame] | 390 | #define GITS_BASER_SHAREABILITY_SHIFT (10) |
Andre Przywara | 645b9e4 | 2016-07-15 12:43:28 +0100 | [diff] [blame] | 391 | #define GITS_BASER_InnerShareable \ |
| 392 | GIC_BASER_SHAREABILITY(GITS_BASER, InnerShareable) |
Marc Zyngier | cc2d321 | 2014-11-24 14:35:11 +0000 | [diff] [blame] | 393 | #define GITS_BASER_PAGE_SIZE_SHIFT (8) |
Vladimir Murzin | e29bd6f | 2016-11-02 11:55:33 +0000 | [diff] [blame] | 394 | #define GITS_BASER_PAGE_SIZE_4K (0ULL << GITS_BASER_PAGE_SIZE_SHIFT) |
| 395 | #define GITS_BASER_PAGE_SIZE_16K (1ULL << GITS_BASER_PAGE_SIZE_SHIFT) |
| 396 | #define GITS_BASER_PAGE_SIZE_64K (2ULL << GITS_BASER_PAGE_SIZE_SHIFT) |
| 397 | #define GITS_BASER_PAGE_SIZE_MASK (3ULL << GITS_BASER_PAGE_SIZE_SHIFT) |
Robert Richter | 30f2136 | 2015-09-21 22:58:34 +0200 | [diff] [blame] | 398 | #define GITS_BASER_PAGES_MAX 256 |
Shanker Donthineni | 9347359 | 2016-06-06 18:17:30 -0500 | [diff] [blame] | 399 | #define GITS_BASER_PAGES_SHIFT (0) |
Andre Przywara | 645b9e4 | 2016-07-15 12:43:28 +0100 | [diff] [blame] | 400 | #define GITS_BASER_NR_PAGES(r) (((r) & 0xff) + 1) |
Marc Zyngier | cc2d321 | 2014-11-24 14:35:11 +0000 | [diff] [blame] | 401 | |
| 402 | #define GITS_BASER_TYPE_NONE 0 |
| 403 | #define GITS_BASER_TYPE_DEVICE 1 |
| 404 | #define GITS_BASER_TYPE_VCPU 2 |
Marc Zyngier | 4f46de9 | 2016-12-20 15:50:14 +0000 | [diff] [blame] | 405 | #define GITS_BASER_TYPE_RESERVED3 3 |
Marc Zyngier | cc2d321 | 2014-11-24 14:35:11 +0000 | [diff] [blame] | 406 | #define GITS_BASER_TYPE_COLLECTION 4 |
| 407 | #define GITS_BASER_TYPE_RESERVED5 5 |
| 408 | #define GITS_BASER_TYPE_RESERVED6 6 |
| 409 | #define GITS_BASER_TYPE_RESERVED7 7 |
| 410 | |
Shanker Donthineni | 3faf24e | 2016-06-06 18:17:32 -0500 | [diff] [blame] | 411 | #define GITS_LVL1_ENTRY_SIZE (8UL) |
| 412 | |
Marc Zyngier | cc2d321 | 2014-11-24 14:35:11 +0000 | [diff] [blame] | 413 | /* |
| 414 | * ITS commands |
| 415 | */ |
| 416 | #define GITS_CMD_MAPD 0x08 |
| 417 | #define GITS_CMD_MAPC 0x09 |
Andre Przywara | 645b9e4 | 2016-07-15 12:43:28 +0100 | [diff] [blame] | 418 | #define GITS_CMD_MAPTI 0x0a |
Andre Przywara | 645b9e4 | 2016-07-15 12:43:28 +0100 | [diff] [blame] | 419 | #define GITS_CMD_MAPI 0x0b |
Marc Zyngier | cc2d321 | 2014-11-24 14:35:11 +0000 | [diff] [blame] | 420 | #define GITS_CMD_MOVI 0x01 |
| 421 | #define GITS_CMD_DISCARD 0x0f |
| 422 | #define GITS_CMD_INV 0x0c |
| 423 | #define GITS_CMD_MOVALL 0x0e |
| 424 | #define GITS_CMD_INVALL 0x0d |
| 425 | #define GITS_CMD_INT 0x03 |
| 426 | #define GITS_CMD_CLEAR 0x04 |
| 427 | #define GITS_CMD_SYNC 0x05 |
| 428 | |
Marc Zyngier | 021f653 | 2014-06-30 16:01:31 +0100 | [diff] [blame] | 429 | /* |
Marc Zyngier | d7276b8 | 2016-12-20 15:11:47 +0000 | [diff] [blame] | 430 | * GICv4 ITS specific commands |
| 431 | */ |
| 432 | #define GITS_CMD_GICv4(x) ((x) | 0x20) |
| 433 | #define GITS_CMD_VINVALL GITS_CMD_GICv4(GITS_CMD_INVALL) |
| 434 | #define GITS_CMD_VMAPP GITS_CMD_GICv4(GITS_CMD_MAPC) |
| 435 | #define GITS_CMD_VMAPTI GITS_CMD_GICv4(GITS_CMD_MAPTI) |
| 436 | #define GITS_CMD_VMOVI GITS_CMD_GICv4(GITS_CMD_MOVI) |
| 437 | #define GITS_CMD_VSYNC GITS_CMD_GICv4(GITS_CMD_SYNC) |
| 438 | /* VMOVP is the odd one, as it doesn't have a physical counterpart */ |
| 439 | #define GITS_CMD_VMOVP GITS_CMD_GICv4(2) |
| 440 | |
| 441 | /* |
Andre Przywara | 645b9e4 | 2016-07-15 12:43:28 +0100 | [diff] [blame] | 442 | * ITS error numbers |
| 443 | */ |
| 444 | #define E_ITS_MOVI_UNMAPPED_INTERRUPT 0x010107 |
| 445 | #define E_ITS_MOVI_UNMAPPED_COLLECTION 0x010109 |
Andre Przywara | fd837b0 | 2016-08-08 17:29:28 +0100 | [diff] [blame] | 446 | #define E_ITS_INT_UNMAPPED_INTERRUPT 0x010307 |
Andre Przywara | 645b9e4 | 2016-07-15 12:43:28 +0100 | [diff] [blame] | 447 | #define E_ITS_CLEAR_UNMAPPED_INTERRUPT 0x010507 |
| 448 | #define E_ITS_MAPD_DEVICE_OOR 0x010801 |
Eric Auger | 0d44cdb | 2016-12-22 18:14:14 +0100 | [diff] [blame] | 449 | #define E_ITS_MAPD_ITTSIZE_OOR 0x010802 |
Andre Przywara | 645b9e4 | 2016-07-15 12:43:28 +0100 | [diff] [blame] | 450 | #define E_ITS_MAPC_PROCNUM_OOR 0x010902 |
| 451 | #define E_ITS_MAPC_COLLECTION_OOR 0x010903 |
| 452 | #define E_ITS_MAPTI_UNMAPPED_DEVICE 0x010a04 |
Eric Auger | 0d44cdb | 2016-12-22 18:14:14 +0100 | [diff] [blame] | 453 | #define E_ITS_MAPTI_ID_OOR 0x010a05 |
Andre Przywara | 645b9e4 | 2016-07-15 12:43:28 +0100 | [diff] [blame] | 454 | #define E_ITS_MAPTI_PHYSICALID_OOR 0x010a06 |
| 455 | #define E_ITS_INV_UNMAPPED_INTERRUPT 0x010c07 |
| 456 | #define E_ITS_INVALL_UNMAPPED_COLLECTION 0x010d09 |
| 457 | #define E_ITS_MOVALL_PROCNUM_OOR 0x010e01 |
| 458 | #define E_ITS_DISCARD_UNMAPPED_INTERRUPT 0x010f07 |
| 459 | |
| 460 | /* |
Marc Zyngier | 021f653 | 2014-06-30 16:01:31 +0100 | [diff] [blame] | 461 | * CPU interface registers |
| 462 | */ |
Vijaya Kumar K | 5c34153 | 2017-01-26 19:50:49 +0530 | [diff] [blame] | 463 | #define ICC_CTLR_EL1_EOImode_SHIFT (1) |
| 464 | #define ICC_CTLR_EL1_EOImode_drop_dir (0U << ICC_CTLR_EL1_EOImode_SHIFT) |
| 465 | #define ICC_CTLR_EL1_EOImode_drop (1U << ICC_CTLR_EL1_EOImode_SHIFT) |
| 466 | #define ICC_CTLR_EL1_EOImode_MASK (1 << ICC_CTLR_EL1_EOImode_SHIFT) |
| 467 | #define ICC_CTLR_EL1_CBPR_SHIFT 0 |
| 468 | #define ICC_CTLR_EL1_CBPR_MASK (1 << ICC_CTLR_EL1_CBPR_SHIFT) |
| 469 | #define ICC_CTLR_EL1_PRI_BITS_SHIFT 8 |
| 470 | #define ICC_CTLR_EL1_PRI_BITS_MASK (0x7 << ICC_CTLR_EL1_PRI_BITS_SHIFT) |
| 471 | #define ICC_CTLR_EL1_ID_BITS_SHIFT 11 |
| 472 | #define ICC_CTLR_EL1_ID_BITS_MASK (0x7 << ICC_CTLR_EL1_ID_BITS_SHIFT) |
| 473 | #define ICC_CTLR_EL1_SEIS_SHIFT 14 |
| 474 | #define ICC_CTLR_EL1_SEIS_MASK (0x1 << ICC_CTLR_EL1_SEIS_SHIFT) |
| 475 | #define ICC_CTLR_EL1_A3V_SHIFT 15 |
| 476 | #define ICC_CTLR_EL1_A3V_MASK (0x1 << ICC_CTLR_EL1_A3V_SHIFT) |
Shanker Donthineni | eda0d04 | 2017-10-06 10:24:00 -0500 | [diff] [blame] | 477 | #define ICC_CTLR_EL1_RSS (0x1 << 18) |
Vijaya Kumar K | 5c34153 | 2017-01-26 19:50:49 +0530 | [diff] [blame] | 478 | #define ICC_PMR_EL1_SHIFT 0 |
| 479 | #define ICC_PMR_EL1_MASK (0xff << ICC_PMR_EL1_SHIFT) |
| 480 | #define ICC_BPR0_EL1_SHIFT 0 |
| 481 | #define ICC_BPR0_EL1_MASK (0x7 << ICC_BPR0_EL1_SHIFT) |
| 482 | #define ICC_BPR1_EL1_SHIFT 0 |
| 483 | #define ICC_BPR1_EL1_MASK (0x7 << ICC_BPR1_EL1_SHIFT) |
| 484 | #define ICC_IGRPEN0_EL1_SHIFT 0 |
| 485 | #define ICC_IGRPEN0_EL1_MASK (1 << ICC_IGRPEN0_EL1_SHIFT) |
| 486 | #define ICC_IGRPEN1_EL1_SHIFT 0 |
| 487 | #define ICC_IGRPEN1_EL1_MASK (1 << ICC_IGRPEN1_EL1_SHIFT) |
Marc Zyngier | 4dfc050 | 2017-02-21 11:32:47 +0000 | [diff] [blame] | 488 | #define ICC_SRE_EL1_DIB (1U << 2) |
| 489 | #define ICC_SRE_EL1_DFB (1U << 1) |
Marc Zyngier | 021f653 | 2014-06-30 16:01:31 +0100 | [diff] [blame] | 490 | #define ICC_SRE_EL1_SRE (1U << 0) |
| 491 | |
| 492 | /* |
| 493 | * Hypervisor interface registers (SRE only) |
| 494 | */ |
Jean-Philippe Brucker | f6c86a4 | 2015-10-01 13:47:15 +0100 | [diff] [blame] | 495 | #define ICH_LR_VIRTUAL_ID_MASK ((1ULL << 32) - 1) |
Marc Zyngier | 021f653 | 2014-06-30 16:01:31 +0100 | [diff] [blame] | 496 | |
Jean-Philippe Brucker | f6c86a4 | 2015-10-01 13:47:15 +0100 | [diff] [blame] | 497 | #define ICH_LR_EOI (1ULL << 41) |
| 498 | #define ICH_LR_GROUP (1ULL << 60) |
| 499 | #define ICH_LR_HW (1ULL << 61) |
| 500 | #define ICH_LR_STATE (3ULL << 62) |
| 501 | #define ICH_LR_PENDING_BIT (1ULL << 62) |
| 502 | #define ICH_LR_ACTIVE_BIT (1ULL << 63) |
Marc Zyngier | fb182cf | 2015-06-08 15:37:26 +0100 | [diff] [blame] | 503 | #define ICH_LR_PHYS_ID_SHIFT 32 |
Jean-Philippe Brucker | f6c86a4 | 2015-10-01 13:47:15 +0100 | [diff] [blame] | 504 | #define ICH_LR_PHYS_ID_MASK (0x3ffULL << ICH_LR_PHYS_ID_SHIFT) |
Marc Zyngier | 59529f6 | 2015-11-30 13:09:53 +0000 | [diff] [blame] | 505 | #define ICH_LR_PRIORITY_SHIFT 48 |
Marc Zyngier | 132a324 | 2017-06-09 12:49:36 +0100 | [diff] [blame] | 506 | #define ICH_LR_PRIORITY_MASK (0xffULL << ICH_LR_PRIORITY_SHIFT) |
Marc Zyngier | 021f653 | 2014-06-30 16:01:31 +0100 | [diff] [blame] | 507 | |
Andre Przywara | 44bfc42 | 2016-05-04 14:35:48 +0100 | [diff] [blame] | 508 | /* These are for GICv2 emulation only */ |
| 509 | #define GICH_LR_VIRTUALID (0x3ffUL << 0) |
| 510 | #define GICH_LR_PHYSID_CPUID_SHIFT (10) |
| 511 | #define GICH_LR_PHYSID_CPUID (7UL << GICH_LR_PHYSID_CPUID_SHIFT) |
Marc Zyngier | 021f653 | 2014-06-30 16:01:31 +0100 | [diff] [blame] | 512 | |
| 513 | #define ICH_MISR_EOI (1 << 0) |
| 514 | #define ICH_MISR_U (1 << 1) |
| 515 | |
| 516 | #define ICH_HCR_EN (1 << 0) |
| 517 | #define ICH_HCR_UIE (1 << 1) |
Marc Zyngier | 16ca6a6 | 2018-03-06 21:48:01 +0000 | [diff] [blame] | 518 | #define ICH_HCR_NPIE (1 << 3) |
Marc Zyngier | ff89511 | 2017-06-09 12:49:53 +0100 | [diff] [blame] | 519 | #define ICH_HCR_TC (1 << 10) |
Marc Zyngier | abf5576 | 2017-06-09 12:49:45 +0100 | [diff] [blame] | 520 | #define ICH_HCR_TALL0 (1 << 11) |
Marc Zyngier | 9c7bfc2 | 2017-06-09 12:49:40 +0100 | [diff] [blame] | 521 | #define ICH_HCR_TALL1 (1 << 12) |
Marc Zyngier | b6f4903 | 2017-06-09 12:49:37 +0100 | [diff] [blame] | 522 | #define ICH_HCR_EOIcount_SHIFT 27 |
| 523 | #define ICH_HCR_EOIcount_MASK (0x1f << ICH_HCR_EOIcount_SHIFT) |
Marc Zyngier | 021f653 | 2014-06-30 16:01:31 +0100 | [diff] [blame] | 524 | |
Christoffer Dall | 28232a4 | 2017-05-20 14:12:34 +0200 | [diff] [blame] | 525 | #define ICH_VMCR_ACK_CTL_SHIFT 2 |
| 526 | #define ICH_VMCR_ACK_CTL_MASK (1 << ICH_VMCR_ACK_CTL_SHIFT) |
| 527 | #define ICH_VMCR_FIQ_EN_SHIFT 3 |
| 528 | #define ICH_VMCR_FIQ_EN_MASK (1 << ICH_VMCR_FIQ_EN_SHIFT) |
Vijaya Kumar K | 5c34153 | 2017-01-26 19:50:49 +0530 | [diff] [blame] | 529 | #define ICH_VMCR_CBPR_SHIFT 4 |
| 530 | #define ICH_VMCR_CBPR_MASK (1 << ICH_VMCR_CBPR_SHIFT) |
| 531 | #define ICH_VMCR_EOIM_SHIFT 9 |
| 532 | #define ICH_VMCR_EOIM_MASK (1 << ICH_VMCR_EOIM_SHIFT) |
Marc Zyngier | 021f653 | 2014-06-30 16:01:31 +0100 | [diff] [blame] | 533 | #define ICH_VMCR_BPR1_SHIFT 18 |
| 534 | #define ICH_VMCR_BPR1_MASK (7 << ICH_VMCR_BPR1_SHIFT) |
| 535 | #define ICH_VMCR_BPR0_SHIFT 21 |
| 536 | #define ICH_VMCR_BPR0_MASK (7 << ICH_VMCR_BPR0_SHIFT) |
| 537 | #define ICH_VMCR_PMR_SHIFT 24 |
| 538 | #define ICH_VMCR_PMR_MASK (0xffUL << ICH_VMCR_PMR_SHIFT) |
Vijaya Kumar K | 5c34153 | 2017-01-26 19:50:49 +0530 | [diff] [blame] | 539 | #define ICH_VMCR_ENG0_SHIFT 0 |
| 540 | #define ICH_VMCR_ENG0_MASK (1 << ICH_VMCR_ENG0_SHIFT) |
| 541 | #define ICH_VMCR_ENG1_SHIFT 1 |
| 542 | #define ICH_VMCR_ENG1_MASK (1 << ICH_VMCR_ENG1_SHIFT) |
| 543 | |
| 544 | #define ICH_VTR_PRI_BITS_SHIFT 29 |
| 545 | #define ICH_VTR_PRI_BITS_MASK (7 << ICH_VTR_PRI_BITS_SHIFT) |
| 546 | #define ICH_VTR_ID_BITS_SHIFT 23 |
| 547 | #define ICH_VTR_ID_BITS_MASK (7 << ICH_VTR_ID_BITS_SHIFT) |
| 548 | #define ICH_VTR_SEIS_SHIFT 22 |
| 549 | #define ICH_VTR_SEIS_MASK (1 << ICH_VTR_SEIS_SHIFT) |
| 550 | #define ICH_VTR_A3V_SHIFT 21 |
| 551 | #define ICH_VTR_A3V_MASK (1 << ICH_VTR_A3V_SHIFT) |
Marc Zyngier | 021f653 | 2014-06-30 16:01:31 +0100 | [diff] [blame] | 552 | |
Marc Zyngier | 021f653 | 2014-06-30 16:01:31 +0100 | [diff] [blame] | 553 | #define ICC_IAR1_EL1_SPURIOUS 0x3ff |
| 554 | |
Marc Zyngier | 021f653 | 2014-06-30 16:01:31 +0100 | [diff] [blame] | 555 | #define ICC_SRE_EL2_SRE (1 << 0) |
| 556 | #define ICC_SRE_EL2_ENABLE (1 << 3) |
| 557 | |
Andre Przywara | 7e58027 | 2014-11-12 13:46:06 +0000 | [diff] [blame] | 558 | #define ICC_SGI1R_TARGET_LIST_SHIFT 0 |
| 559 | #define ICC_SGI1R_TARGET_LIST_MASK (0xffff << ICC_SGI1R_TARGET_LIST_SHIFT) |
| 560 | #define ICC_SGI1R_AFFINITY_1_SHIFT 16 |
| 561 | #define ICC_SGI1R_AFFINITY_1_MASK (0xff << ICC_SGI1R_AFFINITY_1_SHIFT) |
| 562 | #define ICC_SGI1R_SGI_ID_SHIFT 24 |
Marc Zyngier | dd5f1b0 | 2016-06-02 09:00:28 +0100 | [diff] [blame] | 563 | #define ICC_SGI1R_SGI_ID_MASK (0xfULL << ICC_SGI1R_SGI_ID_SHIFT) |
Andre Przywara | 7e58027 | 2014-11-12 13:46:06 +0000 | [diff] [blame] | 564 | #define ICC_SGI1R_AFFINITY_2_SHIFT 32 |
Andrew Jones | fab0cdc | 2016-05-12 10:46:34 +0200 | [diff] [blame] | 565 | #define ICC_SGI1R_AFFINITY_2_MASK (0xffULL << ICC_SGI1R_AFFINITY_2_SHIFT) |
Andre Przywara | 7e58027 | 2014-11-12 13:46:06 +0000 | [diff] [blame] | 566 | #define ICC_SGI1R_IRQ_ROUTING_MODE_BIT 40 |
Shanker Donthineni | eda0d04 | 2017-10-06 10:24:00 -0500 | [diff] [blame] | 567 | #define ICC_SGI1R_RS_SHIFT 44 |
| 568 | #define ICC_SGI1R_RS_MASK (0xfULL << ICC_SGI1R_RS_SHIFT) |
Andre Przywara | 7e58027 | 2014-11-12 13:46:06 +0000 | [diff] [blame] | 569 | #define ICC_SGI1R_AFFINITY_3_SHIFT 48 |
Andrew Jones | fab0cdc | 2016-05-12 10:46:34 +0200 | [diff] [blame] | 570 | #define ICC_SGI1R_AFFINITY_3_MASK (0xffULL << ICC_SGI1R_AFFINITY_3_SHIFT) |
Andre Przywara | 7e58027 | 2014-11-12 13:46:06 +0000 | [diff] [blame] | 571 | |
Jean-Philippe Brucker | 7936e91 | 2015-10-01 13:47:14 +0100 | [diff] [blame] | 572 | #include <asm/arch_gicv3.h> |
Marc Zyngier | 021f653 | 2014-06-30 16:01:31 +0100 | [diff] [blame] | 573 | |
| 574 | #ifndef __ASSEMBLY__ |
| 575 | |
Marc Zyngier | b48ac83 | 2014-11-24 14:35:16 +0000 | [diff] [blame] | 576 | /* |
| 577 | * We need a value to serve as a irq-type for LPIs. Choose one that will |
| 578 | * hopefully pique the interest of the reviewer. |
| 579 | */ |
| 580 | #define GIC_IRQ_TYPE_LPI 0xa110c8ed |
| 581 | |
Marc Zyngier | f5c1434 | 2014-11-24 14:35:10 +0000 | [diff] [blame] | 582 | struct rdists { |
| 583 | struct { |
| 584 | void __iomem *rd_base; |
| 585 | struct page *pend_page; |
| 586 | phys_addr_t phys_base; |
| 587 | } __percpu *rdist; |
| 588 | struct page *prop_page; |
| 589 | int id_bits; |
| 590 | u64 flags; |
Marc Zyngier | 0edc23e | 2016-12-19 17:01:52 +0000 | [diff] [blame] | 591 | bool has_vlpis; |
| 592 | bool has_direct_lpi; |
Marc Zyngier | f5c1434 | 2014-11-24 14:35:10 +0000 | [diff] [blame] | 593 | }; |
| 594 | |
Marc Zyngier | da33f31 | 2014-11-24 14:35:18 +0000 | [diff] [blame] | 595 | struct irq_domain; |
Tomasz Nowicki | db40f0a | 2016-09-12 20:32:24 +0200 | [diff] [blame] | 596 | struct fwnode_handle; |
Marc Zyngier | da33f31 | 2014-11-24 14:35:18 +0000 | [diff] [blame] | 597 | int its_cpu_init(void); |
Tomasz Nowicki | db40f0a | 2016-09-12 20:32:24 +0200 | [diff] [blame] | 598 | int its_init(struct fwnode_handle *handle, struct rdists *rdists, |
Marc Zyngier | da33f31 | 2014-11-24 14:35:18 +0000 | [diff] [blame] | 599 | struct irq_domain *domain); |
Marc Zyngier | 5052875 | 2018-05-08 13:14:36 +0100 | [diff] [blame] | 600 | int mbi_init(struct fwnode_handle *fwnode, struct irq_domain *parent); |
Marc Zyngier | da33f31 | 2014-11-24 14:35:18 +0000 | [diff] [blame] | 601 | |
Jean-Philippe Brucker | 7936e91 | 2015-10-01 13:47:14 +0100 | [diff] [blame] | 602 | static inline bool gic_enable_sre(void) |
| 603 | { |
| 604 | u32 val; |
| 605 | |
| 606 | val = gic_read_sre(); |
| 607 | if (val & ICC_SRE_EL1_SRE) |
| 608 | return true; |
| 609 | |
| 610 | val |= ICC_SRE_EL1_SRE; |
| 611 | gic_write_sre(val); |
| 612 | val = gic_read_sre(); |
| 613 | |
| 614 | return !!(val & ICC_SRE_EL1_SRE); |
| 615 | } |
| 616 | |
Marc Zyngier | 021f653 | 2014-06-30 16:01:31 +0100 | [diff] [blame] | 617 | #endif |
| 618 | |
| 619 | #endif |