Home | History | Annotate | Line # | Download | only in malta
malta_intr.c revision 1.11
      1  1.11  gdamore /*	$NetBSD: malta_intr.c,v 1.11 2006/02/09 18:03:12 gdamore Exp $	*/
      2   1.1   simonb 
      3   1.1   simonb /*
      4   1.1   simonb  * Copyright 2001, 2002 Wasabi Systems, Inc.
      5   1.1   simonb  * All rights reserved.
      6   1.1   simonb  *
      7   1.1   simonb  * Written by Jason R. Thorpe and Simon Burge for Wasabi Systems, Inc.
      8   1.1   simonb  *
      9   1.1   simonb  * Redistribution and use in source and binary forms, with or without
     10   1.1   simonb  * modification, are permitted provided that the following conditions
     11   1.1   simonb  * are met:
     12   1.1   simonb  * 1. Redistributions of source code must retain the above copyright
     13   1.1   simonb  *    notice, this list of conditions and the following disclaimer.
     14   1.1   simonb  * 2. Redistributions in binary form must reproduce the above copyright
     15   1.1   simonb  *    notice, this list of conditions and the following disclaimer in the
     16   1.1   simonb  *    documentation and/or other materials provided with the distribution.
     17   1.1   simonb  * 3. All advertising materials mentioning features or use of this software
     18   1.1   simonb  *    must display the following acknowledgement:
     19   1.1   simonb  *      This product includes software developed for the NetBSD Project by
     20   1.1   simonb  *      Wasabi Systems, Inc.
     21   1.1   simonb  * 4. The name of Wasabi Systems, Inc. may not be used to endorse
     22   1.1   simonb  *    or promote products derived from this software without specific prior
     23   1.1   simonb  *    written permission.
     24   1.1   simonb  *
     25   1.1   simonb  * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
     26   1.1   simonb  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     27   1.1   simonb  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     28   1.1   simonb  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
     29   1.1   simonb  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     30   1.1   simonb  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     31   1.1   simonb  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     32   1.1   simonb  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     33   1.1   simonb  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     34   1.1   simonb  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     35   1.1   simonb  * POSSIBILITY OF SUCH DAMAGE.
     36   1.1   simonb  */
     37   1.1   simonb 
     38   1.1   simonb /*
     39   1.1   simonb  * Platform-specific interrupt support for the MIPS Malta.
     40   1.1   simonb  */
     41   1.1   simonb 
     42   1.9    lukem #include <sys/cdefs.h>
     43  1.11  gdamore __KERNEL_RCSID(0, "$NetBSD: malta_intr.c,v 1.11 2006/02/09 18:03:12 gdamore Exp $");
     44   1.1   simonb 
     45   1.1   simonb #include <sys/param.h>
     46   1.1   simonb #include <sys/device.h>
     47   1.1   simonb #include <sys/kernel.h>
     48   1.1   simonb #include <sys/malloc.h>
     49  1.10   simonb #include <sys/systm.h>
     50   1.1   simonb 
     51   1.1   simonb #include <mips/locore.h>
     52   1.1   simonb 
     53   1.1   simonb #include <evbmips/evbmips/clockvar.h>
     54   1.1   simonb 
     55   1.1   simonb #include <evbmips/malta/maltavar.h>
     56   1.1   simonb #include <evbmips/malta/pci/pcibvar.h>
     57   1.1   simonb 
     58   1.1   simonb #include <dev/ic/mc146818reg.h>		/* for malta_cal_timer() */
     59   1.1   simonb 
     60   1.1   simonb #include <dev/isa/isavar.h>
     61   1.1   simonb #include <dev/pci/pciidereg.h>
     62   1.1   simonb 
     63   1.1   simonb /*
     64   1.1   simonb  * This is a mask of bits to clear in the SR when we go to a
     65   1.1   simonb  * given hardware interrupt priority level.
     66   1.1   simonb  */
     67  1.11  gdamore const uint32_t ipl_sr_bits[_IPL_N] = {
     68   1.4   simonb 	0,					/*  0: IPL_NONE */
     69   1.1   simonb 
     70   1.4   simonb 	MIPS_SOFT_INT_MASK_0,			/*  1: IPL_SOFT */
     71   1.1   simonb 
     72   1.4   simonb 	MIPS_SOFT_INT_MASK_0,			/*  2: IPL_SOFTCLOCK */
     73   1.1   simonb 
     74   1.1   simonb 	MIPS_SOFT_INT_MASK_0|
     75   1.4   simonb 		MIPS_SOFT_INT_MASK_1,		/*  3: IPL_SOFTNET */
     76   1.1   simonb 
     77   1.1   simonb 	MIPS_SOFT_INT_MASK_0|
     78   1.4   simonb 		MIPS_SOFT_INT_MASK_1,		/*  4: IPL_SOFTSERIAL */
     79   1.1   simonb 
     80   1.1   simonb 	MIPS_SOFT_INT_MASK_0|
     81   1.1   simonb 		MIPS_SOFT_INT_MASK_1|
     82   1.4   simonb 		MIPS_INT_MASK_0,		/*  5: IPL_BIO */
     83   1.1   simonb 
     84   1.1   simonb 	MIPS_SOFT_INT_MASK_0|
     85   1.1   simonb 		MIPS_SOFT_INT_MASK_1|
     86   1.4   simonb 		MIPS_INT_MASK_0,		/*  6: IPL_NET */
     87   1.1   simonb 
     88   1.1   simonb 	MIPS_SOFT_INT_MASK_0|
     89   1.1   simonb 		MIPS_SOFT_INT_MASK_1|
     90   1.4   simonb 		MIPS_INT_MASK_0,		/*  7: IPL_{TTY,SERIAL} */
     91   1.1   simonb 
     92   1.1   simonb 	MIPS_SOFT_INT_MASK_0|
     93   1.1   simonb 		MIPS_SOFT_INT_MASK_1|
     94   1.1   simonb 		MIPS_INT_MASK_0|
     95   1.1   simonb 		MIPS_INT_MASK_1|
     96   1.1   simonb 		MIPS_INT_MASK_2|
     97   1.1   simonb 		MIPS_INT_MASK_3|
     98   1.1   simonb 		MIPS_INT_MASK_4|
     99   1.4   simonb 		MIPS_INT_MASK_5,		/*  8: IPL_{CLOCK,HIGH} */
    100   1.4   simonb };
    101   1.4   simonb 
    102   1.4   simonb /*
    103   1.4   simonb  * This is a mask of bits to clear in the SR when we go to a
    104   1.4   simonb  * given software interrupt priority level.
    105   1.4   simonb  * Hardware ipls are port/board specific.
    106   1.4   simonb  */
    107  1.11  gdamore const uint32_t mips_ipl_si_to_sr[_IPL_NSOFT] = {
    108   1.4   simonb 	MIPS_SOFT_INT_MASK_0,			/* IPL_SOFT */
    109   1.4   simonb 	MIPS_SOFT_INT_MASK_0,			/* IPL_SOFTCLOCK */
    110   1.4   simonb 	MIPS_SOFT_INT_MASK_1,			/* IPL_SOFTNET */
    111   1.4   simonb 	MIPS_SOFT_INT_MASK_1,			/* IPL_SOFTSERIAL */
    112   1.1   simonb };
    113   1.1   simonb 
    114   1.1   simonb struct malta_cpuintr {
    115   1.1   simonb 	LIST_HEAD(, evbmips_intrhand) cintr_list;
    116   1.1   simonb 	struct evcnt cintr_count;
    117   1.1   simonb };
    118   1.1   simonb #define	NINTRS		5	/* MIPS INT0 - INT4 */
    119   1.1   simonb 
    120   1.1   simonb struct malta_cpuintr malta_cpuintrs[NINTRS];
    121   1.1   simonb const char *malta_cpuintrnames[NINTRS] = {
    122   1.1   simonb 	"int 0 (piix4)",
    123   1.1   simonb 	"int 1 (smi)",
    124   1.1   simonb 	"int 2 (uart)",
    125   1.1   simonb 	"int 3 (core hi/gt64120)",
    126   1.1   simonb 	"int 4 (core lo)",
    127   1.1   simonb };
    128   1.1   simonb 
    129   1.1   simonb static int	malta_pci_intr_map(struct pci_attach_args *, pci_intr_handle_t *);
    130   1.1   simonb static const char
    131   1.1   simonb 		*malta_pci_intr_string(void *, pci_intr_handle_t);
    132   1.1   simonb static const struct evcnt
    133   1.1   simonb 		*malta_pci_intr_evcnt(void *, pci_intr_handle_t);
    134   1.1   simonb static void	*malta_pci_intr_establish(void *, pci_intr_handle_t, int,
    135   1.1   simonb 		    int (*)(void *), void *);
    136   1.1   simonb static void	malta_pci_intr_disestablish(void *, void *);
    137   1.1   simonb static void	malta_pci_conf_interrupt(void *, int, int, int, int, int *);
    138   1.1   simonb static void	*malta_pciide_compat_intr_establish(void *, struct device *,
    139   1.1   simonb 		    struct pci_attach_args *, int, int (*)(void *), void *);
    140   1.1   simonb 
    141   1.1   simonb void
    142   1.1   simonb evbmips_intr_init(void)
    143   1.1   simonb {
    144   1.1   simonb 	struct malta_config *mcp = &malta_configuration;
    145   1.1   simonb 	int i;
    146   1.1   simonb 
    147   1.1   simonb 	for (i = 0; i < NINTRS; i++) {
    148   1.1   simonb 		LIST_INIT(&malta_cpuintrs[i].cintr_list);
    149   1.1   simonb 		evcnt_attach_dynamic(&malta_cpuintrs[i].cintr_count,
    150   1.1   simonb 		    EVCNT_TYPE_INTR, NULL, "mips", malta_cpuintrnames[i]);
    151   1.1   simonb 	}
    152   1.1   simonb 
    153   1.1   simonb 	mcp->mc_pc.pc_intr_v = NULL;
    154   1.1   simonb 	mcp->mc_pc.pc_intr_map = malta_pci_intr_map;
    155   1.1   simonb 	mcp->mc_pc.pc_intr_string = malta_pci_intr_string;
    156   1.1   simonb 	mcp->mc_pc.pc_intr_evcnt = malta_pci_intr_evcnt;
    157   1.1   simonb 	mcp->mc_pc.pc_intr_establish = malta_pci_intr_establish;
    158   1.1   simonb 	mcp->mc_pc.pc_intr_disestablish = malta_pci_intr_disestablish;
    159   1.1   simonb 	mcp->mc_pc.pc_conf_interrupt = malta_pci_conf_interrupt;
    160   1.1   simonb 	mcp->mc_pc.pc_pciide_compat_intr_establish =
    161   1.1   simonb 	    malta_pciide_compat_intr_establish;
    162   1.1   simonb }
    163   1.1   simonb 
    164   1.1   simonb void
    165   1.1   simonb malta_cal_timer(bus_space_tag_t st, bus_space_handle_t sh)
    166   1.1   simonb {
    167   1.4   simonb 	uint32_t ctrdiff[4], startctr, endctr;
    168  1.11  gdamore 	uint8_t regc;
    169   1.1   simonb 	int i;
    170   1.1   simonb 
    171   1.1   simonb 	/* Disable interrupts first. */
    172   1.1   simonb 	bus_space_write_1(st, sh, 0, MC_REGB);
    173   1.1   simonb 	bus_space_write_1(st, sh, 1, MC_REGB_SQWE | MC_REGB_BINARY |
    174   1.1   simonb 	    MC_REGB_24HR);
    175   1.1   simonb 
    176   1.1   simonb 	/* Initialize for 16Hz. */
    177   1.1   simonb 	bus_space_write_1(st, sh, 0, MC_REGA);
    178   1.1   simonb 	bus_space_write_1(st, sh, 1, MC_BASE_32_KHz | MC_RATE_16_Hz);
    179   1.1   simonb 
    180   1.1   simonb 	/* Run the loop an extra time to prime the cache. */
    181   1.1   simonb 	for (i = 0; i < 4; i++) {
    182   1.1   simonb 		// led_display('h', 'z', '0' + i, ' ');
    183   1.1   simonb 
    184   1.1   simonb 		/* Enable the interrupt. */
    185   1.1   simonb 		bus_space_write_1(st, sh, 0, MC_REGB);
    186   1.1   simonb 		bus_space_write_1(st, sh, 1, MC_REGB_PIE | MC_REGB_SQWE |
    187   1.1   simonb 		    MC_REGB_BINARY | MC_REGB_24HR);
    188   1.1   simonb 
    189   1.1   simonb 		/* Go to REGC. */
    190   1.1   simonb 		bus_space_write_1(st, sh, 0, MC_REGC);
    191   1.1   simonb 
    192   1.1   simonb 		/* Wait for it to happen. */
    193   1.1   simonb 		startctr = mips3_cp0_count_read();
    194   1.1   simonb 		do {
    195   1.1   simonb 			regc = bus_space_read_1(st, sh, 1);
    196   1.1   simonb 			endctr = mips3_cp0_count_read();
    197   1.1   simonb 		} while ((regc & MC_REGC_IRQF) == 0);
    198   1.1   simonb 
    199   1.1   simonb 		/* Already ACK'd. */
    200   1.1   simonb 
    201   1.1   simonb 		/* Disable. */
    202   1.1   simonb 		bus_space_write_1(st, sh, 0, MC_REGB);
    203   1.1   simonb 		bus_space_write_1(st, sh, 1, MC_REGB_SQWE | MC_REGB_BINARY |
    204   1.1   simonb 		    MC_REGB_24HR);
    205   1.1   simonb 
    206   1.1   simonb 		ctrdiff[i] = endctr - startctr;
    207   1.1   simonb 	}
    208   1.1   simonb 
    209   1.1   simonb 	/* Compute the number of cycles per second. */
    210   1.1   simonb 	curcpu()->ci_cpu_freq = ((ctrdiff[2] + ctrdiff[3]) / 2) * 16/*Hz*/;
    211   1.1   simonb 
    212   1.1   simonb 	/* Compute the number of ticks for hz. */
    213   1.2   simonb 	curcpu()->ci_cycles_per_hz = (curcpu()->ci_cpu_freq + hz / 2) / hz;
    214   1.1   simonb 
    215   1.3   simonb 	/* Compute the delay divisor and reciprical. */
    216   1.2   simonb 	curcpu()->ci_divisor_delay =
    217   1.2   simonb 	    ((curcpu()->ci_cpu_freq + 500000) / 1000000);
    218   1.3   simonb 	MIPS_SET_CI_RECIPRICAL(curcpu());
    219   1.2   simonb 
    220   1.2   simonb 	/*
    221   1.2   simonb 	 * Get correct cpu frequency if the CPU runs at twice the
    222   1.2   simonb 	 * external/cp0-count frequency.
    223   1.2   simonb 	 */
    224   1.2   simonb 	if (mips_cpu_flags & CPU_MIPS_DOUBLE_COUNT)
    225   1.2   simonb 		curcpu()->ci_cpu_freq *= 2;
    226   1.1   simonb 
    227   1.1   simonb #ifdef DEBUG
    228   1.4   simonb 	printf("Timer calibration: %lu cycles/sec [(%u, %u) * 16]\n",
    229   1.1   simonb 	    curcpu()->ci_cpu_freq, ctrdiff[2], ctrdiff[3]);
    230   1.1   simonb #endif
    231   1.1   simonb }
    232   1.1   simonb 
    233   1.1   simonb void *
    234   1.1   simonb evbmips_intr_establish(int irq, int (*func)(void *), void *arg)
    235   1.1   simonb {
    236   1.1   simonb 	struct evbmips_intrhand *ih;
    237   1.1   simonb 	int s;
    238   1.1   simonb 
    239   1.1   simonb 	ih = malloc(sizeof(*ih), M_DEVBUF, M_NOWAIT);
    240   1.1   simonb 	if (ih == NULL)
    241   1.1   simonb 		return (NULL);
    242   1.1   simonb 
    243   1.1   simonb 	ih->ih_func = func;
    244   1.1   simonb 	ih->ih_arg = arg;
    245   1.1   simonb 
    246   1.1   simonb 	s = splhigh();
    247   1.1   simonb 
    248   1.1   simonb 	/*
    249   1.1   simonb 	 * Link it into the tables.
    250   1.1   simonb 	 */
    251   1.1   simonb 	LIST_INSERT_HEAD(&malta_cpuintrs[0].cintr_list, ih, ih_q);
    252   1.1   simonb 
    253   1.1   simonb 	/* XXX - should check that MIPS_INT_MASK_0 is set... */
    254   1.1   simonb 
    255   1.1   simonb 	splx(s);
    256   1.1   simonb 
    257   1.1   simonb 	return (ih);
    258   1.1   simonb }
    259   1.1   simonb 
    260   1.1   simonb void
    261   1.1   simonb evbmips_intr_disestablish(void *arg)
    262   1.1   simonb {
    263   1.1   simonb 	struct evbmips_intrhand *ih = arg;
    264   1.1   simonb 	int s;
    265   1.1   simonb 
    266   1.1   simonb 	s = splhigh();
    267   1.1   simonb 
    268   1.1   simonb 	/*
    269   1.1   simonb 	 * First, remove it from the table.
    270   1.1   simonb 	 */
    271   1.1   simonb 	LIST_REMOVE(ih, ih_q);
    272   1.1   simonb 
    273   1.1   simonb 	/* XXX - disable MIPS_INT_MASK_0 if list is empty? */
    274   1.1   simonb 
    275   1.1   simonb 	splx(s);
    276   1.1   simonb 
    277   1.1   simonb 	free(ih, M_DEVBUF);
    278   1.1   simonb }
    279   1.1   simonb 
    280   1.1   simonb void
    281   1.1   simonb evbmips_iointr(uint32_t status, uint32_t cause, uint32_t pc, uint32_t ipending)
    282   1.1   simonb {
    283   1.1   simonb 	struct evbmips_intrhand *ih;
    284   1.1   simonb 
    285   1.5   simonb 	/* Check for error interrupts (SMI, GT64120) */
    286   1.1   simonb 	if (ipending & (MIPS_INT_MASK_1 | MIPS_INT_MASK_3)) {
    287   1.1   simonb 		if (ipending & MIPS_INT_MASK_1)
    288   1.1   simonb 			panic("piix4 SMI interrupt");
    289   1.1   simonb 		if (ipending & MIPS_INT_MASK_3)
    290   1.5   simonb 			panic("gt64120 error interrupt");
    291   1.1   simonb 	}
    292   1.1   simonb 
    293   1.1   simonb 	/*
    294   1.1   simonb 	 * Read the interrupt pending registers, mask them with the
    295   1.1   simonb 	 * ones we have enabled, and service them in order of decreasing
    296   1.1   simonb 	 * priority.
    297   1.1   simonb 	 */
    298   1.1   simonb 	if (ipending & MIPS_INT_MASK_0) {
    299   1.1   simonb 		/* All interrupts are gated through MIPS HW interrupt 0 */
    300   1.1   simonb 		malta_cpuintrs[0].cintr_count.ev_count++;
    301   1.1   simonb 		LIST_FOREACH(ih, &malta_cpuintrs[0].cintr_list, ih_q)
    302   1.1   simonb 			(*ih->ih_func)(ih->ih_arg);
    303   1.1   simonb 		cause &= ~MIPS_INT_MASK_0;
    304   1.1   simonb 	}
    305   1.1   simonb 
    306   1.1   simonb 	/* Re-enable anything that we have processed. */
    307   1.1   simonb 	_splset(MIPS_SR_INT_IE | ((status & ~cause) & MIPS_HARD_INT_MASK));
    308   1.1   simonb }
    309   1.1   simonb 
    310   1.1   simonb /*
    311   1.1   simonb  * YAMON configures pa_intrline correctly (so far), so we trust it to DTRT
    312   1.1   simonb  * in the future...
    313   1.1   simonb  */
    314   1.1   simonb #undef YAMON_IRQ_MAP_BAD
    315   1.1   simonb 
    316   1.1   simonb /*
    317   1.1   simonb  * PCI interrupt support
    318   1.1   simonb  */
    319   1.1   simonb static int
    320   1.1   simonb malta_pci_intr_map(struct pci_attach_args *pa, pci_intr_handle_t *ihp)
    321   1.1   simonb {
    322   1.1   simonb #ifdef YAMON_IRQ_MAP_BAD
    323   1.7   simonb 	static const int pciirqmap[12/*device*/][4/*pin*/] = {
    324   1.1   simonb 		{ -1, -1, -1, 11 },	/* 10: USB */
    325   1.1   simonb 		{ 10, -1, -1, -1 },	/* 11: Ethernet */
    326   1.1   simonb 		{ 11, -1, -1, -1 },	/* 12: Audio */
    327   1.1   simonb 		{ -1, -1, -1, -1 },	/* 13: not used */
    328   1.1   simonb 		{ -1, -1, -1, -1 },	/* 14: not used */
    329   1.1   simonb 		{ -1, -1, -1, -1 },	/* 15: not used */
    330   1.1   simonb 		{ -1, -1, -1, -1 },	/* 16: not used */
    331   1.1   simonb 		{ -1, -1, -1, -1 },	/* 17: Core card(?) */
    332   1.1   simonb 		{ 10, 10, 11, 11 },	/* 18: PCI Slot 1 */
    333   1.1   simonb 		{ 10, 11, 11, 10 },	/* 19: PCI Slot 2 */
    334   1.1   simonb 		{ 11, 11, 10, 10 },	/* 20: PCI Slot 3 */
    335   1.1   simonb 		{ 11, 10, 10, 11 },	/* 21: PCI Slot 4 */
    336   1.1   simonb 	};
    337   1.1   simonb 	int buspin, device, irq;
    338   1.1   simonb #else	/* !YAMON_IRQ_MAP_BAD */
    339   1.1   simonb 	int buspin;
    340   1.1   simonb #endif	/* !YAMON_IRQ_MAP_BAD */
    341   1.1   simonb 
    342   1.1   simonb 	buspin = pa->pa_intrpin;
    343   1.1   simonb 
    344   1.1   simonb 	if (buspin == 0) {
    345   1.1   simonb 		/* No IRQ used. */
    346   1.1   simonb 		return (1);
    347   1.1   simonb 	}
    348   1.1   simonb 
    349   1.1   simonb 	if (buspin > 4) {
    350   1.1   simonb 		printf("malta_pci_intr_map: bad interrupt pin %d\n", buspin);
    351   1.1   simonb 		return (1);
    352   1.1   simonb 	}
    353   1.1   simonb 
    354   1.1   simonb #ifdef YAMON_IRQ_MAP_BAD
    355   1.1   simonb 	pci_decompose_tag(pa->pa_pc, pa->pa_intrtag, NULL, &device, NULL);
    356   1.1   simonb 
    357   1.1   simonb 	if (device < 10 || device > 21) {
    358   1.1   simonb 		printf("malta_pci_intr_map: bad device %d\n", device);
    359   1.1   simonb 		return (1);
    360   1.1   simonb 	}
    361   1.1   simonb 
    362   1.1   simonb 	irq = pciirqmap[device - 10][buspin - 1];
    363   1.1   simonb 	if (irq == -1) {
    364   1.1   simonb 		printf("malta_pci_intr_map: no mapping for device %d pin %d\n",
    365   1.1   simonb 		    device, buspin);
    366   1.1   simonb 		return (1);
    367   1.1   simonb 	}
    368   1.1   simonb 
    369   1.1   simonb 	*ihp = irq;
    370   1.1   simonb #else	/* !YAMON_IRQ_MAP_BAD */
    371   1.1   simonb 	*ihp = pa->pa_intrline;
    372   1.1   simonb #endif	/* !YAMON_IRQ_MAP_BAD */
    373   1.1   simonb 	return (0);
    374   1.1   simonb }
    375   1.1   simonb 
    376   1.1   simonb static const char *
    377   1.1   simonb malta_pci_intr_string(void *v, pci_intr_handle_t irq)
    378   1.1   simonb {
    379   1.1   simonb 
    380   1.1   simonb 	return (isa_intr_string(pcib_ic, irq));
    381   1.1   simonb }
    382   1.1   simonb 
    383   1.1   simonb static const struct evcnt *
    384   1.1   simonb malta_pci_intr_evcnt(void *v, pci_intr_handle_t irq)
    385   1.1   simonb {
    386   1.1   simonb 
    387   1.1   simonb 	return (isa_intr_evcnt(pcib_ic, irq));
    388   1.1   simonb }
    389   1.1   simonb 
    390   1.1   simonb static void *
    391   1.1   simonb malta_pci_intr_establish(void *v, pci_intr_handle_t irq, int level,
    392   1.1   simonb     int (*func)(void *), void *arg)
    393   1.1   simonb {
    394   1.1   simonb 
    395   1.1   simonb 	return (isa_intr_establish(pcib_ic, irq, IST_LEVEL, level, func, arg));
    396   1.1   simonb }
    397   1.1   simonb 
    398   1.1   simonb static void
    399   1.1   simonb malta_pci_intr_disestablish(void *v, void *arg)
    400   1.1   simonb {
    401   1.1   simonb 
    402   1.1   simonb 	return (isa_intr_disestablish(pcib_ic, arg));
    403   1.1   simonb }
    404   1.1   simonb 
    405   1.1   simonb static void
    406   1.1   simonb malta_pci_conf_interrupt(void *v, int bus, int dev, int func, int swiz,
    407   1.1   simonb     int *iline)
    408   1.1   simonb {
    409   1.1   simonb 
    410   1.1   simonb 	/*
    411   1.1   simonb 	 * We actually don't need to do anything; everything is handled
    412   1.1   simonb 	 * in pci_intr_map().
    413   1.1   simonb 	 */
    414   1.1   simonb 	*iline = 0;
    415   1.1   simonb }
    416   1.1   simonb 
    417   1.1   simonb void *
    418   1.1   simonb malta_pciide_compat_intr_establish(void *v, struct device *dev,
    419   1.1   simonb     struct pci_attach_args *pa, int chan, int (*func)(void *), void *arg)
    420   1.1   simonb {
    421   1.1   simonb 	pci_chipset_tag_t pc = pa->pa_pc;
    422   1.1   simonb 	void *cookie;
    423   1.1   simonb 	int bus, irq;
    424   1.1   simonb 
    425   1.1   simonb 	pci_decompose_tag(pc, pa->pa_tag, &bus, NULL, NULL);
    426   1.1   simonb 
    427   1.1   simonb 	/*
    428   1.1   simonb 	 * If this isn't PCI bus #0, all bets are off.
    429   1.1   simonb 	 */
    430   1.1   simonb 	if (bus != 0)
    431   1.1   simonb 		return (NULL);
    432   1.1   simonb 
    433   1.1   simonb 	irq = PCIIDE_COMPAT_IRQ(chan);
    434   1.1   simonb 	cookie = isa_intr_establish(pcib_ic, irq, IST_EDGE, IPL_BIO, func, arg);
    435   1.1   simonb 	if (cookie == NULL)
    436   1.1   simonb 		return (NULL);
    437   1.1   simonb 	printf("%s: %s channel interrupting at %s\n", dev->dv_xname,
    438   1.1   simonb 	    PCIIDE_CHANNEL_NAME(chan), malta_pci_intr_string(v, irq));
    439   1.1   simonb 	return (cookie);
    440   1.1   simonb }
    441