Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/usb Add shutdown hooks to ensure that the host contr...



details:   https://anonhg.NetBSD.org/src/rev/7c7730a14f92
branches:  trunk
changeset: 480580:7c7730a14f92
user:      augustss <augustss%NetBSD.org@localhost>
date:      Sun Jan 16 10:27:51 2000 +0000

description:
Add shutdown hooks to ensure that the host controller is halted when
a reboot occurs.

diffstat:

 sys/dev/usb/ohci.c    |  29 ++++++++++++++++++++++++++---
 sys/dev/usb/ohcivar.h |   4 +++-
 sys/dev/usb/uhci.c    |  31 +++++++++++++++++++++++++------
 sys/dev/usb/uhcivar.h |   3 ++-
 4 files changed, 56 insertions(+), 11 deletions(-)

diffs (194 lines):

diff -r 2ff0a756a3eb -r 7c7730a14f92 sys/dev/usb/ohci.c
--- a/sys/dev/usb/ohci.c        Sun Jan 16 09:43:43 2000 +0000
+++ b/sys/dev/usb/ohci.c        Sun Jan 16 10:27:51 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ohci.c,v 1.58 1999/12/06 21:06:59 augustss Exp $       */
+/*     $NetBSD: ohci.c,v 1.59 2000/01/16 10:27:51 augustss Exp $       */
 /*     $FreeBSD: src/sys/dev/usb/ohci.c,v 1.22 1999/11/17 22:33:40 n_hibma Exp $       */
 
 /*
@@ -123,6 +123,7 @@
                            ohci_softc_t *, int, int, int, usb_dma_t *, 
                            ohci_soft_td_t *, ohci_soft_td_t **));
 
+static void            ohci_shutdown __P((void *v));
 static void            ohci_power __P((int, void *));
 static usbd_status     ohci_open __P((usbd_pipe_handle));
 static void            ohci_poll __P((struct usbd_bus *));
@@ -348,6 +349,8 @@
                return (rv);
 
        powerhook_disestablish(sc->sc_powerhook);
+       shutdownhook_disestablish(sc->sc_shutdownhook);
+
        /* free data structures XXX */
 
        return (rv);
@@ -697,6 +700,8 @@
 
        sc->sc_powerhook = powerhook_establish(ohci_power, sc);
 
+       sc->sc_shutdownhook = shutdownhook_establish(ohci_shutdown, sc);
+
        return (USBD_NORMAL_COMPLETION);
 
  bad3:
@@ -733,7 +738,26 @@
        usb_freemem(&sc->sc_bus, dma);
 }
 
-#if defined(__NetBSD__)
+/*
+ * Shut down the controller when the system is going down.
+ */
+void
+ohci_shutdown(v)
+       void *v;
+{
+       ohci_softc_t *sc = v;
+
+       DPRINTF(("ohci_shutdown: stopping the HC\n"));
+       OWRITE4(sc, OHCI_CONTROL, OHCI_HCFS_RESET);
+}
+
+/*
+ * Handle suspend/resume.
+ *
+ * We need to switch to polling mode here, because this routine is
+ * called from an intterupt context.  This is all right since we
+ * are almost suspended anyway.
+ */
 void
 ohci_power(why, v)
        int why;
@@ -747,7 +771,6 @@
        ohci_dumpregs(sc);
 #endif
 }
-#endif /* defined(__NetBSD__) */
 
 #ifdef OHCI_DEBUG
 void
diff -r 2ff0a756a3eb -r 7c7730a14f92 sys/dev/usb/ohcivar.h
--- a/sys/dev/usb/ohcivar.h     Sun Jan 16 09:43:43 2000 +0000
+++ b/sys/dev/usb/ohcivar.h     Sun Jan 16 10:27:51 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ohcivar.h,v 1.15 1999/11/18 23:32:27 augustss Exp $    */
+/*     $NetBSD: ohcivar.h,v 1.16 2000/01/16 10:27:51 augustss Exp $    */
 /*     $FreeBSD: src/sys/dev/usb/ohcivar.h,v 1.13 1999/11/17 22:33:41 n_hibma Exp $    */
 
 /*
@@ -94,6 +94,8 @@
        int sc_id_vendor;
 
        void *sc_powerhook;
+       void *sc_shutdownhook;          /* cookie from shutdown hook */
+
        device_ptr_t sc_child;
 } ohci_softc_t;
 
