summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2007-04-01 21:41:10 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2007-04-01 21:41:10 +0000
commitc676f8905e2d66cc0ef2d1ecdf314f3d96ec7b39 (patch)
tree49e1e68e72c16f0413b7a05bf12e408121b37df2 /sys
parentc33e2ff696d74a46d429fae1207cdd3eb6db33b1 (diff)
Add code to establish interrupts.
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/sparc64/dev/pyro.c61
-rw-r--r--sys/arch/sparc64/dev/pyrovar.h4
2 files changed, 62 insertions, 3 deletions
diff --git a/sys/arch/sparc64/dev/pyro.c b/sys/arch/sparc64/dev/pyro.c
index 1e5291d88b4..e881d06c185 100644
--- a/sys/arch/sparc64/dev/pyro.c
+++ b/sys/arch/sparc64/dev/pyro.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pyro.c,v 1.5 2007/04/01 12:50:18 kettenis Exp $ */
+/* $OpenBSD: pyro.c,v 1.6 2007/04/01 21:41:09 kettenis Exp $ */
/*
* Copyright (c) 2002 Jason L. Wright (jason@thought.net)
@@ -109,6 +109,8 @@ pyro_attach(struct device *parent, struct device *self, void *aux)
sc->sc_node = ma->ma_node;
sc->sc_dmat = ma->ma_dmatag;
sc->sc_bust = ma->ma_bustag;
+ sc->sc_csr = ma->ma_reg[0].ur_paddr;
+ sc->sc_xbc = ma->ma_reg[1].ur_paddr;
sc->sc_ign = INTIGN(ma->ma_upaid << INTMAP_IGN_SHIFT);
if ((ma->ma_reg[0].ur_paddr & 0x00700000) == 0x00600000)
@@ -116,6 +118,18 @@ pyro_attach(struct device *parent, struct device *self, void *aux)
else
busa = 0;
+ if (bus_space_map(sc->sc_bust, sc->sc_csr,
+ ma->ma_reg[0].ur_len, 0, &sc->sc_csrh)) {
+ printf(": failed to map csr registers\n");
+ return;
+ }
+
+ if (bus_space_map(sc->sc_bust, sc->sc_xbc,
+ ma->ma_reg[1].ur_len, 0, &sc->sc_xbch)) {
+ printf(": failed to map xbc registers\n");
+ return;
+ }
+
pyro_init(sc, busa);
}
@@ -402,7 +416,50 @@ void *
_pyro_intr_establish(bus_space_tag_t t, bus_space_tag_t t0, int ihandle,
int level, int flags, int (*handler)(void *), void *arg, const char *what)
{
- return (NULL);
+ struct pyro_pbm *pbm = t->cookie;
+ struct pyro_softc *sc = pbm->pp_sc;
+ struct intrhand *ih = NULL;
+ volatile u_int64_t *intrmapptr = NULL, *intrclrptr = NULL;
+ int ino;
+
+ ino = INTINO(ihandle);
+
+ if (level == IPL_NONE)
+ level = INTLEV(ihandle);
+ if (level == IPL_NONE) {
+ printf(": no IPL, setting IPL 2.\n");
+ level = 2;
+ }
+
+ if ((flags & BUS_INTR_ESTABLISH_SOFTINTR) == 0) {
+ u_int64_t *imap, *iclr;
+
+ imap = bus_space_vaddr(sc->sc_bust, sc->sc_csrh) + 0x1000;
+ iclr = bus_space_vaddr(sc->sc_bust, sc->sc_csrh) + 0x1400;
+ intrmapptr = &imap[ino];
+ intrclrptr = &iclr[ino];
+ ino |= INTVEC(ihandle);
+ }
+
+ ih = bus_intr_allocate(t0, handler, arg, ino, level, intrmapptr,
+ intrclrptr, what);
+ if (ih == NULL)
+ return (NULL);
+
+ intr_establish(ih->ih_pil, ih);
+
+ if (intrmapptr != NULL) {
+ u_int64_t intrmap;
+
+ intrmap = *intrmapptr;
+ intrmap |= (1LL << 6);
+ intrmap |= INTMAP_V;
+ *intrmapptr = intrmap;
+ intrmap = *intrmapptr;
+ ih->ih_number |= intrmap & INTMAP_INR;
+ }
+
+ return (ih);
}
const struct cfattach pyro_ca = {
diff --git a/sys/arch/sparc64/dev/pyrovar.h b/sys/arch/sparc64/dev/pyrovar.h
index cfc8d41968b..702d6b67f66 100644
--- a/sys/arch/sparc64/dev/pyrovar.h
+++ b/sys/arch/sparc64/dev/pyrovar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: pyrovar.h,v 1.1 2007/03/30 22:24:56 kettenis Exp $ */
+/* $OpenBSD: pyrovar.h,v 1.2 2007/04/01 21:41:09 kettenis Exp $ */
/*
* Copyright (c) 2007 Mark Kettenis
@@ -57,6 +57,8 @@ struct pyro_softc {
int sc_ign;
bus_dma_tag_t sc_dmat;
bus_space_tag_t sc_bust;
+ bus_addr_t sc_csr, sc_xbc;
+ bus_space_handle_t sc_csrh, sc_xbch;
int sc_oberon;
};