ioblix_zbus.c revision 1.4 1 /* $NetBSD: ioblix_zbus.c,v 1.4 2002/01/26 13:40:57 aymeric Exp $ */
2
3 /*-
4 * Copyright (c) 2000 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 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the NetBSD
21 * Foundation, Inc. and its contributors.
22 * 4. Neither the name of The NetBSD Foundation nor the names of its
23 * contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
37 */
38
39 /* IOBlix Zorro driver */
40 /* XXX to be done: we need to probe the com clock speed! */
41
42 #include <sys/types.h>
43
44 #include <sys/conf.h>
45 #include <sys/device.h>
46 #include <sys/systm.h>
47 #include <sys/param.h>
48
49 #include <machine/bus.h>
50 #include <machine/conf.h>
51
52 #include <amiga/include/cpu.h>
53
54 #include <amiga/amiga/device.h>
55 #include <amiga/amiga/drcustom.h>
56
57 #include <amiga/dev/supio.h>
58 #include <amiga/dev/zbusvar.h>
59
60
61 struct iobz_softc {
62 struct device sc_dev;
63 struct bus_space_tag sc_bst;
64 };
65
66 int iobzmatch(struct device *, struct cfdata *, void *);
67 void iobzattach(struct device *, struct device *, void *);
68 int iobzprint(void *auxp, const char *);
69
70 struct cfattach iobl_zbus_ca = {
71 sizeof(struct iobz_softc), iobzmatch, iobzattach
72 };
73
74 int
75 iobzmatch(struct device *parent, struct cfdata *cfp, void *auxp)
76 {
77
78 struct zbus_args *zap;
79
80 zap = auxp;
81
82 if (zap->manid != 4711)
83 return (0);
84
85 if (zap->prodid != 1)
86 return (0);
87
88 return (1);
89 }
90
91 struct iobz_devs {
92 char *name;
93 unsigned off;
94 int arg;
95 } iobzdevices[] = {
96 { "com", 0x100, 24000000 }, /* XXX see below */
97 { "com", 0x108, 24000000 },
98 { "com", 0x110, 24000000 },
99 { "com", 0x118, 24000000 },
100 { "lpt", 0x200, 0 },
101 { "lpt", 0x300, 0 },
102 { 0, 0, 0}
103 };
104
105 #ifndef IOBZCLOCK
106 #define IOBZCLOCK 22118400;
107 #endif
108 int iobzclock = IOBZCLOCK; /* patchable! */
109
110 void
111 iobzattach(struct device *parent, struct device *self, void *auxp)
112 {
113 struct iobz_softc *iobzsc;
114 struct iobz_devs *iobzd;
115 struct zbus_args *zap;
116 struct supio_attach_args supa;
117 extern const struct amiga_bus_space_methods amiga_bus_stride_16;
118 volatile u_int8_t *p;
119
120
121 iobzsc = (struct iobz_softc *)self;
122 zap = auxp;
123
124 if (parent)
125 printf("\n");
126
127 iobzsc->sc_bst.base = (u_long)zap->va;
128 iobzsc->sc_bst.absm = &amiga_bus_stride_16;
129
130 supa.supio_iot = &iobzsc->sc_bst;
131 supa.supio_ipl = 6;
132
133 iobzd = iobzdevices;
134
135 while (iobzd->name) {
136 supa.supio_name = iobzd->name;
137 supa.supio_iobase = iobzd->off;
138 supa.supio_arg = iobzclock /* XXX iobzd->arg */;
139 config_found(self, &supa, iobzprint); /* XXX */
140 ++iobzd;
141 }
142
143 p = (volatile u_int8_t *)zap->va + 2;
144 *p = ((*p) & 0x1F) | 0x80;
145 }
146
147 int
148 iobzprint(void *auxp, const char *pnp)
149 {
150 struct supio_attach_args *supa;
151 supa = auxp;
152
153 if (pnp == NULL)
154 return(QUIET);
155
156 printf("%s at %s port 0x%02x",
157 supa->supio_name, pnp, supa->supio_iobase);
158
159 return(UNCONF);
160 }
161