xref: /netbsd-src/sys/arch/amiga/dev/hyper.c (revision 4d5a26ba82d7626676323ce46e41be76b930cd70)
1 /*	$NetBSD: hyper.c,v 1.6 1999/01/10 19:19:57 is Exp $ */
2 
3 /*
4  * Copyright (c) 1997, 1998 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 hyper_prods {
71 	char *name;
72 	unsigned baseoff;
73 } hyperproducts [] = {
74 	{0, 0},			/* 0: not used */
75 	{0, 0},			/* 1: handled by aster driver */
76 	{"4", 1},		/* 2 */
77 	{"Z3", 0},		/* 3 */
78 	{0, 0},			/* 4: not used */
79 	{0, 0},			/* 5: not used */
80 	{"4+", 0x8000},		/* 6 */
81 	{"3+", 0x8000}		/* 7 */
82 };
83 
84 int
85 hypermatch(parent, cfp, auxp)
86 	struct device *parent;
87 	struct cfdata *cfp;
88 	void *auxp;
89 {
90 
91 	struct zbus_args *zap;
92 
93 	zap = auxp;
94 
95 	if (zap->manid != 5001)
96 		return (0);
97 
98 	if (zap->prodid < sizeof(hyperproducts)/sizeof(*hyperproducts) &&
99 	    hyperproducts[zap->prodid].name)
100 
101 		return (1);
102 
103 	return (0);
104 }
105 
106 #define HYPERPROD3	(1<<3)
107 #define HYPERPROD4	(1<<2)
108 #define HYPERPROD4PLUS	(1<<6)
109 #define HYPERPROD3PLUS	(1<<7)
110 
111 struct hyper_devs {
112 	char *name;
113 	unsigned off;
114 	int arg;
115 	u_int32_t productmask;	/* XXX only prodid 0..31 */
116 } hyperdevices[] = {
117 	{ "com", 0x00, 115200 * 16 * 4, HYPERPROD3 | HYPERPROD4 },
118 	{ "com", 0x08, 115200 * 16 * 4, HYPERPROD3 | HYPERPROD4 },
119 	{ "com", 0x10, 115200 * 16 * 4, HYPERPROD4 },
120 	{ "com", 0x18, 115200 * 16 * 4, HYPERPROD4 },
121 	/* not yet { "lpt", 0x40, 0, HYPERPROD3 }, */
122 	{ "com", 0x0400, 115200 * 16 * 4, HYPERPROD3PLUS | HYPERPROD4PLUS },
123 	{ "com", 0x0000, 115200 * 16 * 4, HYPERPROD3PLUS | HYPERPROD4PLUS },
124 	{ "com", 0x0c00, 115200 * 16 * 4, HYPERPROD4PLUS },
125 	{ "com", 0x1000, 115200 * 16 * 4, HYPERPROD4PLUS },
126 #ifdef notyet
127 	{ "lpt", 0x0800, 0, HYPERPROD3PLUS | HYPERPROD4PLUS },
128 	{ "lpt", 0x1400, 0, HYPERPROD4PLUS },
129 #endif
130 };
131 
132 void
133 hyperattach(parent, self, auxp)
134 	struct device *parent, *self;
135 	void *auxp;
136 {
137 	struct hyper_softc *hprsc;
138 	struct hyper_devs  *hprsd;
139 	struct zbus_args *zap;
140 	struct supio_attach_args supa;
141 	struct hyper_prods *hprpp;
142 
143 	hprsc = (struct hyper_softc *)self;
144 	zap = auxp;
145 	hprpp = &hyperproducts[zap->prodid];
146 
147 	if (parent)
148 		printf(": Hypercom %s\n", hprpp->name);
149 
150 	hprsc->sc_bst.base = (u_long)zap->va + hprpp->baseoff;
151 	hprsc->sc_bst.stride = 2;
152 
153 	supa.supio_iot = &hprsc->sc_bst;
154 	supa.supio_ipl = 6;
155 
156 	hprsd = hyperdevices;
157 
158 	while (hprsd->name) {
159 		if (hprsd->productmask & (1 << zap->prodid)) {
160 			supa.supio_name = hprsd->name;
161 			supa.supio_iobase = hprsd->off;
162 			supa.supio_arg = hprsd->arg;
163 			config_found(self, &supa, hyperprint); /* XXX */
164 		}
165 		++hprsd;
166 	}
167 }
168 
169 int
170 hyperprint(auxp, pnp)
171 	void *auxp;
172 	const char *pnp;
173 {
174 	struct supio_attach_args *supa;
175 	supa = auxp;
176 
177 	if (pnp == NULL)
178 		return(QUIET);
179 
180 	printf("%s at %s port 0x%02x",
181 	    supa->supio_name, pnp, supa->supio_iobase);
182 
183 	return(UNCONF);
184 }
185