Source-Changes-HG archive

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

[src/trunk]: src/sys/dev Add preliminary (untested) code for detaching the US...



details:   https://anonhg.NetBSD.org/src/rev/b539998e5aca
branches:  trunk
changeset: 476381:b539998e5aca
user:      augustss <augustss%NetBSD.org@localhost>
date:      Wed Sep 15 10:25:30 1999 +0000

description:
Add preliminary (untested) code for detaching the USB host controller
(needed for CardBus based controllers).

diffstat:

 sys/dev/pci/ohci_pci.c |    7 +-
 sys/dev/pci/uhci_pci.c |    7 +-
 sys/dev/usb/ohci.c     |   43 +++++++++++++++-
 sys/dev/usb/ohcivar.h  |    7 ++-
 sys/dev/usb/uhci.c     |   43 +++++++++++++++-
 sys/dev/usb/uhcivar.h  |   10 ++-
 sys/dev/usb/uhub.c     |   63 +----------------------
 sys/dev/usb/usb.c      |  132 ++++++++++++++++++++++++++----------------------
 sys/dev/usb/usb_subr.c |   59 +++++++++++++++++++++-
 sys/dev/usb/usbdi.c    |    5 +-
 sys/dev/usb/usbdivar.h |    3 +-
 11 files changed, 238 insertions(+), 141 deletions(-)

diffs (truncated from 694 to 300 lines):

diff -r fdba25a88e02 -r b539998e5aca sys/dev/pci/ohci_pci.c
--- a/sys/dev/pci/ohci_pci.c    Wed Sep 15 09:59:41 1999 +0000
+++ b/sys/dev/pci/ohci_pci.c    Wed Sep 15 10:25:30 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ohci_pci.c,v 1.12 1999/09/14 01:07:13 augustss Exp $   */
+/*     $NetBSD: ohci_pci.c,v 1.13 1999/09/15 10:25:30 augustss Exp $   */
 
 /*
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -67,7 +67,8 @@
 void   ohci_pci_attach __P((struct device *, struct device *, void *));
 
 struct cfattach ohci_pci_ca = {
-       sizeof(struct ohci_softc), ohci_pci_match, ohci_pci_attach
+       sizeof(struct ohci_softc), ohci_pci_match, ohci_pci_attach,
+       ohci_detach, ohci_activate
 };
 
 int
@@ -157,5 +158,5 @@
        }
 
        /* Attach usb device. */
-       config_found((void *)sc, &sc->sc_bus, usbctlprint);
+       sc->sc_child = config_found((void *)sc, &sc->sc_bus, usbctlprint);
 }
diff -r fdba25a88e02 -r b539998e5aca sys/dev/pci/uhci_pci.c
--- a/sys/dev/pci/uhci_pci.c    Wed Sep 15 09:59:41 1999 +0000
+++ b/sys/dev/pci/uhci_pci.c    Wed Sep 15 10:25:30 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uhci_pci.c,v 1.10 1999/09/14 09:29:05 augustss Exp $   */
+/*     $NetBSD: uhci_pci.c,v 1.11 1999/09/15 10:25:30 augustss Exp $   */
 
 /*
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -60,7 +60,8 @@
 void   uhci_pci_attach __P((struct device *, struct device *, void *));
 
 struct cfattach uhci_pci_ca = {
-       sizeof(uhci_softc_t), uhci_pci_match, uhci_pci_attach
+       sizeof(uhci_softc_t), uhci_pci_match, uhci_pci_attach,
+       uhci_detach, uhci_activate
 };
 
 int
@@ -163,5 +164,5 @@
        }
 
        /* Attach usb device. */
-       config_found((void *)sc, &sc->sc_bus, usbctlprint);
+       sc->sc_child = config_found((void *)sc, &sc->sc_bus, usbctlprint);
 }
