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