Home | History | Annotate | Line # | Download | only in pci
pci_machdep.c revision 1.13
      1  1.13  garbled /*	$NetBSD: pci_machdep.c,v 1.13 2007/10/17 19:56:58 garbled Exp $	*/
      2   1.1   briggs 
      3   1.1   briggs /*
      4   1.1   briggs  * Copyright (c) 1996 Christopher G. Demetriou.  All rights reserved.
      5   1.1   briggs  * Copyright (c) 1994 Charles M. Hannum.  All rights reserved.
      6   1.1   briggs  *
      7   1.1   briggs  * Redistribution and use in source and binary forms, with or without
      8   1.1   briggs  * modification, are permitted provided that the following conditions
      9   1.1   briggs  * are met:
     10   1.1   briggs  * 1. Redistributions of source code must retain the above copyright
     11   1.1   briggs  *    notice, this list of conditions and the following disclaimer.
     12   1.1   briggs  * 2. Redistributions in binary form must reproduce the above copyright
     13   1.1   briggs  *    notice, this list of conditions and the following disclaimer in the
     14   1.1   briggs  *    documentation and/or other materials provided with the distribution.
     15   1.1   briggs  * 3. All advertising materials mentioning features or use of this software
     16   1.1   briggs  *    must display the following acknowledgement:
     17   1.1   briggs  *	This product includes software developed by Charles M. Hannum.
     18   1.1   briggs  * 4. The name of the author may not be used to endorse or promote products
     19   1.1   briggs  *    derived from this software without specific prior written permission.
     20   1.1   briggs  *
     21   1.1   briggs  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     22   1.1   briggs  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     23   1.1   briggs  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     24   1.1   briggs  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     25   1.1   briggs  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     26   1.1   briggs  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     27   1.1   briggs  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     28   1.1   briggs  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     29   1.1   briggs  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     30   1.1   briggs  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     31   1.1   briggs  */
     32   1.1   briggs 
     33   1.1   briggs /*
     34   1.1   briggs  * Machine-specific functions for PCI autoconfiguration.
     35   1.1   briggs  *
     36   1.1   briggs  * On PCs, there are two methods of generating PCI configuration cycles.
     37   1.1   briggs  * We try to detect the appropriate mechanism for this machine and set
     38   1.1   briggs  * up a few function pointers to access the correct method directly.
     39   1.1   briggs  *
     40   1.1   briggs  * The configuration method can be hard-coded in the config file by
     41   1.1   briggs  * using `options PCI_CONF_MODE=N', where `N' is the configuration mode
     42   1.1   briggs  * as defined section 3.6.4.1, `Generating Configuration Cycles'.
     43   1.1   briggs  */
     44  1.11    lukem 
     45  1.11    lukem #include <sys/cdefs.h>
     46  1.13  garbled __KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.13 2007/10/17 19:56:58 garbled Exp $");
     47   1.1   briggs 
     48   1.1   briggs #include <sys/types.h>
     49   1.1   briggs #include <sys/param.h>
     50   1.1   briggs #include <sys/device.h>
     51   1.1   briggs #include <sys/errno.h>
     52   1.1   briggs #include <sys/extent.h>
     53   1.1   briggs #include <sys/malloc.h>
     54   1.1   briggs #include <sys/queue.h>
     55   1.1   briggs #include <sys/systm.h>
     56   1.1   briggs #include <sys/time.h>
     57   1.1   briggs 
     58   1.1   briggs #include <uvm/uvm.h>
     59   1.1   briggs 
     60   1.4   briggs #define _POWERPC_BUS_DMA_PRIVATE
     61   1.1   briggs #include <machine/bus.h>
     62  1.13  garbled #include <machine/intr.h>
     63   1.1   briggs #include <machine/pio.h>
     64   1.1   briggs 
     65   1.1   briggs #include <dev/isa/isavar.h>
     66   1.1   briggs #include <dev/pci/pcivar.h>
     67   1.1   briggs #include <dev/pci/pcireg.h>
     68   1.1   briggs #include <dev/pci/pciconf.h>
     69  1.13  garbled #include <dev/pci/pcidevs.h>
     70   1.1   briggs 
     71   1.4   briggs struct powerpc_bus_dma_tag pci_bus_dma_tag = {
     72   1.1   briggs 	0,			/* _bounce_thresh */
     73   1.1   briggs 	_bus_dmamap_create,
     74   1.1   briggs 	_bus_dmamap_destroy,
     75   1.1   briggs 	_bus_dmamap_load,
     76   1.1   briggs 	_bus_dmamap_load_mbuf,
     77   1.1   briggs 	_bus_dmamap_load_uio,
     78   1.1   briggs 	_bus_dmamap_load_raw,
     79   1.1   briggs 	_bus_dmamap_unload,
     80   1.1   briggs 	NULL,			/* _dmamap_sync */
     81   1.1   briggs 	_bus_dmamem_alloc,
     82   1.1   briggs 	_bus_dmamem_free,
     83   1.1   briggs 	_bus_dmamem_map,
     84   1.1   briggs 	_bus_dmamem_unmap,
     85   1.1   briggs 	_bus_dmamem_mmap,
     86   1.1   briggs };
     87   1.1   briggs 
     88  1.13  garbled #define	EPIC_DEBUGIRQ
     89  1.13  garbled 
     90  1.13  garbled static int brdtype;
     91  1.13  garbled #define BRD_SANDPOINTX2		2
     92  1.13  garbled #define BRD_SANDPOINTX3		3
     93  1.13  garbled #define BRD_ENCOREPP1		10
     94  1.13  garbled #define BRD_KUROBOX		100
     95  1.13  garbled #define BRD_QNAPTS101		101
     96  1.13  garbled #define BRD_SYNOLOGY		102
     97  1.13  garbled #define BRD_UNKNOWN		-1
     98  1.13  garbled 
     99   1.1   briggs #define	PCI_CONFIG_ENABLE	0x80000000UL
    100   1.1   briggs 
    101   1.1   briggs void
    102   1.1   briggs pci_attach_hook(parent, self, pba)
    103   1.1   briggs 	struct device *parent, *self;
    104   1.1   briggs 	struct pcibus_attach_args *pba;
    105   1.1   briggs {
    106  1.13  garbled 	pcitag_t tag;
    107  1.13  garbled 	pcireg_t dev11, dev22, dev15;
    108  1.13  garbled 
    109  1.13  garbled 	tag = pci_make_tag(pba->pba_pc, pba->pba_bus, 11, 0);
    110  1.13  garbled 	dev11 = pci_conf_read(pba->pba_pc, tag, PCI_CLASS_REG);
    111  1.13  garbled 	if (PCI_CLASS(dev11) == PCI_CLASS_BRIDGE) {
    112  1.13  garbled 		/* WinBond/Symphony Lab 83C553 at dev 11 */
    113  1.13  garbled 		/*
    114  1.13  garbled 		 * XXX distinguish SP3 from SP2 by fiddling ISA GPIO #7/6.
    115  1.13  garbled 		 * XXX SP3 #7 output values loopback to #6 input.
    116  1.13  garbled 		 */
    117  1.13  garbled 		brdtype = BRD_SANDPOINTX3;
    118  1.13  garbled 		return;
    119  1.13  garbled 	}
    120  1.13  garbled 	tag = pci_make_tag(pba->pba_pc, pba->pba_bus, 22, 0);
    121  1.13  garbled 	dev22 = pci_conf_read(pba->pba_pc, tag, PCI_CLASS_REG);
    122  1.13  garbled 	if (PCI_CLASS(dev22) == PCI_CLASS_BRIDGE) {
    123  1.13  garbled 		/* VIA 82C686B at dev 22 */
    124  1.13  garbled 		brdtype = BRD_ENCOREPP1;
    125  1.13  garbled 		return;
    126  1.13  garbled 	}
    127  1.13  garbled 	tag = pci_make_tag(pba->pba_pc, pba->pba_bus, 11, 0);
    128  1.13  garbled 	dev11 = pci_conf_read(pba->pba_pc, tag, PCI_CLASS_REG);
    129  1.13  garbled 	if (PCI_CLASS(dev11) == PCI_CLASS_NETWORK) {
    130  1.13  garbled 		/* tlp (ADMtek AN985) or re (RealTek 8169S) at dev 11 */
    131  1.13  garbled 		brdtype = BRD_KUROBOX;
    132  1.13  garbled 		return;
    133  1.13  garbled 	}
    134  1.13  garbled 	tag = pci_make_tag(pba->pba_pc, pba->pba_bus, 15, 0);
    135  1.13  garbled 	dev15 = pci_conf_read(pba->pba_pc, tag, PCI_ID_REG);
    136  1.13  garbled 	if (PCI_VENDOR(dev15) == PCI_VENDOR_INTEL) {
    137  1.13  garbled 		/* Intel GbE at dev 15 */
    138  1.13  garbled 		brdtype = BRD_QNAPTS101;
    139  1.13  garbled 		return;
    140  1.13  garbled 	}
    141  1.13  garbled 	if (PCI_VENDOR(dev15) == PCI_VENDOR_MARVELL) {
    142  1.13  garbled 		/* Marvell GbE at dev 15 */
    143  1.13  garbled 		brdtype = BRD_SYNOLOGY;
    144  1.13  garbled 		return;
    145  1.13  garbled 	}
    146  1.13  garbled 	brdtype = BRD_UNKNOWN;
    147   1.1   briggs }
    148   1.1   briggs 
    149   1.1   briggs int
    150   1.1   briggs pci_bus_maxdevs(pc, busno)
    151   1.1   briggs 	pci_chipset_tag_t pc;
    152   1.1   briggs 	int busno;
    153   1.1   briggs {
    154   1.1   briggs 
    155   1.1   briggs 	/*
    156   1.1   briggs 	 * Bus number is irrelevant.  Configuration Mechanism 1 is in
    157   1.1   briggs 	 * use, can have devices 0-32 (i.e. the `normal' range).
    158   1.1   briggs 	 */
    159   1.1   briggs 	return (32);
    160   1.1   briggs }
    161   1.1   briggs 
    162   1.1   briggs pcitag_t
    163   1.1   briggs pci_make_tag(pc, bus, device, function)
    164   1.1   briggs 	pci_chipset_tag_t pc;
    165   1.1   briggs 	int bus, device, function;
    166   1.1   briggs {
    167   1.1   briggs 	pcitag_t tag;
    168   1.1   briggs 
    169   1.1   briggs 	if (bus >= 256 || device >= 32 || function >= 8)
    170   1.1   briggs 		panic("pci_make_tag: bad request");
    171   1.1   briggs 
    172   1.1   briggs 	tag = PCI_CONFIG_ENABLE |
    173   1.1   briggs 		    (bus << 16) | (device << 11) | (function << 8);
    174   1.1   briggs 	return tag;
    175   1.1   briggs }
    176   1.1   briggs 
    177   1.1   briggs void
    178   1.1   briggs pci_decompose_tag(pc, tag, bp, dp, fp)
    179   1.1   briggs 	pci_chipset_tag_t pc;
    180   1.1   briggs 	pcitag_t tag;
    181   1.1   briggs 	int *bp, *dp, *fp;
    182   1.1   briggs {
    183   1.1   briggs 
    184   1.1   briggs 	if (bp != NULL)
    185   1.1   briggs 		*bp = (tag >> 16) & 0xff;
    186   1.1   briggs 	if (dp != NULL)
    187   1.1   briggs 		*dp = (tag >> 11) & 0x1f;
    188   1.1   briggs 	if (fp != NULL)
    189   1.1   briggs 		*fp = (tag >> 8) & 0x7;
    190   1.1   briggs 	return;
    191   1.1   briggs }
    192   1.1   briggs 
    193   1.1   briggs /*
    194   1.1   briggs  * The Kahlua documentation says that "reg" should be left-shifted by two
    195   1.1   briggs  * and be in bits 2-7.  Apparently not.  It doesn't work that way, and the
    196   1.1   briggs  * DINK32 ROM doesn't do it that way (I peeked at 0xfec00000 after running
    197   1.1   briggs  * the DINK32 "pcf" command).
    198   1.1   briggs  */
    199   1.1   briggs #define SP_PCI(tag, reg) ((tag) | (reg))
    200   1.1   briggs 
    201   1.1   briggs pcireg_t
    202   1.1   briggs pci_conf_read(pc, tag, reg)
    203   1.1   briggs 	pci_chipset_tag_t pc;
    204   1.1   briggs 	pcitag_t tag;
    205   1.1   briggs 	int reg;
    206   1.1   briggs {
    207   1.1   briggs 	pcireg_t data;
    208   1.1   briggs 
    209   1.1   briggs 	out32rb(SANDPOINT_PCI_CONFIG_ADDR, SP_PCI(tag,reg));
    210   1.1   briggs 	data = in32rb(SANDPOINT_PCI_CONFIG_DATA);
    211   1.1   briggs 	out32rb(SANDPOINT_PCI_CONFIG_ADDR, 0);
    212   1.1   briggs 	return data;
    213   1.1   briggs }
    214   1.1   briggs 
    215   1.1   briggs void
    216   1.1   briggs pci_conf_write(pc, tag, reg, data)
    217   1.1   briggs 	pci_chipset_tag_t pc;
    218   1.1   briggs 	pcitag_t tag;
    219   1.1   briggs 	int reg;
    220   1.1   briggs 	pcireg_t data;
    221   1.1   briggs {
    222   1.1   briggs 	out32rb(SANDPOINT_PCI_CONFIG_ADDR, SP_PCI(tag, reg));
    223   1.1   briggs 	out32rb(SANDPOINT_PCI_CONFIG_DATA, data);
    224   1.1   briggs 	out32rb(SANDPOINT_PCI_CONFIG_ADDR, 0);
    225   1.1   briggs }
    226   1.1   briggs 
    227   1.1   briggs int
    228   1.1   briggs pci_intr_map(pa, ihp)
    229   1.1   briggs 	struct pci_attach_args *pa;
    230   1.1   briggs 	pci_intr_handle_t *ihp;
    231   1.1   briggs {
    232   1.1   briggs 	int	pin = pa->pa_intrpin;
    233   1.1   briggs 	int	line = pa->pa_intrline;
    234   1.1   briggs 
    235  1.13  garbled 	/* No IRQ used. */
    236  1.13  garbled 	if (pin == 0)
    237   1.1   briggs 		goto bad;
    238   1.1   briggs 	if (pin > 4) {
    239  1.13  garbled 		aprint_error("pci_intr_map: bad interrupt pin %d\n", pin);
    240   1.1   briggs 		goto bad;
    241   1.1   briggs 	}
    242   1.1   briggs 
    243   1.1   briggs 	/*
    244   1.1   briggs 	 * Section 6.2.4, `Miscellaneous Functions', says that 255 means
    245   1.1   briggs 	 * `unknown' or `no connection' on a PC.  We assume that a device with
    246   1.1   briggs 	 * `no connection' either doesn't have an interrupt (in which case the
    247   1.1   briggs 	 * pin number should be 0, and would have been noticed above), or
    248   1.1   briggs 	 * wasn't configured by the BIOS (in which case we punt, since there's
    249   1.1   briggs 	 * no real way we can know how the interrupt lines are mapped in the
    250   1.1   briggs 	 * hardware).
    251   1.1   briggs 	 *
    252   1.1   briggs 	 * XXX
    253   1.1   briggs 	 * Since IRQ 0 is only used by the clock, and we can't actually be sure
    254   1.1   briggs 	 * that the BIOS did its job, we also recognize that as meaning that
    255   1.1   briggs 	 * the BIOS has not configured the device.
    256   1.1   briggs 	 */
    257   1.1   briggs 	if (line == 255) {
    258  1.13  garbled 		aprint_error("pci_intr_map: no mapping for pin %c\n",
    259  1.13  garbled 		    '@' + pin);
    260   1.1   briggs 		goto bad;
    261   1.8   briggs 	}
    262  1.13  garbled #ifdef EPIC_DEBUGIRQ
    263  1.13  garbled printf("line %d, pin %c", line, pin + '@');
    264  1.13  garbled #endif
    265  1.13  garbled 	switch (brdtype) {
    266  1.13  garbled 	/* Sandpoint has 4 PCI slots in a weird order.
    267  1.13  garbled 	 * From next to MPMC mezzanine card toward the board edge,
    268  1.13  garbled 	 * 	64bit slot PCI AD14
    269  1.13  garbled 	 * 	64bit slot PCI AD13
    270  1.13  garbled 	 * 	32bit slot PCI AD16
    271  1.13  garbled 	 * 	32bit slot PCI AD15
    272  1.13  garbled 	 * Don't believe identifying labels printed on PCB and
    273  1.13  garbled 	 * documents confusing as well since Moto names the slots
    274  1.13  garbled 	 * as number 1 origin.
    275  1.13  garbled 	 */
    276  1.13  garbled 	case BRD_SANDPOINTX3:
    277  1.13  garbled 	/*
    278  1.13  garbled 	 * Sandpoint X3 brd uses EPIC serial mode IRQ.
    279  1.13  garbled 	 * - i8259 PIC interrupt to EPIC IRQ0.
    280  1.13  garbled 	 * - WinBond IDE PCI C/D to EPIC IRQ8/9.
    281  1.13  garbled 	 * - PCI AD13 pin A,B,C,D to EPIC IRQ2,5,4,3.
    282  1.13  garbled 	 * - PCI AD14 pin A,B,C,D to EPIC IRQ3,2,5,4.
    283  1.13  garbled 	 * - PCI AD15 pin A,B,C,D to EPIC IRQ4,3,2,5.
    284  1.13  garbled 	 * - PCI AD16 pin A,B,C,D to EPIC IRQ5,4,3,2.
    285  1.13  garbled 	 */
    286  1.13  garbled 		if (line == 11
    287  1.13  garbled 		    && pa->pa_function == 1 && pa->pa_bus == 0) {
    288  1.13  garbled 			/* X3 wires 83c553 pin C,D to EPIC IRQ8,9 */
    289  1.13  garbled 			*ihp = 8; /* pin C only, indeed */
    290   1.8   briggs 			break;
    291  1.13  garbled 		}
    292  1.13  garbled 		if (line < 13 || line > 16) {
    293  1.13  garbled 			aprint_error("pci_intr_map: bad interrupt line %d,%c\n",
    294   1.8   briggs 				line, pin + '@');
    295   1.8   briggs 			goto bad;
    296  1.13  garbled 		}
    297  1.13  garbled 		line -= 13; pin -= 1;
    298  1.13  garbled 		*ihp = 2 + ((line + (4 - pin)) & 03);
    299  1.13  garbled 		break;
    300  1.13  garbled 	case BRD_SANDPOINTX2:
    301  1.13  garbled 	/*
    302  1.13  garbled 	 * Sandpoint X2 brd uses EPIC direct mode IRQ.
    303  1.13  garbled 	 * - i8259 PIC interrupt EPIC IRQ2.
    304  1.13  garbled 	 * - PCI AD13 pin A,B,C,D to EPIC IRQ0,1,2,3.
    305  1.13  garbled 	 * - PCI AD14 pin A,B,C,D to EPIC IRQ1,2,3,0.
    306  1.13  garbled 	 * - PCI AD15 pin A,B,C,D to EPIC IRQ2,3,0,1.
    307  1.13  garbled 	 * - PCI AD16 pin A,B,C,D to EPIC IRQ3,0,1,2.
    308  1.13  garbled 	 * - PCI AD12 is wired to PMPC device itself.
    309  1.13  garbled 	 */
    310  1.13  garbled 		if (line == 11
    311  1.13  garbled 		    && pa->pa_function == 1 && pa->pa_bus == 0) {
    312  1.13  garbled 			/* 83C553 PCI IDE comes thru EPIC IRQ2 */
    313  1.13  garbled 			*ihp = 2;
    314   1.8   briggs 			break;
    315   1.8   briggs 		}
    316   1.1   briggs 		if (line < 13 || line > 16) {
    317  1.13  garbled 			aprint_error("pci_intr_map: bad interrupt line %d,%c\n",
    318   1.8   briggs 				line, pin + '@');
    319   1.1   briggs 			goto bad;
    320   1.1   briggs 		}
    321  1.13  garbled 		line -= 13; pin -= 1;
    322  1.13  garbled 		*ihp = (line + pin) & 03;
    323  1.13  garbled 		break;
    324  1.13  garbled 	case BRD_ENCOREPP1:
    325  1.13  garbled 	/*
    326  1.13  garbled 	 * Ampro EnCorePP1 brd uses EPIC direct mode IRQ. VIA 686B SB
    327  1.13  garbled 	 * i8259 interrupt goes through EPC IRQ0.  PCI pin A-D are
    328  1.13  garbled 	 * tied with EPIC IRQ1-4.
    329  1.13  garbled 	 * - PCI AD22 pin A,B,C,D to EPIC IRQ 1,2,3,4.
    330  1.13  garbled 	 * - PCI AD23 pin A,B,C,D to EPIC IRQ 2,3,4,1.
    331  1.13  garbled 	 * - PCI AD24 pin A,B,C,D to EPIC IRQ 3,4,1,2.
    332  1.13  garbled 	 * - PCI AD25 pin A,B,C,D to EPIC IRQ 4,1,2,3.
    333  1.13  garbled 	 */
    334  1.13  garbled 		line -= 22; pin -= 1;
    335  1.13  garbled 		*ihp = 1 + ((line + pin) & 3);
    336  1.13  garbled 		break;
    337  1.13  garbled 	case BRD_KUROBOX:
    338  1.13  garbled 		/* map line 11,12,13,14 to EPIC IRQ0,1,4,3 */
    339  1.13  garbled 		*ihp = (line == 13) ? 4 : line - 11;
    340  1.13  garbled 		break;
    341  1.13  garbled 	case BRD_QNAPTS101:
    342  1.13  garbled 		/* map line 12-15 to EPIC IRQ0-3 */
    343  1.13  garbled 		*ihp = line - 12;
    344  1.13  garbled 		break;
    345  1.13  garbled 	case BRD_SYNOLOGY:
    346  1.13  garbled 		/* map line 12,13-15 to EPIC IRQ4,0-2 */
    347  1.13  garbled 		*ihp = (line == 12) ? 4 : line - 13;
    348  1.13  garbled 		break;
    349  1.13  garbled 	default:
    350  1.13  garbled 		/* map line 12-15 to EPIC IRQ0-3 */
    351  1.13  garbled 		*ihp = line - 12;
    352  1.13  garbled 		break;
    353  1.13  garbled 	}
    354  1.13  garbled #ifdef EPIC_DEBUGIRQ
    355  1.13  garbled printf(" = EPIC %d\n", *ihp);
    356   1.6   briggs #endif
    357   1.1   briggs 	return 0;
    358  1.13  garbled   bad:
    359   1.1   briggs 	*ihp = -1;
    360   1.1   briggs 	return 1;
    361   1.1   briggs }
    362   1.1   briggs 
    363   1.1   briggs const char *
    364   1.1   briggs pci_intr_string(pc, ih)
    365   1.1   briggs 	pci_chipset_tag_t pc;
    366   1.1   briggs 	pci_intr_handle_t ih;
    367   1.1   briggs {
    368   1.1   briggs 	static char irqstr[8];		/* 4 + 2 + NULL + sanity */
    369   1.1   briggs 
    370   1.1   briggs 	if (ih < 0 || ih >= ICU_LEN)
    371  1.10   provos 		panic("pci_intr_string: bogus handle 0x%x", ih);
    372   1.1   briggs 
    373  1.13  garbled 	sprintf(irqstr, "irq %d", ih + 16);
    374   1.1   briggs 	return (irqstr);
    375   1.1   briggs 
    376   1.1   briggs }
    377   1.1   briggs 
    378   1.1   briggs const struct evcnt *
    379   1.1   briggs pci_intr_evcnt(pc, ih)
    380   1.1   briggs 	pci_chipset_tag_t pc;
    381   1.1   briggs 	pci_intr_handle_t ih;
    382   1.1   briggs {
    383   1.1   briggs 
    384   1.1   briggs 	/* XXX for now, no evcnt parent reported */
    385   1.1   briggs 	return NULL;
    386   1.1   briggs }
    387   1.1   briggs 
    388   1.1   briggs void *
    389   1.1   briggs pci_intr_establish(pc, ih, level, func, arg)
    390   1.1   briggs 	pci_chipset_tag_t pc;
    391   1.1   briggs 	pci_intr_handle_t ih;
    392   1.1   briggs 	int level, (*func) __P((void *));
    393   1.1   briggs 	void *arg;
    394   1.1   briggs {
    395   1.1   briggs 	/*
    396   1.1   briggs 	 * ih is the value assigned in pci_intr_map(), above.
    397  1.13  garbled 	 * It's the EPIC IRQ #.
    398   1.1   briggs 	 */
    399  1.13  garbled 	return intr_establish(ih + 16, IST_LEVEL, level, func, arg);
    400   1.1   briggs }
    401   1.1   briggs 
    402   1.1   briggs void
    403   1.1   briggs pci_intr_disestablish(pc, cookie)
    404   1.1   briggs 	pci_chipset_tag_t pc;
    405   1.1   briggs 	void *cookie;
    406   1.1   briggs {
    407   1.3    lukem 	intr_disestablish(cookie);
    408   1.1   briggs }
    409   1.1   briggs 
    410   1.1   briggs void
    411   1.7  thorpej pci_conf_interrupt(pci_chipset_tag_t pc, int bus, int dev, int pin, int swiz,
    412   1.2   briggs     int *iline)
    413   1.1   briggs {
    414   1.2   briggs 	if (bus == 0) {
    415   1.2   briggs 		*iline = dev;
    416   1.2   briggs 	} else {
    417   1.2   briggs 		/*
    418   1.2   briggs 		 * If we are not on bus zero, we're behind a bridge, so we
    419   1.2   briggs 		 * swizzle.
    420   1.2   briggs 		 *
    421   1.2   briggs 		 * The documentation lies about this.  In slot 3 (numbering
    422   1.2   briggs 		 * from 0) aka device 16, INTD# becomes an interrupt for
    423   1.2   briggs 		 * slot 2.  INTC# becomes an interrupt for slot 1, etc.
    424   1.2   briggs 		 * In slot 2 aka device 16, INTD# becomes an interrupt for
    425   1.2   briggs 		 * slot 1, etc.
    426   1.2   briggs 		 *
    427   1.2   briggs 		 * Verified for INTD# on device 16, INTC# on device 16,
    428   1.2   briggs 		 * INTD# on device 15, INTD# on device 13, and INTC# on
    429   1.2   briggs 		 * device 14.  I presume that the rest follow the same
    430   1.2   briggs 		 * pattern.
    431   1.2   briggs 		 *
    432   1.2   briggs 		 * Slot 0 is device 13, and is the base for the rest.
    433   1.2   briggs 		 */
    434   1.2   briggs 		*iline = 13 + ((swiz + dev + 3) & 3);
    435   1.2   briggs 	}
    436   1.1   briggs }
    437