Module Name:    src
Committed By:   mrg
Date:           Wed Jan  6 05:55:01 UTC 2010

Modified Files:
        src/sys/arch/sparc64/dev: pci_machdep.c psycho.c schizo.c
        src/sys/arch/sparc64/include: pci_machdep.h

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.65 -r1.66 src/sys/arch/sparc64/dev/pci_machdep.c
cvs rdiff -u -r1.99 -r1.100 src/sys/arch/sparc64/dev/psycho.c
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/sparc64/dev/schizo.c
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/sparc64/include/pci_machdep.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sparc64/dev/pci_machdep.c
diff -u src/sys/arch/sparc64/dev/pci_machdep.c:1.65 src/sys/arch/sparc64/dev/pci_machdep.c:1.66
--- src/sys/arch/sparc64/dev/pci_machdep.c:1.65	Mon Nov 30 05:00:58 2009
+++ src/sys/arch/sparc64/dev/pci_machdep.c	Wed Jan  6 05:55:01 2010
@@ -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)
 {

Index: src/sys/arch/sparc64/dev/psycho.c
diff -u src/sys/arch/sparc64/dev/psycho.c:1.99 src/sys/arch/sparc64/dev/psycho.c:1.100
--- src/sys/arch/sparc64/dev/psycho.c:1.99	Wed Dec 30 17:16:49 2009
+++ src/sys/arch/sparc64/dev/psycho.c	Wed Jan  6 05:55:01 2010
@@ -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)

Index: src/sys/arch/sparc64/dev/schizo.c
diff -u src/sys/arch/sparc64/dev/schizo.c:1.11 src/sys/arch/sparc64/dev/schizo.c:1.12
--- src/sys/arch/sparc64/dev/schizo.c:1.11	Wed Dec 30 20:20:56 2009
+++ src/sys/arch/sparc64/dev/schizo.c	Wed Jan  6 05:55:01 2010
@@ -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);
 }

Index: src/sys/arch/sparc64/include/pci_machdep.h
diff -u src/sys/arch/sparc64/include/pci_machdep.h:1.23 src/sys/arch/sparc64/include/pci_machdep.h:1.24
--- src/sys/arch/sparc64/include/pci_machdep.h:1.23	Mon Nov 30 05:00:58 2009
+++ src/sys/arch/sparc64/include/pci_machdep.h	Wed Jan  6 05:55:01 2010
@@ -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))
 

Reply via email to