hyper.c revision 1.3 1 /* $NetBSD: hyper.c,v 1.3 1998/08/09 22:25:18 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 int
71 hypermatch(parent, cfp, auxp)
72 struct device *parent;
73 struct cfdata *cfp;
74 void *auxp;
75 {
76
77 struct zbus_args *zap;
78
79 zap = auxp;
80
81 if (zap->manid != 5001)
82 return (0);
83
84 if (zap->prodid != 2 && zap->prodid != 3)
85 return (0);
86
87 return (1);
88 }
89
90 struct hyper_devs {
91 char *name;
92 int off;
93 int arg;
94 };
95
96 struct hyper_devs hyper3devs[] = {
97 { "com", 0x00, 115200 * 16 * 4 },
98 { "com", 0x08, 115200 * 16 * 4 },
99 /* not yet { "lpt", 0x40, 0 }, */
100 { 0 }
101 };
102
103 struct hyper_devs hyper4devs[] = {
104 { "com", 0x00, 115200 * 16 * 4 },
105 { "com", 0x08, 115200 * 16 * 4 },
106 { "com", 0x10, 115200 * 16 * 4 },
107 { "com", 0x18, 115200 * 16 * 4 },
108 { 0 }
109 };
110
111 void
112 hyperattach(parent, self, auxp)
113 struct device *parent, *self;
114 void *auxp;
115 {
116 struct hyper_softc *hprsc;
117 struct hyper_devs *hprsd;
118 struct zbus_args *zap;
119 struct supio_attach_args supa;
120
121 hprsc = (struct hyper_softc *)self;
122 zap = auxp;
123
124 if (zap->prodid == 2) {
125 if (parent)
126 printf(": HyperCom 4\n");
127 hprsc->sc_bst.base = (u_long)zap->va + 1;
128 hprsc->sc_bst.stride = 2;
129 hprsd = hyper4devs;
130 } else { /* prodid == 3 */
131 if (parent)
132 printf(": HyperCom 3Z\n");
133 hprsc->sc_bst.base = (u_long)zap->va + 0;
134 hprsc->sc_bst.stride = 2;
135 hprsd = hyper3devs;
136 }
137
138 supa.supio_iot = &hprsc->sc_bst;
139 supa.supio_ipl = 6;
140
141 while (hprsd->name) {
142 supa.supio_name = hprsd->name;
143 supa.supio_iobase = hprsd->off;
144 supa.supio_arg = hprsd->arg;
145 config_found(self, &supa, hyperprint); /* XXX */
146 ++hprsd;
147 }
148 }
149
150 int
151 hyperprint(auxp, pnp)
152 void *auxp;
153 const char *pnp;
154 {
155 struct supio_attach_args *supa;
156 supa = auxp;
157
158 if (pnp == NULL)
159 return(QUIET);
160
161 printf("%s at %s port 0x%02x",
162 supa->supio_name, pnp, supa->supio_iobase);
163
164 return(UNCONF);
165 }
166