Re: 2 patches for NEWCARD
> "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 - 1.12 +++ cardbus/cardbus.c 9 Dec 2001 15:51:50 - @@ -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 - 1.48 +++ pccard/pccard.c 9 Dec 2001 15:50:43 - @@ -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 - 1.31 +++ pccbb/pccbb.c 9 Dec 2001 15:50:04 - @@ -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; + } + + /* es
Re: 2 patches for NEWCARD
In message <[EMAIL PROTECTED]> YAMAMOTO Shigeru writes: : I make 2 patches for NEWCARD. Wonderful! : one is to supoort to suspend/resume PC Card devices on NEWCARD. Hmmm. Something about this patch looks incorrect. Wouldn't it delete the actual bus (eg pccard/cardbus)? I'd think that we'd want to delete the children's children. I will have to look at the code more closely to see if I might be mistaken. : other is to ignore ghost interrupt at ed driver when removing PC Card. This looks good. I'll commit it. : So I don't know my patches work fine on other NotePC. I'll have to test it on my machine. Thank you yamamoto-san. Warner To Unsubscribe: send mail to [EMAIL PROTECTED] with "unsubscribe freebsd-current" in the body of the message
2 patches for NEWCARD
Hi all, I make 2 patches for NEWCARD. one is to supoort to suspend/resume PC Card devices on NEWCARD. other is to ignore ghost interrupt at ed driver when removing PC Card. It is a quick hack and I only tested on my NotePC, Sony VAIO 818. So I don't know my patches work fine on other NotePC. Please try if you have interest to my patches. Thanks, --- YAMAMOTO Shigeru<[EMAIL PROTECTED]> Index: sys/dev/pccbb/pccbb.c === RCS file: /share/cvsup/FreeBSD/current/usr/src/sys/dev/pccbb/pccbb.c,v retrieving revision 1.27 diff -u -r1.27 pccbb.c --- sys/dev/pccbb/pccbb.c 3 Nov 2001 16:45:31 - 1.27 +++ sys/dev/pccbb/pccbb.c 18 Nov 2001 19:37:52 - @@ -2096,14 +2096,112 @@ b, s, f, reg, val, width); } +static +int +pccbb_suspend(device_t dev) { + int error = 0; + struct pccbb_softc* sc = device_get_softc(dev); + int numdevs; + device_t* devlist; + int tmp; + + bus_teardown_intr(dev, sc->sc_irq_res, sc->sc_intrhand); + + device_get_children(dev, &devlist, &numdevs); + + error = 0; + for (tmp = 0; tmp < numdevs; tmp++) { + if (device_detach(devlist[tmp]) == 0) { + device_delete_child(dev, devlist[tmp]); + } + else { + error++; + } + } + free(devlist, M_TEMP); + if (error > 0) { + return ENXIO; + } + + sc->sc_cbdev = NULL; + sc->sc_pccarddev = NULL; + + 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; + } + + /* attach children */ + if (!error) { + sc->sc_cbdev = device_add_child(self, "cardbus", -1); + if (sc->sc_cbdev == NULL) + DEVPRINTF((self, "WARNING: cannot add cardbus bus.\n")); + else if (device_probe_and_attach(sc->sc_cbdev) != 0) { + DEVPRINTF((self, "WARNING: cannot attach cardbus bus!\n")); + sc->sc_cbdev = NULL; + } + + sc->sc_pccarddev = device_add_child(self, "pccard", -1); + if (sc->sc_pccarddev == NULL) + DEVPRINTF((self, "WARNING: cannot add pccard bus.\n")); + else if (device_probe_and_attach(sc->sc_pccarddev) != 0) { + DEVPRINTF((self, "WARNING: cannot attach pccard bus.\n")); + sc->sc_pccarddev = NULL; + } + } + + /* 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), Index: sys/dev/ed/if_ed.c