Home | History | Annotate | Line # | Download | only in dev
hyper.c revision 1.1
      1 /*	$NetBSD: hyper.c,v 1.1 1997/10/18 23:31:40 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  * zbus HyperCom driver
     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 #include <amiga/dev/zbusvar.h>
     55 
     56 
     57 struct hyper_softc {
     58 	struct device sc_dev;
     59 	struct bus_space_tag sc_bst;
     60 };
     61 
     62 int hypermatch __P((struct device *, struct cfdata *, void *));
     63 void hyperattach __P((struct device *, struct device *, void *));
     64 int hyperprint __P((void *auxp, const char *));
     65 
     66 struct cfattach hyper_ca = {
     67 	sizeof(struct hyper_softc), hypermatch, hyperattach
     68 };
     69 
     70 struct cfdriver hyper_cd = {
     71 	NULL, "hyper", DV_DULL
     72 };
     73 
     74 int
     75 hypermatch(parent, cfp, auxp)
     76 	struct device *parent;
     77 	struct cfdata *cfp;
     78 	void *auxp;
     79 {
     80 
     81 	struct zbus_args *zap;
     82 
     83 	zap = auxp;
     84 
     85 	if (zap->manid != 5001)
     86 		return (0);
     87 
     88 	if (zap->prodid != 2 && zap->prodid != 3)
     89 		return (0);
     90 
     91 	return (1);
     92 }
     93 
     94 struct hyper_devs {
     95 	char *name;
     96 	int off;
     97 	int arg;
     98 };
     99 
    100 struct hyper_devs hyper3devs[] = {
    101 	{ "com", 0x00, 115200 * 16 * 4 },
    102 	{ "com", 0x08, 115200 * 16 * 4 },
    103 	/* not yet { "lpt", 0x40, 0 }, */
    104 	{ 0 }
    105 };
    106 
    107 struct hyper_devs hyper4devs[] = {
    108 	{ "com", 0x00, 115200 * 16 * 4 },
    109 	{ "com", 0x08, 115200 * 16 * 4 },
    110 	{ "com", 0x10, 115200 * 16 * 4 },
    111 	{ "com", 0x18, 115200 * 16 * 4 },
    112 	{ 0 }
    113 };
    114 
    115 void
    116 hyperattach(parent, self, auxp)
    117 	struct device *parent, *self;
    118 	void *auxp;
    119 {
    120 	struct hyper_softc *hprsc;
    121 	struct hyper_devs  *hprsd;
    122 	struct zbus_args *zap;
    123 	struct supio_attach_args supa;
    124 
    125 	hprsc = (struct hyper_softc *)self;
    126 	zap = auxp;
    127 
    128 	if (zap->prodid == 2) {
    129 		if (parent)
    130 			printf(": HyperCom 4\n");
    131 		hprsc->sc_bst.base = (u_long)zap->va + 1;
    132 		hprsc->sc_bst.stride = 2;
    133 		hprsd = hyper4devs;
    134 	} else { /* prodid == 3 */
    135 		if (parent)
    136 			printf(": HyperCom 3\n");
    137 		hprsc->sc_bst.base = (u_long)zap->va + 0;
    138 		hprsc->sc_bst.stride = 2;
    139 		hprsd = hyper3devs;
    140 	}
    141 
    142 	supa.supio_iot = &hprsc->sc_bst;
    143 	supa.supio_ipl = 6;
    144 
    145 	while (hprsd->name) {
    146 		supa.supio_name = hprsd->name;
    147 		supa.supio_iobase = hprsd->off;
    148 		supa.supio_arg = hprsd->arg;
    149 		config_found(self, &supa, hyperprint); /* XXX */
    150 		++hprsd;
    151 	}
    152 }
    153 
    154 int
    155 hyperprint(auxp, pnp)
    156 	void *auxp;
    157 	const char *pnp;
    158 {
    159 	struct supio_attach_args *supa;
    160 	supa = auxp;
    161 
    162 	if (pnp == NULL)
    163 		return(QUIET);
    164 
    165 	printf("%s at %s port 0x%02x",
    166 	    supa->supio_name, pnp, supa->supio_iobase);
    167 
    168 	return(UNCONF);
    169 }
    170