Achin Gupta | 92712a5 | 2015-09-03 14:18:02 +0100 | [diff] [blame] | 1 | /* |
Jeenu Viswambharan | b6982c0 | 2018-03-22 08:57:52 +0000 | [diff] [blame] | 2 | * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved. |
Achin Gupta | 92712a5 | 2015-09-03 14:18:02 +0100 | [diff] [blame] | 3 | * |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | * SPDX-License-Identifier: BSD-3-Clause |
Achin Gupta | 92712a5 | 2015-09-03 14:18:02 +0100 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <assert.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 8 | |
| 9 | #include <drivers/arm/gic_common.h> |
| 10 | #include <lib/mmio.h> |
| 11 | |
Soby Mathew | 50f6fe4 | 2016-02-01 17:59:22 +0000 | [diff] [blame] | 12 | #include "gic_common_private.h" |
Achin Gupta | 92712a5 | 2015-09-03 14:18:02 +0100 | [diff] [blame] | 13 | |
| 14 | /******************************************************************************* |
| 15 | * GIC Distributor interface accessors for reading entire registers |
| 16 | ******************************************************************************/ |
| 17 | /* |
| 18 | * Accessor to read the GIC Distributor IGROUPR corresponding to the interrupt |
| 19 | * `id`, 32 interrupt ids at a time. |
| 20 | */ |
| 21 | unsigned int gicd_read_igroupr(uintptr_t base, unsigned int id) |
| 22 | { |
Antonio Nino Diaz | ca994e7 | 2018-08-21 10:02:33 +0100 | [diff] [blame] | 23 | unsigned int n = id >> IGROUPR_SHIFT; |
| 24 | |
Achin Gupta | 92712a5 | 2015-09-03 14:18:02 +0100 | [diff] [blame] | 25 | return mmio_read_32(base + GICD_IGROUPR + (n << 2)); |
| 26 | } |
| 27 | |
| 28 | /* |
| 29 | * Accessor to read the GIC Distributor ISENABLER corresponding to the |
| 30 | * interrupt `id`, 32 interrupt ids at a time. |
| 31 | */ |
| 32 | unsigned int gicd_read_isenabler(uintptr_t base, unsigned int id) |
| 33 | { |
Antonio Nino Diaz | ca994e7 | 2018-08-21 10:02:33 +0100 | [diff] [blame] | 34 | unsigned int n = id >> ISENABLER_SHIFT; |
| 35 | |
Achin Gupta | 92712a5 | 2015-09-03 14:18:02 +0100 | [diff] [blame] | 36 | return mmio_read_32(base + GICD_ISENABLER + (n << 2)); |
| 37 | } |
| 38 | |
| 39 | /* |
| 40 | * Accessor to read the GIC Distributor ICENABLER corresponding to the |
| 41 | * interrupt `id`, 32 interrupt IDs at a time. |
| 42 | */ |
| 43 | unsigned int gicd_read_icenabler(uintptr_t base, unsigned int id) |
| 44 | { |
Antonio Nino Diaz | ca994e7 | 2018-08-21 10:02:33 +0100 | [diff] [blame] | 45 | unsigned int n = id >> ICENABLER_SHIFT; |
| 46 | |
Achin Gupta | 92712a5 | 2015-09-03 14:18:02 +0100 | [diff] [blame] | 47 | return mmio_read_32(base + GICD_ICENABLER + (n << 2)); |
| 48 | } |
| 49 | |
| 50 | /* |
| 51 | * Accessor to read the GIC Distributor ISPENDR corresponding to the |
| 52 | * interrupt `id`, 32 interrupt IDs at a time. |
| 53 | */ |
| 54 | unsigned int gicd_read_ispendr(uintptr_t base, unsigned int id) |
| 55 | { |
Antonio Nino Diaz | ca994e7 | 2018-08-21 10:02:33 +0100 | [diff] [blame] | 56 | unsigned int n = id >> ISPENDR_SHIFT; |
| 57 | |
Achin Gupta | 92712a5 | 2015-09-03 14:18:02 +0100 | [diff] [blame] | 58 | return mmio_read_32(base + GICD_ISPENDR + (n << 2)); |
| 59 | } |
| 60 | |
| 61 | /* |
| 62 | * Accessor to read the GIC Distributor ICPENDR corresponding to the |
| 63 | * interrupt `id`, 32 interrupt IDs at a time. |
| 64 | */ |
| 65 | unsigned int gicd_read_icpendr(uintptr_t base, unsigned int id) |
| 66 | { |
Antonio Nino Diaz | ca994e7 | 2018-08-21 10:02:33 +0100 | [diff] [blame] | 67 | unsigned int n = id >> ICPENDR_SHIFT; |
| 68 | |
Achin Gupta | 92712a5 | 2015-09-03 14:18:02 +0100 | [diff] [blame] | 69 | return mmio_read_32(base + GICD_ICPENDR + (n << 2)); |
| 70 | } |
| 71 | |
| 72 | /* |
| 73 | * Accessor to read the GIC Distributor ISACTIVER corresponding to the |
| 74 | * interrupt `id`, 32 interrupt IDs at a time. |
| 75 | */ |
| 76 | unsigned int gicd_read_isactiver(uintptr_t base, unsigned int id) |
| 77 | { |
Antonio Nino Diaz | ca994e7 | 2018-08-21 10:02:33 +0100 | [diff] [blame] | 78 | unsigned int n = id >> ISACTIVER_SHIFT; |
| 79 | |
Achin Gupta | 92712a5 | 2015-09-03 14:18:02 +0100 | [diff] [blame] | 80 | return mmio_read_32(base + GICD_ISACTIVER + (n << 2)); |
| 81 | } |
| 82 | |
| 83 | /* |
| 84 | * Accessor to read the GIC Distributor ICACTIVER corresponding to the |
| 85 | * interrupt `id`, 32 interrupt IDs at a time. |
| 86 | */ |
| 87 | unsigned int gicd_read_icactiver(uintptr_t base, unsigned int id) |
| 88 | { |
Antonio Nino Diaz | ca994e7 | 2018-08-21 10:02:33 +0100 | [diff] [blame] | 89 | unsigned int n = id >> ICACTIVER_SHIFT; |
| 90 | |
Achin Gupta | 92712a5 | 2015-09-03 14:18:02 +0100 | [diff] [blame] | 91 | return mmio_read_32(base + GICD_ICACTIVER + (n << 2)); |
| 92 | } |
| 93 | |
| 94 | /* |
| 95 | * Accessor to read the GIC Distributor IPRIORITYR corresponding to the |
| 96 | * interrupt `id`, 4 interrupt IDs at a time. |
| 97 | */ |
| 98 | unsigned int gicd_read_ipriorityr(uintptr_t base, unsigned int id) |
| 99 | { |
Antonio Nino Diaz | ca994e7 | 2018-08-21 10:02:33 +0100 | [diff] [blame] | 100 | unsigned int n = id >> IPRIORITYR_SHIFT; |
| 101 | |
Achin Gupta | 92712a5 | 2015-09-03 14:18:02 +0100 | [diff] [blame] | 102 | return mmio_read_32(base + GICD_IPRIORITYR + (n << 2)); |
| 103 | } |
| 104 | |
| 105 | /* |
| 106 | * Accessor to read the GIC Distributor ICGFR corresponding to the |
| 107 | * interrupt `id`, 16 interrupt IDs at a time. |
| 108 | */ |
| 109 | unsigned int gicd_read_icfgr(uintptr_t base, unsigned int id) |
| 110 | { |
Antonio Nino Diaz | ca994e7 | 2018-08-21 10:02:33 +0100 | [diff] [blame] | 111 | unsigned int n = id >> ICFGR_SHIFT; |
| 112 | |
Achin Gupta | 92712a5 | 2015-09-03 14:18:02 +0100 | [diff] [blame] | 113 | return mmio_read_32(base + GICD_ICFGR + (n << 2)); |
| 114 | } |
| 115 | |
| 116 | /* |
| 117 | * Accessor to read the GIC Distributor NSACR corresponding to the |
| 118 | * interrupt `id`, 16 interrupt IDs at a time. |
| 119 | */ |
| 120 | unsigned int gicd_read_nsacr(uintptr_t base, unsigned int id) |
| 121 | { |
Antonio Nino Diaz | ca994e7 | 2018-08-21 10:02:33 +0100 | [diff] [blame] | 122 | unsigned int n = id >> NSACR_SHIFT; |
| 123 | |
Achin Gupta | 92712a5 | 2015-09-03 14:18:02 +0100 | [diff] [blame] | 124 | return mmio_read_32(base + GICD_NSACR + (n << 2)); |
| 125 | } |
| 126 | |
| 127 | /******************************************************************************* |
| 128 | * GIC Distributor interface accessors for writing entire registers |
| 129 | ******************************************************************************/ |
| 130 | /* |
| 131 | * Accessor to write the GIC Distributor IGROUPR corresponding to the |
| 132 | * interrupt `id`, 32 interrupt IDs at a time. |
| 133 | */ |
| 134 | void gicd_write_igroupr(uintptr_t base, unsigned int id, unsigned int val) |
| 135 | { |
Antonio Nino Diaz | ca994e7 | 2018-08-21 10:02:33 +0100 | [diff] [blame] | 136 | unsigned int n = id >> IGROUPR_SHIFT; |
| 137 | |
Achin Gupta | 92712a5 | 2015-09-03 14:18:02 +0100 | [diff] [blame] | 138 | mmio_write_32(base + GICD_IGROUPR + (n << 2), val); |
| 139 | } |
| 140 | |
| 141 | /* |
| 142 | * Accessor to write the GIC Distributor ISENABLER corresponding to the |
| 143 | * interrupt `id`, 32 interrupt IDs at a time. |
| 144 | */ |
| 145 | void gicd_write_isenabler(uintptr_t base, unsigned int id, unsigned int val) |
| 146 | { |
Antonio Nino Diaz | ca994e7 | 2018-08-21 10:02:33 +0100 | [diff] [blame] | 147 | unsigned int n = id >> ISENABLER_SHIFT; |
| 148 | |
Achin Gupta | 92712a5 | 2015-09-03 14:18:02 +0100 | [diff] [blame] | 149 | mmio_write_32(base + GICD_ISENABLER + (n << 2), val); |
| 150 | } |
| 151 | |
| 152 | /* |
| 153 | * Accessor to write the GIC Distributor ICENABLER corresponding to the |
| 154 | * interrupt `id`, 32 interrupt IDs at a time. |
| 155 | */ |
| 156 | void gicd_write_icenabler(uintptr_t base, unsigned int id, unsigned int val) |
| 157 | { |
Antonio Nino Diaz | ca994e7 | 2018-08-21 10:02:33 +0100 | [diff] [blame] | 158 | unsigned int n = id >> ICENABLER_SHIFT; |
| 159 | |
Achin Gupta | 92712a5 | 2015-09-03 14:18:02 +0100 | [diff] [blame] | 160 | mmio_write_32(base + GICD_ICENABLER + (n << 2), val); |
| 161 | } |
| 162 | |
| 163 | /* |
| 164 | * Accessor to write the GIC Distributor ISPENDR corresponding to the |
| 165 | * interrupt `id`, 32 interrupt IDs at a time. |
| 166 | */ |
| 167 | void gicd_write_ispendr(uintptr_t base, unsigned int id, unsigned int val) |
| 168 | { |
Antonio Nino Diaz | ca994e7 | 2018-08-21 10:02:33 +0100 | [diff] [blame] | 169 | unsigned int n = id >> ISPENDR_SHIFT; |
| 170 | |
Achin Gupta | 92712a5 | 2015-09-03 14:18:02 +0100 | [diff] [blame] | 171 | mmio_write_32(base + GICD_ISPENDR + (n << 2), val); |
| 172 | } |
| 173 | |
| 174 | /* |
| 175 | * Accessor to write the GIC Distributor ICPENDR corresponding to the |
| 176 | * interrupt `id`, 32 interrupt IDs at a time. |
| 177 | */ |
| 178 | void gicd_write_icpendr(uintptr_t base, unsigned int id, unsigned int val) |
| 179 | { |
Antonio Nino Diaz | ca994e7 | 2018-08-21 10:02:33 +0100 | [diff] [blame] | 180 | unsigned int n = id >> ICPENDR_SHIFT; |
| 181 | |
Achin Gupta | 92712a5 | 2015-09-03 14:18:02 +0100 | [diff] [blame] | 182 | mmio_write_32(base + GICD_ICPENDR + (n << 2), val); |
| 183 | } |
| 184 | |
| 185 | /* |
| 186 | * Accessor to write the GIC Distributor ISACTIVER corresponding to the |
| 187 | * interrupt `id`, 32 interrupt IDs at a time. |
| 188 | */ |
| 189 | void gicd_write_isactiver(uintptr_t base, unsigned int id, unsigned int val) |
| 190 | { |
Antonio Nino Diaz | ca994e7 | 2018-08-21 10:02:33 +0100 | [diff] [blame] | 191 | unsigned int n = id >> ISACTIVER_SHIFT; |
| 192 | |
Achin Gupta | 92712a5 | 2015-09-03 14:18:02 +0100 | [diff] [blame] | 193 | mmio_write_32(base + GICD_ISACTIVER + (n << 2), val); |
| 194 | } |
| 195 | |
| 196 | /* |
| 197 | * Accessor to write the GIC Distributor ICACTIVER corresponding to the |
| 198 | * interrupt `id`, 32 interrupt IDs at a time. |
| 199 | */ |
| 200 | void gicd_write_icactiver(uintptr_t base, unsigned int id, unsigned int val) |
| 201 | { |
Antonio Nino Diaz | ca994e7 | 2018-08-21 10:02:33 +0100 | [diff] [blame] | 202 | unsigned int n = id >> ICACTIVER_SHIFT; |
| 203 | |
Achin Gupta | 92712a5 | 2015-09-03 14:18:02 +0100 | [diff] [blame] | 204 | mmio_write_32(base + GICD_ICACTIVER + (n << 2), val); |
| 205 | } |
| 206 | |
| 207 | /* |
| 208 | * Accessor to write the GIC Distributor IPRIORITYR corresponding to the |
| 209 | * interrupt `id`, 4 interrupt IDs at a time. |
| 210 | */ |
| 211 | void gicd_write_ipriorityr(uintptr_t base, unsigned int id, unsigned int val) |
| 212 | { |
Antonio Nino Diaz | ca994e7 | 2018-08-21 10:02:33 +0100 | [diff] [blame] | 213 | unsigned int n = id >> IPRIORITYR_SHIFT; |
| 214 | |
Achin Gupta | 92712a5 | 2015-09-03 14:18:02 +0100 | [diff] [blame] | 215 | mmio_write_32(base + GICD_IPRIORITYR + (n << 2), val); |
| 216 | } |
| 217 | |
| 218 | /* |
| 219 | * Accessor to write the GIC Distributor ICFGR corresponding to the |
| 220 | * interrupt `id`, 16 interrupt IDs at a time. |
| 221 | */ |
| 222 | void gicd_write_icfgr(uintptr_t base, unsigned int id, unsigned int val) |
| 223 | { |
Antonio Nino Diaz | ca994e7 | 2018-08-21 10:02:33 +0100 | [diff] [blame] | 224 | unsigned int n = id >> ICFGR_SHIFT; |
| 225 | |
Achin Gupta | 92712a5 | 2015-09-03 14:18:02 +0100 | [diff] [blame] | 226 | mmio_write_32(base + GICD_ICFGR + (n << 2), val); |
| 227 | } |
| 228 | |
| 229 | /* |
| 230 | * Accessor to write the GIC Distributor NSACR corresponding to the |
| 231 | * interrupt `id`, 16 interrupt IDs at a time. |
| 232 | */ |
| 233 | void gicd_write_nsacr(uintptr_t base, unsigned int id, unsigned int val) |
| 234 | { |
Antonio Nino Diaz | ca994e7 | 2018-08-21 10:02:33 +0100 | [diff] [blame] | 235 | unsigned int n = id >> NSACR_SHIFT; |
| 236 | |
Achin Gupta | 92712a5 | 2015-09-03 14:18:02 +0100 | [diff] [blame] | 237 | mmio_write_32(base + GICD_NSACR + (n << 2), val); |
| 238 | } |
| 239 | |
| 240 | /******************************************************************************* |
Soby Mathew | 50f6fe4 | 2016-02-01 17:59:22 +0000 | [diff] [blame] | 241 | * GIC Distributor functions for accessing the GIC registers |
| 242 | * corresponding to a single interrupt ID. These functions use bitwise |
| 243 | * operations or appropriate register accesses to modify or return |
| 244 | * the bit-field corresponding the single interrupt ID. |
Achin Gupta | 92712a5 | 2015-09-03 14:18:02 +0100 | [diff] [blame] | 245 | ******************************************************************************/ |
| 246 | unsigned int gicd_get_igroupr(uintptr_t base, unsigned int id) |
| 247 | { |
Antonio Nino Diaz | ca994e7 | 2018-08-21 10:02:33 +0100 | [diff] [blame] | 248 | unsigned int bit_num = id & ((1U << IGROUPR_SHIFT) - 1U); |
Achin Gupta | 92712a5 | 2015-09-03 14:18:02 +0100 | [diff] [blame] | 249 | unsigned int reg_val = gicd_read_igroupr(base, id); |
| 250 | |
Antonio Nino Diaz | ca994e7 | 2018-08-21 10:02:33 +0100 | [diff] [blame] | 251 | return (reg_val >> bit_num) & 0x1U; |
Achin Gupta | 92712a5 | 2015-09-03 14:18:02 +0100 | [diff] [blame] | 252 | } |
| 253 | |
| 254 | void gicd_set_igroupr(uintptr_t base, unsigned int id) |
| 255 | { |
Antonio Nino Diaz | ca994e7 | 2018-08-21 10:02:33 +0100 | [diff] [blame] | 256 | unsigned int bit_num = id & ((1U << IGROUPR_SHIFT) - 1U); |
Achin Gupta | 92712a5 | 2015-09-03 14:18:02 +0100 | [diff] [blame] | 257 | unsigned int reg_val = gicd_read_igroupr(base, id); |
| 258 | |
Antonio Nino Diaz | ca994e7 | 2018-08-21 10:02:33 +0100 | [diff] [blame] | 259 | gicd_write_igroupr(base, id, reg_val | (1U << bit_num)); |
Achin Gupta | 92712a5 | 2015-09-03 14:18:02 +0100 | [diff] [blame] | 260 | } |
| 261 | |
| 262 | void gicd_clr_igroupr(uintptr_t base, unsigned int id) |
| 263 | { |
Antonio Nino Diaz | ca994e7 | 2018-08-21 10:02:33 +0100 | [diff] [blame] | 264 | unsigned int bit_num = id & ((1U << IGROUPR_SHIFT) - 1U); |
Achin Gupta | 92712a5 | 2015-09-03 14:18:02 +0100 | [diff] [blame] | 265 | unsigned int reg_val = gicd_read_igroupr(base, id); |
| 266 | |
Antonio Nino Diaz | ca994e7 | 2018-08-21 10:02:33 +0100 | [diff] [blame] | 267 | gicd_write_igroupr(base, id, reg_val & ~(1U << bit_num)); |
Achin Gupta | 92712a5 | 2015-09-03 14:18:02 +0100 | [diff] [blame] | 268 | } |
| 269 | |
| 270 | void gicd_set_isenabler(uintptr_t base, unsigned int id) |
| 271 | { |
Antonio Nino Diaz | ca994e7 | 2018-08-21 10:02:33 +0100 | [diff] [blame] | 272 | unsigned int bit_num = id & ((1U << ISENABLER_SHIFT) - 1U); |
Achin Gupta | 92712a5 | 2015-09-03 14:18:02 +0100 | [diff] [blame] | 273 | |
Antonio Nino Diaz | ca994e7 | 2018-08-21 10:02:33 +0100 | [diff] [blame] | 274 | gicd_write_isenabler(base, id, (1U << bit_num)); |
Achin Gupta | 92712a5 | 2015-09-03 14:18:02 +0100 | [diff] [blame] | 275 | } |
| 276 | |
| 277 | void gicd_set_icenabler(uintptr_t base, unsigned int id) |
| 278 | { |
Antonio Nino Diaz | ca994e7 | 2018-08-21 10:02:33 +0100 | [diff] [blame] | 279 | unsigned int bit_num = id & ((1U << ICENABLER_SHIFT) - 1U); |
Achin Gupta | 92712a5 | 2015-09-03 14:18:02 +0100 | [diff] [blame] | 280 | |
Antonio Nino Diaz | ca994e7 | 2018-08-21 10:02:33 +0100 | [diff] [blame] | 281 | gicd_write_icenabler(base, id, (1U << bit_num)); |
Achin Gupta | 92712a5 | 2015-09-03 14:18:02 +0100 | [diff] [blame] | 282 | } |
| 283 | |
| 284 | void gicd_set_ispendr(uintptr_t base, unsigned int id) |
| 285 | { |
Antonio Nino Diaz | ca994e7 | 2018-08-21 10:02:33 +0100 | [diff] [blame] | 286 | unsigned int bit_num = id & ((1U << ISPENDR_SHIFT) - 1U); |
Achin Gupta | 92712a5 | 2015-09-03 14:18:02 +0100 | [diff] [blame] | 287 | |
Antonio Nino Diaz | ca994e7 | 2018-08-21 10:02:33 +0100 | [diff] [blame] | 288 | gicd_write_ispendr(base, id, (1U << bit_num)); |
Achin Gupta | 92712a5 | 2015-09-03 14:18:02 +0100 | [diff] [blame] | 289 | } |
| 290 | |
| 291 | void gicd_set_icpendr(uintptr_t base, unsigned int id) |
| 292 | { |
Antonio Nino Diaz | ca994e7 | 2018-08-21 10:02:33 +0100 | [diff] [blame] | 293 | unsigned int bit_num = id & ((1U << ICPENDR_SHIFT) - 1U); |
Achin Gupta | 92712a5 | 2015-09-03 14:18:02 +0100 | [diff] [blame] | 294 | |
Antonio Nino Diaz | ca994e7 | 2018-08-21 10:02:33 +0100 | [diff] [blame] | 295 | gicd_write_icpendr(base, id, (1U << bit_num)); |
Achin Gupta | 92712a5 | 2015-09-03 14:18:02 +0100 | [diff] [blame] | 296 | } |
| 297 | |
Jeenu Viswambharan | 24e7029 | 2017-09-22 08:32:09 +0100 | [diff] [blame] | 298 | unsigned int gicd_get_isactiver(uintptr_t base, unsigned int id) |
| 299 | { |
Antonio Nino Diaz | ca994e7 | 2018-08-21 10:02:33 +0100 | [diff] [blame] | 300 | unsigned int bit_num = id & ((1U << ISACTIVER_SHIFT) - 1U); |
Jeenu Viswambharan | 24e7029 | 2017-09-22 08:32:09 +0100 | [diff] [blame] | 301 | unsigned int reg_val = gicd_read_isactiver(base, id); |
| 302 | |
Antonio Nino Diaz | ca994e7 | 2018-08-21 10:02:33 +0100 | [diff] [blame] | 303 | return (reg_val >> bit_num) & 0x1U; |
Jeenu Viswambharan | 24e7029 | 2017-09-22 08:32:09 +0100 | [diff] [blame] | 304 | } |
| 305 | |
Achin Gupta | 92712a5 | 2015-09-03 14:18:02 +0100 | [diff] [blame] | 306 | void gicd_set_isactiver(uintptr_t base, unsigned int id) |
| 307 | { |
Antonio Nino Diaz | ca994e7 | 2018-08-21 10:02:33 +0100 | [diff] [blame] | 308 | unsigned int bit_num = id & ((1U << ISACTIVER_SHIFT) - 1U); |
Achin Gupta | 92712a5 | 2015-09-03 14:18:02 +0100 | [diff] [blame] | 309 | |
Antonio Nino Diaz | ca994e7 | 2018-08-21 10:02:33 +0100 | [diff] [blame] | 310 | gicd_write_isactiver(base, id, (1U << bit_num)); |
Achin Gupta | 92712a5 | 2015-09-03 14:18:02 +0100 | [diff] [blame] | 311 | } |
| 312 | |
| 313 | void gicd_set_icactiver(uintptr_t base, unsigned int id) |
| 314 | { |
Antonio Nino Diaz | ca994e7 | 2018-08-21 10:02:33 +0100 | [diff] [blame] | 315 | unsigned int bit_num = id & ((1U << ICACTIVER_SHIFT) - 1U); |
Achin Gupta | 92712a5 | 2015-09-03 14:18:02 +0100 | [diff] [blame] | 316 | |
Antonio Nino Diaz | ca994e7 | 2018-08-21 10:02:33 +0100 | [diff] [blame] | 317 | gicd_write_icactiver(base, id, (1U << bit_num)); |
Achin Gupta | 92712a5 | 2015-09-03 14:18:02 +0100 | [diff] [blame] | 318 | } |
Soby Mathew | 421259e | 2016-01-15 14:20:57 +0000 | [diff] [blame] | 319 | |
| 320 | void gicd_set_ipriorityr(uintptr_t base, unsigned int id, unsigned int pri) |
| 321 | { |
Antonio Nino Diaz | ca994e7 | 2018-08-21 10:02:33 +0100 | [diff] [blame] | 322 | uint8_t val = pri & GIC_PRI_MASK; |
| 323 | |
| 324 | mmio_write_8(base + GICD_IPRIORITYR + id, val); |
Soby Mathew | 421259e | 2016-01-15 14:20:57 +0000 | [diff] [blame] | 325 | } |
Jeenu Viswambharan | 4684bce | 2017-09-22 08:32:09 +0100 | [diff] [blame] | 326 | |
| 327 | void gicd_set_icfgr(uintptr_t base, unsigned int id, unsigned int cfg) |
| 328 | { |
Jeenu Viswambharan | b6982c0 | 2018-03-22 08:57:52 +0000 | [diff] [blame] | 329 | /* Interrupt configuration is a 2-bit field */ |
Antonio Nino Diaz | ca994e7 | 2018-08-21 10:02:33 +0100 | [diff] [blame] | 330 | unsigned int bit_num = id & ((1U << ICFGR_SHIFT) - 1U); |
Jeenu Viswambharan | b6982c0 | 2018-03-22 08:57:52 +0000 | [diff] [blame] | 331 | unsigned int bit_shift = bit_num << 1; |
| 332 | |
Jeenu Viswambharan | 4684bce | 2017-09-22 08:32:09 +0100 | [diff] [blame] | 333 | uint32_t reg_val = gicd_read_icfgr(base, id); |
| 334 | |
| 335 | /* Clear the field, and insert required configuration */ |
Jeenu Viswambharan | b6982c0 | 2018-03-22 08:57:52 +0000 | [diff] [blame] | 336 | reg_val &= ~(GIC_CFG_MASK << bit_shift); |
| 337 | reg_val |= ((cfg & GIC_CFG_MASK) << bit_shift); |
Jeenu Viswambharan | 4684bce | 2017-09-22 08:32:09 +0100 | [diff] [blame] | 338 | |
| 339 | gicd_write_icfgr(base, id, reg_val); |
| 340 | } |