Home | History | Annotate | Line # | Download | only in gdium
gdium_intr.c revision 1.2
      1  1.2  matt /*	$NetBSD: gdium_intr.c,v 1.2 2009/08/07 01:27:14 matt Exp $	*/
      2  1.1  matt 
      3  1.1  matt /*-
      4  1.1  matt  * Copyright (c) 2001 The NetBSD Foundation, Inc.
      5  1.1  matt  * All rights reserved.
      6  1.1  matt  *
      7  1.1  matt  * This code is derived from software contributed to The NetBSD Foundation
      8  1.1  matt  * by Jason R. Thorpe.
      9  1.1  matt  *
     10  1.1  matt  * Redistribution and use in source and binary forms, with or without
     11  1.1  matt  * modification, are permitted provided that the following conditions
     12  1.1  matt  * are met:
     13  1.1  matt  * 1. Redistributions of source code must retain the above copyright
     14  1.1  matt  *    notice, this list of conditions and the following disclaimer.
     15  1.1  matt  * 2. Redistributions in binary form must reproduce the above copyright
     16  1.1  matt  *    notice, this list of conditions and the following disclaimer in the
     17  1.1  matt  *    documentation and/or other materials provided with the distribution.
     18  1.1  matt  *
     19  1.1  matt  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20  1.1  matt  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21  1.1  matt  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22  1.1  matt  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23  1.1  matt  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24  1.1  matt  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25  1.1  matt  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26  1.1  matt  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27  1.1  matt  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28  1.1  matt  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29  1.1  matt  * POSSIBILITY OF SUCH DAMAGE.
     30  1.1  matt  */
     31  1.1  matt 
     32  1.1  matt /*
     33  1.1  matt  * Platform-specific interrupt support for the Algorithmics P-6032.
     34  1.1  matt  *
     35  1.1  matt  * The Algorithmics P-6032's interrupts are wired to GPIO pins
     36  1.1  matt  * on the BONITO system controller.
     37  1.1  matt  */
     38  1.1  matt 
     39  1.1  matt #include <sys/cdefs.h>
     40  1.2  matt __KERNEL_RCSID(0, "$NetBSD: gdium_intr.c,v 1.2 2009/08/07 01:27:14 matt Exp $");
     41  1.1  matt 
     42  1.1  matt #include "opt_ddb.h"
     43  1.1  matt 
     44  1.1  matt #include <sys/param.h>
     45  1.1  matt #include <sys/queue.h>
     46  1.1  matt #include <sys/malloc.h>
     47  1.1  matt #include <sys/systm.h>
     48  1.1  matt #include <sys/device.h>
     49  1.1  matt #include <sys/kernel.h>
     50  1.1  matt #include <sys/cpu.h>
     51  1.1  matt 
     52  1.1  matt #include <machine/bus.h>
     53  1.1  matt #include <machine/intr.h>
     54  1.1  matt 
     55  1.1  matt #include <mips/locore.h>
     56  1.1  matt 
     57  1.1  matt #include <mips/bonito/bonitoreg.h>
     58  1.1  matt #include <evbmips/gdium/gdiumvar.h>
     59  1.1  matt 
     60  1.1  matt #include <dev/pci/pcireg.h>
     61  1.1  matt #include <dev/pci/pcivar.h>
     62  1.1  matt 
     63  1.1  matt /*
     64  1.1  matt  * The GDIUM interrupts are wired up in the following way:
     65  1.1  matt  *
     66  1.1  matt  *	GPIN0		ISA_NMI		(in)
     67  1.1  matt  *	GPIN1		ISA_INTR	(in)
     68  1.1  matt  *	GPIN2		ETH_INT~	(in)
     69  1.1  matt  *	GPIN3		BONIDE_INT	(in)
     70  1.1  matt  *
     71  1.1  matt  *	PCI_INTA
     72  1.1  matt  *	GPIN4		ISA IRQ3	(in, also on piix4)
     73  1.1  matt  *	GPIN5		ISA IRQ4	(in, also on piix4)
     74  1.1  matt  *
     75  1.1  matt  *	GPIO0		PIRQ A~		(in)
     76  1.1  matt  *	GPIO1		PIRQ B~		(in)
     77  1.1  matt  *	GPIO2		PIRQ C~		(in)
     78  1.1  matt  *	GPIO3		PIRQ D~		(in)
     79  1.1  matt  */
     80  1.1  matt 
     81  1.1  matt struct gdium_irqmap {
     82  1.1  matt 	const char *name;
     83  1.1  matt 	uint8_t	irqidx;
     84  1.1  matt 	uint8_t	flags;
     85  1.1  matt };
     86  1.1  matt 
     87  1.1  matt #define	IRQ_F_INVERT	0x80	/* invert polarity */
     88  1.1  matt #define	IRQ_F_EDGE	0x40	/* edge trigger */
     89  1.1  matt #define	IRQ_F_INT0	0x00	/* INT0 */
     90  1.1  matt #define	IRQ_F_INT1	0x01	/* INT1 */
     91  1.1  matt #define	IRQ_F_INT2	0x02	/* INT2 */
     92  1.1  matt #define	IRQ_F_INT3	0x03	/* INT3 */
     93  1.1  matt #define	IRQ_F_INTMASK	0x07	/* INT mask */
     94  1.1  matt 
     95  1.1  matt const struct gdium_irqmap gdium_irqmap[] = {
     96  1.1  matt 	{ "gpio0",	GDIUM_IRQ_GPIO0,	IRQ_F_INT0 },
     97  1.1  matt 	{ "gpio1",	GDIUM_IRQ_GPIO1,	IRQ_F_INT0 },
     98  1.1  matt 	{ "gpio2",	GDIUM_IRQ_GPIO2,	IRQ_F_INT0 },
     99  1.1  matt 	{ "gpio3",	GDIUM_IRQ_GPIO3,	IRQ_F_INT0 },
    100  1.1  matt 
    101  1.1  matt 	{ "pci inta",	GDIUM_IRQ_PCI_INTA,	IRQ_F_INT0 },
    102  1.1  matt 	{ "pci intb",	GDIUM_IRQ_PCI_INTB,	IRQ_F_INT0 },
    103  1.1  matt 	{ "pci intc",	GDIUM_IRQ_PCI_INTC,	IRQ_F_INT0 },
    104  1.1  matt 	{ "pci intd",	GDIUM_IRQ_PCI_INTD,	IRQ_F_INT0 },
    105  1.1  matt 
    106  1.1  matt 	{ "pci perr",	GDIUM_IRQ_PCI_PERR,	IRQ_F_EDGE|IRQ_F_INT1 },
    107  1.1  matt 	{ "pci serr",	GDIUM_IRQ_PCI_SERR,	IRQ_F_EDGE|IRQ_F_INT1 },
    108  1.1  matt 
    109  1.1  matt 	{ "denali",	GDIUM_IRQ_DENALI,	IRQ_F_INT1 },
    110  1.1  matt 
    111  1.2  matt 	{ "mips int0",	GDIUM_IRQ_INT0,		IRQ_F_INT0 },
    112  1.2  matt 	{ "mips int1",	GDIUM_IRQ_INT1,		IRQ_F_INT1 },
    113  1.2  matt 	{ "mips int2",	GDIUM_IRQ_INT2,		IRQ_F_INT2 },
    114  1.2  matt 	{ "mips int3",	GDIUM_IRQ_INT3,		IRQ_F_INT3 },
    115  1.1  matt };
    116  1.1  matt 
    117  1.1  matt struct gdium_intrhead {
    118  1.1  matt 	struct evcnt intr_count;
    119  1.1  matt 	int intr_refcnt;
    120  1.1  matt };
    121  1.1  matt struct gdium_intrhead gdium_intrtab[__arraycount(gdium_irqmap)];
    122  1.1  matt 
    123  1.1  matt #define	NINTRS			2	/* MIPS INT0 - INT1 */
    124  1.1  matt 
    125  1.1  matt struct gdium_cpuintr {
    126  1.1  matt 	LIST_HEAD(, evbmips_intrhand) cintr_list;
    127  1.1  matt 	struct evcnt cintr_count;
    128  1.2  matt 	int cintr_refcnt;
    129  1.1  matt };
    130  1.1  matt 
    131  1.1  matt struct gdium_cpuintr gdium_cpuintrs[NINTRS];
    132  1.1  matt const char *gdium_cpuintrnames[NINTRS] = {
    133  1.1  matt 	"int 0 (pci)",
    134  1.2  matt 	"int 1 (errors)",
    135  1.1  matt };
    136  1.1  matt 
    137  1.1  matt /*
    138  1.1  matt  * This is a mask of bits to clear in the SR when we go to a
    139  1.1  matt  * given hardware interrupt priority level.
    140  1.1  matt  */
    141  1.1  matt const uint32_t ipl_sr_bits[_IPL_N] = {
    142  1.1  matt 	[IPL_NONE] = 0,
    143  1.1  matt 	[IPL_SOFTCLOCK] =
    144  1.1  matt 	    MIPS_SOFT_INT_MASK_0,
    145  1.2  matt #if IPL_SOFTCLOCK != IPL_SOFTBIO
    146  1.2  matt 	[IPL_SOFTBIO] =
    147  1.2  matt 	    MIPS_SOFT_INT_MASK_0,
    148  1.2  matt #endif
    149  1.1  matt 	[IPL_SOFTNET] =
    150  1.1  matt 	    MIPS_SOFT_INT_MASK_0 | MIPS_SOFT_INT_MASK_1,
    151  1.2  matt #if IPL_SOFTNET != IPL_SOFTSERIAL
    152  1.2  matt 	[IPL_SOFTSERIAL] =
    153  1.2  matt 	    MIPS_SOFT_INT_MASK_0 | MIPS_SOFT_INT_MASK_1,
    154  1.2  matt #endif
    155  1.1  matt 	[IPL_VM] =
    156  1.1  matt 	    MIPS_SOFT_INT_MASK_0 | MIPS_SOFT_INT_MASK_1 |
    157  1.2  matt 	    MIPS_INT_MASK_0 |
    158  1.2  matt 	    MIPS_INT_MASK_1 |
    159  1.2  matt 	    MIPS_INT_MASK_2 |
    160  1.2  matt 	    MIPS_INT_MASK_3 |
    161  1.2  matt 	    MIPS_INT_MASK_4,
    162  1.1  matt 	[IPL_SCHED] =
    163  1.1  matt 	    MIPS_SOFT_INT_MASK_0 | MIPS_SOFT_INT_MASK_1 |
    164  1.1  matt 	    MIPS_INT_MASK_0 |
    165  1.1  matt 	    MIPS_INT_MASK_1 |
    166  1.1  matt 	    MIPS_INT_MASK_2 |
    167  1.1  matt 	    MIPS_INT_MASK_3 |
    168  1.1  matt 	    MIPS_INT_MASK_4 |
    169  1.1  matt 	    MIPS_INT_MASK_5,
    170  1.1  matt };
    171  1.1  matt 
    172  1.1  matt /*
    173  1.1  matt  * This is a mask of bits to clear in the SR when we go to a
    174  1.1  matt  * given software interrupt priority level.
    175  1.1  matt  * Hardware ipls are port/board specific.
    176  1.1  matt  */
    177  1.2  matt const uint32_t mips_ipl_si_to_sr[] = {
    178  1.2  matt 	[IPL_SOFTCLOCK-IPL_SOFTCLOCK] = MIPS_SOFT_INT_MASK_0,
    179  1.2  matt #if IPL_SOFTCLOCK != IPL_SOFTBIO
    180  1.2  matt 	[IPL_SOFTBIO-IPL_SOFTCLOCK] = MIPS_SOFT_INT_MASK_0,
    181  1.2  matt #endif
    182  1.2  matt 	[IPL_SOFTNET-IPL_SOFTCLOCK] = MIPS_SOFT_INT_MASK_1,
    183  1.2  matt #if IPL_SOFTNET != IPL_SOFTSERIAL
    184  1.2  matt 	[IPL_SOFTSERIAL-IPL_SOFTCLOCK] = MIPS_SOFT_INT_MASK_1,
    185  1.2  matt #endif
    186  1.1  matt };
    187  1.1  matt 
    188  1.1  matt int	gdium_pci_intr_map(struct pci_attach_args *, pci_intr_handle_t *);
    189  1.1  matt const char *gdium_pci_intr_string(void *, pci_intr_handle_t);
    190  1.1  matt const struct evcnt *gdium_pci_intr_evcnt(void *, pci_intr_handle_t);
    191  1.1  matt void	*gdium_pci_intr_establish(void *, pci_intr_handle_t, int,
    192  1.1  matt 	    int (*)(void *), void *);
    193  1.1  matt void	gdium_pci_intr_disestablish(void *, void *);
    194  1.1  matt void	gdium_pci_conf_interrupt(void *, int, int, int, int, int *);
    195  1.1  matt 
    196  1.1  matt void
    197  1.1  matt evbmips_intr_init(void)
    198  1.1  matt {
    199  1.1  matt 	struct gdium_config *gc = &gdium_configuration;
    200  1.1  matt 	struct bonito_config *bc = &gc->gc_bonito;
    201  1.1  matt 	const struct gdium_irqmap *irqmap;
    202  1.1  matt 	uint32_t intbit;
    203  1.1  matt 	int i;
    204  1.1  matt 
    205  1.1  matt 	for (i = 0; i < NINTRS; i++) {
    206  1.1  matt 		LIST_INIT(&gdium_cpuintrs[i].cintr_list);
    207  1.1  matt 		evcnt_attach_dynamic(&gdium_cpuintrs[i].cintr_count,
    208  1.1  matt 		    EVCNT_TYPE_INTR, NULL, "mips", gdium_cpuintrnames[i]);
    209  1.1  matt 	}
    210  1.1  matt 	//evcnt_attach_static(&mips_int5_evcnt);
    211  1.1  matt 
    212  1.1  matt 	for (i = 0; i < __arraycount(gdium_irqmap); i++) {
    213  1.1  matt 		irqmap = &gdium_irqmap[i];
    214  1.1  matt 		intbit = 1 << irqmap->irqidx;
    215  1.1  matt 
    216  1.1  matt 		evcnt_attach_dynamic(&gdium_intrtab[i].intr_count,
    217  1.1  matt 		    EVCNT_TYPE_INTR, NULL, "bonito", irqmap->name);
    218  1.1  matt 
    219  1.1  matt 		if (irqmap->irqidx < 4)
    220  1.1  matt 			bc->bc_gpioIE |= intbit;
    221  1.1  matt 		if (irqmap->flags & IRQ_F_INVERT)
    222  1.1  matt 			bc->bc_intPol |= intbit;
    223  1.1  matt 		if (irqmap->flags & IRQ_F_EDGE)
    224  1.1  matt 			bc->bc_intEdge |= intbit;
    225  1.1  matt 		if ((irqmap->flags & IRQ_F_INTMASK) == IRQ_F_INT1)
    226  1.1  matt 			bc->bc_intSteer |= intbit;
    227  1.1  matt 
    228  1.1  matt 		REGVAL(BONITO_INTENCLR) = intbit;
    229  1.1  matt 	}
    230  1.1  matt 
    231  1.1  matt 	REGVAL(BONITO_GPIOIE) = bc->bc_gpioIE;
    232  1.1  matt 	REGVAL(BONITO_INTEDGE) = bc->bc_intEdge;
    233  1.1  matt 	REGVAL(BONITO_INTSTEER) = bc->bc_intSteer;
    234  1.1  matt 	REGVAL(BONITO_INTPOL) = bc->bc_intPol;
    235  1.1  matt 
    236  1.1  matt 	gc->gc_pc.pc_intr_v = NULL;
    237  1.1  matt 	gc->gc_pc.pc_intr_map = gdium_pci_intr_map;
    238  1.1  matt 	gc->gc_pc.pc_intr_string = gdium_pci_intr_string;
    239  1.1  matt 	gc->gc_pc.pc_intr_evcnt = gdium_pci_intr_evcnt;
    240  1.1  matt 	gc->gc_pc.pc_intr_establish = gdium_pci_intr_establish;
    241  1.1  matt 	gc->gc_pc.pc_intr_disestablish = gdium_pci_intr_disestablish;
    242  1.1  matt 	gc->gc_pc.pc_conf_interrupt = gdium_pci_conf_interrupt;
    243  1.1  matt 
    244  1.1  matt 	/* We let the PCI-ISA bridge code handle this. */
    245  1.1  matt 	gc->gc_pc.pc_pciide_compat_intr_establish = NULL;
    246  1.1  matt }
    247  1.1  matt 
    248  1.1  matt void *
    249  1.2  matt evbmips_intr_establish(int irq, int (*func)(void *), void *arg)
    250  1.1  matt {
    251  1.1  matt 	const struct gdium_irqmap *irqmap;
    252  1.1  matt 	struct evbmips_intrhand *ih;
    253  1.2  matt 	int level;
    254  1.1  matt 	int s;
    255  1.1  matt 
    256  1.1  matt 	irqmap = &gdium_irqmap[irq];
    257  1.1  matt 	KASSERT(irq < __arraycount(gdium_irqmap));
    258  1.1  matt 
    259  1.1  matt 	KASSERT(irq == irqmap->irqidx);
    260  1.1  matt 
    261  1.1  matt 	ih = malloc(sizeof(*ih), M_DEVBUF, M_NOWAIT|M_ZERO);
    262  1.1  matt 	if (ih == NULL)
    263  1.2  matt 		return NULL;
    264  1.1  matt 
    265  1.1  matt 	ih->ih_func = func;
    266  1.1  matt 	ih->ih_arg = arg;
    267  1.1  matt 	ih->ih_irq = irq;
    268  1.1  matt 
    269  1.1  matt 	s = splhigh();
    270  1.1  matt 
    271  1.1  matt 	/*
    272  1.1  matt 	 * First, link it into the tables.
    273  1.1  matt 	 */
    274  1.2  matt 	level = (irqmap->flags & IRQ_F_INT1) != 0;
    275  1.2  matt 	LIST_INSERT_HEAD(&gdium_cpuintrs[level].cintr_list, ih, ih_q);
    276  1.2  matt 	gdium_cpuintrs[level].cintr_refcnt++;
    277  1.1  matt 
    278  1.1  matt 	/*
    279  1.1  matt 	 * Now enable it.
    280  1.1  matt 	 */
    281  1.2  matt 	if (gdium_intrtab[ih->ih_irq].intr_refcnt++ == 0)
    282  1.2  matt 		REGVAL(BONITO_INTENSET) = (1 << ih->ih_irq);
    283  1.1  matt 
    284  1.1  matt 	splx(s);
    285  1.1  matt 
    286  1.1  matt 	return (ih);
    287  1.1  matt }
    288  1.1  matt 
    289  1.1  matt void
    290  1.2  matt evbmips_intr_disestablish(void *cookie)
    291  1.1  matt {
    292  1.1  matt 	const struct gdium_irqmap *irqmap;
    293  1.1  matt 	struct evbmips_intrhand *ih = cookie;
    294  1.1  matt 	int s;
    295  1.1  matt 
    296  1.1  matt 	irqmap = &gdium_irqmap[ih->ih_irq];
    297  1.1  matt 
    298  1.1  matt 	s = splhigh();
    299  1.1  matt 
    300  1.1  matt 	/*
    301  1.1  matt 	 * First, remove it from the table.
    302  1.1  matt 	 */
    303  1.1  matt 	LIST_REMOVE(ih, ih_q);
    304  1.2  matt 	gdium_cpuintrs[(irqmap->flags & IRQ_F_INT1) != 0].cintr_refcnt--;
    305  1.1  matt 
    306  1.1  matt 	/*
    307  1.1  matt 	 * Now, disable it, if there is nothing remaining on the
    308  1.1  matt 	 * list.
    309  1.1  matt 	 */
    310  1.2  matt 	if (gdium_intrtab[ih->ih_irq].intr_refcnt-- == 1)
    311  1.2  matt 		REGVAL(BONITO_INTENCLR) = (1 << ih->ih_irq);
    312  1.1  matt 
    313  1.1  matt 	splx(s);
    314  1.1  matt 
    315  1.1  matt 	free(ih, M_DEVBUF);
    316  1.1  matt }
    317  1.1  matt 
    318  1.1  matt void
    319  1.1  matt evbmips_iointr(uint32_t status, uint32_t cause, uint32_t pc,
    320  1.1  matt 	uint32_t ipending)
    321  1.1  matt {
    322  1.1  matt 	const struct gdium_irqmap *irqmap;
    323  1.1  matt 	struct evbmips_intrhand *ih;
    324  1.1  matt 	int level;
    325  1.1  matt 	uint32_t isr;
    326  1.1  matt 
    327  1.1  matt 	/*
    328  1.1  matt 	 * Read the interrupt pending registers, mask them with the
    329  1.1  matt 	 * ones we have enabled, and service them in order of decreasing
    330  1.1  matt 	 * priority.
    331  1.1  matt 	 */
    332  1.1  matt 	isr = REGVAL(BONITO_INTISR) & REGVAL(BONITO_INTEN);
    333  1.1  matt 	for (level = 1; level >= 0; level--) {
    334  1.2  matt 		if ((ipending & (MIPS_INT_MASK_4 << level)) == 0)
    335  1.1  matt 			continue;
    336  1.1  matt 		gdium_cpuintrs[level].cintr_count.ev_count++;
    337  1.2  matt 		LIST_FOREACH (ih, &gdium_cpuintrs[level].cintr_list, ih_q) {
    338  1.1  matt 			irqmap = &gdium_irqmap[ih->ih_irq];
    339  1.1  matt 			if (isr & (1 << ih->ih_irq)) {
    340  1.1  matt 				gdium_intrtab[ih->ih_irq].intr_count.ev_count++;
    341  1.1  matt 				(*ih->ih_func)(ih->ih_arg);
    342  1.1  matt 			}
    343  1.1  matt 		}
    344  1.1  matt 		cause &= ~(MIPS_INT_MASK_0 << level);
    345  1.1  matt 	}
    346  1.1  matt 
    347  1.1  matt 	/* Re-enable anything that we have processed. */
    348  1.1  matt 	_splset(MIPS_SR_INT_IE | ((status & ~cause) & MIPS_HARD_INT_MASK));
    349  1.1  matt }
    350  1.1  matt 
    351  1.1  matt /*****************************************************************************
    352  1.1  matt  * PCI interrupt support
    353  1.1  matt  *****************************************************************************/
    354  1.1  matt 
    355  1.1  matt int
    356  1.1  matt gdium_pci_intr_map(struct pci_attach_args *pa,
    357  1.1  matt     pci_intr_handle_t *ihp)
    358  1.1  matt {
    359  1.1  matt 	static const int8_t pciirqmap[5/*device*/] = {
    360  1.1  matt 	    GDIUM_IRQ_PCI_INTC, /* 13: PCI 802.11 */
    361  1.1  matt 	    GDIUM_IRQ_PCI_INTA, /* 14: SM501 */
    362  1.1  matt 	    GDIUM_IRQ_PCI_INTB, /* 15: NEC USB (2 func) */
    363  1.1  matt 	    GDIUM_IRQ_PCI_INTD, /* 16: Ethernet */
    364  1.1  matt 	    GDIUM_IRQ_PCI_INTC, /* 17: NEC USB (2 func) */
    365  1.1  matt 	};
    366  1.1  matt 	pcitag_t bustag = pa->pa_intrtag;
    367  1.1  matt 	int buspin = pa->pa_intrpin;
    368  1.1  matt 	pci_chipset_tag_t pc = pa->pa_pc;
    369  1.1  matt 	int device;
    370  1.1  matt 
    371  1.1  matt 	if (buspin == 0) {
    372  1.1  matt 		/* No IRQ used. */
    373  1.1  matt 		return (1);
    374  1.1  matt 	}
    375  1.1  matt 
    376  1.1  matt 	if (buspin > 4) {
    377  1.1  matt 		printf("gdium_pci_intr_map: bad interrupt pin %d\n",
    378  1.1  matt 		    buspin);
    379  1.1  matt 		return (1);
    380  1.1  matt 	}
    381  1.1  matt 
    382  1.1  matt 	pci_decompose_tag(pc, bustag, NULL, &device, NULL);
    383  1.1  matt 	if (device < 13 || device > 17) {
    384  1.1  matt 		printf("gdium_pci_intr_map: bad device %d\n",
    385  1.1  matt 		    device);
    386  1.1  matt 		return (1);
    387  1.1  matt 	}
    388  1.1  matt 
    389  1.1  matt 	*ihp = pciirqmap[device - 13];
    390  1.1  matt 	return (0);
    391  1.1  matt }
    392  1.1  matt 
    393  1.1  matt const char *
    394  1.1  matt gdium_pci_intr_string(void *v, pci_intr_handle_t ih)
    395  1.1  matt {
    396  1.1  matt 
    397  1.1  matt 	if (ih >= __arraycount(gdium_irqmap))
    398  1.1  matt 		panic("gdium_intr_string: bogus IRQ %ld", ih);
    399  1.1  matt 
    400  1.1  matt 	return gdium_irqmap[ih].name;
    401  1.1  matt }
    402  1.1  matt 
    403  1.1  matt const struct evcnt *
    404  1.1  matt gdium_pci_intr_evcnt(void *v, pci_intr_handle_t ih)
    405  1.1  matt {
    406  1.1  matt 
    407  1.1  matt 	return &gdium_intrtab[ih].intr_count;
    408  1.1  matt }
    409  1.1  matt 
    410  1.1  matt void *
    411  1.1  matt gdium_pci_intr_establish(void *v, pci_intr_handle_t ih, int level,
    412  1.1  matt     int (*func)(void *), void *arg)
    413  1.1  matt {
    414  1.1  matt 
    415  1.1  matt 	if (ih >= __arraycount(gdium_irqmap))
    416  1.2  matt 		panic("gdium_pci_intr_establish: bogus IRQ %ld", ih);
    417  1.1  matt 
    418  1.2  matt 	return evbmips_intr_establish(ih, func, arg);
    419  1.1  matt }
    420  1.1  matt 
    421  1.1  matt void
    422  1.1  matt gdium_pci_intr_disestablish(void *v, void *cookie)
    423  1.1  matt {
    424  1.1  matt 
    425  1.2  matt 	return (evbmips_intr_disestablish(cookie));
    426  1.1  matt }
    427  1.1  matt 
    428  1.1  matt void
    429  1.1  matt gdium_pci_conf_interrupt(void *v, int bus, int dev, int pin, int swiz,
    430  1.1  matt     int *iline)
    431  1.1  matt {
    432  1.1  matt 
    433  1.1  matt 	/*
    434  1.1  matt 	 * We actually don't need to do anything; everything is handled
    435  1.1  matt 	 * in pci_intr_map().
    436  1.1  matt 	 */
    437  1.1  matt 	*iline = 0;
    438  1.1  matt }
    439