Source-Changes-HG archive

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

[src/trunk]: src/sys/dev Fill the companion controller array.



details:   https://anonhg.NetBSD.org/src/rev/866e77b5c4a8
branches:  trunk
changeset: 517319:866e77b5c4a8
user:      augustss <augustss%NetBSD.org@localhost>
date:      Sat Nov 10 17:07:21 2001 +0000

description:
Fill the companion controller array.

diffstat:

 sys/dev/cardbus/ehci_cardbus.c |  39 ++++++++++++++++++++++++++++++++-------
 sys/dev/pci/ehci_pci.c         |  31 ++++++++++++++++++++++++++++---
 2 files changed, 60 insertions(+), 10 deletions(-)

diffs (155 lines):

diff -r 5417f28bf88b -r 866e77b5c4a8 sys/dev/cardbus/ehci_cardbus.c
--- a/sys/dev/cardbus/ehci_cardbus.c    Sat Nov 10 17:06:11 2001 +0000
+++ b/sys/dev/cardbus/ehci_cardbus.c    Sat Nov 10 17:07:21 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ehci_cardbus.c,v 1.1 2001/11/06 03:18:53 augustss Exp $        */
+/*     $NetBSD: ehci_cardbus.c,v 1.2 2001/11/10 17:07:21 augustss Exp $        */
 
 /*
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -62,6 +62,13 @@
 #include <dev/usb/ehcireg.h>
 #include <dev/usb/ehcivar.h>
 
+#ifdef EHCI_DEBUG
+#define DPRINTF(x)     if (ehcidebug) printf x
+extern int ehcidebug;
+#else
+#define DPRINTF(x)
+#endif
+
 int    ehci_cardbus_match(struct device *, struct cfdata *, void *);
 void   ehci_cardbus_attach(struct device *, struct device *, void *);
 int    ehci_cardbus_detach(device_ptr_t, int);
@@ -112,7 +119,9 @@
        char devinfo[256];
        usbd_status r;
        char *vendor;
+       u_int ncomp;
        const char *devname = sc->sc.sc_bus.bdev.dv_xname;
+       struct usb_cardbus *up;
 
        cardbus_devinfo(ca->ca_id, ca->ca_class, 0, devinfo);
        printf(": %s (rev. 0x%02x)\n", devinfo,
@@ -125,11 +134,6 @@
                return;
        }
 
-       sc->sc.sc_offs = bus_space_read_1(sc->sc.iot, sc->sc.ioh, EHCI_CAPLENGTH);
-
-       /* Disable interrupts, so we don't get any spurious ones. */
-       EOWRITE2(&sc->sc, EHCI_USBINTR, 0);
-
        sc->sc_cc = cc;
        sc->sc_cf = cf;
        sc->sc_ct = ct;
@@ -149,6 +153,11 @@
                       csr | CARDBUS_COMMAND_MASTER_ENABLE
                           | CARDBUS_COMMAND_MEM_ENABLE);
 
