ioblix_zbus.c revision 1.1 1 /*-
2 * Copyright (c) 2000 The NetBSD Foundation, Inc.
3 * All rights reserved.
4 *
5 * This code is derived from software contributed to The NetBSD Foundation
6 * by Ignatios Souvatzis.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by the NetBSD
19 * Foundation, Inc. and its contributors.
20 * 4. Neither the name of The NetBSD Foundation nor the names of its
21 * contributors may be used to endorse or promote products derived
22 * from this software without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
25 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
26 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
27 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
28 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 * POSSIBILITY OF SUCH DAMAGE.
35 */
36
37 /* IOBlix Zorro driver */
38 /* XXX to be done: we need to probe the com clock speed! */
39
40 #include <sys/types.h>
41
42 #include <sys/conf.h>
43 #include <sys/device.h>
44 #include <sys/systm.h>
45 #include <sys/param.h>
46
47 #include <machine/bus.h>
48 #include <machine/conf.h>
49
50 #include <amiga/include/cpu.h>
51
52 #include <amiga/amiga/device.h>
53 #include <amiga/amiga/drcustom.h>
54
55 #include <amiga/dev/supio.h>
56 #include <amiga/dev/zbusvar.h>
57
58
59 struct iobz_softc {
60 struct device sc_dev;
61 struct bus_space_tag sc_bst;
62 };
63
64 int iobzmatch __P((struct device *, struct cfdata *, void *));
65 void iobzattach __P((struct device *, struct device *, void *));
66 int iobzprint __P((void *auxp, const char *));
67
68 struct cfattach iobl_zbus_ca = {
69 sizeof(struct iobz_softc), iobzmatch, iobzattach
70 };
71
72 int
73 iobzmatch(parent, cfp, auxp)
74 struct device *parent;
75 struct cfdata *cfp;
76 void *auxp;
77 {
78
79 struct zbus_args *zap;
80
81 zap = auxp;
82
83 if (zap->manid != 4711)
84 return (0);
85
86 if (zap->prodid != 1)
87 return (0);
88
89 return (1);
90 }
91
92 struct iobz_devs {
93 char *name;
94 unsigned off;
95 int arg;
96 } iobzdevices[] = {
97 { "com", 0x100, 24000000 },
98 { "com", 0x108, 24000000 },
99 { "com", 0x110, 24000000 },
100 { "com", 0x118, 24000000 },
101 { "lpt", 0x200, 0 },
102 { "lpt", 0x300, 0 },
103 { 0, 0, 0}
104 };
105
106
107
108 void
109 iobzattach(parent, self, auxp)
110 struct device *parent, *self;
111 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 = 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(auxp, pnp)
149 void *auxp;
150 const char *pnp;
151 {
152 struct supio_attach_args *supa;
153 supa = auxp;
154
155 if (pnp == NULL)
156 return(QUIET);
157
158 printf("%s at %s port 0x%02x",
159 supa->supio_name, pnp, supa->supio_iobase);
160
161 return(UNCONF);
162 }
163