Home | History | Annotate | Line # | Download | only in marvell
mvpex.c revision 1.2
      1  1.2  kiyohara /*	$NetBSD: mvpex.c,v 1.2 2010/08/01 06:57:06 kiyohara Exp $	*/
      2  1.1  kiyohara /*
      3  1.1  kiyohara  * Copyright (c) 2008 KIYOHARA Takashi
      4  1.1  kiyohara  * All rights reserved.
      5  1.1  kiyohara  *
      6  1.1  kiyohara  * Redistribution and use in source and binary forms, with or without
      7  1.1  kiyohara  * modification, are permitted provided that the following conditions
      8  1.1  kiyohara  * are met:
      9  1.1  kiyohara  * 1. Redistributions of source code must retain the above copyright
     10  1.1  kiyohara  *    notice, this list of conditions and the following disclaimer.
     11  1.1  kiyohara  * 2. Redistributions in binary form must reproduce the above copyright
     12  1.1  kiyohara  *    notice, this list of conditions and the following disclaimer in the
     13  1.1  kiyohara  *    documentation and/or other materials provided with the distribution.
     14  1.1  kiyohara  *
     15  1.1  kiyohara  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     16  1.1  kiyohara  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
     17  1.1  kiyohara  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
     18  1.1  kiyohara  * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
     19  1.1  kiyohara  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     20  1.1  kiyohara  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     21  1.1  kiyohara  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     22  1.1  kiyohara  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     23  1.1  kiyohara  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
     24  1.1  kiyohara  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     25  1.1  kiyohara  * POSSIBILITY OF SUCH DAMAGE.
     26  1.1  kiyohara  */
     27  1.1  kiyohara 
     28  1.1  kiyohara #include <sys/cdefs.h>
     29  1.2  kiyohara __KERNEL_RCSID(0, "$NetBSD: mvpex.c,v 1.2 2010/08/01 06:57:06 kiyohara Exp $");
     30  1.1  kiyohara 
     31  1.1  kiyohara #include "opt_pci.h"
     32  1.1  kiyohara #include "pci.h"
     33  1.1  kiyohara 
     34  1.1  kiyohara #include <sys/param.h>
     35  1.1  kiyohara #include <sys/bus.h>
     36  1.1  kiyohara #include <sys/device.h>
     37  1.1  kiyohara #include <sys/errno.h>
     38  1.1  kiyohara #include <sys/extent.h>
     39  1.1  kiyohara #include <sys/evcnt.h>
     40  1.1  kiyohara #include <sys/malloc.h>
     41  1.1  kiyohara #include <sys/systm.h>
     42  1.1  kiyohara 
     43  1.1  kiyohara #include <prop/proplib.h>
     44  1.1  kiyohara 
     45  1.1  kiyohara #include <dev/pci/pcivar.h>
     46  1.1  kiyohara #include <dev/pci/pcireg.h>
     47  1.1  kiyohara #include <dev/pci/pciconf.h>
     48  1.1  kiyohara 
     49  1.1  kiyohara #include <dev/marvell/mvpexreg.h>
     50  1.1  kiyohara #include <dev/marvell/mvpexvar.h>
     51  1.1  kiyohara #include <dev/marvell/marvellreg.h>
     52  1.1  kiyohara #include <dev/marvell/marvellvar.h>
     53  1.1  kiyohara 
     54  1.1  kiyohara #include <machine/pci_machdep.h>
     55  1.1  kiyohara 
     56  1.1  kiyohara #include "locators.h"
     57  1.1  kiyohara 
     58  1.1  kiyohara 
     59  1.1  kiyohara static int mvpex_match(device_t, struct cfdata *, void *);
     60  1.1  kiyohara static void mvpex_attach(device_t, device_t, void *);
     61  1.1  kiyohara 
     62  1.1  kiyohara static int mvpex_intr(void *);
     63  1.1  kiyohara 
     64  1.1  kiyohara static void mvpex_init(struct mvpex_softc *);
     65  1.1  kiyohara #if 0	/* shall move to pchb(4)? */
     66  1.1  kiyohara static void mvpex_barinit(struct mvpex_softc *);
     67  1.1  kiyohara static int mvpex_wininit(struct mvpex_softc *, int, int, int, int, uint32_t *,
     68  1.1  kiyohara 			 uint32_t *);
     69  1.1  kiyohara #else
     70  1.1  kiyohara static void mvpex_wininit(struct mvpex_softc *);
     71  1.1  kiyohara #endif
     72  1.1  kiyohara #if NPCI > 0
     73  1.1  kiyohara static void mvpex_pci_config(struct mvpex_softc *, bus_space_tag_t,
     74  1.1  kiyohara 			     bus_space_tag_t, bus_dma_tag_t, pci_chipset_tag_t,
     75  1.1  kiyohara 			     u_long, u_long, u_long, u_long, int);
     76  1.1  kiyohara #endif
     77  1.1  kiyohara 
     78  1.1  kiyohara CFATTACH_DECL_NEW(mvpex_gt, sizeof(struct mvpex_softc),
     79  1.1  kiyohara     mvpex_match, mvpex_attach, NULL, NULL);
     80  1.1  kiyohara CFATTACH_DECL_NEW(mvpex_mbus, sizeof(struct mvpex_softc),
     81  1.1  kiyohara     mvpex_match, mvpex_attach, NULL, NULL);
     82  1.1  kiyohara 
     83  1.1  kiyohara 
     84  1.1  kiyohara /* ARGSUSED */
     85  1.1  kiyohara static int
     86  1.1  kiyohara mvpex_match(device_t parent, struct cfdata *match, void *aux)
     87  1.1  kiyohara {
     88  1.1  kiyohara 	struct marvell_attach_args *mva = aux;
     89  1.1  kiyohara 
     90  1.2  kiyohara 	if (strcmp(mva->mva_name, match->cf_name) != 0)
     91  1.1  kiyohara 		return 0;
     92  1.1  kiyohara 	if (mva->mva_offset == MVA_OFFSET_DEFAULT ||
     93  1.1  kiyohara 	    mva->mva_irq == MVA_IRQ_DEFAULT)
     94  1.1  kiyohara 		return 0;
     95  1.1  kiyohara 
     96  1.1  kiyohara 	mva->mva_size = MVPEX_SIZE;
     97  1.1  kiyohara 	return 1;
     98  1.1  kiyohara }
     99  1.1  kiyohara 
    100  1.1  kiyohara /* ARGSUSED */
    101  1.1  kiyohara static void
    102  1.1  kiyohara mvpex_attach(device_t parent, device_t self, void *aux)
    103  1.1  kiyohara {
    104  1.1  kiyohara 	struct mvpex_softc *sc = device_private(self);
    105  1.1  kiyohara 	struct marvell_attach_args *mva = aux;
    106  1.1  kiyohara #if NPCI > 0
    107  1.1  kiyohara 	prop_dictionary_t dict = device_properties(self);
    108  1.1  kiyohara 	prop_object_t pc, iot, memt;
    109  1.1  kiyohara 	pci_chipset_tag_t mvpex_chipset;
    110  1.1  kiyohara 	bus_space_tag_t mvpex_io_bs_tag, mvpex_mem_bs_tag;
    111  1.1  kiyohara 	uint64_t iostart = 0, ioend = 0, memstart = 0, memend = 0;
    112  1.1  kiyohara 	uint32_t cl_size;
    113  1.1  kiyohara 	int i;
    114  1.1  kiyohara #endif
    115  1.1  kiyohara 
    116  1.1  kiyohara 	aprint_normal(": Marvell PCI Express Interface\n");
    117  1.1  kiyohara 	aprint_naive("\n");
    118  1.1  kiyohara 
    119  1.1  kiyohara #if NPCI > 0
    120  1.1  kiyohara 	iot = prop_dictionary_get(dict, "io-bus-tag");
    121  1.1  kiyohara 	if (iot == NULL) {
    122  1.1  kiyohara 		aprint_error_dev(self, "no io-bus-tag property\n");
    123  1.1  kiyohara 		return;
    124  1.1  kiyohara 	}
    125  1.1  kiyohara 	KASSERT(prop_object_type(iot) == PROP_TYPE_DATA);
    126  1.1  kiyohara 	mvpex_io_bs_tag = __UNCONST(prop_data_data_nocopy(iot));
    127  1.1  kiyohara 	memt = prop_dictionary_get(dict, "mem-bus-tag");
    128  1.1  kiyohara 	if (memt == NULL) {
    129  1.1  kiyohara 		aprint_error_dev(self, "no mem-bus-tag property\n");
    130  1.1  kiyohara 		return;
    131  1.1  kiyohara 	}
    132  1.1  kiyohara 	KASSERT(prop_object_type(memt) == PROP_TYPE_DATA);
    133  1.1  kiyohara 	mvpex_mem_bs_tag = __UNCONST(prop_data_data_nocopy(memt));
    134  1.1  kiyohara 	pc = prop_dictionary_get(dict, "pci-chipset");
    135  1.1  kiyohara 	if (pc == NULL) {
    136  1.1  kiyohara 		aprint_error_dev(self, "no pci-chipset property\n");
    137  1.1  kiyohara 		return;
    138  1.1  kiyohara 	}
    139  1.1  kiyohara 	KASSERT(prop_object_type(pc) == PROP_TYPE_DATA);
    140  1.1  kiyohara 	mvpex_chipset = __UNCONST(prop_data_data_nocopy(pc));
    141  1.1  kiyohara #ifdef PCI_NETBSD_CONFIGURE
    142  1.1  kiyohara 	if (!prop_dictionary_get_uint64(dict, "iostart", &iostart)) {
    143  1.1  kiyohara 		aprint_error_dev(self, "no iostart property\n");
    144  1.1  kiyohara 		return;
    145  1.1  kiyohara 	}
    146  1.1  kiyohara 	if (!prop_dictionary_get_uint64(dict, "ioend", &ioend)) {
    147  1.1  kiyohara 		aprint_error_dev(self, "no ioend property\n");
    148  1.1  kiyohara 		return;
    149  1.1  kiyohara 	}
    150  1.1  kiyohara 	if (!prop_dictionary_get_uint64(dict, "memstart", &memstart)) {
    151  1.1  kiyohara 		aprint_error_dev(self, "no memstart property\n");
    152  1.1  kiyohara 		return;
    153  1.1  kiyohara 	}
    154  1.1  kiyohara 	if (!prop_dictionary_get_uint64(dict, "memend", &memend)) {
    155  1.1  kiyohara 		aprint_error_dev(self, "no memend property\n");
    156  1.1  kiyohara 		return;
    157  1.1  kiyohara 	}
    158  1.1  kiyohara 	if (!prop_dictionary_get_uint32(dict, "cache-line-size", &cl_size)) {
    159  1.1  kiyohara 		aprint_error_dev(self, "no cache-line-size property\n");
    160  1.1  kiyohara 		return;
    161  1.1  kiyohara 	}
    162  1.1  kiyohara #endif
    163  1.1  kiyohara #endif
    164  1.1  kiyohara 
    165  1.1  kiyohara 	sc->sc_dev = self;
    166  1.1  kiyohara 	sc->sc_model = mva->mva_model;
    167  1.1  kiyohara 	sc->sc_rev = mva->mva_revision;
    168  1.1  kiyohara 	sc->sc_offset = mva->mva_offset;
    169  1.1  kiyohara 	sc->sc_iot = mva->mva_iot;
    170  1.1  kiyohara 
    171  1.1  kiyohara 	/* Map I/O registers for mvpex */
    172  1.1  kiyohara 	if (bus_space_subregion(mva->mva_iot, mva->mva_ioh, mva->mva_offset,
    173  1.1  kiyohara 	    mva->mva_size, &sc->sc_ioh)) {
    174  1.1  kiyohara 		aprint_error_dev(self, "can't map registers\n");
    175  1.1  kiyohara 		return;
    176  1.1  kiyohara 	}
    177  1.1  kiyohara 	mvpex_init(sc);
    178  1.1  kiyohara 
    179  1.1  kiyohara 	/* XXX: looks seem good to specify level IPL_VM. */
    180  1.1  kiyohara 	marvell_intr_establish(mva->mva_irq, IPL_VM, mvpex_intr, sc);
    181  1.1  kiyohara 
    182  1.1  kiyohara #if NPCI > 0
    183  1.1  kiyohara 	for (i = 0; i < PCI_INTERRUPT_PIN_MAX; i++) {
    184  1.1  kiyohara 		sc->sc_intrtab[i].intr_pin = PCI_INTERRUPT_PIN_A + i;
    185  1.1  kiyohara 		sc->sc_intrtab[i].intr_refcnt = 0;
    186  1.1  kiyohara 		LIST_INIT(&sc->sc_intrtab[i].intr_list);
    187  1.1  kiyohara 	}
    188  1.1  kiyohara 
    189  1.1  kiyohara 	mvpex_pci_config(sc, mvpex_io_bs_tag, mvpex_mem_bs_tag, mva->mva_dmat,
    190  1.1  kiyohara 	    mvpex_chipset, iostart, ioend, memstart, memend, cl_size);
    191  1.1  kiyohara #endif
    192  1.1  kiyohara }
    193  1.1  kiyohara 
    194  1.1  kiyohara static int
    195  1.1  kiyohara mvpex_intr(void *arg)
    196  1.1  kiyohara {
    197  1.1  kiyohara 	struct mvpex_softc *sc = (struct mvpex_softc *)arg;
    198  1.1  kiyohara 	struct mvpex_intrhand *ih;
    199  1.1  kiyohara 	struct mvpex_intrtab *intrtab;
    200  1.1  kiyohara 	uint32_t ic, im;
    201  1.1  kiyohara 	int handled = 0, pin, rv, i, s;
    202  1.1  kiyohara 
    203  1.1  kiyohara 	for (;;) {
    204  1.1  kiyohara 		ic = bus_space_read_4(sc->sc_iot, sc->sc_ioh, MVPEX_IC);
    205  1.1  kiyohara 		im = bus_space_read_4(sc->sc_iot, sc->sc_ioh, MVPEX_IM);
    206  1.1  kiyohara 		ic &= im;
    207  1.1  kiyohara 
    208  1.1  kiyohara 		if (!ic)
    209  1.1  kiyohara 			break;
    210  1.1  kiyohara 
    211  1.1  kiyohara 		for (i = 0, pin = PCI_INTERRUPT_PIN_A;
    212  1.1  kiyohara 		    i < PCI_INTERRUPT_PIN_MAX; pin++, i++) {
    213  1.1  kiyohara 			if ((ic & MVPEX_I_PIN(pin)) == 0)
    214  1.1  kiyohara 				continue;
    215  1.1  kiyohara 
    216  1.1  kiyohara 			intrtab = &sc->sc_intrtab[i];
    217  1.1  kiyohara 			LIST_FOREACH(ih, &intrtab->intr_list, ih_q) {
    218  1.1  kiyohara 				s = _splraise(ih->ih_type);
    219  1.1  kiyohara 				rv = (*ih->ih_func)(ih->ih_arg);
    220  1.1  kiyohara 				splx(s);
    221  1.1  kiyohara 				if (rv) {
    222  1.1  kiyohara 					ih->ih_evcnt.ev_count++;
    223  1.1  kiyohara 					handled++;
    224  1.1  kiyohara 				}
    225  1.1  kiyohara 			}
    226  1.1  kiyohara 			bus_space_write_4(sc->sc_iot, sc->sc_ioh, MVPEX_IC,
    227  1.1  kiyohara 			    ~MVPEX_I_PIN(pin));
    228  1.1  kiyohara 		}
    229  1.1  kiyohara 	}
    230  1.1  kiyohara 
    231  1.1  kiyohara 	return handled;
    232  1.1  kiyohara }
    233  1.1  kiyohara 
    234  1.1  kiyohara 
    235  1.1  kiyohara static void
    236  1.1  kiyohara mvpex_init(struct mvpex_softc *sc)
    237  1.1  kiyohara {
    238  1.1  kiyohara 	uint32_t reg;
    239  1.1  kiyohara 	int window;
    240  1.1  kiyohara 
    241  1.1  kiyohara 	/*
    242  1.1  kiyohara 	 * First implement Guideline (GL# PCI Express-2) Wrong Default Value
    243  1.1  kiyohara 	 * to Transmitter Output Current (TXAMP) Relevant for: 88F5181-A1/B0/B1
    244  1.1  kiyohara 	 * and 88F5281-B0
    245  1.1  kiyohara 	 */
    246  1.1  kiyohara 						/* Write the read command */
    247  1.1  kiyohara 	bus_space_write_4(sc->sc_iot, sc->sc_ioh, 0x1b00, 0x80820000);
    248  1.1  kiyohara 	reg = bus_space_read_4(sc->sc_iot, sc->sc_ioh, 0x1b00);
    249  1.1  kiyohara 	/* Prepare new data for write */
    250  1.1  kiyohara 	reg &= ~0x7;		/* Clear bits [2:0] */
    251  1.1  kiyohara 	reg |= 0x4;		/* Set the new value */
    252  1.1  kiyohara 	reg &= ~0x80000000;	/* Set "write" command */
    253  1.1  kiyohara 	bus_space_write_4(sc->sc_iot, sc->sc_ioh, 0x1b00, reg);
    254  1.1  kiyohara 
    255  1.1  kiyohara 	for (window = 0; window < MVPEX_NWINDOW; window++)
    256  1.1  kiyohara 		bus_space_write_4(sc->sc_iot, sc->sc_ioh, MVPEX_WC(window), 0);
    257  1.1  kiyohara 
    258  1.1  kiyohara #if 0	/* shall move to pchb(4)? */
    259  1.1  kiyohara 	mvpex_barinit(sc);
    260  1.1  kiyohara #else
    261  1.1  kiyohara 	mvpex_wininit(sc);
    262  1.1  kiyohara #endif
    263  1.1  kiyohara 
    264  1.1  kiyohara 	/* Clear Interrupt Cause and Mask registers */
    265  1.1  kiyohara 	bus_space_write_4(sc->sc_iot, sc->sc_ioh, MVPEX_IC, 0);
    266  1.1  kiyohara 	bus_space_write_4(sc->sc_iot, sc->sc_ioh, MVPEX_IM, 0);
    267  1.1  kiyohara 
    268  1.1  kiyohara 	/* now wait 60 ns to be sure the link is valid (spec compliant) */
    269  1.1  kiyohara 	delay(1);
    270  1.1  kiyohara }
    271  1.1  kiyohara 
    272  1.1  kiyohara #if 0
    273  1.1  kiyohara static int
    274  1.1  kiyohara mvpex_wininit(struct mvpex_softc *sc, int window, int tbegin, int tend,
    275  1.1  kiyohara 	      int barmap, uint32_t *barbase, uint32_t *barsize)
    276  1.1  kiyohara {
    277  1.1  kiyohara 	uint32_t target, attr, base, size;
    278  1.1  kiyohara 	int targetid;
    279  1.1  kiyohara 
    280  1.1  kiyohara 	for (targetid = tbegin; targetid <= tend && window < MVPEX_NWINDOW;
    281  1.1  kiyohara 	    targetid++) {
    282  1.1  kiyohara 		if (orion_target(targetid, &target, &attr, &base, &size) == -1)
    283  1.1  kiyohara 			continue;
    284  1.1  kiyohara 		if (size == 0)
    285  1.1  kiyohara 			continue;
    286  1.1  kiyohara 
    287  1.1  kiyohara 		if (base < *barbase)
    288  1.1  kiyohara 			*barbase = base;
    289  1.1  kiyohara 		*barsize += size;
    290  1.1  kiyohara 
    291  1.1  kiyohara 		bus_space_write_4(sc->sc_iot, sc->sc_ioh, MVPEX_WC(window),
    292  1.1  kiyohara 		    MVPEX_WC_WINEN		|
    293  1.1  kiyohara 		    barmap			|
    294  1.1  kiyohara 		    MVPEX_WC_TARGET(target)	|
    295  1.1  kiyohara 		    MVPEX_WC_ATTR(attr)		|
    296  1.1  kiyohara 		    MVPEX_WC_SIZE(size));
    297  1.1  kiyohara 		bus_space_write_4(sc->sc_iot, sc->sc_ioh, MVPEX_WB(window),
    298  1.1  kiyohara 		    MVPEX_WB_BASE(base));
    299  1.1  kiyohara 		bus_space_write_4(sc->sc_iot, sc->sc_ioh, MVPEX_WR(window), 0);
    300  1.1  kiyohara 		window++;
    301  1.1  kiyohara 	}
    302  1.1  kiyohara 
    303  1.1  kiyohara 	return window;
    304  1.1  kiyohara }
    305  1.1  kiyohara 
    306  1.1  kiyohara /* shall move to pchb(4)? */
    307  1.1  kiyohara static void
    308  1.1  kiyohara mvpex_barinit(struct mvpex_softc *sc)
    309  1.1  kiyohara {
    310  1.1  kiyohara 	const uint32_t barflag =
    311  1.1  kiyohara 	    PCI_MAPREG_MEM_PREFETCHABLE_MASK | PCI_MAPREG_MEM_TYPE_64BIT;
    312  1.1  kiyohara 	uint32_t base, size;
    313  1.1  kiyohara 	int window = 0;
    314  1.1  kiyohara 
    315  1.1  kiyohara 	marvell_winparams_by_tag(device_parent(sc->sc_dev),
    316  1.1  kiyohara 	    ORION_TARGETID_INTERNALREG, NULL, NULL, &base, &size);
    317  1.1  kiyohara 	bus_space_write_4(sc->sc_iot, sc->sc_ioh, MVPEX_BAR0INTERNAL,
    318  1.1  kiyohara 	    barflag | (base & MVPEX_BAR0INTERNAL_MASK));
    319  1.1  kiyohara 	bus_space_write_4(sc->sc_iot, sc->sc_ioh, MVPEX_BAR0INTERNALH, 0);
    320  1.1  kiyohara 
    321  1.1  kiyohara 	base = size = 0;
    322  1.1  kiyohara 	window = mvpex_wininit(sc, window, ORION_TARGETID_SDRAM_CS0,
    323  1.1  kiyohara 	    ORION_TARGETID_SDRAM_CS3, MVPEX_WC_BARMAP_BAR1, &base, &size);
    324  1.1  kiyohara 	bus_space_write_4(sc->sc_iot, sc->sc_ioh, MVPEX_BAR1,
    325  1.1  kiyohara 	    barflag | (base & MVPEX_BAR_MASK));
    326  1.1  kiyohara 	bus_space_write_4(sc->sc_iot, sc->sc_ioh, MVPEX_BAR1H, 0);
    327  1.1  kiyohara 	bus_space_write_4(sc->sc_iot, sc->sc_ioh, MVPEX_BAR1C,
    328  1.1  kiyohara 	    MVPEX_BARC_BARSIZE(size) | MVPEX_BARC_BAREN);
    329  1.1  kiyohara 
    330  1.1  kiyohara #if 0
    331  1.1  kiyohara 	base = size = 0;
    332  1.1  kiyohara 	if (sc->sc_model == MARVELL_ORION_1_88F1181)
    333  1.1  kiyohara 		window = mvpex_wininit(sc, window, ORION_TARGETID_FLASH_CS,
    334  1.1  kiyohara 		    ORION_TARGETID_DEVICE_BOOTCS,
    335  1.1  kiyohara 		    MVPEX_WC_BARMAP_BAR2, &base, &size);
    336  1.1  kiyohara 	else {
    337  1.1  kiyohara 		window = mvpex_wininit(sc, window,
    338  1.1  kiyohara 		    ORION_TARGETID_DEVICE_CS0, ORION_TARGETID_DEVICE_CS2,
    339  1.1  kiyohara 		    MVPEX_WC_BARMAP_BAR2, &base, &size);
    340  1.1  kiyohara 		window = mvpex_wininit(sc, window,
    341  1.1  kiyohara 		    ORION_TARGETID_DEVICE_BOOTCS, ORION_TARGETID_DEVICE_BOOTCS,
    342  1.1  kiyohara 		    MVPEX_WC_BARMAP_BAR2, &base, &size);
    343  1.1  kiyohara 	}
    344  1.1  kiyohara 	bus_space_write_4(sc->sc_iot, sc->sc_ioh, MVPEX_BAR2,
    345  1.1  kiyohara 	    barflag | (base & MVPEX_BAR_MASK));
    346  1.1  kiyohara 	bus_space_write_4(sc->sc_iot, sc->sc_ioh, MVPEX_BAR2H, 0);
    347  1.1  kiyohara 	bus_space_write_4(sc->sc_iot, sc->sc_ioh, MVPEX_BAR2C,
    348  1.1  kiyohara 	    MVPEX_BARC_BARSIZE(size) | MVPEX_BARC_BAREN);
    349  1.1  kiyohara #else
    350  1.1  kiyohara 	bus_space_write_4(sc->sc_iot, sc->sc_ioh, MVPEX_BAR2C, 0);
    351  1.1  kiyohara #endif
    352  1.1  kiyohara }
    353  1.1  kiyohara #else
    354  1.1  kiyohara static void
    355  1.1  kiyohara mvpex_wininit(struct mvpex_softc *sc)
    356  1.1  kiyohara {
    357  1.1  kiyohara 	device_t pdev = device_parent(sc->sc_dev);
    358  1.1  kiyohara 	uint64_t base;
    359  1.1  kiyohara 	uint32_t size;
    360  1.1  kiyohara 	int target, attr, window, rv, i;
    361  1.1  kiyohara 	static struct {
    362  1.1  kiyohara 		int tag;
    363  1.1  kiyohara 		int bar;
    364  1.1  kiyohara 	} tags[] = {
    365  1.1  kiyohara 		{ MARVELL_TAG_SDRAM_CS0,	MVPEX_WC_BARMAP_BAR1	},
    366  1.1  kiyohara 		{ MARVELL_TAG_SDRAM_CS1,	MVPEX_WC_BARMAP_BAR1	},
    367  1.1  kiyohara 		{ MARVELL_TAG_SDRAM_CS2,	MVPEX_WC_BARMAP_BAR1	},
    368  1.1  kiyohara 		{ MARVELL_TAG_SDRAM_CS3,	MVPEX_WC_BARMAP_BAR1	},
    369  1.1  kiyohara 
    370  1.1  kiyohara 		{ MARVELL_TAG_UNDEFINED,	0			},
    371  1.1  kiyohara 	};
    372  1.1  kiyohara 
    373  1.1  kiyohara 	for (window = 0, i = 0;
    374  1.1  kiyohara 	    tags[i].tag != MARVELL_TAG_UNDEFINED && window < MVPEX_NWINDOW;
    375  1.1  kiyohara 	    i++) {
    376  1.1  kiyohara 		rv = marvell_winparams_by_tag(pdev, tags[i].tag,
    377  1.1  kiyohara 		    &target, &attr, &base, &size);
    378  1.1  kiyohara 		if (rv != 0 || size == 0)
    379  1.1  kiyohara 			continue;
    380  1.1  kiyohara 
    381  1.1  kiyohara 		if (base > 0xffffffffULL) {
    382  1.1  kiyohara 			aprint_error_dev(sc->sc_dev,
    383  1.1  kiyohara 			    "tag %d address 0x%llx not support\n",
    384  1.1  kiyohara 			    tags[i].tag, base);
    385  1.1  kiyohara 			continue;
    386  1.1  kiyohara 		}
    387  1.1  kiyohara 
    388  1.1  kiyohara 		bus_space_write_4(sc->sc_iot, sc->sc_ioh, MVPEX_WC(window),
    389  1.1  kiyohara 		    MVPEX_WC_WINEN		|
    390  1.1  kiyohara 		    tags[i].bar			|
    391  1.1  kiyohara 		    MVPEX_WC_TARGET(target)	|
    392  1.1  kiyohara 		    MVPEX_WC_ATTR(attr)		|
    393  1.1  kiyohara 		    MVPEX_WC_SIZE(size));
    394  1.1  kiyohara 		bus_space_write_4(sc->sc_iot, sc->sc_ioh, MVPEX_WB(window),
    395  1.1  kiyohara 		    MVPEX_WB_BASE(base));
    396  1.1  kiyohara 		bus_space_write_4(sc->sc_iot, sc->sc_ioh, MVPEX_WR(window), 0);
    397  1.1  kiyohara 		window++;
    398  1.1  kiyohara 	}
    399  1.1  kiyohara 	for ( ; window < MVPEX_NWINDOW; window++)
    400  1.1  kiyohara 		bus_space_write_4(sc->sc_iot, sc->sc_ioh, MVPEX_WC(window), 0);
    401  1.1  kiyohara }
    402  1.1  kiyohara #endif
    403  1.1  kiyohara 
    404  1.1  kiyohara #if NPCI > 0
    405  1.1  kiyohara static void
    406  1.1  kiyohara mvpex_pci_config(struct mvpex_softc *sc, bus_space_tag_t iot,
    407  1.1  kiyohara 		 bus_space_tag_t memt, bus_dma_tag_t dmat, pci_chipset_tag_t pc,
    408  1.1  kiyohara 		 u_long iostart, u_long ioend, u_long memstart, u_long memend,
    409  1.1  kiyohara 		 int cacheline_size)
    410  1.1  kiyohara {
    411  1.1  kiyohara 	struct pcibus_attach_args pba;
    412  1.1  kiyohara #ifdef PCI_NETBSD_CONFIGURE
    413  1.1  kiyohara 	struct extent *ioext = NULL, *memext = NULL;
    414  1.1  kiyohara #endif
    415  1.1  kiyohara 	uint32_t stat;
    416  1.1  kiyohara 
    417  1.1  kiyohara 	stat = bus_space_read_4(sc->sc_iot, sc->sc_ioh, MVPEX_STAT);
    418  1.1  kiyohara 
    419  1.1  kiyohara #ifdef PCI_NETBSD_CONFIGURE
    420  1.1  kiyohara 	ioext = extent_create("pexio", iostart, ioend, M_DEVBUF, NULL, 0,
    421  1.1  kiyohara 	    EX_NOWAIT);
    422  1.1  kiyohara 	memext = extent_create("pexmem", memstart, memend, M_DEVBUF, NULL, 0,
    423  1.1  kiyohara 	    EX_NOWAIT);
    424  1.1  kiyohara 	if (ioext != NULL && memext != NULL)
    425  1.1  kiyohara 		pci_configure_bus(pc, ioext, memext, NULL,
    426  1.1  kiyohara 		    MVPEX_STAT_PEXBUSNUM(stat), cacheline_size);
    427  1.1  kiyohara         else
    428  1.1  kiyohara 		aprint_error_dev(sc->sc_dev, "can't create extent %s%s%s\n",
    429  1.1  kiyohara 		    ioext == NULL ? "io" : "",
    430  1.1  kiyohara 		    ioext == NULL && memext == NULL ? " and " : "",
    431  1.1  kiyohara 		    memext == NULL ? "mem" : "");
    432  1.1  kiyohara 	if (ioext != NULL)
    433  1.1  kiyohara 		extent_destroy(ioext);
    434  1.1  kiyohara 	if (memext != NULL)
    435  1.1  kiyohara 		extent_destroy(memext);
    436  1.1  kiyohara #endif
    437  1.1  kiyohara 
    438  1.1  kiyohara 	pba.pba_iot = iot;
    439  1.1  kiyohara 	pba.pba_memt = memt;
    440  1.1  kiyohara 	pba.pba_dmat = dmat;
    441  1.1  kiyohara 	pba.pba_dmat64 = NULL;
    442  1.1  kiyohara 	pba.pba_pc = pc;
    443  1.1  kiyohara 	pba.pba_flags = PCI_FLAGS_IO_ENABLED | PCI_FLAGS_MEM_ENABLED;
    444  1.1  kiyohara 	pba.pba_bus = MVPEX_STAT_PEXBUSNUM(stat);
    445  1.1  kiyohara 	pba.pba_bridgetag = NULL;
    446  1.1  kiyohara 	config_found_ia(sc->sc_dev, "pcibus", &pba, NULL);
    447  1.1  kiyohara }
    448  1.1  kiyohara 
    449  1.1  kiyohara 
    450  1.1  kiyohara /*
    451  1.1  kiyohara  * PCI-Express CPU dependent code
    452  1.1  kiyohara  */
    453  1.1  kiyohara 
    454  1.1  kiyohara /* ARGSUSED */
    455  1.1  kiyohara void
    456  1.1  kiyohara mvpex_attach_hook(device_t parent, device_t self,
    457  1.1  kiyohara 		  struct pcibus_attach_args *pba)
    458  1.1  kiyohara {
    459  1.1  kiyohara 
    460  1.1  kiyohara 	/* Nothing */
    461  1.1  kiyohara }
    462  1.1  kiyohara 
    463  1.1  kiyohara /*
    464  1.1  kiyohara  * Bit map for configuration register:
    465  1.1  kiyohara  *   [31]    ConfigEn
    466  1.1  kiyohara  *   [30:28] Reserved
    467  1.1  kiyohara  *   [27:24] ExtRegNum (PCI Express only)
    468  1.1  kiyohara  *   [23:16] BusNum
    469  1.1  kiyohara  *   [15:11] DevNum
    470  1.1  kiyohara  *   [10: 8] FunctNum
    471  1.1  kiyohara  *   [ 7: 2] RegNum
    472  1.1  kiyohara  *   [ 1: 0] reserved
    473  1.1  kiyohara  */
    474  1.1  kiyohara 
    475  1.1  kiyohara /* ARGSUSED */
    476  1.1  kiyohara int
    477  1.1  kiyohara mvpex_bus_maxdevs(void *v, int busno)
    478  1.1  kiyohara {
    479  1.1  kiyohara 
    480  1.1  kiyohara 	return 32;	/* 32 device/bus */
    481  1.1  kiyohara }
    482  1.1  kiyohara 
    483  1.1  kiyohara /* ARGSUSED */
    484  1.1  kiyohara pcitag_t
    485  1.1  kiyohara mvpex_make_tag(void *v, int bus, int dev, int func)
    486  1.1  kiyohara {
    487  1.1  kiyohara 
    488  1.1  kiyohara 	return (bus << 16) | (dev << 11) | (func << 8);
    489  1.1  kiyohara }
    490  1.1  kiyohara 
    491  1.1  kiyohara /* ARGSUSED */
    492  1.1  kiyohara void
    493  1.1  kiyohara mvpex_decompose_tag(void *v, pcitag_t tag, int *bp, int *dp, int *fp)
    494  1.1  kiyohara {
    495  1.1  kiyohara 
    496  1.1  kiyohara 	if (bp != NULL)
    497  1.1  kiyohara 		*bp = (tag >> 16) & 0xff;
    498  1.1  kiyohara 	if (dp != NULL)
    499  1.1  kiyohara 		*dp = (tag >> 11) & 0x1f;
    500  1.1  kiyohara 	if (fp != NULL)
    501  1.1  kiyohara 		*fp = (tag >> 8) & 0x07;
    502  1.1  kiyohara }
    503  1.1  kiyohara 
    504  1.1  kiyohara pcireg_t
    505  1.1  kiyohara mvpex_conf_read(void *v, pcitag_t tag, int reg)
    506  1.1  kiyohara {
    507  1.1  kiyohara 	struct mvpex_softc *sc = v;
    508  1.1  kiyohara 	pcireg_t addr, pci_cs;
    509  1.1  kiyohara 	uint32_t stat;
    510  1.1  kiyohara 	int bus, dev, func, pexbus, pexdev;
    511  1.1  kiyohara 
    512  1.1  kiyohara 	mvpex_decompose_tag(v, tag, &bus, &dev, &func);
    513  1.1  kiyohara 
    514  1.1  kiyohara 	stat = bus_space_read_4(sc->sc_iot, sc->sc_ioh, MVPEX_STAT);
    515  1.1  kiyohara 	pexbus = MVPEX_STAT_PEXBUSNUM(stat);
    516  1.1  kiyohara 	pexdev = MVPEX_STAT_PEXDEVNUM(stat);
    517  1.1  kiyohara 	if (bus != pexbus || dev != pexdev)
    518  1.1  kiyohara 		if (stat & MVPEX_STAT_DLDOWN)
    519  1.1  kiyohara 			return -1;
    520  1.1  kiyohara 
    521  1.1  kiyohara 	if (bus == pexbus) {
    522  1.1  kiyohara 		if (pexdev == 0) {
    523  1.1  kiyohara 			if (dev != 1 && dev != pexdev)
    524  1.1  kiyohara 				return -1;
    525  1.1  kiyohara 		} else {
    526  1.1  kiyohara 			if (dev != 0 && dev != pexdev)
    527  1.1  kiyohara 				return -1;
    528  1.1  kiyohara 		}
    529  1.1  kiyohara 		if (func != 0)
    530  1.1  kiyohara 			return -1;
    531  1.1  kiyohara 	}
    532  1.1  kiyohara 
    533  1.1  kiyohara 	addr = ((reg & 0xf00) << 24)  | tag | (reg & 0xfc);
    534  1.1  kiyohara 
    535  1.1  kiyohara 	bus_space_write_4(sc->sc_iot, sc->sc_ioh, MVPEX_CA,
    536  1.1  kiyohara 	    addr | MVPEX_CA_CONFIGEN);
    537  1.1  kiyohara 	if ((addr | MVPEX_CA_CONFIGEN) !=
    538  1.1  kiyohara 	    bus_space_read_4(sc->sc_iot, sc->sc_ioh, MVPEX_CA))
    539  1.1  kiyohara 		return -1;
    540  1.1  kiyohara 
    541  1.1  kiyohara 	pci_cs = bus_space_read_4(sc->sc_iot, sc->sc_ioh,
    542  1.1  kiyohara 	    PCI_COMMAND_STATUS_REG);
    543  1.1  kiyohara 	bus_space_write_4(sc->sc_iot, sc->sc_ioh,
    544  1.1  kiyohara 	    PCI_COMMAND_STATUS_REG, pci_cs | PCI_STATUS_MASTER_ABORT);
    545  1.1  kiyohara 
    546  1.1  kiyohara 	return bus_space_read_4(sc->sc_iot, sc->sc_ioh, MVPEX_CD);
    547  1.1  kiyohara }
    548  1.1  kiyohara 
    549  1.1  kiyohara void
    550  1.1  kiyohara mvpex_conf_write(void *v, pcitag_t tag, int reg, pcireg_t data)
    551  1.1  kiyohara {
    552  1.1  kiyohara 	struct mvpex_softc *sc = v;
    553  1.1  kiyohara 	pcireg_t addr;
    554  1.1  kiyohara 	uint32_t stat;
    555  1.1  kiyohara 	int bus, dev, func, pexbus, pexdev;
    556  1.1  kiyohara 
    557  1.1  kiyohara 	mvpex_decompose_tag(v, tag, &bus, &dev, &func);
    558  1.1  kiyohara 
    559  1.1  kiyohara 	stat = bus_space_read_4(sc->sc_iot, sc->sc_ioh, MVPEX_STAT);
    560  1.1  kiyohara 	pexbus = MVPEX_STAT_PEXBUSNUM(stat);
    561  1.1  kiyohara 	pexdev = MVPEX_STAT_PEXDEVNUM(stat);
    562  1.1  kiyohara 	if (bus != pexbus || dev != pexdev)
    563  1.1  kiyohara 		if (stat & MVPEX_STAT_DLDOWN)
    564  1.1  kiyohara 			return;
    565  1.1  kiyohara 
    566  1.1  kiyohara 	if (bus == pexbus) {
    567  1.1  kiyohara 		if (pexdev == 0) {
    568  1.1  kiyohara 			if (dev != 1 && dev != pexdev)
    569  1.1  kiyohara 				return;
    570  1.1  kiyohara 		} else {
    571  1.1  kiyohara 			if (dev != 0 && dev != pexdev)
    572  1.1  kiyohara 				return;
    573  1.1  kiyohara 		}
    574  1.1  kiyohara 		if (func != 0)
    575  1.1  kiyohara 			return;
    576  1.1  kiyohara 	}
    577  1.1  kiyohara 
    578  1.1  kiyohara 	addr = ((reg & 0xf00) << 24)  | tag | (reg & 0xfc);
    579  1.1  kiyohara 
    580  1.1  kiyohara 	bus_space_write_4(sc->sc_iot, sc->sc_ioh, MVPEX_CA,
    581  1.1  kiyohara 	    addr | MVPEX_CA_CONFIGEN);
    582  1.1  kiyohara 	if ((addr | MVPEX_CA_CONFIGEN) !=
    583  1.1  kiyohara 	    bus_space_read_4(sc->sc_iot, sc->sc_ioh, MVPEX_CA))
    584  1.1  kiyohara 		return;
    585  1.1  kiyohara 
    586  1.1  kiyohara 	bus_space_write_4(sc->sc_iot, sc->sc_ioh, MVPEX_CD, data);
    587  1.1  kiyohara }
    588  1.1  kiyohara 
    589  1.1  kiyohara /* ARGSUSED */
    590  1.1  kiyohara int
    591  1.1  kiyohara mvpex_conf_hook(pci_chipset_tag_t pc, int bus, int dev, int func, pcireg_t id)
    592  1.1  kiyohara {
    593  1.1  kiyohara 
    594  1.1  kiyohara 	if (bus == 0 && dev == 0)	/* don't configure GT */
    595  1.1  kiyohara 		return 0;
    596  1.1  kiyohara 
    597  1.1  kiyohara 	return PCI_CONF_DEFAULT;
    598  1.1  kiyohara }
    599  1.1  kiyohara 
    600  1.1  kiyohara int
    601  1.1  kiyohara mvpex_intr_map(struct pci_attach_args *pa, pci_intr_handle_t *ihp)
    602  1.1  kiyohara {
    603  1.1  kiyohara 
    604  1.1  kiyohara 	switch (pa->pa_intrpin) {
    605  1.1  kiyohara 	case PCI_INTERRUPT_PIN_A:
    606  1.1  kiyohara 	case PCI_INTERRUPT_PIN_B:
    607  1.1  kiyohara 	case PCI_INTERRUPT_PIN_C:
    608  1.1  kiyohara 	case PCI_INTERRUPT_PIN_D:
    609  1.1  kiyohara 		*ihp = pa->pa_intrpin;
    610  1.1  kiyohara 		return 0;
    611  1.1  kiyohara 	}
    612  1.1  kiyohara 	return -1;
    613  1.1  kiyohara }
    614  1.1  kiyohara 
    615  1.1  kiyohara /* ARGSUSED */
    616  1.1  kiyohara const char *
    617  1.1  kiyohara mvpex_intr_string(void *v, pci_intr_handle_t pin)
    618  1.1  kiyohara {
    619  1.1  kiyohara 	static char intrstr[32];
    620  1.1  kiyohara 
    621  1.1  kiyohara 	switch (pin) {
    622  1.1  kiyohara 	case PCI_INTERRUPT_PIN_A:
    623  1.1  kiyohara 	case PCI_INTERRUPT_PIN_B:
    624  1.1  kiyohara 	case PCI_INTERRUPT_PIN_C:
    625  1.1  kiyohara 	case PCI_INTERRUPT_PIN_D:
    626  1.1  kiyohara 		break;
    627  1.1  kiyohara 
    628  1.1  kiyohara 	default:
    629  1.1  kiyohara 		return NULL;
    630  1.1  kiyohara 	}
    631  1.1  kiyohara 	snprintf(intrstr, sizeof(intrstr), "interrupt pin INT%c#",
    632  1.1  kiyohara 	    (char)('A' - 1 + pin));
    633  1.1  kiyohara 
    634  1.1  kiyohara 	return intrstr;
    635  1.1  kiyohara }
    636  1.1  kiyohara 
    637  1.1  kiyohara /* ARGSUSED */
    638  1.1  kiyohara const struct evcnt *
    639  1.1  kiyohara mvpex_intr_evcnt(void *v, pci_intr_handle_t pin)
    640  1.1  kiyohara {
    641  1.1  kiyohara 
    642  1.1  kiyohara 	return NULL;
    643  1.1  kiyohara }
    644  1.1  kiyohara 
    645  1.1  kiyohara /*
    646  1.1  kiyohara  * XXXX: Shall these functions use mutex(9) instead of spl(9)?
    647  1.1  kiyohara  *       MV78200 and MV64360 and after supports SMP.
    648  1.1  kiyohara  */
    649  1.1  kiyohara 
    650  1.1  kiyohara /* ARGSUSED */
    651  1.1  kiyohara void *
    652  1.1  kiyohara mvpex_intr_establish(void *v, pci_intr_handle_t pin, int ipl,
    653  1.1  kiyohara 		     int (*intrhand)(void *), void *intrarg)
    654  1.1  kiyohara {
    655  1.1  kiyohara 	struct mvpex_softc *sc = (struct mvpex_softc *)v;
    656  1.1  kiyohara 	struct mvpex_intrtab *intrtab;
    657  1.1  kiyohara 	struct mvpex_intrhand *pexih;
    658  1.1  kiyohara 	uint32_t mask;
    659  1.1  kiyohara 	int ih = pin - 1, s;
    660  1.1  kiyohara 
    661  1.1  kiyohara 	intrtab = &sc->sc_intrtab[ih];
    662  1.1  kiyohara 
    663  1.1  kiyohara 	KASSERT(pin == intrtab->intr_pin);
    664  1.1  kiyohara 
    665  1.1  kiyohara 	pexih = malloc(sizeof(*pexih), M_DEVBUF, M_NOWAIT);
    666  1.1  kiyohara 	if (pexih == NULL)
    667  1.1  kiyohara 		return NULL;
    668  1.1  kiyohara 
    669  1.1  kiyohara 	pexih->ih_func = intrhand;
    670  1.1  kiyohara 	pexih->ih_arg = intrarg;
    671  1.1  kiyohara 	pexih->ih_type = ipl;
    672  1.1  kiyohara 	pexih->ih_intrtab = intrtab;
    673  1.1  kiyohara 	evcnt_attach_dynamic(&pexih->ih_evcnt, EVCNT_TYPE_INTR, NULL, "mvpex",
    674  1.1  kiyohara 	    mvpex_intr_string(v, pin));
    675  1.1  kiyohara 
    676  1.1  kiyohara 	s = splhigh();
    677  1.1  kiyohara 
    678  1.1  kiyohara 	/* First, link it into the tables. */
    679  1.1  kiyohara 	LIST_INSERT_HEAD(&intrtab->intr_list, pexih, ih_q);
    680  1.1  kiyohara 
    681  1.1  kiyohara 	/* Now enable it. */
    682  1.1  kiyohara 	if (intrtab->intr_refcnt++ == 0) {
    683  1.1  kiyohara 		mask = bus_space_read_4(sc->sc_iot, sc->sc_ioh, MVPEX_IM);
    684  1.1  kiyohara 		mask |= MVPEX_I_PIN(intrtab->intr_pin);
    685  1.1  kiyohara 		bus_space_write_4(sc->sc_iot, sc->sc_ioh, MVPEX_IM, mask);
    686  1.1  kiyohara 	}
    687  1.1  kiyohara 
    688  1.1  kiyohara 	splx(s);
    689  1.1  kiyohara 
    690  1.1  kiyohara 	return pexih;
    691  1.1  kiyohara }
    692  1.1  kiyohara 
    693  1.1  kiyohara void
    694  1.1  kiyohara mvpex_intr_disestablish(void *v, void *ih)
    695  1.1  kiyohara {
    696  1.1  kiyohara 	struct mvpex_softc *sc = (struct mvpex_softc *)v;
    697  1.1  kiyohara 	struct mvpex_intrtab *intrtab;
    698  1.1  kiyohara 	struct mvpex_intrhand *pexih = ih;
    699  1.1  kiyohara 	uint32_t mask;
    700  1.1  kiyohara 	int s;
    701  1.1  kiyohara 
    702  1.1  kiyohara 	intrtab = pexih->ih_intrtab;
    703  1.1  kiyohara 
    704  1.1  kiyohara 	s = splhigh();
    705  1.1  kiyohara 
    706  1.1  kiyohara 	/*
    707  1.1  kiyohara 	 * First, remove it from the table.
    708  1.1  kiyohara 	 */
    709  1.1  kiyohara 	LIST_REMOVE(pexih, ih_q);
    710  1.1  kiyohara 
    711  1.1  kiyohara 	/* Now, disable it, if there is nothing remaining on the list. */
    712  1.1  kiyohara 	if (intrtab->intr_refcnt-- == 1) {
    713  1.1  kiyohara 		mask = bus_space_read_4(sc->sc_iot, sc->sc_ioh, MVPEX_IM);
    714  1.1  kiyohara 		mask &= ~MVPEX_I_PIN(intrtab->intr_pin);
    715  1.1  kiyohara 		bus_space_write_4(sc->sc_iot, sc->sc_ioh, MVPEX_IM, mask);
    716  1.1  kiyohara 	}
    717  1.1  kiyohara 	splx(s);
    718  1.1  kiyohara 
    719  1.1  kiyohara 	free(pexih, M_DEVBUF);
    720  1.1  kiyohara }
    721  1.1  kiyohara #endif	/* NPCI > 0 */
    722