static int obio_teardown_intr(device_t dev, device_t child, struct resource *ires, void *cookie) { struct obio_softc *sc = device_get_softc(dev); int irq, result; uint32_t mask_register, mask, ip_bit; irq = rman_get_start(ires); if (irq >= NIRQS) panic("%s: bad irq %d", __func__, irq); if (sc->sc_eventstab[irq] == NULL) panic("Trying to teardown unoccupied IRQ"); /* mask IRQ */ mask_register = ICU_IRQ_MASK_REG(irq); ip_bit = ICU_IP_BIT(irq); mask = ICU_REG_READ(mask_register); ICU_REG_WRITE(mask_register, mask | ip_bit); result = intr_event_remove_handler(cookie); if (!result) sc->sc_eventstab[irq] = NULL; return (result); }
static void obio_unmask_irq(void *arg) { unsigned int irq = (unsigned int)arg; int ip_bit, mask, mask_register; /* unmask IRQ */ mask_register = ICU_IRQ_MASK_REG(irq); ip_bit = ICU_IP_BIT(irq); mask = ICU_REG_READ(mask_register); ICU_REG_WRITE(mask_register, mask & ~ip_bit); }
static void obio_mask_irq(void *arg) { /* XXX need to write */ #if 0 unsigned int irq = (unsigned int)arg; int ip_bit, mask, mask_register; /* mask IRQ */ mask_register = ICU_IRQ_MASK_REG(irq); ip_bit = ICU_IP_BIT(irq); mask = ICU_REG_READ(mask_register); ICU_REG_WRITE(mask_register, mask | ip_bit); #endif }
static int obio_setup_intr(device_t dev, device_t child, struct resource *ires, int flags, driver_filter_t *filt, driver_intr_t *handler, void *arg, void **cookiep) { struct obio_softc *sc = device_get_softc(dev); struct intr_event *event; int irq, ip_bit, error, mask, mask_register; irq = rman_get_start(ires); if (irq >= NIRQS) panic("%s: bad irq %d", __func__, irq); event = sc->sc_eventstab[irq]; if (event == NULL) { error = intr_event_create(&event, (void *)irq, 0, irq, obio_mask_irq, obio_unmask_irq, NULL, NULL, "obio intr%d:", irq); sc->sc_eventstab[irq] = event; } intr_event_add_handler(event, device_get_nameunit(child), filt, handler, arg, intr_priority(flags), flags, cookiep); /* unmask IRQ */ mask_register = ICU_IRQ_MASK_REG(irq); ip_bit = ICU_IP_BIT(irq); mask = ICU_REG_READ(mask_register); ICU_REG_WRITE(mask_register, mask & ~ip_bit); return (0); }