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