Home | History | Annotate | Line # | Download | only in pci
pci_550.c revision 1.13.8.3
      1  1.13.8.2   bouyer /* $NetBSD: pci_550.c,v 1.13.8.3 2001/03/27 15:30:10 bouyer Exp $ */
      2       1.1  thorpej 
      3       1.1  thorpej /*-
      4  1.13.8.1   bouyer  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
      5       1.1  thorpej  * All rights reserved.
      6       1.1  thorpej  *
      7       1.1  thorpej  * This code is derived from software contributed to The NetBSD Foundation
      8       1.3     ross  * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
      9       1.4  thorpej  * NASA Ames Research Center, and by Andrew Gallatin.
     10       1.1  thorpej  *
     11       1.1  thorpej  * Redistribution and use in source and binary forms, with or without
     12       1.1  thorpej  * modification, are permitted provided that the following conditions
     13       1.1  thorpej  * are met:
     14       1.1  thorpej  * 1. Redistributions of source code must retain the above copyright
     15       1.1  thorpej  *    notice, this list of conditions and the following disclaimer.
     16       1.1  thorpej  * 2. Redistributions in binary form must reproduce the above copyright
     17       1.1  thorpej  *    notice, this list of conditions and the following disclaimer in the
     18       1.1  thorpej  *    documentation and/or other materials provided with the distribution.
     19       1.1  thorpej  * 3. All advertising materials mentioning features or use of this software
     20       1.1  thorpej  *    must display the following acknowledgement:
     21       1.1  thorpej  *	This product includes software developed by the NetBSD
     22       1.1  thorpej  *	Foundation, Inc. and its contributors.
     23       1.1  thorpej  * 4. Neither the name of The NetBSD Foundation nor the names of its
     24       1.1  thorpej  *    contributors may be used to endorse or promote products derived
     25       1.1  thorpej  *    from this software without specific prior written permission.
     26       1.1  thorpej  *
     27       1.1  thorpej  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     28       1.1  thorpej  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     29       1.1  thorpej  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     30       1.1  thorpej  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     31       1.1  thorpej  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     32       1.1  thorpej  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     33       1.1  thorpej  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     34       1.1  thorpej  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     35       1.1  thorpej  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     36       1.1  thorpej  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     37       1.1  thorpej  * POSSIBILITY OF SUCH DAMAGE.
     38       1.1  thorpej  */
     39       1.1  thorpej 
     40       1.1  thorpej /*
     41       1.1  thorpej  * Copyright (c) 1995, 1996 Carnegie-Mellon University.
     42       1.1  thorpej  * All rights reserved.
     43       1.1  thorpej  *
     44       1.1  thorpej  * Author: Chris G. Demetriou
     45       1.1  thorpej  *
     46       1.1  thorpej  * Permission to use, copy, modify and distribute this software and
     47       1.1  thorpej  * its documentation is hereby granted, provided that both the copyright
     48       1.1  thorpej  * notice and this permission notice appear in all copies of the
     49       1.1  thorpej  * software, derivative works or modified versions, and any portions
     50       1.1  thorpej  * thereof, and that both notices appear in supporting documentation.
     51       1.1  thorpej  *
     52       1.1  thorpej  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
     53       1.1  thorpej  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
     54       1.1  thorpej  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
     55       1.1  thorpej  *
     56       1.1  thorpej  * Carnegie Mellon requests users of this software to return to
     57       1.1  thorpej  *
     58       1.1  thorpej  *  Software Distribution Coordinator  or  Software.Distribution (at) CS.CMU.EDU
     59       1.1  thorpej  *  School of Computer Science
     60       1.1  thorpej  *  Carnegie Mellon University
     61       1.1  thorpej  *  Pittsburgh PA 15213-3890
     62       1.1  thorpej  *
     63       1.1  thorpej  * any improvements or extensions that they make and grant Carnegie the
     64       1.1  thorpej  * rights to redistribute these changes.
     65       1.1  thorpej  */
     66       1.1  thorpej 
     67       1.1  thorpej #include <sys/cdefs.h>			/* RCS ID & Copyright macro defns */
     68       1.1  thorpej 
     69  1.13.8.2   bouyer __KERNEL_RCSID(0, "$NetBSD: pci_550.c,v 1.13.8.3 2001/03/27 15:30:10 bouyer Exp $");
     70       1.1  thorpej 
     71       1.1  thorpej #include <sys/types.h>
     72       1.1  thorpej #include <sys/param.h>
     73       1.1  thorpej #include <sys/time.h>
     74       1.1  thorpej #include <sys/systm.h>
     75       1.1  thorpej #include <sys/errno.h>
     76       1.1  thorpej #include <sys/malloc.h>
     77       1.1  thorpej #include <sys/device.h>
     78       1.1  thorpej #include <sys/syslog.h>
     79       1.1  thorpej 
     80  1.13.8.1   bouyer #include <uvm/uvm_extern.h>
     81       1.1  thorpej 
     82       1.1  thorpej #include <machine/autoconf.h>
     83       1.5  thorpej #include <machine/rpb.h>
     84       1.1  thorpej 
     85       1.1  thorpej #include <dev/pci/pcireg.h>
     86       1.1  thorpej #include <dev/pci/pcivar.h>
     87       1.1  thorpej #include <dev/pci/pciidereg.h>
     88       1.1  thorpej #include <dev/pci/pciidevar.h>
     89       1.1  thorpej 
     90       1.1  thorpej #include <alpha/pci/ciareg.h>
     91       1.1  thorpej #include <alpha/pci/ciavar.h>
     92       1.1  thorpej 
     93       1.1  thorpej #include <alpha/pci/pci_550.h>
     94       1.1  thorpej 
     95       1.1  thorpej #include "sio.h"
     96       1.1  thorpej #if NSIO
     97       1.1  thorpej #include <alpha/pci/siovar.h>
     98       1.1  thorpej #endif
     99       1.1  thorpej 
    100  1.13.8.2   bouyer int	dec_550_intr_map __P((struct pci_attach_args *,
    101       1.1  thorpej 	    pci_intr_handle_t *));
    102       1.1  thorpej const char *dec_550_intr_string __P((void *, pci_intr_handle_t));
    103  1.13.8.1   bouyer const struct evcnt *dec_550_intr_evcnt __P((void *, pci_intr_handle_t));
    104       1.1  thorpej void	*dec_550_intr_establish __P((void *, pci_intr_handle_t,
    105       1.1  thorpej 	    int, int (*func)(void *), void *));
    106       1.1  thorpej void	dec_550_intr_disestablish __P((void *, void *));
    107       1.1  thorpej 
    108       1.1  thorpej void	*dec_550_pciide_compat_intr_establish __P((void *, struct device *,
    109       1.1  thorpej 	    struct pci_attach_args *, int, int (*)(void *), void *));
    110       1.1  thorpej 
    111       1.1  thorpej #define	DEC_550_PCI_IRQ_BEGIN	8
    112  1.13.8.1   bouyer #define	DEC_550_MAX_IRQ		(64 - DEC_550_PCI_IRQ_BEGIN)
    113      1.10  thorpej 
    114      1.10  thorpej /*
    115      1.10  thorpej  * The Miata has a Pyxis, which seems to have problems with stray
    116      1.10  thorpej  * interrupts.  Work around this by just ignoring strays.
    117      1.10  thorpej  */
    118      1.10  thorpej #define	PCI_STRAY_MAX		0
    119       1.1  thorpej 
    120  1.13.8.1   bouyer /*
    121  1.13.8.1   bouyer  * Some Miata models, notably models with a Cypress PCI-ISA bridge, have
    122  1.13.8.1   bouyer  * a PCI device (the OHCI USB controller) with interrupts tied to ISA IRQ
    123  1.13.8.3   bouyer  * lines.  This IRQ is encoded as: line = FLAG | isa_irq. Usually FLAG
    124  1.13.8.3   bouyer  * is 0xe0, however, it can be 0xf0.  We don't allow 0xf0 | irq15.
    125  1.13.8.1   bouyer  */
    126  1.13.8.3   bouyer #define	DEC_550_LINE_IS_ISA(line)	((line) >= 0xe0 && (line) <= 0xfe)
    127  1.13.8.1   bouyer #define	DEC_550_LINE_ISA_IRQ(line)	((line) & 0x0f)
    128  1.13.8.1   bouyer 
    129       1.1  thorpej struct alpha_shared_intr *dec_550_pci_intr;
    130       1.1  thorpej 
    131       1.1  thorpej void	dec_550_iointr __P((void *framep, unsigned long vec));
    132       1.1  thorpej void	dec_550_intr_enable __P((int irq));
    133       1.1  thorpej void	dec_550_intr_disable __P((int irq));
    134       1.1  thorpej 
    135       1.1  thorpej void
    136       1.1  thorpej pci_550_pickintr(ccp)
    137       1.1  thorpej 	struct cia_config *ccp;
    138       1.1  thorpej {
    139       1.1  thorpej 	bus_space_tag_t iot = &ccp->cc_iot;
    140       1.1  thorpej 	pci_chipset_tag_t pc = &ccp->cc_pc;
    141  1.13.8.1   bouyer 	char *cp;
    142       1.1  thorpej 	int i;
    143       1.1  thorpej 
    144       1.1  thorpej         pc->pc_intr_v = ccp;
    145       1.1  thorpej         pc->pc_intr_map = dec_550_intr_map;
    146       1.1  thorpej         pc->pc_intr_string = dec_550_intr_string;
    147  1.13.8.1   bouyer 	pc->pc_intr_evcnt = dec_550_intr_evcnt;
    148       1.1  thorpej         pc->pc_intr_establish = dec_550_intr_establish;
    149       1.1  thorpej         pc->pc_intr_disestablish = dec_550_intr_disestablish;
    150       1.1  thorpej 
    151       1.1  thorpej 	pc->pc_pciide_compat_intr_establish =
    152       1.1  thorpej 	    dec_550_pciide_compat_intr_establish;
    153       1.1  thorpej 
    154       1.1  thorpej 	/*
    155       1.1  thorpej 	 * DEC 550's interrupts are enabled via the Pyxis interrupt
    156       1.7  thorpej 	 * mask register.  Nothing to map.
    157       1.1  thorpej 	 */
    158       1.1  thorpej 
    159       1.1  thorpej 	for (i = 0; i < DEC_550_MAX_IRQ; i++)
    160  1.13.8.1   bouyer 		dec_550_intr_disable(i);
    161  1.13.8.1   bouyer 
    162  1.13.8.1   bouyer 	dec_550_pci_intr = alpha_shared_intr_alloc(DEC_550_MAX_IRQ, 8);
    163  1.13.8.1   bouyer 	for (i = 0; i < DEC_550_MAX_IRQ; i++) {
    164       1.1  thorpej 		alpha_shared_intr_set_maxstrays(dec_550_pci_intr, i,
    165  1.13.8.1   bouyer 		    PCI_STRAY_MAX);
    166  1.13.8.1   bouyer 		alpha_shared_intr_set_private(dec_550_pci_intr, i, ccp);
    167  1.13.8.1   bouyer 
    168  1.13.8.1   bouyer 		cp = alpha_shared_intr_string(dec_550_pci_intr, i);
    169  1.13.8.1   bouyer 		sprintf(cp, "irq %d", i);
    170  1.13.8.1   bouyer 		evcnt_attach_dynamic(alpha_shared_intr_evcnt(
    171  1.13.8.1   bouyer 		    dec_550_pci_intr, i), EVCNT_TYPE_INTR, NULL,
    172  1.13.8.1   bouyer 		    "dec_550", cp);
    173  1.13.8.1   bouyer 	}
    174       1.1  thorpej 
    175       1.1  thorpej #if NSIO
    176       1.1  thorpej 	sio_intr_setup(pc, iot);
    177       1.1  thorpej #endif
    178       1.1  thorpej 
    179       1.1  thorpej 	set_iointr(dec_550_iointr);
    180       1.1  thorpej }
    181       1.1  thorpej 
    182       1.1  thorpej int
    183  1.13.8.2   bouyer dec_550_intr_map(pa, ihp)
    184  1.13.8.2   bouyer 	struct pci_attach_args *pa;
    185       1.1  thorpej         pci_intr_handle_t *ihp;
    186       1.1  thorpej {
    187  1.13.8.2   bouyer 	pcitag_t bustag = pa->pa_intrtag;
    188  1.13.8.2   bouyer 	int buspin = pa->pa_intrpin, line = pa->pa_intrline;
    189  1.13.8.2   bouyer 	pci_chipset_tag_t pc = pa->pa_pc;
    190       1.1  thorpej 	int bus, device, function;
    191       1.1  thorpej 
    192       1.1  thorpej 	if (buspin == 0) {
    193       1.1  thorpej 		/* No IRQ used. */
    194       1.1  thorpej 		return 1;
    195       1.1  thorpej 	}
    196       1.1  thorpej 	if (buspin > 4) {
    197       1.1  thorpej 		printf("dec_550_intr_map: bad interrupt pin %d\n", buspin);
    198       1.1  thorpej 		return 1;
    199       1.1  thorpej 	}
    200       1.1  thorpej 
    201       1.1  thorpej 	alpha_pci_decompose_tag(pc, bustag, &bus, &device, &function);
    202       1.1  thorpej 
    203       1.1  thorpej 	/*
    204       1.5  thorpej 	 * There are two main variants of Miata: Miata 1 (Intel SIO)
    205       1.5  thorpej 	 * and Miata {1.5,2} (Cypress).
    206       1.5  thorpej 	 *
    207       1.5  thorpej 	 * The Miata 1 has a CMD PCI IDE wired to compatibility mode at
    208       1.5  thorpej 	 * device 4 of bus 0.  This variant apparently also has the
    209       1.5  thorpej 	 * Pyxis DMA bug.
    210       1.5  thorpej 	 *
    211       1.5  thorpej 	 * On the Miata 1.5 and Miata 2, the Cypress PCI-ISA bridge lives
    212       1.5  thorpej 	 * on device 7 of bus 0.  This device has PCI IDE wired to
    213       1.5  thorpej 	 * compatibility mode on functions 1 and 2.
    214       1.5  thorpej 	 *
    215       1.5  thorpej 	 * There will be no interrupt mapping for these devices, so just
    216       1.5  thorpej 	 * bail out now.
    217       1.1  thorpej 	 */
    218       1.5  thorpej 	if (bus == 0) {
    219       1.5  thorpej 		if ((hwrpb->rpb_variation & SV_ST_MASK) < SV_ST_MIATA_1_5) {
    220       1.5  thorpej 			/* Miata 1 */
    221       1.5  thorpej 			if (device == 7)
    222       1.5  thorpej 				panic("dec_550_intr_map: SIO device");
    223       1.5  thorpej 			else if (device == 4)
    224       1.5  thorpej 				return (1);
    225       1.5  thorpej 		} else {
    226       1.5  thorpej 			/* Miata 1.5 or Miata 2 */
    227       1.5  thorpej 			if (device == 7) {
    228       1.5  thorpej 				if (function == 0)
    229       1.5  thorpej 					panic("dec_550_intr_map: SIO device");
    230  1.13.8.1   bouyer 				if (function == 1 || function == 2)
    231  1.13.8.1   bouyer 					return (1);
    232       1.5  thorpej 			}
    233       1.5  thorpej 		}
    234       1.1  thorpej 	}
    235       1.1  thorpej 
    236       1.1  thorpej 	/*
    237       1.1  thorpej 	 * The console places the interrupt mapping in the "line" value.
    238       1.1  thorpej 	 * A value of (char)-1 indicates there is no mapping.
    239       1.1  thorpej 	 */
    240       1.1  thorpej 	if (line == 0xff) {
    241       1.1  thorpej 		printf("dec_550_intr_map: no mapping for %d/%d/%d\n",
    242       1.1  thorpej 		    bus, device, function);
    243       1.1  thorpej 		return (1);
    244       1.1  thorpej 	}
    245       1.1  thorpej 
    246  1.13.8.1   bouyer #if NSIO == 0
    247  1.13.8.1   bouyer 	if (DEC_550_LINE_IS_ISA(line)) {
    248  1.13.8.1   bouyer 		printf("dec_550_intr_map: ISA IRQ %d for %d/%d/%d\n",
    249  1.13.8.1   bouyer 		    DEC_550_LINE_ISA_IRQ(line), bus, device, function);
    250  1.13.8.1   bouyer 		return (1);
    251  1.13.8.1   bouyer 	}
    252  1.13.8.1   bouyer #endif
    253       1.1  thorpej 
    254  1.13.8.3   bouyer 	if (DEC_550_LINE_IS_ISA(line) == 0 && line >= DEC_550_MAX_IRQ) {
    255  1.13.8.3   bouyer 		printf("dec_550_intr_map: irq %d out of range %d/%d/%d\n",
    256  1.13.8.3   bouyer 		    line, bus, device, function);
    257  1.13.8.3   bouyer 		return (1);
    258  1.13.8.3   bouyer 	}
    259       1.1  thorpej 	*ihp = line;
    260       1.1  thorpej 	return (0);
    261       1.1  thorpej }
    262       1.1  thorpej 
    263       1.1  thorpej const char *
    264       1.1  thorpej dec_550_intr_string(ccv, ih)
    265       1.1  thorpej 	void *ccv;
    266       1.1  thorpej 	pci_intr_handle_t ih;
    267       1.1  thorpej {
    268       1.1  thorpej #if 0
    269       1.1  thorpej 	struct cia_config *ccp = ccv;
    270       1.1  thorpej #endif
    271       1.1  thorpej 	static char irqstr[16];		/* 12 + 2 + NULL + sanity */
    272       1.1  thorpej 
    273  1.13.8.1   bouyer #if NSIO
    274  1.13.8.1   bouyer 	if (DEC_550_LINE_IS_ISA(ih))
    275  1.13.8.1   bouyer 		return (sio_intr_string(NULL /*XXX*/,
    276  1.13.8.1   bouyer 		    DEC_550_LINE_ISA_IRQ(ih)));
    277  1.13.8.1   bouyer #endif
    278  1.13.8.1   bouyer 
    279       1.1  thorpej 	if (ih >= DEC_550_MAX_IRQ)
    280      1.13  thorpej 		panic("dec_550_intr_string: bogus 550 IRQ 0x%lx\n", ih);
    281      1.13  thorpej 	sprintf(irqstr, "dec 550 irq %ld", ih);
    282       1.1  thorpej 	return (irqstr);
    283       1.1  thorpej }
    284       1.1  thorpej 
    285  1.13.8.1   bouyer const struct evcnt *
    286  1.13.8.1   bouyer dec_550_intr_evcnt(ccv, ih)
    287  1.13.8.1   bouyer 	void *ccv;
    288  1.13.8.1   bouyer 	pci_intr_handle_t ih;
    289  1.13.8.1   bouyer {
    290  1.13.8.1   bouyer #if 0
    291  1.13.8.1   bouyer 	struct cia_config *ccp = ccv;
    292  1.13.8.1   bouyer #endif
    293  1.13.8.1   bouyer 
    294  1.13.8.1   bouyer #if NSIO
    295  1.13.8.1   bouyer 	if (DEC_550_LINE_IS_ISA(ih))
    296  1.13.8.1   bouyer 		return (sio_intr_evcnt(NULL /*XXX*/,
    297  1.13.8.1   bouyer 		    DEC_550_LINE_ISA_IRQ(ih)));
    298  1.13.8.1   bouyer #endif
    299  1.13.8.1   bouyer 
    300  1.13.8.1   bouyer 	if (ih >= DEC_550_MAX_IRQ)
    301  1.13.8.1   bouyer 		panic("dec_550_intr_evcnt: bogus 550 IRQ 0x%lx\n", ih);
    302  1.13.8.1   bouyer 
    303  1.13.8.1   bouyer 	return (alpha_shared_intr_evcnt(dec_550_pci_intr, ih));
    304  1.13.8.1   bouyer }
    305  1.13.8.1   bouyer 
    306       1.1  thorpej void *
    307       1.1  thorpej dec_550_intr_establish(ccv, ih, level, func, arg)
    308       1.1  thorpej 	void *ccv, *arg;
    309       1.1  thorpej 	pci_intr_handle_t ih;
    310       1.1  thorpej 	int level;
    311       1.1  thorpej 	int (*func) __P((void *));
    312       1.1  thorpej {
    313       1.1  thorpej #if 0
    314       1.1  thorpej 	struct cia_config *ccp = ccv;
    315       1.1  thorpej #endif
    316       1.1  thorpej 	void *cookie;
    317       1.1  thorpej 
    318  1.13.8.1   bouyer #if NSIO
    319  1.13.8.1   bouyer 	if (DEC_550_LINE_IS_ISA(ih))
    320  1.13.8.1   bouyer 		return (sio_intr_establish(NULL /*XXX*/,
    321  1.13.8.1   bouyer 		    DEC_550_LINE_ISA_IRQ(ih), IST_LEVEL, level, func, arg));
    322  1.13.8.1   bouyer #endif
    323  1.13.8.1   bouyer 
    324       1.1  thorpej 	if (ih >= DEC_550_MAX_IRQ)
    325      1.13  thorpej 		panic("dec_550_intr_establish: bogus dec 550 IRQ 0x%lx\n", ih);
    326       1.1  thorpej 
    327       1.1  thorpej 	cookie = alpha_shared_intr_establish(dec_550_pci_intr, ih, IST_LEVEL,
    328       1.1  thorpej 	    level, func, arg, "dec 550 irq");
    329       1.1  thorpej 
    330       1.1  thorpej 	if (cookie != NULL && alpha_shared_intr_isactive(dec_550_pci_intr, ih))
    331       1.1  thorpej 		dec_550_intr_enable(ih);
    332       1.1  thorpej 	return (cookie);
    333       1.1  thorpej }
    334       1.1  thorpej 
    335       1.1  thorpej void
    336       1.1  thorpej dec_550_intr_disestablish(ccv, cookie)
    337       1.1  thorpej         void *ccv, *cookie;
    338       1.1  thorpej {
    339       1.1  thorpej 	struct cia_config *ccp = ccv;
    340      1.12  thorpej 	struct alpha_shared_intrhand *ih = cookie;
    341      1.12  thorpej 	unsigned int irq = ih->ih_num;
    342      1.12  thorpej 	int s;
    343  1.13.8.1   bouyer 
    344  1.13.8.1   bouyer #if NSIO
    345  1.13.8.1   bouyer 	/*
    346  1.13.8.1   bouyer 	 * We have to determine if this is an ISA IRQ or not!  We do this
    347  1.13.8.1   bouyer 	 * by checking to see if the intrhand points back to an intrhead
    348  1.13.8.1   bouyer 	 * that points to our cia_config.  If not, it's an ISA IRQ.  Pretty
    349  1.13.8.1   bouyer 	 * disgusting, eh?
    350  1.13.8.1   bouyer 	 */
    351  1.13.8.1   bouyer 	if (ih->ih_intrhead->intr_private != ccp) {
    352  1.13.8.1   bouyer 		sio_intr_disestablish(NULL /*XXX*/, cookie);
    353  1.13.8.1   bouyer 		return;
    354  1.13.8.1   bouyer 	}
    355  1.13.8.1   bouyer #endif
    356      1.12  thorpej 
    357      1.12  thorpej 	s = splhigh();
    358      1.12  thorpej 
    359      1.12  thorpej 	alpha_shared_intr_disestablish(dec_550_pci_intr, cookie,
    360      1.12  thorpej 	    "dec 550 irq");
    361      1.12  thorpej 	if (alpha_shared_intr_isactive(dec_550_pci_intr, irq) == 0) {
    362      1.12  thorpej 		dec_550_intr_disable(irq);
    363      1.12  thorpej 		alpha_shared_intr_set_dfltsharetype(dec_550_pci_intr, irq,
    364      1.12  thorpej 		    IST_NONE);
    365      1.12  thorpej 	}
    366      1.12  thorpej 
    367      1.12  thorpej 	splx(s);
    368       1.1  thorpej }
    369       1.1  thorpej 
    370       1.1  thorpej void *
    371       1.1  thorpej dec_550_pciide_compat_intr_establish(v, dev, pa, chan, func, arg)
    372       1.1  thorpej 	void *v;
    373       1.1  thorpej 	struct device *dev;
    374       1.1  thorpej 	struct pci_attach_args *pa;
    375       1.1  thorpej 	int chan;
    376       1.1  thorpej 	int (*func) __P((void *));
    377       1.1  thorpej 	void *arg;
    378       1.1  thorpej {
    379       1.1  thorpej 	pci_chipset_tag_t pc = pa->pa_pc;
    380       1.1  thorpej 	void *cookie = NULL;
    381       1.1  thorpej 	int bus, irq;
    382       1.1  thorpej 
    383       1.1  thorpej 	alpha_pci_decompose_tag(pc, pa->pa_tag, &bus, NULL, NULL);
    384       1.1  thorpej 
    385       1.1  thorpej 	/*
    386       1.1  thorpej 	 * If this isn't PCI bus #0, all bets are off.
    387       1.1  thorpej 	 */
    388       1.1  thorpej 	if (bus != 0)
    389       1.1  thorpej 		return (NULL);
    390       1.1  thorpej 
    391       1.1  thorpej 	irq = PCIIDE_COMPAT_IRQ(chan);
    392       1.1  thorpej #if NSIO
    393       1.1  thorpej 	cookie = sio_intr_establish(NULL /*XXX*/, irq, IST_EDGE, IPL_BIO,
    394       1.1  thorpej 	    func, arg);
    395  1.13.8.1   bouyer 	if (cookie == NULL)
    396  1.13.8.1   bouyer 		return (NULL);
    397  1.13.8.1   bouyer 	printf("%s: %s channel interrupting at %s\n", dev->dv_xname,
    398  1.13.8.1   bouyer 	    PCIIDE_CHANNEL_NAME(chan), sio_intr_string(NULL /*XXX*/, irq));
    399       1.1  thorpej #endif
    400       1.1  thorpej 	return (cookie);
    401       1.1  thorpej }
    402       1.1  thorpej 
    403       1.1  thorpej void
    404       1.1  thorpej dec_550_iointr(framep, vec)
    405       1.1  thorpej 	void *framep;
    406       1.1  thorpej 	unsigned long vec;
    407       1.1  thorpej {
    408       1.1  thorpej 	int irq;
    409       1.1  thorpej 
    410       1.1  thorpej 	if (vec >= 0x900) {
    411  1.13.8.1   bouyer 		irq = ((vec - 0x900) >> 4);
    412       1.1  thorpej 
    413       1.1  thorpej 		if (irq >= DEC_550_MAX_IRQ)
    414      1.13  thorpej 			panic("550_iointr: vec 0x%lx out of range\n", vec);
    415       1.1  thorpej 
    416       1.1  thorpej 		if (!alpha_shared_intr_dispatch(dec_550_pci_intr, irq)) {
    417       1.1  thorpej 			alpha_shared_intr_stray(dec_550_pci_intr, irq,
    418       1.1  thorpej 			    "dec 550 irq");
    419      1.11  thorpej 			if (ALPHA_SHARED_INTR_DISABLE(dec_550_pci_intr, irq))
    420       1.1  thorpej 				dec_550_intr_disable(irq);
    421       1.1  thorpej 		}
    422       1.1  thorpej 		return;
    423       1.1  thorpej 	}
    424       1.1  thorpej #if NSIO
    425       1.1  thorpej 	if (vec >= 0x800) {
    426       1.1  thorpej 		sio_iointr(framep, vec);
    427       1.1  thorpej 		return;
    428       1.1  thorpej 	}
    429       1.1  thorpej #endif
    430      1.13  thorpej 	panic("dec_550_iointr: weird vec 0x%lx\n", vec);
    431       1.1  thorpej }
    432       1.1  thorpej 
    433       1.1  thorpej void
    434       1.1  thorpej dec_550_intr_enable(irq)
    435       1.1  thorpej 	int irq;
    436       1.1  thorpej {
    437       1.1  thorpej 
    438  1.13.8.1   bouyer 	cia_pyxis_intr_enable(irq + DEC_550_PCI_IRQ_BEGIN, 1);
    439       1.1  thorpej }
    440       1.1  thorpej 
    441       1.1  thorpej void
    442       1.1  thorpej dec_550_intr_disable(irq)
    443       1.1  thorpej 	int irq;
    444       1.1  thorpej {
    445       1.1  thorpej 
    446  1.13.8.1   bouyer 	cia_pyxis_intr_enable(irq + DEC_550_PCI_IRQ_BEGIN, 0);
    447       1.1  thorpej }
    448