Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-1-5]: src/sys/arch/i386/pci Pull up to netbsd-1-5 branch



details:   https://anonhg.NetBSD.org/src/rev/e8c90c73532b
branches:  netbsd-1-5
changeset: 489034:e8c90c73532b
user:      soda <soda%NetBSD.org@localhost>
date:      Thu Aug 10 22:29:58 2000 +0000

description:
Pull up to netbsd-1-5 branch
Approved by: thorpej

deal with FIRESTAR_PIR_SELECT_PIRQ case on set/get_trigger(),
to prevent a panic on a Panasonic Let's Note AL-N2T516J5.
add several debug printf which can be enabled by FIRESTARDEBUG.
use I386_PCI_INTERRUPT_LINE_NO_CONNECTION instead of magic number.

Revisions pulled up:
 > cvs rdiff -r1.1 -r1.2 syssrc/sys/arch/i386/pci/opti82c700.c \
 >     syssrc/sys/arch/i386/pci/opti82c700reg.h

diffstat:

 sys/arch/i386/pci/opti82c700.c    |  113 +++++++++++++++++++++++++++++++++----
 sys/arch/i386/pci/opti82c700reg.h |    7 +--
 2 files changed, 102 insertions(+), 18 deletions(-)

diffs (218 lines):

diff -r 1385cf672d8e -r e8c90c73532b sys/arch/i386/pci/opti82c700.c
--- a/sys/arch/i386/pci/opti82c700.c    Thu Aug 10 22:25:56 2000 +0000
+++ b/sys/arch/i386/pci/opti82c700.c    Thu Aug 10 22:29:58 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: opti82c700.c,v 1.1 1999/11/17 01:21:20 thorpej Exp $   */
+/*     $NetBSD: opti82c700.c,v 1.1.8.1 2000/08/10 22:29:58 soda Exp $  */
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -63,7 +63,7 @@
  */
 
 /*
- * Support for the Opti 82c700 PCI-ISA bridge interrupt controller.
+ * Support for the Opti 82c700 FireStar PCI-ISA bridge interrupt controller.
  */
 
 #include <sys/param.h>
@@ -81,6 +81,12 @@
 #include <i386/pci/pci_intr_fixup.h>
 #include <i386/pci/opti82c700reg.h>
 
+#ifdef FIRESTARDEBUG
+#define        DPRINTF(arg) printf arg
+#else
+#define        DPRINTF(arg)
+#endif
+
 int    opti82c700_getclink __P((pciintr_icu_handle_t, int, int *));
 int    opti82c700_get_intr __P((pciintr_icu_handle_t, int, int *));
 int    opti82c700_set_intr __P((pciintr_icu_handle_t, int, int));
@@ -101,6 +107,9 @@
 };
 
 int    opti82c700_addr __P((int, int *, int *));
+#ifdef FIRESTARDEBUG
+void   opti82c700_pir_dump __P((struct opti82c700_handle *));
+#endif
 
 int
 opti82c700_init(pc, iot, tag, ptagp, phandp)
@@ -118,7 +127,9 @@
 
        ph->ph_pc = pc;
        ph->ph_tag = tag;
-
+#ifdef FIRESTARDEBUG
+       opti82c700_pir_dump(ph);
+#endif
        *ptagp = &opti82c700_pci_icu;
        *phandp = ph;
        return (0);
@@ -145,6 +156,7 @@
                break;
 
        case FIRESTAR_PIR_SELECT_PIRQ:
+               /* FALLTHROUGH */
        case FIRESTAR_PIR_SELECT_BRIDGE:
                if (regofs < 0 || regofs > 3)
                        return (1);
@@ -164,13 +176,30 @@
        pciintr_icu_handle_t v;
        int link, *clinkp;
 {
+       DPRINTF(("FireStar link value 0x%x: ", link));
 
-       if (FIRESTAR_LEGAL_LINK(link)) {
-               *clinkp = link;
-               return (0);
+       switch (FIRESTAR_PIR_SELECTSRC(link)) {
+       default:
+               DPRINTF(("bogus IRQ selection source\n"));
+               return (1);
+       case FIRESTAR_PIR_SELECT_NONE:
+               DPRINTF(("No interrupt connection\n"));
+               return (1);
+       case FIRESTAR_PIR_SELECT_IRQ:
+               DPRINTF(("FireStar IRQ pin"));
+               break;
+       case FIRESTAR_PIR_SELECT_PIRQ:
+               DPRINTF(("FireStar PIO pin or Serial IRQ PIRQ#"));
+               break;
+       case FIRESTAR_PIR_SELECT_BRIDGE:
+               DPRINTF(("FireBridge 1 INTx# pin"));
+               break;
        }
+       
+       DPRINTF((" REGOFST:%#x\n", FIRESTAR_PIR_REGOFS(link)));
+       *clinkp = link;
 
-       return (1);
+       return (0);
 }
 
 int
@@ -182,15 +211,14 @@
        pcireg_t reg;
        int val, addrofs, ofs;
 
-       if (FIRESTAR_LEGAL_LINK(clink) == 0)
-               return (1);
-
        if (opti82c700_addr(clink, &addrofs, &ofs))
                return (1);
 
        reg = pci_conf_read(ph->ph_pc, ph->ph_tag, addrofs);
        val = (reg >> ofs) & FIRESTAR_CFG_PIRQ_MASK;
-       *irqp = (val == FIRESTAR_PIRQ_NONE) ? 0xff : val;
+
+       *irqp = (val == FIRESTAR_PIRQ_NONE) ?
+           I386_PCI_INTERRUPT_LINE_NO_CONNECTION : val;
 
        return (0);
 }
