Home | History | Annotate | Line # | Download | only in isa
i82365_isa.c revision 1.8
      1  1.8  drochner /*	$NetBSD: i82365_isa.c,v 1.8 1997/11/30 15:31:24 drochner Exp $	*/
      2  1.2   thorpej 
      3  1.2   thorpej #define	PCICISADEBUG
      4  1.2   thorpej 
      5  1.2   thorpej /*
      6  1.2   thorpej  * Copyright (c) 1997 Marc Horowitz.  All rights reserved.
      7  1.2   thorpej  *
      8  1.2   thorpej  * Redistribution and use in source and binary forms, with or without
      9  1.2   thorpej  * modification, are permitted provided that the following conditions
     10  1.2   thorpej  * are met:
     11  1.2   thorpej  * 1. Redistributions of source code must retain the above copyright
     12  1.2   thorpej  *    notice, this list of conditions and the following disclaimer.
     13  1.2   thorpej  * 2. Redistributions in binary form must reproduce the above copyright
     14  1.2   thorpej  *    notice, this list of conditions and the following disclaimer in the
     15  1.2   thorpej  *    documentation and/or other materials provided with the distribution.
     16  1.2   thorpej  * 3. All advertising materials mentioning features or use of this software
     17  1.2   thorpej  *    must display the following acknowledgement:
     18  1.2   thorpej  *	This product includes software developed by Marc Horowitz.
     19  1.2   thorpej  * 4. The name of the author may not be used to endorse or promote products
     20  1.2   thorpej  *    derived from this software without specific prior written permission.
     21  1.2   thorpej  *
     22  1.2   thorpej  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     23  1.2   thorpej  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     24  1.2   thorpej  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     25  1.2   thorpej  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     26  1.2   thorpej  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     27  1.2   thorpej  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     28  1.2   thorpej  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     29  1.2   thorpej  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     30  1.2   thorpej  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     31  1.2   thorpej  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     32  1.2   thorpej  */
     33  1.2   thorpej 
     34  1.2   thorpej #include <sys/types.h>
     35  1.2   thorpej #include <sys/param.h>
     36  1.2   thorpej #include <sys/systm.h>
     37  1.2   thorpej #include <sys/device.h>
     38  1.2   thorpej #include <sys/extent.h>
     39  1.2   thorpej #include <sys/malloc.h>
     40  1.2   thorpej 
     41  1.2   thorpej #include <vm/vm.h>
     42  1.2   thorpej 
     43  1.2   thorpej #include <machine/bus.h>
     44  1.2   thorpej #include <machine/intr.h>
     45  1.2   thorpej 
     46  1.2   thorpej #include <dev/isa/isareg.h>
     47  1.2   thorpej #include <dev/isa/isavar.h>
     48  1.2   thorpej 
     49  1.2   thorpej #include <dev/pcmcia/pcmciareg.h>
     50  1.2   thorpej #include <dev/pcmcia/pcmciavar.h>
     51  1.2   thorpej #include <dev/pcmcia/pcmciachip.h>
     52  1.2   thorpej 
     53  1.2   thorpej #include <dev/ic/i82365reg.h>
     54  1.2   thorpej #include <dev/ic/i82365var.h>
     55  1.2   thorpej 
     56  1.6   thorpej /*****************************************************************************
     57  1.6   thorpej  * Configurable parameters.
     58  1.6   thorpej  *****************************************************************************/
     59  1.6   thorpej 
     60  1.6   thorpej #include "opt_pcic_isa_alloc_iobase.h"
     61  1.6   thorpej #include "opt_pcic_isa_alloc_iosize.h"
     62  1.6   thorpej #include "opt_pcic_isa_intr_alloc_mask.h"
     63  1.6   thorpej 
     64  1.6   thorpej /*
     65  1.6   thorpej  * Default I/O allocation range.  If both are set to non-zero, these
     66  1.6   thorpej  * values will be used instead.  Otherwise, the code attempts to probe
     67  1.6   thorpej  * the bus width.  Systems with 10 address bits should use 0x300 and 0xff.
     68  1.6   thorpej  * Systems with 12 address bits (most) should use 0x400 and 0xbff.
     69  1.6   thorpej  */
     70  1.6   thorpej 
     71  1.6   thorpej #ifndef PCIC_ISA_ALLOC_IOBASE
     72  1.6   thorpej #define	PCIC_ISA_ALLOC_IOBASE		0
     73  1.6   thorpej #endif
     74  1.6   thorpej 
     75  1.6   thorpej #ifndef PCIC_ISA_ALLOC_IOSIZE
     76  1.6   thorpej #define	PCIC_ISA_ALLOC_IOSIZE		0
     77  1.6   thorpej #endif
     78  1.6   thorpej 
     79  1.6   thorpej int	pcic_isa_alloc_iobase = PCIC_ISA_ALLOC_IOBASE;
     80  1.6   thorpej int	pcic_isa_alloc_iosize = PCIC_ISA_ALLOC_IOSIZE;
     81  1.6   thorpej 
     82  1.6   thorpej /*
     83  1.6   thorpej  * Default IRQ allocation bitmask.  This defines the range of allowable
     84  1.6   thorpej  * IRQs for PCMCIA slots.  Useful if order of probing would screw up other
     85  1.6   thorpej  * devices, or if PCIC hardware/cards have trouble with certain interrupt
     86  1.6   thorpej  * lines.
     87  1.6   thorpej  *
     88  1.6   thorpej  * We disable IRQ 10 by default, since some common laptops (namely, the
     89  1.6   thorpej  * NEC Versa series) reserve IRQ 10 for the docking station SCSI interface.
     90  1.6   thorpej  */
     91  1.6   thorpej 
     92  1.6   thorpej #ifndef PCIC_ISA_INTR_ALLOC_MASK
     93  1.6   thorpej #define	PCIC_ISA_INTR_ALLOC_MASK	0xfbff
     94  1.6   thorpej #endif
     95  1.6   thorpej 
     96  1.6   thorpej int	pcic_isa_intr_alloc_mask = PCIC_ISA_INTR_ALLOC_MASK;
     97  1.6   thorpej 
     98  1.6   thorpej /*****************************************************************************
     99  1.6   thorpej  * End of configurable parameters.
    100  1.6   thorpej  *****************************************************************************/
    101  1.6   thorpej 
    102  1.2   thorpej #ifdef PCICISADEBUG
    103  1.2   thorpej int	pcicisa_debug = 0 /* XXX */ ;
    104  1.2   thorpej #define	DPRINTF(arg) if (pcicisa_debug) printf arg;
    105  1.2   thorpej #else
    106  1.2   thorpej #define	DPRINTF(arg)
    107  1.2   thorpej #endif
    108  1.2   thorpej 
    109  1.8  drochner #ifdef __BROKEN_INDIRECT_CONFIG
    110  1.2   thorpej int	pcic_isa_probe __P((struct device *, void *, void *));
    111  1.8  drochner #else
    112  1.8  drochner int	pcic_isa_probe __P((struct device *, struct cfdata *, void *));
    113  1.8  drochner #endif
    114  1.2   thorpej void	pcic_isa_attach __P((struct device *, struct device *, void *));
    115  1.2   thorpej 
    116  1.2   thorpej void	*pcic_isa_chip_intr_establish __P((pcmcia_chipset_handle_t,
    117  1.2   thorpej 	    struct pcmcia_function *, int, int (*) (void *), void *));
    118  1.2   thorpej void	pcic_isa_chip_intr_disestablish __P((pcmcia_chipset_handle_t, void *));
    119  1.2   thorpej 
    120  1.2   thorpej struct cfattach pcic_isa_ca = {
    121  1.2   thorpej 	sizeof(struct pcic_softc), pcic_isa_probe, pcic_isa_attach
    122  1.2   thorpej };
    123  1.2   thorpej 
    124  1.2   thorpej static struct pcmcia_chip_functions pcic_isa_functions = {
    125  1.2   thorpej 	pcic_chip_mem_alloc,
    126  1.2   thorpej 	pcic_chip_mem_free,
    127  1.2   thorpej 	pcic_chip_mem_map,
    128  1.2   thorpej 	pcic_chip_mem_unmap,
    129  1.2   thorpej 
    130  1.2   thorpej 	pcic_chip_io_alloc,
    131  1.2   thorpej 	pcic_chip_io_free,
    132  1.2   thorpej 	pcic_chip_io_map,
    133  1.2   thorpej 	pcic_chip_io_unmap,
    134  1.2   thorpej 
    135  1.2   thorpej 	pcic_isa_chip_intr_establish,
    136  1.2   thorpej 	pcic_isa_chip_intr_disestablish,
    137  1.2   thorpej 
    138  1.2   thorpej 	pcic_chip_socket_enable,
    139  1.2   thorpej 	pcic_chip_socket_disable,
    140  1.2   thorpej };
    141  1.2   thorpej 
    142  1.2   thorpej int
    143  1.2   thorpej pcic_isa_probe(parent, match, aux)
    144  1.2   thorpej 	struct device *parent;
    145  1.8  drochner #ifdef __BROKEN_INDIRECT_CONFIG
    146  1.8  drochner 	void *match;
    147  1.8  drochner #else
    148  1.8  drochner 	struct cfdata *match;
    149  1.8  drochner #endif
    150  1.8  drochner 	void *aux;
    151  1.2   thorpej {
    152  1.2   thorpej 	struct isa_attach_args *ia = aux;
    153  1.2   thorpej 	bus_space_tag_t iot = ia->ia_iot;
    154  1.2   thorpej 	bus_space_handle_t ioh, memh;
    155  1.2   thorpej 	int val, found;
    156  1.3   thorpej 
    157  1.3   thorpej 	/* Disallow wildcarded i/o address. */
    158  1.3   thorpej 	if (ia->ia_iobase == ISACF_PORT_DEFAULT)
    159  1.3   thorpej 		return (0);
    160  1.2   thorpej 
    161  1.2   thorpej 	if (bus_space_map(iot, ia->ia_iobase, PCIC_IOSIZE, 0, &ioh))
    162  1.2   thorpej 		return (0);
    163  1.2   thorpej 
    164  1.2   thorpej 	if (ia->ia_msize == -1)
    165  1.2   thorpej 		ia->ia_msize = PCIC_MEMSIZE;
    166  1.2   thorpej 
    167  1.2   thorpej 	if (bus_space_map(ia->ia_memt, ia->ia_maddr, ia->ia_msize, 0, &memh))
    168  1.2   thorpej 		return (0);
    169  1.2   thorpej 
    170  1.2   thorpej 	found = 0;
    171  1.2   thorpej 
    172  1.2   thorpej 	/*
    173  1.2   thorpej 	 * this could be done with a loop, but it would violate the
    174  1.2   thorpej 	 * abstraction
    175  1.2   thorpej 	 */
    176  1.2   thorpej 
    177  1.2   thorpej 	bus_space_write_1(iot, ioh, PCIC_REG_INDEX, C0SA + PCIC_IDENT);
    178  1.2   thorpej 
    179  1.2   thorpej 	val = bus_space_read_1(iot, ioh, PCIC_REG_DATA);
    180  1.2   thorpej 
    181  1.2   thorpej 	if (pcic_ident_ok(val))
    182  1.2   thorpej 		found++;
    183  1.2   thorpej 
    184  1.2   thorpej 
    185  1.2   thorpej 	bus_space_write_1(iot, ioh, PCIC_REG_INDEX, C0SB + PCIC_IDENT);
    186  1.2   thorpej 
    187  1.2   thorpej 	val = bus_space_read_1(iot, ioh, PCIC_REG_DATA);
    188  1.2   thorpej 
    189  1.2   thorpej 	if (pcic_ident_ok(val))
    190  1.2   thorpej 		found++;
    191  1.2   thorpej 
    192  1.2   thorpej 
    193  1.2   thorpej 	bus_space_write_1(iot, ioh, PCIC_REG_INDEX, C1SA + PCIC_IDENT);
    194  1.2   thorpej 
    195  1.2   thorpej 	val = bus_space_read_1(iot, ioh, PCIC_REG_DATA);
    196  1.2   thorpej 
    197  1.2   thorpej 	if (pcic_ident_ok(val))
    198  1.2   thorpej 		found++;
    199  1.2   thorpej 
    200  1.2   thorpej 
    201  1.2   thorpej 	bus_space_write_1(iot, ioh, PCIC_REG_INDEX, C1SB + PCIC_IDENT);
    202  1.2   thorpej 
    203  1.2   thorpej 	val = bus_space_read_1(iot, ioh, PCIC_REG_DATA);
    204  1.2   thorpej 
    205  1.2   thorpej 	if (pcic_ident_ok(val))
    206  1.2   thorpej 		found++;
    207  1.2   thorpej 
    208  1.2   thorpej 
    209  1.2   thorpej 	bus_space_unmap(iot, ioh, PCIC_IOSIZE);
    210  1.2   thorpej 	bus_space_unmap(ia->ia_memt, memh, ia->ia_msize);
    211  1.2   thorpej 
    212  1.2   thorpej 	if (!found)
    213  1.2   thorpej 		return (0);
    214  1.2   thorpej 
    215  1.2   thorpej 	ia->ia_iosize = PCIC_IOSIZE;
    216  1.2   thorpej 
    217  1.2   thorpej 	return (1);
    218  1.2   thorpej }
    219  1.2   thorpej 
    220  1.2   thorpej void
    221  1.2   thorpej pcic_isa_attach(parent, self, aux)
    222  1.2   thorpej 	struct device *parent, *self;
    223  1.2   thorpej 	void *aux;
    224  1.2   thorpej {
    225  1.2   thorpej 	struct pcic_softc *sc = (void *) self;
    226  1.2   thorpej 	struct isa_attach_args *ia = aux;
    227  1.2   thorpej 	isa_chipset_tag_t ic = ia->ia_ic;
    228  1.2   thorpej 	bus_space_tag_t iot = ia->ia_iot;
    229  1.2   thorpej 	bus_space_tag_t memt = ia->ia_memt;
    230  1.2   thorpej 	bus_space_handle_t ioh;
    231  1.2   thorpej 	bus_space_handle_t memh;
    232  1.2   thorpej 	bus_space_handle_t ioh_high;
    233  1.2   thorpej 	int i, iobuswidth, tmp1, tmp2;
    234  1.2   thorpej 
    235  1.2   thorpej 	/* Map i/o space. */
    236  1.4   thorpej 	if (bus_space_map(iot, ia->ia_iobase, ia->ia_iosize, 0, &ioh)) {
    237  1.4   thorpej 		printf(": can't map i/o space\n");
    238  1.4   thorpej 		return;
    239  1.4   thorpej 	}
    240  1.2   thorpej 
    241  1.2   thorpej 	/* Map mem space. */
    242  1.4   thorpej 	if (bus_space_map(memt, ia->ia_maddr, ia->ia_msize, 0, &memh)) {
    243  1.4   thorpej 		printf(": can't map mem space\n");
    244  1.4   thorpej 		return;
    245  1.4   thorpej 	}
    246  1.2   thorpej 
    247  1.2   thorpej 	sc->membase = ia->ia_maddr;
    248  1.2   thorpej 	sc->subregionmask = (1 << (ia->ia_msize / PCIC_MEM_PAGESIZE)) - 1;
    249  1.2   thorpej 
    250  1.2   thorpej 	sc->intr_est = ic;
    251  1.2   thorpej 	sc->pct = (pcmcia_chipset_tag_t) & pcic_isa_functions;
    252  1.2   thorpej 
    253  1.2   thorpej 	sc->iot = iot;
    254  1.2   thorpej 	sc->ioh = ioh;
    255  1.2   thorpej 	sc->memt = memt;
    256  1.2   thorpej 	sc->memh = memh;
    257  1.2   thorpej 
    258  1.2   thorpej 	/*
    259  1.2   thorpej 	 * allocate an irq.  it will be used by both controllers.  I could
    260  1.2   thorpej 	 * use two different interrupts, but interrupts are relatively
    261  1.2   thorpej 	 * scarce, shareable, and for PCIC controllers, very infrequent.
    262  1.2   thorpej 	 */
    263  1.2   thorpej 
    264  1.2   thorpej 	if ((sc->irq = ia->ia_irq) == IRQUNK) {
    265  1.6   thorpej 		if (isa_intr_alloc(ic,
    266  1.6   thorpej 		    PCIC_CSC_INTR_IRQ_VALIDMASK & pcic_isa_intr_alloc_mask,
    267  1.6   thorpej 		    IST_EDGE, &sc->irq)) {
    268  1.6   thorpej 			printf("\n%s: can't allocate interrupt\n",
    269  1.6   thorpej 			    sc->dev.dv_xname);
    270  1.6   thorpej 			return;
    271  1.6   thorpej 		}
    272  1.2   thorpej 		printf(": using irq %d", sc->irq);
    273  1.2   thorpej 	}
    274  1.2   thorpej 	printf("\n");
    275  1.2   thorpej 
    276  1.2   thorpej 	pcic_attach(sc);
    277  1.2   thorpej 
    278  1.2   thorpej 	/*
    279  1.2   thorpej 	 * figure out how wide the isa bus is.  Do this by checking if the
    280  1.2   thorpej 	 * pcic controller is mirrored 0x400 above where we expect it to be.
    281  1.2   thorpej 	 */
    282  1.2   thorpej 
    283  1.2   thorpej 	iobuswidth = 12;
    284  1.2   thorpej 
    285  1.2   thorpej 	/* Map i/o space. */
    286  1.2   thorpej 	if (bus_space_map(iot, ia->ia_iobase + 0x400, ia->ia_iosize, 0,
    287  1.4   thorpej 	    &ioh_high)) {
    288  1.4   thorpej 		printf("%s: can't map high i/o space\n", sc->dev.dv_xname);
    289  1.4   thorpej 		return;
    290  1.4   thorpej 	}
    291  1.2   thorpej 
    292  1.2   thorpej 	for (i = 0; i < PCIC_NSLOTS; i++) {
    293  1.2   thorpej 		if (sc->handle[i].flags & PCIC_FLAG_SOCKETP) {
    294  1.2   thorpej 			/*
    295  1.2   thorpej 			 * read the ident flags from the normal space and
    296  1.2   thorpej 			 * from the mirror, and compare them
    297  1.2   thorpej 			 */
    298  1.2   thorpej 
    299  1.2   thorpej 			bus_space_write_1(iot, ioh, PCIC_REG_INDEX,
    300  1.2   thorpej 			    sc->handle[i].sock + PCIC_IDENT);
    301  1.2   thorpej 			tmp1 = bus_space_read_1(iot, ioh, PCIC_REG_DATA);
    302  1.2   thorpej 
    303  1.2   thorpej 			bus_space_write_1(iot, ioh_high, PCIC_REG_INDEX,
    304  1.2   thorpej 			    sc->handle[i].sock + PCIC_IDENT);
    305  1.2   thorpej 			tmp2 = bus_space_read_1(iot, ioh_high, PCIC_REG_DATA);
    306  1.2   thorpej 
    307  1.2   thorpej 			if (tmp1 == tmp2)
    308  1.2   thorpej 				iobuswidth = 10;
    309  1.2   thorpej 		}
    310  1.2   thorpej 	}
    311  1.2   thorpej 
    312  1.2   thorpej 	bus_space_free(iot, ioh_high, ia->ia_iosize);
    313  1.2   thorpej 
    314  1.2   thorpej 	/*
    315  1.2   thorpej 	 * XXX mycroft recommends I/O space range 0x400-0xfff .  I should put
    316  1.2   thorpej 	 * this in a header somewhere
    317  1.2   thorpej 	 */
    318  1.2   thorpej 
    319  1.2   thorpej 	/*
    320  1.2   thorpej 	 * XXX some hardware doesn't seem to grok addresses in 0x400 range--
    321  1.2   thorpej 	 * apparently missing a bit or more of address lines. (e.g.
    322  1.2   thorpej 	 * CIRRUS_PD672X with Linksys EthernetCard ne2000 clone in TI
    323  1.2   thorpej 	 * TravelMate 5000--not clear which is at fault)
    324  1.2   thorpej 	 *
    325  1.2   thorpej 	 * Add a kludge to detect 10 bit wide buses and deal with them,
    326  1.2   thorpej 	 * and also a config file option to override the probe.
    327  1.2   thorpej 	 */
    328  1.2   thorpej 
    329  1.2   thorpej 	if (iobuswidth == 10) {
    330  1.2   thorpej 		sc->iobase = 0x300;
    331  1.2   thorpej 		sc->iosize = 0x0ff;
    332  1.2   thorpej 	} else {
    333  1.7   thorpej #if 0
    334  1.7   thorpej 		/*
    335  1.7   thorpej 		 * This is what we'd like to use, but...
    336  1.7   thorpej 		 */
    337  1.2   thorpej 		sc->iobase = 0x400;
    338  1.2   thorpej 		sc->iosize = 0xbff;
    339  1.7   thorpej #else
    340  1.7   thorpej 		/*
    341  1.7   thorpej 		 * ...the above bus width probe doesn't always work.
    342  1.7   thorpej 		 * So, experimentation has shown the following range
    343  1.7   thorpej 		 * to not lose on systems that 0x300-0x3ff loses on
    344  1.7   thorpej 		 * (e.g. the NEC Versa 6030X).
    345  1.7   thorpej 		 */
    346  1.7   thorpej 		sc->iobase = 0x330;
    347  1.7   thorpej 		sc->iosize = 0x0cf;
    348  1.7   thorpej #endif
    349  1.2   thorpej 	}
    350  1.2   thorpej 
    351  1.2   thorpej 	DPRINTF(("%s: bus_space_alloc range 0x%04lx-0x%04lx (probed)\n",
    352  1.2   thorpej 	    sc->dev.dv_xname, (long) sc->iobase,
    353  1.2   thorpej 	    (long) sc->iobase + sc->iosize));
    354  1.2   thorpej 
    355  1.2   thorpej 	if (pcic_isa_alloc_iobase && pcic_isa_alloc_iosize) {
    356  1.2   thorpej 		sc->iobase = pcic_isa_alloc_iobase;
    357  1.2   thorpej 		sc->iosize = pcic_isa_alloc_iosize;
    358  1.2   thorpej 
    359  1.2   thorpej 		DPRINTF(("%s: bus_space_alloc range 0x%04lx-0x%04lx "
    360  1.2   thorpej 		    "(config override)\n", sc->dev.dv_xname, (long) sc->iobase,
    361  1.2   thorpej 		    (long) sc->iobase + sc->iosize));
    362  1.2   thorpej 	}
    363  1.2   thorpej 	sc->ih = isa_intr_establish(ic, sc->irq, IST_EDGE, IPL_TTY,
    364  1.2   thorpej 	    pcic_intr, sc);
    365  1.6   thorpej 	if (sc->ih == NULL) {
    366  1.6   thorpej 		printf("%s: can't establish interrupt\n", sc->dev.dv_xname);
    367  1.6   thorpej 		return;
    368  1.6   thorpej 	}
    369  1.2   thorpej 
    370  1.2   thorpej 	pcic_attach_sockets(sc);
    371  1.2   thorpej }
    372  1.2   thorpej 
    373  1.2   thorpej void *
    374  1.2   thorpej pcic_isa_chip_intr_establish(pch, pf, ipl, fct, arg)
    375  1.2   thorpej 	pcmcia_chipset_handle_t pch;
    376  1.2   thorpej 	struct pcmcia_function *pf;
    377  1.2   thorpej 	int ipl;
    378  1.2   thorpej 	int (*fct) __P((void *));
    379  1.2   thorpej 	void *arg;
    380  1.2   thorpej {
    381  1.2   thorpej 	struct pcic_handle *h = (struct pcic_handle *) pch;
    382  1.2   thorpej 	int irq, ist;
    383  1.2   thorpej 	void *ih;
    384  1.2   thorpej 	int reg;
    385  1.2   thorpej 
    386  1.2   thorpej 	if (pf->cfe->flags & PCMCIA_CFE_IRQLEVEL)
    387  1.2   thorpej 		ist = IST_LEVEL;
    388  1.2   thorpej 	else if (pf->cfe->flags & PCMCIA_CFE_IRQPULSE)
    389  1.2   thorpej 		ist = IST_PULSE;
    390  1.2   thorpej 	else
    391  1.2   thorpej 		ist = IST_LEVEL;
    392  1.2   thorpej 
    393  1.2   thorpej 	if (isa_intr_alloc(h->sc->intr_est,
    394  1.6   thorpej 	    PCIC_INTR_IRQ_VALIDMASK & pcic_isa_intr_alloc_mask, ist, &irq))
    395  1.2   thorpej 		return (NULL);
    396  1.2   thorpej 	if ((ih = isa_intr_establish(h->sc->intr_est, irq, ist, ipl,
    397  1.2   thorpej 	    fct, arg)) == NULL)
    398  1.2   thorpej 		return (NULL);
    399  1.2   thorpej 
    400  1.2   thorpej 	reg = pcic_read(h, PCIC_INTR);
    401  1.2   thorpej 	reg &= ~PCIC_INTR_IRQ_MASK;
    402  1.2   thorpej 	reg |= irq;
    403  1.2   thorpej 	pcic_write(h, PCIC_INTR, reg);
    404  1.2   thorpej 
    405  1.2   thorpej 	h->ih_irq = irq;
    406  1.2   thorpej 
    407  1.2   thorpej 	printf("%s: card irq %d\n", h->pcmcia->dv_xname, irq);
    408  1.2   thorpej 
    409  1.2   thorpej 	return (ih);
    410  1.2   thorpej }
    411  1.2   thorpej 
    412  1.2   thorpej void
    413  1.2   thorpej pcic_isa_chip_intr_disestablish(pch, ih)
    414  1.2   thorpej 	pcmcia_chipset_handle_t pch;
    415  1.2   thorpej 	void *ih;
    416  1.2   thorpej {
    417  1.2   thorpej 	struct pcic_handle *h = (struct pcic_handle *) pch;
    418  1.2   thorpej 	int reg;
    419  1.2   thorpej 
    420  1.2   thorpej 	h->ih_irq = 0;
    421  1.2   thorpej 
    422  1.2   thorpej 	reg = pcic_read(h, PCIC_INTR);
    423  1.2   thorpej 	reg &= ~(PCIC_INTR_IRQ_MASK | PCIC_INTR_ENABLE);
    424  1.2   thorpej 	pcic_write(h, PCIC_INTR, reg);
    425  1.2   thorpej 
    426  1.2   thorpej 	isa_intr_disestablish(h->sc->intr_est, ih);
    427  1.2   thorpej }
    428