Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/isa -unmap port range after probe, so that the attac...



details:   https://anonhg.NetBSD.org/src/rev/2a2b419d9d2f
branches:  trunk
changeset: 558082:2a2b419d9d2f
user:      drochner <drochner%NetBSD.org@localhost>
date:      Wed Jan 28 13:51:16 2004 +0000

description:
-unmap port range after probe, so that the attach function has
 a chance to map it again
-minor cleanup

diffstat:

 sys/dev/isa/atppc_isa.c |  98 +++++++++++++++++++++++++-----------------------
 1 files changed, 51 insertions(+), 47 deletions(-)

diffs (194 lines):

diff -r 14410dad3312 -r 2a2b419d9d2f sys/dev/isa/atppc_isa.c
--- a/sys/dev/isa/atppc_isa.c   Wed Jan 28 10:54:23 2004 +0000
+++ b/sys/dev/isa/atppc_isa.c   Wed Jan 28 13:51:16 2004 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: atppc_isa.c,v 1.4 2004/01/25 11:35:46 jdolecek Exp $ */
+/* $NetBSD: atppc_isa.c,v 1.5 2004/01/28 13:51:16 drochner Exp $ */
 
 /*-
  * Copyright (c) 2001 Alcove - Nicolas Souchu
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: atppc_isa.c,v 1.4 2004/01/25 11:35:46 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: atppc_isa.c,v 1.5 2004/01/28 13:51:16 drochner Exp $");
 
 #include "opt_atppc.h"
 
@@ -53,11 +53,11 @@
 
 /*
  * ISA bus attach code for atppc driver.
- * Note on capabilities: capabilites may exist in the chipset but may not 
- * necessarily be useable. I.e. you may specify an IRQ in the autoconfig, but 
+ * Note on capabilities: capabilites may exist in the chipset but may not
+ * necessarily be useable. I.e. you may specify an IRQ in the autoconfig, but
  * will the port actually have an IRQ assigned to it at the hardware level?
- * How can you test if the capabilites can be used? For interrupts, see if a 
- * handler exists (sc_intr != NULL). For DMA, see if the sc_dma_start() and 
+ * How can you test if the capabilites can be used? For interrupts, see if a
+ * handler exists (sc_intr != NULL). For DMA, see if the sc_dma_start() and
  * sc_dma_finish() function pointers are not NULL.
  */
 
@@ -79,28 +79,29 @@
 static int atppc_isa_probe __P((struct device *, struct cfdata *, void *));
 static void atppc_isa_attach __P((struct device *, struct device *, void *));
 
