reorganize the ISA DMA setup/use code so that it could be shared
with ACPI and PNPBIOS attachments; move it to new atppc_isadma.[ch] and g/c previous atppc_isa_subr.[ch] move attppc_isa_softc struct definition to atppc_isa.c, and reorganize the attachment somewhat for better readability; also g/c detach support code
This commit is contained in:
parent
6894b27b47
commit
907186d1bb
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: atppc_isa.c,v 1.3 2004/01/25 00:28:01 bjh21 Exp $ */
|
||||
/* $NetBSD: atppc_isa.c,v 1.4 2004/01/25 11:35:46 jdolecek Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 Alcove - Nicolas Souchu
|
||||
|
@ -30,7 +30,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: atppc_isa.c,v 1.3 2004/01/25 00:28:01 bjh21 Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: atppc_isa.c,v 1.4 2004/01/25 11:35:46 jdolecek Exp $");
|
||||
|
||||
#include "opt_atppc.h"
|
||||
|
||||
|
@ -46,10 +46,10 @@ __KERNEL_RCSID(0, "$NetBSD: atppc_isa.c,v 1.3 2004/01/25 00:28:01 bjh21 Exp $");
|
|||
#include <dev/isa/isareg.h>
|
||||
#include <dev/isa/isavar.h>
|
||||
#include <dev/isa/isadmavar.h>
|
||||
#include <dev/isa/atppc_isa_subr.h>
|
||||
|
||||
#include <dev/ic/atppcreg.h>
|
||||
#include <dev/ic/atppcvar.h>
|
||||
#include <dev/isa/atppc_isadma.h>
|
||||
|
||||
/*
|
||||
* ISA bus attach code for atppc driver.
|
||||
|
@ -61,13 +61,35 @@ __KERNEL_RCSID(0, "$NetBSD: atppc_isa.c,v 1.3 2004/01/25 00:28:01 bjh21 Exp $");
|
|||
* sc_dma_finish() function pointers are not NULL.
|
||||
*/
|
||||
|
||||
/* Probe, attach, and detach functions for a atppc device on the ISA bus. */
|
||||
/* Configuration data for atppc on isa bus. */
|
||||
struct atppc_isa_softc {
|
||||
/* Machine independent device data */
|
||||
struct atppc_softc sc_atppc;
|
||||
|
||||
/* IRQ/DRQ/IO Port assignments on ISA bus */
|
||||
int sc_irq;
|
||||
int sc_drq;
|
||||
int sc_iobase;
|
||||
|
||||
/* ISA chipset tag */
|
||||
isa_chipset_tag_t sc_ic;
|
||||
};
|
||||
|
||||
/* Probe and attach functions for a atppc device on the ISA bus. */
|
||||
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_detach __P((struct device *, 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 *,
|
||||
bus_size_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, atppc_isa_detach, NULL);
|
||||
atppc_isa_attach, NULL, NULL);
|
||||
|
||||
/*
|
||||
* Probe function: find parallel port controller on isa bus. Combined from
|
||||
|
@ -79,101 +101,89 @@ atppc_isa_probe(struct device * parent, struct cfdata * cf, void * aux)
|
|||
bus_space_handle_t ioh;
|
||||
struct isa_attach_args * ia = aux;
|
||||
bus_space_tag_t iot = ia->ia_iot;
|
||||
int addr = ia->ia_io->ir_addr;
|
||||
int rval = 0;
|
||||
|
||||
if(ia->ia_nio < 1 || addr == ISACF_PORT_DEFAULT) {
|
||||
printf("%s(%s): io port unknown.\n", __func__,
|
||||
parent->dv_xname);
|
||||
}
|
||||
else if(bus_space_map(iot, addr, IO_LPTSIZE, 0, &ioh) == 0) {
|
||||
if (atppc_detect_port(iot, ioh) == 0)
|
||||
rval = 1;
|
||||
else
|
||||
printf("%s(%s): unable to write/read I/O port.\n",
|
||||
__func__, parent->dv_xname);
|
||||
bus_space_unmap(iot, ioh, IO_LPTSIZE);
|
||||
}
|
||||
else {
|
||||
printf("%s(%s): attempt to map bus space failed.\n", __func__,
|
||||
parent->dv_xname);
|
||||
}
|
||||
if (ia->ia_nio < 1)
|
||||
return (0);
|
||||
|
||||
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;
|
||||
}
|
||||
/* Disallow wildcarded i/o address */
|
||||
if (ia->ia_io[0].ir_addr == ISACF_PORT_DEFAULT)
|
||||
return (0);
|
||||
|
||||
return rval;
|
||||
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);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/* Attach function: attach and configure parallel port controller on isa bus. */
|
||||
static void
|
||||
atppc_isa_attach(struct device * parent, struct device * self, void * aux)
|
||||
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;
|
||||
|
||||
printf(": AT Parallel Port\n");
|
||||
|
||||
lsc->sc_iot = ia->ia_iot;
|
||||
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);
|
||||
lsc->sc_dev_ok = ATPPC_NOATTACH;
|
||||
return;
|
||||
}
|
||||
else {
|
||||
lsc->sc_dev_ok = ATPPC_ATTACHED;
|
||||
}
|
||||
|
||||
lsc->sc_dev_ok = ATPPC_ATTACHED;
|
||||
|
||||
/* Assign interrupt handler */
|
||||
if(!(self->dv_cfdata->cf_flags & ATPPC_FLAG_DISABLE_INTR)) {
|
||||
if((ia->ia_irq->ir_irq != ISACF_IRQ_DEFAULT) &&
|
||||
(ia->ia_nirq > 0)) {
|
||||
|
||||
sc->sc_irq = ia->ia_irq->ir_irq;
|
||||
/* Establish interrupt handler. */
|
||||
if(!(atppc_isa_intr_establish(lsc))) {
|
||||
lsc->sc_has |= ATPPC_HAS_INTR;
|
||||
}
|
||||
}
|
||||
else {
|
||||
ATPPC_DPRINTF(("%s: IRQ not assigned or bad number of "
|
||||
"IRQs.\n", self->dv_xname));
|
||||
}
|
||||
}
|
||||
else {
|
||||
ATPPC_VPRINTF(("%s: interrupts not configured due to flags.\n",
|
||||
self->dv_xname));
|
||||
if (!(self->dv_cfdata->cf_flags & ATPPC_FLAG_DISABLE_INTR)
|
||||
&& ia->ia_irq->ir_irq != ISACF_IRQ_DEFAULT
|
||||
&& ia->ia_nirq >= 1) {
|
||||
sc->sc_irq = ia->ia_irq[0].ir_irq;
|
||||
} else
|
||||
sc->sc_irq = -1;
|
||||
|
||||
if (sc->sc_irq > 0) {
|
||||
/* Establish interrupt handler. */
|
||||
lsc->sc_ieh = isa_intr_establish(sc->sc_ic, sc->sc_irq,
|
||||
IST_EDGE, IPL_ATPPC, atppcintr, &lsc->sc_dev);
|
||||
|
||||
lsc->sc_has |= ATPPC_HAS_INTR;
|
||||
}
|
||||
|
||||
/* Configure DMA */
|
||||
if(!(self->dv_cfdata->cf_flags & ATPPC_FLAG_DISABLE_DMA)) {
|
||||
if((ia->ia_drq->ir_drq != ISACF_DRQ_DEFAULT) &&
|
||||
(ia->ia_ndrq > 0)) {
|
||||
if (!(self->dv_cfdata->cf_flags & ATPPC_FLAG_DISABLE_DMA)
|
||||
&& ia->ia_drq->ir_drq != ISACF_DRQ_DEFAULT
|
||||
&& ia->ia_ndrq >= 1)
|
||||
sc->sc_drq = ia->ia_drq[0].ir_drq;
|
||||
else
|
||||
sc->sc_drq = -1;
|
||||
|
||||
sc->sc_drq = ia->ia_drq->ir_drq;
|
||||
if(!(atppc_isa_dma_setup(lsc))) {
|
||||
lsc->sc_has |= ATPPC_HAS_DMA;
|
||||
}
|
||||
}
|
||||
else {
|
||||
ATPPC_DPRINTF(("%s: DRQ not assigned or bad number of "
|
||||
"DRQs.\n", self->dv_xname));
|
||||
}
|
||||
}
|
||||
else {
|
||||
ATPPC_VPRINTF(("%s: dma not configured due to flags.\n",
|
||||
self->dv_xname));
|
||||
if (sc->sc_drq != -1
|
||||
&& atppc_isadma_setup(lsc, sc->sc_ic, sc->sc_drq) == 0) {
|
||||
lsc->sc_has |= ATPPC_HAS_DMA;
|
||||
|
||||
/* setup DMA hooks */
|
||||
lsc->sc_dma_start = atppc_isa_dma_start;
|
||||
lsc->sc_dma_finish = atppc_isa_dma_finish;
|
||||
lsc->sc_dma_abort = atppc_isa_dma_abort;
|
||||
lsc->sc_dma_malloc = atppc_isa_dma_malloc;
|
||||
lsc->sc_dma_free = atppc_isa_dma_free;
|
||||
}
|
||||
|
||||
/* Run soft configuration attach */
|
||||
|
@ -182,40 +192,50 @@ atppc_isa_attach(struct device * parent, struct device * self, void * aux)
|
|||
return;
|
||||
}
|
||||
|
||||
/* Detach function: used to detach atppc driver at run time. */
|
||||
/* Start DMA operation over ISA bus */
|
||||
static int
|
||||
atppc_isa_detach(struct device * dev, int flag)
|
||||
atppc_isa_dma_start(struct atppc_softc *lsc, void *buf, u_int nbytes,
|
||||
u_int8_t mode)
|
||||
{
|
||||
struct atppc_softc * lsc = (struct atppc_softc *) dev;
|
||||
int rval;
|
||||
|
||||
if(lsc->sc_dev_ok == ATPPC_ATTACHED) {
|
||||
/* Run soft configuration detach first */
|
||||
rval = atppc_sc_detach(lsc, flag);
|
||||
|
||||
/* Disable DMA */
|
||||
atppc_isa_dma_remove(lsc);
|
||||
|
||||
/* Disestablish interrupt handler */
|
||||
atppc_isa_intr_disestablish(lsc);
|
||||
struct atppc_isa_softc * sc = (struct atppc_isa_softc *) lsc;
|
||||
|
||||
/* Unmap bus space */
|
||||
bus_space_unmap(lsc->sc_iot, lsc->sc_ioh, IO_LPTSIZE);
|
||||
|
||||
/* Mark config data */
|
||||
lsc->sc_dev_ok = ATPPC_NOATTACH;
|
||||
}
|
||||
else {
|
||||
rval = 0;
|
||||
if(!(flag & DETACH_QUIET)) {
|
||||
printf("%s not properly attached! Detach routines "
|
||||
"skipped.\n", dev->dv_xname);
|
||||
}
|
||||
}
|
||||
|
||||
if(!(flag & DETACH_QUIET)) {
|
||||
printf("%s: detached.", dev->dv_xname);
|
||||
}
|
||||
|
||||
return rval;
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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 */
|
||||
static int
|
||||
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;
|
||||
|
||||
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,
|
||||
bus_size_t size)
|
||||
{
|
||||
struct atppc_isa_softc * sc = (struct atppc_isa_softc *) dev;
|
||||
|
||||
return atppc_isadma_free(sc->sc_ic, sc->sc_drq, buf, bus_addr, size);
|
||||
}
|
||||
|
|
|
@ -1,232 +0,0 @@
|
|||
/* $NetBSD: atppc_isa_subr.c,v 1.3 2004/01/25 00:28:01 bjh21 Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 Alcove - Nicolas Souchu
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* FreeBSD: src/sys/isa/ppc.c,v 1.26.2.5 2001/10/02 05:21:45 nsouch Exp
|
||||
*
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: atppc_isa_subr.c,v 1.3 2004/01/25 00:28:01 bjh21 Exp $");
|
||||
|
||||
#include "opt_atppc.h"
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/device.h>
|
||||
|
||||
#include <machine/intr.h>
|
||||
#include <machine/bus.h>
|
||||
|
||||
#include <dev/ic/atppcreg.h>
|
||||
#include <dev/ic/atppcvar.h>
|
||||
|
||||
#include <dev/isa/atppc_isa_subr.h>
|
||||
#include <dev/isa/isadmavar.h>
|
||||
#include <dev/isa/isareg.h>
|
||||
#include <dev/isa/isavar.h>
|
||||
|
||||
|
||||
/* Initialize interrupt handler. */
|
||||
int
|
||||
atppc_isa_intr_establish(struct atppc_softc * lsc)
|
||||
{
|
||||
struct device * dev = (struct device *) lsc;
|
||||
struct atppc_isa_softc * sc = (struct atppc_isa_softc *) lsc;
|
||||
|
||||
/*
|
||||
* Make sure a handler has not already been established (use
|
||||
* atppc_isa_intr_disestablish() before calling this in that case).
|
||||
*/
|
||||
if(lsc->sc_ieh != NULL) {
|
||||
panic("%s: attempt to establish interrupt handler when"
|
||||
" another handler has already been established.\n",
|
||||
dev->dv_xname);
|
||||
}
|
||||
|
||||
/* Assign interrupt handler */
|
||||
lsc->sc_ieh = isa_intr_establish(sc->sc_ic, sc->sc_irq, IST_EDGE,
|
||||
IPL_ATPPC, atppcintr, dev);
|
||||
|
||||
if(lsc->sc_ieh == NULL) {
|
||||
ATPPC_DPRINTF(("%s: establishment of interrupt handler "
|
||||
"failed.\n", dev->dv_xname));
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Disestablish the interrupt handler: panics if no handler exists. */
|
||||
void
|
||||
atppc_isa_intr_disestablish(struct atppc_softc * lsc)
|
||||
{
|
||||
struct device * dev = (struct device *) lsc;
|
||||
struct atppc_isa_softc * sc = (struct atppc_isa_softc *) lsc;
|
||||
|
||||
/* If a handler exists, disestablish it */
|
||||
if(lsc->sc_ieh != NULL) {
|
||||
isa_intr_disestablish(sc->sc_ic, lsc->sc_ieh);
|
||||
lsc->sc_ieh = NULL;
|
||||
}
|
||||
else {
|
||||
panic("%s: attempt to disestablish interrupt handler when"
|
||||
" no handler has been established.\n", dev->dv_xname);
|
||||
}
|
||||
}
|
||||
|
||||
/* Enable DMA */
|
||||
int
|
||||
atppc_isa_dma_setup(struct atppc_softc * lsc)
|
||||
{
|
||||
struct atppc_isa_softc * sc = (struct atppc_isa_softc *) lsc;
|
||||
#ifdef ATPPC_DEBUG
|
||||
struct device * dev = (struct device *) lsc;
|
||||
#endif
|
||||
int error = 1;
|
||||
|
||||
/* Reserve DRQ */
|
||||
if(isa_drq_alloc(sc->sc_ic, sc->sc_drq)) {
|
||||
ATPPC_DPRINTF(("%s(%s): cannot reserve DRQ line.\n", __func__,
|
||||
dev->dv_xname));
|
||||
return error;
|
||||
}
|
||||
|
||||
/* Get maximum DMA size for isa bus */
|
||||
lsc->sc_dma_maxsize = isa_dmamaxsize(sc->sc_ic, sc->sc_drq);
|
||||
|
||||
/* Create dma mapping */
|
||||
error = isa_dmamap_create(sc->sc_ic, sc->sc_drq, lsc->sc_dma_maxsize,
|
||||
BUS_DMA_NOWAIT|BUS_DMA_ALLOCNOW);
|
||||
|
||||
if(!error) {
|
||||
lsc->sc_dma_start = atppc_isa_dma_start;
|
||||
lsc->sc_dma_finish = atppc_isa_dma_finish;
|
||||
lsc->sc_dma_abort = atppc_isa_dma_abort;
|
||||
lsc->sc_dma_malloc = atppc_isa_dma_malloc;
|
||||
lsc->sc_dma_free = atppc_isa_dma_free;
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
/* Disable DMA: if no DMA mapping exists, does nothing. */
|
||||
int
|
||||
atppc_isa_dma_remove(struct atppc_softc * lsc)
|
||||
{
|
||||
struct atppc_isa_softc * sc = (struct atppc_isa_softc *) lsc;
|
||||
#ifdef ATPPC_DEBUG
|
||||
struct device * dev = (struct device *) lsc;
|
||||
#endif
|
||||
|
||||
if(sc->sc_drq != ISACF_DRQ_DEFAULT &&
|
||||
lsc->sc_has & ATPPC_HAS_DMA) {
|
||||
|
||||
/* Free DRQ for use */
|
||||
if(isa_drq_free(sc->sc_ic, sc->sc_drq)) {
|
||||
ATPPC_DPRINTF(("%s(%s): could not free DRQ line.\n",
|
||||
__func__, dev->dv_xname));
|
||||
}
|
||||
|
||||
/* Remove DMA mapping */
|
||||
isa_dmamap_destroy(sc->sc_ic, sc->sc_drq);
|
||||
}
|
||||
else {
|
||||
ATPPC_DPRINTF(("%s: attempt to remove non-existent DMA "
|
||||
"mapping.\n", dev->dv_xname));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Start DMA operation over ISA bus */
|
||||
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;
|
||||
|
||||
return (isa_dmastart(sc->sc_ic, sc->sc_drq, buf, nbytes, NULL,
|
||||
((mode == ATPPC_DMA_MODE_WRITE) ? DMAMODE_WRITE :
|
||||
DMAMODE_READ) | DMAMODE_DEMAND, ((mode == ATPPC_DMA_MODE_WRITE)
|
||||
? BUS_DMA_WRITE : BUS_DMA_READ) | BUS_DMA_NOWAIT));
|
||||
}
|
||||
|
||||
/* Stop DMA operation over ISA bus */
|
||||
int
|
||||
atppc_isa_dma_finish(struct atppc_softc * lsc)
|
||||
{
|
||||
struct atppc_isa_softc * sc = (struct atppc_isa_softc *) lsc;
|
||||
|
||||
isa_dmadone(sc->sc_ic, sc->sc_drq);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Abort DMA operation over ISA bus */
|
||||
int
|
||||
atppc_isa_dma_abort(struct atppc_softc * lsc)
|
||||
{
|
||||
struct atppc_isa_softc * sc = (struct atppc_isa_softc *) lsc;
|
||||
|
||||
isa_dmaabort(sc->sc_ic, sc->sc_drq);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Allocate memory for DMA over ISA bus */
|
||||
int
|
||||
atppc_isa_dma_malloc(struct device * dev, caddr_t * buf, bus_addr_t * bus_addr,
|
||||
bus_size_t size)
|
||||
{
|
||||
int error;
|
||||
struct atppc_isa_softc * sc = (struct atppc_isa_softc *) dev;
|
||||
|
||||
error = isa_dmamem_alloc(sc->sc_ic, sc->sc_drq, size, bus_addr,
|
||||
BUS_DMA_WAITOK);
|
||||
if(error)
|
||||
return error;
|
||||
|
||||
error = isa_dmamem_map(sc->sc_ic, sc->sc_drq, *bus_addr, size, buf,
|
||||
BUS_DMA_WAITOK);
|
||||
if(error) {
|
||||
isa_dmamem_free(sc->sc_ic, sc->sc_drq, *bus_addr, size);
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
/* Free memory allocated by atppc_isa_dma_malloc() */
|
||||
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;
|
||||
|
||||
isa_dmamem_unmap(sc->sc_ic, sc->sc_drq, *buf, size);
|
||||
isa_dmamem_free(sc->sc_ic, sc->sc_drq, *bus_addr, size);
|
||||
}
|
||||
|
|
@ -1,73 +0,0 @@
|
|||
/* $NetBSD: atppc_isa_subr.h,v 1.3 2004/01/25 00:28:01 bjh21 Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 Alcove - Nicolas Souchu
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* FreeBSD: src/sys/isa/ppc.c,v 1.26.2.5 2001/10/02 05:21:45 nsouch Exp
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __ATPPC_ISA_SUBR_H
|
||||
#define __ATPPC_ISA_SUBR_H
|
||||
|
||||
#include <dev/ic/atppcvar.h>
|
||||
#include <dev/isa/isavar.h>
|
||||
|
||||
|
||||
/* Configuration data for atppc on isa bus. */
|
||||
struct atppc_isa_softc {
|
||||
/* Machine independent device data */
|
||||
struct atppc_softc sc_atppc;
|
||||
|
||||
/* IRQ/DRQ/IO Port assignments on ISA bus */
|
||||
int sc_irq;
|
||||
int sc_drq;
|
||||
int sc_iobase;
|
||||
|
||||
/* ISA chipset tag */
|
||||
isa_chipset_tag_t sc_ic;
|
||||
};
|
||||
|
||||
#ifdef _KERNEL
|
||||
|
||||
/* Interrupt setup/teardown functions */
|
||||
int atppc_isa_intr_establish(struct atppc_softc *);
|
||||
void atppc_isa_intr_disestablish(struct atppc_softc *);
|
||||
|
||||
/* DMA setup functions */
|
||||
int atppc_isa_dma_setup(struct atppc_softc *);
|
||||
int atppc_isa_dma_remove(struct atppc_softc *);
|
||||
int atppc_isa_dma_start(struct atppc_softc *, void *, u_int,
|
||||
u_int8_t);
|
||||
int atppc_isa_dma_finish(struct atppc_softc *);
|
||||
int atppc_isa_dma_abort(struct atppc_softc *);
|
||||
int atppc_isa_dma_malloc(struct device *, caddr_t *, bus_addr_t *,
|
||||
bus_size_t);
|
||||
void atppc_isa_dma_free(struct device *, caddr_t *, bus_addr_t *,
|
||||
bus_size_t);
|
||||
|
||||
#endif /* _KERNEL */
|
||||
|
||||
#endif /* __ATPPC_ISA_SUBR_H */
|
|
@ -0,0 +1,128 @@
|
|||
/* $NetBSD: atppc_isadma.c,v 1.1 2004/01/25 11:35:46 jdolecek Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 Alcove - Nicolas Souchu
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* FreeBSD: src/sys/isa/ppc.c,v 1.26.2.5 2001/10/02 05:21:45 nsouch Exp
|
||||
*
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: atppc_isadma.c,v 1.1 2004/01/25 11:35:46 jdolecek Exp $");
|
||||
|
||||
#include "opt_atppc.h"
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/device.h>
|
||||
|
||||
#include <machine/intr.h>
|
||||
#include <machine/bus.h>
|
||||
|
||||
#include <dev/ic/atppcreg.h>
|
||||
#include <dev/ic/atppcvar.h>
|
||||
|
||||
#include <dev/isa/isadmavar.h>
|
||||
#include <dev/isa/isareg.h>
|
||||
#include <dev/isa/isavar.h>
|
||||
|
||||
#include <dev/isa/atppc_isadma.h>
|
||||
|
||||
/* Enable DMA */
|
||||
int
|
||||
atppc_isadma_setup(struct atppc_softc * lsc, isa_chipset_tag_t ic, int drq)
|
||||
{
|
||||
int error = 1;
|
||||
|
||||
/* Reserve DRQ */
|
||||
if (isa_drq_alloc(ic, drq)) {
|
||||
ATPPC_DPRINTF(("%s(%s): cannot reserve DRQ line.\n", __func__,
|
||||
lsc->sc_dev.dv_xname));
|
||||
return error;
|
||||
}
|
||||
|
||||
/* Get maximum DMA size for isa bus */
|
||||
lsc->sc_dma_maxsize = isa_dmamaxsize(ic, drq);
|
||||
|
||||
/* Create dma mapping */
|
||||
error = isa_dmamap_create(ic, drq, lsc->sc_dma_maxsize,
|
||||
BUS_DMA_NOWAIT|BUS_DMA_ALLOCNOW);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
/* Start DMA operation over ISA bus */
|
||||
int
|
||||
atppc_isadma_start(isa_chipset_tag_t ic, int drq, void * buf, u_int nbytes,
|
||||
u_int8_t mode)
|
||||
{
|
||||
return (isa_dmastart(ic, drq, buf, nbytes, NULL,
|
||||
((mode == ATPPC_DMA_MODE_WRITE) ? DMAMODE_WRITE :
|
||||
DMAMODE_READ) | DMAMODE_DEMAND, ((mode == ATPPC_DMA_MODE_WRITE)
|
||||
? BUS_DMA_WRITE : BUS_DMA_READ) | BUS_DMA_NOWAIT));
|
||||
}
|
||||
|
||||
/* Stop DMA operation over ISA bus */
|
||||
int
|
||||
atppc_isadma_finish(isa_chipset_tag_t ic, int drq)
|
||||
{
|
||||
isa_dmadone(ic, drq);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Abort DMA operation over ISA bus */
|
||||
int
|
||||
atppc_isadma_abort(isa_chipset_tag_t ic, int drq)
|
||||
{
|
||||
isa_dmaabort(ic, drq);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Allocate memory for DMA over ISA bus */
|
||||
int
|
||||
atppc_isadma_malloc(isa_chipset_tag_t ic, int drq, caddr_t *buf, bus_addr_t *bus_addr, bus_size_t size)
|
||||
{
|
||||
int error;
|
||||
|
||||
error = isa_dmamem_alloc(ic, drq, size, bus_addr, BUS_DMA_WAITOK);
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
error = isa_dmamem_map(ic, drq, *bus_addr, size, buf, BUS_DMA_WAITOK);
|
||||
if (error)
|
||||
isa_dmamem_free(ic, drq, *bus_addr, size);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
/* Free memory allocated by atppc_isadma_malloc() */
|
||||
void
|
||||
atppc_isadma_free(isa_chipset_tag_t ic, int drq, caddr_t * buf, bus_addr_t * bus_addr, bus_size_t size)
|
||||
{
|
||||
isa_dmamem_unmap(ic, drq, *buf, size);
|
||||
isa_dmamem_free(ic, drq, *bus_addr, size);
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
/* $NetBSD: atppc_isadma.h,v 1.1 2004/01/25 11:35:46 jdolecek Exp $ */
|
||||
|
||||
/* atppc ISA DMA functions */
|
||||
int atppc_isadma_setup(struct atppc_softc *, isa_chipset_tag_t, int);
|
||||
int atppc_isadma_start(isa_chipset_tag_t, int, void *, u_int,
|
||||
u_int8_t);
|
||||
int atppc_isadma_finish(isa_chipset_tag_t, int);
|
||||
int atppc_isadma_abort(isa_chipset_tag_t, int);
|
||||
int atppc_isadma_malloc(isa_chipset_tag_t, int, caddr_t *, bus_addr_t *,
|
||||
bus_size_t);
|
||||
void atppc_isadma_free(isa_chipset_tag_t, int, caddr_t *, bus_addr_t *,
|
||||
bus_size_t);
|
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: files.isa,v 1.130 2004/01/20 19:58:01 jdolecek Exp $
|
||||
# $NetBSD: files.isa,v 1.131 2004/01/25 11:35:46 jdolecek Exp $
|
||||
#
|
||||
# Config file and device description for machine-independent ISA code.
|
||||
# Included by ports that need it. Requires that the SCSI files be
|
||||
|
@ -81,7 +81,7 @@ file dev/isa/lpt_isa.c lpt_isa & !ppbus
|
|||
# Parallel port chipset
|
||||
attach atppc at isa with atppc_isa
|
||||
file dev/isa/atppc_isa.c atppc_isa
|
||||
file dev/isa/atppc_isa_subr.c atppc_isa
|
||||
file dev/isa/atppc_isadma.c atppc_isa | atppc_acpi | atppc_pnpbios
|
||||
|
||||
#
|
||||
# SCSI host adapters
|
||||
|
|
Loading…
Reference in New Issue