@@ -204,7 +232,7 @@
        int addrofs, ofs;
        pcireg_t reg;
 
-       if (FIRESTAR_LEGAL_LINK(clink) == 0 || FIRESTAR_LEGAL_IRQ(irq) == 0)
+       if (FIRESTAR_LEGAL_IRQ(irq) == 0)
                return (1);
 
        if (opti82c700_addr(clink, &addrofs, &ofs))
@@ -249,6 +277,20 @@
                return (0);
        }
 
+       /*
+        * Search PIO PCIIRQ.
+        */
+       for (i = 0; i < 4; i++) {
+               opti82c700_addr(FIRESTAR_PIR_MAKELINK(FIRESTAR_PIR_SELECT_PIRQ,
+                   i), &addrofs, &ofs);
+               reg = pci_conf_read(ph->ph_pc, ph->ph_tag, addrofs);
+               val = (reg >> ofs) & FIRESTAR_CFG_PIRQ_MASK;
+               if (val != irq)
+                       continue;
+               *triggerp = IST_LEVEL;
+               return (0);
+       }
+
        return (1);
 }
 
@@ -286,5 +328,52 @@
                return (0);
        }
 
+       /*
+        * Search PIO PCIIRQ.
+        */
+       for (i = 0; i < 4; i++) {
+               opti82c700_addr(FIRESTAR_PIR_MAKELINK(FIRESTAR_PIR_SELECT_PIRQ,
+                   i), &addrofs, &ofs);
+               reg = pci_conf_read(ph->ph_pc, ph->ph_tag, addrofs);
+               val = (reg >> ofs) & FIRESTAR_CFG_PIRQ_MASK;
+               if (val != irq)
+                       continue;
+               return (trigger == IST_LEVEL ? 0 : 1);
+       }
+
        return (1);
 }
+
+#ifdef FIRESTARDEBUG
+void
+opti82c700_pir_dump(ph)
+       struct opti82c700_handle *ph;
+{
+       pcireg_t r;
+       pcitag_t tag = ph->ph_tag;
+       pci_chipset_tag_t pc = ph->ph_pc;
+       int i, j, k;
+
+       /* FireStar IRQ pin */
+       printf("-FireStar IRQ pin-\n");
+       for (i = j = k = 0; i < 8; i += 4) {
+               r = pci_conf_read(pc, tag, 0xb0 + i);
+               printf ("\t");
+               for (j = 0; j < 4; j++, k++, r >>= 8) {
+                       printf("[%d:%s-IRQ%2d] ", k,
+                              (r & (FIRESTAR_TRIGGER_MASK <<
+                                    FIRESTAR_TRIGGER_SHIFT)) ? "PCI" : "ISA",
+                              r & FIRESTAR_CFG_PIRQ_MASK);
+               }
+               printf("\n");
+       }
+       
+       /* FireStar PIO pin or Serial IRQ PIRQ# */
+       r = pci_conf_read(pc, tag, 0xb8);
+       printf("-FireStar PIO pin or Serial IRQ PIRQ#-\n\t");
+       for (i = 0; i < 4; i++, r >>= 4) {
+               printf("[PCIIRQ%d# %d] ", i, r & FIRESTAR_CFG_PIRQ_MASK);
+       }
+       printf("\n");
+}
+#endif /* FIRESTARDEBUG */
diff -r 1385cf672d8e -r e8c90c73532b sys/arch/i386/pci/opti82c700reg.h
--- a/sys/arch/i386/pci/opti82c700reg.h Thu Aug 10 22:25:56 2000 +0000
+++ b/sys/arch/i386/pci/opti82c700reg.h Thu Aug 10 22:29:58 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: opti82c700reg.h,v 1.1 1999/11/17 01:21:20 thorpej Exp $        */
+/*     $NetBSD: opti82c700reg.h,v 1.1.8.1 2000/08/10 22:29:58 soda Exp $       */
 
 /*
  * Copyright (c) 1999, by UCHIYAMA Yasushi
@@ -34,11 +34,6 @@
 #define        FIRESTAR_CFG_INTR_PIRQ  0xb8    /* PCI configuration space */
 
 #define        FIRESTAR_PIRQ_NONE      0
-#define        FIRESTAR_PIRQ_MIN       FIRESTAR_CFG_INTR_IRQ
-#define        FIRESTAR_PIRQ_MAX       (FIRESTAR_CFG_INTR_PIRQ + 1)
-#define        FIRESTAR_LEGAL_LINK(link) ((link) >= FIRESTAR_PIRQ_MIN &&       \
-                                  (link) <= FIRESTAR_PIRQ_MAX)
-
 #define        FIRESTAR_PIRQ_MASK      0xdffa
 #define        FIRESTAR_LEGAL_IRQ(irq) ((irq) >= 0 && (irq) <= 15 &&           \
                                 ((1 << (irq)) & FIRESTAR_PIRQ_MASK) != 0)



Home | Main Index | Thread Index | Old Index