gicv3_fdt.c revision 1.2.2.2 1 1.2.2.2 pgoyette /* $NetBSD: gicv3_fdt.c,v 1.2.2.2 2018/09/06 06:55:26 pgoyette Exp $ */
2 1.2.2.2 pgoyette
3 1.2.2.2 pgoyette /*-
4 1.2.2.2 pgoyette * Copyright (c) 2015-2018 Jared McNeill <jmcneill (at) invisible.ca>
5 1.2.2.2 pgoyette * All rights reserved.
6 1.2.2.2 pgoyette *
7 1.2.2.2 pgoyette * Redistribution and use in source and binary forms, with or without
8 1.2.2.2 pgoyette * modification, are permitted provided that the following conditions
9 1.2.2.2 pgoyette * are met:
10 1.2.2.2 pgoyette * 1. Redistributions of source code must retain the above copyright
11 1.2.2.2 pgoyette * notice, this list of conditions and the following disclaimer.
12 1.2.2.2 pgoyette * 2. Redistributions in binary form must reproduce the above copyright
13 1.2.2.2 pgoyette * notice, this list of conditions and the following disclaimer in the
14 1.2.2.2 pgoyette * documentation and/or other materials provided with the distribution.
15 1.2.2.2 pgoyette *
16 1.2.2.2 pgoyette * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 1.2.2.2 pgoyette * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 1.2.2.2 pgoyette * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 1.2.2.2 pgoyette * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 1.2.2.2 pgoyette * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21 1.2.2.2 pgoyette * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 1.2.2.2 pgoyette * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23 1.2.2.2 pgoyette * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 1.2.2.2 pgoyette * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 1.2.2.2 pgoyette * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 1.2.2.2 pgoyette * SUCH DAMAGE.
27 1.2.2.2 pgoyette */
28 1.2.2.2 pgoyette
29 1.2.2.2 pgoyette #define _INTR_PRIVATE
30 1.2.2.2 pgoyette
31 1.2.2.2 pgoyette #include <sys/cdefs.h>
32 1.2.2.2 pgoyette __KERNEL_RCSID(0, "$NetBSD: gicv3_fdt.c,v 1.2.2.2 2018/09/06 06:55:26 pgoyette Exp $");
33 1.2.2.2 pgoyette
34 1.2.2.2 pgoyette #include <sys/param.h>
35 1.2.2.2 pgoyette #include <sys/bus.h>
36 1.2.2.2 pgoyette #include <sys/device.h>
37 1.2.2.2 pgoyette #include <sys/intr.h>
38 1.2.2.2 pgoyette #include <sys/systm.h>
39 1.2.2.2 pgoyette #include <sys/kernel.h>
40 1.2.2.2 pgoyette #include <sys/lwp.h>
41 1.2.2.2 pgoyette #include <sys/kmem.h>
42 1.2.2.2 pgoyette #include <sys/queue.h>
43 1.2.2.2 pgoyette
44 1.2.2.2 pgoyette #include <dev/fdt/fdtvar.h>
45 1.2.2.2 pgoyette
46 1.2.2.2 pgoyette #include <arm/cortex/gicv3.h>
47 1.2.2.2 pgoyette
48 1.2.2.2 pgoyette #define GICV3_MAXIRQ 1020
49 1.2.2.2 pgoyette
50 1.2.2.2 pgoyette #define IRQ_PPI(n) ((n) + 16)
51 1.2.2.2 pgoyette #define IRQ_SPI(n) ((n) + 32)
52 1.2.2.2 pgoyette
53 1.2.2.2 pgoyette struct gicv3_fdt_softc;
54 1.2.2.2 pgoyette struct gicv3_fdt_irq;
55 1.2.2.2 pgoyette
56 1.2.2.2 pgoyette static int gicv3_fdt_match(device_t, cfdata_t, void *);
57 1.2.2.2 pgoyette static void gicv3_fdt_attach(device_t, device_t, void *);
58 1.2.2.2 pgoyette
59 1.2.2.2 pgoyette static int gicv3_fdt_map_registers(struct gicv3_fdt_softc *);
60 1.2.2.2 pgoyette
61 1.2.2.2 pgoyette static int gicv3_fdt_intr(void *);
62 1.2.2.2 pgoyette
63 1.2.2.2 pgoyette static void * gicv3_fdt_establish(device_t, u_int *, int, int,
64 1.2.2.2 pgoyette int (*)(void *), void *);
65 1.2.2.2 pgoyette static void gicv3_fdt_disestablish(device_t, void *);
66 1.2.2.2 pgoyette static bool gicv3_fdt_intrstr(device_t, u_int *, char *, size_t);
67 1.2.2.2 pgoyette
68 1.2.2.2 pgoyette struct fdtbus_interrupt_controller_func gicv3_fdt_funcs = {
69 1.2.2.2 pgoyette .establish = gicv3_fdt_establish,
70 1.2.2.2 pgoyette .disestablish = gicv3_fdt_disestablish,
71 1.2.2.2 pgoyette .intrstr = gicv3_fdt_intrstr
72 1.2.2.2 pgoyette };
73 1.2.2.2 pgoyette
74 1.2.2.2 pgoyette struct gicv3_fdt_irqhandler {
75 1.2.2.2 pgoyette struct gicv3_fdt_irq *ih_irq;
76 1.2.2.2 pgoyette int (*ih_fn)(void *);
77 1.2.2.2 pgoyette void *ih_arg;
78 1.2.2.2 pgoyette bool ih_mpsafe;
79 1.2.2.2 pgoyette TAILQ_ENTRY(gicv3_fdt_irqhandler) ih_next;
80 1.2.2.2 pgoyette };
81 1.2.2.2 pgoyette
82 1.2.2.2 pgoyette struct gicv3_fdt_irq {
83 1.2.2.2 pgoyette struct gicv3_fdt_softc *intr_sc;
84 1.2.2.2 pgoyette void *intr_ih;
85 1.2.2.2 pgoyette void *intr_arg;
86 1.2.2.2 pgoyette int intr_refcnt;
87 1.2.2.2 pgoyette int intr_ipl;
88 1.2.2.2 pgoyette int intr_level;
89 1.2.2.2 pgoyette int intr_mpsafe;
90 1.2.2.2 pgoyette TAILQ_HEAD(, gicv3_fdt_irqhandler) intr_handlers;
91 1.2.2.2 pgoyette int intr_irq;
92 1.2.2.2 pgoyette };
93 1.2.2.2 pgoyette
94 1.2.2.2 pgoyette struct gicv3_fdt_softc {
95 1.2.2.2 pgoyette struct gicv3_softc sc_gic;
96 1.2.2.2 pgoyette int sc_phandle;
97 1.2.2.2 pgoyette
98 1.2.2.2 pgoyette struct gicv3_fdt_irq *sc_irq[GICV3_MAXIRQ];
99 1.2.2.2 pgoyette };
100 1.2.2.2 pgoyette
101 1.2.2.2 pgoyette CFATTACH_DECL_NEW(gicv3_fdt, sizeof(struct gicv3_fdt_softc),
102 1.2.2.2 pgoyette gicv3_fdt_match, gicv3_fdt_attach, NULL, NULL);
103 1.2.2.2 pgoyette
104 1.2.2.2 pgoyette static int
105 1.2.2.2 pgoyette gicv3_fdt_match(device_t parent, cfdata_t cf, void *aux)
106 1.2.2.2 pgoyette {
107 1.2.2.2 pgoyette const char * const compatible[] = {
108 1.2.2.2 pgoyette "arm,gic-v3",
109 1.2.2.2 pgoyette NULL
110 1.2.2.2 pgoyette };
111 1.2.2.2 pgoyette struct fdt_attach_args * const faa = aux;
112 1.2.2.2 pgoyette const int phandle = faa->faa_phandle;
113 1.2.2.2 pgoyette
114 1.2.2.2 pgoyette return of_match_compatible(phandle, compatible);
115 1.2.2.2 pgoyette }
116 1.2.2.2 pgoyette
117 1.2.2.2 pgoyette static void
118 1.2.2.2 pgoyette gicv3_fdt_attach(device_t parent, device_t self, void *aux)
119 1.2.2.2 pgoyette {
120 1.2.2.2 pgoyette struct gicv3_fdt_softc * const sc = device_private(self);
121 1.2.2.2 pgoyette struct fdt_attach_args * const faa = aux;
122 1.2.2.2 pgoyette const int phandle = faa->faa_phandle;
123 1.2.2.2 pgoyette int error;
124 1.2.2.2 pgoyette
125 1.2.2.2 pgoyette error = fdtbus_register_interrupt_controller(self, phandle,
126 1.2.2.2 pgoyette &gicv3_fdt_funcs);
127 1.2.2.2 pgoyette if (error) {
128 1.2.2.2 pgoyette aprint_error(": couldn't register with fdtbus: %d\n", error);
129 1.2.2.2 pgoyette return;
130 1.2.2.2 pgoyette }
131 1.2.2.2 pgoyette
132 1.2.2.2 pgoyette aprint_naive("\n");
133 1.2.2.2 pgoyette aprint_normal(": GICv3\n");
134 1.2.2.2 pgoyette
135 1.2.2.2 pgoyette sc->sc_phandle = phandle;
136 1.2.2.2 pgoyette sc->sc_gic.sc_dev = self;
137 1.2.2.2 pgoyette sc->sc_gic.sc_bst = faa->faa_bst;
138 1.2.2.2 pgoyette
139 1.2.2.2 pgoyette error = gicv3_fdt_map_registers(sc);
140 1.2.2.2 pgoyette if (error) {
141 1.2.2.2 pgoyette aprint_error_dev(self, "couldn't map registers\n");
142 1.2.2.2 pgoyette return;
143 1.2.2.2 pgoyette }
144 1.2.2.2 pgoyette
145 1.2.2.2 pgoyette aprint_debug_dev(self, "%d redistributors\n", sc->sc_gic.sc_bsh_r_count);
146 1.2.2.2 pgoyette
147 1.2.2.2 pgoyette error = gicv3_init(&sc->sc_gic);
148 1.2.2.2 pgoyette if (error) {
149 1.2.2.2 pgoyette aprint_error_dev(self, "failed to initialize GIC: %d\n", error);
150 1.2.2.2 pgoyette return;
151 1.2.2.2 pgoyette }
152 1.2.2.2 pgoyette
153 1.2.2.2 pgoyette arm_fdt_irq_set_handler(gicv3_irq_handler);
154 1.2.2.2 pgoyette }
155 1.2.2.2 pgoyette
156 1.2.2.2 pgoyette static int
157 1.2.2.2 pgoyette gicv3_fdt_map_registers(struct gicv3_fdt_softc *sc)
158 1.2.2.2 pgoyette {
159 1.2.2.2 pgoyette struct gicv3_softc *gic = &sc->sc_gic;
160 1.2.2.2 pgoyette const int phandle = sc->sc_phandle;
161 1.2.2.2 pgoyette u_int redistributor_regions, redistributor_stride;
162 1.2.2.2 pgoyette bus_space_handle_t bsh;
163 1.2.2.2 pgoyette bus_size_t size, region_off;
164 1.2.2.2 pgoyette bus_addr_t addr;
165 1.2.2.2 pgoyette size_t reg_off;
166 1.2.2.2 pgoyette int n, r;
167 1.2.2.2 pgoyette
168 1.2.2.2 pgoyette if (of_getprop_uint32(phandle, "#redistributor-regions", &redistributor_regions))
169 1.2.2.2 pgoyette redistributor_regions = 1;
170 1.2.2.2 pgoyette if (of_getprop_uint32(phandle, "redistributor-stride", &redistributor_stride))
171 1.2.2.2 pgoyette redistributor_stride = 0x20000;
172 1.2.2.2 pgoyette
173 1.2.2.2 pgoyette /*
174 1.2.2.2 pgoyette * Map GIC Distributor interface (GICD)
175 1.2.2.2 pgoyette */
176 1.2.2.2 pgoyette if (fdtbus_get_reg(phandle, 0, &addr, &size) != 0) {
177 1.2.2.2 pgoyette aprint_error_dev(gic->sc_dev, "couldn't get distributor registers\n");
178 1.2.2.2 pgoyette return ENXIO;
179 1.2.2.2 pgoyette }
180 1.2.2.2 pgoyette if (bus_space_map(sc->sc_gic.sc_bst, addr, size, 0, &sc->sc_gic.sc_bsh_d) != 0) {
181 1.2.2.2 pgoyette aprint_error_dev(gic->sc_dev, "couldn't map distributor registers\n");
182 1.2.2.2 pgoyette return ENXIO;
183 1.2.2.2 pgoyette }
184 1.2.2.2 pgoyette
185 1.2.2.2 pgoyette /*
186 1.2.2.2 pgoyette * GIC Redistributors (GICR)
187 1.2.2.2 pgoyette */
188 1.2.2.2 pgoyette for (reg_off = 1, n = 0; n < redistributor_regions; n++, reg_off++) {
189 1.2.2.2 pgoyette if (fdtbus_get_reg(phandle, reg_off, NULL, &size) != 0) {
190 1.2.2.2 pgoyette aprint_error_dev(gic->sc_dev, "couldn't get redistributor registers\n");
191 1.2.2.2 pgoyette return ENXIO;
192 1.2.2.2 pgoyette }
193 1.2.2.2 pgoyette gic->sc_bsh_r_count += howmany(size, redistributor_stride);
194 1.2.2.2 pgoyette }
195 1.2.2.2 pgoyette gic->sc_bsh_r = kmem_alloc(sizeof(bus_space_handle_t) * gic->sc_bsh_r_count, KM_SLEEP);
196 1.2.2.2 pgoyette for (reg_off = 1, n = 0; n < redistributor_regions; n++, reg_off++) {
197 1.2.2.2 pgoyette if (fdtbus_get_reg(phandle, reg_off, &addr, &size) != 0) {
198 1.2.2.2 pgoyette aprint_error_dev(gic->sc_dev, "couldn't get redistributor registers\n");
199 1.2.2.2 pgoyette return ENXIO;
200 1.2.2.2 pgoyette }
201 1.2.2.2 pgoyette if (bus_space_map(sc->sc_gic.sc_bst, addr, size, 0, &bsh) != 0) {
202 1.2.2.2 pgoyette aprint_error_dev(gic->sc_dev, "couldn't map redistributor registers\n");
203 1.2.2.2 pgoyette return ENXIO;
204 1.2.2.2 pgoyette }
205 1.2.2.2 pgoyette const int count = howmany(size, redistributor_stride);
206 1.2.2.2 pgoyette for (r = 0, region_off = 0; r < count; r++, region_off += redistributor_stride) {
207 1.2.2.2 pgoyette if (bus_space_subregion(sc->sc_gic.sc_bst, bsh, region_off, redistributor_stride, &gic->sc_bsh_r[r]) != 0) {
208 1.2.2.2 pgoyette aprint_error_dev(gic->sc_dev, "couldn't subregion redistributor registers\n");
209 1.2.2.2 pgoyette return ENXIO;
210 1.2.2.2 pgoyette }
211 1.2.2.2 pgoyette }
212 1.2.2.2 pgoyette }
213 1.2.2.2 pgoyette
214 1.2.2.2 pgoyette return 0;
215 1.2.2.2 pgoyette }
216 1.2.2.2 pgoyette
217 1.2.2.2 pgoyette static void *
218 1.2.2.2 pgoyette gicv3_fdt_establish(device_t dev, u_int *specifier, int ipl, int flags,
219 1.2.2.2 pgoyette int (*func)(void *), void *arg)
220 1.2.2.2 pgoyette {
221 1.2.2.2 pgoyette struct gicv3_fdt_softc * const sc = device_private(dev);
222 1.2.2.2 pgoyette struct gicv3_fdt_irq *firq;
223 1.2.2.2 pgoyette struct gicv3_fdt_irqhandler *firqh;
224 1.2.2.2 pgoyette
225 1.2.2.2 pgoyette /* 1st cell is the interrupt type; 0 is SPI, 1 is PPI */
226 1.2.2.2 pgoyette /* 2nd cell is the interrupt number */
227 1.2.2.2 pgoyette /* 3rd cell is flags */
228 1.2.2.2 pgoyette /* 4th cell is affinity */
229 1.2.2.2 pgoyette
230 1.2.2.2 pgoyette const u_int type = be32toh(specifier[0]);
231 1.2.2.2 pgoyette const u_int intr = be32toh(specifier[1]);
232 1.2.2.2 pgoyette const u_int irq = type == 0 ? IRQ_SPI(intr) : IRQ_PPI(intr);
233 1.2.2.2 pgoyette const u_int trig = be32toh(specifier[2]) & 0xf;
234 1.2.2.2 pgoyette const u_int level = (trig & 0x3) ? IST_EDGE : IST_LEVEL;
235 1.2.2.2 pgoyette
236 1.2.2.2 pgoyette const u_int mpsafe = (flags & FDT_INTR_MPSAFE) ? IST_MPSAFE : 0;
237 1.2.2.2 pgoyette
238 1.2.2.2 pgoyette firq = sc->sc_irq[irq];
239 1.2.2.2 pgoyette if (firq == NULL) {
240 1.2.2.2 pgoyette firq = kmem_alloc(sizeof(*firq), KM_SLEEP);
241 1.2.2.2 pgoyette firq->intr_sc = sc;
242 1.2.2.2 pgoyette firq->intr_refcnt = 0;
243 1.2.2.2 pgoyette firq->intr_arg = arg;
244 1.2.2.2 pgoyette firq->intr_ipl = ipl;
245 1.2.2.2 pgoyette firq->intr_level = level;
246 1.2.2.2 pgoyette firq->intr_mpsafe = mpsafe;
247 1.2.2.2 pgoyette TAILQ_INIT(&firq->intr_handlers);
248 1.2.2.2 pgoyette firq->intr_irq = irq;
249 1.2.2.2 pgoyette if (arg == NULL) {
250 1.2.2.2 pgoyette firq->intr_ih = intr_establish(irq, ipl, level | mpsafe,
251 1.2.2.2 pgoyette func, NULL);
252 1.2.2.2 pgoyette } else {
253 1.2.2.2 pgoyette firq->intr_ih = intr_establish(irq, ipl, level | mpsafe,
254 1.2.2.2 pgoyette gicv3_fdt_intr, firq);
255 1.2.2.2 pgoyette }
256 1.2.2.2 pgoyette if (firq->intr_ih == NULL) {
257 1.2.2.2 pgoyette kmem_free(firq, sizeof(*firq));
258 1.2.2.2 pgoyette return NULL;
259 1.2.2.2 pgoyette }
260 1.2.2.2 pgoyette sc->sc_irq[irq] = firq;
261 1.2.2.2 pgoyette } else {
262 1.2.2.2 pgoyette if (firq->intr_arg == NULL && arg != NULL) {
263 1.2.2.2 pgoyette device_printf(dev, "cannot share irq with NULL arg\n");
264 1.2.2.2 pgoyette return NULL;
265 1.2.2.2 pgoyette }
266 1.2.2.2 pgoyette if (firq->intr_ipl != ipl) {
267 1.2.2.2 pgoyette device_printf(dev, "cannot share irq with different "
268 1.2.2.2 pgoyette "ipl\n");
269 1.2.2.2 pgoyette return NULL;
270 1.2.2.2 pgoyette }
271 1.2.2.2 pgoyette if (firq->intr_level != level) {
272 1.2.2.2 pgoyette device_printf(dev, "cannot share edge and level "
273 1.2.2.2 pgoyette "interrupts\n");
274 1.2.2.2 pgoyette return NULL;
275 1.2.2.2 pgoyette }
276 1.2.2.2 pgoyette if (firq->intr_mpsafe != mpsafe) {
277 1.2.2.2 pgoyette device_printf(dev, "cannot share between "
278 1.2.2.2 pgoyette "mpsafe/non-mpsafe\n");
279 1.2.2.2 pgoyette return NULL;
280 1.2.2.2 pgoyette }
281 1.2.2.2 pgoyette }
282 1.2.2.2 pgoyette
283 1.2.2.2 pgoyette firq->intr_refcnt++;
284 1.2.2.2 pgoyette
285 1.2.2.2 pgoyette firqh = kmem_alloc(sizeof(*firqh), KM_SLEEP);
286 1.2.2.2 pgoyette firqh->ih_mpsafe = (flags & FDT_INTR_MPSAFE) != 0;
287 1.2.2.2 pgoyette firqh->ih_irq = firq;
288 1.2.2.2 pgoyette firqh->ih_fn = func;
289 1.2.2.2 pgoyette firqh->ih_arg = arg;
290 1.2.2.2 pgoyette TAILQ_INSERT_TAIL(&firq->intr_handlers, firqh, ih_next);
291 1.2.2.2 pgoyette
292 1.2.2.2 pgoyette return firq->intr_ih;
293 1.2.2.2 pgoyette }
294 1.2.2.2 pgoyette
295 1.2.2.2 pgoyette static void
296 1.2.2.2 pgoyette gicv3_fdt_disestablish(device_t dev, void *ih)
297 1.2.2.2 pgoyette {
298 1.2.2.2 pgoyette struct gicv3_fdt_softc * const sc = device_private(dev);
299 1.2.2.2 pgoyette struct gicv3_fdt_irqhandler *firqh;
300 1.2.2.2 pgoyette struct gicv3_fdt_irq *firq;
301 1.2.2.2 pgoyette u_int n;
302 1.2.2.2 pgoyette
303 1.2.2.2 pgoyette for (n = 0; n < GICV3_MAXIRQ; n++) {
304 1.2.2.2 pgoyette firq = sc->sc_irq[n];
305 1.2.2.2 pgoyette if (firq->intr_ih != ih)
306 1.2.2.2 pgoyette continue;
307 1.2.2.2 pgoyette
308 1.2.2.2 pgoyette KASSERT(firq->intr_refcnt > 0);
309 1.2.2.2 pgoyette
310 1.2.2.2 pgoyette if (firq->intr_refcnt > 1)
311 1.2.2.2 pgoyette panic("%s: cannot disestablish shared irq", __func__);
312 1.2.2.2 pgoyette
313 1.2.2.2 pgoyette firqh = TAILQ_FIRST(&firq->intr_handlers);
314 1.2.2.2 pgoyette kmem_free(firqh, sizeof(*firqh));
315 1.2.2.2 pgoyette intr_disestablish(firq->intr_ih);
316 1.2.2.2 pgoyette kmem_free(firq, sizeof(*firq));
317 1.2.2.2 pgoyette sc->sc_irq[n] = NULL;
318 1.2.2.2 pgoyette return;
319 1.2.2.2 pgoyette }
320 1.2.2.2 pgoyette
321 1.2.2.2 pgoyette panic("%s: interrupt not established", __func__);
322 1.2.2.2 pgoyette }
323 1.2.2.2 pgoyette
324 1.2.2.2 pgoyette static int
325 1.2.2.2 pgoyette gicv3_fdt_intr(void *priv)
326 1.2.2.2 pgoyette {
327 1.2.2.2 pgoyette struct gicv3_fdt_irq *firq = priv;
328 1.2.2.2 pgoyette struct gicv3_fdt_irqhandler *firqh;
329 1.2.2.2 pgoyette int handled = 0;
330 1.2.2.2 pgoyette
331 1.2.2.2 pgoyette TAILQ_FOREACH(firqh, &firq->intr_handlers, ih_next)
332 1.2.2.2 pgoyette handled += firqh->ih_fn(firqh->ih_arg);
333 1.2.2.2 pgoyette
334 1.2.2.2 pgoyette return handled;
335 1.2.2.2 pgoyette }
336 1.2.2.2 pgoyette
337 1.2.2.2 pgoyette static bool
338 1.2.2.2 pgoyette gicv3_fdt_intrstr(device_t dev, u_int *specifier, char *buf, size_t buflen)
339 1.2.2.2 pgoyette {
340 1.2.2.2 pgoyette /* 1st cell is the interrupt type; 0 is SPI, 1 is PPI */
341 1.2.2.2 pgoyette /* 2nd cell is the interrupt number */
342 1.2.2.2 pgoyette /* 3rd cell is flags */
343 1.2.2.2 pgoyette /* 4th cell is affinity */
344 1.2.2.2 pgoyette
345 1.2.2.2 pgoyette if (!specifier)
346 1.2.2.2 pgoyette return false;
347 1.2.2.2 pgoyette const u_int type = be32toh(specifier[0]);
348 1.2.2.2 pgoyette const u_int intr = be32toh(specifier[1]);
349 1.2.2.2 pgoyette const u_int irq = type == 0 ? IRQ_SPI(intr) : IRQ_PPI(intr);
350 1.2.2.2 pgoyette
351 1.2.2.2 pgoyette snprintf(buf, buflen, "GICv3 irq %d", irq);
352 1.2.2.2 pgoyette
353 1.2.2.2 pgoyette return true;
354 1.2.2.2 pgoyette }
355