-unmap port range after probe, so that the attach function has

a chance to map it again
-minor cleanup
This commit is contained in:
drochner 2004-01-28 13:51:16 +00:00
parent 3e9d8d6772
commit d1506371f5
1 changed files with 50 additions and 46 deletions

View File

@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: atppc_isa.c,v 1.4 2004/01/25 11:35:46 jdolecek Exp $
/*
* 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 @@ struct atppc_isa_softc {
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 @@ atppc_isa_probe(struct device * parent, struct cfdata * cf, void * aux)
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;
ia->ia_nio = 1;
ia->ia_io[0].ir_size = IO_LPTSIZE;
ia->ia_nirq = 1;
ia->ia_ndrq = 1;
ia->ia_niomem = 0;
bus_space_unmap(iot, ioh, IO_LPTSIZE);
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 @@ atppc_isa_attach(struct device *parent, struct device *self, void *aux)
}
/* 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);
}