ISA PnP atppc(4) attachment

based loosely on aha ISA PnP attachment
This commit is contained in:
jdolecek 2004-01-28 19:31:07 +00:00
parent bb920938c0
commit 0a4cb8aa12
3 changed files with 205 additions and 2 deletions

View File

@ -0,0 +1,192 @@
/* $NetBSD: atppc_isapnp.c,v 1.1 2004/01/28 19:31:07 jdolecek Exp $ */
/*-
* Copyright (c) 2004 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Jaromir Dolecek.
*
* 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.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: atppc_isapnp.c,v 1.1 2004/01/28 19:31:07 jdolecek Exp $");
#include "opt_atppc.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/errno.h>
#include <sys/ioctl.h>
#include <sys/syslog.h>
#include <sys/device.h>
#include <sys/proc.h>
#include <sys/termios.h>
#include <machine/bus.h>
#include <dev/isa/isavar.h>
#include <dev/isa/isadmavar.h>
#include <dev/isapnp/isapnpreg.h>
#include <dev/isapnp/isapnpvar.h>
#include <dev/isapnp/isapnpdevs.h>
#include <dev/ic/atppcvar.h>
#include <dev/isa/atppc_isadma.h>
static int atppc_isapnp_match(struct device *, struct cfdata *, void *);
static void atppc_isapnp_attach(struct device *, struct device *, void *);
struct atppc_isapnp_softc {
struct atppc_softc sc_atppc;
isa_chipset_tag_t sc_ic;
int sc_drq;
};
CFATTACH_DECL(atppc_isapnp, sizeof(struct atppc_isapnp_softc),
atppc_isapnp_match, atppc_isapnp_attach, NULL, NULL);
static int atppc_isapnp_dma_start(struct atppc_softc *, void *, u_int,
u_int8_t);
static int atppc_isapnp_dma_finish(struct atppc_softc *);
static int atppc_isapnp_dma_abort(struct atppc_softc *);
static int atppc_isapnp_dma_malloc(struct device *, caddr_t *, bus_addr_t *,
bus_size_t);
static void atppc_isapnp_dma_free(struct device *, caddr_t *, bus_addr_t *,
bus_size_t);
/*
* atppc_isapnp_match: autoconf(9) match routine
*/
static int
atppc_isapnp_match(struct device *parent, struct cfdata *match, void *aux)
{
int pri, variant;
pri = isapnp_devmatch(aux, &isapnp_sb_devinfo, &variant);
if (pri && variant > 0)
pri = 0;
return (pri);
}
static void
atppc_isapnp_attach(struct device *parent, struct device *self, void *aux)
{
struct atppc_softc *sc = (struct atppc_softc *) self;
struct atppc_isapnp_softc *asc = (struct atppc_isapnp_softc *)self;
struct isapnp_attach_args *ipa = aux;
sc->sc_dev_ok = ATPPC_NOATTACH;
printf(": AT Parallel Port\n");
if (isapnp_config(ipa->ipa_iot, ipa->ipa_memt, ipa)) {
printf("%s: error in region allocation\n",
sc->sc_dev.dv_xname);
return;
}
/* Attach */
sc->sc_iot = ipa->ipa_iot;
sc->sc_ioh = ipa->ipa_io[0].h;
sc->sc_has = 0;
asc->sc_ic = ipa->ipa_ic;
asc->sc_drq = -1; /* Initialized below */
sc->sc_dev_ok = ATPPC_ATTACHED;
sc->sc_ieh = isa_intr_establish(ipa->ipa_ic, ipa->ipa_irq[0].num,
ipa->ipa_irq[0].type, IPL_TTY, atppcintr, sc);
sc->sc_has |= ATPPC_HAS_INTR;
/* setup DMA hooks */
if (ipa->ipa_ndrq > 0
&& atppc_isadma_setup(sc, asc->sc_ic, ipa->ipa_drq[0].num) == 0) {
asc->sc_drq = ipa->ipa_drq[0].num;
sc->sc_has |= ATPPC_HAS_DMA;
sc->sc_dma_start = atppc_isapnp_dma_start;
sc->sc_dma_finish = atppc_isapnp_dma_finish;
sc->sc_dma_abort = atppc_isapnp_dma_abort;
sc->sc_dma_malloc = atppc_isapnp_dma_malloc;
sc->sc_dma_free = atppc_isapnp_dma_free;
}
/* Run soft configuration attach */
atppc_sc_attach(sc);
}
/* Start DMA operation over ISA bus */
static int
atppc_isapnp_dma_start(struct atppc_softc *lsc, void *buf, u_int nbytes,
u_int8_t mode)
{
struct atppc_isapnp_softc * sc = (struct atppc_isapnp_softc *) lsc;
return atppc_isadma_start(sc->sc_ic, sc->sc_drq, buf, nbytes, mode);
}
/* Stop DMA operation over ISA bus */
static int
atppc_isapnp_dma_finish(struct atppc_softc * lsc)
{
struct atppc_isapnp_softc * sc = (struct atppc_isapnp_softc *) lsc;
return atppc_isadma_finish(sc->sc_ic, sc->sc_drq);
}
/* Abort DMA operation over ISA bus */
int
atppc_isapnp_dma_abort(struct atppc_softc * lsc)
{
struct atppc_isapnp_softc * sc = (struct atppc_isapnp_softc *) lsc;
return atppc_isadma_abort(sc->sc_ic, sc->sc_drq);
}
/* Allocate memory for DMA over ISA bus */
int
atppc_isapnp_dma_malloc(struct device * dev, caddr_t * buf, bus_addr_t * bus_addr,
bus_size_t size)
{
struct atppc_isapnp_softc * sc = (struct atppc_isapnp_softc *) dev;
return atppc_isadma_malloc(sc->sc_ic, sc->sc_drq, buf, bus_addr, size);
}
/* Free memory allocated by atppc_isa_dma_malloc() */
void
atppc_isapnp_dma_free(struct device * dev, caddr_t * buf, bus_addr_t * bus_addr,
bus_size_t size)
{
struct atppc_isapnp_softc * sc = (struct atppc_isapnp_softc *) dev;
return atppc_isadma_free(sc->sc_ic, sc->sc_drq, buf, bus_addr, size);
}

