rmixl_iobus.c revision 1.3.8.2 1 1.3.8.2 matt /* $NetBSD: rmixl_iobus.c,v 1.3.8.2 2011/12/27 19:58:19 matt Exp $ */
2 1.3.8.2 matt
3 1.3.8.2 matt /*-
4 1.3.8.2 matt * Copyright (c) 2011 The NetBSD Foundation, Inc.
5 1.3.8.2 matt * All rights reserved.
6 1.3.8.2 matt *
7 1.3.8.2 matt * This code is derived from software contributed to The NetBSD Foundation
8 1.3.8.2 matt * by Cliff Neighbors
9 1.3.8.2 matt *
10 1.3.8.2 matt * Redistribution and use in source and binary forms, with or without
11 1.3.8.2 matt * modification, are permitted provided that the following conditions
12 1.3.8.2 matt * are met:
13 1.3.8.2 matt * 1. Redistributions of source code must retain the above copyright
14 1.3.8.2 matt * notice, this list of conditions and the following disclaimer.
15 1.3.8.2 matt * 2. Redistributions in binary form must reproduce the above copyright
16 1.3.8.2 matt * notice, this list of conditions and the following disclaimer in the
17 1.3.8.2 matt * documentation and/or other materials provided with the distribution.
18 1.3.8.2 matt *
19 1.3.8.2 matt * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 1.3.8.2 matt * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 1.3.8.2 matt * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 1.3.8.2 matt * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 1.3.8.2 matt * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 1.3.8.2 matt * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 1.3.8.2 matt * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 1.3.8.2 matt * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 1.3.8.2 matt * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 1.3.8.2 matt * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 1.3.8.2 matt * POSSIBILITY OF SUCH DAMAGE.
30 1.3.8.2 matt */
31 1.3.8.2 matt
32 1.3.8.2 matt /*
33 1.3.8.2 matt * RMI Peripherals IO Bus support
34 1.3.8.2 matt * - interface to NOR, NAND, PCMCIA Memory controlers, &etc.
35 1.3.8.2 matt * - manages the 10 Chip Selects
36 1.3.8.2 matt * - manages the "Flash" interrupts
37 1.3.8.2 matt * - manages the "Flash" errors
38 1.3.8.2 matt */
39 1.3.8.2 matt
40 1.3.8.2 matt /*
41 1.3.8.2 matt * iobus control registers are accessed as 32 bits.
42 1.3.8.2 matt * ALEn and CLEn NAND control registers are defined as 8 bits wide
43 1.3.8.2 matt * but that seems to be a documentation error.
44 1.3.8.2 matt *
45 1.3.8.2 matt * iobus data access may be as 1 or 2 or 4 bytes, even if device is 1 byte wide;
46 1.3.8.2 matt * the controller will sequence the bytes, in big-endian order.
47 1.3.8.2 matt */
48 1.3.8.2 matt
49 1.3.8.2 matt #include <sys/cdefs.h>
50 1.3.8.2 matt __KERNEL_RCSID(0, "$NetBSD: rmixl_iobus.c,v 1.3.8.2 2011/12/27 19:58:19 matt Exp $");
51 1.3.8.2 matt
52 1.3.8.2 matt #include "locators.h"
53 1.3.8.2 matt
54 1.3.8.2 matt #include <sys/param.h>
55 1.3.8.2 matt #include <sys/systm.h>
56 1.3.8.2 matt #include <sys/device.h>
57 1.3.8.2 matt
58 1.3.8.2 matt #include <sys/bus.h>
59 1.3.8.2 matt
60 1.3.8.2 matt #include <mips/rmi/rmixlreg.h>
61 1.3.8.2 matt #include <mips/rmi/rmixlvar.h>
62 1.3.8.2 matt #include <mips/rmi/rmixl_intr.h>
63 1.3.8.2 matt #include <mips/rmi/rmixl_obiovar.h>
64 1.3.8.2 matt #include <mips/rmi/rmixl_iobusvar.h>
65 1.3.8.2 matt // #include <mips/rmi/rmixl_gpiovar.h>
66 1.3.8.2 matt
67 1.3.8.2 matt typedef struct {
68 1.3.8.2 matt bool cs_allocated;
69 1.3.8.2 matt uint32_t cs_addr; /* base address on the Peripherals I/O Bus */
70 1.3.8.2 matt uint32_t cs_mask; /* address mask on the Peripherals I/O Bus */
71 1.3.8.2 matt uint32_t cs_dev_parm;
72 1.3.8.2 matt } rmixl_iobus_csconfig_t;
73 1.3.8.2 matt
74 1.3.8.2 matt typedef struct rmixl_iobus_softc {
75 1.3.8.2 matt device_t sc_dev;
76 1.3.8.2 matt bus_space_tag_t sc_obio_bst; /* for iobus device controler access */
77 1.3.8.2 matt bus_space_handle_t sc_obio_bsh; /* " " " " " */
78 1.3.8.2 matt bus_addr_t sc_obio_addr;
79 1.3.8.2 matt bus_size_t sc_obio_size;
80 1.3.8.2 matt bus_space_tag_t sc_iobus_bst; /* for iobus access */
81 1.3.8.2 matt rmixl_iobus_csconfig_t sc_csconfig[RMIXL_FLASH_NCS];
82 1.3.8.2 matt } rmixl_iobus_softc_t;
83 1.3.8.2 matt
84 1.3.8.2 matt
85 1.3.8.2 matt static int rmixl_iobus_obio_match(device_t, cfdata_t, void *);
86 1.3.8.2 matt static void rmixl_iobus_obio_attach(device_t, device_t, void *);
87 1.3.8.2 matt static void rmixl_iobus_csconfig_init(struct rmixl_iobus_softc *);
88 1.3.8.2 matt static int rmixl_iobus_print(void *, const char *);
89 1.3.8.2 matt static int rmixl_iobus_search(device_t, cfdata_t, const int *, void *);
90 1.3.8.2 matt #ifdef NOTYET
91 1.3.8.2 matt static int rmixl_iobus_intr(void *);
92 1.3.8.2 matt #endif
93 1.3.8.2 matt
94 1.3.8.2 matt #ifdef RMIXL_IOBUS_DEBUG
95 1.3.8.2 matt rmixl_iobus_softc_t *rmixl_iobus_sc;
96 1.3.8.2 matt #endif
97 1.3.8.2 matt
98 1.3.8.2 matt
99 1.3.8.2 matt CFATTACH_DECL_NEW(xliobus_obio, sizeof (rmixl_iobus_softc_t),
100 1.3.8.2 matt rmixl_iobus_obio_match, rmixl_iobus_obio_attach, NULL, NULL);
101 1.3.8.2 matt
102 1.3.8.2 matt int
103 1.3.8.2 matt rmixl_iobus_obio_match(device_t parent, cfdata_t match, void *aux)
104 1.3.8.2 matt {
105 1.3.8.2 matt struct obio_attach_args *obio = aux;
106 1.3.8.2 matt
107 1.3.8.2 matt if (obio->obio_addr == RMIXL_IO_DEV_FLASH)
108 1.3.8.2 matt return rmixl_probe_4((volatile uint32_t *)
109 1.3.8.2 matt RMIXL_IOREG_VADDR(obio->obio_addr));
110 1.3.8.2 matt
111 1.3.8.2 matt return 0;
112 1.3.8.2 matt }
113 1.3.8.2 matt
114 1.3.8.2 matt void
115 1.3.8.2 matt rmixl_iobus_obio_attach(device_t parent, device_t self, void *aux)
116 1.3.8.2 matt {
117 1.3.8.2 matt rmixl_iobus_softc_t *sc = device_private(self);
118 1.3.8.2 matt struct obio_attach_args *obio = aux;
119 1.3.8.2 matt struct rmixl_config *rcp = &rmixl_configuration;
120 1.3.8.2 matt uint64_t r;
121 1.3.8.2 matt int err;
122 1.3.8.2 matt
123 1.3.8.2 matt #ifdef RMIXL_IOBUS_DEBUG
124 1.3.8.2 matt rmixl_iobus_sc = sc;
125 1.3.8.2 matt #endif
126 1.3.8.2 matt sc->sc_dev = self;
127 1.3.8.2 matt sc->sc_obio_bst = obio->obio_eb_bst;
128 1.3.8.2 matt sc->sc_obio_addr = obio->obio_addr;
129 1.3.8.2 matt sc->sc_obio_size = 0x1000;
130 1.3.8.2 matt
131 1.3.8.2 matt err = bus_space_map(sc->sc_obio_bst, sc->sc_obio_addr,
132 1.3.8.2 matt sc->sc_obio_size, 0, &sc->sc_obio_bsh);
133 1.3.8.2 matt if (err != 0) {
134 1.3.8.2 matt aprint_error_dev(self,
135 1.3.8.2 matt "bus space map err %d, iobus space\n", err);
136 1.3.8.2 matt return;
137 1.3.8.2 matt }
138 1.3.8.2 matt
139 1.3.8.2 matt r = RMIXL_IOREG_READ(RMIXL_SBC_FLASH_BAR);
140 1.3.8.2 matt KASSERT((r & 1) != 0); /* BAR is enabled */
141 1.3.8.2 matt rcp->rc_flash[0].r_pbase = RMIXL_FLASH_BAR_TO_BA(r);
142 1.3.8.2 matt rcp->rc_flash[0].r_size = RMIXL_FLASH_BAR_TO_MASK(r) + 1;
143 1.3.8.2 matt
144 1.3.8.2 matt aprint_normal("\n");
145 1.3.8.2 matt aprint_debug_dev(self,
146 1.3.8.2 matt "Flash BAR pbase %#" PRIx64 " size %#" PRIx64 "\n",
147 1.3.8.2 matt rcp->rc_flash[0].r_pbase, rcp->rc_flash[0].r_size);
148 1.3.8.2 matt
149 1.3.8.2 matt /* initialize iobus bus space */
150 1.3.8.2 matt rmixl_iobus_bus_mem_init(&rcp->rc_iobus_memt, rcp);
151 1.3.8.2 matt sc->sc_iobus_bst = (bus_space_tag_t)&rcp->rc_iobus_memt;
152 1.3.8.2 matt
153 1.3.8.2 matt /* disable all Flsah interupts */
154 1.3.8.2 matt bus_space_write_4(sc->sc_obio_bst, sc->sc_obio_bsh,
155 1.3.8.2 matt RMIXL_FLASH_INT_MASK, 0);
156 1.3.8.2 matt
157 1.3.8.2 matt /* write-1-to-clear Flash interrupt status */
158 1.3.8.2 matt bus_space_write_4(sc->sc_obio_bst, sc->sc_obio_bsh,
159 1.3.8.2 matt RMIXL_FLASH_INT_STATUS, ~0);
160 1.3.8.2 matt
161 1.3.8.2 matt rmixl_iobus_csconfig_init(sc);
162 1.3.8.2 matt
163 1.3.8.2 matt /* attach any children */
164 1.3.8.2 matt config_search_ia(rmixl_iobus_search, self, "rmixl_iobus", NULL);
165 1.3.8.2 matt }
166 1.3.8.2 matt
167 1.3.8.2 matt static void
168 1.3.8.2 matt rmixl_iobus_csconfig_init(struct rmixl_iobus_softc *sc)
169 1.3.8.2 matt {
170 1.3.8.2 matt rmixl_iobus_csconfig_t *cs = &sc->sc_csconfig[0];
171 1.3.8.2 matt
172 1.3.8.2 matt for (int i=0; i < RMIXL_FLASH_NCS; i++) {
173 1.3.8.2 matt memset(cs, 0, sizeof(rmixl_iobus_csconfig_t));
174 1.3.8.2 matt cs->cs_addr = bus_space_read_4(sc->sc_obio_bst, sc->sc_obio_bsh,
175 1.3.8.2 matt RMIXL_FLASH_CSBASE_ADDRn(i)) << 16;
176 1.3.8.2 matt cs->cs_mask = bus_space_read_4(sc->sc_obio_bst, sc->sc_obio_bsh,
177 1.3.8.2 matt RMIXL_FLASH_CSADDR_MASKn(i)) << 16;
178 1.3.8.2 matt cs->cs_mask |= __BITS(15,0);
179 1.3.8.2 matt cs->cs_dev_parm = bus_space_read_4(sc->sc_obio_bst, sc->sc_obio_bsh,
180 1.3.8.2 matt RMIXL_FLASH_CSDEV_PARMn(i));
181 1.3.8.2 matt aprint_debug_dev(sc->sc_dev,
182 1.3.8.2 matt "CS#%d: addr 0x%08x mask 0x%08x parm 0x%08x\n",
183 1.3.8.2 matt i, cs->cs_addr, cs->cs_mask, cs->cs_dev_parm);
184 1.3.8.2 matt cs++;
185 1.3.8.2 matt }
186 1.3.8.2 matt }
187 1.3.8.2 matt
188 1.3.8.2 matt
189 1.3.8.2 matt static int
190 1.3.8.2 matt rmixl_iobus_print(void *aux, const char *pnp)
191 1.3.8.2 matt {
192 1.3.8.2 matt struct rmixl_iobus_attach_args *ia = aux;
193 1.3.8.2 matt
194 1.3.8.2 matt if (ia->ia_cs != XLIOBUSCF_CS_DEFAULT)
195 1.3.8.2 matt aprint_normal(" CS#%d", ia->ia_cs);
196 1.3.8.2 matt if (ia->ia_iobus_addr != XLIOBUSCF_ADDR_DEFAULT) {
197 1.3.8.2 matt aprint_normal(" addr %#" PRIxBUSADDR, ia->ia_iobus_addr);
198 1.3.8.2 matt if (ia->ia_iobus_size != XLIOBUSCF_SIZE_DEFAULT)
199 1.3.8.2 matt aprint_normal("-%#" PRIxBUSSIZE,
200 1.3.8.2 matt ia->ia_iobus_addr + (ia->ia_iobus_size - 1));
201 1.3.8.2 matt }
202 1.3.8.2 matt if (ia->ia_iobus_intr != XLIOBUSCF_INTR_DEFAULT)
203 1.3.8.2 matt aprint_normal(" intr %d", ia->ia_iobus_intr);
204 1.3.8.2 matt
205 1.3.8.2 matt return UNCONF;
206 1.3.8.2 matt }
207 1.3.8.2 matt
208 1.3.8.2 matt static int
209 1.3.8.2 matt rmixl_iobus_search(device_t parent, cfdata_t cf, const int *ldesc, void *aux)
210 1.3.8.2 matt {
211 1.3.8.2 matt struct rmixl_iobus_softc *sc = device_private(parent);
212 1.3.8.2 matt struct rmixl_iobus_attach_args ia;
213 1.3.8.2 matt rmixl_iobus_csconfig_t *cs;
214 1.3.8.2 matt
215 1.3.8.2 matt ia.ia_obio_bst = sc->sc_obio_bst;
216 1.3.8.2 matt ia.ia_obio_bsh = sc->sc_obio_bsh;
217 1.3.8.2 matt ia.ia_iobus_bst = sc->sc_iobus_bst;
218 1.3.8.2 matt ia.ia_iobus_addr = (bus_addr_t)cf->cf_loc[XLIOBUSCF_ADDR];
219 1.3.8.2 matt ia.ia_iobus_size = (bus_size_t)cf->cf_loc[XLIOBUSCF_SIZE];
220 1.3.8.2 matt ia.ia_iobus_intr = cf->cf_loc[XLIOBUSCF_INTR];
221 1.3.8.2 matt ia.ia_cs = cf->cf_loc[XLIOBUSCF_CS];
222 1.3.8.2 matt
223 1.3.8.2 matt if (ia.ia_cs != XLIOBUSCF_CS_DEFAULT) {
224 1.3.8.2 matt /* CS is configured */
225 1.3.8.2 matt cs = &sc->sc_csconfig[ia.ia_cs];
226 1.3.8.2 matt
227 1.3.8.2 matt /* ensure exclusive use of chip select */
228 1.3.8.2 matt if (cs->cs_allocated) {
229 1.3.8.2 matt aprint_error_dev(parent, "CS#%d already allocated\n",
230 1.3.8.2 matt ia.ia_cs);
231 1.3.8.2 matt return 0;
232 1.3.8.2 matt }
233 1.3.8.2 matt if (ia.ia_iobus_addr != XLIOBUSCF_ADDR_DEFAULT) {
234 1.3.8.2 matt if (ia.ia_iobus_addr != cs->cs_addr) {
235 1.3.8.2 matt /*
236 1.3.8.2 matt * both CS and addr are configured,
237 1.3.8.2 matt * ensure they match
238 1.3.8.2 matt */
239 1.3.8.2 matt aprint_error_dev(parent,
240 1.3.8.2 matt "CS#%d addr 0x%08x mismatch cf_loc "
241 1.3.8.2 matt "addr 0x%08" PRIxBUSADDR "\n",
242 1.3.8.2 matt ia.ia_cs, cs->cs_addr, ia.ia_iobus_addr);
243 1.3.8.2 matt return 0;
244 1.3.8.2 matt }
245 1.3.8.2 matt } else {
246 1.3.8.2 matt /* no addr configured, pull from CS */
247 1.3.8.2 matt ia.ia_iobus_addr = cs->cs_addr;
248 1.3.8.2 matt }
249 1.3.8.2 matt } else {
250 1.3.8.2 matt /* addr is configured, CS is not; search for matching CS */
251 1.3.8.2 matt bool found = false;
252 1.3.8.2 matt cs = &sc->sc_csconfig[0];
253 1.3.8.2 matt for (int i=0; i < RMIXL_FLASH_NCS; i++) {
254 1.3.8.2 matt if (cs->cs_allocated)
255 1.3.8.2 matt continue;
256 1.3.8.2 matt if (cs->cs_addr == ia.ia_iobus_addr) {
257 1.3.8.2 matt ia.ia_cs = i;
258 1.3.8.2 matt found = true;
259 1.3.8.2 matt break;
260 1.3.8.2 matt }
261 1.3.8.2 matt cs++;
262 1.3.8.2 matt }
263 1.3.8.2 matt if (! found) {
264 1.3.8.2 matt aprint_error_dev(parent, "no CS for addr 0x%08"
265 1.3.8.2 matt PRIxBUSADDR "\n", ia.ia_iobus_addr);
266 1.3.8.2 matt return 0;
267 1.3.8.2 matt }
268 1.3.8.2 matt }
269 1.3.8.2 matt
270 1.3.8.2 matt if (ia.ia_iobus_size != XLIOBUSCF_SIZE_DEFAULT) {
271 1.3.8.2 matt /* ensure size fits w/ CS mask */
272 1.3.8.2 matt if ((ia.ia_iobus_size - 1) > (bus_size_t)cs->cs_mask) {
273 1.3.8.2 matt aprint_error_dev(parent, "size %#" PRIxBUSSIZE
274 1.3.8.2 matt " exceeds CS#%d mask 0x%08x\n",
275 1.3.8.2 matt ia.ia_iobus_size, ia.ia_cs, cs->cs_mask);
276 1.3.8.2 matt }
277 1.3.8.2 matt } else {
278 1.3.8.2 matt /* size not configured, pull from CS */
279 1.3.8.2 matt ia.ia_iobus_size = (bus_size_t)cs->cs_mask + 1;
280 1.3.8.2 matt }
281 1.3.8.2 matt
282 1.3.8.2 matt ia.ia_dev_parm = cs->cs_dev_parm;
283 1.3.8.2 matt
284 1.3.8.2 matt if (config_match(parent, cf, &ia) > 0) {
285 1.3.8.2 matt cs->cs_allocated = true;
286 1.3.8.2 matt config_attach(parent, cf, &ia, rmixl_iobus_print);
287 1.3.8.2 matt }
288 1.3.8.2 matt
289 1.3.8.2 matt return 0;
290 1.3.8.2 matt }
291 1.3.8.2 matt
292 1.3.8.2 matt
293 1.3.8.2 matt #ifdef NOTYET
294 1.3.8.2 matt
295 1.3.8.2 matt void
296 1.3.8.2 matt rmixl_iobus_intr_disestablish(void *uh, void *ih)
297 1.3.8.2 matt {
298 1.3.8.2 matt rmixl_iobus_softc_t *sc = uh;
299 1.3.8.2 matt u_int intr;
300 1.3.8.2 matt
301 1.3.8.2 matt for (intr=0; intr <= RMIXL_UB_INTERRUPT_MAX; intr++) {
302 1.3.8.2 matt if (ih == &sc->sc_dispatch[intr]) {
303 1.3.8.2 matt uint32_t r;
304 1.3.8.2 matt
305 1.3.8.2 matt /* disable this interrupt in the usb interface */
306 1.3.8.2 matt r = bus_space_read_4(sc->sc_obio_bst, sc->sc_obio_bsh,
307 1.3.8.2 matt RMIXL_USB_INTERRUPT_ENABLE);
308 1.3.8.2 matt r &= 1 << intr;
309 1.3.8.2 matt bus_space_write_4(sc->sc_obio_bst, sc->sc_obio_bsh,
310 1.3.8.2 matt RMIXL_USB_INTERRUPT_ENABLE, r);
311 1.3.8.2 matt
312 1.3.8.2 matt /* free the dispatch slot */
313 1.3.8.2 matt sc->sc_dispatch[intr].func = NULL;
314 1.3.8.2 matt sc->sc_dispatch[intr].arg = NULL;
315 1.3.8.2 matt
316 1.3.8.2 matt break;
317 1.3.8.2 matt }
318 1.3.8.2 matt }
319 1.3.8.2 matt }
320 1.3.8.2 matt
321 1.3.8.2 matt void *
322 1.3.8.2 matt rmixl_iobus_intr_establish(void *uh, u_int intr, int (func)(void *), void *arg)
323 1.3.8.2 matt {
324 1.3.8.2 matt rmixl_iobus_softc_t *sc = uh;
325 1.3.8.2 matt uint32_t r;
326 1.3.8.2 matt void *ih = NULL;
327 1.3.8.2 matt int s;
328 1.3.8.2 matt
329 1.3.8.2 matt s = splusb();
330 1.3.8.2 matt
331 1.3.8.2 matt if (intr > RMIXL_UB_INTERRUPT_MAX) {
332 1.3.8.2 matt aprint_error_dev(sc->sc_dev, "invalid intr %d\n", intr);
333 1.3.8.2 matt goto out;
334 1.3.8.2 matt }
335 1.3.8.2 matt
336 1.3.8.2 matt if (sc->sc_dispatch[intr].func != NULL) {
337 1.3.8.2 matt aprint_error_dev(sc->sc_dev, "intr %dq busy\n", intr);
338 1.3.8.2 matt goto out;
339 1.3.8.2 matt }
340 1.3.8.2 matt
341 1.3.8.2 matt sc->sc_dispatch[intr].func = func;
342 1.3.8.2 matt sc->sc_dispatch[intr].arg = arg;
343 1.3.8.2 matt ih = &sc->sc_dispatch[intr];
344 1.3.8.2 matt
345 1.3.8.2 matt /* enable this interrupt in the usb interface */
346 1.3.8.2 matt r = bus_space_read_4(sc->sc_obio_bst, sc->sc_obio_bsh,
347 1.3.8.2 matt RMIXL_USB_INTERRUPT_ENABLE);
348 1.3.8.2 matt r |= 1 << intr;
349 1.3.8.2 matt bus_space_write_4(sc->sc_obio_bst, sc->sc_obio_bsh,
350 1.3.8.2 matt RMIXL_USB_INTERRUPT_ENABLE, r);
351 1.3.8.2 matt
352 1.3.8.2 matt out:
353 1.3.8.2 matt splx(s);
354 1.3.8.2 matt return ih;
355 1.3.8.2 matt }
356 1.3.8.2 matt
357 1.3.8.2 matt static int
358 1.3.8.2 matt rmixl_iobus_intr(void *arg)
359 1.3.8.2 matt {
360 1.3.8.2 matt rmixl_iobus_softc_t *sc = arg;
361 1.3.8.2 matt uint32_t r;
362 1.3.8.2 matt int intr;
363 1.3.8.2 matt int rv = 0;
364 1.3.8.2 matt
365 1.3.8.2 matt r = bus_space_read_4(sc->sc_obio_bst, sc->sc_obio_bsh,
366 1.3.8.2 matt RMIXL_USB_INTERRUPT_STATUS);
367 1.3.8.2 matt if (r != 0) {
368 1.3.8.2 matt for (intr=0; intr <= RMIXL_UB_INTERRUPT_MAX; intr++) {
369 1.3.8.2 matt uint32_t bit = 1 << intr;
370 1.3.8.2 matt if ((r & bit) != 0) {
371 1.3.8.2 matt int (*f)(void *) = sc->sc_dispatch[intr].func;
372 1.3.8.2 matt void *a = sc->sc_dispatch[intr].arg;
373 1.3.8.2 matt if (f != NULL) {
374 1.3.8.2 matt (void)(*f)(a);
375 1.3.8.2 matt sc->sc_dispatch[intr].count.ev_count++;
376 1.3.8.2 matt rv = 1;
377 1.3.8.2 matt }
378 1.3.8.2 matt }
379 1.3.8.2 matt }
380 1.3.8.2 matt }
381 1.3.8.2 matt
382 1.3.8.2 matt return rv;
383 1.3.8.2 matt }
384 1.3.8.2 matt
385 1.3.8.2 matt #endif /* NOTYET */
386