>>>>> "Warner" == Warner Losh <[EMAIL PROTECTED]> writes:
Warner> Hmmm.  Something about this patch looks incorrect.  Wouldn't it
Warner> delete the actual bus (eg pccard/cardbus)?  I'd think that we'd want
Warner> to delete the children's children.  I will have to look at the code
Warner> more closely to see if I might be mistaken.

I re-write a patch for NEWCARD.
New patch is,
 - detach children of cardbus/pccard devices at suspend time
 - probe and attach children of cardbus/pccard devices at resume time
 - pccbb devices are suspend/resume
 - cardbus and pccard devices are suspend/resume instead of detach/attach

Currently, I'm using this fixes on my NotePC and there is no problem.
-------
YAMAMOTO Shigeru        <[EMAIL PROTECTED]>
Index: cardbus/cardbus.c
===================================================================
RCS file: /share/cvsup/FreeBSD/current/usr/src/sys/dev/cardbus/cardbus.c,v
retrieving revision 1.12
diff -u -r1.12 cardbus.c
--- cardbus/cardbus.c   27 Aug 2001 00:09:34 -0000      1.12
+++ cardbus/cardbus.c   9 Dec 2001 15:51:50 -0000
@@ -163,6 +163,24 @@
        return 0;
 }
 
+static
+int
+cardbus_suspend(device_t self) {
+       int     error = 0;
+
+       cardbus_detach_card(self, DETACH_FORCE);
+
+       return(error);
+}
+
+static
+int
+cardbus_resume(device_t self) {
+       int     error = 0;
+
+       return(error);
+}
+
 /************************************************************************/
 /* Attach/Detach card                                                  */
 /************************************************************************/
@@ -1199,8 +1217,8 @@
        DEVMETHOD(device_attach,        cardbus_attach),
        DEVMETHOD(device_detach,        cardbus_detach),
        DEVMETHOD(device_shutdown,      bus_generic_shutdown),
-       DEVMETHOD(device_suspend,       bus_generic_suspend),
-       DEVMETHOD(device_resume,        bus_generic_resume),
+       DEVMETHOD(device_suspend,       cardbus_suspend),
+       DEVMETHOD(device_resume,        cardbus_resume),
 
        /* Bus interface */
        DEVMETHOD(bus_print_child,      cardbus_print_child),
Index: pccard/pccard.c
===================================================================
RCS file: /share/cvsup/FreeBSD/current/usr/src/sys/dev/pccard/pccard.c,v
retrieving revision 1.48
diff -u -r1.48 pccard.c
--- pccard/pccard.c     26 Nov 2001 07:14:00 -0000      1.48
+++ pccard/pccard.c     9 Dec 2001 15:50:43 -0000
@@ -807,6 +807,25 @@
        return 0;
 }
 
+static
+int
+pccard_suspend(device_t self) {
+       int     error = 0;
+       struct pccard_softc*    sc = PCCARD_SOFTC(self);
+
+       pccard_detach_card(self, 0);
+
+       return(error);
+}
+
+static
+int
+pccard_resume(device_t self) {
+       int     error = 0;
+
+       return(error);
+}
+
 static void
 pccard_print_resources(struct resource_list *rl, const char *name, int type,
     int count, const char *format)
@@ -1200,8 +1219,8 @@
        DEVMETHOD(device_attach,        pccard_attach),
        DEVMETHOD(device_detach,        pccard_detach),
        DEVMETHOD(device_shutdown,      bus_generic_shutdown),
-       DEVMETHOD(device_suspend,       bus_generic_suspend),
-       DEVMETHOD(device_resume,        bus_generic_resume),
+       DEVMETHOD(device_suspend,       pccard_suspend),
+       DEVMETHOD(device_resume,        pccard_resume),
 
        /* Bus interface */
        DEVMETHOD(bus_print_child,      pccard_print_child),
Index: pccbb/pccbb.c
===================================================================
RCS file: /share/cvsup/FreeBSD/current/usr/src/sys/dev/pccbb/pccbb.c,v
retrieving revision 1.31
diff -u -r1.31 pccbb.c
--- pccbb/pccbb.c       26 Nov 2001 07:17:09 -0000      1.31
+++ pccbb/pccbb.c       9 Dec 2001 15:50:04 -0000
@@ -2096,14 +2096,78 @@
            b, s, f, reg, val, width);
 }
 
+static
+int
+pccbb_suspend(device_t self) {
+       int                     error = 0;
+       struct pccbb_softc*     sc = device_get_softc(self);
+       int                     numdevs;
+       device_t*               devlist;
+       int                     tmp;
+
+       bus_teardown_intr(self, sc->sc_irq_res, sc->sc_intrhand);
+
+       bus_generic_suspend(self);
+
+       return(error);
+}
+
+static
+int
+pccbb_resume(device_t self)
+{
+       int     error = 0;
+       struct pccbb_softc *sc = (struct pccbb_softc *)device_get_softc(self);
+
+       pci_write_config(self, PCCBBR_SOCKBASE,
+                               rman_get_start(sc->sc_base_res), 4);
+       DEVPRINTF((self, "PCI Memory allocated: %08lx\n",
+                               rman_get_start(sc->sc_base_res)));
+
+       pccbb_chipinit(sc);
+
+       /* CSC Interrupt: Card detect interrupt on */
+       sc->sc_socketreg->socket_mask |= PCCBB_SOCKET_MASK_CD;
+
+       /* reset interrupt */
+       {
+               u_int32_t tmp;
+
+               tmp = sc->sc_socketreg->socket_event;
+               sc->sc_socketreg->socket_event = tmp;
+       }
+
+       /* establish the interrupt. */
+       if (bus_setup_intr(self, sc->sc_irq_res, INTR_TYPE_BIO, pccbb_intr, sc,
+           &(sc->sc_intrhand))) {
+               device_printf(self, "couldn't establish interrupt");
+               bus_release_resource(self, SYS_RES_IRQ, 0, sc->sc_irq_res);
+               bus_release_resource(self, SYS_RES_MEMORY, PCCBBR_SOCKBASE,
+                   sc->sc_base_res);
+               mtx_destroy(&sc->sc_mtx);
+               error = ENOMEM;
+       }
+
+       bus_generic_resume(self);
+
+       /* wakeup thread */
+       if (!error) {
+               mtx_lock(&sc->sc_mtx);
+               wakeup(sc);
+               mtx_unlock(&sc->sc_mtx);
+       }
+
+       return(error);
+}
+
 static device_method_t pccbb_methods[] = {
        /* Device interface */
        DEVMETHOD(device_probe,                 pccbb_probe),
        DEVMETHOD(device_attach,                pccbb_attach),
        DEVMETHOD(device_detach,                pccbb_detach),
        DEVMETHOD(device_shutdown,              pccbb_shutdown),
-       DEVMETHOD(device_suspend,               bus_generic_suspend),
-       DEVMETHOD(device_resume,                bus_generic_resume),
+       DEVMETHOD(device_suspend,               pccbb_suspend),
+       DEVMETHOD(device_resume,                pccbb_resume),
 
        /* bus methods */
        DEVMETHOD(bus_print_child,              bus_generic_print_child),

Reply via email to