View File

@ -1,4 +1,4 @@
# $NetBSD: files.isapnp,v 1.34 2003/08/14 10:03:03 itojun Exp $
# $NetBSD: files.isapnp,v 1.35 2004/01/28 19:31:07 jdolecek Exp $
#
# Config file and device description for machine-independent ISAPnP code.
# Included by ports that need it.
@ -112,3 +112,7 @@ file dev/isapnp/isic_isapnp_itkix.c isic_isapnp
# Game adapter (joystick)
attach joy at isapnp with joy_isapnp
file dev/isapnp/joy_isapnp.c joy_isapnp
# AT-style Parallel Port
attach atppc at isapnp with atppc_isapnp
file dev/isapnp/atppc_isapnp.c atppc_isapnp

View File

@ -1,4 +1,4 @@
$NetBSD: isapnpdevs,v 1.54 2003/07/08 07:26:04 rh Exp $
$NetBSD: isapnpdevs,v 1.55 2004/01/28 19:31:07 jdolecek Exp $
/*-
* Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc.
@ -42,6 +42,7 @@ $NetBSD: isapnpdevs,v 1.54 2003/07/08 07:26:04 rh Exp $
driver aha Adaptec SCSI
driver aic Adaptec SCSI
driver an Aironet 802.11
driver atppc AT Parallel Port
driver com National Semiconductor Serial
driver cs Cirrus Logic Crystal CS89x0 Ethernet
driver ep 3Com 3CXXX Ethernet
@ -78,6 +79,12 @@ devcompat aic ADP1530 0 (Adaptec AVA-1505A)
*/
devlogic an AOL0001 0 Aironet 4500/4800
/*
* atppc
*/
devlogic atppc PNP0400 0 Generic AT Parallel Port
devlogic atppc PNP0401 0 Generic ECP Prallel Port
/*
* com
*/