diff options
Diffstat (limited to 'sys/dev/gpio/pl061.c')
-rw-r--r-- | sys/dev/gpio/pl061.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/sys/dev/gpio/pl061.c b/sys/dev/gpio/pl061.c index 76754fead635..87d4310a6396 100644 --- a/sys/dev/gpio/pl061.c +++ b/sys/dev/gpio/pl061.c @@ -460,6 +460,9 @@ pl061_attach(device_t dev) goto free_mem; } + /* Mask all interrupts. They will be unmasked as needed later */ + bus_write_1(sc->sc_mem_res, PL061_INTMASK, 0); + ret = bus_setup_intr(dev, sc->sc_irq_res, INTR_TYPE_MISC | INTR_MPSAFE, pl061_intr, NULL, sc, &sc->sc_irq_hdlr); if (ret) { @@ -484,14 +487,21 @@ pl061_attach(device_t dev) } } + mtx_init(&sc->sc_mtx, device_get_nameunit(dev), "pl061", MTX_SPIN); + + if (sc->sc_xref != 0 && !intr_pic_register(dev, sc->sc_xref)) { + device_printf(dev, "couldn't register PIC\n"); + PL061_LOCK_DESTROY(sc); + goto free_isrc; + } + sc->sc_busdev = gpiobus_attach_bus(dev); if (sc->sc_busdev == NULL) { device_printf(dev, "couldn't attach gpio bus\n"); + PL061_LOCK_DESTROY(sc); goto free_isrc; } - mtx_init(&sc->sc_mtx, device_get_nameunit(dev), "pl061", MTX_SPIN); - return (0); free_isrc: @@ -500,6 +510,7 @@ free_isrc: * for (irq = 0; irq < PL061_NUM_GPIO; irq++) * intr_isrc_deregister(PIC_INTR_ISRC(sc, irq)); */ + bus_teardown_intr(dev, sc->sc_irq_res, sc->sc_irq_hdlr); bus_release_resource(dev, SYS_RES_IRQ, sc->sc_irq_rid, sc->sc_irq_res); free_pic: |