sa1111.c revision 1.3.4.3 1 1.3.4.3 nathanw /* $NetBSD: sa1111.c,v 1.3.4.3 2002/08/13 02:17:56 nathanw Exp $ */
2 1.3.4.2 nathanw
3 1.3.4.2 nathanw /*-
4 1.3.4.2 nathanw * Copyright (c) 2001 The NetBSD Foundation, Inc.
5 1.3.4.2 nathanw * All rights reserved.
6 1.3.4.2 nathanw *
7 1.3.4.2 nathanw * This code is derived from software contributed to The NetBSD Foundation
8 1.3.4.2 nathanw * by IWAMOTO Toshihiro.
9 1.3.4.2 nathanw *
10 1.3.4.2 nathanw * Redistribution and use in source and binary forms, with or without
11 1.3.4.2 nathanw * modification, are permitted provided that the following conditions
12 1.3.4.2 nathanw * are met:
13 1.3.4.2 nathanw * 1. Redistributions of source code must retain the above copyright
14 1.3.4.2 nathanw * notice, this list of conditions and the following disclaimer.
15 1.3.4.2 nathanw * 2. Redistributions in binary form must reproduce the above copyright
16 1.3.4.2 nathanw * notice, this list of conditions and the following disclaimer in the
17 1.3.4.2 nathanw * documentation and/or other materials provided with the distribution.
18 1.3.4.2 nathanw * 3. All advertising materials mentioning features or use of this software
19 1.3.4.2 nathanw * must display the following acknowledgement:
20 1.3.4.2 nathanw * This product includes software developed by the NetBSD
21 1.3.4.2 nathanw * Foundation, Inc. and its contributors.
22 1.3.4.2 nathanw * 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.3.4.2 nathanw * contributors may be used to endorse or promote products derived
24 1.3.4.2 nathanw * from this software without specific prior written permission.
25 1.3.4.2 nathanw *
26 1.3.4.2 nathanw * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 1.3.4.2 nathanw * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.3.4.2 nathanw * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.3.4.2 nathanw * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 1.3.4.2 nathanw * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.3.4.2 nathanw * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.3.4.2 nathanw * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.3.4.2 nathanw * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.3.4.2 nathanw * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.3.4.2 nathanw * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.3.4.2 nathanw * POSSIBILITY OF SUCH DAMAGE.
37 1.3.4.2 nathanw */
38 1.3.4.2 nathanw
39 1.3.4.2 nathanw /*
40 1.3.4.2 nathanw * TODO:
41 1.3.4.2 nathanw * - separate machine specific attach code
42 1.3.4.2 nathanw * - introduce bus abstraction to support SA1101
43 1.3.4.2 nathanw */
44 1.3.4.2 nathanw
45 1.3.4.2 nathanw #include <sys/param.h>
46 1.3.4.2 nathanw #include <sys/systm.h>
47 1.3.4.2 nathanw #include <sys/types.h>
48 1.3.4.2 nathanw #include <sys/conf.h>
49 1.3.4.2 nathanw #include <sys/device.h>
50 1.3.4.2 nathanw #include <sys/kernel.h>
51 1.3.4.2 nathanw #include <sys/malloc.h>
52 1.3.4.2 nathanw #include <sys/uio.h>
53 1.3.4.2 nathanw
54 1.3.4.2 nathanw #include <machine/bus.h>
55 1.3.4.2 nathanw #ifdef hpcarm
56 1.3.4.2 nathanw #include <machine/platid.h>
57 1.3.4.2 nathanw #include <machine/platid_mask.h>
58 1.3.4.2 nathanw #endif
59 1.3.4.2 nathanw
60 1.3.4.2 nathanw #include <arm/sa11x0/sa11x0_reg.h>
61 1.3.4.2 nathanw #include <arm/sa11x0/sa11x0_var.h>
62 1.3.4.2 nathanw #include <arm/sa11x0/sa11x0_gpioreg.h>
63 1.3.4.2 nathanw #include <arm/sa11x0/sa1111_reg.h>
64 1.3.4.2 nathanw #include <arm/sa11x0/sa1111_var.h>
65 1.3.4.2 nathanw
66 1.3.4.2 nathanw static int sacc_probe(struct device *, struct cfdata *, void *);
67 1.3.4.2 nathanw static void sacc_attach(struct device *, struct device *, void *);
68 1.3.4.2 nathanw static int sa1111_search(struct device *, struct cfdata *, void *);
69 1.3.4.2 nathanw static int sa1111_print(void *, const char *);
70 1.3.4.2 nathanw
71 1.3.4.2 nathanw static void sacc_intr_calculatemasks(struct sacc_softc *);
72 1.3.4.2 nathanw static void sacc_intr_setpolarity(sacc_chipset_tag_t *, int , int);
73 1.3.4.2 nathanw int sacc_intr(void *);
74 1.3.4.2 nathanw
75 1.3.4.2 nathanw #ifndef hpcarm
76 1.3.4.2 nathanw void *softintr_establish(int, int (*)(void *), void *);
77 1.3.4.2 nathanw void softintr_schedule(void *);
78 1.3.4.2 nathanw #endif
79 1.3.4.2 nathanw
80 1.3.4.2 nathanw #ifdef hpcarm
81 1.3.4.2 nathanw struct platid_data sacc_platid_table[] = {
82 1.3.4.2 nathanw { &platid_mask_MACH_HP_JORNADA_720, (void *)1 },
83 1.3.4.2 nathanw { &platid_mask_MACH_HP_JORNADA_720JP, (void *)1 },
84 1.3.4.2 nathanw { NULL, NULL }
85 1.3.4.2 nathanw };
86 1.3.4.2 nathanw #endif
87 1.3.4.2 nathanw
88 1.3.4.2 nathanw struct cfattach sacc_ca = {
89 1.3.4.2 nathanw sizeof(struct sacc_softc), sacc_probe, sacc_attach
90 1.3.4.2 nathanw };
91 1.3.4.2 nathanw
92 1.3.4.2 nathanw #ifdef INTR_DEBUG
93 1.3.4.2 nathanw #define DPRINTF(arg) printf arg
94 1.3.4.2 nathanw #else
95 1.3.4.2 nathanw #define DPRINTF(arg)
96 1.3.4.2 nathanw #endif
97 1.3.4.2 nathanw
98 1.3.4.2 nathanw static int
99 1.3.4.2 nathanw sacc_probe(parent, match, aux)
100 1.3.4.2 nathanw struct device *parent;
101 1.3.4.2 nathanw struct cfdata *match;
102 1.3.4.2 nathanw void *aux;
103 1.3.4.2 nathanw {
104 1.3.4.2 nathanw struct sa11x0_attach_args *sa = aux;
105 1.3.4.2 nathanw bus_space_handle_t ioh;
106 1.3.4.2 nathanw u_int32_t skid;
107 1.3.4.2 nathanw
108 1.3.4.2 nathanw if (bus_space_map(sa->sa_iot, sa->sa_addr, sa->sa_size, 0, &ioh))
109 1.3.4.2 nathanw return (0);
110 1.3.4.2 nathanw
111 1.3.4.2 nathanw skid = bus_space_read_4(sa->sa_iot, ioh, SACCSBI_SKID);
112 1.3.4.2 nathanw bus_space_unmap(sa->sa_iot, ioh, sa->sa_size);
113 1.3.4.2 nathanw
114 1.3.4.2 nathanw if ((skid & 0xffffff00) != 0x690cc200)
115 1.3.4.2 nathanw return (0);
116 1.3.4.2 nathanw
117 1.3.4.2 nathanw return (1);
118 1.3.4.2 nathanw }
119 1.3.4.2 nathanw
120 1.3.4.2 nathanw static void
121 1.3.4.2 nathanw sacc_attach(parent, self, aux)
122 1.3.4.2 nathanw struct device *parent;
123 1.3.4.2 nathanw struct device *self;
124 1.3.4.2 nathanw void *aux;
125 1.3.4.2 nathanw {
126 1.3.4.2 nathanw int i, gpiopin;
127 1.3.4.2 nathanw u_int32_t skid;
128 1.3.4.2 nathanw struct sacc_softc *sc = (struct sacc_softc *)self;
129 1.3.4.2 nathanw struct sa11x0_softc *psc = (struct sa11x0_softc *)parent;
130 1.3.4.2 nathanw struct sa11x0_attach_args *sa = aux;
131 1.3.4.2 nathanw #ifdef hpcarm
132 1.3.4.2 nathanw struct platid_data *p;
133 1.3.4.2 nathanw #endif
134 1.3.4.2 nathanw
135 1.3.4.2 nathanw printf("\n");
136 1.3.4.2 nathanw
137 1.3.4.2 nathanw sc->sc_iot = sa->sa_iot;
138 1.3.4.2 nathanw sc->sc_piot = psc->sc_iot;
139 1.3.4.2 nathanw sc->sc_gpioh = psc->sc_gpioh;
140 1.3.4.2 nathanw #ifdef hpcarm
141 1.3.4.2 nathanw if ((p = platid_search_data(&platid, sacc_platid_table)) == NULL)
142 1.3.4.2 nathanw return;
143 1.3.4.2 nathanw
144 1.3.4.2 nathanw gpiopin = (int) p->data;
145 1.3.4.2 nathanw #else
146 1.3.4.2 nathanw gpiopin = sa->sa_gpio;
147 1.3.4.2 nathanw #endif
148 1.3.4.2 nathanw sc->sc_gpiomask = 1 << gpiopin;
149 1.3.4.2 nathanw
150 1.3.4.2 nathanw if (bus_space_map(sa->sa_iot, sa->sa_addr, sa->sa_size, 0,
151 1.3.4.2 nathanw &sc->sc_ioh)) {
152 1.3.4.2 nathanw printf("%s: unable to map registers\n", sc->sc_dev.dv_xname);
153 1.3.4.2 nathanw return;
154 1.3.4.2 nathanw }
155 1.3.4.2 nathanw
156 1.3.4.2 nathanw skid = bus_space_read_4(sc->sc_iot, sc->sc_ioh, SACCSBI_SKID);
157 1.3.4.2 nathanw
158 1.3.4.2 nathanw printf("%s: SA1111 rev %d.%d\n", sc->sc_dev.dv_xname,
159 1.3.4.2 nathanw (skid & 0xf0) >> 3, skid & 0xf);
160 1.3.4.2 nathanw
161 1.3.4.2 nathanw for(i = 0; i < SACCIC_LEN; i++)
162 1.3.4.2 nathanw sc->sc_intrhand[i] = NULL;
163 1.3.4.2 nathanw
164 1.3.4.2 nathanw /* initialize SA1111 interrupt controller */
165 1.3.4.2 nathanw bus_space_write_4(sc->sc_iot, sc->sc_ioh, SACCIC_INTEN0, 0);
166 1.3.4.2 nathanw bus_space_write_4(sc->sc_iot, sc->sc_ioh, SACCIC_INTEN1, 0);
167 1.3.4.2 nathanw bus_space_write_4(sc->sc_iot, sc->sc_ioh, SACCIC_INTTSTSEL, 0);
168 1.3.4.2 nathanw bus_space_write_4(sc->sc_iot, sc->sc_ioh,
169 1.3.4.2 nathanw SACCIC_INTSTATCLR0, 0xffffffff);
170 1.3.4.2 nathanw bus_space_write_4(sc->sc_iot, sc->sc_ioh,
171 1.3.4.2 nathanw SACCIC_INTSTATCLR1, 0xffffffff);
172 1.3.4.2 nathanw
173 1.3.4.2 nathanw /* connect to SA1110's GPIO intr */
174 1.3.4.2 nathanw sa11x0_intr_establish(0, gpiopin, 1, IPL_SERIAL, sacc_intr, sc);
175 1.3.4.2 nathanw
176 1.3.4.2 nathanw /*
177 1.3.4.2 nathanw * Attach each devices
178 1.3.4.2 nathanw */
179 1.3.4.2 nathanw config_search(sa1111_search, self, NULL);
180 1.3.4.2 nathanw }
181 1.3.4.2 nathanw
182 1.3.4.2 nathanw static int
183 1.3.4.2 nathanw sa1111_search(parent, cf, aux)
184 1.3.4.2 nathanw struct device *parent;
185 1.3.4.2 nathanw struct cfdata *cf;
186 1.3.4.2 nathanw void *aux;
187 1.3.4.2 nathanw {
188 1.3.4.2 nathanw if ((*cf->cf_attach->ca_match)(parent, cf, NULL) > 0)
189 1.3.4.2 nathanw config_attach(parent, cf, NULL, sa1111_print);
190 1.3.4.2 nathanw
191 1.3.4.2 nathanw return 0;
192 1.3.4.2 nathanw }
193 1.3.4.2 nathanw
194 1.3.4.2 nathanw static int
195 1.3.4.2 nathanw sa1111_print(aux, name)
196 1.3.4.2 nathanw void *aux;
197 1.3.4.2 nathanw const char *name;
198 1.3.4.2 nathanw {
199 1.3.4.2 nathanw return (UNCONF);
200 1.3.4.2 nathanw }
201 1.3.4.2 nathanw
202 1.3.4.2 nathanw int
203 1.3.4.2 nathanw sacc_intr(arg)
204 1.3.4.2 nathanw void *arg;
205 1.3.4.2 nathanw {
206 1.3.4.2 nathanw int i;
207 1.3.4.2 nathanw u_int32_t mask;
208 1.3.4.2 nathanw struct sacc_intrvec intstat;
209 1.3.4.2 nathanw struct sacc_softc *sc = arg;
210 1.3.4.2 nathanw #ifdef hpcarm
211 1.3.4.2 nathanw struct sacc_intrhand *ih;
212 1.3.4.2 nathanw #endif
213 1.3.4.2 nathanw
214 1.3.4.2 nathanw intstat.lo =
215 1.3.4.2 nathanw bus_space_read_4(sc->sc_iot, sc->sc_ioh, SACCIC_INTSTATCLR0);
216 1.3.4.2 nathanw intstat.hi =
217 1.3.4.2 nathanw bus_space_read_4(sc->sc_iot, sc->sc_ioh, SACCIC_INTSTATCLR1);
218 1.3.4.2 nathanw DPRINTF(("sacc_intr_dispatch: %x %x\n", intstat.lo, intstat.hi));
219 1.3.4.2 nathanw
220 1.3.4.3 nathanw /* clear SA1110's GPIO intr status */
221 1.3.4.3 nathanw bus_space_write_4(sc->sc_piot, sc->sc_gpioh,
222 1.3.4.3 nathanw SAGPIO_EDR, sc->sc_gpiomask);
223 1.3.4.3 nathanw
224 1.3.4.2 nathanw for(i = 0, mask = 1; i < 32; i++, mask <<= 1)
225 1.3.4.2 nathanw if (intstat.lo & mask) {
226 1.3.4.2 nathanw /*
227 1.3.4.2 nathanw * Clear intr status before calling intr handlers.
228 1.3.4.2 nathanw * This cause stray interrupts, but clearing
229 1.3.4.2 nathanw * after calling intr handlers cause intr lossage.
230 1.3.4.2 nathanw */
231 1.3.4.2 nathanw bus_space_write_4(sc->sc_iot, sc->sc_ioh,
232 1.3.4.2 nathanw SACCIC_INTSTATCLR0, 1 << i);
233 1.3.4.2 nathanw
234 1.3.4.2 nathanw #ifdef hpcarm
235 1.3.4.2 nathanw for(ih = sc->sc_intrhand[i]; ih; ih = ih->ih_next)
236 1.3.4.2 nathanw softintr_schedule(ih->ih_soft);
237 1.3.4.2 nathanw #endif
238 1.3.4.2 nathanw }
239 1.3.4.2 nathanw for(i = 0, mask = 1; i < SACCIC_LEN - 32; i++, mask <<= 1)
240 1.3.4.2 nathanw if (intstat.hi & mask) {
241 1.3.4.2 nathanw bus_space_write_4(sc->sc_iot, sc->sc_ioh,
242 1.3.4.2 nathanw SACCIC_INTSTATCLR1, 1 << i);
243 1.3.4.2 nathanw #ifdef hpcarm
244 1.3.4.2 nathanw for(ih = sc->sc_intrhand[i + 32]; ih; ih = ih->ih_next)
245 1.3.4.2 nathanw softintr_schedule(ih->ih_soft);
246 1.3.4.2 nathanw #endif
247 1.3.4.2 nathanw }
248 1.3.4.2 nathanw return 1;
249 1.3.4.2 nathanw }
250 1.3.4.2 nathanw
251 1.3.4.2 nathanw void *
252 1.3.4.2 nathanw sacc_intr_establish(ic, irq, type, level, ih_fun, ih_arg)
253 1.3.4.2 nathanw sacc_chipset_tag_t *ic;
254 1.3.4.2 nathanw int irq, type, level;
255 1.3.4.2 nathanw int (*ih_fun)(void *);
256 1.3.4.2 nathanw void *ih_arg;
257 1.3.4.2 nathanw {
258 1.3.4.2 nathanw int s;
259 1.3.4.2 nathanw struct sacc_softc *sc = (struct sacc_softc *)ic;
260 1.3.4.2 nathanw struct sacc_intrhand **p, *ih;
261 1.3.4.2 nathanw
262 1.3.4.2 nathanw /* no point in sleeping unless someone can free memory. */
263 1.3.4.2 nathanw ih = malloc(sizeof *ih, M_DEVBUF, cold ? M_NOWAIT : M_WAITOK);
264 1.3.4.2 nathanw if (ih == NULL)
265 1.3.4.2 nathanw panic("sacc_intr_establish: can't malloc handler info");
266 1.3.4.2 nathanw
267 1.3.4.2 nathanw if (irq < 0 || irq > SACCIC_LEN ||
268 1.3.4.2 nathanw ! (type == IST_EDGE_RAISE || type == IST_EDGE_FALL))
269 1.3.4.2 nathanw panic("sacc_intr_establish: bogus irq or type");
270 1.3.4.2 nathanw
271 1.3.4.2 nathanw if (sc->sc_intrhand[irq] == NULL) {
272 1.3.4.2 nathanw sacc_intr_setpolarity(ic, irq, type);
273 1.3.4.2 nathanw sc->sc_intrtype[irq] = type;
274 1.3.4.2 nathanw } else if (sc->sc_intrtype[irq] != type)
275 1.3.4.2 nathanw /* XXX we should be able to share raising and
276 1.3.4.2 nathanw * falling edge intrs */
277 1.3.4.2 nathanw panic("sacc_intr_establish: type must be unique\n");
278 1.3.4.2 nathanw
279 1.3.4.2 nathanw /* install intr handler */
280 1.3.4.2 nathanw #ifdef hpcarm
281 1.3.4.2 nathanw ih->ih_soft = softintr_establish(level, (void (*)(void *)) ih_fun,
282 1.3.4.2 nathanw ih_arg);
283 1.3.4.2 nathanw #endif
284 1.3.4.2 nathanw ih->ih_irq = irq;
285 1.3.4.2 nathanw ih->ih_next = NULL;
286 1.3.4.2 nathanw
287 1.3.4.2 nathanw s = splhigh();
288 1.3.4.2 nathanw for(p = &sc->sc_intrhand[irq]; *p; p = &(*p)->ih_next)
289 1.3.4.2 nathanw ;
290 1.3.4.2 nathanw
291 1.3.4.2 nathanw *p = ih;
292 1.3.4.2 nathanw
293 1.3.4.2 nathanw sacc_intr_calculatemasks(sc);
294 1.3.4.2 nathanw splx(s);
295 1.3.4.2 nathanw
296 1.3.4.2 nathanw return(ih);
297 1.3.4.2 nathanw }
298 1.3.4.2 nathanw
299 1.3.4.2 nathanw void
300 1.3.4.2 nathanw sacc_intr_disestablish(ic, arg)
301 1.3.4.2 nathanw sacc_chipset_tag_t *ic;
302 1.3.4.2 nathanw void *arg;
303 1.3.4.2 nathanw {
304 1.3.4.2 nathanw int irq, s;
305 1.3.4.2 nathanw struct sacc_softc *sc = (struct sacc_softc *)ic;
306 1.3.4.2 nathanw struct sacc_intrhand *ih, **p;
307 1.3.4.2 nathanw
308 1.3.4.2 nathanw ih = (struct sacc_intrhand *)arg;
309 1.3.4.2 nathanw irq = ih->ih_irq;
310 1.3.4.2 nathanw
311 1.3.4.2 nathanw #ifdef DIAGNOSTIC
312 1.3.4.2 nathanw if (irq < 0 || irq > SACCIC_LEN)
313 1.3.4.2 nathanw panic("sacc_intr_disestablish: bogus irq");
314 1.3.4.2 nathanw #endif
315 1.3.4.2 nathanw
316 1.3.4.2 nathanw s = splhigh();
317 1.3.4.2 nathanw
318 1.3.4.2 nathanw for(p = &sc->sc_intrhand[irq];; p = &(*p)->ih_next) {
319 1.3.4.2 nathanw if (*p == NULL)
320 1.3.4.2 nathanw panic("sacc_intr_disestablish: handler not registered");
321 1.3.4.2 nathanw if (*p == ih)
322 1.3.4.2 nathanw break;
323 1.3.4.2 nathanw }
324 1.3.4.2 nathanw *p = (*p)->ih_next;
325 1.3.4.2 nathanw
326 1.3.4.2 nathanw sacc_intr_calculatemasks(sc);
327 1.3.4.2 nathanw splx(s);
328 1.3.4.2 nathanw
329 1.3.4.2 nathanw free(ih, M_DEVBUF);
330 1.3.4.2 nathanw }
331 1.3.4.2 nathanw
332 1.3.4.2 nathanw void
333 1.3.4.2 nathanw sacc_intr_setpolarity(ic, irq, type)
334 1.3.4.2 nathanw sacc_chipset_tag_t *ic;
335 1.3.4.2 nathanw int irq;
336 1.3.4.2 nathanw int type;
337 1.3.4.2 nathanw {
338 1.3.4.2 nathanw struct sacc_softc *sc = (struct sacc_softc *)ic;
339 1.3.4.2 nathanw int s;
340 1.3.4.2 nathanw u_int32_t pol, mask;
341 1.3.4.2 nathanw int addr;
342 1.3.4.2 nathanw
343 1.3.4.2 nathanw if (irq >= 32) {
344 1.3.4.2 nathanw addr = SACCIC_INTPOL1;
345 1.3.4.2 nathanw irq -= 32;
346 1.3.4.2 nathanw } else
347 1.3.4.2 nathanw addr = SACCIC_INTPOL0;
348 1.3.4.2 nathanw
349 1.3.4.2 nathanw mask = (1 << irq);
350 1.3.4.2 nathanw
351 1.3.4.2 nathanw s = splhigh();
352 1.3.4.2 nathanw pol = bus_space_read_4(sc->sc_iot, sc->sc_ioh, addr);
353 1.3.4.2 nathanw if (type == IST_EDGE_RAISE)
354 1.3.4.2 nathanw pol &= ~mask;
355 1.3.4.2 nathanw else
356 1.3.4.2 nathanw pol |= mask;
357 1.3.4.2 nathanw bus_space_write_4(sc->sc_iot, sc->sc_ioh, addr, pol);
358 1.3.4.2 nathanw splx(s);
359 1.3.4.2 nathanw }
360 1.3.4.2 nathanw
361 1.3.4.2 nathanw void
362 1.3.4.2 nathanw sacc_intr_calculatemasks(sc)
363 1.3.4.2 nathanw struct sacc_softc *sc;
364 1.3.4.2 nathanw {
365 1.3.4.2 nathanw int irq;
366 1.3.4.2 nathanw
367 1.3.4.2 nathanw sc->sc_imask.lo = 0;
368 1.3.4.2 nathanw sc->sc_imask.hi = 0;
369 1.3.4.2 nathanw for(irq = 0; irq < 32; irq++)
370 1.3.4.2 nathanw if (sc->sc_intrhand[irq])
371 1.3.4.2 nathanw sc->sc_imask.lo |= (1 << irq);
372 1.3.4.2 nathanw for(irq = 0; irq < SACCIC_LEN - 32; irq++)
373 1.3.4.2 nathanw if (sc->sc_intrhand[irq + 32])
374 1.3.4.2 nathanw sc->sc_imask.hi |= (1 << irq);
375 1.3.4.2 nathanw
376 1.3.4.2 nathanw
377 1.3.4.2 nathanw /* XXX this should not be done here */
378 1.3.4.2 nathanw bus_space_write_4(sc->sc_iot, sc->sc_ioh, SACCIC_INTEN0,
379 1.3.4.2 nathanw sc->sc_imask.lo);
380 1.3.4.2 nathanw bus_space_write_4(sc->sc_iot, sc->sc_ioh, SACCIC_INTEN1,
381 1.3.4.2 nathanw sc->sc_imask.hi);
382 1.3.4.2 nathanw DPRINTF(("sacc_intr_calculatemasks: %x %x\n", sc->sc_imask.lo,
383 1.3.4.2 nathanw sc->sc_imask.hi));
384 1.3.4.2 nathanw }
385