diff -r fdba25a88e02 -r b539998e5aca sys/dev/usb/ohci.c
--- a/sys/dev/usb/ohci.c        Wed Sep 15 09:59:41 1999 +0000
+++ b/sys/dev/usb/ohci.c        Wed Sep 15 10:25:30 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ohci.c,v 1.46 1999/09/13 21:33:25 augustss Exp $       */
+/*     $NetBSD: ohci.c,v 1.47 1999/09/15 10:25:31 augustss Exp $       */
 
 /*
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -283,6 +283,45 @@
 };
 #endif
 
+int
+ohci_activate(self, act)
+       device_ptr_t self;
+       enum devact act;
+{
+       /*struct ohci_softc *sc = (struct ohci_softc *)self;*/
+       int rv = 0;
+
+       switch (act) {
+       case DVACT_ACTIVATE:
+               return (EOPNOTSUPP);
+               break;
+
+       case DVACT_DEACTIVATE:
+               break;
+       }
+       return (rv);
+}
+
+int
+ohci_detach(self, flags)
+       device_ptr_t self;
+       int flags;
+{
+       struct ohci_softc *sc = (struct ohci_softc *)self;
+       int rv = 0;
+
+       if (sc->sc_child != NULL)
+               rv = config_detach(sc->sc_child, flags);
+       
+       if (rv != 0)
+               return (rv);
+
+       powerhook_disestablish(sc->sc_powerhook);
+       /* free data structures XXX */
+
+       return (rv);
+}
+
 ohci_soft_ed_t *
 ohci_alloc_sed(sc)
        ohci_softc_t *sc;
@@ -539,7 +578,7 @@
        sc->sc_bus.methods = &ohci_bus_methods;
        sc->sc_bus.pipe_size = sizeof(struct ohci_pipe);
 
-       powerhook_establish(ohci_power, sc);
+       sc->sc_powerhook = powerhook_establish(ohci_power, sc);
 
        return (USBD_NORMAL_COMPLETION);
 
diff -r fdba25a88e02 -r b539998e5aca sys/dev/usb/ohcivar.h
--- a/sys/dev/usb/ohcivar.h     Wed Sep 15 09:59:41 1999 +0000
+++ b/sys/dev/usb/ohcivar.h     Wed Sep 15 10:25:30 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ohcivar.h,v 1.9 1999/09/13 19:18:17 augustss Exp $     */
+/*     $NetBSD: ohcivar.h,v 1.10 1999/09/15 10:25:31 augustss Exp $    */
 
 /*
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -96,10 +96,15 @@
 
        char sc_vendor[16];
        int sc_id_vendor;
+
+       void *sc_powerhook;
+       device_ptr_t sc_child;
 } ohci_softc_t;
 
 usbd_status    ohci_init __P((ohci_softc_t *));
 int            ohci_intr __P((void *));
+int            ohci_detach __P((device_ptr_t, int));
+int            ohci_activate __P((device_ptr_t, enum devact));
 
 #define MS_TO_TICKS(ms) ((ms) * hz / 1000)
 
diff -r fdba25a88e02 -r b539998e5aca sys/dev/usb/uhci.c
--- a/sys/dev/usb/uhci.c        Wed Sep 15 09:59:41 1999 +0000
+++ b/sys/dev/usb/uhci.c        Wed Sep 15 10:25:30 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uhci.c,v 1.52 1999/09/13 21:33:25 augustss Exp $       */
+/*     $NetBSD: uhci.c,v 1.53 1999/09/15 10:25:31 augustss Exp $       */
 
 /*
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -407,7 +407,7 @@
        sc->sc_bus.pipe_size = sizeof(struct uhci_pipe);
 
        sc->sc_suspend = PWR_RESUME;
-       powerhook_establish(uhci_power, sc);
+       sc->sc_powerhook = powerhook_establish(uhci_power, sc);
 
        DPRINTFN(1,("uhci_init: enabling\n"));
        UWRITE2(sc, UHCI_INTR, UHCI_INTR_TOCRCIE | UHCI_INTR_RIE | 
@@ -416,6 +416,45 @@
        return (uhci_run(sc, 1));               /* and here we go... */
 }
 
+int
+uhci_activate(self, act)
+       device_ptr_t self;
+       enum devact act;
+{
+       /*struct uhci_softc *sc = (struct uhci_softc *)self;*/
+       int rv = 0;
+
+       switch (act) {
+       case DVACT_ACTIVATE:
+               return (EOPNOTSUPP);
+               break;
+
+       case DVACT_DEACTIVATE:
+               break;
+       }
+       return (rv);
+}
+
+int
+uhci_detach(self, flags)
+       device_ptr_t self;
+       int flags;
+{
+       struct uhci_softc *sc = (struct uhci_softc *)self;
+       int rv = 0;
+
+       if (sc->sc_child != NULL)
+               rv = config_detach(sc->sc_child, flags);
+       
+       if (rv != 0)
+               return (rv);
+
+       powerhook_disestablish(sc->sc_powerhook);
+       /* free data structures XXX */
+
+       return (rv);
+}
+
 usbd_status
 uhci_allocm(bus, dma, size)
        struct usbd_bus *bus;
