summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2015-07-26 05:09:45 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2015-07-26 05:09:45 +0000
commit1b983136d78f25b523b32856fe6fdc7681a81a26 (patch)
treea285ce9d0fbe44d8487689cf331e7c630dfcc447
parenta9a4f197443fb352dc09cd672abc908f9abc2782 (diff)
Make sure pci_intr_map() will perform proper interrupt swizzling for devices
behind a bridge, if the SRM didn't pick an interrupt line for them.
-rw-r--r--sys/arch/alpha/pci/pci_1000.c37
-rw-r--r--sys/arch/alpha/pci/pci_1000a.c16
-rw-r--r--sys/arch/alpha/pci/pci_2100_a50.c65
-rw-r--r--sys/arch/alpha/pci/pci_550.c68
-rw-r--r--sys/arch/alpha/pci/pci_6600.c59
-rw-r--r--sys/arch/alpha/pci/pci_alphabook1.c41
-rw-r--r--sys/arch/alpha/pci/pci_axppci_33.c57
-rw-r--r--sys/arch/alpha/pci/pci_eb164.c57
-rw-r--r--sys/arch/alpha/pci/pci_eb64plus.c44
-rw-r--r--sys/arch/alpha/pci/pci_kn20aa.c39
-rw-r--r--sys/arch/alpha/pci/pci_kn300.c23
-rw-r--r--sys/arch/alpha/pci/pci_machdep.c15
-rw-r--r--sys/arch/alpha/pci/pci_machdep.h8
-rw-r--r--sys/arch/alpha/pci/pci_up1000.c59
14 files changed, 265 insertions, 323 deletions
diff --git a/sys/arch/alpha/pci/pci_1000.c b/sys/arch/alpha/pci/pci_1000.c
index 69b2ca92f16..deac6a60c6c 100644
--- a/sys/arch/alpha/pci/pci_1000.c
+++ b/sys/arch/alpha/pci/pci_1000.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pci_1000.c,v 1.10 2009/09/30 20:16:30 miod Exp $ */
+/* $OpenBSD: pci_1000.c,v 1.11 2015/07/26 05:09:44 miod Exp $ */
/* $NetBSD: pci_1000.c,v 1.12 2001/07/27 00:25:20 thorpej Exp $ */
/*
@@ -73,6 +73,7 @@
#include <dev/pci/pcireg.h>
#include <dev/pci/pcivar.h>
+#include <dev/pci/ppbreg.h>
#include <alpha/pci/pci_1000.h>
@@ -107,9 +108,6 @@ pci_1000_pickintr(core, iot, memt, pc)
bus_space_tag_t iot, memt;
pci_chipset_tag_t pc;
{
-#if 0
- char *cp;
-#endif
int i;
another_mystery_icu_iot = iot;
@@ -145,19 +143,33 @@ dec_1000_intr_map(pa, ihp)
pci_intr_handle_t *ihp;
{
pcitag_t bustag = pa->pa_intrtag;
- int buspin = pa->pa_intrpin;
- int device;
+ int buspin, device, line = pa->pa_intrline;
+
+ /*
+ * The console places the interrupt mapping in the "line" value.
+ * We trust it whenever possible.
+ */
+ if (line >= 0 && line < PCI_NIRQ) {
+ *ihp = line;
+ return 0;
+ }
- if (buspin == 0) /* No IRQ used. */
- return 1;
- if (!(1 <= buspin && buspin <= 4))
- goto bad;
+ if (pa->pa_bridgetag) {
+ buspin = PPB_INTERRUPT_SWIZZLE(pa->pa_rawintrpin,
+ pa->pa_device);
+ if (pa->pa_bridgeih[buspin - 1] == 0)
+ return 1;
+
+ *ihp = pa->pa_bridgeih[buspin - 1];
+ return 0;
+ }
+ buspin = pa->pa_intrpin;
pci_decompose_tag(pa->pa_pc, bustag, NULL, &device, NULL);
- switch(device) {
+ switch (device) {
case 6:
- if(buspin != 1)
+ if (buspin != 1)
break;
*ihp = 0xc; /* integrated ncr scsi */
return 0;
@@ -168,7 +180,6 @@ dec_1000_intr_map(pa, ihp)
return 0;
}
-bad:
return 1;
}
diff --git a/sys/arch/alpha/pci/pci_1000a.c b/sys/arch/alpha/pci/pci_1000a.c
index 75d9f2e262f..02dd1e4d86d 100644
--- a/sys/arch/alpha/pci/pci_1000a.c
+++ b/sys/arch/alpha/pci/pci_1000a.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pci_1000a.c,v 1.12 2009/09/30 20:16:30 miod Exp $ */
+/* $OpenBSD: pci_1000a.c,v 1.13 2015/07/26 05:09:44 miod Exp $ */
/* $NetBSD: pci_1000a.c,v 1.14 2001/07/27 00:25:20 thorpej Exp $ */
/*
@@ -146,7 +146,7 @@ dec_1000a_intr_map(pa, ihp)
pci_intr_handle_t *ihp;
{
pcitag_t bustag = pa->pa_intrtag;
- int buspin = pa->pa_intrpin, line = pa->pa_intrline;
+ int buspin, line = pa->pa_intrline;
int imrbit = 0, bus, device;
/*
* Get bit number in mystery ICU imr
@@ -177,13 +177,6 @@ dec_1000a_intr_map(pa, ihp)
/* 4 */ IRQSPLIT(14)
};
- if (buspin == 0) /* No IRQ used. */
- return 1;
- if (!(1 <= buspin && buspin <= 4))
- goto bad;
-
- pci_decompose_tag(pa->pa_pc, bustag, &bus, &device, NULL);
-
/*
* The console places the interrupt mapping in the "line" value.
* We trust it whenever possible.
@@ -217,6 +210,9 @@ dec_1000a_intr_map(pa, ihp)
}
}
} else {
+ pci_decompose_tag(pa->pa_pc, bustag, &bus, &device,
+ NULL);
+ buspin = pa->pa_intrpin;
if (0 <= device &&
device < sizeof imrmap / sizeof imrmap[0])
imrbit = imrmap[device][buspin - 1];
@@ -227,7 +223,7 @@ dec_1000a_intr_map(pa, ihp)
*ihp = IMR2IRQ(imrbit);
return 0;
}
-bad:
+
return 1;
}
diff --git a/sys/arch/alpha/pci/pci_2100_a50.c b/sys/arch/alpha/pci/pci_2100_a50.c
index 53e8bbca5a0..efd74cddaa6 100644
--- a/sys/arch/alpha/pci/pci_2100_a50.c
+++ b/sys/arch/alpha/pci/pci_2100_a50.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pci_2100_a50.c,v 1.22 2009/08/22 02:54:50 mk Exp $ */
+/* $OpenBSD: pci_2100_a50.c,v 1.23 2015/07/26 05:09:44 miod Exp $ */
/* $NetBSD: pci_2100_a50.c,v 1.12 1996/11/13 21:13:29 cgd Exp $ */
/*
@@ -43,6 +43,7 @@
#include <dev/isa/isavar.h>
#include <dev/pci/pcireg.h>
#include <dev/pci/pcivar.h>
+#include <dev/pci/ppbreg.h>
#include <alpha/pci/apecsvar.h>
@@ -101,22 +102,23 @@ dec_2100_a50_intr_map(pa, ihp)
pci_intr_handle_t *ihp;
{
pcitag_t bustag = pa->pa_intrtag;
- int buspin = pa->pa_intrpin;
pci_chipset_tag_t pc = pa->pa_pc;
- int device, pirq;
+ int buspin, device, pirq;
pcireg_t pirqreg;
u_int8_t pirqline;
- if (buspin == 0) {
- /* No IRQ used. */
- return 1;
- }
- if (buspin > 4) {
- printf("dec_2100_a50_intr_map: bad interrupt pin %d\n",
- buspin);
- return 1;
- }
+ if (pa->pa_bridgetag) {
+ buspin = PPB_INTERRUPT_SWIZZLE(pa->pa_rawintrpin,
+ pa->pa_device);
+ if (pa->pa_bridgeih[buspin - 1] != 0) {
+ *ihp = pa->pa_bridgeih[buspin - 1];
+ return 0;
+ }
+
+ return 1;
+ }
+ buspin = pa->pa_intrpin;
pci_decompose_tag(pc, bustag, NULL, &device, NULL);
switch (device) {
@@ -127,6 +129,7 @@ dec_2100_a50_intr_map(pa, ihp)
case 11: /* slot 1 */
case 14: /* slot 3 */
switch (buspin) {
+ default:
case PCI_INTERRUPT_PIN_A:
case PCI_INTERRUPT_PIN_D:
pirq = 0;
@@ -137,16 +140,12 @@ dec_2100_a50_intr_map(pa, ihp)
case PCI_INTERRUPT_PIN_C:
pirq = 1;
break;
-#ifdef DIAGNOSTIC
- default: /* XXX gcc -Wuninitialized */
- panic("dec_2100_a50_intr_map bogus PCI pin %d",
- buspin);
-#endif
};
- break;
+ break;
case 12: /* slot 2 */
switch (buspin) {
+ default:
case PCI_INTERRUPT_PIN_A:
case PCI_INTERRUPT_PIN_D:
pirq = 1;
@@ -157,16 +156,12 @@ dec_2100_a50_intr_map(pa, ihp)
case PCI_INTERRUPT_PIN_C:
pirq = 2;
break;
-#ifdef DIAGNOSTIC
- default: /* XXX gcc -Wuninitialized */
- panic("dec_2100_a50_intr_map bogus PCI pin %d",
- buspin);
-#endif
- };
- break;
+ };
+ break;
case 13: /* slot 3 */
switch (buspin) {
+ default:
case PCI_INTERRUPT_PIN_A:
case PCI_INTERRUPT_PIN_D:
pirq = 2;
@@ -177,38 +172,24 @@ dec_2100_a50_intr_map(pa, ihp)
case PCI_INTERRUPT_PIN_C:
pirq = 0;
break;
-#ifdef DIAGNOSTIC
- default: /* XXX gcc -Wuninitialized */
- panic("dec_2100_a50_intr_map bogus PCI pin %d",
- buspin);
-#endif
};
break;
default:
- printf("dec_2100_a50_intr_map: weird device number %d\n",
- device);
+ printf("dec_2100_a50_intr_map: don't know how to setup %d/%d/%d\n",
+ pa->pa_bus, pa->pa_device, pa->pa_function);
return 1;
}
pirqreg = pci_conf_read(pc, pci_make_tag(pc, 0, APECS_SIO_DEVICE, 0),
SIO_PCIREG_PIRQ_RTCTRL);
-#if 0
- printf("pci_2100_a50_map_int: device %d pin %c: pirq %d, reg = %x\n",
- device, '@' + buspin, pirq, pirqreg);
-#endif
pirqline = (pirqreg >> (pirq * 8)) & 0xff;
if ((pirqline & 0x80) != 0)
return 1;
pirqline &= 0xf;
-#if 0
- printf("pci_2100_a50_map_int: device %d pin %c: mapped to line %d\n",
- device, '@' + buspin, pirqline);
-#endif
-
*ihp = pirqline;
- return (0);
+ return 0;
}
const char *
diff --git a/sys/arch/alpha/pci/pci_550.c b/sys/arch/alpha/pci/pci_550.c
index e1d71f92bf8..da725d53771 100644
--- a/sys/arch/alpha/pci/pci_550.c
+++ b/sys/arch/alpha/pci/pci_550.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pci_550.c,v 1.22 2010/08/07 03:50:01 krw Exp $ */
+/* $OpenBSD: pci_550.c,v 1.23 2015/07/26 05:09:44 miod Exp $ */
/* $NetBSD: pci_550.c,v 1.18 2000/06/29 08:58:48 mrg Exp $ */
/*-
@@ -74,6 +74,7 @@
#include <dev/pci/pcireg.h>
#include <dev/pci/pcivar.h>
+#include <dev/pci/ppbreg.h>
#include <dev/pci/pciidereg.h>
#include <dev/pci/pciidevar.h>
@@ -170,21 +171,7 @@ dec_550_intr_map(pa, ihp)
struct pci_attach_args *pa;
pci_intr_handle_t *ihp;
{
- pcitag_t bustag = pa->pa_intrtag;
- int buspin = pa->pa_intrpin, line = pa->pa_intrline;
- pci_chipset_tag_t pc = pa->pa_pc;
- int bus, device, function;
-
- if (buspin == 0) {
- /* No IRQ used. */
- return 1;
- }
- if (buspin > 4) {
- printf("dec_550_intr_map: bad interrupt pin %d\n", buspin);
- return 1;
- }
-
- pci_decompose_tag(pc, bustag, &bus, &device, &function);
+ int buspin, line = pa->pa_intrline;
/*
* There are two main variants of Miata: Miata 1 (Intel SIO)
@@ -201,19 +188,20 @@ dec_550_intr_map(pa, ihp)
* There will be no interrupt mapping for these devices, so just
* bail out now.
*/
- if (bus == 0) {
+ if (pa->pa_bus == 0) {
if ((hwrpb->rpb_variation & SV_ST_MASK) < SV_ST_MIATA_1_5) {
/* Miata 1 */
- if (device == 7)
+ if (pa->pa_device == 7)
panic("dec_550_intr_map: SIO device");
- else if (device == 4)
+ else if (pa->pa_device == 4)
return (1);
} else {
/* Miata 1.5 or Miata 2 */
- if (device == 7) {
- if (function == 0)
+ if (pa->pa_device == 7) {
+ if (pa->pa_function == 0)
panic("dec_550_intr_map: SIO device");
- if (function == 1 || function == 2)
+ if (pa->pa_function == 1 ||
+ pa->pa_function == 2)
return (1);
}
}
@@ -221,30 +209,34 @@ dec_550_intr_map(pa, ihp)
/*
* The console places the interrupt mapping in the "line" value.
- * A value of (char)-1 indicates there is no mapping.
+ * We trust it whenever possible.
*/
- if (line == 0xff) {
- printf("dec_550_intr_map: no mapping for %d/%d/%d\n",
- bus, device, function);
- return (1);
+ if (line >= 0 && line < DEC_550_MAX_IRQ) {
+ *ihp = line;
+ return 0;
}
-
-#if NSIO == 0
if (DEC_550_LINE_IS_ISA(line)) {
+#if NSIO > 0
+ *ihp = line;
+ return 0;
+#else
printf("dec_550_intr_map: ISA IRQ %d for %d/%d/%d\n",
- DEC_550_LINE_ISA_IRQ(line), bus, device, function);
- return (1);
- }
+ DEC_550_LINE_ISA_IRQ(line),
+ pa->pa_bus, pa->pa_device, pa->pa_function);
+ return 1;
#endif
+ }
- if (DEC_550_LINE_IS_ISA(line) == 0 && line >= DEC_550_MAX_IRQ) {
- printf("dec_550_intr_map: dec 550 irq too large (%d)",
- line);
- return (1);
+ if (pa->pa_bridgetag) {
+ buspin = PPB_INTERRUPT_SWIZZLE(pa->pa_rawintrpin,
+ pa->pa_device);
+ if (pa->pa_bridgeih[buspin - 1] != 0) {
+ *ihp = pa->pa_bridgeih[buspin - 1];
+ return 0;
+ }
}
- *ihp = line;
- return (0);
+ return 1;
}
const char *
diff --git a/sys/arch/alpha/pci/pci_6600.c b/sys/arch/alpha/pci/pci_6600.c
index 6bfceef3c15..55c20e8d5c4 100644
--- a/sys/arch/alpha/pci/pci_6600.c
+++ b/sys/arch/alpha/pci/pci_6600.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pci_6600.c,v 1.20 2014/04/14 07:36:12 mpi Exp $ */
+/* $OpenBSD: pci_6600.c,v 1.21 2015/07/26 05:09:44 miod Exp $ */
/* $NetBSD: pci_6600.c,v 1.5 2000/06/06 00:50:15 thorpej Exp $ */
/*-
@@ -45,6 +45,7 @@
#include <dev/pci/pcireg.h>
#include <dev/pci/pcivar.h>
+#include <dev/pci/ppbreg.h>
#include <dev/pci/pciidereg.h>
#include <dev/pci/pciidevar.h>
@@ -134,46 +135,38 @@ dec_6600_intr_map(pa, ihp)
struct pci_attach_args *pa;
pci_intr_handle_t *ihp;
{
- pcitag_t bustag = pa->pa_intrtag;
- int buspin = pa->pa_intrpin, line = pa->pa_intrline;
- pci_chipset_tag_t pc = pa->pa_pc;
- int bus, device, function;
-
- if (buspin == 0) {
- /* No IRQ used. */
- return 1;
- }
- if (buspin > 4) {
- printf("intr_map: bad interrupt pin %d\n", buspin);
- return 1;
- }
-
- pci_decompose_tag(pc, bustag, &bus, &device, &function);
+ int buspin, line = pa->pa_intrline;
/*
* The console places the interrupt mapping in the "line" value.
- * A value of (char)-1 indicates there is no mapping.
+ * We trust it whenever possible.
*/
- if (line == 0xff) {
- printf("dec_6600_intr_map: no mapping for %d/%d/%d\n",
- bus, device, function);
- return (1);
+ if (line >= 0 && line < PCI_NIRQ) {
+ *ihp = line;
+ return 0;
}
-
-#if NSIO == 0
if (DEC_6600_LINE_IS_ISA(line)) {
+#if NSIO > 0
+ *ihp = line;
+ return 0;
+#else
printf("dec_6600_intr_map: ISA IRQ %d for %d/%d/%d\n",
- DEC_6600_LINE_ISA_IRQ(line), bus, device, function);
- return (1);
- }
+ DEC_6600_LINE_ISA_IRQ(line),
+ pa->pa_bus, pa->pa_device, pa->pa_function);
+ return 1;
#endif
+ }
+
+ if (pa->pa_bridgetag) {
+ buspin = PPB_INTERRUPT_SWIZZLE(pa->pa_rawintrpin,
+ pa->pa_device);
+ if (pa->pa_bridgeih[buspin - 1] != 0) {
+ *ihp = pa->pa_bridgeih[buspin - 1];
+ return 0;
+ }
+ }
- if (DEC_6600_LINE_IS_ISA(line) == 0 && line >= PCI_NIRQ)
- panic("dec_6600_intr_map: dec 6600 irq too large (%d)",
- line);
-
- *ihp = line;
- return (0);
+ return 1;
}
const char *
@@ -286,7 +279,7 @@ dec_6600_iointr(arg, vec)
irq = SCB_VECTOIDX(vec - 0x900);
if (irq >= PCI_NIRQ)
- panic("iointr: irq %d is too high", irq);
+ panic("dec_6600_iointr: irq %d is too high", irq);
if (!alpha_shared_intr_dispatch(dec_6600_pci_intr, irq)) {
alpha_shared_intr_stray(dec_6600_pci_intr, irq, "6600 irq");
diff --git a/sys/arch/alpha/pci/pci_alphabook1.c b/sys/arch/alpha/pci/pci_alphabook1.c
index 832b71828b9..eaa5b8bf315 100644
--- a/sys/arch/alpha/pci/pci_alphabook1.c
+++ b/sys/arch/alpha/pci/pci_alphabook1.c
@@ -1,3 +1,4 @@
+/* $OpenBSD: pci_alphabook1.c,v 1.3 2015/07/26 05:09:44 miod Exp $ */
/* $NetBSD: pci_alphabook1.c,v 1.16 2012/02/06 02:14:15 matt Exp $ */
/*-
@@ -69,6 +70,7 @@
#include <dev/isa/isavar.h>
#include <dev/pci/pcireg.h>
#include <dev/pci/pcivar.h>
+#include <dev/pci/ppbreg.h>
#include <alpha/pci/lcavar.h>
@@ -122,25 +124,25 @@ pci_alphabook1_pickintr(struct lca_config *lcp)
}
int
-dec_alphabook1_intr_map(struct pci_attach_args *pa,
- pci_intr_handle_t *ihp)
+dec_alphabook1_intr_map(struct pci_attach_args *pa, pci_intr_handle_t *ihp)
{
pcitag_t bustag = pa->pa_intrtag;
- int buspin = pa->pa_intrpin;
- pci_chipset_tag_t pc = pa->pa_pc;
- int device, irq;
+ int buspin, device;
- if (buspin == 0) {
- /* No IRQ used. */
- return 1;
- }
- if (buspin > 4) {
- printf("dec_alphabook1_intr_map: bad interrupt pin %d\n",
- buspin);
- return 1;
+#ifdef notyet
+ if (pa->pa_bridgetag) {
+ buspin = PPB_INTERRUPT_SWIZZLE(pa->pa_rawintrpin,
+ pa->pa_device);
+ if (pa->pa_bridgeih[buspin - 1] == 0)
+ return 1;
+
+ *ihp = pa->pa_bridgeih[buspin - 1];
+ return 0;
}
+#endif
- pci_decompose_tag(pc, bustag, NULL, &device, NULL);
+ buspin = pa->pa_intrpin;
+ pci_decompose_tag(pa->pa_pc, bustag, NULL, &device, NULL);
/*
* There are only two interrupting PCI devices on the AlphaBook:
@@ -154,17 +156,14 @@ dec_alphabook1_intr_map(struct pci_attach_args *pa,
switch (device) {
case 6: /* NCR SCSI */
- irq = 14;
- break;
+ *ihp = 14;
+ return 0;
case 8: /* Cirrus CL-PD6729 */
- irq = 15;
- break;
+ *ihp = 15;
+ return 0;
default:
return 1;
}
-
- *ihp = irq;
- return (0);
}
const char *
diff --git a/sys/arch/alpha/pci/pci_axppci_33.c b/sys/arch/alpha/pci/pci_axppci_33.c
index b2b50af7d4c..ec0f6f6a8ce 100644
--- a/sys/arch/alpha/pci/pci_axppci_33.c
+++ b/sys/arch/alpha/pci/pci_axppci_33.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pci_axppci_33.c,v 1.20 2009/08/22 02:54:50 mk Exp $ */
+/* $OpenBSD: pci_axppci_33.c,v 1.21 2015/07/26 05:09:44 miod Exp $ */
/* $NetBSD: pci_axppci_33.c,v 1.10 1996/11/13 21:13:29 cgd Exp $ */
/*
@@ -43,6 +43,7 @@
#include <dev/isa/isavar.h>
#include <dev/pci/pcireg.h>
#include <dev/pci/pcivar.h>
+#include <dev/pci/ppbreg.h>
#include <alpha/pci/lcavar.h>
@@ -89,7 +90,7 @@ pci_axppci_33_pickintr(lcp)
pc->pc_pciide_compat_intr_establish = NULL;
pc->pc_pciide_compat_intr_disestablish = NULL;
-#if NSIO
+#if NSIO > 0
sio_intr_setup(pc, iot);
#else
panic("pci_axppci_33_pickintr: no I/O interrupt handler (no sio)");
@@ -102,21 +103,23 @@ dec_axppci_33_intr_map(pa, ihp)
pci_intr_handle_t *ihp;
{
pcitag_t bustag = pa->pa_intrtag;
- int buspin = pa->pa_intrpin;
pci_chipset_tag_t pc = pa->pa_pc;
- int device, pirq;
+ int buspin, device, pirq;
pcireg_t pirqreg;
u_int8_t pirqline;
- if (buspin == 0) {
- /* No IRQ used. */
- return 1;
- }
- if (buspin > 4) {
- printf("pci_map_int: bad interrupt pin %d\n", buspin);
- return 1;
- }
+ if (pa->pa_bridgetag) {
+ buspin = PPB_INTERRUPT_SWIZZLE(pa->pa_rawintrpin,
+ pa->pa_device);
+ if (pa->pa_bridgeih[buspin - 1] != 0) {
+ *ihp = pa->pa_bridgeih[buspin - 1];
+ return 0;
+ }
+
+ return 1;
+ }
+ buspin = pa->pa_intrpin;
pci_decompose_tag(pc, bustag, NULL, &device, NULL);
switch (device) {
@@ -126,6 +129,7 @@ dec_axppci_33_intr_map(pa, ihp)
case 11: /* slot 1 */
switch (buspin) {
+ default:
case PCI_INTERRUPT_PIN_A:
case PCI_INTERRUPT_PIN_D:
pirq = 0;
@@ -136,16 +140,12 @@ dec_axppci_33_intr_map(pa, ihp)
case PCI_INTERRUPT_PIN_C:
pirq = 1;
break;
-#ifdef DIAGNOSTIC
- default: /* XXX gcc -Wuninitialized */
- panic("dec_axppci_33_intr_map bogus PCI pin %d",
- buspin);
-#endif
};
break;
case 12: /* slot 2 */
switch (buspin) {
+ default:
case PCI_INTERRUPT_PIN_A:
case PCI_INTERRUPT_PIN_D:
pirq = 1;
@@ -156,16 +156,12 @@ dec_axppci_33_intr_map(pa, ihp)
case PCI_INTERRUPT_PIN_C:
pirq = 2;
break;
-#ifdef DIAGNOSTIC
- default: /* XXX gcc -Wuninitialized */
- panic("dec_axppci_33_intr_map bogus PCI pin %d",
- buspin);
-#endif
};
break;
case 8: /* slot 3 */
switch (buspin) {
+ default:
case PCI_INTERRUPT_PIN_A:
case PCI_INTERRUPT_PIN_D:
pirq = 2;
@@ -176,36 +172,21 @@ dec_axppci_33_intr_map(pa, ihp)
case PCI_INTERRUPT_PIN_C:
pirq = 0;
break;
-#ifdef DIAGNOSTIC
- default: /* XXX gcc -Wuninitialized */
- panic("dec_axppci_33_intr_map bogus PCI pin %d",
- buspin);
-#endif
};
break;
default:
- printf("dec_axppci_33_intr_map: weird device number %d\n",
- device);
return 1;
}
pirqreg = pci_conf_read(pc, pci_make_tag(pc, 0, LCA_SIO_DEVICE, 0),
SIO_PCIREG_PIRQ_RTCTRL);
-#if 0
- printf("pci_axppci_33_map_int: device %d pin %c: pirq %d, reg = %x\n",
- device, '@' + buspin, pirq, pirqreg);
-#endif
+
pirqline = (pirqreg >> (pirq * 8)) & 0xff;
if ((pirqline & 0x80) != 0)
return 1; /* not routed? */
pirqline &= 0xf;
-#if 0
- printf("pci_axppci_33_map_int: device %d pin %c: mapped to line %d\n",
- device, '@' + buspin, pirqline);
-#endif
-
*ihp = pirqline;
return (0);
}
diff --git a/sys/arch/alpha/pci/pci_eb164.c b/sys/arch/alpha/pci/pci_eb164.c
index 2bf45a66a42..d3cc5480a02 100644
--- a/sys/arch/alpha/pci/pci_eb164.c
+++ b/sys/arch/alpha/pci/pci_eb164.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pci_eb164.c,v 1.26 2014/04/14 07:36:12 mpi Exp $ */
+/* $OpenBSD: pci_eb164.c,v 1.27 2015/07/26 05:09:44 miod Exp $ */
/* $NetBSD: pci_eb164.c,v 1.27 2000/06/06 00:50:15 thorpej Exp $ */
/*-
@@ -72,6 +72,7 @@
#include <dev/pci/pcireg.h>
#include <dev/pci/pcivar.h>
+#include <dev/pci/ppbreg.h>
#include <dev/pci/pciidereg.h>
#include <dev/pci/pciidevar.h>
@@ -158,25 +159,9 @@ dec_eb164_intr_map(pa, ihp)
struct pci_attach_args *pa;
pci_intr_handle_t *ihp;
{
- pcitag_t bustag = pa->pa_intrtag;
- int buspin = pa->pa_intrpin, line = pa->pa_intrline;
- pci_chipset_tag_t pc = pa->pa_pc;
- int bus, device, function;
+ int buspin, line = pa->pa_intrline;
u_int64_t variation;
- if (buspin == 0) {
- /* No IRQ used. */
- return 1;
- }
- if (buspin > 4) {
- printf("dec_eb164_intr_map: bad interrupt pin %d\n", buspin);
- return 1;
- }
-
- pci_decompose_tag(pc, bustag, &bus, &device, &function);
-
- variation = hwrpb->rpb_variation & SV_ST_MASK;
-
/*
*
* The AlphaPC 164 and AlphaPC 164LX have a CMD PCI IDE controller
@@ -189,42 +174,46 @@ dec_eb164_intr_map(pa, ihp)
*
* Real EB164s have ISA IDE on the Super I/O chip.
*/
- if (bus == 0) {
+ variation = hwrpb->rpb_variation & SV_ST_MASK;
+ if (pa->pa_bus == 0) {
if (variation >= SV_ST_ALPHAPC164_366 &&
variation <= SV_ST_ALPHAPC164LX_600) {
- if (device == 8)
+ if (pa->pa_device == 8)
panic("dec_eb164_intr_map: SIO device");
- if (device == 11)
+ if (pa->pa_device == 11)
return (1);
} else if (variation >= SV_ST_ALPHAPC164SX_400 &&
variation <= SV_ST_ALPHAPC164SX_600) {
- if (device == 8) {
- if (function == 0)
+ if (pa->pa_device == 8) {
+ if (pa->pa_function == 0)
panic("dec_eb164_intr_map: SIO device");
return (1);
}
} else {
- if (device == 8)
+ if (pa->pa_device == 8)
panic("dec_eb164_intr_map: SIO device");
}
}
/*
* The console places the interrupt mapping in the "line" value.
- * A value of (char)-1 indicates there is no mapping.
+ * We trust it whenever possible.
*/
- if (line == 0xff) {
- printf("dec_eb164_intr_map: no mapping for %d/%d/%d\n",
- bus, device, function);
- return (1);
+ if (line >= 0 && line < EB164_MAX_IRQ) {
+ *ihp = line;
+ return 0;
}
- if (line > EB164_MAX_IRQ)
- panic("dec_eb164_intr_map: eb164 irq too large (%d)",
- line);
+ if (pa->pa_bridgetag) {
+ buspin = PPB_INTERRUPT_SWIZZLE(pa->pa_rawintrpin,
+ pa->pa_device);
+ if (pa->pa_bridgeih[buspin - 1] != 0) {
+ *ihp = pa->pa_bridgeih[buspin - 1];
+ return 0;
+ }
+ }
- *ihp = line;
- return (0);
+ return 1;
}
const char *
diff --git a/sys/arch/alpha/pci/pci_eb64plus.c b/sys/arch/alpha/pci/pci_eb64plus.c
index e90d344d03b..b9398d79aa0 100644
--- a/sys/arch/alpha/pci/pci_eb64plus.c
+++ b/sys/arch/alpha/pci/pci_eb64plus.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pci_eb64plus.c,v 1.14 2009/09/30 20:18:06 miod Exp $ */
+/* $OpenBSD: pci_eb64plus.c,v 1.15 2015/07/26 05:09:44 miod Exp $ */
/* $NetBSD: pci_eb64plus.c,v 1.10 2001/07/27 00:25:20 thorpej Exp $ */
/*-
@@ -73,6 +73,7 @@
#include <dev/pci/pcireg.h>
#include <dev/pci/pcivar.h>
+#include <dev/pci/ppbreg.h>
#include <alpha/pci/apecsreg.h>
#include <alpha/pci/apecsvar.h>
@@ -132,7 +133,7 @@ pci_eb64plus_pickintr(acp)
PCI_STRAY_MAX);
}
-#if NSIO
+#if NSIO > 0
sio_intr_setup(pc, iot);
#endif
}
@@ -142,38 +143,27 @@ dec_eb64plus_intr_map(pa, ihp)
struct pci_attach_args *pa;
pci_intr_handle_t *ihp;
{
- pcitag_t bustag = pa->pa_intrtag;
- int buspin = pa->pa_intrpin, line = pa->pa_intrline;
- pci_chipset_tag_t pc = pa->pa_pc;
- int bus, device, function;
-
- if (buspin == 0) {
- /* No IRQ used. */
- return 1;
- }
- if (buspin > 4) {
- printf("dec_eb64plus_intr_map: bad interrupt pin %d\n", buspin);
- return 1;
- }
-
- pci_decompose_tag(pc, bustag, &bus, &device, &function);
+ int buspin, line = pa->pa_intrline;
/*
* The console places the interrupt mapping in the "line" value.
- * A value of (char)-1 indicates there is no mapping.
+ * We trust it whenever possible.
*/
- if (line == 0xff) {
- printf("dec_eb64plus_intr_map: no mapping for %d/%d/%d\n",
- bus, device, function);
- return (1);
+ if (line >= 0 && line < EB64PLUS_MAX_IRQ) {
+ *ihp = line;
+ return 0;
}
- if (line >= EB64PLUS_MAX_IRQ)
- panic("dec_eb64plus_intr_map: eb64+ irq too large (%d)",
- line);
+ if (pa->pa_bridgetag) {
+ buspin = PPB_INTERRUPT_SWIZZLE(pa->pa_rawintrpin,
+ pa->pa_device);
+ if (pa->pa_bridgeih[buspin - 1] != 0) {
+ *ihp = pa->pa_bridgeih[buspin - 1];
+ return 0;
+ }
+ }
- *ihp = line;
- return (0);
+ return 1;
}
const char *
diff --git a/sys/arch/alpha/pci/pci_kn20aa.c b/sys/arch/alpha/pci/pci_kn20aa.c
index 4d3149b9c6d..6916147ba9f 100644
--- a/sys/arch/alpha/pci/pci_kn20aa.c
+++ b/sys/arch/alpha/pci/pci_kn20aa.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pci_kn20aa.c,v 1.27 2014/05/08 20:46:49 miod Exp $ */
+/* $OpenBSD: pci_kn20aa.c,v 1.28 2015/07/26 05:09:44 miod Exp $ */
/* $NetBSD: pci_kn20aa.c,v 1.21 1996/11/17 02:05:27 cgd Exp $ */
/*
@@ -43,6 +43,7 @@
#include <dev/pci/pcireg.h>
#include <dev/pci/pcivar.h>
+#include <dev/pci/ppbreg.h>
#include <alpha/pci/ciareg.h>
#include <alpha/pci/ciavar.h>
@@ -113,14 +114,16 @@ dec_kn20aa_intr_map(pa, ihp)
int device;
int kn20aa_irq;
- if (buspin == 0) {
- /* No IRQ used. */
- return 1;
- }
- if (buspin > 4) {
- printf("pci_map_int: bad interrupt pin %d\n", buspin);
- return 1;
- }
+ if (pa->pa_bridgetag) {
+ buspin = PPB_INTERRUPT_SWIZZLE(pa->pa_rawintrpin,
+ pa->pa_device);
+ if (pa->pa_bridgeih[buspin - 1] != 0) {
+ *ihp = pa->pa_bridgeih[buspin - 1];
+ return 0;
+ }
+
+ return 1;
+ }
/*
* Slot->interrupt translation. Appears to work, though it
@@ -153,18 +156,22 @@ dec_kn20aa_intr_map(pa, ihp)
break;
default:
- printf("dec_kn20aa_intr_map: weird device number %d\n",
- device);
+ printf("dec_kn20aa_intr_map: don't know how to setup %d/%d/%d\n",
+ pa->pa_bus, pa->pa_device, pa->pa_function);
return 1;
}
- kn20aa_irq += buspin - 1;
- if (kn20aa_irq >= KN20AA_MAX_IRQ)
- panic("pci_kn20aa_map_int: kn20aa_irq too large (%d)",
- kn20aa_irq);
+ if (kn20aa_irq != 13)
+ kn20aa_irq += buspin - 1;
+
+ if (kn20aa_irq >= KN20AA_MAX_IRQ) {
+ printf("dec_kn20aa_intr_map: kn20aa_irq %d too large for %d/%d/%d\n",
+ kn20aa_irq, pa->pa_bus, pa->pa_device, pa->pa_function);
+ return 1;
+ }
*ihp = kn20aa_irq;
- return (0);
+ return 0;
}
const char *
diff --git a/sys/arch/alpha/pci/pci_kn300.c b/sys/arch/alpha/pci/pci_kn300.c
index 040097f4127..2bd1bc0d7d6 100644
--- a/sys/arch/alpha/pci/pci_kn300.c
+++ b/sys/arch/alpha/pci/pci_kn300.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pci_kn300.c,v 1.6 2014/05/08 20:46:49 miod Exp $ */
+/* $OpenBSD: pci_kn300.c,v 1.7 2015/07/26 05:09:44 miod Exp $ */
/* $NetBSD: pci_kn300.c,v 1.28 2005/12/11 12:16:17 christos Exp $ */
/*
@@ -46,6 +46,7 @@
#include <dev/pci/pcireg.h>
#include <dev/pci/pcivar.h>
+#include <dev/pci/ppbreg.h>
#include <alpha/mcbus/mcbusvar.h>
#include <alpha/mcbus/mcbusreg.h>
@@ -126,12 +127,14 @@ dec_kn300_intr_map(pa, ihp)
int device;
int mcpcia_irq;
- if (buspin == 0) {
- /* No IRQ used. */
- return 1;
- }
- if (buspin > 4 || buspin < 0) {
- printf("dec_kn300_intr_map: bad interrupt pin %d\n", buspin);
+ if (pa->pa_bridgetag) {
+ buspin = PPB_INTERRUPT_SWIZZLE(pa->pa_rawintrpin,
+ pa->pa_device);
+ if (pa->pa_bridgeih[buspin - 1] != 0) {
+ *ihp = pa->pa_bridgeih[buspin - 1];
+ return 0;
+ }
+
return 1;
}
@@ -145,8 +148,9 @@ dec_kn300_intr_map(pa, ihp)
} else if (device >= 2 && device <= 5) {
mcpcia_irq = (device - 2) * 4 + buspin - 1;
} else {
- printf("dec_kn300_intr_map: weird device number %d\n", device);
- return(1);
+ printf("dec_kn300_intr_map: don't know how to setup %d/%d/%d\n",
+ pa->pa_bus, pa->pa_device, pa->pa_function);
+ return 1;
}
/*
@@ -167,6 +171,7 @@ dec_kn300_intr_map(pa, ihp)
((ccp->cc_mid - 4) << 5) |
((7 - ccp->cc_gid) << 8) |
(mcpcia_irq << 11);
+
return (0);
}
diff --git a/sys/arch/alpha/pci/pci_machdep.c b/sys/arch/alpha/pci/pci_machdep.c
index b8ce26c181a..0bcdba22249 100644
--- a/sys/arch/alpha/pci/pci_machdep.c
+++ b/sys/arch/alpha/pci/pci_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pci_machdep.c,v 1.19 2010/04/21 15:00:14 deraadt Exp $ */
+/* $OpenBSD: pci_machdep.c,v 1.20 2015/07/26 05:09:44 miod Exp $ */
/* $NetBSD: pci_machdep.c,v 1.7 1996/11/19 04:57:32 cgd Exp $ */
/*
@@ -47,6 +47,7 @@
#include <dev/pci/pcireg.h>
#include <dev/pci/pcivar.h>
#include <dev/pci/pcidevs.h>
+#include <dev/pci/ppbreg.h>
#include "vga.h"
#if NVGA_PCI
@@ -140,3 +141,15 @@ alpha_sysctl_chipset(int *name, u_int namelen, char *where, size_t *sizep)
}
/* NOTREACHED */
}
+
+int
+pci_intr_map(struct pci_attach_args *pa, pci_intr_handle_t *ihp)
+{
+ if (pa->pa_intrpin == 0) /* No IRQ used. */
+ return 1;
+
+ if (!(1 <= pa->pa_intrpin && pa->pa_intrpin <= 4))
+ return 1;
+
+ return (*(pa->pa_pc)->pc_intr_map)(pa, ihp);
+}
diff --git a/sys/arch/alpha/pci/pci_machdep.h b/sys/arch/alpha/pci/pci_machdep.h
index daf9eff22af..fc80bd0f306 100644
--- a/sys/arch/alpha/pci/pci_machdep.h
+++ b/sys/arch/alpha/pci/pci_machdep.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: pci_machdep.h,v 1.28 2013/11/05 10:12:35 mpi Exp $ */
+/* $OpenBSD: pci_machdep.h,v 1.29 2015/07/26 05:09:44 miod Exp $ */
/* $NetBSD: pci_machdep.h,v 1.6 1996/11/19 04:49:21 cgd Exp $ */
/*
@@ -103,8 +103,6 @@ int alpha_sysctl_chipset(int *, u_int, char *, size_t *);
(*(c)->pc_conf_read)((c)->pc_conf_v, (t), (r))
#define pci_conf_write(c, t, r, v) \
(*(c)->pc_conf_write)((c)->pc_conf_v, (t), (r), (v))
-#define pci_intr_map(pa, ihp) \
- (*((pa)->pa_pc)->pc_intr_map)((pa), (ihp))
#define pci_intr_map_msi(pa, ihp) (-1)
#define pci_intr_string(c, ih) \
(*(c)->pc_intr_string)((c)->pc_intr_v, (ih))
@@ -138,5 +136,7 @@ void pci_display_console(bus_space_tag_t, bus_space_tag_t,
#define pci_dev_postattach(a, b)
#ifdef _KERNEL
-void pci_display_console(bus_space_tag_t, bus_space_tag_t, pci_chipset_tag_t, int, int, int);
+void pci_display_console(bus_space_tag_t, bus_space_tag_t, pci_chipset_tag_t,
+ int, int, int);
+int pci_intr_map(struct pci_attach_args *, pci_intr_handle_t *);
#endif /* _KERNEL */
diff --git a/sys/arch/alpha/pci/pci_up1000.c b/sys/arch/alpha/pci/pci_up1000.c
index 2c24f3332d1..bf470a163f8 100644
--- a/sys/arch/alpha/pci/pci_up1000.c
+++ b/sys/arch/alpha/pci/pci_up1000.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pci_up1000.c,v 1.15 2009/08/22 02:54:50 mk Exp $ */
+/* $OpenBSD: pci_up1000.c,v 1.16 2015/07/26 05:09:44 miod Exp $ */
/* $NetBSD: pci_up1000.c,v 1.6 2000/12/28 22:59:07 sommerfeld Exp $ */
/*-
@@ -47,6 +47,7 @@
#include <dev/pci/pcireg.h>
#include <dev/pci/pcivar.h>
+#include <dev/pci/ppbreg.h>
#include <dev/pci/pciidereg.h>
#include <dev/pci/pciidevar.h>
@@ -97,50 +98,34 @@ pci_up1000_pickintr(struct irongate_config *icp)
int
api_up1000_intr_map(struct pci_attach_args *pa, pci_intr_handle_t *ihp)
{
- pcitag_t bustag = pa->pa_intrtag;
- int buspin = pa->pa_intrpin, line = pa->pa_intrline;
- pci_chipset_tag_t pc = pa->pa_pc;
- int bus, device, function;
-
- if (buspin == 0) {
- /* No IRQ used. */
- return 1;
- }
- if (buspin > 4) {
- printf("api_up1000_intr_map: bad interrupt pin %d\n",
- buspin);
- return 1;
- }
-
- pci_decompose_tag(pc, bustag, &bus, &device, &function);
+ int buspin, line = pa->pa_intrline;
/*
* The console places the interrupt mapping in the "line" value.
- * A value of (char)-1 indicates there is no mapping.
+ * We trust it whenever possible.
*/
- if (line == 0xff) {
- printf("api_up1000_intr_map: no mapping for %d/%d/%d\n",
- bus, device, function);
- return (1);
- }
-
- /* XXX Check for 0? */
- if (line > 15) {
-#ifdef DIAGNOSTIC
- printf("api_up1000_intr_map: ISA IRQ too large (%d)\n",
- line);
+ if (line >= 0 && line <= 15) {
+ if (line == 2) {
+#ifdef DEBUG
+ printf("api_up1000_intr_map: changed IRQ 2 to IRQ 9\n");
#endif
- return (1);
+ line = 9;
+ }
+
+ *ihp = line;
+ return 0;
}
- if (line == 2) {
-#ifdef DIAGNOSTIC
- printf("api_up1000_intr_map: changed IRQ 2 to IRQ 9\n");
-#endif
- line = 9;
+
+ if (pa->pa_bridgetag) {
+ buspin = PPB_INTERRUPT_SWIZZLE(pa->pa_rawintrpin,
+ pa->pa_device);
+ if (pa->pa_bridgeih[buspin - 1] != 0) {
+ *ihp = pa->pa_bridgeih[buspin - 1];
+ return 0;
+ }
}
- *ihp = line;
- return (0);
+ return 1;
}
const char *