2 * Copyright (c) 2011 The FreeBSD Foundation
5 * Developed by Damjan Marion <damjan.marion@gmail.com>
7 * Based on OMAP4 GIC code by Ben Gray
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. The name of the company nor the name of the author may be used to
18 * endorse or promote products derived from this software without specific
19 * prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 #include <sys/cdefs.h>
35 __FBSDID("$FreeBSD$");
37 #include "opt_platform.h"
39 #include <sys/param.h>
40 #include <sys/systm.h>
42 #include <sys/kernel.h>
44 #include <sys/module.h>
45 #include <sys/malloc.h>
49 #include <sys/cpuset.h>
51 #include <sys/mutex.h>
54 #include <sys/sched.h>
60 #include <machine/bus.h>
61 #include <machine/intr.h>
62 #include <machine/smp.h>
65 #include <dev/fdt/fdt_intr.h>
66 #include <dev/ofw/ofw_bus_subr.h>
69 #include <arm/arm/gic.h>
70 #include <arm/arm/gic_common.h>
77 /* We are using GICv2 register naming */
79 /* Distributor Registers */
82 #define GICC_CTLR 0x0000 /* v1 ICCICR */
83 #define GICC_PMR 0x0004 /* v1 ICCPMR */
84 #define GICC_BPR 0x0008 /* v1 ICCBPR */
85 #define GICC_IAR 0x000C /* v1 ICCIAR */
86 #define GICC_EOIR 0x0010 /* v1 ICCEOIR */
87 #define GICC_RPR 0x0014 /* v1 ICCRPR */
88 #define GICC_HPPIR 0x0018 /* v1 ICCHPIR */
89 #define GICC_ABPR 0x001C /* v1 ICCABPR */
90 #define GICC_IIDR 0x00FC /* v1 ICCIIDR*/
93 #define GICD_TYPER_SECURITYEXT 0x400
94 #define GIC_SUPPORT_SECEXT(_sc) \
95 ((_sc->typer & GICD_TYPER_SECURITYEXT) == GICD_TYPER_SECURITYEXT)
98 #ifndef GIC_DEFAULT_ICFGR_INIT
99 #define GIC_DEFAULT_ICFGR_INIT 0x00000000
104 struct intr_irqsrc gi_isrc;
106 enum intr_polarity gi_pol;
107 enum intr_trigger gi_trig;
108 #define GI_FLAG_EARLY_EOI (1 << 0)
109 #define GI_FLAG_MSI (1 << 1) /* This interrupt source should only */
110 /* be used for MSI/MSI-X interrupts */
111 #define GI_FLAG_MSI_USED (1 << 2) /* This irq is already allocated */
112 /* for a MSI/MSI-X interrupt */
116 static u_int gic_irq_cpu;
117 static int arm_gic_bind_intr(device_t dev, struct intr_irqsrc *isrc);
120 static u_int sgi_to_ipi[GIC_LAST_SGI - GIC_FIRST_SGI + 1];
121 static u_int sgi_first_unused = GIC_FIRST_SGI;
124 #define GIC_INTR_ISRC(sc, irq) (&sc->gic_irqs[irq].gi_isrc)
126 static struct ofw_compat_data compat_data[] = {
127 {"arm,gic", true}, /* Non-standard, used in FreeBSD dts. */
128 {"arm,gic-400", true},
129 {"arm,cortex-a15-gic", true},
130 {"arm,cortex-a9-gic", true},
131 {"arm,cortex-a7-gic", true},
132 {"arm,arm11mp-gic", true},
133 {"brcm,brahma-b15-gic", true},
134 {"qcom,msm-qgic2", true},
139 static struct resource_spec arm_gic_spec[] = {
140 { SYS_RES_MEMORY, 0, RF_ACTIVE }, /* Distributor registers */
141 { SYS_RES_MEMORY, 1, RF_ACTIVE }, /* CPU Interrupt Intf. registers */
143 { SYS_RES_IRQ, 0, RF_ACTIVE | RF_OPTIONAL }, /* Parent interrupt */
148 static u_int arm_gic_map[MAXCPU];
150 static struct arm_gic_softc *gic_sc = NULL;
152 #define gic_c_read_4(_sc, _reg) \
153 bus_space_read_4((_sc)->gic_c_bst, (_sc)->gic_c_bsh, (_reg))
154 #define gic_c_write_4(_sc, _reg, _val) \
155 bus_space_write_4((_sc)->gic_c_bst, (_sc)->gic_c_bsh, (_reg), (_val))
156 #define gic_d_read_4(_sc, _reg) \
157 bus_space_read_4((_sc)->gic_d_bst, (_sc)->gic_d_bsh, (_reg))
158 #define gic_d_write_1(_sc, _reg, _val) \
159 bus_space_write_1((_sc)->gic_d_bst, (_sc)->gic_d_bsh, (_reg), (_val))
160 #define gic_d_write_4(_sc, _reg, _val) \
161 bus_space_write_4((_sc)->gic_d_bst, (_sc)->gic_d_bsh, (_reg), (_val))
164 static int gic_config_irq(int irq, enum intr_trigger trig,
165 enum intr_polarity pol);
166 static void gic_post_filter(void *);
171 gic_irq_unmask(struct arm_gic_softc *sc, u_int irq)
174 gic_d_write_4(sc, GICD_ISENABLER(irq), (1UL << (irq & 0x1F)));
178 gic_irq_mask(struct arm_gic_softc *sc, u_int irq)
181 gic_d_write_4(sc, GICD_ICENABLER(irq), (1UL << (irq & 0x1F)));
186 gic_cpu_mask(struct arm_gic_softc *sc)
191 /* Read the current cpuid mask by reading ITARGETSR{0..7} */
192 for (i = 0; i < 8; i++) {
193 mask = gic_d_read_4(sc, GICD_ITARGETSR(i));
197 /* No mask found, assume we are on CPU interface 0 */
201 /* Collect the mask in the lower byte */
211 arm_gic_init_secondary(device_t dev)
213 struct arm_gic_softc *sc = device_get_softc(dev);
216 /* Set the mask so we can find this CPU to send it IPIs */
217 cpu = PCPU_GET(cpuid);
218 arm_gic_map[cpu] = gic_cpu_mask(sc);
220 for (irq = 0; irq < sc->nirqs; irq += 4)
221 gic_d_write_4(sc, GICD_IPRIORITYR(irq), 0);
223 /* Set all the interrupts to be in Group 0 (secure) */
224 for (irq = 0; GIC_SUPPORT_SECEXT(sc) && irq < sc->nirqs; irq += 32) {
225 gic_d_write_4(sc, GICD_IGROUPR(irq), 0);
228 /* Enable CPU interface */
229 gic_c_write_4(sc, GICC_CTLR, 1);
231 /* Set priority mask register. */
232 gic_c_write_4(sc, GICC_PMR, 0xff);
234 /* Enable interrupt distribution */
235 gic_d_write_4(sc, GICD_CTLR, 0x01);
237 /* Unmask attached SGI interrupts. */
238 for (irq = GIC_FIRST_SGI; irq <= GIC_LAST_SGI; irq++)
239 if (intr_isrc_init_on_cpu(GIC_INTR_ISRC(sc, irq), cpu))
240 gic_irq_unmask(sc, irq);
242 /* Unmask attached PPI interrupts. */
243 for (irq = GIC_FIRST_PPI; irq <= GIC_LAST_PPI; irq++)
244 if (intr_isrc_init_on_cpu(GIC_INTR_ISRC(sc, irq), cpu))
245 gic_irq_unmask(sc, irq);
249 arm_gic_init_secondary(device_t dev)
251 struct arm_gic_softc *sc = device_get_softc(dev);
254 /* Set the mask so we can find this CPU to send it IPIs */
255 arm_gic_map[PCPU_GET(cpuid)] = gic_cpu_mask(sc);
257 for (i = 0; i < sc->nirqs; i += 4)
258 gic_d_write_4(sc, GICD_IPRIORITYR(i), 0);
260 /* Set all the interrupts to be in Group 0 (secure) */
261 for (i = 0; GIC_SUPPORT_SECEXT(sc) && i < sc->nirqs; i += 32) {
262 gic_d_write_4(sc, GICD_IGROUPR(i), 0);
265 /* Enable CPU interface */
266 gic_c_write_4(sc, GICC_CTLR, 1);
268 /* Set priority mask register. */
269 gic_c_write_4(sc, GICC_PMR, 0xff);
271 /* Enable interrupt distribution */
272 gic_d_write_4(sc, GICD_CTLR, 0x01);
275 * Activate the timer interrupts: virtual, secure, and non-secure.
277 gic_d_write_4(sc, GICD_ISENABLER(27), (1UL << (27 & 0x1F)));
278 gic_d_write_4(sc, GICD_ISENABLER(29), (1UL << (29 & 0x1F)));
279 gic_d_write_4(sc, GICD_ISENABLER(30), (1UL << (30 & 0x1F)));
286 gic_decode_fdt(phandle_t iparent, pcell_t *intr, int *interrupt,
289 static u_int num_intr_cells;
290 static phandle_t self;
291 struct ofw_compat_data *ocd;
294 for (ocd = compat_data; ocd->ocd_str != NULL; ocd++) {
295 if (ofw_bus_node_is_compatible(iparent, ocd->ocd_str)) {
304 if (num_intr_cells == 0) {
305 if (OF_searchencprop(OF_node_from_xref(iparent),
306 "#interrupt-cells", &num_intr_cells,
307 sizeof(num_intr_cells)) == -1) {
312 if (num_intr_cells == 1) {
313 *interrupt = fdt32_to_cpu(intr[0]);
314 *trig = INTR_TRIGGER_CONFORM;
315 *pol = INTR_POLARITY_CONFORM;
317 if (fdt32_to_cpu(intr[0]) == 0)
318 *interrupt = fdt32_to_cpu(intr[1]) + GIC_FIRST_SPI;
320 *interrupt = fdt32_to_cpu(intr[1]) + GIC_FIRST_PPI;
322 * In intr[2], bits[3:0] are trigger type and level flags.
323 * 1 = low-to-high edge triggered
324 * 2 = high-to-low edge triggered
325 * 4 = active high level-sensitive
326 * 8 = active low level-sensitive
327 * The hardware only supports active-high-level or rising-edge
330 if (*interrupt >= GIC_FIRST_SPI &&
331 fdt32_to_cpu(intr[2]) & 0x0a) {
332 printf("unsupported trigger/polarity configuration "
333 "0x%02x\n", fdt32_to_cpu(intr[2]) & 0x0f);
335 *pol = INTR_POLARITY_CONFORM;
336 if (fdt32_to_cpu(intr[2]) & 0x03)
337 *trig = INTR_TRIGGER_EDGE;
339 *trig = INTR_TRIGGER_LEVEL;
347 arm_gic_register_isrcs(struct arm_gic_softc *sc, uint32_t num)
351 struct gic_irqsrc *irqs;
352 struct intr_irqsrc *isrc;
355 irqs = malloc(num * sizeof(struct gic_irqsrc), M_DEVBUF,
358 name = device_get_nameunit(sc->gic_dev);
359 for (irq = 0; irq < num; irq++) {
360 irqs[irq].gi_irq = irq;
361 irqs[irq].gi_pol = INTR_POLARITY_CONFORM;
362 irqs[irq].gi_trig = INTR_TRIGGER_CONFORM;
364 isrc = &irqs[irq].gi_isrc;
365 if (irq <= GIC_LAST_SGI) {
366 error = intr_isrc_register(isrc, sc->gic_dev,
367 INTR_ISRCF_IPI, "%s,i%u", name, irq - GIC_FIRST_SGI);
368 } else if (irq <= GIC_LAST_PPI) {
369 error = intr_isrc_register(isrc, sc->gic_dev,
370 INTR_ISRCF_PPI, "%s,p%u", name, irq - GIC_FIRST_PPI);
372 error = intr_isrc_register(isrc, sc->gic_dev, 0,
373 "%s,s%u", name, irq - GIC_FIRST_SPI);
376 /* XXX call intr_isrc_deregister() */
377 free(irqs, M_DEVBUF);
387 arm_gic_reserve_msi_range(device_t dev, u_int start, u_int count)
389 struct arm_gic_softc *sc;
392 sc = device_get_softc(dev);
394 KASSERT((start + count) < sc->nirqs,
395 ("%s: Trying to allocate too many MSI IRQs: %d + %d > %d", __func__,
396 start, count, sc->nirqs));
397 for (i = 0; i < count; i++) {
398 KASSERT(sc->gic_irqs[start + i].gi_isrc.isrc_handlers == 0,
399 ("%s: MSI interrupt %d already has a handler", __func__,
401 KASSERT(sc->gic_irqs[start + i].gi_pol == INTR_POLARITY_CONFORM,
402 ("%s: MSI interrupt %d already has a polarity", __func__,
404 KASSERT(sc->gic_irqs[start + i].gi_trig == INTR_TRIGGER_CONFORM,
405 ("%s: MSI interrupt %d already has a trigger", __func__,
407 sc->gic_irqs[start + i].gi_pol = INTR_POLARITY_HIGH;
408 sc->gic_irqs[start + i].gi_trig = INTR_TRIGGER_EDGE;
409 sc->gic_irqs[start + i].gi_flags |= GI_FLAG_MSI;
415 arm_gic_attach(device_t dev)
417 struct arm_gic_softc *sc;
419 uint32_t icciidr, mask, nirqs;
424 sc = device_get_softc(dev);
426 if (bus_alloc_resources(dev, arm_gic_spec, sc->gic_res)) {
427 device_printf(dev, "could not allocate resources\n");
434 /* Initialize mutex */
435 mtx_init(&sc->mutex, "GIC lock", "", MTX_SPIN);
437 /* Distributor Interface */
438 sc->gic_d_bst = rman_get_bustag(sc->gic_res[0]);
439 sc->gic_d_bsh = rman_get_bushandle(sc->gic_res[0]);
442 sc->gic_c_bst = rman_get_bustag(sc->gic_res[1]);
443 sc->gic_c_bsh = rman_get_bushandle(sc->gic_res[1]);
445 /* Disable interrupt forwarding to the CPU interface */
446 gic_d_write_4(sc, GICD_CTLR, 0x00);
448 /* Get the number of interrupts */
449 sc->typer = gic_d_read_4(sc, GICD_TYPER);
450 nirqs = 32 * ((sc->typer & 0x1f) + 1);
453 if (arm_gic_register_isrcs(sc, nirqs)) {
454 device_printf(dev, "could not register irqs\n");
460 /* Set up function pointers */
461 arm_post_filter = gic_post_filter;
462 arm_config_irq = gic_config_irq;
465 icciidr = gic_c_read_4(sc, GICC_IIDR);
467 "pn 0x%x, arch 0x%x, rev 0x%x, implementer 0x%x irqs %u\n",
468 GICD_IIDR_PROD(icciidr), GICD_IIDR_VAR(icciidr),
469 GICD_IIDR_REV(icciidr), GICD_IIDR_IMPL(icciidr), sc->nirqs);
471 /* Set all global interrupts to be level triggered, active low. */
472 for (i = 32; i < sc->nirqs; i += 16) {
473 gic_d_write_4(sc, GICD_ICFGR(i), GIC_DEFAULT_ICFGR_INIT);
476 /* Disable all interrupts. */
477 for (i = 32; i < sc->nirqs; i += 32) {
478 gic_d_write_4(sc, GICD_ICENABLER(i), 0xFFFFFFFF);
481 /* Find the current cpu mask */
482 mask = gic_cpu_mask(sc);
483 /* Set the mask so we can find this CPU to send it IPIs */
484 arm_gic_map[PCPU_GET(cpuid)] = mask;
485 /* Set all four targets to this cpu */
489 for (i = 0; i < sc->nirqs; i += 4) {
490 gic_d_write_4(sc, GICD_IPRIORITYR(i), 0);
492 gic_d_write_4(sc, GICD_ITARGETSR(i), mask);
496 /* Set all the interrupts to be in Group 0 (secure) */
497 for (i = 0; GIC_SUPPORT_SECEXT(sc) && i < sc->nirqs; i += 32) {
498 gic_d_write_4(sc, GICD_IGROUPR(i), 0);
501 /* Enable CPU interface */
502 gic_c_write_4(sc, GICC_CTLR, 1);
504 /* Set priority mask register. */
505 gic_c_write_4(sc, GICC_PMR, 0xff);
507 /* Enable interrupt distribution */
508 gic_d_write_4(sc, GICD_CTLR, 0x01);
519 arm_gic_detach(device_t dev)
522 struct arm_gic_softc *sc;
524 sc = device_get_softc(dev);
526 if (sc->gic_irqs != NULL)
527 free(sc->gic_irqs, M_DEVBUF);
529 bus_release_resources(dev, arm_gic_spec, sc->gic_res);
537 arm_gic_print_child(device_t bus, device_t child)
539 struct resource_list *rl;
542 rv = bus_print_child_header(bus, child);
544 rl = BUS_GET_RESOURCE_LIST(bus, child);
546 rv += resource_list_print_type(rl, "mem", SYS_RES_MEMORY,
548 rv += resource_list_print_type(rl, "irq", SYS_RES_IRQ, "%jd");
551 rv += bus_print_child_footer(bus, child);
556 static struct resource *
557 arm_gic_alloc_resource(device_t bus, device_t child, int type, int *rid,
558 rman_res_t start, rman_res_t end, rman_res_t count, u_int flags)
560 struct arm_gic_softc *sc;
561 struct resource_list_entry *rle;
562 struct resource_list *rl;
565 KASSERT(type == SYS_RES_MEMORY, ("Invalid resoure type %x", type));
567 sc = device_get_softc(bus);
570 * Request for the default allocation with a given rid: use resource
571 * list stored in the local device info.
573 if (RMAN_IS_DEFAULT_RANGE(start, end)) {
574 rl = BUS_GET_RESOURCE_LIST(bus, child);
576 if (type == SYS_RES_IOPORT)
577 type = SYS_RES_MEMORY;
579 rle = resource_list_find(rl, type, *rid);
582 device_printf(bus, "no default resources for "
583 "rid = %d, type = %d\n", *rid, type);
591 /* Remap through ranges property */
592 for (j = 0; j < sc->nranges; j++) {
593 if (start >= sc->ranges[j].bus && end <
594 sc->ranges[j].bus + sc->ranges[j].size) {
595 start -= sc->ranges[j].bus;
596 start += sc->ranges[j].host;
597 end -= sc->ranges[j].bus;
598 end += sc->ranges[j].host;
602 if (j == sc->nranges && sc->nranges != 0) {
604 device_printf(bus, "Could not map resource "
605 "%#jx-%#jx\n", (uintmax_t)start, (uintmax_t)end);
610 return (bus_generic_alloc_resource(bus, child, type, rid, start, end,
615 arm_gic_intr(void *arg)
617 struct arm_gic_softc *sc = arg;
618 struct gic_irqsrc *gi;
619 uint32_t irq_active_reg, irq;
620 struct trapframe *tf;
622 irq_active_reg = gic_c_read_4(sc, GICC_IAR);
623 irq = irq_active_reg & 0x3FF;
626 * 1. We do EOI here because recent read value from active interrupt
627 * register must be used for it. Another approach is to save this
628 * value into associated interrupt source.
629 * 2. EOI must be done on same CPU where interrupt has fired. Thus
630 * we must ensure that interrupted thread does not migrate to
632 * 3. EOI cannot be delayed by any preemption which could happen on
633 * critical_exit() used in MI intr code, when interrupt thread is
634 * scheduled. See next point.
635 * 4. IPI_RENDEZVOUS assumes that no preemption is permitted during
636 * an action and any use of critical_exit() could break this
637 * assumption. See comments within smp_rendezvous_action().
638 * 5. We always return FILTER_HANDLED as this is an interrupt
639 * controller dispatch function. Otherwise, in cascaded interrupt
640 * case, the whole interrupt subtree would be masked.
643 if (irq >= sc->nirqs) {
644 #ifdef GIC_DEBUG_SPURIOUS
645 device_printf(sc->gic_dev,
646 "Spurious interrupt detected: last irq: %d on CPU%d\n",
647 sc->last_irq[PCPU_GET(cpuid)], PCPU_GET(cpuid));
649 return (FILTER_HANDLED);
652 tf = curthread->td_intr_frame;
654 gi = sc->gic_irqs + irq;
656 * Note that GIC_FIRST_SGI is zero and is not used in 'if' statement
657 * as compiler complains that comparing u_int >= 0 is always true.
659 if (irq <= GIC_LAST_SGI) {
661 /* Call EOI for all IPI before dispatch. */
662 gic_c_write_4(sc, GICC_EOIR, irq_active_reg);
663 intr_ipi_dispatch(sgi_to_ipi[gi->gi_irq], tf);
666 device_printf(sc->gic_dev, "SGI %u on UP system detected\n",
667 irq - GIC_FIRST_SGI);
668 gic_c_write_4(sc, GICC_EOIR, irq_active_reg);
673 #ifdef GIC_DEBUG_SPURIOUS
674 sc->last_irq[PCPU_GET(cpuid)] = irq;
676 if ((gi->gi_flags & GI_FLAG_EARLY_EOI) == GI_FLAG_EARLY_EOI)
677 gic_c_write_4(sc, GICC_EOIR, irq_active_reg);
679 if (intr_isrc_dispatch(&gi->gi_isrc, tf) != 0) {
680 gic_irq_mask(sc, irq);
681 if ((gi->gi_flags & GI_FLAG_EARLY_EOI) != GI_FLAG_EARLY_EOI)
682 gic_c_write_4(sc, GICC_EOIR, irq_active_reg);
683 device_printf(sc->gic_dev, "Stray irq %u disabled\n", irq);
687 arm_irq_memory_barrier(irq);
688 irq_active_reg = gic_c_read_4(sc, GICC_IAR);
689 irq = irq_active_reg & 0x3FF;
693 return (FILTER_HANDLED);
697 gic_config(struct arm_gic_softc *sc, u_int irq, enum intr_trigger trig,
698 enum intr_polarity pol)
703 if (irq < GIC_FIRST_SPI)
706 mtx_lock_spin(&sc->mutex);
708 reg = gic_d_read_4(sc, GICD_ICFGR(irq));
709 mask = (reg >> 2*(irq % 16)) & 0x3;
711 if (pol == INTR_POLARITY_LOW) {
712 mask &= ~GICD_ICFGR_POL_MASK;
713 mask |= GICD_ICFGR_POL_LOW;
714 } else if (pol == INTR_POLARITY_HIGH) {
715 mask &= ~GICD_ICFGR_POL_MASK;
716 mask |= GICD_ICFGR_POL_HIGH;
719 if (trig == INTR_TRIGGER_LEVEL) {
720 mask &= ~GICD_ICFGR_TRIG_MASK;
721 mask |= GICD_ICFGR_TRIG_LVL;
722 } else if (trig == INTR_TRIGGER_EDGE) {
723 mask &= ~GICD_ICFGR_TRIG_MASK;
724 mask |= GICD_ICFGR_TRIG_EDGE;
728 reg = reg & ~(0x3 << 2*(irq % 16));
729 reg = reg | (mask << 2*(irq % 16));
730 gic_d_write_4(sc, GICD_ICFGR(irq), reg);
732 mtx_unlock_spin(&sc->mutex);
736 gic_bind(struct arm_gic_softc *sc, u_int irq, cpuset_t *cpus)
738 uint32_t cpu, end, mask;
740 end = min(mp_ncpus, 8);
741 for (cpu = end; cpu < MAXCPU; cpu++)
742 if (CPU_ISSET(cpu, cpus))
745 for (mask = 0, cpu = 0; cpu < end; cpu++)
746 if (CPU_ISSET(cpu, cpus))
747 mask |= arm_gic_map[cpu];
749 gic_d_write_1(sc, GICD_ITARGETSR(0) + irq, mask);
755 gic_map_fdt(device_t dev, u_int ncells, pcell_t *cells, u_int *irqp,
756 enum intr_polarity *polp, enum intr_trigger *trigp)
761 *polp = INTR_POLARITY_CONFORM;
762 *trigp = INTR_TRIGGER_CONFORM;
769 * The 1st cell is the interrupt type:
772 * The 2nd cell contains the interrupt number:
775 * The 3rd cell is the flags, encoded as follows:
776 * bits[3:0] trigger type and level flags
777 * 1 = low-to-high edge triggered
778 * 2 = high-to-low edge triggered
779 * 4 = active high level-sensitive
780 * 8 = active low level-sensitive
781 * bits[15:8] PPI interrupt cpu mask
782 * Each bit corresponds to each of the 8 possible cpus
783 * attached to the GIC. A bit set to '1' indicated
784 * the interrupt is wired to that CPU.
788 irq = GIC_FIRST_SPI + cells[1];
789 /* SPI irq is checked later. */
792 irq = GIC_FIRST_PPI + cells[1];
793 if (irq > GIC_LAST_PPI) {
794 device_printf(dev, "unsupported PPI interrupt "
795 "number %u\n", cells[1]);
800 device_printf(dev, "unsupported interrupt type "
801 "configuration %u\n", cells[0]);
805 tripol = cells[2] & 0xff;
806 if (tripol & 0xf0 || (tripol & FDT_INTR_LOW_MASK &&
808 device_printf(dev, "unsupported trigger/polarity "
809 "configuration 0x%02x\n", tripol);
812 *polp = INTR_POLARITY_CONFORM;
813 *trigp = tripol & FDT_INTR_EDGE_MASK ?
814 INTR_TRIGGER_EDGE : INTR_TRIGGER_LEVEL;
822 gic_map_msi(device_t dev, struct intr_map_data_msi *msi_data, u_int *irqp,
823 enum intr_polarity *polp, enum intr_trigger *trigp)
825 struct gic_irqsrc *gi;
827 /* Map a non-GICv2m MSI */
828 gi = (struct gic_irqsrc *)msi_data->isrc;
834 /* MSI/MSI-X interrupts are always edge triggered with high polarity */
835 *polp = INTR_POLARITY_HIGH;
836 *trigp = INTR_TRIGGER_EDGE;
842 gic_map_intr(device_t dev, struct intr_map_data *data, u_int *irqp,
843 enum intr_polarity *polp, enum intr_trigger *trigp)
846 enum intr_polarity pol;
847 enum intr_trigger trig;
848 struct arm_gic_softc *sc;
849 struct intr_map_data_msi *dam;
851 struct intr_map_data_fdt *daf;
854 sc = device_get_softc(dev);
855 switch (data->type) {
857 case INTR_MAP_DATA_FDT:
858 daf = (struct intr_map_data_fdt *)data;
859 if (gic_map_fdt(dev, daf->ncells, daf->cells, &irq, &pol,
862 KASSERT(irq >= sc->nirqs ||
863 (sc->gic_irqs[irq].gi_flags & GI_FLAG_MSI) == 0,
864 ("%s: Attempting to map a MSI interrupt from FDT",
868 case INTR_MAP_DATA_MSI:
870 dam = (struct intr_map_data_msi *)data;
871 if (gic_map_msi(dev, dam, &irq, &pol, &trig) != 0)
878 if (irq >= sc->nirqs)
880 if (pol != INTR_POLARITY_CONFORM && pol != INTR_POLARITY_LOW &&
881 pol != INTR_POLARITY_HIGH)
883 if (trig != INTR_TRIGGER_CONFORM && trig != INTR_TRIGGER_EDGE &&
884 trig != INTR_TRIGGER_LEVEL)
896 arm_gic_map_intr(device_t dev, struct intr_map_data *data,
897 struct intr_irqsrc **isrcp)
901 struct arm_gic_softc *sc;
903 error = gic_map_intr(dev, data, &irq, NULL, NULL);
905 sc = device_get_softc(dev);
906 *isrcp = GIC_INTR_ISRC(sc, irq);
912 arm_gic_setup_intr(device_t dev, struct intr_irqsrc *isrc,
913 struct resource *res, struct intr_map_data *data)
915 struct arm_gic_softc *sc = device_get_softc(dev);
916 struct gic_irqsrc *gi = (struct gic_irqsrc *)isrc;
917 enum intr_trigger trig;
918 enum intr_polarity pol;
920 if ((gi->gi_flags & GI_FLAG_MSI) == GI_FLAG_MSI) {
924 KASSERT(pol == INTR_POLARITY_HIGH,
925 ("%s: MSI interrupts must be active-high", __func__));
926 KASSERT(trig == INTR_TRIGGER_EDGE,
927 ("%s: MSI interrupts must be edge triggered", __func__));
928 } else if (data != NULL) {
931 /* Get config for resource. */
932 if (gic_map_intr(dev, data, &irq, &pol, &trig) ||
936 pol = INTR_POLARITY_CONFORM;
937 trig = INTR_TRIGGER_CONFORM;
940 /* Compare config if this is not first setup. */
941 if (isrc->isrc_handlers != 0) {
942 if ((pol != INTR_POLARITY_CONFORM && pol != gi->gi_pol) ||
943 (trig != INTR_TRIGGER_CONFORM && trig != gi->gi_trig))
949 /* For MSI/MSI-X we should have already configured these */
950 if ((gi->gi_flags & GI_FLAG_MSI) == 0) {
951 if (pol == INTR_POLARITY_CONFORM)
952 pol = INTR_POLARITY_LOW; /* just pick some */
953 if (trig == INTR_TRIGGER_CONFORM)
954 trig = INTR_TRIGGER_EDGE; /* just pick some */
959 /* Edge triggered interrupts need an early EOI sent */
960 if (gi->gi_pol == INTR_TRIGGER_EDGE)
961 gi->gi_flags |= GI_FLAG_EARLY_EOI;
965 * XXX - In case that per CPU interrupt is going to be enabled in time
966 * when SMP is already started, we need some IPI call which
967 * enables it on others CPUs. Further, it's more complicated as
968 * pic_enable_source() and pic_disable_source() should act on
969 * per CPU basis only. Thus, it should be solved here somehow.
971 if (isrc->isrc_flags & INTR_ISRCF_PPI)
972 CPU_SET(PCPU_GET(cpuid), &isrc->isrc_cpu);
974 gic_config(sc, gi->gi_irq, gi->gi_trig, gi->gi_pol);
975 arm_gic_bind_intr(dev, isrc);
980 arm_gic_teardown_intr(device_t dev, struct intr_irqsrc *isrc,
981 struct resource *res, struct intr_map_data *data)
983 struct gic_irqsrc *gi = (struct gic_irqsrc *)isrc;
985 if (isrc->isrc_handlers == 0 && (gi->gi_flags & GI_FLAG_MSI) == 0) {
986 gi->gi_pol = INTR_POLARITY_CONFORM;
987 gi->gi_trig = INTR_TRIGGER_CONFORM;
993 arm_gic_enable_intr(device_t dev, struct intr_irqsrc *isrc)
995 struct arm_gic_softc *sc = device_get_softc(dev);
996 struct gic_irqsrc *gi = (struct gic_irqsrc *)isrc;
998 arm_irq_memory_barrier(gi->gi_irq);
999 gic_irq_unmask(sc, gi->gi_irq);
1003 arm_gic_disable_intr(device_t dev, struct intr_irqsrc *isrc)
1005 struct arm_gic_softc *sc = device_get_softc(dev);
1006 struct gic_irqsrc *gi = (struct gic_irqsrc *)isrc;
1008 gic_irq_mask(sc, gi->gi_irq);
1012 arm_gic_pre_ithread(device_t dev, struct intr_irqsrc *isrc)
1014 struct arm_gic_softc *sc = device_get_softc(dev);
1015 struct gic_irqsrc *gi = (struct gic_irqsrc *)isrc;
1017 arm_gic_disable_intr(dev, isrc);
1018 gic_c_write_4(sc, GICC_EOIR, gi->gi_irq);
1022 arm_gic_post_ithread(device_t dev, struct intr_irqsrc *isrc)
1025 arm_irq_memory_barrier(0);
1026 arm_gic_enable_intr(dev, isrc);
1030 arm_gic_post_filter(device_t dev, struct intr_irqsrc *isrc)
1032 struct arm_gic_softc *sc = device_get_softc(dev);
1033 struct gic_irqsrc *gi = (struct gic_irqsrc *)isrc;
1035 /* EOI for edge-triggered done earlier. */
1036 if ((gi->gi_flags & GI_FLAG_EARLY_EOI) == GI_FLAG_EARLY_EOI)
1039 arm_irq_memory_barrier(0);
1040 gic_c_write_4(sc, GICC_EOIR, gi->gi_irq);
1044 arm_gic_bind_intr(device_t dev, struct intr_irqsrc *isrc)
1046 struct arm_gic_softc *sc = device_get_softc(dev);
1047 struct gic_irqsrc *gi = (struct gic_irqsrc *)isrc;
1049 if (gi->gi_irq < GIC_FIRST_SPI)
1052 if (CPU_EMPTY(&isrc->isrc_cpu)) {
1053 gic_irq_cpu = intr_irq_next_cpu(gic_irq_cpu, &all_cpus);
1054 CPU_SETOF(gic_irq_cpu, &isrc->isrc_cpu);
1056 return (gic_bind(sc, gi->gi_irq, &isrc->isrc_cpu));
1061 arm_gic_ipi_send(device_t dev, struct intr_irqsrc *isrc, cpuset_t cpus,
1064 struct arm_gic_softc *sc = device_get_softc(dev);
1065 struct gic_irqsrc *gi = (struct gic_irqsrc *)isrc;
1066 uint32_t val = 0, i;
1068 for (i = 0; i < MAXCPU; i++)
1069 if (CPU_ISSET(i, &cpus))
1070 val |= arm_gic_map[i] << GICD_SGI_TARGET_SHIFT;
1072 gic_d_write_4(sc, GICD_SGIR, val | gi->gi_irq);
1076 arm_gic_ipi_setup(device_t dev, u_int ipi, struct intr_irqsrc **isrcp)
1078 struct intr_irqsrc *isrc;
1079 struct arm_gic_softc *sc = device_get_softc(dev);
1081 if (sgi_first_unused > GIC_LAST_SGI)
1084 isrc = GIC_INTR_ISRC(sc, sgi_first_unused);
1085 sgi_to_ipi[sgi_first_unused++] = ipi;
1087 CPU_SET(PCPU_GET(cpuid), &isrc->isrc_cpu);
1095 arm_gic_next_irq(struct arm_gic_softc *sc, int last_irq)
1097 uint32_t active_irq;
1099 active_irq = gic_c_read_4(sc, GICC_IAR);
1102 * Immediately EOIR the SGIs, because doing so requires the other
1103 * bits (ie CPU number), not just the IRQ number, and we do not
1104 * have this information later.
1106 if ((active_irq & 0x3ff) <= GIC_LAST_SGI)
1107 gic_c_write_4(sc, GICC_EOIR, active_irq);
1108 active_irq &= 0x3FF;
1110 if (active_irq == 0x3FF) {
1112 device_printf(sc->gic_dev,
1113 "Spurious interrupt detected\n");
1121 arm_gic_config(device_t dev, int irq, enum intr_trigger trig,
1122 enum intr_polarity pol)
1124 struct arm_gic_softc *sc = device_get_softc(dev);
1128 /* Function is public-accessible, so validate input arguments */
1129 if ((irq < 0) || (irq >= sc->nirqs))
1131 if ((trig != INTR_TRIGGER_EDGE) && (trig != INTR_TRIGGER_LEVEL) &&
1132 (trig != INTR_TRIGGER_CONFORM))
1134 if ((pol != INTR_POLARITY_HIGH) && (pol != INTR_POLARITY_LOW) &&
1135 (pol != INTR_POLARITY_CONFORM))
1138 mtx_lock_spin(&sc->mutex);
1140 reg = gic_d_read_4(sc, GICD_ICFGR(irq));
1141 mask = (reg >> 2*(irq % 16)) & 0x3;
1143 if (pol == INTR_POLARITY_LOW) {
1144 mask &= ~GICD_ICFGR_POL_MASK;
1145 mask |= GICD_ICFGR_POL_LOW;
1146 } else if (pol == INTR_POLARITY_HIGH) {
1147 mask &= ~GICD_ICFGR_POL_MASK;
1148 mask |= GICD_ICFGR_POL_HIGH;
1151 if (trig == INTR_TRIGGER_LEVEL) {
1152 mask &= ~GICD_ICFGR_TRIG_MASK;
1153 mask |= GICD_ICFGR_TRIG_LVL;
1154 } else if (trig == INTR_TRIGGER_EDGE) {
1155 mask &= ~GICD_ICFGR_TRIG_MASK;
1156 mask |= GICD_ICFGR_TRIG_EDGE;
1160 reg = reg & ~(0x3 << 2*(irq % 16));
1161 reg = reg | (mask << 2*(irq % 16));
1162 gic_d_write_4(sc, GICD_ICFGR(irq), reg);
1164 mtx_unlock_spin(&sc->mutex);
1169 device_printf(dev, "gic_config_irg, invalid parameters\n");
1175 arm_gic_mask(device_t dev, int irq)
1177 struct arm_gic_softc *sc = device_get_softc(dev);
1179 gic_d_write_4(sc, GICD_ICENABLER(irq), (1UL << (irq & 0x1F)));
1180 gic_c_write_4(sc, GICC_EOIR, irq); /* XXX - not allowed */
1184 arm_gic_unmask(device_t dev, int irq)
1186 struct arm_gic_softc *sc = device_get_softc(dev);
1188 if (irq > GIC_LAST_SGI)
1189 arm_irq_memory_barrier(irq);
1191 gic_d_write_4(sc, GICD_ISENABLER(irq), (1UL << (irq & 0x1F)));
1196 arm_gic_ipi_send(device_t dev, cpuset_t cpus, u_int ipi)
1198 struct arm_gic_softc *sc = device_get_softc(dev);
1199 uint32_t val = 0, i;
1201 for (i = 0; i < MAXCPU; i++)
1202 if (CPU_ISSET(i, &cpus))
1203 val |= arm_gic_map[i] << GICD_SGI_TARGET_SHIFT;
1205 gic_d_write_4(sc, GICD_SGIR, val | ipi);
1209 arm_gic_ipi_read(device_t dev, int i)
1214 * The intr code will automagically give the frame pointer
1215 * if the interrupt argument is 0.
1217 if ((unsigned int)i > 16)
1226 arm_gic_ipi_clear(device_t dev, int ipi)
1233 gic_post_filter(void *arg)
1235 struct arm_gic_softc *sc = gic_sc;
1236 uintptr_t irq = (uintptr_t) arg;
1238 if (irq > GIC_LAST_SGI)
1239 arm_irq_memory_barrier(irq);
1240 gic_c_write_4(sc, GICC_EOIR, irq);
1244 gic_config_irq(int irq, enum intr_trigger trig, enum intr_polarity pol)
1247 return (arm_gic_config(gic_sc->gic_dev, irq, trig, pol));
1251 arm_mask_irq(uintptr_t nb)
1254 arm_gic_mask(gic_sc->gic_dev, nb);
1258 arm_unmask_irq(uintptr_t nb)
1261 arm_gic_unmask(gic_sc->gic_dev, nb);
1265 arm_get_next_irq(int last_irq)
1268 return (arm_gic_next_irq(gic_sc, last_irq));
1273 intr_pic_init_secondary(void)
1276 arm_gic_init_secondary(gic_sc->gic_dev);
1280 pic_ipi_send(cpuset_t cpus, u_int ipi)
1283 arm_gic_ipi_send(gic_sc->gic_dev, cpus, ipi);
1290 return (arm_gic_ipi_read(gic_sc->gic_dev, i));
1294 pic_ipi_clear(int ipi)
1297 arm_gic_ipi_clear(gic_sc->gic_dev, ipi);
1302 static device_method_t arm_gic_methods[] = {
1305 DEVMETHOD(bus_print_child, arm_gic_print_child),
1306 DEVMETHOD(bus_add_child, bus_generic_add_child),
1307 DEVMETHOD(bus_alloc_resource, arm_gic_alloc_resource),
1308 DEVMETHOD(bus_release_resource, bus_generic_release_resource),
1309 DEVMETHOD(bus_activate_resource,bus_generic_activate_resource),
1311 /* Interrupt controller interface */
1312 DEVMETHOD(pic_disable_intr, arm_gic_disable_intr),
1313 DEVMETHOD(pic_enable_intr, arm_gic_enable_intr),
1314 DEVMETHOD(pic_map_intr, arm_gic_map_intr),
1315 DEVMETHOD(pic_setup_intr, arm_gic_setup_intr),
1316 DEVMETHOD(pic_teardown_intr, arm_gic_teardown_intr),
1317 DEVMETHOD(pic_post_filter, arm_gic_post_filter),
1318 DEVMETHOD(pic_post_ithread, arm_gic_post_ithread),
1319 DEVMETHOD(pic_pre_ithread, arm_gic_pre_ithread),
1321 DEVMETHOD(pic_bind_intr, arm_gic_bind_intr),
1322 DEVMETHOD(pic_init_secondary, arm_gic_init_secondary),
1323 DEVMETHOD(pic_ipi_send, arm_gic_ipi_send),
1324 DEVMETHOD(pic_ipi_setup, arm_gic_ipi_setup),
1330 DEFINE_CLASS_0(gic, arm_gic_driver, arm_gic_methods,
1331 sizeof(struct arm_gic_softc));
1335 * GICv2m support -- the GICv2 MSI/MSI-X controller.
1338 #define GICV2M_MSI_TYPER 0x008
1339 #define MSI_TYPER_SPI_BASE(x) (((x) >> 16) & 0x3ff)
1340 #define MSI_TYPER_SPI_COUNT(x) (((x) >> 0) & 0x3ff)
1341 #define GICv2M_MSI_SETSPI_NS 0x040
1342 #define GICV2M_MSI_IIDR 0xFCC
1345 arm_gicv2m_attach(device_t dev)
1347 struct arm_gicv2m_softc *sc;
1348 struct arm_gic_softc *psc;
1352 psc = device_get_softc(device_get_parent(dev));
1353 sc = device_get_softc(dev);
1356 sc->sc_mem = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid,
1358 if (sc->sc_mem == NULL) {
1359 device_printf(dev, "Unable to allocate resources\n");
1363 typer = bus_read_4(sc->sc_mem, GICV2M_MSI_TYPER);
1364 sc->sc_spi_start = MSI_TYPER_SPI_BASE(typer);
1365 sc->sc_spi_count = MSI_TYPER_SPI_COUNT(typer);
1366 sc->sc_spi_end = sc->sc_spi_start + sc->sc_spi_count;
1368 /* Reserve these interrupts for MSI/MSI-X use */
1369 arm_gic_reserve_msi_range(device_get_parent(dev), sc->sc_spi_start,
1372 mtx_init(&sc->sc_mutex, "GICv2m lock", "", MTX_DEF);
1374 intr_msi_register(dev, sc->sc_xref);
1377 device_printf(dev, "using spi %u to %u\n", sc->sc_spi_start,
1378 sc->sc_spi_start + sc->sc_spi_count - 1);
1384 arm_gicv2m_alloc_msi(device_t dev, device_t child, int count, int maxcount,
1385 device_t *pic, struct intr_irqsrc **srcs)
1387 struct arm_gic_softc *psc;
1388 struct arm_gicv2m_softc *sc;
1389 int i, irq, end_irq;
1392 KASSERT(powerof2(count), ("%s: bad count", __func__));
1393 KASSERT(powerof2(maxcount), ("%s: bad maxcount", __func__));
1395 psc = device_get_softc(device_get_parent(dev));
1396 sc = device_get_softc(dev);
1398 mtx_lock(&sc->sc_mutex);
1401 for (irq = sc->sc_spi_start; irq < sc->sc_spi_end && !found; irq++) {
1402 /* Start on an aligned interrupt */
1403 if ((irq & (maxcount - 1)) != 0)
1406 /* Assume we found a valid range until shown otherwise */
1409 /* Check this range is valid */
1410 for (end_irq = irq; end_irq != irq + count - 1; end_irq++) {
1411 /* No free interrupts */
1412 if (end_irq == sc->sc_spi_end) {
1417 KASSERT((psc->gic_irqs[irq].gi_flags & GI_FLAG_MSI)!= 0,
1418 ("%s: Non-MSI interrupt found", __func__));
1420 /* This is already used */
1421 if ((psc->gic_irqs[irq].gi_flags & GI_FLAG_MSI_USED) ==
1429 /* Not enough interrupts were found */
1430 if (!found || irq == sc->sc_spi_end) {
1431 mtx_unlock(&sc->sc_mutex);
1435 for (i = 0; i < count; i++) {
1436 /* Mark the interrupt as used */
1437 psc->gic_irqs[irq + i].gi_flags |= GI_FLAG_MSI_USED;
1440 mtx_unlock(&sc->sc_mutex);
1442 for (i = 0; i < count; i++)
1443 srcs[i] = (struct intr_irqsrc *)&psc->gic_irqs[irq + i];
1444 *pic = device_get_parent(dev);
1450 arm_gicv2m_release_msi(device_t dev, device_t child, int count,
1451 struct intr_irqsrc **isrc)
1453 struct arm_gicv2m_softc *sc;
1454 struct gic_irqsrc *gi;
1457 sc = device_get_softc(dev);
1459 mtx_lock(&sc->sc_mutex);
1460 for (i = 0; i < count; i++) {
1461 gi = (struct gic_irqsrc *)isrc[i];
1463 KASSERT((gi->gi_flags & GI_FLAG_MSI_USED) == GI_FLAG_MSI_USED,
1464 ("%s: Trying to release an unused MSI-X interrupt",
1467 gi->gi_flags &= ~GI_FLAG_MSI_USED;
1469 mtx_unlock(&sc->sc_mutex);
1475 arm_gicv2m_alloc_msix(device_t dev, device_t child, device_t *pic,
1476 struct intr_irqsrc **isrcp)
1478 struct arm_gicv2m_softc *sc;
1479 struct arm_gic_softc *psc;
1482 psc = device_get_softc(device_get_parent(dev));
1483 sc = device_get_softc(dev);
1485 mtx_lock(&sc->sc_mutex);
1486 /* Find an unused interrupt */
1487 for (irq = sc->sc_spi_start; irq < sc->sc_spi_end; irq++) {
1488 KASSERT((psc->gic_irqs[irq].gi_flags & GI_FLAG_MSI) != 0,
1489 ("%s: Non-MSI interrupt found", __func__));
1490 if ((psc->gic_irqs[irq].gi_flags & GI_FLAG_MSI_USED) == 0)
1493 /* No free interrupt was found */
1494 if (irq == sc->sc_spi_end) {
1495 mtx_unlock(&sc->sc_mutex);
1499 /* Mark the interrupt as used */
1500 psc->gic_irqs[irq].gi_flags |= GI_FLAG_MSI_USED;
1501 mtx_unlock(&sc->sc_mutex);
1503 *isrcp = (struct intr_irqsrc *)&psc->gic_irqs[irq];
1504 *pic = device_get_parent(dev);
1510 arm_gicv2m_release_msix(device_t dev, device_t child, struct intr_irqsrc *isrc)
1512 struct arm_gicv2m_softc *sc;
1513 struct gic_irqsrc *gi;
1515 sc = device_get_softc(dev);
1516 gi = (struct gic_irqsrc *)isrc;
1518 KASSERT((gi->gi_flags & GI_FLAG_MSI_USED) == GI_FLAG_MSI_USED,
1519 ("%s: Trying to release an unused MSI-X interrupt", __func__));
1521 mtx_lock(&sc->sc_mutex);
1522 gi->gi_flags &= ~GI_FLAG_MSI_USED;
1523 mtx_unlock(&sc->sc_mutex);
1529 arm_gicv2m_map_msi(device_t dev, device_t child, struct intr_irqsrc *isrc,
1530 uint64_t *addr, uint32_t *data)
1532 struct arm_gicv2m_softc *sc = device_get_softc(dev);
1533 struct gic_irqsrc *gi = (struct gic_irqsrc *)isrc;
1535 *addr = vtophys(rman_get_virtual(sc->sc_mem)) + GICv2M_MSI_SETSPI_NS;
1541 static device_method_t arm_gicv2m_methods[] = {
1542 /* Device interface */
1543 DEVMETHOD(device_attach, arm_gicv2m_attach),
1546 DEVMETHOD(msi_alloc_msi, arm_gicv2m_alloc_msi),
1547 DEVMETHOD(msi_release_msi, arm_gicv2m_release_msi),
1548 DEVMETHOD(msi_alloc_msix, arm_gicv2m_alloc_msix),
1549 DEVMETHOD(msi_release_msix, arm_gicv2m_release_msix),
1550 DEVMETHOD(msi_map_msi, arm_gicv2m_map_msi),
1556 DEFINE_CLASS_0(gicv2m, arm_gicv2m_driver, arm_gicv2m_methods,
1557 sizeof(struct arm_gicv2m_softc));