Home | History | Annotate | Line # | Download | only in dev
drsupio.c revision 1.2
      1 /*	$NetBSD: drsupio.c,v 1.2 1997/09/16 20:34:38 is Exp $ */
      2 
      3 /*
      4  * Copyright (c) 1997 Ignatios Souvatzis
      5  * All rights reserved.
      6  *
      7  * Redistribution and use in source and binary forms, with or without
      8  * modification, are permitted provided that the following conditions
      9  * are met:
     10  * 1. Redistributions of source code must retain the above copyright
     11  *    notice, this list of conditions and the following disclaimer.
     12  * 2. Redistributions in binary form must reproduce the above copyright
     13  *    notice, this list of conditions and the following disclaimer in the
     14  *    documentation and/or other materials provided with the distribution.
     15  * 3. All advertising materials mentioning features or use of this software
     16  *    must display the following acknowledgement:
     17  *      This product includes software developed by Ignatios Souvatzis
     18  *      for the NetBSD Project.
     19  * 4. The name of the author may not be used to endorse or promote products
     20  *    derived from this software without specific prior written permission
     21  *
     22  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     23  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     24  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     25  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     27  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     28  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     29  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     30  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     31  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     32  */
     33 
     34 /*
     35  * DraCo multi-io chip bus space stuff
     36  */
     37 
     38 #include <sys/types.h>
     39 
     40 #include <sys/conf.h>
     41 #include <sys/device.h>
     42 #include <sys/systm.h>
     43 #include <sys/param.h>
     44 
     45 #include <machine/bus.h>
     46 #include <machine/conf.h>
     47 
     48 #include <amiga/include/cpu.h>
     49 
     50 #include <amiga/amiga/device.h>
     51 #include <amiga/amiga/drcustom.h>
     52 
     53 #include <amiga/dev/supio.h>
     54 
     55 
     56 struct drsupio_softc {
     57 	struct device sc_dev;
     58 	struct bus_space_tag sc_bst;
     59 };
     60 
     61 int drsupiomatch __P((struct device *, struct cfdata *, void *));
     62 void drsupioattach __P((struct device *, struct device *, void *));
     63 int drsupprint __P((void *auxp, const char *));
     64 
     65 struct cfattach drsupio_ca = {
     66 	sizeof(struct drsupio_softc), drsupiomatch, drsupioattach
     67 };
     68 
     69 struct cfdriver drsupio_cd = {
     70 	NULL, "drsupio", DV_DULL
     71 };
     72 
     73 int
     74 drsupiomatch(parent, cfp, auxp)
     75 	struct device *parent;
     76 	struct cfdata *cfp;
     77 	void *auxp;
     78 {
     79 
     80 	/* Exactly one of us lives on the DraCo */
     81 
     82 	if (is_draco() && matchname(auxp, "drsupio") && (cfp->cf_unit == 0))
     83 		return 1;
     84 
     85 	return 0;
     86 }
     87 
     88 struct drsupio_devs {
     89 	char *name;
     90 	int off;
     91 	int arg;
     92 } drsupiodevs[] = {
     93 	{ "com", 0x3f8, 115200 * 16 },
     94 	{ "com", 0x2f8, 115200 * 16 },
     95 	{ "lpt", 0x378, 0 },
     96 	{ "fdc", 0x3f0, 0 },
     97 	/* WD port? */
     98 	{ 0 }
     99 };
    100 
    101 void
    102 drsupioattach(parent, self, auxp)
    103 	struct device *parent, *self;
    104 	void *auxp;
    105 {
    106 	struct drsupio_softc *drsc;
    107 	struct drsupio_devs  *drsd;
    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.stride = 2;
    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 
    131 int
    132 drsupprint(auxp, pnp)
    133 	void *auxp;
    134 	const char *pnp;
    135 {
    136 	struct supio_attach_args *supa;
    137 	supa = auxp;
    138 
    139 	if (pnp == NULL)
    140 		return(QUIET);
    141 
    142 	printf("%s at %s port 0x%02x",
    143 	    supa->supio_name, pnp, supa->supio_iobase);
    144 
    145 	return(UNCONF);
    146 }
    147