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