frodo.c revision 1.14.2.2 1 1.14.2.2 skrll /* $NetBSD: frodo.c,v 1.14.2.2 2004/09/03 12:44:30 skrll Exp $ */
2 1.2 thorpej
3 1.2 thorpej /*-
4 1.5 thorpej * Copyright (c) 1997, 1998, 1999 The NetBSD Foundation, Inc.
5 1.2 thorpej * All rights reserved.
6 1.2 thorpej *
7 1.2 thorpej * This code is derived from software contributed to The NetBSD Foundation
8 1.2 thorpej * by Jason R. Thorpe.
9 1.2 thorpej *
10 1.2 thorpej * Redistribution and use in source and binary forms, with or without
11 1.2 thorpej * modification, are permitted provided that the following conditions
12 1.2 thorpej * are met:
13 1.2 thorpej * 1. Redistributions of source code must retain the above copyright
14 1.2 thorpej * notice, this list of conditions and the following disclaimer.
15 1.2 thorpej * 2. Redistributions in binary form must reproduce the above copyright
16 1.2 thorpej * notice, this list of conditions and the following disclaimer in the
17 1.2 thorpej * documentation and/or other materials provided with the distribution.
18 1.2 thorpej * 3. All advertising materials mentioning features or use of this software
19 1.2 thorpej * must display the following acknowledgement:
20 1.2 thorpej * This product includes software developed by the NetBSD
21 1.2 thorpej * Foundation, Inc. and its contributors.
22 1.2 thorpej * 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.2 thorpej * contributors may be used to endorse or promote products derived
24 1.2 thorpej * from this software without specific prior written permission.
25 1.2 thorpej *
26 1.2 thorpej * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 1.2 thorpej * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.2 thorpej * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.2 thorpej * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 1.2 thorpej * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.2 thorpej * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.2 thorpej * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.2 thorpej * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.2 thorpej * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.2 thorpej * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.2 thorpej * POSSIBILITY OF SUCH DAMAGE.
37 1.2 thorpej */
38 1.1 thorpej
39 1.1 thorpej /*
40 1.1 thorpej * Copyright (c) 1997 Michael Smith. All rights reserved.
41 1.1 thorpej *
42 1.1 thorpej * Redistribution and use in source and binary forms, with or without
43 1.1 thorpej * modification, are permitted provided that the following conditions
44 1.1 thorpej * are met:
45 1.1 thorpej * 1. Redistributions of source code must retain the above copyright
46 1.1 thorpej * notice, this list of conditions and the following disclaimer.
47 1.1 thorpej * 2. Redistributions in binary form must reproduce the above copyright
48 1.1 thorpej * notice, this list of conditions and the following disclaimer in the
49 1.1 thorpej * documentation and/or other materials provided with the distribution.
50 1.1 thorpej *
51 1.1 thorpej * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
52 1.1 thorpej * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
53 1.1 thorpej * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
54 1.1 thorpej * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
55 1.1 thorpej * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
56 1.1 thorpej * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
57 1.1 thorpej * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
58 1.1 thorpej * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
59 1.1 thorpej * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
60 1.1 thorpej * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
61 1.1 thorpej * SUCH DAMAGE.
62 1.1 thorpej */
63 1.1 thorpej
64 1.1 thorpej /*
65 1.1 thorpej * Support for the "Frodo" (a.k.a. "Apollo Utility") chip found
66 1.1 thorpej * in HP Apollo 9000/4xx workstations.
67 1.1 thorpej */
68 1.9 gmcgarry
69 1.9 gmcgarry #include <sys/cdefs.h>
70 1.14.2.2 skrll __KERNEL_RCSID(0, "$NetBSD: frodo.c,v 1.14.2.2 2004/09/03 12:44:30 skrll Exp $");
71 1.1 thorpej
72 1.1 thorpej #define _HP300_INTR_H_PRIVATE
73 1.1 thorpej
74 1.1 thorpej #include <sys/param.h>
75 1.1 thorpej #include <sys/systm.h>
76 1.1 thorpej #include <sys/kernel.h>
77 1.1 thorpej #include <sys/syslog.h>
78 1.1 thorpej #include <sys/device.h>
79 1.1 thorpej
80 1.14.2.1 skrll #include <machine/bus.h>
81 1.1 thorpej #include <machine/cpu.h>
82 1.1 thorpej #include <machine/intr.h>
83 1.1 thorpej #include <machine/hp300spu.h>
84 1.1 thorpej
85 1.1 thorpej #include <hp300/dev/intiovar.h>
86 1.1 thorpej
87 1.1 thorpej #include <hp300/dev/frodoreg.h>
88 1.1 thorpej #include <hp300/dev/frodovar.h>
89 1.1 thorpej
90 1.1 thorpej /*
91 1.1 thorpej * Description of a Frodo interrupt handler.
92 1.1 thorpej */
93 1.8 gmcgarry struct frodo_interhand {
94 1.14.2.2 skrll int (*ih_fn)(void *);
95 1.8 gmcgarry void *ih_arg;
96 1.8 gmcgarry int ih_priority;
97 1.1 thorpej };
98 1.1 thorpej
99 1.1 thorpej struct frodo_softc {
100 1.1 thorpej struct device sc_dev; /* generic device glue */
101 1.1 thorpej volatile u_int8_t *sc_regs; /* register base */
102 1.8 gmcgarry struct frodo_interhand sc_intr[FRODO_NINTR]; /* interrupt handlers */
103 1.6 gmcgarry int sc_ipl;
104 1.1 thorpej void *sc_ih; /* out interrupt cookie */
105 1.1 thorpej int sc_refcnt; /* number of interrupt refs */
106 1.14.2.1 skrll struct bus_space_tag sc_tag; /* bus space tag */
107 1.1 thorpej };
108 1.1 thorpej
109 1.14.2.2 skrll static int frodomatch(struct device *, struct cfdata *, void *);
110 1.14.2.2 skrll static void frodoattach(struct device *, struct device *, void *);
111 1.1 thorpej
112 1.14.2.2 skrll static int frodoprint(void *, const char *);
113 1.14.2.2 skrll static int frodosubmatch(struct device *, struct cfdata *, void *);
114 1.1 thorpej
115 1.14.2.2 skrll static int frodointr(void *);
116 1.1 thorpej
117 1.14.2.2 skrll static void frodo_imask(struct frodo_softc *, u_int16_t, u_int16_t);
118 1.1 thorpej
119 1.13 thorpej CFATTACH_DECL(frodo, sizeof(struct frodo_softc),
120 1.13 thorpej frodomatch, frodoattach, NULL, NULL);
121 1.1 thorpej
122 1.14.2.2 skrll static const struct frodo_device frodo_subdevs[] = {
123 1.1 thorpej { "dnkbd", FRODO_APCI_OFFSET(0), FRODO_INTR_APCI0 },
124 1.14.2.1 skrll { "com", FRODO_APCI_OFFSET(1), FRODO_INTR_APCI1 },
125 1.14.2.1 skrll { "com", FRODO_APCI_OFFSET(2), FRODO_INTR_APCI2 },
126 1.14.2.1 skrll { "com", FRODO_APCI_OFFSET(3), FRODO_INTR_APCI3 },
127 1.1 thorpej { NULL, 0, 0 },
128 1.1 thorpej };
129 1.1 thorpej
130 1.14.2.2 skrll static int
131 1.14.2.2 skrll frodomatch(struct device *parent, struct cfdata *match, void *aux)
132 1.1 thorpej {
133 1.1 thorpej struct intio_attach_args *ia = aux;
134 1.1 thorpej static int frodo_matched = 0;
135 1.1 thorpej
136 1.1 thorpej /* only allow one instance */
137 1.1 thorpej if (frodo_matched)
138 1.1 thorpej return (0);
139 1.1 thorpej
140 1.10 gmcgarry if (strcmp(ia->ia_modname, "frodo") != 0)
141 1.1 thorpej return (0);
142 1.1 thorpej
143 1.6 gmcgarry if (badaddr((caddr_t)ia->ia_addr))
144 1.1 thorpej return (0);
145 1.1 thorpej
146 1.1 thorpej frodo_matched = 1;
147 1.1 thorpej return (1);
148 1.1 thorpej }
149 1.1 thorpej
150 1.14.2.2 skrll static void
151 1.14.2.2 skrll frodoattach(struct device *parent, struct device *self, void *aux)
152 1.1 thorpej {
153 1.1 thorpej struct frodo_softc *sc = (struct frodo_softc *)self;
154 1.1 thorpej struct intio_attach_args *ia = aux;
155 1.14.2.1 skrll bus_space_tag_t bst = &sc->sc_tag;
156 1.14.2.2 skrll const struct frodo_device *fd;
157 1.14.2.1 skrll struct frodo_attach_args fa;
158 1.1 thorpej
159 1.6 gmcgarry sc->sc_regs = (volatile u_int8_t *)ia->ia_addr;
160 1.6 gmcgarry sc->sc_ipl = ia->ia_ipl;
161 1.1 thorpej
162 1.1 thorpej if ((FRODO_READ(sc, FRODO_IISR) & FRODO_IISR_SERVICE) == 0)
163 1.1 thorpej printf(": service mode enabled");
164 1.1 thorpej printf("\n");
165 1.1 thorpej
166 1.14.2.1 skrll /* Initialize bus_space_tag_t for frodo */
167 1.14.2.1 skrll frodo_init_bus_space(bst);
168 1.14.2.1 skrll
169 1.1 thorpej /* Clear all of the interrupt handlers. */
170 1.7 gmcgarry memset(sc->sc_intr, 0, sizeof(sc->sc_intr));
171 1.1 thorpej sc->sc_refcnt = 0;
172 1.1 thorpej
173 1.1 thorpej /*
174 1.1 thorpej * Disable all of the interrupt lines; we reenable them
175 1.1 thorpej * as subdevices attach.
176 1.1 thorpej */
177 1.1 thorpej frodo_imask(sc, 0, 0xffff);
178 1.1 thorpej
179 1.1 thorpej /* Clear any pending interrupts. */
180 1.1 thorpej FRODO_WRITE(sc, FRODO_PIC_PU, 0xff);
181 1.1 thorpej FRODO_WRITE(sc, FRODO_PIC_PL, 0xff);
182 1.1 thorpej
183 1.1 thorpej /* Set interrupt polarities. */
184 1.1 thorpej FRODO_WRITE(sc, FRODO_PIO_IPR, 0x10);
185 1.1 thorpej
186 1.1 thorpej /* ...and configure for edge triggering. */
187 1.1 thorpej FRODO_WRITE(sc, FRODO_PIO_IELR, 0xcf);
188 1.1 thorpej
189 1.1 thorpej /*
190 1.1 thorpej * We defer hooking up our interrupt handler until
191 1.1 thorpej * a subdevice hooks up theirs.
192 1.1 thorpej */
193 1.1 thorpej sc->sc_ih = NULL;
194 1.1 thorpej
195 1.1 thorpej /* ... and attach subdevices. */
196 1.14.2.1 skrll for (fd = frodo_subdevs; fd->fd_name != NULL; fd++) {
197 1.5 thorpej /*
198 1.5 thorpej * Skip the first serial port if we're not a 425e;
199 1.5 thorpej * it's mapped to the DCA at select code 9 on all
200 1.5 thorpej * other models.
201 1.5 thorpej */
202 1.14.2.1 skrll if (fd->fd_offset == FRODO_APCI_OFFSET(1) &&
203 1.5 thorpej mmuid != MMUID_425_E)
204 1.5 thorpej continue;
205 1.14.2.1 skrll fa.fa_name = fd->fd_name;
206 1.14.2.1 skrll fa.fa_bst = bst;
207 1.14.2.1 skrll fa.fa_base = FRODO_BASE;
208 1.14.2.1 skrll fa.fa_offset = fd->fd_offset;
209 1.14.2.1 skrll fa.fa_line = fd->fd_line;
210 1.14.2.1 skrll config_found_sm(self, &fa, frodoprint, frodosubmatch);
211 1.5 thorpej }
212 1.1 thorpej }
213 1.1 thorpej
214 1.14.2.2 skrll static int
215 1.14.2.2 skrll frodosubmatch(struct device *parent, struct cfdata *cf, void *aux)
216 1.1 thorpej {
217 1.1 thorpej struct frodo_attach_args *fa = aux;
218 1.1 thorpej
219 1.1 thorpej if (cf->frodocf_offset != FRODO_UNKNOWN_OFFSET &&
220 1.1 thorpej cf->frodocf_offset != fa->fa_offset)
221 1.1 thorpej return (0);
222 1.1 thorpej
223 1.11 thorpej return (config_match(parent, cf, aux));
224 1.1 thorpej }
225 1.1 thorpej
226 1.14.2.2 skrll static int
227 1.14.2.2 skrll frodoprint(void *aux, const char *pnp)
228 1.1 thorpej {
229 1.1 thorpej struct frodo_attach_args *fa = aux;
230 1.1 thorpej
231 1.1 thorpej if (pnp)
232 1.14 thorpej aprint_normal("%s at %s", fa->fa_name, pnp);
233 1.14 thorpej aprint_normal(" offset 0x%x", fa->fa_offset);
234 1.1 thorpej return (UNCONF);
235 1.1 thorpej }
236 1.1 thorpej
237 1.1 thorpej void
238 1.14.2.2 skrll frodo_intr_establish(struct device *frdev, int (*func)(void *), void *arg,
239 1.14.2.2 skrll int line, int priority)
240 1.1 thorpej {
241 1.1 thorpej struct frodo_softc *sc = (struct frodo_softc *)frdev;
242 1.8 gmcgarry struct hp300_intrhand *ih = sc->sc_ih;
243 1.1 thorpej
244 1.1 thorpej if (line < 0 || line >= FRODO_NINTR) {
245 1.1 thorpej printf("%s: bad interrupt line %d\n",
246 1.1 thorpej sc->sc_dev.dv_xname, line);
247 1.1 thorpej goto lose;
248 1.1 thorpej }
249 1.8 gmcgarry if (sc->sc_intr[line].ih_fn != NULL) {
250 1.1 thorpej printf("%s: interrupt line %d already used\n",
251 1.1 thorpej sc->sc_dev.dv_xname, line);
252 1.1 thorpej goto lose;
253 1.1 thorpej }
254 1.1 thorpej
255 1.1 thorpej /* Install the handler. */
256 1.8 gmcgarry sc->sc_intr[line].ih_fn = func;
257 1.8 gmcgarry sc->sc_intr[line].ih_arg = arg;
258 1.8 gmcgarry sc->sc_intr[line].ih_priority = priority;
259 1.1 thorpej
260 1.1 thorpej /*
261 1.1 thorpej * If this is the first one, establish the frodo
262 1.1 thorpej * interrupt handler. If not, reestablish at a
263 1.1 thorpej * higher priority if necessary.
264 1.1 thorpej */
265 1.8 gmcgarry if (ih == NULL || ih->ih_priority < priority) {
266 1.8 gmcgarry if (ih != NULL)
267 1.8 gmcgarry intr_disestablish(ih);
268 1.6 gmcgarry sc->sc_ih = intr_establish(frodointr, sc, sc->sc_ipl, priority);
269 1.1 thorpej }
270 1.1 thorpej
271 1.1 thorpej sc->sc_refcnt++;
272 1.1 thorpej
273 1.1 thorpej /* Enable the interrupt line. */
274 1.1 thorpej frodo_imask(sc, (1 << line), 0);
275 1.1 thorpej return;
276 1.1 thorpej lose:
277 1.1 thorpej panic("frodo_intr_establish");
278 1.1 thorpej }
279 1.1 thorpej
280 1.1 thorpej void
281 1.14.2.2 skrll frodo_intr_disestablish(struct device *frdev, int line)
282 1.1 thorpej {
283 1.1 thorpej struct frodo_softc *sc = (struct frodo_softc *)frdev;
284 1.8 gmcgarry struct hp300_intrhand *ih = sc->sc_ih;
285 1.1 thorpej int newpri;
286 1.1 thorpej
287 1.8 gmcgarry if (sc->sc_intr[line].ih_fn == NULL) {
288 1.1 thorpej printf("%s: no handler for line %d\n",
289 1.1 thorpej sc->sc_dev.dv_xname, line);
290 1.1 thorpej panic("frodo_intr_disestablish");
291 1.1 thorpej }
292 1.1 thorpej
293 1.8 gmcgarry sc->sc_intr[line].ih_fn = NULL;
294 1.1 thorpej frodo_imask(sc, 0, (1 << line));
295 1.1 thorpej
296 1.1 thorpej /* If this was the last, unhook ourselves. */
297 1.1 thorpej if (sc->sc_refcnt-- == 1) {
298 1.8 gmcgarry intr_disestablish(ih);
299 1.1 thorpej return;
300 1.1 thorpej }
301 1.1 thorpej
302 1.1 thorpej /* Lower our priority, if appropriate. */
303 1.1 thorpej for (newpri = 0, line = 0; line < FRODO_NINTR; line++)
304 1.8 gmcgarry if (sc->sc_intr[line].ih_fn != NULL &&
305 1.8 gmcgarry sc->sc_intr[line].ih_priority > newpri)
306 1.8 gmcgarry newpri = sc->sc_intr[line].ih_priority;
307 1.1 thorpej
308 1.8 gmcgarry if (newpri != ih->ih_priority) {
309 1.8 gmcgarry intr_disestablish(ih);
310 1.6 gmcgarry sc->sc_ih = intr_establish(frodointr, sc, sc->sc_ipl, newpri);
311 1.1 thorpej }
312 1.1 thorpej }
313 1.1 thorpej
314 1.14.2.2 skrll static int
315 1.14.2.2 skrll frodointr(void *arg)
316 1.1 thorpej {
317 1.1 thorpej struct frodo_softc *sc = arg;
318 1.8 gmcgarry struct frodo_interhand *fih;
319 1.1 thorpej int line, taken = 0;
320 1.1 thorpej
321 1.1 thorpej /* Any interrupts pending? */
322 1.1 thorpej if (FRODO_GETPEND(sc) == 0)
323 1.1 thorpej return (0);
324 1.1 thorpej
325 1.1 thorpej do {
326 1.1 thorpej /*
327 1.1 thorpej * Get pending interrupt; this also clears it for us.
328 1.1 thorpej */
329 1.1 thorpej line = FRODO_IPEND(sc);
330 1.8 gmcgarry fih = &sc->sc_intr[line];
331 1.8 gmcgarry if (fih->ih_fn == NULL ||
332 1.8 gmcgarry (*fih->ih_fn)(fih->ih_arg) == 0)
333 1.1 thorpej printf("%s: spurious interrupt on line %d\n",
334 1.1 thorpej sc->sc_dev.dv_xname, line);
335 1.1 thorpej if (taken++ > 100)
336 1.1 thorpej panic("frodointr: looping!");
337 1.1 thorpej } while (FRODO_GETPEND(sc) != 0);
338 1.1 thorpej
339 1.1 thorpej return (1);
340 1.1 thorpej }
341 1.1 thorpej
342 1.14.2.2 skrll static void
343 1.14.2.2 skrll frodo_imask(struct frodo_softc *sc, u_int16_t set, u_int16_t clear)
344 1.1 thorpej {
345 1.1 thorpej u_int16_t imask;
346 1.1 thorpej
347 1.1 thorpej imask = FRODO_GETMASK(sc);
348 1.1 thorpej
349 1.1 thorpej imask |= set;
350 1.1 thorpej imask &= ~clear;
351 1.1 thorpej
352 1.1 thorpej FRODO_SETMASK(sc, imask);
353 1.1 thorpej }
354 1.14.2.1 skrll
355 1.14.2.1 skrll /*
356 1.14.2.1 skrll * frodo chip specific bus_space(9) support functions.
357 1.14.2.1 skrll */
358 1.14.2.2 skrll static u_int8_t frodo_bus_space_read_sparse_1(bus_space_tag_t,
359 1.14.2.2 skrll bus_space_handle_t, bus_size_t);
360 1.14.2.2 skrll static void frodo_bus_space_write_sparse_1(bus_space_tag_t,
361 1.14.2.2 skrll bus_space_handle_t, bus_size_t, u_int8_t);
362 1.14.2.2 skrll
363 1.14.2.2 skrll static void frodo_bus_space_read_multi_sparse_1(bus_space_tag_t,
364 1.14.2.2 skrll bus_space_handle_t, bus_size_t, u_int8_t *, bus_size_t);
365 1.14.2.2 skrll static void frodo_bus_space_write_multi_sparse_1(bus_space_tag_t,
366 1.14.2.2 skrll bus_space_handle_t, bus_size_t, const u_int8_t *, bus_size_t);
367 1.14.2.2 skrll
368 1.14.2.2 skrll static void frodo_bus_space_read_region_sparse_1(bus_space_tag_t,
369 1.14.2.2 skrll bus_space_handle_t, bus_size_t, u_int8_t *, bus_size_t);
370 1.14.2.2 skrll static void frodo_bus_space_write_region_sparse_1(bus_space_tag_t,
371 1.14.2.2 skrll bus_space_handle_t, bus_size_t, const u_int8_t *, bus_size_t);
372 1.14.2.1 skrll
373 1.14.2.2 skrll static void frodo_bus_space_set_multi_sparse_1(bus_space_tag_t,
374 1.14.2.2 skrll bus_space_handle_t, bus_size_t, u_int8_t, bus_size_t);
375 1.14.2.1 skrll
376 1.14.2.2 skrll static void frodo_bus_space_set_region_sparse_1(bus_space_tag_t,
377 1.14.2.2 skrll bus_space_handle_t, bus_size_t, u_int8_t, bus_size_t);
378 1.14.2.1 skrll
379 1.14.2.1 skrll /*
380 1.14.2.1 skrll * frodo_init_bus_space():
381 1.14.2.1 skrll * Initialize bus_space functions in bus_space_tag_t
382 1.14.2.1 skrll * for frodo devices which have sparse address space.
383 1.14.2.1 skrll */
384 1.14.2.1 skrll void
385 1.14.2.2 skrll frodo_init_bus_space(bus_space_tag_t bst)
386 1.14.2.1 skrll {
387 1.14.2.1 skrll
388 1.14.2.1 skrll memset(bst, 0, sizeof(struct bus_space_tag));
389 1.14.2.1 skrll bst->bustype = HP300_BUS_SPACE_INTIO;
390 1.14.2.1 skrll
391 1.14.2.1 skrll bst->bsr1 = frodo_bus_space_read_sparse_1;
392 1.14.2.1 skrll bst->bsw1 = frodo_bus_space_write_sparse_1;
393 1.14.2.1 skrll
394 1.14.2.1 skrll bst->bsrm1 = frodo_bus_space_read_multi_sparse_1;
395 1.14.2.1 skrll bst->bswm1 = frodo_bus_space_write_multi_sparse_1;
396 1.14.2.1 skrll
397 1.14.2.1 skrll bst->bsrr1 = frodo_bus_space_read_region_sparse_1;
398 1.14.2.1 skrll bst->bswr1 = frodo_bus_space_write_region_sparse_1;
399 1.14.2.1 skrll
400 1.14.2.1 skrll bst->bssm1 = frodo_bus_space_set_multi_sparse_1;
401 1.14.2.1 skrll
402 1.14.2.1 skrll bst->bssr1 = frodo_bus_space_set_region_sparse_1;
403 1.14.2.1 skrll }
404 1.14.2.1 skrll
405 1.14.2.1 skrll static u_int8_t
406 1.14.2.2 skrll frodo_bus_space_read_sparse_1(bus_space_tag_t bst, bus_space_handle_t bsh,
407 1.14.2.2 skrll bus_size_t offset)
408 1.14.2.1 skrll {
409 1.14.2.1 skrll
410 1.14.2.1 skrll return *(volatile u_int8_t *)(bsh + (offset << 2));
411 1.14.2.1 skrll }
412 1.14.2.1 skrll
413 1.14.2.2 skrll static void
414 1.14.2.2 skrll frodo_bus_space_write_sparse_1(bus_space_tag_t bst, bus_space_handle_t bsh,
415 1.14.2.2 skrll bus_size_t offset, u_int8_t val)
416 1.14.2.1 skrll {
417 1.14.2.1 skrll
418 1.14.2.1 skrll *(volatile u_int8_t *)(bsh + (offset << 2)) = val;
419 1.14.2.1 skrll }
420 1.14.2.1 skrll
421 1.14.2.1 skrll static void
422 1.14.2.2 skrll frodo_bus_space_read_multi_sparse_1(bus_space_tag_t bst, bus_space_handle_t bsh,
423 1.14.2.2 skrll bus_size_t offset, u_int8_t *addr, bus_size_t len)
424 1.14.2.1 skrll {
425 1.14.2.1 skrll
426 1.14.2.1 skrll __asm __volatile (
427 1.14.2.1 skrll " movl %0,%%a0 ;\n"
428 1.14.2.1 skrll " movl %1,%%a1 ;\n"
429 1.14.2.1 skrll " movl %2,%%d0 ;\n"
430 1.14.2.1 skrll "1: movb %%a0@,%%a1@+ ;\n"
431 1.14.2.1 skrll " subql #1,%%d0 ;\n"
432 1.14.2.1 skrll " jne 1b"
433 1.14.2.1 skrll :
434 1.14.2.1 skrll : "r" (bsh + (offset << 2)), "g" (addr), "g" (len)
435 1.14.2.1 skrll : "%a0","%a1","%d0");
436 1.14.2.1 skrll }
437 1.14.2.1 skrll
438 1.14.2.1 skrll static void
439 1.14.2.2 skrll frodo_bus_space_write_multi_sparse_1(bus_space_tag_t bst,
440 1.14.2.2 skrll bus_space_handle_t bsh, bus_size_t offset, const u_int8_t *addr,
441 1.14.2.2 skrll bus_size_t len)
442 1.14.2.1 skrll {
443 1.14.2.1 skrll
444 1.14.2.1 skrll __asm __volatile (
445 1.14.2.1 skrll " movl %0,%%a0 ;\n"
446 1.14.2.1 skrll " movl %1,%%a1 ;\n"
447 1.14.2.1 skrll " movl %2,%%d0 ;\n"
448 1.14.2.1 skrll "1: movb %%a1@+,%%a0@ ;\n"
449 1.14.2.1 skrll " subql #1,%%d0 ;\n"
450 1.14.2.1 skrll " jne 1b"
451 1.14.2.1 skrll :
452 1.14.2.1 skrll : "r" (bsh + (offset << 2)), "g" (addr), "g" (len)
453 1.14.2.1 skrll : "%a0","%a1","%d0");
454 1.14.2.1 skrll }
455 1.14.2.1 skrll
456 1.14.2.1 skrll static void
457 1.14.2.2 skrll frodo_bus_space_read_region_sparse_1(bus_space_tag_t bst,
458 1.14.2.2 skrll bus_space_handle_t bsh, bus_size_t offset, u_int8_t *addr, bus_size_t len)
459 1.14.2.1 skrll {
460 1.14.2.1 skrll __asm __volatile (
461 1.14.2.1 skrll " movl %0,%%a0 ;\n"
462 1.14.2.1 skrll " movl %1,%%a1 ;\n"
463 1.14.2.1 skrll " movl %2,%%d0 ;\n"
464 1.14.2.1 skrll "1: movb %%a0@,%%a1@+ ;\n"
465 1.14.2.1 skrll " addql #4,%%a0 ;\n"
466 1.14.2.1 skrll " subql #1,%%d0 ;\n"
467 1.14.2.1 skrll " jne 1b"
468 1.14.2.1 skrll :
469 1.14.2.1 skrll : "r" (bsh + (offset << 2)), "g" (addr), "g" (len)
470 1.14.2.1 skrll : "%a0","%a1","%d0");
471 1.14.2.1 skrll }
472 1.14.2.1 skrll
473 1.14.2.1 skrll static void
474 1.14.2.2 skrll frodo_bus_space_write_region_sparse_1(bus_space_tag_t bst,
475 1.14.2.2 skrll bus_space_handle_t bsh, bus_size_t offset, const u_int8_t *addr,
476 1.14.2.2 skrll bus_size_t len)
477 1.14.2.1 skrll {
478 1.14.2.1 skrll
479 1.14.2.1 skrll __asm __volatile (
480 1.14.2.1 skrll " movl %0,%%a0 ;\n"
481 1.14.2.1 skrll " movl %1,%%a1 ;\n"
482 1.14.2.1 skrll " movl %2,%%d0 ;\n"
483 1.14.2.1 skrll "1: movb %%a1@+,%%a0@ ;\n"
484 1.14.2.1 skrll " addql #4,%%a0 ;\n"
485 1.14.2.1 skrll " subql #1,%%d0 ;\n"
486 1.14.2.1 skrll " jne 1b"
487 1.14.2.1 skrll :
488 1.14.2.1 skrll : "r" (bsh + (offset << 2)), "g" (addr), "g" (len)
489 1.14.2.1 skrll : "%a0","%a1","%d0");
490 1.14.2.1 skrll }
491 1.14.2.1 skrll
492 1.14.2.1 skrll static void
493 1.14.2.2 skrll frodo_bus_space_set_multi_sparse_1(bus_space_tag_t bst, bus_space_handle_t bsh,
494 1.14.2.2 skrll bus_size_t offset, u_int8_t val, bus_size_t count)
495 1.14.2.1 skrll {
496 1.14.2.1 skrll __asm __volatile (
497 1.14.2.1 skrll " movl %0,%%a0 ;\n"
498 1.14.2.1 skrll " movl %1,%%d1 ;\n"
499 1.14.2.1 skrll " movl %2,%%d0 ;\n"
500 1.14.2.1 skrll "1: movb %%d1,%%a0@ ;\n"
501 1.14.2.1 skrll " subql #1,%%d0 ;\n"
502 1.14.2.1 skrll " jne 1b"
503 1.14.2.1 skrll :
504 1.14.2.1 skrll : "r" (bsh + (offset << 2)), "g" (val), "g" (count)
505 1.14.2.1 skrll : "%a0","%d0","%d1");
506 1.14.2.1 skrll }
507 1.14.2.1 skrll
508 1.14.2.1 skrll static void
509 1.14.2.2 skrll frodo_bus_space_set_region_sparse_1(bus_space_tag_t bst, bus_space_handle_t bsh,
510 1.14.2.2 skrll bus_size_t offset, u_int8_t val, bus_size_t count)
511 1.14.2.1 skrll {
512 1.14.2.1 skrll
513 1.14.2.1 skrll __asm __volatile (
514 1.14.2.1 skrll " movl %0,%%a0 ;\n"
515 1.14.2.1 skrll " movl %1,%%d1 ;\n"
516 1.14.2.1 skrll " movl %2,%%d0 ;\n"
517 1.14.2.1 skrll "1: movb %%d1,%%a0@ ;\n"
518 1.14.2.1 skrll " addql #4,%%a0 ;\n"
519 1.14.2.1 skrll " subql #1,%%d0 ;\n"
520 1.14.2.1 skrll " jne 1b"
521 1.14.2.1 skrll :
522 1.14.2.1 skrll : "r" (bsh + (offset << 2)), "g" (val), "g" (count)
523 1.14.2.1 skrll : "%a0","%d0","%d1");
524 1.14.2.1 skrll }
525