Implement IRQ masking and unmasking in imxgpio(4).
authorpatrick <patrick@openbsd.org>
Wed, 8 Aug 2018 11:06:47 +0000 (11:06 +0000)
committerpatrick <patrick@openbsd.org>
Wed, 8 Aug 2018 11:06:47 +0000 (11:06 +0000)
sys/dev/fdt/imxgpio.c

index fee6856..4a108c2 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: imxgpio.c,v 1.2 2018/08/06 10:52:30 patrick Exp $ */
+/* $OpenBSD: imxgpio.c,v 1.3 2018/08/08 11:06:47 patrick Exp $ */
 /*
  * Copyright (c) 2007,2009 Dale Rahn <drahn@openbsd.org>
  * Copyright (c) 2012-2013 Patrick Wildt <patrick@blueri.se>
@@ -82,6 +82,8 @@ void *imxgpio_intr_establish(void *, int *, int, int (*)(void *),
     void *, char *);
 void imxgpio_intr_disestablish(void *);
 void imxgpio_recalc_ipl(struct imxgpio_softc *);
+void imxgpio_intr_enable(void *);
+void imxgpio_intr_disable(void *);
 
 
 struct cfattach        imxgpio_ca = {
@@ -131,6 +133,8 @@ imxgpio_attach(struct device *parent, struct device *self, void *aux)
        sc->sc_ic.ic_cookie = sc;
        sc->sc_ic.ic_establish = imxgpio_intr_establish;
        sc->sc_ic.ic_disestablish = imxgpio_intr_disestablish;
+       sc->sc_ic.ic_enable = imxgpio_intr_enable;
+       sc->sc_ic.ic_disable = imxgpio_intr_disable;
        fdt_intr_register(&sc->sc_ic);
 
        printf("\n");
@@ -372,3 +376,33 @@ imxgpio_recalc_ipl(struct imxgpio_softc *sc)
                }
        }
 }
+
+void
+imxgpio_intr_enable(void *cookie)
+{
+       struct intrhand         *ih = cookie;
+       struct imxgpio_softc    *sc = ih->ih_sc;
+       uint32_t                 mask;
+       int                      s;
+
+       s = splhigh();
+       mask = bus_space_read_4(sc->sc_iot, sc->sc_ioh, GPIO_IMR);
+       mask |= (1 << ih->ih_irq);
+       bus_space_write_4(sc->sc_iot, sc->sc_ioh, GPIO_IMR, mask);
+       splx(s);
+}
+
+void
+imxgpio_intr_disable(void *cookie)
+{
+       struct intrhand         *ih = cookie;
+       struct imxgpio_softc    *sc = ih->ih_sc;
+       uint32_t                 mask;
+       int                      s;
+
+       s = splhigh();
+       mask = bus_space_read_4(sc->sc_iot, sc->sc_ioh, GPIO_IMR);
+       mask &= ~(1 << ih->ih_irq);
+       bus_space_write_4(sc->sc_iot, sc->sc_ioh, GPIO_IMR, mask);
+       splx(s);
+}