From c306d509692dd2452b2a862e63fe444878e62090 Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Thu, 29 Sep 2005 15:00:09 +0000 Subject: [PATCH] Don't save and restore the ELCR register across suspend and resume for the Intel 82371AB PCI-ISA bridge. We now do this all the time for the !APIC case in the atpic driver. This cuts the raw line count for this driver by about 40%. MFC after: 1 week --- sys/dev/pci/isa_pci.c | 105 ++---------------------------------------- 1 file changed, 5 insertions(+), 100 deletions(-) diff --git a/sys/dev/pci/isa_pci.c b/sys/dev/pci/isa_pci.c index 335f1a5a9f23..073aff7a8095 100644 --- a/sys/dev/pci/isa_pci.c +++ b/sys/dev/pci/isa_pci.c @@ -39,37 +39,22 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include -#include #include -#include #include #include #include -#define ELCR_IOADDR 0x4d0 /* Interrupt Edge/Level Control Registers */ -#define ELCR_IOLEN 2 - -struct isab_softc { - struct resource *elcr_res; - u_char saved_elcr[ELCR_IOLEN]; -}; - static int isab_probe(device_t dev); -static int pci_isab_attach(device_t dev); -static int isab_detach(device_t dev); -static int isab_resume(device_t dev); -static int isab_suspend(device_t dev); static device_method_t isab_methods[] = { /* Device interface */ DEVMETHOD(device_probe, isab_probe), - DEVMETHOD(device_attach, pci_isab_attach), - DEVMETHOD(device_detach, isab_detach), + DEVMETHOD(device_attach, isab_attach), + DEVMETHOD(device_detach, bus_generic_detach), DEVMETHOD(device_shutdown, bus_generic_shutdown), - DEVMETHOD(device_suspend, isab_suspend), - DEVMETHOD(device_resume, isab_resume), + DEVMETHOD(device_suspend, bus_generic_suspend), + DEVMETHOD(device_resume, bus_generic_resume), /* Bus interface */ DEVMETHOD(bus_print_child, bus_generic_print_child), @@ -86,7 +71,7 @@ static device_method_t isab_methods[] = { static driver_t isab_driver = { "isab", isab_methods, - sizeof(struct isab_softc), + 0, }; DRIVER_MODULE(isab, pci, isab_driver, isab_devclass, 0, 0); @@ -154,83 +139,3 @@ isab_probe(device_t dev) } return(ENXIO); } - -static int -pci_isab_attach(device_t dev) -{ - struct isab_softc *sc = device_get_softc(dev); - int error, rid; - - /* - * Attach an ISA bus. Note that we can only have one ISA bus. - */ - error = isab_attach(dev); - if (error) - return (error); - - switch (pci_get_devid(dev)) { - case 0x71108086: /* Intel 82371AB */ - /* - * Sometimes the ELCR (Edge/Level Control Register) is not restored - * correctly on resume by the BIOS, so we handle it ourselves. - */ - rid = 0; - bus_set_resource(dev, SYS_RES_IOPORT, rid, ELCR_IOADDR, ELCR_IOLEN); - sc->elcr_res = bus_alloc_resource_any(dev, SYS_RES_IOPORT, &rid, - RF_ACTIVE); - if (sc->elcr_res == NULL) - device_printf(dev, "failed to allocate ELCR resource\n"); - break; - } - - return(0); -} - -static int -isab_detach(device_t dev) -{ - struct isab_softc *sc = device_get_softc(dev); - - if (sc->elcr_res != NULL) - bus_release_resource(dev, SYS_RES_IOPORT, 0, sc->elcr_res); - - return (bus_generic_detach(dev)); -} - -static int -isab_suspend(device_t dev) -{ - struct isab_softc *sc = device_get_softc(dev); - bus_space_tag_t bst; - bus_space_handle_t bsh; - int i; - - /* Save the ELCR if required. */ - if (sc->elcr_res != NULL) { - bst = rman_get_bustag(sc->elcr_res); - bsh = rman_get_bushandle(sc->elcr_res); - for (i = 0; i < ELCR_IOLEN; i++) - sc->saved_elcr[i] = bus_space_read_1(bst, bsh, i); - } - - return (bus_generic_suspend(dev)); -} - -static int -isab_resume(device_t dev) -{ - struct isab_softc *sc = device_get_softc(dev); - bus_space_tag_t bst; - bus_space_handle_t bsh; - int i; - - /* Restore the ELCR if required. */ - if (sc->elcr_res != NULL) { - bst = rman_get_bustag(sc->elcr_res); - bsh = rman_get_bushandle(sc->elcr_res); - for (i = 0; i < ELCR_IOLEN; i++) - bus_space_write_1(bst, bsh, i, sc->saved_elcr[i]); - } - - return (bus_generic_resume(dev)); -}