Home | History | Annotate | Line # | Download | only in vr
vrc4173bcu.c revision 1.1.4.1
      1  1.1.4.1  thorpej /*	$NetBSD: vrc4173bcu.c,v 1.1.4.1 2002/01/10 19:44:13 thorpej Exp $	*/
      2      1.1    enami 
      3      1.1    enami /*-
      4  1.1.4.1  thorpej  * Copyright (c) 2001,2002 Enami Tsugutomo.
      5      1.1    enami  * All rights reserved.
      6      1.1    enami  *
      7      1.1    enami  * Redistribution and use in source and binary forms, with or without
      8      1.1    enami  * modification, are permitted provided that the following conditions
      9      1.1    enami  * are met:
     10      1.1    enami  * 1. Redistributions of source code must retain the above copyright
     11      1.1    enami  *    notice, this list of conditions and the following disclaimer.
     12      1.1    enami  * 2. Redistributions in binary form must reproduce the above copyright
     13      1.1    enami  *    notice, this list of conditions and the following disclaimer in the
     14      1.1    enami  *    documentation and/or other materials provided with the distribution.
     15      1.1    enami  *
     16      1.1    enami  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     17      1.1    enami  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     18      1.1    enami  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     19      1.1    enami  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     20      1.1    enami  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     21      1.1    enami  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     22      1.1    enami  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     23      1.1    enami  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     24      1.1    enami  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     25      1.1    enami  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     26      1.1    enami  * SUCH DAMAGE.
     27      1.1    enami  */
     28      1.1    enami 
     29      1.1    enami #include <sys/param.h>
     30      1.1    enami #include <sys/systm.h>
     31      1.1    enami #include <sys/device.h>
     32      1.1    enami 
     33      1.1    enami #include <machine/bus.h>
     34      1.1    enami 
     35      1.1    enami #include <dev/pci/pcivar.h>
     36      1.1    enami #include <dev/pci/pcidevs.h>
     37      1.1    enami 
     38  1.1.4.1  thorpej #include <machine/platid.h>
     39  1.1.4.1  thorpej #include <machine/platid_mask.h>
     40  1.1.4.1  thorpej 
     41      1.1    enami #include <hpcmips/vr/vrc4173bcuvar.h>
     42      1.1    enami #include <hpcmips/vr/vrc4173icureg.h>
     43  1.1.4.1  thorpej #include <hpcmips/vr/vrc4173cmureg.h>
     44      1.1    enami 
     45      1.1    enami #define	VRC4173BCU_BADR		0x10
     46      1.1    enami #ifdef DEBUG
     47      1.1    enami #define	DPRINTF(args)	printf args
     48      1.1    enami #else
     49      1.1    enami #define	DPRINTF(args)
     50      1.1    enami #endif
     51      1.1    enami 
     52  1.1.4.1  thorpej #define USE_WINCE_CLKMASK	(~0)
     53  1.1.4.1  thorpej 
     54      1.1    enami static int	vrc4173bcu_match(struct device *, struct cfdata *, void *);
     55      1.1    enami static void	vrc4173bcu_attach(struct device *, struct device *, void *);
     56      1.1    enami static int	vrc4173bcu_print(void *, const char *);
     57      1.1    enami 
     58  1.1.4.1  thorpej /*
     59  1.1.4.1  thorpej  * machine dependent info
     60  1.1.4.1  thorpej  */
     61  1.1.4.1  thorpej static struct vrc4173bcu_platdep {
     62  1.1.4.1  thorpej 	platid_mask_t *platidmask;
     63  1.1.4.1  thorpej 	u_int32_t clkmask;
     64  1.1.4.1  thorpej 	int intr_port;	/* GPIO port to which VRCINT is connected to. XXX */
     65  1.1.4.1  thorpej } platdep_table[] = {
     66  1.1.4.1  thorpej 	{
     67  1.1.4.1  thorpej 		&platid_mask_MACH_VICTOR_INTERLINK_MPC303,
     68  1.1.4.1  thorpej 		USE_WINCE_CLKMASK,	/* clock mask */
     69  1.1.4.1  thorpej 		1,			/* intrrupt port# */
     70  1.1.4.1  thorpej 	},
     71  1.1.4.1  thorpej 	{
     72  1.1.4.1  thorpej 		&platid_mask_MACH_VICTOR_INTERLINK_MPC304,
     73  1.1.4.1  thorpej 		USE_WINCE_CLKMASK,	/* clock mask */
     74  1.1.4.1  thorpej 		1,			/* intrrupt port# */
     75  1.1.4.1  thorpej 	},
     76  1.1.4.1  thorpej 	{
     77  1.1.4.1  thorpej 		&platid_mask_MACH_NEC_MCR_SIGMARION2,
     78  1.1.4.1  thorpej 		USE_WINCE_CLKMASK,	/* clock mask */
     79  1.1.4.1  thorpej 		0,			/* intrrupt port# */
     80  1.1.4.1  thorpej 	},
     81  1.1.4.1  thorpej 	{
     82  1.1.4.1  thorpej 		&platid_wild,
     83  1.1.4.1  thorpej 		USE_WINCE_CLKMASK,	/* XXX */
     84  1.1.4.1  thorpej 		-1,
     85  1.1.4.1  thorpej 	},
     86  1.1.4.1  thorpej };
     87  1.1.4.1  thorpej 
     88  1.1.4.1  thorpej struct vrc4173bcu_softc {
     89  1.1.4.1  thorpej 	struct device sc_dev;
     90  1.1.4.1  thorpej 
     91  1.1.4.1  thorpej 	pci_chipset_tag_t sc_pc;
     92  1.1.4.1  thorpej 	bus_space_tag_t sc_iot;
     93  1.1.4.1  thorpej 	bus_space_handle_t sc_ioh;
     94  1.1.4.1  thorpej 	bus_size_t sc_size;
     95  1.1.4.1  thorpej 
     96  1.1.4.1  thorpej 	bus_space_handle_t sc_icuh;	/* I/O handle for ICU. */
     97  1.1.4.1  thorpej 	bus_space_handle_t sc_cmuh;	/* I/O handle for CMU. */
     98  1.1.4.1  thorpej 	void *sc_ih;
     99  1.1.4.1  thorpej 
    100  1.1.4.1  thorpej #define	VRC4173BCU_NINTRHAND	(16)	/* XXX */
    101  1.1.4.1  thorpej 	struct intrhand {
    102  1.1.4.1  thorpej 		int (*ih_func)(void *);
    103  1.1.4.1  thorpej 		void *ih_arg;
    104  1.1.4.1  thorpej 	} sc_intrhand[VRC4173BCU_NINTRHAND];
    105  1.1.4.1  thorpej 	int sc_intrmask;
    106  1.1.4.1  thorpej 
    107  1.1.4.1  thorpej 	struct vrc4173bcu_platdep *sc_platdep;
    108  1.1.4.1  thorpej };
    109      1.1    enami 
    110      1.1    enami struct cfattach vrc4173bcu_ca = {
    111      1.1    enami 	sizeof(struct vrc4173bcu_softc), vrc4173bcu_match, vrc4173bcu_attach,
    112      1.1    enami };
    113      1.1    enami 
    114      1.1    enami int
    115      1.1    enami vrc4173bcu_match(struct device *parent, struct cfdata *match, void *aux)
    116      1.1    enami {
    117      1.1    enami 	struct pci_attach_args *pa = (struct pci_attach_args *)aux;
    118      1.1    enami 
    119      1.1    enami 	if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_NEC &&
    120      1.1    enami 	    PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_NEC_VRC4173_BCU)
    121      1.1    enami 		return (1);
    122      1.1    enami 
    123      1.1    enami 	return (0);
    124      1.1    enami }
    125      1.1    enami 
    126      1.1    enami void
    127      1.1    enami vrc4173bcu_attach(struct device *parent, struct device *self, void *aux)
    128      1.1    enami {
    129      1.1    enami 	struct vrc4173bcu_softc *sc = (struct vrc4173bcu_softc *)self;
    130      1.1    enami 	struct pci_attach_args *pa = (struct pci_attach_args *)aux;
    131      1.1    enami 	pci_chipset_tag_t pc = pa->pa_pc;
    132      1.1    enami 	pcitag_t tag = pa->pa_tag;
    133      1.1    enami 	pcireg_t csr;
    134      1.1    enami 	char devinfo[256];
    135      1.1    enami 	int i;
    136  1.1.4.1  thorpej 	u_int16_t reg;
    137      1.1    enami #ifdef DEBUG
    138      1.1    enami 	char buf[80];
    139      1.1    enami #endif
    140      1.1    enami 
    141      1.1    enami 	pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo);
    142      1.1    enami 	printf(": %s (rev. 0x%02x)\n", devinfo, PCI_REVISION(pa->pa_class));
    143      1.1    enami 
    144      1.1    enami #if 0
    145      1.1    enami 	printf("%s: ", sc->sc_dev.dv_xname);
    146      1.1    enami 	pci_conf_print(pa->pa_pc, pa->pa_tag, NULL);
    147      1.1    enami #endif
    148      1.1    enami 
    149      1.1    enami 	csr = pci_conf_read(pc, tag, VRC4173BCU_BADR);
    150      1.1    enami 	DPRINTF(("%s: base addr = 0x%08x\n", sc->sc_dev.dv_xname, csr));
    151      1.1    enami 
    152  1.1.4.1  thorpej 	sc->sc_platdep = platid_search(&platid, platdep_table,
    153  1.1.4.1  thorpej 	    sizeof(platdep_table)/sizeof(*platdep_table),
    154  1.1.4.1  thorpej 	    sizeof(*platdep_table));
    155  1.1.4.1  thorpej 
    156      1.1    enami 	/* Map I/O registers */
    157      1.1    enami 	if (pci_mapreg_map(pa, VRC4173BCU_BADR, PCI_MAPREG_TYPE_IO, 0,
    158      1.1    enami 	    &sc->sc_iot, &sc->sc_ioh, NULL, &sc->sc_size)) {
    159      1.1    enami 		printf("%s: can't map mem space\n", sc->sc_dev.dv_xname);
    160      1.1    enami 		return;
    161      1.1    enami 	}
    162      1.1    enami 
    163      1.1    enami 	sc->sc_pc = pc;
    164      1.1    enami 
    165      1.1    enami 	/* Enable the device. */
    166      1.1    enami 	csr = pci_conf_read(pc, tag, PCI_COMMAND_STATUS_REG);
    167      1.1    enami 	DPRINTF(("%s: csr = 0x%08x", sc->sc_dev.dv_xname, csr));
    168      1.1    enami 	pci_conf_write(pc, tag, PCI_COMMAND_STATUS_REG,
    169      1.1    enami 	    csr | PCI_COMMAND_MASTER_ENABLE | PCI_COMMAND_IO_ENABLE);
    170      1.1    enami 	csr = pci_conf_read(pc, tag, PCI_COMMAND_STATUS_REG);
    171      1.1    enami 	DPRINTF((" -> 0x%08x\n", csr));
    172      1.1    enami 
    173      1.1    enami 	csr = pci_conf_read(pc, tag, VRC4173BCU_BADR);
    174      1.1    enami 	DPRINTF(("%s: base addr = %x@0x%08x\n", sc->sc_dev.dv_xname,
    175      1.1    enami 	    (int)sc->sc_size, csr));
    176      1.1    enami 	DPRINTF(("%s: iot = 0x%08x, ioh = 0x%08x\n", sc->sc_dev.dv_xname,
    177  1.1.4.1  thorpej 	    (int)sc->sc_iot, (int)sc->sc_ioh));
    178      1.1    enami 
    179      1.1    enami 	/*
    180      1.1    enami 	 * Map I/O space for ICU.
    181      1.1    enami 	 */
    182      1.1    enami 	if (bus_space_subregion(sc->sc_iot, sc->sc_ioh,
    183      1.1    enami 	    VRC4173ICU_IOBASE, VRC4173ICU_IOSIZE, &sc->sc_icuh)) {
    184      1.1    enami 		printf(": can't map ICU i/o space\n");
    185      1.1    enami 		return;
    186      1.1    enami 	}
    187      1.1    enami 
    188  1.1.4.1  thorpej 	/*
    189  1.1.4.1  thorpej 	 * Map I/O space for CMU.
    190  1.1.4.1  thorpej 	 */
    191  1.1.4.1  thorpej 	if (bus_space_subregion(sc->sc_iot, sc->sc_ioh,
    192  1.1.4.1  thorpej 	    VRC4173CMU_IOBASE, VRC4173CMU_IOSIZE, &sc->sc_cmuh)) {
    193  1.1.4.1  thorpej 		printf(": can't map CMU i/o space\n");
    194  1.1.4.1  thorpej 		return;
    195  1.1.4.1  thorpej 	}
    196  1.1.4.1  thorpej 
    197  1.1.4.1  thorpej 	/* machine dependent setup */
    198  1.1.4.1  thorpej 	if (sc->sc_platdep->clkmask == USE_WINCE_CLKMASK) {
    199  1.1.4.1  thorpej 		/* XXX, You can nothing! */
    200  1.1.4.1  thorpej 		reg = bus_space_read_2(sc->sc_iot, sc->sc_cmuh,
    201  1.1.4.1  thorpej 		    VRC4173CMU_CLKMSK);
    202  1.1.4.1  thorpej 		printf("%s: default clock mask is %04x\n",
    203  1.1.4.1  thorpej 		    sc->sc_dev.dv_xname, reg);
    204  1.1.4.1  thorpej 	} else {
    205  1.1.4.1  thorpej 		/* assert all reset bits */
    206  1.1.4.1  thorpej 		bus_space_write_2(sc->sc_iot, sc->sc_cmuh, VRC4173CMU_SRST,
    207  1.1.4.1  thorpej 		    VRC4173CMU_SRST_AC97 | VRC4173CMU_SRST_USB |
    208  1.1.4.1  thorpej 		    VRC4173CMU_SRST_CARD2 | VRC4173CMU_SRST_CARD1);
    209  1.1.4.1  thorpej 		/* set clock mask */
    210  1.1.4.1  thorpej 		bus_space_write_2(sc->sc_iot, sc->sc_cmuh,
    211  1.1.4.1  thorpej 		    VRC4173CMU_CLKMSK, sc->sc_platdep->clkmask);
    212  1.1.4.1  thorpej 		/* clear reset bit */
    213  1.1.4.1  thorpej 		bus_space_write_2(sc->sc_iot, sc->sc_cmuh, VRC4173CMU_SRST, 0);
    214  1.1.4.1  thorpej 	}
    215  1.1.4.1  thorpej 
    216      1.1    enami #ifdef DEBUG
    217      1.1    enami 	reg = bus_space_read_2(sc->sc_iot, sc->sc_icuh, VRC4173ICU_SYSINT1);
    218      1.1    enami 	bitmask_snprintf(reg,
    219      1.1    enami 	    "\20\1USB\2PCMCIA2\3PCMCIA1\4PS2CH2\5PS2CH1\6PIU\7AIU\10KIU"
    220      1.1    enami 	    "\11GIU\12AC97\13AC97-1\14B11\15B12\16DOZEPIU\17B14\20B15",
    221      1.1    enami 	    buf, sizeof(buf));
    222      1.1    enami 	printf("%s: SYSINT1 = 0x%s\n", sc->sc_dev.dv_xname, buf);
    223      1.1    enami 
    224      1.1    enami 	reg = bus_space_read_2(sc->sc_iot, sc->sc_icuh, VRC4173ICU_MKIUINT);
    225      1.1    enami 	bitmask_snprintf(reg,
    226      1.1    enami 	    "\20\1SCANINT\2KDATRDY\3KDATLOST\4B3\5B4\6B5\7B6\10B7"
    227      1.1    enami 	    "\11B8\12B9\13B10\14B11\15B12\16B13\17B14\20B15",
    228      1.1    enami 	    buf, sizeof(buf));
    229      1.1    enami 	printf("%s: MKIUINT = 0x%s\n", sc->sc_dev.dv_xname, buf);
    230      1.1    enami 
    231      1.1    enami 	reg = bus_space_read_2(sc->sc_iot, sc->sc_icuh, VRC4173ICU_MSYSINT1);
    232      1.1    enami 	bitmask_snprintf(reg,
    233      1.1    enami 	    "\20\1USB\2PCMCIA2\3PCMCIA1\4PS2CH2\5PS2CH1\6PIU\7AIU\10KIU"
    234      1.1    enami 	    "\11GIU\12AC97\13AC97-1\14B11\15B12\16DOZEPIU\17B14\20B15",
    235      1.1    enami 	    buf, sizeof(buf));
    236      1.1    enami 	printf("%s: MSYSINT1 = 0x%s\n", sc->sc_dev.dv_xname, buf);
    237      1.1    enami 
    238      1.1    enami #if 1
    239      1.1    enami 	reg = VRC4173ICU_USBINTR | VRC4173ICU_PIUINTR | VRC4173ICU_KIUINTR |
    240      1.1    enami 	    VRC4173ICU_DOZEPIUINTR;
    241      1.1    enami 	bus_space_write_2(sc->sc_iot, sc->sc_icuh, VRC4173ICU_MSYSINT1, reg);
    242      1.1    enami 
    243      1.1    enami 	reg = bus_space_read_2(sc->sc_iot, sc->sc_icuh, VRC4173ICU_MSYSINT1);
    244      1.1    enami 	bitmask_snprintf(reg,
    245      1.1    enami 	    "\20\1USB\2PCMCIA2\3PCMCIA1\4PS2CH2\5PS2CH1\6PIU\7AIU\10KIU"
    246      1.1    enami 	    "\11GIU\12AC97\13AC97-1\14B11\15B12\16DOZEPIU\17B14\20B15",
    247      1.1    enami 	    buf, sizeof(buf));
    248      1.1    enami 	printf("%s: MSYSINT1 = 0x%s\n", sc->sc_dev.dv_xname, buf);
    249      1.1    enami #endif
    250      1.1    enami #endif
    251      1.1    enami 
    252      1.1    enami 	for (i = 0; i < VRC4173BCU_NINTRHAND; i++)
    253      1.1    enami 		sc->sc_intrhand[i].ih_func = NULL;
    254  1.1.4.1  thorpej 	sc->sc_intrmask = 0;
    255  1.1.4.1  thorpej 	bus_space_write_2(sc->sc_iot, sc->sc_icuh, VRC4173ICU_MSYSINT1,
    256  1.1.4.1  thorpej 	    sc->sc_intrmask);
    257      1.1    enami 
    258      1.1    enami 	/*
    259      1.1    enami 	 * Attach sub units found in vrc4173.  XXX.
    260      1.1    enami 	 */
    261      1.1    enami 	config_found(self, "vrc4173cmu", vrc4173bcu_print);
    262      1.1    enami 	config_found(self, "vrc4173giu", vrc4173bcu_print);
    263      1.1    enami 	config_found(self, "vrc4173piu", vrc4173bcu_print);
    264      1.1    enami 	config_found(self, "vrc4173kiu", vrc4173bcu_print);
    265      1.1    enami 	config_found(self, "vrc4173aiu", vrc4173bcu_print);
    266      1.1    enami 	config_found(self, "vrc4173ps2u", vrc4173bcu_print);
    267      1.1    enami 
    268      1.1    enami 	/*
    269      1.1    enami 	 * Establish VRCINT interrupt.  Normally connected to one of
    270      1.1    enami 	 * GPIO pin in VR41xx.  XXX.
    271      1.1    enami 	 */
    272  1.1.4.1  thorpej 	if (0 <= sc->sc_platdep->intr_port) {
    273  1.1.4.1  thorpej 		sc->sc_ih = pci_vrcintr_establish(pc,
    274  1.1.4.1  thorpej 		    sc->sc_platdep->intr_port, vrc4173bcu_intr, sc);
    275  1.1.4.1  thorpej 		if (sc->sc_ih != NULL)
    276  1.1.4.1  thorpej 			printf("%s: interrupting at %p\n", sc->sc_dev.dv_xname,
    277  1.1.4.1  thorpej 			    sc->sc_ih);
    278  1.1.4.1  thorpej 	} else {
    279  1.1.4.1  thorpej 		printf("%s: interrupt port isn't specified\n",
    280  1.1.4.1  thorpej 		    sc->sc_dev.dv_xname);
    281  1.1.4.1  thorpej 	}
    282      1.1    enami }
    283      1.1    enami 
    284      1.1    enami int
    285      1.1    enami vrc4173bcu_print(void *aux, const char *pnp)
    286      1.1    enami {
    287      1.1    enami 	const char *name = aux;
    288      1.1    enami 
    289      1.1    enami 	if (pnp)
    290      1.1    enami 		printf("%s at %s", name, pnp);
    291      1.1    enami 
    292      1.1    enami 	return (UNCONF);
    293      1.1    enami }
    294      1.1    enami 
    295      1.1    enami int
    296      1.1    enami vrc4173bcu_intr(void *arg)
    297      1.1    enami {
    298      1.1    enami 	struct vrc4173bcu_softc *sc = (struct vrc4173bcu_softc *)arg;
    299      1.1    enami 	struct intrhand *ih;
    300      1.1    enami 	u_int16_t reg;
    301      1.1    enami 	int i, handled;
    302      1.1    enami 
    303      1.1    enami 	reg = bus_space_read_2(sc->sc_iot, sc->sc_icuh, VRC4173ICU_SYSINT1);
    304      1.1    enami 	if (reg == 0)
    305      1.1    enami 		return (0);
    306      1.1    enami 
    307      1.1    enami #if 0
    308      1.1    enami     {
    309      1.1    enami 	char buf[80];
    310      1.1    enami 	bitmask_snprintf(reg,
    311      1.1    enami 	    "\20\1USB\2PCMCIA2\3PCMCIA1\4PS2CH2\5PS2CH1\6PIU\7AIU\10KIU"
    312      1.1    enami 	    "\11GIU\12AC97\13AC97-1\14B11\15B12\16DOZEPIU\17B14\20B15",
    313      1.1    enami 	    buf, sizeof(buf));
    314      1.1    enami 	printf("%s: %s\n", sc->sc_dev.dv_xname, buf);
    315      1.1    enami     }
    316      1.1    enami #endif
    317      1.1    enami 	for (handled = i = 0; i < VRC4173BCU_NINTRHAND; i++) {
    318      1.1    enami 		ih = &sc->sc_intrhand[i];
    319      1.1    enami 		if (ih->ih_func != NULL && (reg & (1 << i)) != 0) {
    320      1.1    enami 			handled = 1;
    321      1.1    enami 			(*ih->ih_func)(ih->ih_arg);
    322      1.1    enami 		}
    323      1.1    enami 	}
    324      1.1    enami 
    325      1.1    enami 	return (handled);
    326      1.1    enami }
    327      1.1    enami 
    328      1.1    enami void *
    329      1.1    enami vrc4173bcu_intr_establish(struct vrc4173bcu_softc *sc, int kind,
    330      1.1    enami     int (*func)(void *), void *arg)
    331      1.1    enami {
    332      1.1    enami 	struct intrhand *ih;
    333      1.1    enami 
    334      1.1    enami 	DPRINTF(("vrc4173bcu_intr_establish: %d, %p, %p\n", kind, func, arg));
    335      1.1    enami 	if (kind < 0 || kind >= VRC4173BCU_NINTRHAND)
    336      1.1    enami 		return (NULL);
    337      1.1    enami 
    338      1.1    enami 	ih = &sc->sc_intrhand[kind];
    339      1.1    enami 	if (ih->ih_func != NULL)
    340      1.1    enami 		return (NULL);
    341      1.1    enami 
    342      1.1    enami 	ih->ih_func = func;
    343      1.1    enami 	ih->ih_arg = arg;
    344  1.1.4.1  thorpej 	sc->sc_intrmask |= (1 << kind);
    345  1.1.4.1  thorpej 	bus_space_write_2(sc->sc_iot, sc->sc_icuh, VRC4173ICU_MSYSINT1,
    346  1.1.4.1  thorpej 	    sc->sc_intrmask);
    347  1.1.4.1  thorpej 
    348      1.1    enami 	return (ih);
    349      1.1    enami }
    350      1.1    enami 
    351      1.1    enami void
    352      1.1    enami vrc4173bcu_intr_disestablish(struct vrc4173bcu_softc *sc, void *ihp)
    353      1.1    enami {
    354      1.1    enami 	struct intrhand *ih = ihp;
    355      1.1    enami 
    356      1.1    enami 	if (ih < &sc->sc_intrhand[0] ||
    357      1.1    enami 	    ih >= &sc->sc_intrhand[VRC4173BCU_NINTRHAND])
    358      1.1    enami 		return;
    359      1.1    enami 
    360      1.1    enami 	ih->ih_func = NULL;
    361  1.1.4.1  thorpej 	sc->sc_intrmask &= ~(1 << (ih - &sc->sc_intrhand[0]));
    362  1.1.4.1  thorpej 	bus_space_write_2(sc->sc_iot, sc->sc_icuh, VRC4173ICU_MSYSINT1,
    363  1.1.4.1  thorpej 	    sc->sc_intrmask);
    364      1.1    enami }
    365      1.1    enami 
    366      1.1    enami int
    367      1.1    enami vrc4173bcu_pci_intr_map(struct pci_attach_args *pa, pci_intr_handle_t *ihp)
    368      1.1    enami {
    369      1.1    enami 	pci_chipset_tag_t pc = pa->pa_pc;
    370      1.1    enami 	pcitag_t intrtag = pa->pa_intrtag;
    371      1.1    enami 	int bus, dev, func;
    372      1.1    enami #ifdef DEBUG
    373      1.1    enami 	int line = pa->pa_intrline;
    374      1.1    enami 	int pin = pa->pa_intrpin;
    375      1.1    enami #endif
    376      1.1    enami 
    377      1.1    enami 	pci_decompose_tag(pc, intrtag, &bus, &dev, &func);
    378      1.1    enami 	DPRINTF(("%s(%d, %d, %d): line = %d, pin = %d\n", pc->pc_dev->dv_xname,
    379      1.1    enami 	    bus, dev, func, line, pin));
    380      1.1    enami 
    381      1.1    enami 	*ihp = -1;
    382      1.1    enami 	switch (dev) {
    383      1.1    enami 	case 1:				/* CARDU0 */
    384      1.1    enami 		*ihp = VRC4173ICU_PCMCIA1INTR;
    385      1.1    enami 		break;
    386      1.1    enami 	case 2:				/* CARDU1 */
    387      1.1    enami 		*ihp = VRC4173ICU_PCMCIA2INTR;
    388      1.1    enami 		break;
    389  1.1.4.1  thorpej 	case 12:			/* VRC4173 (SigmarionII) */
    390  1.1.4.1  thorpej 	case 19:			/* VRC4173 (MP-C303) */
    391      1.1    enami 		switch (func) {
    392      1.1    enami 		case 2:
    393      1.1    enami 			*ihp = VRC4173ICU_USBINTR;
    394      1.1    enami 			break;
    395      1.1    enami 		}
    396      1.1    enami 		break;
    397      1.1    enami 	}
    398      1.1    enami 
    399      1.1    enami 	return (*ihp == -1);
    400      1.1    enami }
    401      1.1    enami 
    402      1.1    enami const char *
    403      1.1    enami vrc4173bcu_pci_intr_string(pci_chipset_tag_t pc, pci_intr_handle_t ih)
    404      1.1    enami {
    405      1.1    enami 	static char irqstr[8 + sizeof("vrc4173 intr")];
    406      1.1    enami 
    407      1.1    enami 	snprintf(irqstr, sizeof(irqstr), "vrc4173 intr %d", (int)ih);
    408      1.1    enami 	return (irqstr);
    409      1.1    enami }
    410      1.1    enami 
    411      1.1    enami const struct evcnt *
    412      1.1    enami vrc4173bcu_pci_intr_evcnt(pci_chipset_tag_t pc, pci_intr_handle_t ih)
    413      1.1    enami {
    414      1.1    enami 
    415      1.1    enami 	/* XXX for now, no evcnt parent reported */
    416      1.1    enami 	return (NULL);
    417      1.1    enami }
    418      1.1    enami 
    419