Home | History | Annotate | Line # | Download | only in dev
pci_machdep.c revision 1.18
      1  1.18    martin /*	$NetBSD: pci_machdep.c,v 1.18 2001/01/19 21:25:19 martin Exp $	*/
      2   1.1       mrg 
      3   1.1       mrg /*
      4   1.5       mrg  * Copyright (c) 1999, 2000 Matthew R. Green
      5   1.1       mrg  * All rights reserved.
      6   1.1       mrg  *
      7   1.1       mrg  * Redistribution and use in source and binary forms, with or without
      8   1.1       mrg  * modification, are permitted provided that the following conditions
      9   1.1       mrg  * are met:
     10   1.1       mrg  * 1. Redistributions of source code must retain the above copyright
     11   1.1       mrg  *    notice, this list of conditions and the following disclaimer.
     12   1.1       mrg  * 2. Redistributions in binary form must reproduce the above copyright
     13   1.1       mrg  *    notice, this list of conditions and the following disclaimer in the
     14   1.1       mrg  *    documentation and/or other materials provided with the distribution.
     15   1.1       mrg  * 3. The name of the author may not be used to endorse or promote products
     16   1.1       mrg  *    derived from this software without specific prior written permission.
     17   1.1       mrg  *
     18   1.1       mrg  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     19   1.1       mrg  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     20   1.1       mrg  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     21   1.1       mrg  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     22   1.1       mrg  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
     23   1.1       mrg  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
     24   1.1       mrg  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
     25   1.1       mrg  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
     26   1.1       mrg  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     27   1.1       mrg  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     28   1.1       mrg  * SUCH DAMAGE.
     29   1.1       mrg  */
     30   1.1       mrg 
     31   1.1       mrg /*
     32   1.1       mrg  * functions expected by the MI PCI code.
     33   1.1       mrg  */
     34   1.1       mrg 
     35   1.1       mrg #ifdef DEBUG
     36   1.1       mrg #define SPDB_CONF	0x01
     37   1.1       mrg #define SPDB_INTR	0x04
     38   1.1       mrg #define SPDB_INTMAP	0x08
     39   1.1       mrg #define SPDB_INTFIX	0x10
     40   1.4       mrg int sparc_pci_debug = 0x0;
     41   1.1       mrg #define DPRINTF(l, s)	do { if (sparc_pci_debug & l) printf s; } while (0)
     42   1.1       mrg #else
     43   1.1       mrg #define DPRINTF(l, s)
     44   1.1       mrg #endif
     45   1.1       mrg 
     46   1.1       mrg #include <sys/types.h>
     47   1.1       mrg #include <sys/param.h>
     48   1.1       mrg #include <sys/time.h>
     49   1.1       mrg #include <sys/systm.h>
     50   1.1       mrg #include <sys/errno.h>
     51   1.1       mrg #include <sys/device.h>
     52   1.1       mrg #include <sys/malloc.h>
     53   1.1       mrg 
     54   1.1       mrg #define _SPARC_BUS_DMA_PRIVATE
     55   1.1       mrg #include <machine/bus.h>
     56   1.1       mrg #include <machine/autoconf.h>
     57   1.1       mrg 
     58   1.1       mrg #include <dev/pci/pcivar.h>
     59   1.1       mrg #include <dev/pci/pcireg.h>
     60   1.1       mrg 
     61   1.1       mrg #include <sparc64/dev/iommureg.h>
     62   1.1       mrg #include <sparc64/dev/iommuvar.h>
     63   1.1       mrg #include <sparc64/dev/psychoreg.h>
     64   1.1       mrg #include <sparc64/dev/psychovar.h>
     65   1.1       mrg 
     66   1.1       mrg /* this is a base to be copied */
     67   1.1       mrg struct sparc_pci_chipset _sparc_pci_chipset = {
     68   1.1       mrg 	NULL,
     69   1.1       mrg };
     70   1.2       mrg 
     71   1.1       mrg /*
     72   1.1       mrg  * functions provided to the MI code.
     73   1.1       mrg  */
     74   1.1       mrg 
     75   1.1       mrg void
     76   1.1       mrg pci_attach_hook(parent, self, pba)
     77   1.1       mrg 	struct device *parent;
     78   1.1       mrg 	struct device *self;
     79   1.1       mrg 	struct pcibus_attach_args *pba;
     80   1.1       mrg {
     81   1.1       mrg 	pci_chipset_tag_t pc = pba->pba_pc;
     82   1.1       mrg 	struct psycho_pbm *pp = pc->cookie;
     83   1.1       mrg 	struct psycho_registers *pr;
     84   1.1       mrg 	pcitag_t tag;
     85   1.1       mrg 	char *name, *devtype;
     86   1.1       mrg 	u_int32_t hi, mid, lo, intr;
     87   1.2       mrg 	u_int32_t dev, fn, bus;
     88   1.1       mrg 	int node, i, n, *ip, *ap;
     89   1.1       mrg 
     90   1.1       mrg 	DPRINTF((SPDB_INTFIX|SPDB_INTMAP), ("\npci_attach_hook:"));
     91   1.1       mrg 
     92   1.1       mrg 	/*
     93   1.1       mrg 	 * ok, here we look in the OFW for each PCI device and fix it's
     94   1.1       mrg 	 * "interrupt line" register to be useful.
     95   1.1       mrg 	 */
     96   1.1       mrg 
     97   1.1       mrg 	for (node = firstchild(pc->node); node; node = nextsibling(node)) {
     98   1.1       mrg 		pr = NULL;
     99   1.1       mrg 		ip = ap = NULL;
    100   1.1       mrg 
    101   1.1       mrg 		/*
    102   1.1       mrg 		 * ok, for each child we get the "interrupts" property,
    103   1.1       mrg 		 * which contains a value to match against later.
    104   1.1       mrg 		 * XXX deal with multiple "interrupts" values XXX.
    105   1.1       mrg 		 * then we get the "assigned-addresses" property which
    106   1.1       mrg 		 * contains, in the first entry, the PCI bus, device and
    107   1.1       mrg 		 * function associated with this node, which we use to
    108   1.1       mrg 		 * generate a pcitag_t to use pci_conf_read() and
    109   1.1       mrg 		 * pci_conf_write().  next, we get the 'reg" property
    110   1.1       mrg 		 * which is structured like the following:
    111   1.1       mrg 		 *	u_int32_t	phys_hi;
    112   1.1       mrg 		 *	u_int32_t	phys_mid;
    113   1.1       mrg 		 *	u_int32_t	phys_lo;
    114   1.1       mrg 		 *	u_int32_t	size_hi;
    115   1.1       mrg 		 *	u_int32_t	size_lo;
    116   1.1       mrg 		 * we mask these values with the "interrupt-map-mask"
    117   1.1       mrg 		 * property of our parent and them compare with each
    118   1.1       mrg 		 * entry in the "interrupt-map" property (also of our
    119   1.1       mrg 		 * parent) which is structred like the following:
    120   1.1       mrg 		 *	u_int32_t	phys_hi;
    121   1.1       mrg 		 *	u_int32_t	phys_mid;
    122   1.1       mrg 		 *	u_int32_t	phys_lo;
    123   1.1       mrg 		 *	u_int32_t	intr;
    124   1.1       mrg 		 *	int32_t		child_node;
    125   1.1       mrg 		 *	u_int32_t	child_intr;
    126   1.1       mrg 		 * if there is an exact match with phys_hi, phys_mid,
    127   1.1       mrg 		 * phys_lo and the interrupt, we have a match and we
    128   1.1       mrg 		 * know that this interrupt's value is really the
    129   1.1       mrg 		 * child_intr of the interrupt map entry.  we put this
    130   1.1       mrg 		 * into the PCI interrupt line register so that when
    131   1.1       mrg 		 * the driver for this node wants to attach, we know
    132   1.1       mrg 		 * it's INO already.
    133   1.1       mrg 		 */
    134   1.1       mrg 
    135   1.1       mrg 		name = getpropstring(node, "name");
    136   1.1       mrg 		DPRINTF((SPDB_INTFIX|SPDB_INTMAP), ("\n\tnode %x name `%s'", node, name));
    137   1.1       mrg 		devtype = getpropstring(node, "device_type");
    138   1.1       mrg 		DPRINTF((SPDB_INTFIX|SPDB_INTMAP), (" devtype `%s':", devtype));
    139   1.1       mrg 
    140   1.1       mrg 		/* ignore PCI bridges, we'll get them later */
    141   1.1       mrg 		if (strcmp(devtype, "pci") == 0)
    142   1.1       mrg 			continue;
    143   1.1       mrg 
    144   1.1       mrg 		/* if there isn't any "interrupts" then we don't care to fix it */
    145   1.1       mrg 		ip = NULL;
    146   1.1       mrg 		if (getprop(node, "interrupts", sizeof(int), &n, (void **)&ip))
    147   1.1       mrg 			continue;
    148   1.1       mrg 		DPRINTF(SPDB_INTFIX, (" got interrupts"));
    149   1.1       mrg 
    150   1.1       mrg 		/* and if there isn't an "assigned-addresses" we can't find b/d/f */
    151   1.1       mrg 		if (getprop(node, "assigned-addresses", sizeof(int), &n,
    152   1.1       mrg 		    (void **)&ap))
    153   1.1       mrg 			goto clean1;
    154   1.1       mrg 		DPRINTF(SPDB_INTFIX, (" got assigned-addresses"));
    155   1.1       mrg 
    156   1.1       mrg 		/* ok, and now the "reg" property, so we know what we're talking about. */
    157   1.1       mrg 		if (getprop(node, "reg", sizeof(*pr), &n,
    158   1.1       mrg 		    (void **)&pr))
    159   1.1       mrg 			goto clean2;
    160   1.1       mrg 		DPRINTF(SPDB_INTFIX, (" got reg"));
    161   1.1       mrg 
    162   1.2       mrg 		bus = TAG2BUS(ap[0]);
    163   1.2       mrg 		dev = TAG2DEV(ap[0]);
    164   1.2       mrg 		fn = TAG2FN(ap[0]);
    165   1.1       mrg 
    166   1.1       mrg 		DPRINTF(SPDB_INTFIX, ("; bus %u dev %u fn %u", bus, dev, fn));
    167   1.1       mrg 
    168   1.1       mrg 		tag = pci_make_tag(pc, bus, dev, fn);
    169   1.1       mrg 
    170   1.1       mrg 		DPRINTF(SPDB_INTFIX, ("; tag %08x\n\t; reg: hi %x mid %x lo %x intr %x", tag, pr->phys_hi, pr->phys_mid, pr->phys_lo, *ip));
    171   1.1       mrg 		DPRINTF(SPDB_INTFIX, ("\n\t; intmapmask: hi %x mid %x lo %x intr %x", pp->pp_intmapmask.phys_hi, pp->pp_intmapmask.phys_mid,
    172   1.1       mrg 										      pp->pp_intmapmask.phys_lo, pp->pp_intmapmask.intr));
    173   1.1       mrg 
    174   1.1       mrg 		hi = pr->phys_hi & pp->pp_intmapmask.phys_hi;
    175   1.1       mrg 		mid = pr->phys_mid & pp->pp_intmapmask.phys_mid;
    176   1.1       mrg 		lo = pr->phys_lo & pp->pp_intmapmask.phys_lo;
    177   1.1       mrg 		intr = *ip & pp->pp_intmapmask.intr;
    178   1.1       mrg 
    179   1.1       mrg 		DPRINTF(SPDB_INTFIX, ("\n\t; after: hi %x mid %x lo %x intr %x", hi, mid, lo, intr));
    180   1.1       mrg 
    181   1.1       mrg 		for (i = 0; i < pp->pp_nintmap; i++) {
    182   1.1       mrg 			DPRINTF(SPDB_INTFIX, ("\n\t\tmatching for: hi %x mid %x lo %x intr %x", pp->pp_intmap[i].phys_hi, pp->pp_intmap[i].phys_mid,
    183   1.1       mrg 												pp->pp_intmap[i].phys_lo, pp->pp_intmap[i].intr));
    184   1.1       mrg 
    185   1.1       mrg 			if (pp->pp_intmap[i].phys_hi != hi ||
    186   1.1       mrg 			    pp->pp_intmap[i].phys_mid != mid ||
    187   1.1       mrg 			    pp->pp_intmap[i].phys_lo != lo ||
    188   1.1       mrg 			    pp->pp_intmap[i].intr != intr)
    189   1.1       mrg 				continue;
    190   1.1       mrg 			DPRINTF(SPDB_INTFIX, ("... BINGO! ..."));
    191   1.1       mrg 
    192  1.15        pk 		bingo:
    193   1.1       mrg 			/*
    194   1.1       mrg 			 * OK!  we found match.  pull out the old interrupt
    195   1.1       mrg 			 * register, patch in the new value, and put it back.
    196   1.1       mrg 			 */
    197   1.1       mrg 			intr = pci_conf_read(pc, tag, PCI_INTERRUPT_REG);
    198   1.1       mrg 			DPRINTF(SPDB_INTFIX, ("\n\t    ; read %x from intreg", intr));
    199   1.1       mrg 
    200   1.1       mrg 			intr = (intr & ~PCI_INTERRUPT_LINE_MASK) |
    201   1.1       mrg 			       (pp->pp_intmap[i].child_intr & PCI_INTERRUPT_LINE_MASK);
    202   1.1       mrg 			DPRINTF((SPDB_INTFIX|SPDB_INTMAP), ("\n\t    ; gonna write %x to intreg", intr));
    203   1.1       mrg 			pci_conf_write(pc, tag, PCI_INTERRUPT_REG, intr);
    204   1.1       mrg 			DPRINTF((SPDB_INTFIX|SPDB_INTMAP), ("\n\t    ; reread %x from intreg", intr));
    205   1.1       mrg 			break;
    206  1.15        pk 		}
    207  1.15        pk 		if (i == pp->pp_nintmap) {
    208  1.15        pk 			/*
    209  1.15        pk 			 * Not matched by parent interrupt map. If the
    210  1.15        pk 			 * interrupt property has the INTMAP_OBIO bit
    211  1.15        pk 			 * set, assume the PROM has (wrongly) supplied it
    212  1.15        pk 			 * in the parent's bus format, rather than as a
    213  1.15        pk 			 * PCI interrupt line number.
    214  1.15        pk 			 *
    215  1.15        pk 			 * This seems to be an issue only with the
    216  1.15        pk 			 * psycho host-to-pci bridge.
    217  1.15        pk 			 */
    218  1.15        pk 			if (pp->pp_sc->sc_mode == PSYCHO_MODE_PSYCHO &&
    219  1.15        pk 			    (*ip & INTMAP_OBIO) != 0) {
    220  1.15        pk 				DPRINTF((SPDB_INTFIX|SPDB_INTMAP),
    221  1.15        pk 		("\n\t; PSYCHO: no match but obio interrupt in parent format"));
    222  1.15        pk 
    223  1.15        pk 				i = -1; goto bingo; /* XXX - hackish.. */
    224  1.15        pk 			}
    225   1.1       mrg 		}
    226   1.1       mrg 
    227   1.9       eeh 		/* enable mem & dma if not already */
    228   1.9       eeh 		pci_conf_write(pc, tag, PCI_COMMAND_STATUS_REG,
    229  1.18    martin 			PCI_COMMAND_MEM_ENABLE|PCI_COMMAND_MASTER_ENABLE|PCI_COMMAND_IO_ENABLE);
    230   1.9       eeh 
    231   1.9       eeh 
    232   1.1       mrg 		/* clean up */
    233   1.1       mrg 		if (pr)
    234   1.1       mrg 			free(pr, M_DEVBUF);
    235   1.1       mrg clean2:
    236   1.1       mrg 		if (ap)
    237   1.1       mrg 			free(ap, M_DEVBUF);
    238   1.1       mrg clean1:
    239   1.1       mrg 		if (ip)
    240   1.1       mrg 			free(ip, M_DEVBUF);
    241   1.1       mrg 	}
    242   1.1       mrg 	DPRINTF(SPDB_INTFIX, ("\n"));
    243   1.1       mrg }
    244   1.1       mrg 
    245   1.1       mrg int
    246   1.1       mrg pci_bus_maxdevs(pc, busno)
    247   1.1       mrg 	pci_chipset_tag_t pc;
    248   1.1       mrg 	int busno;
    249   1.1       mrg {
    250   1.1       mrg 
    251   1.1       mrg 	return 32;
    252   1.1       mrg }
    253   1.1       mrg 
    254   1.1       mrg pcitag_t
    255   1.1       mrg pci_make_tag(pc, b, d, f)
    256   1.1       mrg 	pci_chipset_tag_t pc;
    257   1.1       mrg 	int b;
    258   1.1       mrg 	int d;
    259   1.1       mrg 	int f;
    260   1.1       mrg {
    261   1.1       mrg 
    262   1.2       mrg 	/* make me a useable offset */
    263   1.1       mrg 	return (b << 16) | (d << 11) | (f << 8);
    264   1.1       mrg }
    265   1.1       mrg 
    266   1.1       mrg static int confaddr_ok __P((struct psycho_softc *, pcitag_t));
    267   1.1       mrg 
    268   1.1       mrg /*
    269   1.1       mrg  * this function is a large hack.  ideally, we should also trap accesses
    270   1.1       mrg  * properly, but we have to avoid letting anything read various parts
    271   1.1       mrg  * of bus 0 dev 0 fn 0 space or the machine may hang.  so, even if we
    272   1.1       mrg  * do properly implement PCI config access trap handling, this function
    273   1.1       mrg  * should remain in place Just In Case.
    274   1.1       mrg  */
    275   1.1       mrg static int
    276   1.1       mrg confaddr_ok(sc, tag)
    277   1.1       mrg 	struct psycho_softc *sc;
    278   1.1       mrg 	pcitag_t tag;
    279   1.1       mrg {
    280   1.1       mrg 	int bus, dev, fn;
    281   1.1       mrg 
    282   1.2       mrg 	bus = TAG2BUS(tag);
    283   1.2       mrg 	dev = TAG2DEV(tag);
    284   1.2       mrg 	fn = TAG2FN(tag);
    285   1.1       mrg 
    286   1.1       mrg 	if (sc->sc_mode == PSYCHO_MODE_SABRE) {
    287   1.1       mrg 		/*
    288   1.1       mrg 		 * bus 0 is only ok for dev 0 fn 0, dev 1 fn 0 and dev fn 1.
    289   1.1       mrg 		 */
    290   1.1       mrg 		if (bus == 0 &&
    291   1.1       mrg 		    ((dev == 0 && fn > 0) ||
    292   1.1       mrg 		     (dev == 1 && fn > 1) ||
    293   1.1       mrg 		     (dev > 1))) {
    294   1.1       mrg 			DPRINTF(SPDB_CONF, (" confaddr_ok: rejecting bus %d dev %d fn %d -", bus, dev, fn));
    295   1.1       mrg 			return (0);
    296   1.1       mrg 		}
    297  1.14        pk 	} else if (sc->sc_mode == PSYCHO_MODE_PSYCHO) {
    298   1.1       mrg 		/*
    299   1.1       mrg 		 * make sure we are reading our own bus
    300   1.1       mrg 		 */
    301   1.1       mrg 		/* XXX??? */
    302  1.14        pk 		paddr_t addr = sc->sc_configaddr + tag;
    303  1.14        pk 		int asi = bus_type_asi[sc->sc_configtag->type];
    304  1.14        pk 		if (probeget(addr, asi, 4) == -1) {
    305  1.14        pk 			DPRINTF(SPDB_CONF, (" confaddr_ok: rejecting bus %d dev %d fn %d -", bus, dev, fn));
    306  1.14        pk 			return (0);
    307  1.14        pk 		}
    308   1.1       mrg 	}
    309   1.1       mrg 	return (1);
    310   1.1       mrg }
    311   1.1       mrg 
    312   1.1       mrg /* assume we are mapped little-endian/side-effect */
    313   1.1       mrg pcireg_t
    314   1.1       mrg pci_conf_read(pc, tag, reg)
    315   1.1       mrg 	pci_chipset_tag_t pc;
    316   1.1       mrg 	pcitag_t tag;
    317   1.1       mrg 	int reg;
    318   1.1       mrg {
    319   1.1       mrg 	struct psycho_pbm *pp = pc->cookie;
    320   1.1       mrg 	struct psycho_softc *sc = pp->pp_sc;
    321   1.1       mrg 	pcireg_t val;
    322   1.1       mrg 
    323   1.1       mrg 	DPRINTF(SPDB_CONF, ("pci_conf_read: tag %lx; reg %x; ", (long)tag, reg));
    324   1.1       mrg 	DPRINTF(SPDB_CONF, ("asi = %x; readaddr = %qx (offset = %x) ...",
    325   1.1       mrg 		    bus_type_asi[sc->sc_configtag->type],
    326  1.17    martin 		    (long long)(sc->sc_configaddr + tag + reg), (int)tag + reg));
    327   1.1       mrg 
    328   1.1       mrg 	if (confaddr_ok(sc, tag) == 0) {
    329   1.1       mrg 		val = (pcireg_t)~0;
    330   1.1       mrg 	} else {
    331   1.1       mrg 		membar_sync();
    332   1.1       mrg 		val = bus_space_read_4(sc->sc_configtag, sc->sc_configaddr,
    333   1.1       mrg 		    tag + reg);
    334   1.1       mrg 		membar_sync();
    335   1.1       mrg 	}
    336   1.1       mrg 	DPRINTF(SPDB_CONF, (" returning %08x\n", (u_int)val));
    337   1.1       mrg 
    338   1.1       mrg 	return (val);
    339   1.1       mrg }
    340   1.1       mrg 
    341   1.1       mrg void
    342   1.1       mrg pci_conf_write(pc, tag, reg, data)
    343   1.1       mrg 	pci_chipset_tag_t pc;
    344   1.1       mrg 	pcitag_t tag;
    345   1.1       mrg 	int reg;
    346   1.1       mrg 	pcireg_t data;
    347   1.1       mrg {
    348   1.1       mrg 	struct psycho_pbm *pp = pc->cookie;
    349   1.1       mrg 	struct psycho_softc *sc = pp->pp_sc;
    350   1.1       mrg 
    351  1.14        pk 	DPRINTF(SPDB_CONF, ("pci_conf_write: tag %lx; reg %x; data %x; ", (long)tag, reg, (int)data));
    352   1.1       mrg 	DPRINTF(SPDB_CONF, ("asi = %x; readaddr = %qx (offset = %x)\n",
    353   1.1       mrg 		    bus_type_asi[sc->sc_configtag->type],
    354  1.17    martin 		    (long long)(sc->sc_configaddr + tag + reg), (int)tag + reg));
    355   1.1       mrg 
    356   1.1       mrg 	if (confaddr_ok(sc, tag) == 0)
    357   1.1       mrg 		panic("pci_conf_write: bad addr");
    358   1.1       mrg 
    359   1.3       eeh 	membar_sync();
    360   1.1       mrg 	bus_space_write_4(sc->sc_configtag, sc->sc_configaddr, tag + reg, data);
    361   1.3       eeh 	membar_sync();
    362   1.1       mrg }
    363   1.1       mrg 
    364   1.1       mrg /*
    365   1.1       mrg  * interrupt mapping foo.
    366   1.1       mrg  */
    367   1.1       mrg int
    368  1.16  sommerfe pci_intr_map(pa, ihp)
    369  1.16  sommerfe 	struct pci_attach_args *pa;
    370   1.1       mrg 	pci_intr_handle_t *ihp;
    371   1.1       mrg {
    372  1.16  sommerfe #if 0
    373  1.16  sommerfe 	pci_chipset_tag_t pc = pa->pa_pc;
    374  1.16  sommerfe #endif
    375  1.16  sommerfe 	pcitag_t tag = pa->pa_intrtag;
    376  1.16  sommerfe 	int pin = pa->pa_intrpin;
    377  1.16  sommerfe 	int line = pa->pa_intrline;
    378   1.1       mrg 	int rv;
    379   1.1       mrg 
    380   1.6       mrg 	/*
    381   1.6       mrg 	 * XXX
    382   1.6       mrg 	 * UltraSPARC IIi PCI does not use PCI_INTERRUPT_REG, but we have
    383   1.6       mrg 	 * used this space for our own purposes...
    384   1.6       mrg 	 */
    385   1.9       eeh 	DPRINTF(SPDB_INTR, ("pci_intr_map: tag %lx; pin %d; line %d",
    386   1.9       eeh 		(long)tag, pin, line));
    387   1.6       mrg #if 1
    388   1.4       mrg 	if (line == 255) {
    389   1.1       mrg 		*ihp = -1;
    390   1.1       mrg 		rv = 1;
    391   1.1       mrg 		goto out;
    392   1.1       mrg 	}
    393   1.6       mrg #endif
    394   1.1       mrg 	if (pin > 4)
    395   1.1       mrg 		panic("pci_intr_map: pin > 4");
    396   1.1       mrg 
    397   1.1       mrg 	rv = psycho_intr_map(tag, pin, line, ihp);
    398   1.1       mrg 
    399   1.1       mrg out:
    400   1.1       mrg 	DPRINTF(SPDB_INTR, ("; handle = %d; returning %d\n", (int)*ihp, rv));
    401   1.1       mrg 	return (rv);
    402   1.1       mrg }
    403   1.1       mrg 
    404   1.1       mrg const char *
    405   1.1       mrg pci_intr_string(pc, ih)
    406   1.1       mrg 	pci_chipset_tag_t pc;
    407   1.1       mrg 	pci_intr_handle_t ih;
    408   1.1       mrg {
    409   1.1       mrg 	static char str[16];
    410   1.1       mrg 
    411   1.1       mrg 	DPRINTF(SPDB_INTR, ("pci_intr_string: ih %u", ih));
    412   1.1       mrg 	if (ih < 0 || ih > 0x32) {
    413   1.1       mrg 		printf("\n");	/* i'm *so* beautiful */
    414   1.1       mrg 		panic("pci_intr_string: bogus handle\n");
    415   1.1       mrg 	}
    416   1.1       mrg 	sprintf(str, "vector %u", ih);
    417   1.1       mrg 	DPRINTF(SPDB_INTR, ("; returning %s\n", str));
    418   1.1       mrg 
    419   1.1       mrg 	return (str);
    420   1.8       cgd }
    421   1.8       cgd 
    422   1.8       cgd const struct evcnt *
    423   1.8       cgd pci_intr_evcnt(pc, ih)
    424   1.8       cgd 	pci_chipset_tag_t pc;
    425   1.8       cgd 	pci_intr_handle_t ih;
    426   1.8       cgd {
    427   1.8       cgd 
    428   1.8       cgd 	/* XXX for now, no evcnt parent reported */
    429   1.8       cgd 	return NULL;
    430   1.1       mrg }
    431   1.1       mrg 
    432   1.1       mrg void *
    433   1.1       mrg pci_intr_establish(pc, ih, level, func, arg)
    434   1.1       mrg 	pci_chipset_tag_t pc;
    435   1.1       mrg 	pci_intr_handle_t ih;
    436   1.1       mrg 	int level;
    437   1.1       mrg 	int (*func) __P((void *));
    438   1.1       mrg 	void *arg;
    439   1.1       mrg {
    440   1.1       mrg 	void *cookie;
    441   1.1       mrg 	struct psycho_pbm *pp = (struct psycho_pbm *)pc->cookie;
    442   1.1       mrg 
    443   1.1       mrg 	DPRINTF(SPDB_INTR, ("pci_intr_establish: ih %lu; level %d", (u_long)ih, level));
    444  1.13        pk 	cookie = bus_intr_establish(pp->pp_memt, ih, level, 0, func, arg);
    445   1.1       mrg 
    446   1.1       mrg 	DPRINTF(SPDB_INTR, ("; returning handle %p\n", cookie));
    447   1.1       mrg 	return (cookie);
    448   1.1       mrg }
    449   1.1       mrg 
    450   1.1       mrg void
    451   1.1       mrg pci_intr_disestablish(pc, cookie)
    452   1.1       mrg 	pci_chipset_tag_t pc;
    453   1.1       mrg 	void *cookie;
    454   1.1       mrg {
    455   1.1       mrg 
    456   1.1       mrg 	DPRINTF(SPDB_INTR, ("pci_intr_disestablish: cookie %p\n", cookie));
    457   1.1       mrg 
    458   1.1       mrg 	/* XXX */
    459   1.1       mrg 	panic("can't disestablish PCI interrupts yet");
    460   1.1       mrg }
    461