-static int atppc_isa_dma_start(struct atppc_softc *, void *, u_int, 
+static int atppc_isa_dma_start(struct atppc_softc *, void *, u_int,
        u_int8_t);
 static int atppc_isa_dma_finish(struct atppc_softc *);
 static int atppc_isa_dma_abort(struct atppc_softc *);
-static int atppc_isa_dma_malloc(struct device *, caddr_t *, bus_addr_t *, 
+static int atppc_isa_dma_malloc(struct device *, caddr_t *, bus_addr_t *,
        bus_size_t);
-static void atppc_isa_dma_free(struct device *, caddr_t *, bus_addr_t *, 
+static void atppc_isa_dma_free(struct device *, caddr_t *, bus_addr_t *,
        bus_size_t);
 
 CFATTACH_DECL(atppc_isa, sizeof(struct atppc_isa_softc), atppc_isa_probe,
        atppc_isa_attach, NULL, NULL);
 
-/* 
- * Probe function: find parallel port controller on isa bus. Combined from 
- * lpt_isa_probe() in lpt.c and atppc_detect_port() from FreeBSD's ppc.c. 
+/*
+ * Probe function: find parallel port controller on isa bus. Combined from
+ * lpt_isa_probe() in lpt.c and atppc_detect_port() from FreeBSD's ppc.c.
  */
 static int
-atppc_isa_probe(struct device * parent, struct cfdata * cf, void * aux)
+atppc_isa_probe(struct device *parent, struct cfdata *cf, void *aux)
 {
        bus_space_handle_t ioh;
-       struct isa_attach_args * ia = aux;
+       struct isa_attach_args *ia = aux;
        bus_space_tag_t iot = ia->ia_iot;
+       int rval = 0;
 
        if (ia->ia_nio < 1)
                return (0);
@@ -112,35 +113,38 @@
        if (bus_space_map(iot, ia->ia_io[0].ir_addr, IO_LPTSIZE, 0, &ioh))
                return (0);
 
-       if (atppc_detect_port(iot, ioh) != 0) 
-               return (0);
+       if (atppc_detect_port(iot, ioh) == 0)
+               rval = 1;
+
+       bus_space_unmap(iot, ioh, IO_LPTSIZE);
 
-       ia->ia_nio = 1;
-       ia->ia_io[0].ir_size = IO_LPTSIZE;
-       ia->ia_nirq = 1;
-       ia->ia_ndrq = 1;
-       ia->ia_niomem = 0;
-
-       return (1);
+       if (rval) {
+               ia->ia_nio = 1;
+               ia->ia_io[0].ir_size = IO_LPTSIZE;
+               ia->ia_nirq = 1;
+               ia->ia_ndrq = 1;
+               ia->ia_niomem = 0;
+       }
+       return (rval);
 }
 
 /* Attach function: attach and configure parallel port controller on isa bus. */
-static void 
+static void
 atppc_isa_attach(struct device *parent, struct device *self, void *aux)
 {
-       struct atppc_isa_softc * sc = (struct atppc_isa_softc *)self;
-       struct atppc_softc * lsc = (struct atppc_softc *)self; 
-       struct isa_attach_args * ia = aux;
+       struct atppc_isa_softc *sc = (struct atppc_isa_softc *)self;
+       struct atppc_softc *lsc = &sc->sc_atppc;
+       struct isa_attach_args *ia = aux;
 
        printf(": AT Parallel Port\n");
 
        lsc->sc_iot = ia->ia_iot;
-       lsc->sc_dmat = ia->ia_dmat; 
+       lsc->sc_dmat = ia->ia_dmat;
        lsc->sc_has = 0;
        sc->sc_ic = ia->ia_ic;
        sc->sc_iobase = ia->ia_io->ir_addr;
 
-       if (bus_space_map(lsc->sc_iot, sc->sc_iobase, IO_LPTSIZE, 0, 
+       if (bus_space_map(lsc->sc_iot, sc->sc_iobase, IO_LPTSIZE, 0,
                &lsc->sc_ioh) != 0) {
                printf("%s: attempt to map bus space failed, device not "
                        "properly attached.\n", self->dv_xname);
@@ -193,49 +197,49 @@
 }
 
 /* Start DMA operation over ISA bus */
-static int 
+static int
 atppc_isa_dma_start(struct atppc_softc *lsc, void *buf, u_int nbytes,
        u_int8_t mode)
 {
-       struct atppc_isa_softc * sc = (struct atppc_isa_softc *) lsc;
-       
+       struct atppc_isa_softc *sc = (struct atppc_isa_softc *)lsc;
+
        return atppc_isadma_start(sc->sc_ic, sc->sc_drq, buf, nbytes, mode);
 }
 
 /* Stop DMA operation over ISA bus */
-static int 
-atppc_isa_dma_finish(struct atppc_softc * lsc)
+static int
+atppc_isa_dma_finish(struct atppc_softc *lsc)
 {
-       struct atppc_isa_softc * sc = (struct atppc_isa_softc *) lsc;
-       
+       struct atppc_isa_softc *sc = (struct atppc_isa_softc *)lsc;
+
        return atppc_isadma_finish(sc->sc_ic, sc->sc_drq);
 }
 
 /* Abort DMA operation over ISA bus */
-static int 
-atppc_isa_dma_abort(struct atppc_softc * lsc)
+static int
+atppc_isa_dma_abort(struct atppc_softc *lsc)
 {
-       struct atppc_isa_softc * sc = (struct atppc_isa_softc *) lsc;
-       
+       struct atppc_isa_softc *sc = (struct atppc_isa_softc *)lsc;
+
        return atppc_isadma_abort(sc->sc_ic, sc->sc_drq);
 }
 
-/* Allocate memory for DMA over ISA bus */ 
+/* Allocate memory for DMA over ISA bus */
 static int
-atppc_isa_dma_malloc(struct device * dev, caddr_t * buf, bus_addr_t * bus_addr,
+atppc_isa_dma_malloc(struct device *dev, caddr_t *buf, bus_addr_t *bus_addr,
        bus_size_t size)
 {
-       struct atppc_isa_softc * sc = (struct atppc_isa_softc *) dev;
+       struct atppc_isa_softc *sc = (struct atppc_isa_softc *)dev;
 
        return atppc_isadma_malloc(sc->sc_ic, sc->sc_drq, buf, bus_addr, size);
 }
 
-/* Free memory allocated by atppc_isa_dma_malloc() */ 
-static void 
-atppc_isa_dma_free(struct device * dev, caddr_t * buf, bus_addr_t * bus_addr, 
+/* Free memory allocated by atppc_isa_dma_malloc() */
+static void
+atppc_isa_dma_free(struct device *dev, caddr_t *buf, bus_addr_t *bus_addr,
        bus_size_t size)
 {
-       struct atppc_isa_softc * sc = (struct atppc_isa_softc *) dev;
+       struct atppc_isa_softc *sc = (struct atppc_isa_softc *)dev;
 
        return atppc_isadma_free(sc->sc_ic, sc->sc_drq, buf, bus_addr, size);
 }



Home | Main Index | Thread Index | Old Index