From 0f6bc470298bce32458e9ae0431495e4c4ef10e9 Mon Sep 17 00:00:00 2001 From: Peter Wemm Date: Sun, 18 Apr 1999 19:08:28 +0000 Subject: [PATCH] Make the bt isa driver work.. - fix cut/paste problem. :-) - don't forget to call isa_dmacascade() - reset the port after we release resources. That last one is a trap to watch out for.. The isa bus driver uses the same port/irq/mem/etc variables for the initial probe hints as it does for allocation/deallocation tracking. Releasing a resource clears the variable and then you loose the hint during attach.. (ouch!) --- sys/dev/buslogic/bt_isa.c | 16 +++++++++++----- sys/i386/isa/bt_isa.c | 16 +++++++++++----- sys/isa/bt_isa.c | 16 +++++++++++----- 3 files changed, 33 insertions(+), 15 deletions(-) diff --git a/sys/dev/buslogic/bt_isa.c b/sys/dev/buslogic/bt_isa.c index 03c5c8230e8..f9105ead61d 100644 --- a/sys/dev/buslogic/bt_isa.c +++ b/sys/dev/buslogic/bt_isa.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: bt_isa.c,v 1.7 1999/04/06 21:15:18 phk Exp $ + * $Id: bt_isa.c,v 1.8 1999/04/18 15:50:35 peter Exp $ */ #include @@ -105,9 +105,9 @@ bt_isa_release_resources(device_t dev) if (bt->port) bus_release_resource(dev, SYS_RES_IOPORT, 0, bt->port); if (bt->irq) - bus_release_resource(dev, SYS_RES_IOPORT, 0, bt->irq); + bus_release_resource(dev, SYS_RES_IRQ, 0, bt->irq); if (bt->drq) - bus_release_resource(dev, SYS_RES_IOPORT, 0, bt->drq); + bus_release_resource(dev, SYS_RES_DRQ, 0, bt->drq); bt_free_softc(dev); } @@ -169,6 +169,7 @@ bt_isa_probe(device_t dev) bt_isa_release_resources(dev); + isa_set_port(dev, ioport); isa_set_drq(dev, info.drq); isa_set_irq(dev, info.irq); @@ -188,7 +189,7 @@ bt_isa_attach(device_t dev) bus_dma_filter_t *filter; void *filter_arg; bus_addr_t lowaddr; - int error; + int error, drq; /* Initialise softc */ error = bt_isa_alloc_resources(dev); @@ -197,6 +198,10 @@ bt_isa_attach(device_t dev) return error; } + /* Program the DMA channel for external control */ + if ((drq = isa_get_drq(dev)) != -1) + isa_dmacascade(drq); + /* Allocate our parent dmatag */ filter = NULL; filter_arg = NULL; @@ -236,7 +241,8 @@ bt_isa_attach(device_t dev) return (ENOMEM); } - if (bt_init(dev)) { + error = bt_init(dev); + if (error) { bt_isa_release_resources(dev); return (ENOMEM); } diff --git a/sys/i386/isa/bt_isa.c b/sys/i386/isa/bt_isa.c index 03c5c8230e8..f9105ead61d 100644 --- a/sys/i386/isa/bt_isa.c +++ b/sys/i386/isa/bt_isa.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: bt_isa.c,v 1.7 1999/04/06 21:15:18 phk Exp $ + * $Id: bt_isa.c,v 1.8 1999/04/18 15:50:35 peter Exp $ */ #include @@ -105,9 +105,9 @@ bt_isa_release_resources(device_t dev) if (bt->port) bus_release_resource(dev, SYS_RES_IOPORT, 0, bt->port); if (bt->irq) - bus_release_resource(dev, SYS_RES_IOPORT, 0, bt->irq); + bus_release_resource(dev, SYS_RES_IRQ, 0, bt->irq); if (bt->drq) - bus_release_resource(dev, SYS_RES_IOPORT, 0, bt->drq); + bus_release_resource(dev, SYS_RES_DRQ, 0, bt->drq); bt_free_softc(dev); } @@ -169,6 +169,7 @@ bt_isa_probe(device_t dev) bt_isa_release_resources(dev); + isa_set_port(dev, ioport); isa_set_drq(dev, info.drq); isa_set_irq(dev, info.irq); @@ -188,7 +189,7 @@ bt_isa_attach(device_t dev) bus_dma_filter_t *filter; void *filter_arg; bus_addr_t lowaddr; - int error; + int error, drq; /* Initialise softc */ error = bt_isa_alloc_resources(dev); @@ -197,6 +198,10 @@ bt_isa_attach(device_t dev) return error; } + /* Program the DMA channel for external control */ + if ((drq = isa_get_drq(dev)) != -1) + isa_dmacascade(drq); + /* Allocate our parent dmatag */ filter = NULL; filter_arg = NULL; @@ -236,7 +241,8 @@ bt_isa_attach(device_t dev) return (ENOMEM); } - if (bt_init(dev)) { + error = bt_init(dev); + if (error) { bt_isa_release_resources(dev); return (ENOMEM); } diff --git a/sys/isa/bt_isa.c b/sys/isa/bt_isa.c index 03c5c8230e8..f9105ead61d 100644 --- a/sys/isa/bt_isa.c +++ b/sys/isa/bt_isa.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: bt_isa.c,v 1.7 1999/04/06 21:15:18 phk Exp $ + * $Id: bt_isa.c,v 1.8 1999/04/18 15:50:35 peter Exp $ */ #include @@ -105,9 +105,9 @@ bt_isa_release_resources(device_t dev) if (bt->port) bus_release_resource(dev, SYS_RES_IOPORT, 0, bt->port); if (bt->irq) - bus_release_resource(dev, SYS_RES_IOPORT, 0, bt->irq); + bus_release_resource(dev, SYS_RES_IRQ, 0, bt->irq); if (bt->drq) - bus_release_resource(dev, SYS_RES_IOPORT, 0, bt->drq); + bus_release_resource(dev, SYS_RES_DRQ, 0, bt->drq); bt_free_softc(dev); } @@ -169,6 +169,7 @@ bt_isa_probe(device_t dev) bt_isa_release_resources(dev); + isa_set_port(dev, ioport); isa_set_drq(dev, info.drq); isa_set_irq(dev, info.irq); @@ -188,7 +189,7 @@ bt_isa_attach(device_t dev) bus_dma_filter_t *filter; void *filter_arg; bus_addr_t lowaddr; - int error; + int error, drq; /* Initialise softc */ error = bt_isa_alloc_resources(dev); @@ -197,6 +198,10 @@ bt_isa_attach(device_t dev) return error; } + /* Program the DMA channel for external control */ + if ((drq = isa_get_drq(dev)) != -1) + isa_dmacascade(drq); + /* Allocate our parent dmatag */ filter = NULL; filter_arg = NULL; @@ -236,7 +241,8 @@ bt_isa_attach(device_t dev) return (ENOMEM); } - if (bt_init(dev)) { + error = bt_init(dev); + if (error) { bt_isa_release_resources(dev); return (ENOMEM); }