Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/sparc64 move the guts of pci_intr_map() into pci_ma...
details: https://anonhg.NetBSD.org/src/rev/0352a223d411
branches: trunk
changeset: 750553:0352a223d411
user: mrg <mrg%NetBSD.org@localhost>
date: Wed Jan 06 05:55:01 2010 +0000
description:
move the guts of pci_intr_map() into pci_machdep.c, and move the schizo
ign addition into a hook. also, don't double shift the ign in set_intr.
tested on U60 and SB2500.
diffstat:
sys/arch/sparc64/dev/pci_machdep.c | 51 ++++++++++++++++++++++++++++++++-
sys/arch/sparc64/dev/psycho.c | 51 ++--------------------------------
sys/arch/sparc64/dev/schizo.c | 39 ++-----------------------
sys/arch/sparc64/include/pci_machdep.h | 5 +--
4 files changed, 58 insertions(+), 88 deletions(-)
diffs (251 lines):
diff -r bf848ef6a6ad -r 0352a223d411 sys/arch/sparc64/dev/pci_machdep.c
--- a/sys/arch/sparc64/dev/pci_machdep.c Tue Jan 05 22:42:16 2010 +0000
+++ b/sys/arch/sparc64/dev/pci_machdep.c Wed Jan 06 05:55:01 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pci_machdep.c,v 1.65 2009/11/30 05:00:58 mrg Exp $ */
+/* $NetBSD: pci_machdep.c,v 1.66 2010/01/06 05:55:01 mrg Exp $ */
/*
* Copyright (c) 1999, 2000 Matthew R. Green
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.65 2009/11/30 05:00:58 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.66 2010/01/06 05:55:01 mrg Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -407,6 +407,53 @@
}
}
+/*
+ * interrupt mapping foo.
+ * XXX: how does this deal with multiple interrupts for a device?
+ */
+int
+pci_intr_map(struct pci_attach_args *pa, pci_intr_handle_t *ihp)
+{
+ pcitag_t tag = pa->pa_tag;
+ int interrupts, *intp;
+ int len, node = PCITAG_NODE(tag);
+ char devtype[30];
+
+ intp = &interrupts;
+ len = 1;
+ if (prom_getprop(node, "interrupts", sizeof(interrupts),
+ &len, &intp) != 0 || len != 1) {
+ DPRINTF(SPDB_INTMAP,
+ ("pci_intr_map: could not read interrupts\n"));
+ return (ENODEV);
+ }
+
+ if (OF_mapintr(node, &interrupts, sizeof(interrupts),
+ sizeof(interrupts)) < 0) {
+ printf("OF_mapintr failed\n");
+ KASSERT(pa->pa_pc->spc_find_ino);
+ pa->pa_pc->spc_find_ino(pa, &interrupts);
+ }
+ DPRINTF(SPDB_INTMAP, ("OF_mapintr() gave %x\n", interrupts));
+
+ /* Try to find an IPL for this type of device. */
+ prom_getpropstringA(node, "device_type", devtype, sizeof(devtype));
+ for (len = 0; intrmap[len].in_class != NULL; len++)
+ if (strcmp(intrmap[len].in_class, devtype) == 0) {
+ interrupts |= INTLEVENCODE(intrmap[len].in_lev);
+ DPRINTF(SPDB_INTMAP, ("reset to %x\n", interrupts));
+ break;
+ }
+
+ *ihp = interrupts;
+
+ /* Call the sub-driver is necessary */
+ if (pa->pa_pc->spc_intr_map)
+ (*pa->pa_pc->spc_intr_map)(pa, ihp);
+
+ return (0);
+}
+
void
pci_intr_disestablish(pci_chipset_tag_t pc, void *cookie)
{
diff -r bf848ef6a6ad -r 0352a223d411 sys/arch/sparc64/dev/psycho.c
--- a/sys/arch/sparc64/dev/psycho.c Tue Jan 05 22:42:16 2010 +0000
+++ b/sys/arch/sparc64/dev/psycho.c Wed Jan 06 05:55:01 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: psycho.c,v 1.99 2009/12/30 17:16:49 nakayama Exp $ */
+/* $NetBSD: psycho.c,v 1.100 2010/01/06 05:55:01 mrg Exp $ */
/*
* Copyright (c) 1999, 2000 Matthew R. Green
@@ -55,7 +55,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: psycho.c,v 1.99 2009/12/30 17:16:49 nakayama Exp $");
+__KERNEL_RCSID(0, "$NetBSD: psycho.c,v 1.100 2010/01/06 05:55:01 mrg Exp $");
#include "opt_ddb.h"
@@ -116,8 +116,6 @@
static pcireg_t psycho_pci_conf_read(pci_chipset_tag_t, pcitag_t, int);
static void psycho_pci_conf_write(pci_chipset_tag_t, pcitag_t, int,
pcireg_t);
-static int psycho_pci_intr_map(struct pci_attach_args *,
- pci_intr_handle_t *);
static void *psycho_pci_intr_establish(pci_chipset_tag_t,
pci_intr_handle_t,
int, int (*)(void *), void *);
@@ -753,7 +751,7 @@
npc->rootnode = node;
npc->spc_conf_read = psycho_pci_conf_read;
npc->spc_conf_write = psycho_pci_conf_write;
- npc->spc_intr_map = psycho_pci_intr_map;
+ npc->spc_intr_map = NULL;
npc->spc_intr_establish = psycho_pci_intr_establish;
npc->spc_find_ino = psycho_pci_find_ino;
@@ -1389,49 +1387,6 @@
PCITAG_OFFSET(tag) + reg, data);
}
-/*
- * interrupt mapping foo.
- * XXX: how does this deal with multiple interrupts for a device?
- */
-int
-psycho_pci_intr_map(struct pci_attach_args *pa, pci_intr_handle_t *ihp)
-{
- pcitag_t tag = pa->pa_tag;
- int interrupts, *intp;
- int len, node = PCITAG_NODE(tag);
- char devtype[30];
-
- intp = &interrupts;
- len = 1;
- if (prom_getprop(node, "interrupts", sizeof(interrupts),
- &len, &intp) != 0 || len != 1) {
- DPRINTF(PDB_INTMAP,
- ("%s: could not read interrupts\n", __func__));
- return (ENODEV);
- }
-
- if (OF_mapintr(node, &interrupts, sizeof(interrupts),
- sizeof(interrupts)) < 0) {
- printf("OF_mapintr failed\n");
- KASSERT(pa->pa_pc->spc_find_ino);
- pa->pa_pc->spc_find_ino(pa, &interrupts);
- }
- DPRINTF(PDB_INTMAP, ("OF_mapintr() gave %x\n", interrupts));
-
- /* Try to find an IPL for this type of device. */
- prom_getpropstringA(node, "device_type", devtype, sizeof(devtype));
- for (len = 0; intrmap[len].in_class != NULL; len++)
- if (strcmp(intrmap[len].in_class, devtype) == 0) {
- interrupts |= INTLEVENCODE(intrmap[len].in_lev);
- DPRINTF(PDB_INTMAP, ("reset to %x\n", interrupts));
- break;
- }
-
- /* XXXX -- we use the ino. What if there is a valid IGN? */
- *ihp = interrupts;
- return (0);
-}
-
static void *
psycho_pci_intr_establish(pci_chipset_tag_t pc, pci_intr_handle_t ih, int level,
int (*func)(void *), void *arg)
diff -r bf848ef6a6ad -r 0352a223d411 sys/arch/sparc64/dev/schizo.c
--- a/sys/arch/sparc64/dev/schizo.c Tue Jan 05 22:42:16 2010 +0000
+++ b/sys/arch/sparc64/dev/schizo.c Wed Jan 06 05:55:01 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: schizo.c,v 1.11 2009/12/30 20:20:56 nakayama Exp $ */
+/* $NetBSD: schizo.c,v 1.12 2010/01/06 05:55:01 mrg Exp $ */
/* $OpenBSD: schizo.c,v 1.55 2008/08/18 20:29:37 brad Exp $ */
/*
@@ -489,7 +489,7 @@
mapoff = offsetof(struct schizo_pbm_regs, imap[ino]);
clroff = offsetof(struct schizo_pbm_regs, iclr[ino]);
- ino |= (sc->sc_ign << INTMAP_IGN_SHIFT);
+ ino |= sc->sc_ign;
DPRINTF(SDB_INTR, (" mapoff %lx clroff %lx\n", mapoff, clroff));
@@ -690,46 +690,15 @@
}
/*
- * interrupt mapping foo.
- * XXX: how does this deal with multiple interrupts for a device?
+ * Set the IGN for this schizo into the handle.
*/
int
schizo_pci_intr_map(struct pci_attach_args *pa, pci_intr_handle_t *ihp)
{
- pcitag_t tag = pa->pa_tag;
struct schizo_pbm *pbm = pa->pa_pc->cookie;
struct schizo_softc *sc = pbm->sp_sc;
- int interrupts, *intp;
- int len, node = PCITAG_NODE(tag);
- char devtype[30];
- intp = &interrupts;
- len = 1;
- if (prom_getprop(node, "interrupts", sizeof(interrupts),
- &len, &intp) != 0 || len != 1) {
- DPRINTF(SDB_INTMAP,
- ("pci_intr_map: could not read interrupts\n"));
- return (ENODEV);
- }
-
- if (OF_mapintr(node, &interrupts, sizeof(interrupts),
- sizeof(interrupts)) < 0) {
- printf("OF_mapintr failed\n");
- KASSERT(pa->pa_pc->spc_find_ino);
- pa->pa_pc->spc_find_ino(pa, &interrupts);
- }
- DPRINTF(SDB_INTMAP, ("OF_mapintr() gave %x\n", interrupts));
-
- /* Try to find an IPL for this type of device. */
- prom_getpropstringA(node, "device_type", devtype, sizeof(devtype));
- for (len = 0; intrmap[len].in_class != NULL; len++)
- if (strcmp(intrmap[len].in_class, devtype) == 0) {
- interrupts |= INTLEVENCODE(intrmap[len].in_lev);
- DPRINTF(SDB_INTMAP, ("reset to %x\n", interrupts));
- break;
- }
-
- *ihp = interrupts | sc->sc_ign;
+ *ihp |= sc->sc_ign;
DPRINTF(SDB_INTMAP, ("returning IGN adjusted to %x\n", *ihp));
return (0);
}
diff -r bf848ef6a6ad -r 0352a223d411 sys/arch/sparc64/include/pci_machdep.h
--- a/sys/arch/sparc64/include/pci_machdep.h Tue Jan 05 22:42:16 2010 +0000
+++ b/sys/arch/sparc64/include/pci_machdep.h Wed Jan 06 05:55:01 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pci_machdep.h,v 1.23 2009/11/30 05:00:58 mrg Exp $ */
+/* $NetBSD: pci_machdep.h,v 1.24 2010/01/06 05:55:01 mrg Exp $ */
/*
* Copyright (c) 1999 Matthew R. Green
@@ -90,6 +90,7 @@
int *);
const char *pci_intr_string(pci_chipset_tag_t, pci_intr_handle_t);
const struct evcnt *pci_intr_evcnt(pci_chipset_tag_t, pci_intr_handle_t);
+int pci_intr_map(struct pci_attach_args *, pci_intr_handle_t *);
void pci_intr_disestablish(pci_chipset_tag_t, void *);
int sparc64_pci_enumerate_bus(struct pci_softc *, const int *,
@@ -101,8 +102,6 @@
((pc)->spc_conf_read(pc, tag, reg))
#define pci_conf_write(pc, tag, reg, val) \
((pc)->spc_conf_write(pc, tag, reg, val))
-#define pci_intr_map(pa, handle) \
- ((pa)->pa_pc->spc_intr_map(pa, handle))
#define pci_intr_establish(pc, handle, level, func, arg) \
((pc)->spc_intr_establish(pc, handle, level, func, arg))
Home |
Main Index |
Thread Index |
Old Index