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