+       /* Disable interrupts, so we don't get any spurious ones. */
+       sc->sc.sc_offs = EREAD1(&sc->sc, EHCI_CAPLENGTH);
+       DPRINTF(("%s: offs=%d\n", devname, sc->sc.sc_offs));
+       EOWRITE2(&sc->sc, EHCI_USBINTR, 0);
+
        sc->sc_ih = cardbus_intr_establish(cc, cf, ca->ca_intrline,
                                           IPL_USB, ehci_intr, sc);
        if (sc->sc_ih == NULL) {
@@ -167,13 +176,29 @@
                sprintf(sc->sc.sc_vendor, "vendor 0x%04x", 
                        CARDBUS_VENDOR(ca->ca_id));
        
+       /*
+        * Find companion controllers.  According to the spec they always
+        * have lower function numbers so they should be enumerated already.
+        */
+       ncomp = 0;
+       TAILQ_FOREACH(up, &ehci_cardbus_alldevs, next) {
+               if (up->bus == ca->ca_bus && up->device == ca->ca_device) {
+                       DPRINTF(("ehci_cardbus_attach: companion %s\n",
+                                USBDEVNAME(up->usb->bdev)));
+                       sc->sc.sc_comps[ncomp++] = up->usb;
+                       if (ncomp >= EHCI_COMPANION_MAX)
+                               break;
+               }
+       }
+       sc->sc.sc_ncomp = ncomp;
+
        r = ehci_init(&sc->sc);
        if (r != USBD_NORMAL_COMPLETION) {
                printf("%s: init failed, error=%d\n", devname, r);
 
                /* Avoid spurious interrupts. */
                cardbus_intr_disestablish(sc->sc_cc, sc->sc_cf, sc->sc_ih);
-               sc->sc_ih = 0;
+               sc->sc_ih = NULL;
 
                return;
        }
diff -r 5417f28bf88b -r 866e77b5c4a8 sys/dev/pci/ehci_pci.c
--- a/sys/dev/pci/ehci_pci.c    Sat Nov 10 17:06:11 2001 +0000
+++ b/sys/dev/pci/ehci_pci.c    Sat Nov 10 17:07:21 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ehci_pci.c,v 1.4 2001/11/06 03:17:36 augustss Exp $    */
+/*     $NetBSD: ehci_pci.c,v 1.5 2001/11/10 17:07:21 augustss Exp $    */
 
 /*
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -56,6 +56,13 @@
 #include <dev/usb/ehcireg.h>
 #include <dev/usb/ehcivar.h>
 
+#ifdef EHCI_DEBUG
+#define DPRINTF(x)     if (ehcidebug) printf x
+extern int ehcidebug;
+#else
+#define DPRINTF(x)
+#endif
+
 int    ehci_pci_match(struct device *, struct cfdata *, void *);
 void   ehci_pci_attach(struct device *, struct device *, void *);
 int    ehci_pci_detach(device_ptr_t, int);
@@ -102,6 +109,8 @@
        char *devname = sc->sc.sc_bus.bdev.dv_xname;
        char devinfo[256];
        usbd_status r;
+       int ncomp;
+       struct usb_pci *up;
 
        pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo);
        printf(": %s (rev. 0x%02x)\n", devinfo, PCI_REVISION(pa->pa_class));
@@ -122,9 +131,9 @@
        pci_conf_write(pc, tag, PCI_COMMAND_STATUS_REG,
                       csr | PCI_COMMAND_MASTER_ENABLE);
 
-       sc->sc.sc_offs = bus_space_read_1(sc->sc.iot, sc->sc.ioh, EHCI_CAPLENGTH);
-
        /* Disable interrupts, so we don't get any spurious ones. */
+       sc->sc.sc_offs = EREAD1(&sc->sc, EHCI_CAPLENGTH);
+       DPRINTF(("%s: offs=%d\n", devname, sc->sc.sc_offs));
        EOWRITE2(&sc->sc, EHCI_USBINTR, 0);
 
        /* Map and establish the interrupt. */
@@ -168,6 +177,22 @@
                sprintf(sc->sc.sc_vendor, "vendor 0x%04x",
                        PCI_VENDOR(pa->pa_id));
        
+       /*
+        * Find companion controllers.  According to the spec they always
+        * have lower function numbers so they should be enumerated already.
+        */
+       ncomp = 0;
+       TAILQ_FOREACH(up, &ehci_pci_alldevs, next) {
+               if (up->bus == pa->pa_bus && up->device == pa->pa_device) {
+                       DPRINTF(("ehci_pci_attach: companion %s\n",
+                                USBDEVNAME(up->usb->bdev)));
+                       sc->sc.sc_comps[ncomp++] = up->usb;
+                       if (ncomp >= EHCI_COMPANION_MAX)
+                               break;
+               }
+       }
+       sc->sc.sc_ncomp = ncomp;
+
        r = ehci_init(&sc->sc);
        if (r != USBD_NORMAL_COMPLETION) {
                printf("%s: init failed, error=%d\n", devname, r);



Home | Main Index | Thread Index | Old Index