diff -r fdba25a88e02 -r b539998e5aca sys/dev/usb/uhcivar.h
--- a/sys/dev/usb/uhcivar.h     Wed Sep 15 09:59:41 1999 +0000
+++ b/sys/dev/usb/uhcivar.h     Wed Sep 15 10:25:30 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uhcivar.h,v 1.13 1999/09/13 19:18:17 augustss Exp $    */
+/*     $NetBSD: uhcivar.h,v 1.14 1999/09/15 10:25:31 augustss Exp $    */
 
 /*
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -166,13 +166,15 @@
 
        char sc_vendor[16];
        int sc_id_vendor;
+
+       void *sc_powerhook;
+       device_ptr_t sc_child;
 } uhci_softc_t;
 
 usbd_status    uhci_init __P((uhci_softc_t *));
 int            uhci_intr __P((void *));
-#if 0
-void           uhci_reset __P((void *));
-#endif
+int            uhci_detach __P((device_ptr_t, int));
+int            uhci_activate __P((device_ptr_t, enum devact));
 
 #ifdef USB_DEBUG
 #define DPRINTF(x)     if (uhcidebug) printf x
diff -r fdba25a88e02 -r b539998e5aca sys/dev/usb/uhub.c
--- a/sys/dev/usb/uhub.c        Wed Sep 15 09:59:41 1999 +0000
+++ b/sys/dev/usb/uhub.c        Wed Sep 15 10:25:30 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uhub.c,v 1.28 1999/09/13 19:18:17 augustss Exp $       */
+/*     $NetBSD: uhub.c,v 1.29 1999/09/15 10:25:31 augustss Exp $       */
 
 /*
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -78,7 +78,6 @@
 };
 
 usbd_status uhub_init_port __P((struct usbd_port *));
-void uhub_disconnect_port __P((struct usbd_port *up));
 usbd_status uhub_explore __P((usbd_device_handle hub));
 void uhub_intr __P((usbd_request_handle, usbd_private_handle, usbd_status));
 
@@ -377,7 +376,7 @@
                        DPRINTF(("uhub_explore: device %d disappeared "
                                 "on port %d\n", 
                                 up->device->address, port));
-                       uhub_disconnect_port(up);
+                       usb_disconnect_port(up);
                        usbd_clear_port_feature(dev, port, 
                                                UHF_C_PORT_CONNECTION);
                }
@@ -432,62 +431,6 @@
        return (USBD_NORMAL_COMPLETION);
 }
 
-/*
- * The general mechanism for detaching drivers works as follows: Each
- * driver is responsible for maintaining a reference count on the
- * number of outstanding references to its softc (e.g.  from
- * processing hanging in a read or write).  The detach method of the
- * driver decrements this counter and flags in the softc that the
- * driver is dying and then wakes any sleepers.  It then sleeps on the
- * softc.  Each place that can sleep must maintain the reference
- * count.  When the reference count drops to -1 (0 is the normal value
- * of the reference count) the a wakeup on the softc is performed
- * signaling to the detach waiter that all references are gone.
- */
-
-/*
- * Called from process context when we discover that a port has
- * been disconnected.
- */
-void
-uhub_disconnect_port(up)
-       struct usbd_port *up;
-{
-       usbd_device_handle dev = up->device;
-       char *hubname;
-       int i;
-
-       DPRINTFN(3,("uhub_disconnect: up=%p dev=%p port=%d\n", 
-                   up, dev, up->portno));
-
-       if (!dev->cdesc) {
-               /* Partially attached device, just drop it. */
-               dev->bus->devices[dev->address] = 0;
-               up->device = 0;
-               return;
-       }
-
-       if (dev->subdevs) {
-               hubname = USBDEVPTRNAME(up->parent->subdevs[0]);



Home | Main Index | Thread Index | Old Index