i82365_isasubr.c revision 1.7 1 1.7 enami /* $NetBSD: i82365_isasubr.c,v 1.7 2000/02/02 14:44:09 enami Exp $ */
2 1.1 sommerfe
3 1.1 sommerfe #define PCICISADEBUG
4 1.1 sommerfe
5 1.1 sommerfe /*
6 1.5 chopps * Copyright (c) 2000 Christian E. Hopps. All rights reserved.
7 1.1 sommerfe * Copyright (c) 1998 Bill Sommerfeld. All rights reserved.
8 1.1 sommerfe * Copyright (c) 1997 Marc Horowitz. All rights reserved.
9 1.1 sommerfe *
10 1.1 sommerfe * Redistribution and use in source and binary forms, with or without
11 1.1 sommerfe * modification, are permitted provided that the following conditions
12 1.1 sommerfe * are met:
13 1.1 sommerfe * 1. Redistributions of source code must retain the above copyright
14 1.1 sommerfe * notice, this list of conditions and the following disclaimer.
15 1.1 sommerfe * 2. Redistributions in binary form must reproduce the above copyright
16 1.1 sommerfe * notice, this list of conditions and the following disclaimer in the
17 1.1 sommerfe * documentation and/or other materials provided with the distribution.
18 1.1 sommerfe * 3. All advertising materials mentioning features or use of this software
19 1.1 sommerfe * must display the following acknowledgement:
20 1.1 sommerfe * This product includes software developed by Marc Horowitz.
21 1.1 sommerfe * 4. The name of the author may not be used to endorse or promote products
22 1.1 sommerfe * derived from this software without specific prior written permission.
23 1.1 sommerfe *
24 1.1 sommerfe * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
25 1.1 sommerfe * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
26 1.1 sommerfe * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
27 1.1 sommerfe * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
28 1.1 sommerfe * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
29 1.1 sommerfe * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30 1.1 sommerfe * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31 1.1 sommerfe * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 1.1 sommerfe * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
33 1.1 sommerfe * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 1.1 sommerfe */
35 1.1 sommerfe
36 1.1 sommerfe
37 1.1 sommerfe #include <sys/types.h>
38 1.1 sommerfe #include <sys/param.h>
39 1.1 sommerfe #include <sys/systm.h>
40 1.1 sommerfe #include <sys/device.h>
41 1.1 sommerfe #include <sys/extent.h>
42 1.1 sommerfe #include <sys/malloc.h>
43 1.1 sommerfe
44 1.1 sommerfe #include <vm/vm.h>
45 1.1 sommerfe
46 1.1 sommerfe #include <machine/bus.h>
47 1.1 sommerfe #include <machine/intr.h>
48 1.1 sommerfe
49 1.1 sommerfe #include <dev/isa/isareg.h>
50 1.1 sommerfe #include <dev/isa/isavar.h>
51 1.1 sommerfe
52 1.1 sommerfe #include <dev/pcmcia/pcmciareg.h>
53 1.1 sommerfe #include <dev/pcmcia/pcmciavar.h>
54 1.1 sommerfe #include <dev/pcmcia/pcmciachip.h>
55 1.1 sommerfe
56 1.1 sommerfe #include <dev/ic/i82365reg.h>
57 1.1 sommerfe #include <dev/ic/i82365var.h>
58 1.1 sommerfe #include <dev/isa/i82365_isavar.h>
59 1.1 sommerfe
60 1.1 sommerfe /*****************************************************************************
61 1.1 sommerfe * Configurable parameters.
62 1.1 sommerfe *****************************************************************************/
63 1.1 sommerfe
64 1.1 sommerfe #include "opt_pcic_isa_alloc_iobase.h"
65 1.1 sommerfe #include "opt_pcic_isa_alloc_iosize.h"
66 1.1 sommerfe #include "opt_pcic_isa_intr_alloc_mask.h"
67 1.1 sommerfe
68 1.1 sommerfe /*
69 1.1 sommerfe * Default I/O allocation range. If both are set to non-zero, these
70 1.1 sommerfe * values will be used instead. Otherwise, the code attempts to probe
71 1.1 sommerfe * the bus width. Systems with 10 address bits should use 0x300 and 0xff.
72 1.1 sommerfe * Systems with 12 address bits (most) should use 0x400 and 0xbff.
73 1.1 sommerfe */
74 1.1 sommerfe
75 1.1 sommerfe #ifndef PCIC_ISA_ALLOC_IOBASE
76 1.1 sommerfe #define PCIC_ISA_ALLOC_IOBASE 0
77 1.1 sommerfe #endif
78 1.1 sommerfe
79 1.1 sommerfe #ifndef PCIC_ISA_ALLOC_IOSIZE
80 1.1 sommerfe #define PCIC_ISA_ALLOC_IOSIZE 0
81 1.1 sommerfe #endif
82 1.1 sommerfe
83 1.1 sommerfe int pcic_isa_alloc_iobase = PCIC_ISA_ALLOC_IOBASE;
84 1.1 sommerfe int pcic_isa_alloc_iosize = PCIC_ISA_ALLOC_IOSIZE;
85 1.1 sommerfe
86 1.1 sommerfe
87 1.1 sommerfe /*
88 1.1 sommerfe * Default IRQ allocation bitmask. This defines the range of allowable
89 1.1 sommerfe * IRQs for PCMCIA slots. Useful if order of probing would screw up other
90 1.1 sommerfe * devices, or if PCIC hardware/cards have trouble with certain interrupt
91 1.1 sommerfe * lines.
92 1.1 sommerfe *
93 1.1 sommerfe * We disable IRQ 10 by default, since some common laptops (namely, the
94 1.1 sommerfe * NEC Versa series) reserve IRQ 10 for the docking station SCSI interface.
95 1.1 sommerfe */
96 1.1 sommerfe
97 1.1 sommerfe #ifndef PCIC_ISA_INTR_ALLOC_MASK
98 1.6 chopps #define PCIC_ISA_INTR_ALLOC_MASK 0xffff
99 1.1 sommerfe #endif
100 1.1 sommerfe
101 1.1 sommerfe int pcic_isa_intr_alloc_mask = PCIC_ISA_INTR_ALLOC_MASK;
102 1.1 sommerfe
103 1.7 enami #ifndef PCIC_NO_IRQ_PROBE
104 1.7 enami #ifdef __hpcmips__
105 1.7 enami #define PCIC_NO_IRQ_PROBE 0
106 1.7 enami #else
107 1.7 enami #define PCIC_NO_IRQ_PROBE 1
108 1.7 enami #endif
109 1.7 enami #endif
110 1.7 enami
111 1.7 enami int pcic_no_irq_probe = PCIC_NO_IRQ_PROBE;
112 1.7 enami
113 1.1 sommerfe /*****************************************************************************
114 1.1 sommerfe * End of configurable parameters.
115 1.1 sommerfe *****************************************************************************/
116 1.1 sommerfe
117 1.1 sommerfe #ifdef PCICISADEBUG
118 1.5 chopps int pcicsubr_debug = 0;
119 1.5 chopps #define DPRINTF(arg) do { if (pcicsubr_debug) printf arg ; } while (0)
120 1.1 sommerfe #else
121 1.1 sommerfe #define DPRINTF(arg)
122 1.1 sommerfe #endif
123 1.1 sommerfe
124 1.5 chopps /*
125 1.5 chopps * count the interrupt if we have a status set
126 1.5 chopps * just use socket 0
127 1.5 chopps */
128 1.5 chopps
129 1.5 chopps void pcic_isa_probe_interrupts __P((struct pcic_softc *, struct pcic_handle *));
130 1.5 chopps static int pcic_isa_count_intr __P((void *));
131 1.5 chopps
132 1.5 chopps static int
133 1.5 chopps pcic_isa_count_intr(arg)
134 1.5 chopps void *arg;
135 1.5 chopps {
136 1.5 chopps struct pcic_softc *sc;
137 1.5 chopps struct pcic_handle *h;
138 1.5 chopps int cscreg;
139 1.5 chopps
140 1.5 chopps h = arg;
141 1.5 chopps sc = (struct pcic_softc *)h->ph_parent;
142 1.5 chopps
143 1.5 chopps cscreg = pcic_read(h, PCIC_CSC);
144 1.5 chopps if (cscreg & PCIC_CSC_CD) {
145 1.5 chopps if ((++sc->intr_detect % 20) == 0)
146 1.5 chopps printf(".");
147 1.5 chopps else
148 1.5 chopps DPRINTF(("."));
149 1.5 chopps return (1);
150 1.5 chopps }
151 1.5 chopps
152 1.5 chopps #ifdef PCICISADEBUG
153 1.5 chopps if (cscreg)
154 1.5 chopps DPRINTF(("o"));
155 1.5 chopps else
156 1.5 chopps DPRINTF(("X"));
157 1.5 chopps #endif
158 1.5 chopps return (cscreg ? 1 : 0);
159 1.5 chopps }
160 1.5 chopps
161 1.5 chopps /*
162 1.5 chopps * use soft interrupt card detect to find out which irqs are available
163 1.5 chopps * for this controller
164 1.5 chopps */
165 1.5 chopps void
166 1.5 chopps pcic_isa_probe_interrupts(sc, h)
167 1.5 chopps struct pcic_softc *sc;
168 1.5 chopps struct pcic_handle *h;
169 1.5 chopps {
170 1.5 chopps isa_chipset_tag_t ic;
171 1.5 chopps int i, j, mask, irq;
172 1.5 chopps int cd, cscintr, intr, csc;
173 1.5 chopps void *ih;
174 1.5 chopps
175 1.5 chopps ic = sc->intr_est;
176 1.5 chopps
177 1.5 chopps printf("%s: controller %d detecting irqs with mask 0x%04x:",
178 1.5 chopps sc->dev.dv_xname, h->chip, sc->intr_mask[h->chip]);
179 1.5 chopps DPRINTF(("\n"));
180 1.5 chopps
181 1.5 chopps /* clear any current interrupt */
182 1.5 chopps pcic_read(h, PCIC_CSC);
183 1.5 chopps
184 1.5 chopps /* first disable the status irq, then enable card detect */
185 1.5 chopps pcic_write(h, PCIC_CSC_INTR, 0);
186 1.5 chopps cscintr = PCIC_CSC_INTR_CD_ENABLE;
187 1.5 chopps pcic_write(h, PCIC_CSC_INTR, cscintr);
188 1.5 chopps
189 1.5 chopps /* steer the interrupt to isa and disable ring and interrupt */
190 1.5 chopps intr = pcic_read(h, PCIC_INTR);
191 1.5 chopps intr &= ~(PCIC_INTR_RI_ENABLE | PCIC_INTR_ENABLE | PCIC_INTR_IRQ_MASK);
192 1.5 chopps pcic_write(h, PCIC_INTR, intr);
193 1.5 chopps
194 1.5 chopps /* clear any current interrupt */
195 1.5 chopps pcic_read(h, PCIC_CSC);
196 1.5 chopps
197 1.5 chopps cd = pcic_read(h, PCIC_CARD_DETECT);
198 1.5 chopps cd |= PCIC_CARD_DETECT_SW_INTR;
199 1.5 chopps mask = 0;
200 1.5 chopps for (i = 0; i < 16; i++) {
201 1.5 chopps /* honor configured limitations */
202 1.5 chopps if ((sc->intr_mask[h->chip] & (1 << i)) == 0)
203 1.5 chopps continue;
204 1.5 chopps
205 1.5 chopps DPRINTF(("probing irq %d: ", i));
206 1.5 chopps
207 1.5 chopps /* ask for a pulse interrupt so we don't share */
208 1.5 chopps if (isa_intr_alloc(ic, (1 << i), IST_PULSE, &irq)) {
209 1.5 chopps DPRINTF(("currently allocated\n"));
210 1.5 chopps continue;
211 1.5 chopps }
212 1.5 chopps
213 1.5 chopps if ((ih = isa_intr_establish(ic, irq, IST_LEVEL, IPL_TTY,
214 1.5 chopps pcic_isa_count_intr, h)) == NULL)
215 1.5 chopps panic("cant get interrupt");
216 1.5 chopps
217 1.5 chopps cscintr &= ~PCIC_CSC_INTR_IRQ_MASK;
218 1.5 chopps cscintr |= (irq << PCIC_CSC_INTR_IRQ_SHIFT);
219 1.5 chopps pcic_write(h, PCIC_CSC_INTR, cscintr);
220 1.5 chopps
221 1.5 chopps /* interrupt 40 times */
222 1.5 chopps sc->intr_detect = 0;
223 1.5 chopps for (j = 0; j < 40; j++) {
224 1.5 chopps pcic_write(h, PCIC_CARD_DETECT, cd);
225 1.5 chopps delay(100);
226 1.5 chopps csc = pcic_read(h, PCIC_CSC);
227 1.5 chopps DPRINTF(("%s", csc ? "-" : ""));
228 1.5 chopps }
229 1.5 chopps DPRINTF((" total %d\n", sc->intr_detect));
230 1.5 chopps /* allow for misses */
231 1.5 chopps if (sc->intr_detect > 37 && sc->intr_detect <= 40) {
232 1.5 chopps printf("%d", i);
233 1.5 chopps DPRINTF((" succeded\n"));
234 1.5 chopps mask |= (1 << i);
235 1.5 chopps }
236 1.5 chopps isa_intr_disestablish(ic, ih);
237 1.5 chopps }
238 1.5 chopps mask |= 0x8000;
239 1.5 chopps
240 1.5 chopps sc->intr_mask[h->chip] = mask;
241 1.5 chopps printf("%s\n", sc->intr_mask ? "" : " none");
242 1.5 chopps
243 1.5 chopps /* disable all status interrupts */
244 1.5 chopps pcic_write(h, PCIC_CSC_INTR, 0);
245 1.5 chopps
246 1.5 chopps /* clear any current interrupt */
247 1.5 chopps pcic_read(h, PCIC_CSC);
248 1.5 chopps }
249 1.5 chopps
250 1.5 chopps /*
251 1.5 chopps * called with interrupts enabled, light up the irqs to find out
252 1.5 chopps * which irq lines are actually hooked up to our pcic
253 1.5 chopps */
254 1.5 chopps void
255 1.5 chopps pcic_isa_config_interrupts(self)
256 1.5 chopps struct device *self;
257 1.5 chopps {
258 1.5 chopps struct pcic_softc *sc;
259 1.5 chopps struct pcic_handle *h;
260 1.5 chopps isa_chipset_tag_t ic;
261 1.5 chopps int s, i, chipmask, chipuniq;
262 1.5 chopps
263 1.5 chopps sc = (struct pcic_softc *)self;
264 1.5 chopps ic = sc->intr_est;
265 1.5 chopps
266 1.5 chopps /* probe each controller */
267 1.5 chopps chipmask = 0xffff;
268 1.5 chopps for (i = 0; i < PCIC_NSLOTS; i += 2) {
269 1.5 chopps if (sc->handle[i].flags & PCIC_FLAG_SOCKETP)
270 1.5 chopps h = &sc->handle[i];
271 1.5 chopps else if (sc->handle[i + 1].flags & PCIC_FLAG_SOCKETP)
272 1.5 chopps h = &sc->handle[i + 1];
273 1.5 chopps else
274 1.5 chopps continue;
275 1.5 chopps
276 1.5 chopps sc->intr_mask[h->chip] =
277 1.5 chopps PCIC_INTR_IRQ_VALIDMASK & pcic_isa_intr_alloc_mask;
278 1.5 chopps
279 1.5 chopps /* the cirrus chips lack support for the soft interrupt */
280 1.7 enami if (pcic_no_irq_probe != 0 &&
281 1.7 enami h->vendor != PCIC_VENDOR_CIRRUS_PD6710 &&
282 1.5 chopps h->vendor != PCIC_VENDOR_CIRRUS_PD672X)
283 1.5 chopps pcic_isa_probe_interrupts(sc, h);
284 1.5 chopps
285 1.5 chopps chipmask &= sc->intr_mask[h->chip];
286 1.5 chopps }
287 1.5 chopps /* now see if there is at least one irq per chip not shared by all */
288 1.5 chopps chipuniq = 1;
289 1.5 chopps for (i = 0; i < PCIC_NSLOTS; i += 2) {
290 1.5 chopps if ((sc->handle[i].flags & PCIC_FLAG_SOCKETP) == 0 &&
291 1.5 chopps (sc->handle[i + 1].flags & PCIC_FLAG_SOCKETP) == 0)
292 1.5 chopps continue;
293 1.5 chopps if ((sc->intr_mask[i / 2] & ~chipmask) == 0) {
294 1.5 chopps chipuniq = 0;
295 1.5 chopps break;
296 1.5 chopps }
297 1.5 chopps }
298 1.5 chopps /*
299 1.5 chopps * the rest of the following code used to run at config time with
300 1.5 chopps * no interrupts and gets unhappy if this is violated so...
301 1.5 chopps */
302 1.5 chopps s = splhigh();
303 1.5 chopps
304 1.5 chopps /*
305 1.5 chopps * allocate our irq. it will be used by both controllers. I could
306 1.5 chopps * use two different interrupts, but interrupts are relatively
307 1.5 chopps * scarce, shareable, and for PCIC controllers, very infrequent.
308 1.5 chopps */
309 1.5 chopps if (sc->irq != IRQUNK) {
310 1.5 chopps if ((chipmask & (1 << sc->irq)) == 0)
311 1.5 chopps printf("%s: warning: configured irq %d not detected as"
312 1.5 chopps " available\n", sc->dev.dv_xname, sc->irq);
313 1.5 chopps } else if (chipmask == 0 ||
314 1.5 chopps isa_intr_alloc(ic, chipmask, IST_EDGE, &sc->irq)) {
315 1.5 chopps printf("%s: no available irq", sc->dev.dv_xname);
316 1.5 chopps sc->irq = -1;
317 1.5 chopps } else if ((chipmask & ~(1 << sc->irq)) == 0 && chipuniq == 0) {
318 1.5 chopps printf("%s: can\'t share irq with cards", sc->dev.dv_xname);
319 1.5 chopps sc->irq = -1;
320 1.5 chopps }
321 1.5 chopps if (sc->irq != -1) {
322 1.5 chopps printf("%s: using irq %d\n", sc->dev.dv_xname, sc->irq);
323 1.5 chopps sc->ih = isa_intr_establish(ic, sc->irq, IST_EDGE, IPL_TTY,
324 1.5 chopps pcic_intr, sc);
325 1.5 chopps if (sc->ih == NULL) {
326 1.5 chopps printf("%s: can't establish interrupt",
327 1.5 chopps sc->dev.dv_xname);
328 1.5 chopps sc->irq = -1;
329 1.5 chopps }
330 1.5 chopps }
331 1.5 chopps if (sc->irq == -1)
332 1.5 chopps printf(", will poll for card insertion and removal\n");
333 1.5 chopps
334 1.5 chopps pcic_attach_sockets_finish(sc);
335 1.5 chopps
336 1.5 chopps splx(s);
337 1.5 chopps }
338 1.5 chopps
339 1.5 chopps /*
340 1.5 chopps * XXX This routine does not deal with the aliasing issue that its
341 1.5 chopps * trying to.
342 1.5 chopps *
343 1.5 chopps * Any isa device may be decoding only 10 bits of address including
344 1.5 chopps * the pcic. This routine only detects if the pcic is doing 10 bits.
345 1.5 chopps *
346 1.5 chopps * What should be done is detect the pcic's idea of the bus width,
347 1.5 chopps * and then within those limits allocate a sparse map, where the
348 1.5 chopps * each sub region is offset by 0x400.
349 1.5 chopps */
350 1.1 sommerfe void pcic_isa_bus_width_probe (sc, iot, ioh, base, length)
351 1.1 sommerfe struct pcic_softc *sc;
352 1.1 sommerfe bus_space_tag_t iot;
353 1.1 sommerfe bus_space_handle_t ioh;
354 1.1 sommerfe bus_addr_t base;
355 1.1 sommerfe u_int32_t length;
356 1.1 sommerfe {
357 1.1 sommerfe bus_space_handle_t ioh_high;
358 1.1 sommerfe int i, iobuswidth, tmp1, tmp2;
359 1.1 sommerfe
360 1.1 sommerfe /*
361 1.1 sommerfe * figure out how wide the isa bus is. Do this by checking if the
362 1.1 sommerfe * pcic controller is mirrored 0x400 above where we expect it to be.
363 1.1 sommerfe */
364 1.1 sommerfe
365 1.1 sommerfe iobuswidth = 12;
366 1.1 sommerfe
367 1.1 sommerfe /* Map i/o space. */
368 1.1 sommerfe if (bus_space_map(iot, base + 0x400, length, 0, &ioh_high)) {
369 1.1 sommerfe printf("%s: can't map high i/o space\n", sc->dev.dv_xname);
370 1.1 sommerfe return;
371 1.1 sommerfe }
372 1.1 sommerfe
373 1.1 sommerfe for (i = 0; i < PCIC_NSLOTS; i++) {
374 1.1 sommerfe if (sc->handle[i].flags & PCIC_FLAG_SOCKETP) {
375 1.1 sommerfe /*
376 1.1 sommerfe * read the ident flags from the normal space and
377 1.1 sommerfe * from the mirror, and compare them
378 1.1 sommerfe */
379 1.1 sommerfe
380 1.1 sommerfe bus_space_write_1(iot, ioh, PCIC_REG_INDEX,
381 1.1 sommerfe sc->handle[i].sock + PCIC_IDENT);
382 1.1 sommerfe tmp1 = bus_space_read_1(iot, ioh, PCIC_REG_DATA);
383 1.1 sommerfe
384 1.1 sommerfe bus_space_write_1(iot, ioh_high, PCIC_REG_INDEX,
385 1.1 sommerfe sc->handle[i].sock + PCIC_IDENT);
386 1.1 sommerfe tmp2 = bus_space_read_1(iot, ioh_high, PCIC_REG_DATA);
387 1.1 sommerfe
388 1.1 sommerfe if (tmp1 == tmp2)
389 1.1 sommerfe iobuswidth = 10;
390 1.1 sommerfe }
391 1.1 sommerfe }
392 1.1 sommerfe
393 1.1 sommerfe bus_space_free(iot, ioh_high, length);
394 1.1 sommerfe
395 1.1 sommerfe /*
396 1.1 sommerfe * XXX mycroft recommends I/O space range 0x400-0xfff . I should put
397 1.1 sommerfe * this in a header somewhere
398 1.1 sommerfe */
399 1.1 sommerfe
400 1.1 sommerfe /*
401 1.1 sommerfe * XXX some hardware doesn't seem to grok addresses in 0x400 range--
402 1.1 sommerfe * apparently missing a bit or more of address lines. (e.g.
403 1.1 sommerfe * CIRRUS_PD672X with Linksys EthernetCard ne2000 clone in TI
404 1.1 sommerfe * TravelMate 5000--not clear which is at fault)
405 1.1 sommerfe *
406 1.1 sommerfe * Add a kludge to detect 10 bit wide buses and deal with them,
407 1.1 sommerfe * and also a config file option to override the probe.
408 1.1 sommerfe */
409 1.1 sommerfe
410 1.1 sommerfe if (iobuswidth == 10) {
411 1.1 sommerfe sc->iobase = 0x300;
412 1.1 sommerfe sc->iosize = 0x0ff;
413 1.1 sommerfe } else {
414 1.1 sommerfe #if 0
415 1.1 sommerfe /*
416 1.1 sommerfe * This is what we'd like to use, but...
417 1.1 sommerfe */
418 1.1 sommerfe sc->iobase = 0x400;
419 1.1 sommerfe sc->iosize = 0xbff;
420 1.1 sommerfe #else
421 1.1 sommerfe /*
422 1.1 sommerfe * ...the above bus width probe doesn't always work.
423 1.1 sommerfe * So, experimentation has shown the following range
424 1.1 sommerfe * to not lose on systems that 0x300-0x3ff loses on
425 1.1 sommerfe * (e.g. the NEC Versa 6030X).
426 1.1 sommerfe */
427 1.1 sommerfe sc->iobase = 0x330;
428 1.1 sommerfe sc->iosize = 0x0cf;
429 1.1 sommerfe #endif
430 1.1 sommerfe }
431 1.1 sommerfe
432 1.1 sommerfe DPRINTF(("%s: bus_space_alloc range 0x%04lx-0x%04lx (probed)\n",
433 1.1 sommerfe sc->dev.dv_xname, (long) sc->iobase,
434 1.1 sommerfe
435 1.1 sommerfe (long) sc->iobase + sc->iosize));
436 1.1 sommerfe
437 1.1 sommerfe if (pcic_isa_alloc_iobase && pcic_isa_alloc_iosize) {
438 1.1 sommerfe sc->iobase = pcic_isa_alloc_iobase;
439 1.1 sommerfe sc->iosize = pcic_isa_alloc_iosize;
440 1.1 sommerfe
441 1.1 sommerfe DPRINTF(("%s: bus_space_alloc range 0x%04lx-0x%04lx "
442 1.1 sommerfe "(config override)\n", sc->dev.dv_xname, (long) sc->iobase,
443 1.1 sommerfe (long) sc->iobase + sc->iosize));
444 1.1 sommerfe }
445 1.1 sommerfe }
446 1.1 sommerfe
447 1.1 sommerfe void *
448 1.1 sommerfe pcic_isa_chip_intr_establish(pch, pf, ipl, fct, arg)
449 1.1 sommerfe pcmcia_chipset_handle_t pch;
450 1.1 sommerfe struct pcmcia_function *pf;
451 1.1 sommerfe int ipl;
452 1.1 sommerfe int (*fct) __P((void *));
453 1.1 sommerfe void *arg;
454 1.1 sommerfe {
455 1.1 sommerfe struct pcic_handle *h = (struct pcic_handle *) pch;
456 1.4 haya struct pcic_softc *sc = (struct pcic_softc *)(h->ph_parent);
457 1.4 haya isa_chipset_tag_t ic = sc->intr_est;
458 1.1 sommerfe int irq, ist;
459 1.1 sommerfe void *ih;
460 1.1 sommerfe int reg;
461 1.1 sommerfe
462 1.1 sommerfe if (pf->cfe->flags & PCMCIA_CFE_IRQLEVEL)
463 1.1 sommerfe ist = IST_LEVEL;
464 1.1 sommerfe else if (pf->cfe->flags & PCMCIA_CFE_IRQPULSE)
465 1.1 sommerfe ist = IST_PULSE;
466 1.1 sommerfe else
467 1.2 mycroft ist = IST_EDGE;
468 1.1 sommerfe
469 1.5 chopps if (isa_intr_alloc(ic, sc->intr_mask[h->chip], ist, &irq))
470 1.1 sommerfe return (NULL);
471 1.5 chopps if ((ih = isa_intr_establish(ic, irq, ist, ipl, fct, arg)) == NULL)
472 1.1 sommerfe return (NULL);
473 1.1 sommerfe
474 1.1 sommerfe reg = pcic_read(h, PCIC_INTR);
475 1.3 mycroft reg &= ~(PCIC_INTR_IRQ_MASK | PCIC_INTR_ENABLE);
476 1.3 mycroft reg |= irq;
477 1.1 sommerfe pcic_write(h, PCIC_INTR, reg);
478 1.1 sommerfe
479 1.1 sommerfe h->ih_irq = irq;
480 1.1 sommerfe
481 1.1 sommerfe printf("%s: card irq %d\n", h->pcmcia->dv_xname, irq);
482 1.1 sommerfe
483 1.1 sommerfe return (ih);
484 1.1 sommerfe }
485 1.1 sommerfe
486 1.1 sommerfe void
487 1.1 sommerfe pcic_isa_chip_intr_disestablish(pch, ih)
488 1.1 sommerfe pcmcia_chipset_handle_t pch;
489 1.1 sommerfe void *ih;
490 1.1 sommerfe {
491 1.1 sommerfe struct pcic_handle *h = (struct pcic_handle *) pch;
492 1.4 haya struct pcic_softc *sc = (struct pcic_softc *)(h->ph_parent);
493 1.4 haya isa_chipset_tag_t ic = sc->intr_est;
494 1.1 sommerfe int reg;
495 1.1 sommerfe
496 1.1 sommerfe h->ih_irq = 0;
497 1.1 sommerfe
498 1.1 sommerfe reg = pcic_read(h, PCIC_INTR);
499 1.1 sommerfe reg &= ~(PCIC_INTR_IRQ_MASK | PCIC_INTR_ENABLE);
500 1.1 sommerfe pcic_write(h, PCIC_INTR, reg);
501 1.1 sommerfe
502 1.1 sommerfe isa_intr_disestablish(ic, ih);
503 1.1 sommerfe }
504