Home | History | Annotate | Line # | Download | only in dev
drsupio.c revision 1.3
      1 /*	$NetBSD: drsupio.c,v 1.3 1997/09/27 22:44:20 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 struct drsupio_softc {
     56 	struct device sc_dev;
     57 	struct bus_space_tag sc_bst;
     58 };
     59 
     60 int drsupiomatch __P((struct device *, struct cfdata *, void *));
     61 void drsupioattach __P((struct device *, struct device *, void *));
     62 int drsupprint __P((void *auxp, const char *));
     63 void drlptintack __P((void *));
     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", 0x278, (int)drlptintack },
     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 drioct *ioct;
    109 	struct supio_attach_args supa;
    110 
    111 	drsc = (struct drsupio_softc *)self;
    112 	drsd = drsupiodevs;
    113 
    114 	if (parent)
    115 		printf("\n");
    116 
    117 	drsc->sc_bst.base = DRCCADDR + NBPG * DRSUPIOPG + 1;
    118 	drsc->sc_bst.stride = 2;
    119 
    120 	supa.supio_iot = &drsc->sc_bst;
    121 	supa.supio_ipl = 5;
    122 
    123 	while (drsd->name) {
    124 		supa.supio_name = drsd->name;
    125 		supa.supio_iobase = drsd->off;
    126 		supa.supio_arg = drsd->arg;
    127 		config_found(self, &supa, drsupprint); /* XXX */
    128 		++drsd;
    129 	}
    130 
    131 	drlptintack(0);
    132 	ioct = (struct drioct *)(DRCCADDR + NBPG * DRIOCTLPG);
    133 	ioct->io_status2 |= DRSTAT2_PARIRQENA;
    134 }
    135 
    136 void
    137 drlptintack(p)
    138 	void *p;
    139 {
    140 	struct drioct *ioct;
    141 
    142 	(void)p;
    143 	ioct = (struct drioct *)(DRCCADDR + NBPG * DRIOCTLPG);
    144 
    145 	ioct->io_parrst = 0;	/* any value works */
    146 }
    147 
    148 int
    149 drsupprint(auxp, pnp)
    150 	void *auxp;
    151 	const char *pnp;
    152 {
    153 	struct supio_attach_args *supa;
    154 	supa = auxp;
    155 
    156 	if (pnp == NULL)
    157 		return(QUIET);
    158 
    159 	printf("%s at %s port 0x%02x",
    160 	    supa->supio_name, pnp, supa->supio_iobase);
    161 
    162 	return(UNCONF);
    163 }
    164