Home | History | Annotate | Line # | Download | only in dev
drsupio.c revision 1.12
      1 /*	$NetBSD: drsupio.c,v 1.12 2002/09/27 20:29:53 thorpej Exp $ */
      2 
      3 /*-
      4  * Copyright (c) 1997 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to The NetBSD Foundation
      8  * by Ignatios Souvatzis.
      9  *
     10  * Redistribution and use in source and binary forms, with or without
     11  * modification, are permitted provided that the following conditions
     12  * are met:
     13  * 1. Redistributions of source code must retain the above copyright
     14  *    notice, this list of conditions and the following disclaimer.
     15  * 2. Redistributions in binary form must reproduce the above copyright
     16  *    notice, this list of conditions and the following disclaimer in the
     17  *    documentation and/or other materials provided with the distribution.
     18  * 3. All advertising materials mentioning features or use of this software
     19  *    must display the following acknowledgement:
     20  *        This product includes software developed by the NetBSD
     21  *        Foundation, Inc. and its contributors.
     22  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23  *    contributors may be used to endorse or promote products derived
     24  *    from this software without specific prior written permission.
     25  *
     26  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36  * POSSIBILITY OF SUCH DAMAGE.
     37  */
     38 
     39 #include <sys/cdefs.h>
     40 __KERNEL_RCSID(0, "$NetBSD: drsupio.c,v 1.12 2002/09/27 20:29:53 thorpej Exp $");
     41 
     42 /*
     43  * DraCo multi-io chip bus space stuff
     44  */
     45 
     46 #include <sys/types.h>
     47 
     48 #include <sys/conf.h>
     49 #include <sys/device.h>
     50 #include <sys/systm.h>
     51 #include <sys/param.h>
     52 
     53 #include <machine/bus.h>
     54 
     55 #include <amiga/include/cpu.h>
     56 
     57 #include <amiga/amiga/device.h>
     58 #include <amiga/amiga/drcustom.h>
     59 
     60 #include <amiga/dev/supio.h>
     61 
     62 struct drsupio_softc {
     63 	struct device sc_dev;
     64 	struct bus_space_tag sc_bst;
     65 };
     66 
     67 int drsupiomatch(struct device *, struct cfdata *, void *);
     68 void drsupioattach(struct device *, struct device *, void *);
     69 int drsupprint(void *auxp, const char *);
     70 void drlptintack(void *);
     71 
     72 const struct cfattach drsupio_ca = {
     73 	sizeof(struct drsupio_softc), drsupiomatch, drsupioattach
     74 };
     75 
     76 int
     77 drsupiomatch(struct device *parent, struct cfdata *cfp, void *auxp)
     78 {
     79 	static int drsupio_matched = 0;
     80 
     81 	/* Exactly one of us lives on the DraCo */
     82 	if (!is_draco() || !matchname(auxp, "drsupio") || drsupio_matched)
     83 		return 0;
     84 
     85 	drsupio_matched = 1;
     86 	return 1;
     87 }
     88 
     89 struct drsupio_devs {
     90 	char *name;
     91 	int off;
     92 	int arg;
     93 } drsupiodevs[] = {
     94 	{ "com", 0x3f8, 115200 * 16 },
     95 	{ "com", 0x2f8, 115200 * 16 },
     96 	{ "lpt", 0x278, (int)drlptintack },
     97 	{ "fdc", 0x3f0, 0 },
     98 	/* WD port? */
     99 	{ 0 }
    100 };
    101 
    102 void
    103 drsupioattach(struct device *parent, struct device *self, void *auxp)
    104 {
    105 	struct drsupio_softc *drsc;
    106 	struct drsupio_devs  *drsd;
    107 	struct drioct *ioct;
    108 	struct supio_attach_args supa;
    109 
    110 	drsc = (struct drsupio_softc *)self;
    111 	drsd = drsupiodevs;
    112 
    113 	if (parent)
    114 		printf("\n");
    115 
    116 	drsc->sc_bst.base = DRCCADDR + NBPG * DRSUPIOPG + 1;
    117 	drsc->sc_bst.absm = &amiga_bus_stride_4;
    118 
    119 	supa.supio_iot = &drsc->sc_bst;
    120 	supa.supio_ipl = 5;
    121 
    122 	while (drsd->name) {
    123 		supa.supio_name = drsd->name;
    124 		supa.supio_iobase = drsd->off;
    125 		supa.supio_arg = drsd->arg;
    126 		config_found(self, &supa, drsupprint); /* XXX */
    127 		++drsd;
    128 	}
    129 
    130 	drlptintack(0);
    131 	ioct = (struct drioct *)(DRCCADDR + NBPG * DRIOCTLPG);
    132 	ioct->io_status2 |= DRSTAT2_PARIRQENA;
    133 }
    134 
    135 void
    136 drlptintack(void *p)
    137 {
    138 	struct drioct *ioct;
    139 
    140 	(void)p;
    141 	ioct = (struct drioct *)(DRCCADDR + NBPG * DRIOCTLPG);
    142 
    143 	ioct->io_parrst = 0;	/* any value works */
    144 }
    145 
    146 int
    147 drsupprint(void *auxp, const char *pnp)
    148 {
    149 	struct supio_attach_args *supa;
    150 	supa = auxp;
    151 
    152 	if (pnp == NULL)
    153 		return(QUIET);
    154 
    155 	printf("%s at %s port 0x%02x",
    156 	    supa->supio_name, pnp, supa->supio_iobase);
    157 
    158 	return(UNCONF);
    159 }
    160