Source-Changes-HG archive

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

[src/trunk]: src/sys/dev Make this work with the SA 431 and 42xx series contr...



details:   https://anonhg.NetBSD.org/src/rev/417c3a62a284
branches:  trunk
changeset: 502015:417c3a62a284
user:      ad <ad%NetBSD.org@localhost>
date:      Wed Jan 10 16:48:04 2001 +0000

description:
Make this work with the SA 431 and 42xx series controllers.

diffstat:

 sys/dev/ic/cacreg.h   |   5 ++-
 sys/dev/pci/cac_pci.c |  55 ++++++++++++++++++++++++++++++++++++--------------
 2 files changed, 42 insertions(+), 18 deletions(-)

diffs (119 lines):

diff -r fab6ede1c027 -r 417c3a62a284 sys/dev/ic/cacreg.h
--- a/sys/dev/ic/cacreg.h       Wed Jan 10 16:45:56 2001 +0000
+++ b/sys/dev/ic/cacreg.h       Wed Jan 10 16:48:04 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cacreg.h,v 1.4 2000/09/01 12:10:21 ad Exp $    */
+/*     $NetBSD: cacreg.h,v 1.5 2001/01/10 16:48:04 ad Exp $    */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -76,7 +76,8 @@
 #define        CAC_42REG_DONE_FIFO             0x44
 #define        CAC_42REG_INTR_MASK             0x34
 #define        CAC_42REG_STATUS                0x30
-#define        CAC_42REG_INTR_PENDING          0x08
+
+#define        CAC_42_EXTINT                   0x08
 
 #define        CAC_EISAREG_INTR_MASK           0x01
 #define        CAC_EISAREG_LOCAL_MASK          0x04
diff -r fab6ede1c027 -r 417c3a62a284 sys/dev/pci/cac_pci.c
--- a/sys/dev/pci/cac_pci.c     Wed Jan 10 16:45:56 2001 +0000
+++ b/sys/dev/pci/cac_pci.c     Wed Jan 10 16:48:04 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cac_pci.c,v 1.9 2000/12/28 22:59:11 sommerfeld Exp $   */
+/*     $NetBSD: cac_pci.c,v 1.10 2001/01/10 16:48:04 ad Exp $  */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -55,9 +55,6 @@
 #include <dev/ic/cacreg.h>
 #include <dev/ic/cacvar.h>
 
-#define        PCI_CBIO        0x10    /* Configuration base I/O address */
-#define        PCI_CBMA        0x14    /* Configuration base memory address */
-
 static void    cac_pci_attach(struct device *, struct device *, void *);
 static struct  cac_pci_type *cac_pci_findtype(struct pci_attach_args *);
 static int     cac_pci_match(struct device *, struct cfdata *, void *);
@@ -160,27 +157,54 @@
        pci_chipset_tag_t pc;
        pci_intr_handle_t ih;
        const char *intrstr;
-       pcireg_t csr;
+       pcireg_t reg;
+       int memr, ior, i;
 
        sc = (struct cac_softc *)self;
        pa = (struct pci_attach_args *)aux;
        pc = pa->pa_pc;
        ct = cac_pci_findtype(pa);
 
-       if (pci_mapreg_map(pa, PCI_CBMA, PCI_MAPREG_TYPE_MEM, 0,
-           &sc->sc_iot, &sc->sc_ioh, NULL, NULL))
-               if (pci_mapreg_map(pa, PCI_CBIO, PCI_MAPREG_TYPE_IO, 0,
-                   &sc->sc_iot, &sc->sc_ioh, NULL, NULL)) {
-                       printf("can't map memory or i/o space\n");
-                       return;
+       /*
+        * Map the PCI register window.
+        */
+       memr = -1;
+       ior = -1;
+
+       for (i = 0x10; i <= 0x14; i += 4) {
+               reg = pci_conf_read(pa->pa_pc, pa->pa_tag, i);
+
+               if (PCI_MAPREG_TYPE(reg) == PCI_MAPREG_TYPE_IO) {
+                       if (ior == -1 && PCI_MAPREG_IO_SIZE(reg) != 0)
+                               ior = i;
+               } else {
+                       if (memr == -1 && PCI_MAPREG_MEM_SIZE(reg) != 0)
+                               memr = i;
                }
+       }
+
+       if (memr != -1) {
+               if (pci_mapreg_map(pa, memr, PCI_MAPREG_TYPE_MEM, 0,
+                   &sc->sc_iot, &sc->sc_ioh, NULL, NULL))
+                       memr = -1;
+               else
+                       ior = -1;
+       }
+       if (ior != -1)
+               if (pci_mapreg_map(pa, ior, PCI_MAPREG_TYPE_IO, 0,
+                   &sc->sc_iot, &sc->sc_ioh, NULL, NULL))
+                       ior = -1;
+       if (memr == -1 && ior == -1) {
+               printf("%s: can't map i/o or memory space\n", self->dv_xname);
+               return;
+       }
 
        sc->sc_dmat = pa->pa_dmat;
 
        /* Enable the device. */
-       csr = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG);
+       reg = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG);
        pci_conf_write(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG,
-                      csr | PCI_COMMAND_MASTER_ENABLE);
+                      reg | PCI_COMMAND_MASTER_ENABLE);
 
        /* Map and establish the interrupt. */
        if (pci_intr_map(pa, &ih)) {
@@ -236,8 +260,7 @@
 cac_pci_l0_intr_pending(struct cac_softc *sc)
 {
 
-       return (cac_inl(sc, CAC_42REG_INTR_PENDING) & 
-           cac_inl(sc, CAC_42REG_STATUS));
+       return ((cac_inl(sc, CAC_42REG_STATUS) & CAC_42_EXTINT) != 0);
 }
 
 static void
@@ -251,5 +274,5 @@
 cac_pci_l0_fifo_full(struct cac_softc *sc)
 {
 
-       return (~cac_inl(sc, CAC_42REG_CMD_FIFO));
+       return (cac_inl(sc, CAC_42REG_CMD_FIFO) != 0);
 }



Home | Main Index | Thread Index | Old Index