diff -r 2ff0a756a3eb -r 7c7730a14f92 sys/dev/usb/uhci.c
--- a/sys/dev/usb/uhci.c        Sun Jan 16 09:43:43 2000 +0000
+++ b/sys/dev/usb/uhci.c        Sun Jan 16 10:27:51 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uhci.c,v 1.71 1999/12/24 13:56:35 augustss Exp $       */
+/*     $NetBSD: uhci.c,v 1.72 2000/01/16 10:27:51 augustss Exp $       */
 /*     $FreeBSD: src/sys/dev/usb/uhci.c,v 1.33 1999/11/17 22:33:41 n_hibma Exp $       */
 
 /*
@@ -150,9 +150,8 @@
 LIST_HEAD(, uhci_intr_info) uhci_ii_free;
 
 static void            uhci_busreset __P((uhci_softc_t *));
-#if defined(__NetBSD__) || defined(__OpenBSD__)
+static void            uhci_shutdown __P((void *v));
 static void            uhci_power __P((int, void *));
-#endif
 static usbd_status     uhci_run __P((uhci_softc_t *, int run));
 static uhci_soft_td_t *uhci_alloc_std __P((uhci_softc_t *));
 static void            uhci_free_std __P((uhci_softc_t *, uhci_soft_td_t *));
@@ -425,6 +424,8 @@
        sc->sc_suspend = PWR_RESUME;
        sc->sc_powerhook = powerhook_establish(uhci_power, sc);
 
+       sc->sc_shutdownhook = shutdownhook_establish(uhci_shutdown, sc);
+
        DPRINTFN(1,("uhci_init: enabling\n"));
        UWRITE2(sc, UHCI_INTR, UHCI_INTR_TOCRCIE | UHCI_INTR_RIE | 
                UHCI_INTR_IOCE | UHCI_INTR_SPIE);       /* enable interrupts */
@@ -470,6 +471,8 @@
                return (rv);
 
        powerhook_disestablish(sc->sc_powerhook);
+       shutdownhook_disestablish(sc->sc_shutdownhook);
+
        /* free data structures XXX */
 
        return (rv);
@@ -494,7 +497,19 @@
        usb_freemem(&((struct uhci_softc *)bus)->sc_bus, dma);
 }
 
-#if defined(__NetBSD__)
+/*
+ * Shut down the controller when the system is going down.
+ */
+void
+uhci_shutdown(v)
+       void *v;
+{
+       uhci_softc_t *sc = v;
+
+       DPRINTF(("uhci_shutdown: stopping the HC\n"));
+       uhci_run(sc, 0); /* stop the controller */
+}
+
 /*
  * Handle suspend/resume.
  *
@@ -564,7 +579,6 @@
        }
        splx(s);
 }
-#endif /* defined(__NetBSD__) */
 
 #ifdef UHCI_DEBUG
 static void
@@ -1583,7 +1597,8 @@
 
        xfer->hcpriv = ii;
 
-       /* make sure hardware has completed, */
+#if 1
+       /* Make sure hardware has completed. */
        if (xfer->device->bus->intr_context) {
                /* We have no process context, so we can't use tsleep(). */
                timeout(uhci_abort_xfer_end, xfer, hz / USB_FRAMES_PER_SECOND);
@@ -1596,6 +1611,10 @@
                /* and call final part of interrupt handler. */
                uhci_abort_xfer_end(xfer);
        }
+#else
+       delay(1000);
+       uhci_abort_xfer_end(xfer);
+#endif
 }
 
 void
diff -r 2ff0a756a3eb -r 7c7730a14f92 sys/dev/usb/uhcivar.h
--- a/sys/dev/usb/uhcivar.h     Sun Jan 16 09:43:43 2000 +0000
+++ b/sys/dev/usb/uhcivar.h     Sun Jan 16 10:27:51 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uhcivar.h,v 1.19 1999/12/06 21:07:00 augustss Exp $    */
+/*     $NetBSD: uhcivar.h,v 1.20 2000/01/16 10:27:51 augustss Exp $    */
 /*     $FreeBSD: src/sys/dev/usb/uhcivar.h,v 1.14 1999/11/17 22:33:42 n_hibma Exp $    */
 
 /*
@@ -163,6 +163,7 @@
        int sc_id_vendor;               /* vendor ID for root hub */
 
        void *sc_powerhook;             /* cookie from power hook */
+       void *sc_shutdownhook;          /* cookie from shutdown hook */
 
        device_ptr_t sc_child;          /* /dev/usb device */
 } uhci_softc_t;



Home | Main Index | Thread Index | Old Index