hyper.c revision 1.21 1 /* $NetBSD: hyper.c,v 1.21 2011/07/19 15:55:27 dyoung Exp $ */
2
3 /*-
4 * Copyright (c) 1997,1998 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Ignatios Souvatzis.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32 #include <sys/cdefs.h>
33 __KERNEL_RCSID(0, "$NetBSD: hyper.c,v 1.21 2011/07/19 15:55:27 dyoung Exp $");
34
35 /*
36 * zbus HyperCom driver
37 */
38
39 #include <sys/types.h>
40
41 #include <sys/device.h>
42 #include <sys/conf.h>
43 #include <sys/systm.h>
44 #include <sys/param.h>
45 #include <sys/bus.h>
46
47 #include <amiga/include/cpu.h>
48
49 #include <amiga/amiga/device.h>
50 #include <amiga/amiga/drcustom.h>
51
52 #include <amiga/dev/supio.h>
53 #include <amiga/dev/zbusvar.h>
54
55
56 struct hyper_softc {
57 struct device sc_dev;
58 struct bus_space_tag sc_bst;
59 };
60
61 int hypermatch(struct device *, struct cfdata *, void *);
62 void hyperattach(struct device *, struct device *, void *);
63 int hyperprint(void *auxp, const char *);
64
65 CFATTACH_DECL(hyper, sizeof(struct hyper_softc),
66 hypermatch, hyperattach, NULL, NULL);
67
68 struct hyper_prods {
69 const char *name;
70 unsigned baseoff;
71 } hyperproducts [] = {
72 {0, 0}, /* 0: not used */
73 {0, 0}, /* 1: handled by aster driver */
74 {"4", 1}, /* 2 */
75 {"Z3", 0}, /* 3 */
76 {0, 0}, /* 4: not used */
77 {0, 0}, /* 5: not used */
78 {"4+", 0x8000}, /* 6 */
79 {"3+", 0x8000} /* 7 */
80 };
81
82 int
83 hypermatch(struct device *parent, struct cfdata *cfp, void *auxp)
84 {
85
86 struct zbus_args *zap;
87
88 zap = auxp;
89
90 if (zap->manid != 5001)
91 return (0);
92
93 if (zap->prodid < sizeof(hyperproducts)/sizeof(*hyperproducts) &&
94 hyperproducts[zap->prodid].name)
95
96 return (1);
97
98 return (0);
99 }
100
101 #define HYPERPROD3 (1<<3)
102 #define HYPERPROD4 (1<<2)
103 #define HYPERPROD4PLUS (1<<6)
104 #define HYPERPROD3PLUS (1<<7)
105
106 struct hyper_devs {
107 const char *name;
108 unsigned off;
109 int arg;
110 u_int32_t productmask; /* XXX only prodid 0..31 */
111 } hyperdevices[] = {
112 { "com", 0x00, 115200 * 16 * 4, HYPERPROD3 | HYPERPROD4 },
113 { "com", 0x08, 115200 * 16 * 4, HYPERPROD3 | HYPERPROD4 },
114 { "com", 0x10, 115200 * 16 * 4, HYPERPROD4 },
115 { "com", 0x18, 115200 * 16 * 4, HYPERPROD4 },
116 /* not yet { "lpt", 0x40, 0, HYPERPROD3 }, */
117 { "com", 0x0400, 115200 * 16 * 4, HYPERPROD3PLUS | HYPERPROD4PLUS },
118 { "com", 0x0000, 115200 * 16 * 4, HYPERPROD3PLUS | HYPERPROD4PLUS },
119 { "com", 0x0c00, 115200 * 16 * 4, HYPERPROD4PLUS },
120 { "com", 0x1000, 115200 * 16 * 4, HYPERPROD4PLUS },
121 { "lpt", 0x0800, 0, HYPERPROD3PLUS | HYPERPROD4PLUS },
122 { "lpt", 0x1400, 0, HYPERPROD4PLUS },
123 };
124
125 void
126 hyperattach(struct device *parent, struct device *self, void *auxp)
127 {
128 struct hyper_softc *hprsc;
129 struct hyper_devs *hprsd;
130 struct zbus_args *zap;
131 struct supio_attach_args supa;
132 struct hyper_prods *hprpp;
133
134 hprsc = (struct hyper_softc *)self;
135 zap = auxp;
136 hprpp = &hyperproducts[zap->prodid];
137
138 if (parent)
139 printf(": Hypercom %s\n", hprpp->name);
140
141 hprsc->sc_bst.base = (u_long)zap->va + hprpp->baseoff;
142 hprsc->sc_bst.absm = &amiga_bus_stride_4;
143
144 supa.supio_iot = &hprsc->sc_bst;
145 supa.supio_ipl = 6;
146
147 hprsd = hyperdevices;
148
149 while (hprsd->name) {
150 if (hprsd->productmask & (1 << zap->prodid)) {
151 supa.supio_name = hprsd->name;
152 supa.supio_iobase = hprsd->off;
153 supa.supio_arg = hprsd->arg;
154 config_found(self, &supa, hyperprint); /* XXX */
155 }
156 ++hprsd;
157 }
158 }
159
160 int
161 hyperprint(void *auxp, const char *pnp)
162 {
163 struct supio_attach_args *supa;
164 supa = auxp;
165
166 if (pnp == NULL)
167 return(QUIET);
168
169 aprint_normal("%s at %s port 0x%02x",
170 supa->supio_name, pnp, supa->supio_iobase);
171
172 return(UNCONF);
173 }
174