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